Control.Monad.Nope
- Package
- purescript-jsinc
- Repository
- david-sledge/purescript-jsinc
#Nope Source
type Nope = MaybeT IdentityA parametrizable nope monad; computations are either nopes or
pure values. If a computation is noped (see nope), it
terminates. Nopes may also be caught with yup,
allowing the computation to resume and exit successfully.
The type parameter a is the type of successful results.
A mechanism for trying many different computations until one succeeds is
provided via the Alt instance, specifically the (<|>) function.
The first computation to succeed is returned. The Plus instance is the same.
Re-exports from Control.Monad.Maybe.Trans
#MaybeT Source
newtype MaybeT :: (Type -> Type) -> Type -> Typenewtype MaybeT m a
The MaybeT monad transformer.
This monad transformer extends the base monad, supporting failure and alternation via
the MonadPlus type class.
Instances
Newtype (MaybeT m a) _(Functor m) => Functor (MaybeT m)(Monad m) => Apply (MaybeT m)(Monad m) => Applicative (MaybeT m)(Monad m) => Bind (MaybeT m)(Monad m) => Monad (MaybeT m)MonadTrans MaybeT(Monad m) => Alt (MaybeT m)(Monad m) => Plus (MaybeT m)(Monad m) => Alternative (MaybeT m)(Monad m) => MonadPlus (MaybeT m)(MonadRec m) => MonadRec (MaybeT m)(MonadEffect m) => MonadEffect (MaybeT m)(MonadCont m) => MonadCont (MaybeT m)(MonadThrow e m) => MonadThrow e (MaybeT m)(MonadError e m) => MonadError e (MaybeT m)(MonadAsk r m) => MonadAsk r (MaybeT m)(MonadReader r m) => MonadReader r (MaybeT m)(MonadState s m) => MonadState s (MaybeT m)(MonadTell w m) => MonadTell w (MaybeT m)(MonadWriter w m) => MonadWriter w (MaybeT m)(Monad m, Semigroup a) => Semigroup (MaybeT m a)(Monad m, Monoid a) => Monoid (MaybeT m a)(MonadST s m) => MonadST s (MaybeT m)
Re-exports from Control.Monad.Nope.Class
#MonadNope Source
class MonadNope :: (Type -> Type) -> Constraintclass (MonadNuhUh m) <= MonadNope m where
The MonadNope type class represents those monads which support catching
nopes.
yup x hcalls the nope handlerhif a nope is thrown during the evaluation ofx.
An implementation is provided for MaybeT, and for other monad transformers
defined in this library.
Laws:
- Catch:
yup nope h = h - Pure:
yup (pure a) h = pure a
Members
yup :: forall a. m a -> m a -> m a
Instances
#MonadNuhUh Source
class MonadNuhUh :: (Type -> Type) -> Constraintclass (Monad m) <= MonadNuhUh m where
The MonadNuhUh type class represents those monads which support Nothing via
nope, where nope halts.
An implementation is provided for MaybeT, (TODO) and for other monad transformers
defined in this library.
Laws:
- Left zero:
nope >>= h = nope
Members
nope :: forall a. m a
Instances
(Monad m) => MonadNuhUh (MaybeT m)(MonadNuhUh m) => MonadNuhUh (ExceptT e m)(MonadNuhUh m) => MonadNuhUh (IdentityT m)(MonadNuhUh m) => MonadNuhUh (ReaderT r m)(MonadNuhUh m) => MonadNuhUh (StateT s m)(Monoid w, MonadNuhUh m) => MonadNuhUh (WriterT w m)MonadNuhUh Maybe
#withResource Source
withResource :: forall m r a. MonadNope m => m r -> (r -> m Unit) -> (r -> m a) -> m aMake sure that a resource is cleaned up in the event of a nope. The release action is called regardless of whether the body action nopes or returns.
#liftMaybe Source
liftMaybe :: forall m a. MonadNuhUh m => Maybe a -> m aLift a Maybe value to a MonadNuhUh monad.