4751N/ADescription : ResultT type and a monadic transformer instance
4751N/ACopyright : (c) T. Mossakowski, C. Maeder, Uni Bremen 2006
4751N/AMaintainer : Christian.Maeder@dfki.de
4751N/A'ResultT' type and a monadic transformer instance
4751N/Anewtype ResultT m a = ResultT { runResultT :: m (Result a) }
4751N/Ainstance Monad m => Functor (ResultT m) where
4751N/Ainstance Monad m => Applicative (ResultT m) where
4751N/Ainstance Monad m => Monad (ResultT m) where
4751N/A return = ResultT . return . return
4751N/A r@(Result e v) <- runResultT m
4751N/A Nothing -> return $ Result e Nothing
4751N/A fail = ResultT . return . fail
4751N/Ainstance MonadTrans ResultT where
4751N/A-- | Inspired by the MonadIO-class
4751N/Aclass Monad m => MonadResult m where
4751N/Ainstance Monad m => MonadResult (ResultT m) where
4751N/Ainstance MonadIO m => MonadIO (ResultT m) where
4751N/A liftIO = ResultT . liftM return . liftIO