uni-util-2.3.0.0: Utilities for the uniform workbench

Safe HaskellNone

Util.Computation

Contents

Description

 

Synopsis

Documentation

done :: Monad m => m ()Source

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

exceptions and handlers

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

Similar to catch, but returns an Either result which is (Right a) if no exception of type e was raised, or (Left ex) if an exception of type 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)

Note that System.IO.Error also exports a function called 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.

foreverUntil :: Monad m => m Bool -> m ()Source

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 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 addFallOut)

The first argument is prepended to any error message.

newtype MonadWithError m a Source

Constructors

MonadWithError (m (WithError a)) 

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

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

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

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