License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
fused-effect utilities for Swarm.
Synopsis
- withThrow :: Has (Throw e2) sig m => (e1 -> e2) -> ThrowC e1 m a -> m a
- throwToMaybe :: forall e m a. Functor m => ThrowC e m a -> m (Maybe a)
- throwToWarning :: Has (Accum (Seq e)) sig m => ThrowC e m a -> m (Maybe a)
- ignoreWarnings :: forall e m a. (Monoid e, Functor m) => AccumC e m a -> m a
- asExceptT :: ThrowC e m a -> ExceptT e m a
- warn :: Has (Accum (Seq w)) sig m => w -> m ()
- traverseW :: (Has (Accum (Seq w)) sig m, Witherable t) => (a -> m (Either w b)) -> t a -> m (t b)
- forMW :: (Has (Accum (Seq w)) sig m, Witherable t) => t a -> (a -> m (Either w b)) -> m (t b)
- simpleErrorHandle :: ThrowC SystemFailure IO a -> IO a
Documentation
withThrow :: Has (Throw e2) sig m => (e1 -> e2) -> ThrowC e1 m a -> m a Source #
Transform a Throw e1
constraint into a Throw e2
constraint,
by supplying an adapter function of type (e1 -> e2)
.
throwToMaybe :: forall e m a. Functor m => ThrowC e m a -> m (Maybe a) Source #
Transform a Throw e
constrint into a concrete Maybe
,
discarding the error.
throwToWarning :: Has (Accum (Seq e)) sig m => ThrowC e m a -> m (Maybe a) Source #
Transform a Throw e
constrint into a concrete Maybe
,
logging any error as a warning.
ignoreWarnings :: forall e m a. (Monoid e, Functor m) => AccumC e m a -> m a Source #
Run a computation with an Accum
effect (typically accumulating
a list of warnings), ignoring the accumulated value.
asExceptT :: ThrowC e m a -> ExceptT e m a Source #
Convert a fused-effects style computation using a Throw e
constraint into an ExceptT
computation. This is mostly a stub
to convert from one style to the other while we are in the middle
of incrementally converting. Eventually this should not be needed.
traverseW :: (Has (Accum (Seq w)) sig m, Witherable t) => (a -> m (Either w b)) -> t a -> m (t b) Source #
A version of traverse
/mapM
that also accumulates warnings.
Note that we can't generalize this to work over any Traversable
because it also needs to have a notion of "filtering".
Witherable
provides exactly the right abstraction.
forMW :: (Has (Accum (Seq w)) sig m, Witherable t) => t a -> (a -> m (Either w b)) -> m (t b) Source #
Flipped version of traverseW
for convenience.
simpleErrorHandle :: ThrowC SystemFailure IO a -> IO a Source #