Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.rb Secret

Last active June 12, 2018 13:23
Show Gist options
  • Save dminuoso/cc021f7ba9ea9748333ab47e2d6203cc to your computer and use it in GitHub Desktop.
Save dminuoso/cc021f7ba9ea9748333ab47e2d6203cc to your computer and use it in GitHub Desktop.
# Non-deterministic choice between two parsers
# choice :: Parser a -> Parser a -> Parser a
choice = -> parser1, parser 2 { ... }.curry
# Enhance a parser to possibly fail
# maybe :: Parser a -> Parser (a + nil)
maybe = -> parser { ... }
# Sequence two parsers
# sequence :: Parser a -> Parser b -> Parser b
sequence = -> parser { ... }
# Runs one parser, feeds the result into the function, and then runs the resulting parser.
# bind :: Parser a -> (a -> Parser b) -> Parser b
bind = -> parser, kf { ... }.curry
# Repeats a parser n times and returns all results packed into an array.
# repeat :: Int -> Parser a -> Parser [a]
repeat = -> n, parser { ... }.curry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment