Last active
October 27, 2016 16:09
-
-
Save stevekane/51e038a59c5b9aa357ecb4a4f5611203 to your computer and use it in GitHub Desktop.
Monadic parsers in Typescript/Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parse_int = | |
then(or(match('-'), of('')), => s | |
then(many(isNumber), => digits | |
of(Number(s + digits)))) | |
/* | |
in ML-style lang, this might look like this: | |
parse_int = do | |
s <- match '-' <|> unit '' | |
digits <- many number | |
Number(s + digits) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment