mirror of
https://git.nerfingen.de/nerf/choirMail.git
synced 2025-06-08 09:41:00 +00:00
some minor code cleanup
This commit is contained in:
parent
5c203e5a95
commit
72e53eea4f
3 changed files with 17 additions and 8 deletions
12
app/Monad.hs
12
app/Monad.hs
|
@ -3,6 +3,8 @@ module Monad(
|
|||
App
|
||||
,module Control.Monad.Fail
|
||||
,module Control.Monad.IO.Class
|
||||
,handleE
|
||||
,catchE
|
||||
,throwE
|
||||
,except
|
||||
,runApp
|
||||
|
@ -29,6 +31,16 @@ instance MonadFail App where
|
|||
throwE :: String -> App a
|
||||
throwE = App . T.throwE
|
||||
|
||||
catchE :: App a -> (String -> App a) -> App a
|
||||
catchE a f = do
|
||||
result <- liftIO $ runApp a
|
||||
case result of
|
||||
Left err -> f err
|
||||
Right res -> return res
|
||||
|
||||
handleE :: (String -> App a) -> App a -> App a
|
||||
handleE = flip catchE
|
||||
|
||||
except :: Either String a -> App a
|
||||
except = App . T.except
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue