Created
October 23, 2018 17:45
-
-
Save dariooddenino/6a2d7b2891401baca6a56540764252f7 to your computer and use it in GitHub Desktop.
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
-- let's ignore negative inputs | |
sub1 :: Int -> Int | |
sub1 0 = throw $ SomeException 0 | |
sub1 n = n - 1 | |
countDown :: Int -> IO Int | |
countDown n = countDown (sub1 n) `catch` \(SomeException n') -> pure n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment