| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Util.Computation
Contents
Description
Synopsis
- type Answer a = Either SomeException a
- done :: Monad m => m ()
- (#) :: a -> (a -> b) -> b
- propagate :: Answer a -> IO a
- try :: Exception e => IO a -> IO (Either e a)
- tryUntilOK :: IO a -> IO a
- raise :: IOError -> IO a
- when :: Applicative f => Bool -> f () -> f ()
- unless :: Applicative f => Bool -> f () -> f ()
- incase :: Maybe a -> (a -> IO b) -> IO ()
- forever :: Applicative f => f a -> f b
- foreverUntil :: Monad m => m Bool -> m ()
- foreach :: Monad m => [a] -> (a -> m b) -> m ()
- while :: Monad m => m a -> (a -> Bool) -> m a
- type Config w = w -> IO w
- configure :: w -> [Config w] -> IO w
- config :: IO () -> Config w
- class HasConfig option configuration where
- data WithError a
- hasError :: String -> WithError a
- hasValue :: a -> WithError a
- fromWithError :: WithError a -> Either String a
- fromWithError1 :: a -> WithError a -> a
- toWithError :: Either String a -> WithError a
- isError :: WithError a -> Bool
- mapWithError :: (a -> b) -> WithError a -> WithError b
- mapWithError' :: (a -> WithError b) -> WithError a -> WithError b
- mapWithErrorIO :: (a -> IO b) -> WithError a -> IO (WithError b)
- mapWithErrorIO' :: (a -> IO (WithError b)) -> WithError a -> IO (WithError b)
- pairWithError :: WithError a -> WithError b -> WithError (a, b)
- listWithError :: [WithError a] -> WithError [a]
- coerceWithError :: WithError a -> a
- coerceWithErrorIO :: WithError a -> IO a
- coerceWithErrorStringIO :: String -> WithError a -> IO a
- coerceWithErrorOrBreakIOPrefix :: String -> (String -> a) -> WithError a -> IO a
- coerceWithErrorOrBreakPrefix :: String -> (String -> a) -> WithError a -> a
- newtype MonadWithError m a = MonadWithError (m (WithError a))
- monadifyWithError :: Monad m => WithError a -> MonadWithError m a
- toMonadWithError :: Monad m => m a -> MonadWithError m a
- coerceWithErrorOrBreak :: (String -> a) -> WithError a -> a
- coerceWithErrorOrBreakIO :: (String -> a) -> WithError a -> IO a
- concatWithError :: [WithError a] -> WithError [a]
- swapIOWithError :: WithError (IO a) -> IO (WithError a)
- exceptionToError :: Exception e => (e -> Maybe String) -> IO a -> IO (WithError a)
Documentation
type Answer a = Either SomeException a Source #
exceptions and handlers
try :: Exception e => IO a -> IO (Either e a) #
Similar to catch, but returns an Either result which is
( if no exception of type Right a)e was raised, or (
if an exception of type Left ex)e was raised and its value is ex.
If any other type of exception is raised than it will be propogated
up to the next enclosing exception handler.
try a = catch (Right `liftM` a) (return . Left)
tryUntilOK :: IO a -> IO a Source #
selectors
when :: Applicative f => Bool -> f () -> f () #
Conditional execution of Applicative expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging if the Boolean value debug
is True, and otherwise do nothing.
unless :: Applicative f => Bool -> f () -> f () #
The reverse of when.
iterators
forever :: Applicative f => f a -> f b #
repeats the action infinitely.forever act
foreverUntil :: Monad m => m Bool -> m () Source #
configure command
The new-style configuration command
Returning results or error messages.
fromWithError1 :: a -> WithError a -> a Source #
mapWithError :: (a -> b) -> WithError a -> WithError b Source #
listWithError :: [WithError a] -> WithError [a] Source #
coerceWithError :: WithError a -> a Source #
coerceWithErrorIO :: WithError a -> IO a Source #
coerceWithErrorOrBreakIOPrefix :: String -> (String -> a) -> WithError a -> IO a Source #
coerce or use the supplied break function (to be used with
addFallOut)
The first argument is prepended to any error message. The value is evaluated immediately.
coerceWithErrorOrBreakPrefix :: String -> (String -> a) -> WithError a -> a Source #
coerce or use the supplied break function (to be used with
addFallOut)
The first argument is prepended to any error message.
newtype MonadWithError m a Source #
Constructors
| MonadWithError (m (WithError a)) |
Instances
| Monad m => Monad (MonadWithError m) Source # | |
Defined in Util.Computation Methods (>>=) :: MonadWithError m a -> (a -> MonadWithError m b) -> MonadWithError m b # (>>) :: MonadWithError m a -> MonadWithError m b -> MonadWithError m b # return :: a -> MonadWithError m a # fail :: String -> MonadWithError m a # | |
| Monad m => Functor (MonadWithError m) Source # | |
Defined in Util.Computation Methods fmap :: (a -> b) -> MonadWithError m a -> MonadWithError m b # (<$) :: a -> MonadWithError m b -> MonadWithError m a # | |
| Monad m => Applicative (MonadWithError m) Source # | |
Defined in Util.Computation Methods pure :: a -> MonadWithError m a # (<*>) :: MonadWithError m (a -> b) -> MonadWithError m a -> MonadWithError m b # liftA2 :: (a -> b -> c) -> MonadWithError m a -> MonadWithError m b -> MonadWithError m c # (*>) :: MonadWithError m a -> MonadWithError m b -> MonadWithError m b # (<*) :: MonadWithError m a -> MonadWithError m b -> MonadWithError m a # | |
monadifyWithError :: Monad m => WithError a -> MonadWithError m a Source #
toMonadWithError :: Monad m => m a -> MonadWithError m a Source #
coerceWithErrorOrBreak :: (String -> a) -> WithError a -> a Source #
coerce or use the supplied break function (to be used with
addFallOut)
coerceWithErrorOrBreakIO :: (String -> a) -> WithError a -> IO a Source #
coerce or use the supplied break function (to be used with
addFallOut)
The value is evaluated immediately.
concatWithError :: [WithError a] -> WithError [a] Source #