Created
September 10, 2013 16:02
-
-
Save anonymous/6511606 to your computer and use it in GitHub Desktop.
Yoba
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
module Main where | |
import qualified Control.Exception as E | |
import Data.Data (Typeable) | |
data MyYobaException a = MyYobaException a deriving (Show, Typeable) | |
data Huy = Huy deriving (Show, Typeable) | |
data Pizda = Pizda deriving (Show, Typeable) | |
instance (Show a, Typeable a) => E.Exception (MyYobaException a) | |
main :: IO () | |
main = do | |
catcher $ E.throwIO (MyYobaException Huy) | |
catcher $ E.throwIO (MyYobaException Pizda) | |
catcher :: IO () -> IO () | |
catcher io = | |
io `E.catches` | |
[ E.Handler (\(_ :: MyYobaException Huy) -> print "Huy") | |
, E.Handler (\(_ :: MyYobaException Pizda) -> print "Pizda") | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment