Skip to content

Instantly share code, notes, and snippets.

@moxuse
Created May 15, 2019 06:01
Show Gist options
  • Save moxuse/042af1bd5e87ebca948fe395b08bf39f to your computer and use it in GitHub Desktop.
Save moxuse/042af1bd5e87ebca948fe395b08bf39f to your computer and use it in GitHub Desktop.
Error Reporting
isReasonableAge : String -> Result String Int
isReasonableAge input =
case String.toInt input of
Nothing ->
Err "That is not a number!"
Just age ->
if age < 0 then
Err "Please try again after you are born."
else if age > 135 then
Err "Are you some kind of turtle?"
else
Ok age
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment