Created
May 15, 2019 06:01
-
-
Save moxuse/042af1bd5e87ebca948fe395b08bf39f to your computer and use it in GitHub Desktop.
Error Reporting
This file contains hidden or 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
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