Skip to content

Instantly share code, notes, and snippets.

@dariooddenino
Created October 23, 2018 17:45
Show Gist options
  • Save dariooddenino/6a2d7b2891401baca6a56540764252f7 to your computer and use it in GitHub Desktop.
Save dariooddenino/6a2d7b2891401baca6a56540764252f7 to your computer and use it in GitHub Desktop.
-- 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