From 5746dbca0ddaef455b6f26fba3945f3533d0b2c1 Mon Sep 17 00:00:00 2001 From: Tomasz Chojnacki Date: Wed, 22 Feb 2023 13:34:58 +0100 Subject: Add aliases to long imports --- aoc-2020-gleam/src/util/runner.gleam | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'aoc-2020-gleam/src/util/runner.gleam') diff --git a/aoc-2020-gleam/src/util/runner.gleam b/aoc-2020-gleam/src/util/runner.gleam index 0ff0a41..938f5b3 100644 --- a/aoc-2020-gleam/src/util/runner.gleam +++ b/aoc-2020-gleam/src/util/runner.gleam @@ -1,22 +1,22 @@ import gleam/list import gleam/int import gleam/io -import gleam/result +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 <- result.then( + use first <- res.then( args |> list.first() - |> result.replace_error("Pass the day as first argument!"), + |> res.replace_error("Pass the day as first argument!"), ) - use day <- result.then( + use day <- res.then( first |> int.parse() - |> result.replace_error("The day argument must be a number!"), + |> res.replace_error("The day argument must be a number!"), ) handler(day) @@ -26,7 +26,7 @@ fn get_day(handler: fn(Int) -> Nil) -> Result(Nil, String) { pub fn with_day(handler: fn(Int) -> Nil) -> Nil { handler - |> get_day() - |> result.map_error(io.println) - |> result.unwrap(Nil) + |> get_day + |> res.map_error(io.println) + |> res.unwrap(or: Nil) } -- cgit v1.2.3