aboutsummaryrefslogtreecommitdiff
path: root/aoc-2020-gleam/src/days/day02.gleam
diff options
context:
space:
mode:
authorTomasz Chojnacki <tomaszchojnacki2001@gmail.com>2023-02-02 14:37:06 +0100
committerTomasz Chojnacki <tomaszchojnacki2001@gmail.com>2023-02-02 14:37:06 +0100
commita5b3eff4b14e3d84a9f5f5f73dc6df4be34cd27d (patch)
tree82d425d24b2138b1ead68cbc3775eafb6ff2310e /aoc-2020-gleam/src/days/day02.gleam
parent673fb853b227313ee574096591135aee713f4100 (diff)
downloadgleam_aoc2020-a5b3eff4b14e3d84a9f5f5f73dc6df4be34cd27d.tar.gz
gleam_aoc2020-a5b3eff4b14e3d84a9f5f5f73dc6df4be34cd27d.zip
Add labels to parsers
Diffstat (limited to 'aoc-2020-gleam/src/days/day02.gleam')
-rw-r--r--aoc-2020-gleam/src/days/day02.gleam4
1 files changed, 3 insertions, 1 deletions
diff --git a/aoc-2020-gleam/src/days/day02.gleam b/aoc-2020-gleam/src/days/day02.gleam
index ba6d9f1..c4dd751 100644
--- a/aoc-2020-gleam/src/days/day02.gleam
+++ b/aoc-2020-gleam/src/days/day02.gleam
@@ -43,13 +43,15 @@ fn parse_line(string: String) -> Line {
|> p.then_third(p.any_grapheme())
|> p.then_skip(p.string_literal(": "))
|> p.map3(with: fn(min, max, grapheme) { Policy(min, max, grapheme) })
+ |> p.labeled(with: "policy")
- let password_parser = p.any_string()
+ let password_parser = p.labeled(p.any_string(), with: "password")
let line_parser =
policy_parser
|> p.then(password_parser)
|> p.map2(fn(policy, password) { Line(policy, password) })
+ |> p.labeled(with: "line")
assert Ok(policy) = p.parse_entire(string, with: line_parser)
policy