strict-data-0.2.0.2: A collection of commonly used strict data structures

Safe HaskellSafe
LanguageHaskell2010

Data.Fail

Contents

Synopsis

Documentation

data Fail a Source #

Constructors

Err !Text 
Ok !a 

Instances

Functor Fail Source # 

Methods

fmap :: (a -> b) -> Fail a -> Fail b #

(<$) :: a -> Fail b -> Fail a #

Foldable Fail Source # 

Methods

fold :: Monoid m => Fail m -> m #

foldMap :: Monoid m => (a -> m) -> Fail a -> m #

foldr :: (a -> b -> b) -> b -> Fail a -> b #

foldr' :: (a -> b -> b) -> b -> Fail a -> b #

foldl :: (b -> a -> b) -> b -> Fail a -> b #

foldl' :: (b -> a -> b) -> b -> Fail a -> b #

foldr1 :: (a -> a -> a) -> Fail a -> a #

foldl1 :: (a -> a -> a) -> Fail a -> a #

toList :: Fail a -> [a] #

null :: Fail a -> Bool #

length :: Fail a -> Int #

elem :: Eq a => a -> Fail a -> Bool #

maximum :: Ord a => Fail a -> a #

minimum :: Ord a => Fail a -> a #

sum :: Num a => Fail a -> a #

product :: Num a => Fail a -> a #

Traversable Fail Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Fail a -> f (Fail b) #

sequenceA :: Applicative f => Fail (f a) -> f (Fail a) #

mapM :: Monad m => (a -> m b) -> Fail a -> m (Fail b) #

sequence :: Monad m => Fail (m a) -> m (Fail a) #

MonadFailure Fail Source # 

Methods

catchFailure :: Fail a -> (String -> Fail a) -> Fail a Source #

Eq a => Eq (Fail a) Source # 

Methods

(==) :: Fail a -> Fail a -> Bool #

(/=) :: Fail a -> Fail a -> Bool #

Ord a => Ord (Fail a) Source # 

Methods

compare :: Fail a -> Fail a -> Ordering #

(<) :: Fail a -> Fail a -> Bool #

(<=) :: Fail a -> Fail a -> Bool #

(>) :: Fail a -> Fail a -> Bool #

(>=) :: Fail a -> Fail a -> Bool #

max :: Fail a -> Fail a -> Fail a #

min :: Fail a -> Fail a -> Fail a #

Show a => Show (Fail a) Source # 

Methods

showsPrec :: Int -> Fail a -> ShowS #

show :: Fail a -> String #

showList :: [Fail a] -> ShowS #

pattern Fail :: forall a. String -> Fail a Source #

newtype FailT m a Source #

Constructors

FailT (m (Fail a)) 

Instances

Functor m => Functor (FailT m) Source # 

Methods

fmap :: (a -> b) -> FailT m a -> FailT m b #

(<$) :: a -> FailT m b -> FailT m a #

Monad m => MonadFailure (FailT m) Source # 

Methods

catchFailure :: FailT m a -> (String -> FailT m a) -> FailT m a Source #

type StT FailT a # 
type StT FailT a = Fail a
type StM (FailT m) a # 
type StM (FailT m) a = ComposeSt FailT m a

runFailT :: FailT m a -> m (Fail a) Source #

type FIO a = FailT IO a Source #

failInM :: Monad m => Fail a -> m a Source #

failInM' :: Monad m => Fail a -> (String -> String) -> m a Source #

failInM'' :: Monad m => String -> Fail a -> m a Source #

mapFail :: (String -> String) -> Fail a -> Fail a Source #

failSwitch :: (String -> c) -> (a -> c) -> Fail a -> c Source #

fromFail :: (String -> a) -> Fail a -> a Source #

class MonadFail m => MonadFailure m where Source #

Minimal complete definition

catchFailure

Methods

catchFailure :: m a -> (String -> m a) -> m a Source #

Instances

MonadFailure Maybe Source # 

Methods

catchFailure :: Maybe a -> (String -> Maybe a) -> Maybe a Source #

MonadFailure IO Source # 

Methods

catchFailure :: IO a -> (String -> IO a) -> IO a Source #

MonadFailure Fail Source # 

Methods

catchFailure :: Fail a -> (String -> Fail a) -> Fail a Source #

Monad m => MonadFailure (FailT m) Source # 

Methods

catchFailure :: FailT m a -> (String -> FailT m a) -> FailT m a Source #

(MonadFail (ReaderT * r m), MonadFailure m) => MonadFailure (ReaderT * r m) Source # 

Methods

catchFailure :: ReaderT * r m a -> (String -> ReaderT * r m a) -> ReaderT * r m a Source #

catFails :: [Fail a] -> [a] 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 #

runError :: forall a. (forall m. Monad m => m a) -> Either String a Source #

runExceptTorFail :: (Monad m, Show e) => ExceptT e m a -> m a Source #

maybeToFail :: Monad m => String -> Maybe a -> m a Source #

partitionFails :: [Fail a] -> ([a], [String]) 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

Minimal complete definition

fail

Instances

MonadFail [] 

Methods

fail :: String -> [a] #

MonadFail Maybe 

Methods

fail :: String -> Maybe a #

MonadFail IO 

Methods

fail :: String -> IO a #

MonadFail Q 

Methods

fail :: String -> Q a #

MonadFail IResult 

Methods

fail :: String -> IResult a #

MonadFail Result 

Methods

fail :: String -> Result a #

MonadFail Parser 

Methods

fail :: String -> Parser a #

MonadFail P 

Methods

fail :: String -> P a #

MonadFail ReadPrec 

Methods

fail :: String -> ReadPrec a #

MonadFail ReadP 

Methods

fail :: String -> ReadP a #

MonadFail StrictList # 

Methods

fail :: String -> StrictList a #

MonadFail Option # 

Methods

fail :: String -> Option a #

MonadFail Vector # 

Methods

fail :: String -> Vector a #

MonadFail (Parser i) 

Methods

fail :: String -> Parser i a #

Monad m => MonadFail (ListT m) 

Methods

fail :: String -> ListT m a #

Monad m => MonadFail (MaybeT m) 

Methods

fail :: String -> MaybeT m a #

Monad m => MonadFail (OptionT m) # 

Methods

fail :: String -> OptionT m a #

(Monoid w, MonadFail m) => MonadFail (WriterT w m) 

Methods

fail :: String -> WriterT w m a #

MonadFail m => MonadFail (StateT s m) 

Methods

fail :: String -> StateT s m a #

MonadFail m => MonadFail (ExceptT e m) 

Methods

fail :: String -> ExceptT e m a #

(Monad m, Error e) => MonadFail (ErrorT e m) 

Methods

fail :: String -> ErrorT e m a #

MonadFail m => MonadFail (IdentityT * m) 

Methods

fail :: String -> IdentityT * m a #

MonadFail m => MonadFail (StateT s m) 

Methods

fail :: String -> StateT s m a #

(Monoid w, MonadFail m) => MonadFail (WriterT w m) 

Methods

fail :: String -> WriterT w m a #

MonadFail m => MonadFail (ReaderT * r m) 

Methods

fail :: String -> ReaderT * r m a #

MonadFail m => MonadFail (ContT * r m) 

Methods

fail :: String -> ContT * r m a #

(Monoid w, MonadFail m) => MonadFail (RWST r w s m) 

Methods

fail :: String -> RWST r w s m a #

(Monoid w, MonadFail m) => MonadFail (RWST r w s m) 

Methods

fail :: String -> RWST r w s m a #

Orphan instances

Monad Fail Source # 

Methods

(>>=) :: Fail a -> (a -> Fail b) -> Fail b #

(>>) :: Fail a -> Fail b -> Fail b #

return :: a -> Fail a #

fail :: String -> Fail a #

MonadFix Fail Source # 

Methods

mfix :: (a -> Fail a) -> Fail a #

MonadFail Fail Source # 

Methods

fail :: String -> Fail a #

Applicative Fail Source # 

Methods

pure :: a -> Fail a #

(<*>) :: Fail (a -> b) -> Fail a -> Fail b #

(*>) :: Fail a -> Fail b -> Fail b #

(<*) :: Fail a -> Fail b -> Fail a #

Alternative Fail Source # 

Methods

empty :: Fail a #

(<|>) :: Fail a -> Fail a -> Fail a #

some :: Fail a -> Fail [a] #

many :: Fail a -> Fail [a] #

MonadPlus Fail Source # 

Methods

mzero :: Fail a #

mplus :: Fail a -> Fail a -> Fail a #

MonadTrans FailT Source # 

Methods

lift :: Monad m => m a -> FailT m a #

MonadTransControl FailT Source # 

Associated Types

type StT (FailT :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run FailT -> m a) -> FailT m a #

restoreT :: Monad m => m (StT FailT a) -> FailT m a #

MonadError String Fail Source # 

Methods

throwError :: String -> Fail a #

catchError :: Fail a -> (String -> Fail a) -> Fail a #

MonadBase b m => MonadBase b (FailT m) Source # 

Methods

liftBase :: b α -> FailT m α #

MonadBaseControl b m => MonadBaseControl b (FailT m) Source # 

Associated Types

type StM (FailT m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (FailT m) b -> b a) -> FailT m a #

restoreM :: StM (FailT m) a -> FailT m a #

Monad m => MonadError String (FailT m) Source # 

Methods

throwError :: String -> FailT m a #

catchError :: FailT m a -> (String -> FailT m a) -> FailT m a #

MonadState s m => MonadState s (FailT m) Source # 

Methods

get :: FailT m s #

put :: s -> FailT m () #

state :: (s -> (a, s)) -> FailT m a #

MonadWriter w m => MonadWriter w (FailT m) Source # 

Methods

writer :: (a, w) -> FailT m a #

tell :: w -> FailT m () #

listen :: FailT m a -> FailT m (a, w) #

pass :: FailT m (a, w -> w) -> FailT m a #

Monad m => Monad (FailT m) Source # 

Methods

(>>=) :: FailT m a -> (a -> FailT m b) -> FailT m b #

(>>) :: FailT m a -> FailT m b -> FailT m b #

return :: a -> FailT m a #

fail :: String -> FailT m a #

MonadFix m => MonadFix (FailT m) Source # 

Methods

mfix :: (a -> FailT m a) -> FailT m a #

Monad m => MonadFail (FailT m) Source # 

Methods

fail :: String -> FailT m a #

(Functor m, Monad m) => Applicative (FailT m) Source # 

Methods

pure :: a -> FailT m a #

(<*>) :: FailT m (a -> b) -> FailT m a -> FailT m b #

(*>) :: FailT m a -> FailT m b -> FailT m b #

(<*) :: FailT m a -> FailT m b -> FailT m a #

Arbitrary a => Arbitrary (Fail a) Source # 

Methods

arbitrary :: Gen (Fail a) #

shrink :: Fail a -> [Fail a] #

Monad m => Alternative (FailT m) Source # 

Methods

empty :: FailT m a #

(<|>) :: FailT m a -> FailT m a -> FailT m a #

some :: FailT m a -> FailT m [a] #

many :: FailT m a -> FailT m [a] #

Monad m => MonadPlus (FailT m) Source # 

Methods

mzero :: FailT m a #

mplus :: FailT m a -> FailT m a -> FailT m a #

MonadIO m => MonadIO (FailT m) Source # 

Methods

liftIO :: IO a -> FailT m a #

MonadThrow m => MonadThrow (FailT m) Source # 

Methods

throwM :: Exception e => e -> FailT m a #

MonadResource m => MonadResource (FailT m) Source # 

Methods

liftResourceT :: ResourceT IO a -> FailT m a #