diff options
author | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-04-05 21:18:32 +0200 |
---|---|---|
committer | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-04-05 21:18:32 +0200 |
commit | feb51c3a6e7eb8a7ac3fa22ac5d12d20e84eb65f (patch) | |
tree | 3272bdb35d4f9f76c612f3198b1e94a945e54c71 /aoc-2020-gleam/src/util | |
parent | 4ecfe6624434f15f3ac00142f7a3c4d78bfab3a1 (diff) | |
download | gleam_aoc2020-feb51c3a6e7eb8a7ac3fa22ac5d12d20e84eb65f.tar.gz gleam_aoc2020-feb51c3a6e7eb8a7ac3fa22ac5d12d20e84eb65f.zip |
Use new module running and remove the runner
Diffstat (limited to 'aoc-2020-gleam/src/util')
-rw-r--r-- | aoc-2020-gleam/src/util/runner.gleam | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/aoc-2020-gleam/src/util/runner.gleam b/aoc-2020-gleam/src/util/runner.gleam deleted file mode 100644 index 938f5b3..0000000 --- a/aoc-2020-gleam/src/util/runner.gleam +++ /dev/null @@ -1,32 +0,0 @@ -import gleam/list -import gleam/int -import gleam/io -import gleam/result as res -import gleam/erlang.{start_arguments} - -fn get_day(handler: fn(Int) -> Nil) -> Result(Nil, String) { - let args = start_arguments() - - use first <- res.then( - args - |> list.first() - |> res.replace_error("Pass the day as first argument!"), - ) - - use day <- res.then( - first - |> int.parse() - |> res.replace_error("The day argument must be a number!"), - ) - - handler(day) - - Ok(Nil) -} - -pub fn with_day(handler: fn(Int) -> Nil) -> Nil { - handler - |> get_day - |> res.map_error(io.println) - |> res.unwrap(or: Nil) -} |