Skip to content

Instantly share code, notes, and snippets.

@bstro
Created Feb 9, 2019
Embed
What would you like to do?
parser.elm
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