simple-effects-0.7.0.1: A simple effect system that integrates with MTL

Safe HaskellNone
LanguageHaskell2010

Control.Effects.Early

Synopsis

Documentation

data Early a Source #

Instances

(Monad m, (~) * a b) => MonadEffect (Early a) (ExceptT (Early b) m) Source # 

Methods

effect :: proxy (Early a) -> EffectMsg (Early a) -> ExceptT (Early b) m (EffectRes (Early a)) Source #

type EffectRes (Early a) Source # 
type EffectRes (Early a) = Void
type EffectMsg (Early a) Source # 
type EffectMsg (Early a) = a

earlyReturn :: forall a b m. MonadEffect (Early a) m => a -> m b Source #

Allows you to return early from a function. Make sure you handleEarly to get the actual result out.

handleEarly :: Monad m => ExceptT (Early a) m a -> m a Source #

Get the result from a computation. Either the early returned one, or the regular result.

onlyDo :: MonadEffect (Early a) m => m a -> m b Source #

Only do the given action and exit early with it's result.

ifNothingEarlyReturn :: MonadEffect (Early a) m => a -> Maybe b -> m b Source #

Early return the given value if the Maybe is Nothing. Otherwise, contnue with the value inside of it.

ifNothingDo :: MonadEffect (Early a) m => m a -> Maybe b -> m b Source #

Only do the given action and early return with it's result if the given value is Nothing. Otherwise continue with the value inside of the Maybe.

ifLeftEarlyReturn :: MonadEffect (Early c) m => (a -> c) -> Either a b -> m b Source #

If the value is a Left, get the value, process it and early return the result. Otherwise just return the Right value.

ifLeftDo :: MonadEffect (Early c) m => (a -> m c) -> Either a b -> m b Source #

If the value is a Left, get the value, process it and only do the resulting action. Otherwise just return the Right value.