Skip to content

Instantly share code, notes, and snippets.

@bstro
Created February 9, 2019 20:18
Show Gist options
  • Save bstro/05a27810465e20f884d528c678e85a05 to your computer and use it in GitHub Desktop.
Save bstro/05a27810465e20f884d528c678e85a05 to your computer and use it in GitHub Desktop.
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