Portability  ghc 

Stability  beta 
Maintainer  Neil Sculthorpe <neil@ittc.ku.edu> 
Safe Haskell  SafeInfered 
This module provides various monadic and arrow combinators that are particularly useful when working with translations.
 class Monad m => MonadCatch m where
 (<<+) :: MonadCatch m => m a > m a > m a
 catchesM :: MonadCatch m => [m a] > m a
 tryM :: MonadCatch m => a > m a > m a
 mtryM :: (MonadCatch m, Monoid a) => m a > m a
 attemptM :: MonadCatch m => m a > m (Either String a)
 testM :: MonadCatch m => m a > m Bool
 notM :: MonadCatch m => m a > m ()
 modFailMsg :: MonadCatch m => (String > String) > m a > m a
 setFailMsg :: MonadCatch m => String > m a > m a
 prefixFailMsg :: MonadCatch m => String > m a > m a
 withPatFailMsg :: MonadCatch m => String > m a > m a
 guardMsg :: Monad m => Bool > String > m ()
 guardM :: Monad m => Bool > m ()
 ifM :: Monad m => m Bool > m a > m a > m a
 whenM :: Monad m => m Bool > m a > m a
 unlessM :: Monad m => m Bool > m a > m a
 class Category ~> => CategoryCatch (~>) where
 (<+) :: CategoryCatch ~> => (a ~> b) > (a ~> b) > a ~> b
 readerT :: ArrowApply ~> => (a > a ~> b) > a ~> b
 acceptR :: (CategoryCatch ~>, ArrowApply ~>) => (a > Bool) > String > a ~> a
 accepterR :: (CategoryCatch ~>, ArrowApply ~>) => (a ~> Bool) > String > a ~> a
 tryR :: CategoryCatch ~> => (a ~> a) > a ~> a
 attemptR :: (CategoryCatch ~>, Arrow ~>) => (a ~> a) > a ~> (Bool, a)
 changedR :: (CategoryCatch ~>, ArrowApply ~>, Eq a) => (a ~> a) > a ~> a
 repeatR :: CategoryCatch ~> => (a ~> a) > a ~> a
 (>+>) :: (CategoryCatch ~>, ArrowApply ~>) => (a ~> a) > (a ~> a) > a ~> a
 orR :: (CategoryCatch ~>, ArrowApply ~>) => [a ~> a] > a ~> a
 andR :: Category ~> => [a ~> a] > a ~> a
 catchesT :: CategoryCatch ~> => [a ~> b] > a ~> b
 result :: Arrow ~> => (b > c) > (a ~> b) > a ~> c
 argument :: Arrow ~> => (a > b) > (b ~> c) > a ~> c
 toFst :: Arrow ~> => (a ~> b) > (a, x) ~> b
 toSnd :: Arrow ~> => (a ~> b) > (x, a) ~> b
 swap :: Arrow ~> => (a, b) ~> (b, a)
 fork :: Arrow ~> => a ~> (a, a)
 forkFirst :: Arrow ~> => (a ~> b) > a ~> (b, a)
 forkSecond :: Arrow ~> => (a ~> b) > a ~> (a, b)
 constant :: Arrow ~> => b > a ~> b
Monad Combinators
Monads with a Catch
class Monad m => MonadCatch m whereSource
MonadCatch KureMonad 

MonadCatch m => MonadCatch (Translate c m a)  Lifting through a Reader transformer, where (c,a) is the readonly environment. 
(<<+) :: MonadCatch m => m a > m a > m aSource
A monadic catch that ignores the error message.
catchesM :: MonadCatch m => [m a] > m aSource
Select the first monadic computation that succeeds, discarding any thereafter.
tryM :: MonadCatch m => a > m a > m aSource
Catch a failing monadic computation, making it succeed with a constant value.
mtryM :: (MonadCatch m, Monoid a) => m a > m aSource
Catch a failing monadic computation, making it succeed with mempty
.
attemptM :: MonadCatch m => m a > m (Either String a)Source
Catch a failing monadic computation, making it succeed with an error message.
testM :: MonadCatch m => m a > m BoolSource
Determine if a monadic computation succeeds.
notM :: MonadCatch m => m a > m ()Source
Fail if the Monad
succeeds; succeed with ()
if it fails.
modFailMsg :: MonadCatch m => (String > String) > m a > m aSource
Modify the error message of a failing monadic computation. Successful computations are unaffected.
setFailMsg :: MonadCatch m => String > m a > m aSource
Set the error message of a failing monadic computation. Successful computations are unaffected.
prefixFailMsg :: MonadCatch m => String > m a > m aSource
Add a prefix to the error message of a failing monadic computation. Successful computations are unaffected.
withPatFailMsg :: MonadCatch m => String > m a > m aSource
Use the given error message whenever a monadic pattern match failure occurs.
Conditionals
whenM :: Monad m => m Bool > m a > m aSource
If the monadic predicate holds then perform the monadic action, else fail.
unlessM :: Monad m => m Bool > m a > m aSource
If the monadic predicate holds then fail, else perform the monadic action.
Arrow Combinators
Categories with a Catch
class Category ~> => CategoryCatch (~>) whereSource
Category
s with failure and catching.
The following law is expected to hold:
failT msg `catchT` f == f msg
failT :: String > a ~> bSource
The failing Category
.
catchT :: (a ~> b) > (String > a ~> b) > a ~> bSource
A catch on Category
s.
MonadCatch m => CategoryCatch (Lens c m)  A 
MonadCatch m => CategoryCatch (Translate c m)  The 
(<+) :: CategoryCatch ~> => (a ~> b) > (a ~> b) > a ~> bSource
Leftbiased choice.
readerT :: ArrowApply ~> => (a > a ~> b) > a ~> bSource
acceptR :: (CategoryCatch ~>, ArrowApply ~>) => (a > Bool) > String > a ~> aSource
Look at the argument to an Arrow
, and choose to be either the identity arrow or a failure.
accepterR :: (CategoryCatch ~>, ArrowApply ~>) => (a ~> Bool) > String > a ~> aSource
tryR :: CategoryCatch ~> => (a ~> a) > a ~> aSource
Catch a failing CategoryCatch
, making it into an identity.
attemptR :: (CategoryCatch ~>, Arrow ~>) => (a ~> a) > a ~> (Bool, a)Source
changedR :: (CategoryCatch ~>, ArrowApply ~>, Eq a) => (a ~> a) > a ~> aSource
Makes an Arrow
fail if the result value equals the argument value.
repeatR :: CategoryCatch ~> => (a ~> a) > a ~> aSource
Repeat a CategoryCatch
until it fails, then return the result before the failure.
Requires at least the first attempt to succeed.
(>+>) :: (CategoryCatch ~>, ArrowApply ~>) => (a ~> a) > (a ~> a) > a ~> aSource
Attempt two Arrow
s in sequence, succeeding if one or both succeed.
orR :: (CategoryCatch ~>, ArrowApply ~>) => [a ~> a] > a ~> aSource
Sequence a list of Arrow
s, succeeding if any succeed.
andR :: Category ~> => [a ~> a] > a ~> aSource
Sequence a list of Category
s, succeeding if all succeed.
catchesT :: CategoryCatch ~> => [a ~> b] > a ~> bSource
Select the first CategoryCatch
that succeeds, discarding any thereafter.
Basic Routing
result :: Arrow ~> => (b > c) > (a ~> b) > a ~> cSource
Apply a pure function to the result of an Arrow
.
argument :: Arrow ~> => (a > b) > (b ~> c) > a ~> cSource
Apply a pure function to the argument to an Arrow
.
toFst :: Arrow ~> => (a ~> b) > (a, x) ~> bSource
Apply an Arrow
to the first element of a pair, discarding the second element.
toSnd :: Arrow ~> => (a ~> b) > (x, a) ~> bSource
Apply an Arrow
to the second element of a pair, discarding the first element.
forkSecond :: Arrow ~> => (a ~> b) > a ~> (a, b)Source
Tag the result of an Arrow
with its argument.