Created
February 9, 2019 20:18
-
-
Save bstro/05a27810465e20f884d528c678e85a05 to your computer and use it in GitHub Desktop.
parser.elm
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
parseStep : List Int -> Parser (Step (List Int) (List Int)) | |
parseStep acc = | |
oneOf | |
[ end |> map (\_ -> Done (List.reverse acc)) | |
, chompWhile Char.isDigit | |
|> getChompedString | |
|> andThen | |
(\s -> | |
case String.toInt s of | |
Just n -> | |
succeed <| Loop (n :: acc) | |
Nothing -> | |
problem "Not a number" | |
) | |
, symbol "." | |
|> andThen (\_ -> succeed <| Loop acc) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment