Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class IsList elist => ErrorList elist where
- data EList = EList Text [Text]
- throwError1 :: (ErrorList e, MonadError e m) => Text -> m a
- throwErrorC :: (ErrorList e, MonadError e m) => [Text] -> m a
- addError1 :: (ErrorList e, MonadError e m) => Text -> e -> m a
- addErrorC :: (ErrorList e, MonadError e m) => [Text] -> e -> m a
- assert :: (ErrorList e, MonadError e m) => Bool -> Text -> m ()
- assertC :: (ErrorList e, MonadError e m) => Bool -> [Text] -> m ()
- wrapJust :: MonadError e m => m a -> m (Maybe a)
- withHandler :: MonadError e m => (e -> m a) -> m a -> m a
- ifErrorDo :: MonadError e m => m a -> m a -> m a
- ifErrorReturn :: MonadError e m => m a -> a -> m a
- showError :: (Render e, Render b) => (a -> Either e b) -> a -> IO ()
- showError' :: (Render e, Render b) => (a -> (Either e b, c)) -> a -> IO ()
- errorC :: [Text] -> a
- oneErrorC :: ErrorList e => [Text] -> e
- firstSuccess :: (ErrorList e, MonadError e m) => Text -> [m a] -> m a
- inContext :: (ErrorList e, MonadError e m) => Text -> m a -> m a
Documentation
throwError1 :: (ErrorList e, MonadError e m) => Text -> m a Source
Throws a single-message eror list.
throwErrorC :: (ErrorList e, MonadError e m) => [Text] -> m a Source
Concatenates a list of strings and throws them as an error.
addError1 :: (ErrorList e, MonadError e m) => Text -> e -> m a Source
Throws a new error with the given string added on.
addErrorC :: (ErrorList e, MonadError e m) => [Text] -> e -> m a Source
Throws a new error with the concatenation of the argument added on.
assert :: (ErrorList e, MonadError e m) => Bool -> Text -> m () Source
If the test is false, throws an error with the given message.
assertC :: (ErrorList e, MonadError e m) => Bool -> [Text] -> m () Source
Same as assert
, but concatenates a text list.
wrapJust :: MonadError e m => m a -> m (Maybe a) Source
withHandler :: MonadError e m => (e -> m a) -> m a -> m a Source
Useful when the handler is more concise than the action.
ifErrorDo :: MonadError e m => m a -> m a -> m a Source
Specifies what to do if the given action fails.
ifErrorReturn :: MonadError e m => m a -> a -> m a Source
Performs an action, returning the second argument if it fails.
showError :: (Render e, Render b) => (a -> Either e b) -> a -> IO () Source
Pretty-prints errors that use Either
.
showError' :: (Render e, Render b) => (a -> (Either e b, c)) -> a -> IO () Source
Pretty-prints errors that use Either
, appearing in tuples.
oneErrorC :: ErrorList e => [Text] -> e Source
Pretty-prints an error list. Considers the first item of the list to be the "main" message; subsequent messages are listed after. printErrors :: ErrorList e => e -> IO () printErrors (ErrorList err errs) = do P.putStrLn ("Error: " <> unpack err) P.mapM_ (P.putStrLn . unpack . (" " <>)) errs
Same as oneError
but concatenates its argument.
firstSuccess :: (ErrorList e, MonadError e m) => Text -> [m a] -> m a Source
inContext :: (ErrorList e, MonadError e m) => Text -> m a -> m a Source
Tries something and throws an error if it fails.