Created
November 3, 2025 09:12
-
-
Save chrisdone-artificial/67ad39fcd61ee5e1fd19aadcc774ff9e to your computer and use it in GitHub Desktop.
enumerate-dates.hell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Opts = Opts { | |
| startDate :: Text, | |
| step :: Text | |
| } | |
| options = | |
| (\startDate step -> Main.Opts { startDate, step }) | |
| <$> Options.strOption (Option.long "start-date" <> Option.help "Starting date in 2025-01-24 format.") | |
| <*> Options.strOption (Option.long "step" <> Option.help "How many days to add each line.") | |
| main = do | |
| opts <- Options.execParser (Options.info (Main.options <**> Options.helper) Options.fullDesc) | |
| date <- Maybe.maybe (Error.error "Bad ISO date.") IO.pure (Day.iso8601ParseM (Record.get @"startDate" opts)) | |
| step <- Maybe.maybe (Error.error "Bad step.") IO.pure (Int.readMaybe (Record.get @"step" opts)) | |
| let dates = List.iterate' (Day.addDays $ Int.toInteger step) date | |
| Monad.forM_ (List.take 10 dates) \date -> Text.putStrLn $ Show.show date | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| chris@linux:~$ hell enumerate-dates.hell --start-date 2025-11-07 --step 1 | |
| 2025-11-07 | |
| 2025-11-08 | |
| 2025-11-09 | |
| 2025-11-10 | |
| 2025-11-11 | |
| 2025-11-12 | |
| 2025-11-13 | |
| 2025-11-14 | |
| 2025-11-15 | |
| 2025-11-16 | |
| chris@linux:~$ hell enumerate-dates.hell --start-date 2025-11-07 --step 7 | |
| 2025-11-07 | |
| 2025-11-14 | |
| 2025-11-21 | |
| 2025-11-28 | |
| 2025-12-05 | |
| 2025-12-12 | |
| 2025-12-19 | |
| 2025-12-26 | |
| 2026-01-02 | |
| 2026-01-09 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment