Skip to content

Commit

Permalink
🎨 refactor map to use generics
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelvalley committed Jul 19, 2024
1 parent 3652da3 commit 3eaf642
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/parz/combinators.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub fn map(parser: Parser(a), transform) {
fn(input) {
case parser(input) {
Error(err) -> Error(err)
Ok(ok) -> Ok(#(transform(ok.matched), ok.remaining))
Ok(ok) -> Ok(ParserState(transform(ok.matched), ok.remaining))
}
}
}
4 changes: 2 additions & 2 deletions test/combinators_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ pub fn map_test() {

run(parser, "[hello]")
|> should.be_ok
|> should.equal(#(Content("[hello]"), ""))
|> should.equal(ParserState(Content("[hello]"), ""))

run(parser, "[hello]x")
|> should.be_ok
|> should.equal(#(Content("[hello]"), "x"))
|> should.equal(ParserState(Content("[hello]"), "x"))

run(parser, "[hellox")
|> should.be_error
Expand Down

0 comments on commit 3eaf642

Please sign in to comment.