Skip to content

Instantly share code, notes, and snippets.

Created September 10, 2013 16:02
Show Gist options
  • Save anonymous/6511606 to your computer and use it in GitHub Desktop.
Save anonymous/6511606 to your computer and use it in GitHub Desktop.
Yoba
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