Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Fail a
- pattern Fail :: forall a. String -> Fail a
- isFail :: Fail a -> Bool
- isOk :: Fail a -> Bool
- newtype FailT m a = FailT (m (Fail a))
- runFailT :: FailT m a -> m (Fail a)
- type FIO a = FailT IO a
- failEitherStr :: Either String a -> Fail a
- failEitherShow :: Show a => Either a b -> Fail b
- failEitherText :: Either Text a -> Fail a
- runExceptTFail :: Monad m => ExceptT String m a -> m (Fail a)
- failInM :: Monad m => Fail a -> m a
- failInM' :: Monad m => Fail a -> (String -> String) -> m a
- failInM'' :: Monad m => String -> Fail a -> m a
- failToEither :: Fail a -> Either String a
- failMaybe :: String -> Maybe a -> Fail a
- failToMaybe :: Fail a -> Maybe a
- mapFail :: (String -> String) -> Fail a -> Fail a
- failSwitch :: (String -> c) -> (a -> c) -> Fail a -> c
- fromFail :: (String -> a) -> Fail a -> a
- class MonadFail m => MonadFailure m where
- failForIOException :: IO a -> IO (Fail a)
- catFails :: [Fail a] -> [a]
- eitherToError :: MonadError e m => Either e a -> m a
- errorToEither :: MonadError e m => m a -> m (Either e a)
- liftError :: (MonadError e m, MonadError e m1) => (forall a. m a -> m1 a) -> m a -> m1 a
- errorToDefault :: MonadError e m => a -> m a -> m a
- errorToMaybe :: MonadError e m => m a -> m (Maybe a)
- maybeToError :: MonadError e m => String -> Maybe a -> m a
- runError :: forall a. (forall m. Monad m => m a) -> Either String a
- runExceptTorFail :: (Monad m, Show e) => ExceptT e m a -> m a
- maybeToFail :: Monad m => String -> Maybe a -> m a
- eitherToFail :: Monad m => Either String a -> m a
- fromFailString :: Fail a -> Maybe String
- partitionFails :: [Fail a] -> ([a], [String])
- safeFromOk :: HasCallStack => Fail a -> a
- class Monad m => MonadFail m
Documentation
failToMaybe :: Fail a -> Maybe a Source #
failSwitch :: (String -> c) -> (a -> c) -> Fail a -> c Source #
class MonadFail m => MonadFailure m where Source #
catchFailure :: m a -> (String -> m a) -> m a Source #
MonadFailure Maybe Source # | |
MonadFailure IO Source # | |
MonadFailure Fail Source # | |
Monad m => MonadFailure (FailT m) Source # | |
(MonadFail (ReaderT * r m), MonadFailure m) => MonadFailure (ReaderT * r m) Source # | |
eitherToError :: MonadError e m => Either e a -> m a Source #
errorToEither :: MonadError e m => m a -> m (Either e a) Source #
liftError :: (MonadError e m, MonadError e m1) => (forall a. m a -> m1 a) -> m a -> m1 a Source #
errorToDefault :: MonadError e m => a -> m a -> m a Source #
errorToMaybe :: MonadError e m => m a -> m (Maybe a) Source #
maybeToError :: MonadError e m => String -> Maybe a -> m a Source #
partitionFails :: [Fail a] -> ([a], [String]) Source #
safeFromOk :: HasCallStack => Fail a -> a Source #
class Monad m => MonadFail m #
When a value is bound in do
-notation, the pattern on the left
hand side of <-
might not match. In this case, this class
provides a function to recover.
A Monad
without a MonadFail
instance may only be used in conjunction
with pattern that always match, such as newtypes, tuples, data types with
only a single data constructor, and irrefutable patterns (~pat
).
Instances of MonadFail
should satisfy the following law: fail s
should
be a left zero for >>=
,
fail s >>= f = fail s
If your Monad
is also MonadPlus
, a popular definition is
fail _ = mzero
Since: 4.9.0.0
MonadFail [] | |
MonadFail Maybe | |
MonadFail IO | |
MonadFail Q | |
MonadFail IResult | |
MonadFail Result | |
MonadFail Parser | |
MonadFail P | |
MonadFail ReadPrec | |
MonadFail ReadP | |
MonadFail StrictList # | |
MonadFail Option # | |
MonadFail Vector # | |
MonadFail (Parser i) | |
Monad m => MonadFail (ListT m) | |
Monad m => MonadFail (MaybeT m) | |
Monad m => MonadFail (OptionT m) # | |
(Monoid w, MonadFail m) => MonadFail (WriterT w m) | |
MonadFail m => MonadFail (StateT s m) | |
MonadFail m => MonadFail (ExceptT e m) | |
(Monad m, Error e) => MonadFail (ErrorT e m) | |
MonadFail m => MonadFail (IdentityT * m) | |
MonadFail m => MonadFail (StateT s m) | |
(Monoid w, MonadFail m) => MonadFail (WriterT w m) | |
MonadFail m => MonadFail (ReaderT * r m) | |
MonadFail m => MonadFail (ContT * r m) | |
(Monoid w, MonadFail m) => MonadFail (RWST r w s m) | |
(Monoid w, MonadFail m) => MonadFail (RWST r w s m) | |
Orphan instances
Monad Fail Source # | |
MonadFix Fail Source # | |
MonadFail Fail Source # | |
Applicative Fail Source # | |
Alternative Fail Source # | |
MonadPlus Fail Source # | |
MonadTrans FailT Source # | |
MonadTransControl FailT Source # | |
MonadError String Fail Source # | |
MonadBase b m => MonadBase b (FailT m) Source # | |
MonadBaseControl b m => MonadBaseControl b (FailT m) Source # | |
Monad m => MonadError String (FailT m) Source # | |
MonadState s m => MonadState s (FailT m) Source # | |
MonadWriter w m => MonadWriter w (FailT m) Source # | |
Monad m => Monad (FailT m) Source # | |
MonadFix m => MonadFix (FailT m) Source # | |
Monad m => MonadFail (FailT m) Source # | |
(Functor m, Monad m) => Applicative (FailT m) Source # | |
Arbitrary a => Arbitrary (Fail a) Source # | |
Monad m => Alternative (FailT m) Source # | |
Monad m => MonadPlus (FailT m) Source # | |
MonadIO m => MonadIO (FailT m) Source # | |
MonadThrow m => MonadThrow (FailT m) Source # | |
MonadResource m => MonadResource (FailT m) Source # | |