uni-util-2.2.0.0: Utilities for the uniform workbench

Util.Computation

Contents

Description

 

Synopsis

Documentation

done :: Monad m => m ()Source

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

exceptions and handlers

try :: IO a -> IO (Either Exception a)

Similar to catch, but returns an Either result which is (Right a) if no exception was raised, or (Left e) if an exception was raised and its value is e.

try a = catch (Right `liftM` a) (return . Left)

Note: as with catch, it is only polite to use this variant if you intend to re-throw the exception after performing whatever cleanup is needed. Otherwise, tryJust is generally considered to be better.

Also note that System.IO.Error also exports a function called System.IO.Error.try with a similar type to try, except that it catches only the IO and user families of exceptions (as required by the Haskell 98 IO module).

selectors

when :: Monad m => Bool -> m () -> m ()

Conditional execution of monadic expressions. For example,

when debug (putStr "Debugging\n")

will output the string Debugging\n if the Boolean value debug is True, and otherwise do nothing.

unless :: Monad m => Bool -> m () -> m ()

The reverse of when.

incase :: Maybe a -> (a -> IO b) -> IO ()Source

iterators

forever :: Monad m => m a -> m b

forever act repeats the action infinitely.

foreach :: Monad m => [a] -> (a -> m b) -> m ()Source

while :: Monad m => m a -> (a -> Bool) -> m aSource

configure command

type Config w = w -> IO wSource

configure :: w -> [Config w] -> IO wSource

The new-style configuration command

class HasConfig option configuration whereSource

Methods

($$) :: option -> configuration -> configurationSource

configUsed :: option -> configuration -> BoolSource

Returning results or error messages.

mapWithError :: (a -> b) -> WithError a -> WithError bSource

mapWithErrorIO :: (a -> IO b) -> WithError a -> IO (WithError b)Source

coerceWithErrorOrBreakIOPrefix :: String -> (String -> a) -> WithError a -> IO aSource

coerce or use the supplied break function (to be used with ExtendedPrelude.addFallOut)

The first argument is prepended to any error message. The value is evaluated immediately.

coerceWithErrorOrBreakPrefix :: String -> (String -> a) -> WithError a -> aSource

coerce or use the supplied break function (to be used with ExtendedPrelude.addFallOut)

The first argument is prepended to any error message.

newtype MonadWithError m a Source

Constructors

MonadWithError (m (WithError a)) 

Instances

coerceWithErrorOrBreak :: (String -> a) -> WithError a -> aSource

coerce or use the supplied break function (to be used with ExtendedPrelude.addFallOut)

coerceWithErrorOrBreakIO :: (String -> a) -> WithError a -> IO aSource

coerce or use the supplied break function (to be used with ExtendedPrelude.addFallOut) The value is evaluated immediately.