Skip to content

Instantly share code, notes, and snippets.

@khibino
Created May 31, 2017 03:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khibino/f17211facd7f254264f818595d788401 to your computer and use it in GitHub Desktop.
Save khibino/f17211facd7f254264f818595d788401 to your computer and use it in GitHub Desktop.
type Parser a = String -> [(a, String)]
return_ :: a -> Parser a
return_ v = \inp -> [(v, inp)]
failure :: Parser a
failure = \inp -> []
item = \inp -> case inp of
[] -> []
(x:xs) -> [(x,xs)]
parse :: Parser a -> String -> [(a, String)]
parse p inp = p inp
@khibino
Copy link
Author

khibino commented May 31, 2017

example code of "programming haskell".

executing in ghci

parse (return_ 1) "abc"
parse failure "abc"
parse item "abc"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment