graphviz-2999.12.0.4: Bindings to Graphviz for graph visualisation.







data GraphvizException Source

Exceptions that arise from using this library fall into four categories:

  • Unable to parse provided Dot code.
  • Dot code is not valid UTF-8.
  • An error when trying to run an external program (e.g. dot).
  • Treating a non-custom Attribute as a custom one.

Re-exported for convenience.

mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a

This function maps one exception into another as proposed in the paper "A semantics for imprecise exceptions".

throw :: Exception e => e -> a

Throw an exception. Exceptions may be thrown from purely functional code, but may only be caught within the IO monad.

handle :: Exception e => (e -> IO a) -> IO a -> IO a

A version of catch with the arguments swapped around; useful in situations where the code for the handler is shorter. For example:

   do handle (\NonTermination -> exitWith (ExitFailure 1)) $



:: IO a

computation to run first ("acquire resource")

-> (a -> IO b)

computation to run last ("release resource")

-> (a -> IO c)

computation to run in-between

-> IO c 

When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release).

A common example is opening a file:

   (openFile "filename" ReadMode)
   (\fileHandle -> do { ... })

The arguments to bracket are in this order so that we can partially apply it, e.g.:

 withFile name mode = bracket (openFile name mode) hClose