dunai-0.3.0.0: Generalised reactive framework supporting classic, arrowized and monadic FRP.

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Trans.MSF.Maybe

Contents

Description

The Maybe monad is very versatile. It can stand for default arguments, for absent values, and for (nondescript) exceptions. The latter viewpoint is most natural in the context of MSFs.

Synopsis

Throwing Nothing as an exception ("exiting")

exit :: Monad m => MSF (MaybeT m) a b Source #

Throw the exception immediately.

exitWhen :: Monad m => (a -> Bool) -> MSF (MaybeT m) a a Source #

Throw the exception when the condition becomes true on the input.

exitIf :: Monad m => MSF (MaybeT m) Bool () Source #

Exit when the incoming value is True.

maybeExit :: Monad m => MSF (MaybeT m) (Maybe a) a Source #

Just a is passed along, Nothing causes the whole MSF to exit.

inMaybeT :: Monad m => MSF (MaybeT m) (Maybe a) a Source #

Embed a Maybe value in the MaybeT layer. Identical to maybeExit.

Catching Maybe exceptions

untilMaybe :: Monad m => MSF m a b -> MSF m b Bool -> MSF (MaybeT m) a b Source #

Run the first msf until the second one produces True from the output of the first.

catchMaybe :: Monad m => MSF (MaybeT m) a b -> MSF m a b -> MSF m a b Source #

When an exception occurs in the first msf, the second msf is executed from there.

Converting to and from MaybeT

listToMaybeS :: Monad m => [b] -> MSF (MaybeT m) a b Source #

Converts a list to an MSF in MaybeT, which outputs an element of the list at each step, throwing Nothing when the list ends.

Running MaybeT

runMaybeS :: Monad m => MSF (MaybeT m) a b -> MSF m a (Maybe b) Source #

Remove the MaybeT layer by outputting Nothing when the exception occurs. The continuation in which the exception occurred is then tested on the next input.

runMaybeS'' :: Monad m => MSF (MaybeT m) a b -> MSF m a (Maybe b) Source #

Different implementation, to study performance.