HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulegraphviz-2999.20.2.0Haskell2010

Data.GraphViz.Types.Monadic

This module is based upon the dotgen library by Andy Gill: http://hackage.haskell.org/package/dotgen

It provides a monadic interface for constructing generalised Dot graphs. Note that this does not have an instance for DotRepr (e.g. what would be the point of the fromCanonical function, as you can't do anything with the result): it is purely for construction purposes. Use the generalised Dot graph instance for printing, etc.

Note that the generalised Dot graph types are not re-exported, in case it causes a clash with other modules you may choose to import.

The example graph in Data.GraphViz.Types can be written as:

digraph (Str "G") $ do

   cluster (Int 0) $ do
       graphAttrs [style filled, color LightGray]
       nodeAttrs [style filled, color White]
       "a0" --> "a1"
       "a1" --> "a2"
       "a2" --> "a3"
       graphAttrs [textLabel "process #1"]

   cluster (Int 1) $ do
       nodeAttrs [style filled]
       "b0" --> "b1"
       "b1" --> "b2"
       "b2" --> "b3"
       graphAttrs [textLabel "process #2", color Blue]

   "start" --> "a0"
   "start" --> "b0"
   "a1" --> "b3"
   "b2" --> "a3"
   "a3" --> "end"
   "b3" --> "end"

   node "start" [shape MDiamond]
   node "end" [shape MSquare]
  • 3 types
  • 15 values
typetype Dot n = DotM n ()
#

The monadic representation of a Dot graph.

newtypenewtype DotM n a
#

The actual monad; as with Dot but allows you to return a value within the do-block. The actual implementation is based upon the Writer monad.

Instances6Monad, Functor, MonadFix, Applicative, Semigroup, Monoid
  • Monad (DotM n)Defined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Monadic
  • Functor (DotM n)Defined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Monadic
  • MonadFix (DotM n)Defined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Monadic
  • Applicative (DotM n)Defined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Monadic
  • Semigroup a => Semigroup (DotM n a)Defined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Monadic
  • Monoid a => Monoid (DotM n a)Defined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Monadic
datadata GraphID
#

A polymorphic type that covers all possible ID values allowed by Dot syntax. Note that whilst the ParseDot and PrintDot instances for String will properly take care of the special cases for numbers, they are treated differently here.

Constructors

Instances6Eq, Ord, Read, Show, ParseDot, PrintDot
  • Eq GraphIDDefined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Internal.Common
  • Ord GraphIDDefined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Internal.Common
  • Read GraphIDDefined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Internal.Common
  • Show GraphIDDefined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Internal.Common
  • ParseDot GraphIDDefined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Internal.Common
  • PrintDot GraphIDDefined in graphviz-2999.20.2.0 · Data.GraphViz.Types.Internal.Common

Creating a generalised DotGraph.

4 declarations

Adding global attributes.

3 declarations

Adding items to the graph.

0 declarations

Subgraphs and clusters

Nodes

valuenode' :: n -> Dot n
#

Add a node with no attributes to the graph.

Edges

If you wish to use something analogous to Dot's ability to write multiple edges with in-line subgraphs such as:

{a b c} -> {d e f}

Then you can use --> and <-> in combination with monadic traversal functions such as traverse_, for_, mapM_, forM_ and zipWithM_; for example:

("a" -->) `traverse_` ["d", "e", "f"]
["a", "b", "c"] `for_` (--> "d")
zipWithM_ (-->) ["a", "b", "c"] ["d", "e", "f"]
value(-->) :: n -> n -> Dot n
#

Add an edge with no attributes.

value(<->) :: n -> n -> Dot n
#

An alias for --> to make edges look more undirected.