diff options
author | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-02-02 14:37:06 +0100 |
---|---|---|
committer | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-02-02 14:37:06 +0100 |
commit | a5b3eff4b14e3d84a9f5f5f73dc6df4be34cd27d (patch) | |
tree | 82d425d24b2138b1ead68cbc3775eafb6ff2310e /aoc-2020-gleam/src/days | |
parent | 673fb853b227313ee574096591135aee713f4100 (diff) | |
download | gleam_aoc2020-a5b3eff4b14e3d84a9f5f5f73dc6df4be34cd27d.tar.gz gleam_aoc2020-a5b3eff4b14e3d84a9f5f5f73dc6df4be34cd27d.zip |
Add labels to parsers
Diffstat (limited to 'aoc-2020-gleam/src/days')
-rw-r--r-- | aoc-2020-gleam/src/days/day02.gleam | 4 |
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 |