Skip to content

Conversation

@vincent-botbol
Copy link
Contributor

@vincent-botbol vincent-botbol commented Oct 22, 2025

This PR fixes a few typos on the stdlib and refactor + add functions, namely (en/fr):

  • In List:
    • List.reverse / List.inverse
  • In Date:
    • month_to_int => month_to_integer (en only)
    • MonthOfYear/MoisDansAnnée => MonthYear/MoisAnnée + a bunch utility functions
  • In Period:
    • smart-constructors:
      • from_month_and_year/depuis_mois_et_année
      • from_year/depuis_année
    • overlap/chevauche predicate
    • cover/englobe predicate
    • is_(before|after)/est_(avant|après) predicates.

Sister PR: CatalaLang/catala-book#24

Copy link
Contributor

@denismerigoux denismerigoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much @vincent-botbol ! The CI is still not green and I put some polish suggestions below, but we're close :)


## Transforms a `MonthYear` into a `date` by choosing the first day of the
## month.
declaration to_first_day_of_month
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we decide to move these functions into their own MonthYear module ? Because right now this function is called with the syntax Date.to_first_day_of_month, which is confusing to read because it does not mention that the argument is a MonthYear.

Comment on lines 226 to 229
## Returns `true` if the date occurs after the first day of the given month (included).
## **Example:** `is_after_the_first_day_of_month of may_2025, |2025-06-15| = true`
## **Example:** `is_after_the_first_day_of_month of may_2025, |2025-05-01| = true`
## **Example:** `is_after_the_first_day_of_month of may_2025, |2025-04-30| = false`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/CatalaLang/catala/blob/master/stdlib/README.md this should rather be :

## Returns `true` if the date occurs after the first day of the given month (included).
## **Examples:** 
## * `is_after_the_first_day_of_month of may_2025, |2025-06-15| = true`
## * `is_after_the_first_day_of_month of may_2025, |2025-05-01| = true`
## * `is_after_the_first_day_of_month of may_2025, |2025-04-30| = false`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same above and below

## **Example**: `sequence of 3, 6` is the list `[3; 4; 5]`
## **Edge-case**: if `end <= begin`, the returned list is empty
## **Example:** `sequence of 3, 6 = [3; 4; 5]`
## **Edge-case**: if `end <= begin`, the returned list is empty.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/CatalaLang/catala/blob/master/stdlib/README.md we decided to remove the **Edge-case** item and simply put the edge case description in the main message describing the goal of the function and how it does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants