Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides generic functions set useful for errortype-parameterized monads and monad transformers,
such as Get
.
Example:
pSign :: Parser (Maybe Char) Bool pSign = do c <- pChar ?>> return Nothing case c of '+' -> return False '-' -> return True x -> throwError (Just x) pSignedNumber :: Parser String Int pSignedNumber = do is_negative <- fromMaybe False <$> option'' pSign value <- foldl1 (\ !a !b -> a * 10 + b) <$> many1'' pDigit ?>> return "digit or sign expected" return $ if is_negative then -value else value
Documentation
class (MonadError e m_e, MonadError e' m_e') => MonadMapError e m_e e' m_e' | m_e -> e, m_e' -> e', m_e e' -> m_e', m_e' e -> m_e where Source #
Instances
MonadMapError e (Either e) e' (Either e') Source # | |
Monad m => MonadMapError e (ExceptT e m) e' (ExceptT e' m) Source # | |
MonadMapError e m_e e' m_e' => MonadMapError e (ConduitT i o m_e) e' (ConduitT i o m_e') Source # | |
Monad m => MonadMapError e (GetC s i e m) e' (GetC s i e' m) Source # | |
(?=>>) :: (MonadMapError e m_e (Either e e') m_Either_e_e', MonadMapError Void m_Void (Either e e') m_Either_e_e', MonadMapError (Either e e') m_Either_e_e' e' m_e') => m_e a -> (e -> m_Void e') -> m_e' a infixl 1 Source #
(?>>) :: (MonadMapError () m_Unit (Maybe e) m_Maybe_e, MonadMapError Void m_Void (Maybe e) m_Maybe_e, MonadMapError (Maybe e) m_Maybe_e e m_e) => m_Unit a -> m_Void e -> m_e a infixl 1 Source #
option'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e' m_e') => m_e a -> m_e' (Maybe a) Source #
many'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e' m_e') => m_e a -> m_e' [a] Source #
many1'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e m_e) => m_e a -> m_e (NonEmpty a) Source #
manyTill'' :: (MonadPlus m_Unit, MonadMapError e' m_e' () m_Unit, MonadMapError () m_Unit e m_e) => m_e a -> m_e' b -> m_e [a] Source #
sepBy'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e'' m_e'', MonadMapError e' m_e' () m_Unit, MonadMapError () m_Unit () m_Unit) => m_e a -> m_e' s -> m_e'' [a] Source #
sepBy1'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e m_e, MonadMapError e' m_e' () m_Unit, MonadMapError () m_Unit () m_Unit) => m_e a -> m_e' s -> m_e (NonEmpty a) Source #
skipMany'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e' m_e') => m_e a -> m_e' () Source #
skipMany1'' :: (MonadPlus m_Unit, MonadMapError e m_e () m_Unit, MonadMapError () m_Unit e m_e) => m_e a -> m_e () Source #