module Err where type E a = Maybe a unitE :: a -> E a unitE a = Just a bindE :: E a -> (a -> E b) -> E b (Just a) `bindE` k = k a Nothing `bindE` k = Nothing tryE :: E a -> E a -> E a tryE (Just v) h = Just v tryE Nothing h = h failE :: String -> E a failE _ = Nothing