Module

Data.DotLang

Package
purescript-dotlang
Repository
csicar/purescript-dotlang

#Id Source

type Id = String

type alias for a Nodes Name

#Node Source

data Node

Dot-Node

> import Data.DotLang
> import Data.DotLang.Class (toText)
> import Data.DotLang.Attr.Node as Node
> toText $ Node "e" [Node.Margin 3, Node.label "some label"]
"e [margin=3, label=\"some label\"]"

Constructors

Instances

#nodeId Source

nodeId :: Node -> Id

get a nodes id

> nodeId (Node "e" [Node.label "foo"])
"e"

#changeNodeId Source

changeNodeId :: (Id -> Id) -> Node -> Node

change Nodes id to a new one; keeing the old id as the label

> changeNodeId (_ <> "!") (Node "e" [])
(Node "e!" [(Label (TextLabel "e"))])

#Edge Source

data Edge

egde from id to id

> toText $ Edge Forward "a" "b" []
"a -> b"

EdgeType determines the direction of the arrow

Constructors

Instances

#Definition Source

data Definition

definition in a graph

Constructors

Instances

#global Source

global :: Array Attr -> Definition
> import Data.DotLang.Attr.Global as Global
> :t global [Global.RankDir Global.FromLeft]
Definition

global as a part of a definition

#node Source

node :: Id -> Array Attr -> Definition
> :t node "a" []
Definition

node as a part of a definition

#edge Source

edge :: EdgeType -> Id -> Id -> Array Attr -> Definition
> :t edge Forward "a" "b" [] 
Definition

edge as a part of a definition. ==> and =*> can also be used for that purpose:

#forwardEdgeWithAttrs Source

#forwardEdge Source

#backwardEdgeWithAttrs Source

#backwardEdge Source

#normalEdgeWithAttrs Source

#normalEdge Source

#(==>) Source

Operator alias for Data.DotLang.forwardEdge (non-associative / precedence 5)

> :t "a" ==> "b" 
Definition

Forward edge as as a definition

#(=*>) Source

Operator alias for Data.DotLang.forwardEdgeWithAttrs (non-associative / precedence 5)

> import Data.DotLang.Attr.Edge as Edge
> import Color.Scheme.HTML (red)
> toText $ "a" =*> "b" $ [ Edge.FillColor red ]
"a -> b [fillcolor=\"#ff0000\"]; "

Forward edge with attributes as a definition

#(<==) Source

Operator alias for Data.DotLang.backwardEdge (non-associative / precedence 5)

> :t "a" <== "b"
Definition

Backward edge as a definition

#(<*=) Source

Operator alias for Data.DotLang.backwardEdgeWithAttrs (non-associative / precedence 5)

> :t "a" <*= "b" $ [ Edge.FillColor red ]
Definition

Backward edge with attributes as a definition

#(-==-) Source

Operator alias for Data.DotLang.normalEdge (non-associative / precedence 5)

> toText $ "a" -==- "b"
"a -- b; "

Normal edge as definition

#(=*=) Source

Operator alias for Data.DotLang.normalEdgeWithAttrs (non-associative / precedence 5)

> toText $ "a" =*= "b" $ [ Edge.FillColor red ]
"a -- b [fillcolor=\"#ff0000\"]; "

Normal edge with attibutes

#Graph Source

data Graph

graph can either be a graph or digraph

Constructors

Instances

#graphFromElements Source

graphFromElements :: Array (Node) -> Array (Edge) -> Graph

create graph from Nodes and Edges

> :t graphFromElements [Node "e" [], Node "d" []] [ Edge Forward "e" "f" []]
Graph

#GraphRepr Source

class GraphRepr a  where

a is a type that can be represented by a Dot-Graph

Members