Portability  ghc 

Stability  beta 
Maintainer  Neil Sculthorpe <neil@ittc.ku.edu> 
Safe Haskell  SafeInferred 
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 arr => CategoryCatch arr where
 (<+) :: CategoryCatch arr => arr a b > arr a b > arr a b
 readerT :: ArrowApply arr => (a > arr a b) > arr a b
 acceptR :: (CategoryCatch arr, ArrowApply arr) => (a > Bool) > String > arr a a
 accepterR :: (CategoryCatch arr, ArrowApply arr) => arr a Bool > String > arr a a
 tryR :: CategoryCatch arr => arr a a > arr a a
 attemptR :: (CategoryCatch arr, Arrow arr) => arr a a > arr a (Bool, a)
 changedR :: (CategoryCatch arr, ArrowApply arr, Eq a) => arr a a > arr a a
 repeatR :: CategoryCatch arr => arr a a > arr a a
 (>+>) :: (CategoryCatch arr, ArrowApply arr) => arr a a > arr a a > arr a a
 orR :: (CategoryCatch arr, ArrowApply arr) => [arr a a] > arr a a
 andR :: Category arr => [arr a a] > arr a a
 catchesT :: CategoryCatch arr => [arr a b] > arr a b
 result :: Arrow arr => (b > c) > arr a b > arr a c
 argument :: Arrow arr => (a > b) > arr b c > arr a c
 toFst :: Arrow arr => arr a b > arr (a, x) b
 toSnd :: Arrow arr => arr a b > arr (x, a) b
 swap :: Arrow arr => arr (a, b) (b, a)
 fork :: Arrow arr => arr a (a, a)
 forkFirst :: Arrow arr => arr a b > arr a (b, a)
 forkSecond :: Arrow arr => arr a b > arr a (a, b)
 constant :: Arrow arr => b > arr a b
Monad Combinators
Monads with a Catch
class Monad m => MonadCatch m whereSource
MonadCatch KureMonad 

(Monad (Translate c m a), 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 arr => CategoryCatch arr whereSource
Category
s with failure and catching.
The following law is expected to hold:
failT msg `catchT` f == f msg
failT :: String > arr a bSource
The failing Category
.
catchT :: arr a b > (String > arr a b) > arr a bSource
A catch on Category
s.
(Category (Lens c m), MonadCatch m) => CategoryCatch (Lens c m)  A 
(Category (Translate c m), MonadCatch m) => CategoryCatch (Translate c m)  The 
(<+) :: CategoryCatch arr => arr a b > arr a b > arr a bSource
Leftbiased choice.
readerT :: ArrowApply arr => (a > arr a b) > arr a bSource
acceptR :: (CategoryCatch arr, ArrowApply arr) => (a > Bool) > String > arr a aSource
Look at the argument to an Arrow
, and choose to be either the identity arrow or a failure.
accepterR :: (CategoryCatch arr, ArrowApply arr) => arr a Bool > String > arr a aSource
tryR :: CategoryCatch arr => arr a a > arr a aSource
Catch a failing CategoryCatch
, making it into an identity.
attemptR :: (CategoryCatch arr, Arrow arr) => arr a a > arr a (Bool, a)Source
changedR :: (CategoryCatch arr, ArrowApply arr, Eq a) => arr a a > arr a aSource
Makes an Arrow
fail if the result value equals the argument value.
repeatR :: CategoryCatch arr => arr a a > arr a aSource
Repeat a CategoryCatch
until it fails, then return the result before the failure.
Requires at least the first attempt to succeed.
(>+>) :: (CategoryCatch arr, ArrowApply arr) => arr a a > arr a a > arr a aSource
Attempt two Arrow
s in sequence, succeeding if one or both succeed.
orR :: (CategoryCatch arr, ArrowApply arr) => [arr a a] > arr a aSource
Sequence a list of Arrow
s, succeeding if any succeed.
andR :: Category arr => [arr a a] > arr a aSource
Sequence a list of Category
s, succeeding if all succeed.
catchesT :: CategoryCatch arr => [arr a b] > arr a bSource
Select the first CategoryCatch
that succeeds, discarding any thereafter.
Basic Routing
result :: Arrow arr => (b > c) > arr a b > arr a cSource
Apply a pure function to the result of an Arrow
.
argument :: Arrow arr => (a > b) > arr b c > arr a cSource
Apply a pure function to the argument to an Arrow
.
toFst :: Arrow arr => arr a b > arr (a, x) bSource
Apply an Arrow
to the first element of a pair, discarding the second element.
toSnd :: Arrow arr => arr a b > arr (x, a) bSource
Apply an Arrow
to the second element of a pair, discarding the first element.
forkFirst :: Arrow arr => arr a b > arr a (b, a)Source
Tag the result of an Arrow
with its argument.
forkSecond :: Arrow arr => arr a b > arr a (a, b)Source
Tag the result of an Arrow
with its argument.