diff --git a/src/parz/combinators.gleam b/src/parz/combinators.gleam index b6556a8..9bfd626 100644 --- a/src/parz/combinators.gleam +++ b/src/parz/combinators.gleam @@ -122,19 +122,8 @@ pub fn many(parser: Parser(a)) { } } -pub fn concat(parser: Parser(List(a)), merge) { - fn(input) { - case parser(input) { - Error(err) -> Error(err) - Ok(ok) -> { - Ok(ParserState(merge(ok.matched), ok.remaining)) - } - } - } -} - pub fn concat_str(parser) { - concat(parser, string.concat) + map(parser, string.concat) } pub fn label_error(parser, message) { diff --git a/test/combinators_test.gleam b/test/combinators_test.gleam index c3ddb3d..dcdea84 100644 --- a/test/combinators_test.gleam +++ b/test/combinators_test.gleam @@ -1,8 +1,8 @@ import gleeunit/should import parz.{run} import parz/combinators.{ - between, choice, concat, concat_str, label_error, left, many, many1, map, - maybe, right, sequence, + between, choice, concat_str, label_error, left, many, many1, map, maybe, right, + sequence, } import parz/parsers.{letters, str} import parz/types.{ParserState} @@ -132,7 +132,7 @@ pub fn sequence_test() { |> should.be_error } -pub fn concat_test() { +pub fn concat_str_test() { let parser = concat_str(sequence([str("["), letters(), str("]")])) run(parser, "[hello]")