-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | dot language parsing and printing. -- -- This package provides parsing and printing of the dot language. -- --
-- >>> :set -XOverloadedLabels -- -- >>> :set -XOverloadedStrings -- -- >>> import DotParse -- -- >>> import Chart -- -- >>> import DotParse.Examples (exInt) -- -- >>> ex <- processGraph exInt -- -- >>> writeChartOptions "other/ex.svg" (graphToChartWith defaultChartConfig ex) ---- @package dotparse @version 0.0.2 -- | TH stage restriction guff for flatparsing module DotParse.FlatParse.TH -- | Consume whitespace. ws :: Parser e () -- | Consume whitespace after running a parser. token :: Parser e a -> Parser e a -- | Parse a line comment. lineComment :: Parser e () -- | Parse a potentially nested multiline comment. multilineComment :: Parser e () -- | Parse a HTML-Like string by counting the angle brackets htmlLike :: Parser e String -- | First character of a dot identifier. isValidStartChar :: Char -> Bool -- | character of a dot identifier. isValidChar :: Char -> Bool -- | Read a starting character of an identifier. identStartChar :: Parser e Char -- | Read a non-starting character of an identifier. identChar :: Parser e Char -- | Parse a non-keyword string. symbol :: String -> Q Exp -- | Parse a keyword string. keyword :: String -> Q Exp -- | Parser a non-keyword string, throw precise error on failure. symbol' :: String -> Q Exp -- | Parse a keyword string, throw precise error on failure. keyword' :: String -> Q Exp -- | Parse an identifier. ident :: Parser e ByteString -- | Parse an identifier, throw a precise error on failure. ident' :: Parser Error ByteString -- | A parsing error. data Error -- | A precisely known error, like leaving out "in" from "let". Precise :: Pos -> ByteString -> Error -- | An imprecise error, when we expect a number of different things, but -- parse something else. Imprecise :: Pos -> [ByteString] -> Error -- | position of error errorPos :: Error -> Pos -- | Merge two errors. Inner errors (which were thrown at points with more -- consumed inputs) are preferred. If errors are thrown at identical -- input positions, we prefer precise errors to imprecise ones. -- -- The point of prioritizing inner and precise errors is to suppress the -- deluge of "expected" items, and instead try to point to a concrete -- issue to fix. merge :: Error -> Error -> Error -- | Pretty print an error. The ByteString input is the source file. -- The offending line from the source is displayed in the output. prettyError :: ByteString -> Error -> ByteString -- | Imprecise cut: we slap a list of items on inner errors. cut :: Parser Error a -> [ByteString] -> Parser Error a -- | Precise cut: we propagate at most a single error. cut' :: Parser Error a -> ByteString -> Parser Error a instance GHC.Show.Show DotParse.FlatParse.TH.Error instance GHC.Classes.Eq DotParse.FlatParse.TH.Error -- | Lower-level flatparse parsers module DotParse.FlatParse -- | A parsing error. data Error -- | A precisely known error, like leaving out "in" from "let". Precise :: Pos -> ByteString -> Error -- | An imprecise error, when we expect a number of different things, but -- parse something else. Imprecise :: Pos -> [ByteString] -> Error -- | Pretty print an error. The ByteString input is the source file. -- The offending line from the source is displayed in the output. prettyError :: ByteString -> Error -> ByteString -- | Parse a keyword string. keyword :: String -> Q Exp -- | Parse a keyword string, throw precise error on failure. keyword' :: String -> Q Exp -- | Parse a non-keyword string. symbol :: String -> Q Exp -- | Parser a non-keyword string, throw precise error on failure. symbol' :: String -> Q Exp -- | Consume whitespace. ws :: Parser e () -- | Consume whitespace after running a parser. token :: Parser e a -> Parser e a -- | Parse an identifier. ident :: Parser e ByteString -- | Imprecise cut: we slap a list of items on inner errors. cut :: Parser Error a -> [ByteString] -> Parser Error a -- | Precise cut: we propagate at most a single error. cut' :: Parser Error a -> ByteString -> Parser Error a -- | Run parser, print pretty error on failure. testParser :: Show a => Parser Error a -> ByteString -> IO () -- | run a Parser, erroring on leftovers, Fail or Err runParser_ :: Parser Error a -> ByteString -> a -- | (unsigned) Int parser int :: Parser Error Int -- |
-- >>> runParser double "1.234x" -- OK 1.234 "x" ---- --
-- >>> runParser double "." -- Fail ---- --
-- >>> runParser double "123" -- OK 123.0 "" ---- --
-- >>> runParser double ".123" -- OK 0.123 "" ---- --
-- >>> runParser double "123." -- OK 123.0 "" --double :: Parser Error Double -- |
-- >>> runParser (signed double) "-1.234x" -- OK (-1.234) "x" --signed :: Num b => Parser e b -> Parser e b -- | Looks ahead for a "/"" that may be in the quoted string. >>> -- runParser quoted (strToUtf8 ""hello"") OK "hello" "" -- --
-- >>> runParser quoted (strToUtf8 "\"hello/\"\"") -- OK "hello\"" "" --quoted :: Parser Error String -- | Parse a HTML-Like string by counting the angle brackets htmlLike :: Parser e String -- | optional separators sepP :: Parser e () -- | parse wrapping square brackets wrapSquareP :: Parser Error a -> Parser Error a -- | print wrapping square brackets wrapSquarePrint :: ByteString -> ByteString -- | parse wrapping square brackets wrapCurlyP :: Parser Error a -> Parser Error a -- | print wrapping curly brackets wrapCurlyPrint :: ByteString -> ByteString -- | print wrapping quotes wrapQuotePrint :: ByteString -> ByteString -- | comma separated Point pointP :: Parser Error (Point Double) -- | dot specification of a cubic spline (and an arrow head which is -- ignored here) data Spline Spline :: Maybe (Point Double) -> Maybe (Point Double) -> Point Double -> [(Point Double, Point Double, Point Double)] -> Spline [splineEnd] :: Spline -> Maybe (Point Double) [splineStart] :: Spline -> Maybe (Point Double) [splineP1] :: Spline -> Point Double [splineTriples] :: Spline -> [(Point Double, Point Double, Point Double)] -- | http://www.graphviz.org/docs/attr-types/splineType/ splineP :: Parser Error Spline -- | comma separated rectangle or bounding box rectP :: Parser Error (Rect Double) -- | true | false boolP :: Parser Error Bool -- | NonEmpty version of many nonEmptyP :: Parser e a -> Parser e () -> Parser e (NonEmpty a) instance GHC.Generics.Generic DotParse.FlatParse.Spline instance GHC.Show.Show DotParse.FlatParse.Spline instance GHC.Classes.Eq DotParse.FlatParse.Spline -- | Abstract Grammar for the dot language. -- http://www.graphviz.org/doc/info/lang.html module DotParse.Types -- | printing options, for separators. data DotConfig DotConfig :: ByteString -> ByteString -> ByteString -> ByteString -> DotConfig [topLevelSep] :: DotConfig -> ByteString [statementSep] :: DotConfig -> ByteString [attSep] :: DotConfig -> ByteString [subGraphSep] :: DotConfig -> ByteString -- | default separators defaultDotConfig :: DotConfig -- | A parser & printer class for a graphviz graph and components of -- its dot language class DotParse a dotPrint :: DotParse a => DotConfig -> a -> ByteString dotParse :: DotParse a => Parser Error a -- | dotParse and then dotPrint: -- --
-- >>> import qualified Data.ByteString.Char8 as B
--
-- >>> B.putStrLn $ dotPrint defaultDotConfig defaultGraph
-- digraph {
-- node [height=0.5;shape=circle]
-- graph [overlap=false;size="1!";splines=spline]
-- edge [arrowsize=0.5]
-- }
--
defaultGraph :: Graph
-- | run a dot string through graphviz, supplying arguments and collecting
-- stdout
processDotWith :: Directed -> [String] -> ByteString -> IO ByteString
-- | run a dot string through graphviz, collecting the augmented dot string
-- output
processDot :: Directed -> ByteString -> IO ByteString
-- | Augment a Graph via the graphviz process
processGraph :: Graph -> IO Graph
-- | Augment a Graph via the graphviz process
processGraphWith :: DotConfig -> Graph -> IO Graph
-- | MergeEdges (strict)
data Strict
MergeEdges :: Strict
NoMergeEdges :: Strict
-- | Default Strict is NoMergeEdges
defStrict :: Last Strict -> Strict
-- | Directed (digraph | graph)
data Directed
Directed :: Directed
UnDirected :: Directed
-- | Default Directed is Directed
defDirected :: Last Directed -> Directed
-- | Identifier as per the dot language specifications.
--
-- -- >>> runDotParser "0" :: ID -- IDInt 0 ---- --
-- >>> runDotParser "-.123" :: ID -- IDDouble (-0.123) ---- --
-- >>> runParser dotParse "apple_1'" :: Result Error ID -- OK (ID "apple_1") "'" ---- --
-- >>> :set -XQuasiQuotes -- -- >>> runParser dotParse "\"hello\"" :: Result Error ID -- OK (IDQuoted "hello") "" ---- --
-- >>> runDotParser "<The <font color='red'><b>foo</b></font>,<br/> the <font point-size='20'>bar</font> and<br/> the <i>baz</i>>" :: ID -- IDHtml "<The <font color='red'><b>foo</b></font>,<br/> the <font point-size='20'>bar</font> and<br/> the <i>baz</i>>" --data ID ID :: ByteString -> ID IDInt :: Int -> ID IDDouble :: Double -> ID IDQuoted :: ByteString -> ID IDHtml :: ByteString -> ID -- | ID as the equivalent plain String -- -- note that the dot language identifier equivalence law is: -- --
-- x == y if label x == label y --label :: ID -> String -- | Compass instructions which are optionally associated with an -- identifier data Compass CompassN :: Compass CompassNE :: Compass CompassE :: Compass CompassSE :: Compass CompassS :: Compass CompassSW :: Compass CompassW :: Compass CompassNW :: Compass CompassC :: Compass Compass_ :: Compass -- | Port instructions which are optionally associated with an identifier newtype Port Port :: These ID Compass -> Port [portID] :: Port -> These ID Compass -- | Category of attribute data AttributeType GraphType :: AttributeType NodeType :: AttributeType EdgeType :: AttributeType -- | Top-level attribute statement -- --
-- >>> runDotParser "graph [overlap=false, splines=spline, size=\"1!\"];" :: Statement
-- StatementAttribute (AttributeStatement {attributeType = GraphType, attributes = fromList [(ID "overlap",ID "false"),(ID "size",IDQuoted "1!"),(ID "splines",ID "spline")]})
--
data AttributeStatement
AttributeStatement :: AttributeType -> Map ID ID -> AttributeStatement
[attributeType] :: AttributeStatement -> AttributeType
[attributes] :: AttributeStatement -> Map ID ID
-- | Node statement
--
--
-- >>> runDotParser "A [shape=diamond; color=blue]" :: Statement
-- StatementNode (NodeStatement {nodeID = ID "A", port = Nothing, nodeAttrs = fromList [(ID "color",ID "blue"),(ID "shape",ID "diamond")]})
--
data NodeStatement
NodeStatement :: ID -> Maybe Port -> Map ID ID -> NodeStatement
[nodeID] :: NodeStatement -> ID
[port] :: NodeStatement -> Maybe Port
[nodeAttrs] :: NodeStatement -> Map ID ID
-- | An edge can be specified in as a NodeID or as a SubGraph
data EdgeID
EdgeID :: ID -> Maybe Port -> EdgeID
EdgeSubGraph :: SubGraphStatement -> EdgeID
-- | An edgeop is -> in directed graphs and -- in undirected graphs.
data EdgeOp
EdgeDirected :: EdgeOp
EdgeUndirected :: EdgeOp
-- | generate an EdgeOp given the type of graph.
fromDirected :: Directed -> EdgeOp
-- | Edge statement
--
--
-- >>> runDotParser "A -> B [style=dashed, color=grey]" :: Statement
-- StatementEdge (EdgeStatement {edgeOp = EdgeDirected, leftEdge = EdgeID (ID "A") Nothing, rightEdges = EdgeID (ID "B") Nothing :| [], edgeAttrs = fromList [(ID "color",ID "grey"),(ID "style",ID "dashed")]})
--
data EdgeStatement
EdgeStatement :: EdgeOp -> EdgeID -> NonEmpty EdgeID -> Map ID ID -> EdgeStatement
[edgeOp] :: EdgeStatement -> EdgeOp
[leftEdge] :: EdgeStatement -> EdgeID
[rightEdges] :: EdgeStatement -> NonEmpty EdgeID
[edgeAttrs] :: EdgeStatement -> Map ID ID
-- | The edge ID or subgraph ID (if any)
edgeID :: EdgeID -> Maybe ID
-- | list of edges in a given EdgeStatement, including anonymous SugGraphs
edgeIDs :: EdgeStatement -> [(Maybe ID, Maybe ID)]
-- | edge IDs
edgeIDsNamed :: EdgeStatement -> [(ID, ID)]
-- | A dot statement as per the dot language specification.
data Statement
StatementNode :: NodeStatement -> Statement
StatementEdge :: EdgeStatement -> Statement
StatementGlobalAttribute :: GlobalAttributeStatement -> Statement
StatementAttribute :: AttributeStatement -> Statement
StatementSubGraph :: SubGraphStatement -> Statement
-- | add a graphviz statement to a Graph
addStatement :: Statement -> Graph -> Graph
-- | add a list of graphviz statements to a Graph
addStatements :: [Statement] -> Graph -> Graph
-- | A subgraph statement.
--
-- Note: each subgraph must have a unique name
--
--
-- >>> runDotParser "subgraph A {A, B, C}" :: Statement
-- StatementSubGraph (SubGraphStatement {subgraphID = Just (ID "A"), subgraphStatements = [StatementNode (NodeStatement {nodeID = ID "A", port = Nothing, nodeAttrs = fromList []}),StatementNode (NodeStatement {nodeID = ID "B", port = Nothing, nodeAttrs = fromList []}),StatementNode (NodeStatement {nodeID = ID "C", port = Nothing, nodeAttrs = fromList []})]})
--
data SubGraphStatement
SubGraphStatement :: Maybe ID -> [Statement] -> SubGraphStatement
[subgraphID] :: SubGraphStatement -> Maybe ID
[subgraphStatements] :: SubGraphStatement -> [Statement]
-- | Bounding Box lens as a Rect
bbL :: Lens' Graph (Maybe (Rect Double))
-- | nodes lens
nodesPortL :: Lens' Graph (Map ID (Maybe Port, Map ID ID))
-- | nodes lens ignoring/forgetting port information
nodesL :: Lens' Graph (Map ID (Map ID ID))
-- | edges lens ignoring/forgetting port information
edgesL :: Lens' Graph (Map (ID, ID) (Map ID ID))
-- | A specific attribute for all nodes in a graph
nodesA :: ID -> Graph -> Map ID (Maybe ID)
-- | Specific attribute for all edges
edgesA :: Graph -> ID -> Map (ID, ID) (Maybe ID)
-- | node position (as a Point)
nodePos :: Graph -> Map ID (Maybe (Point Double))
-- | node width attributes
nodeWidth :: Graph -> Map ID (Maybe Double)
-- | edge path attributes
edgeSpline :: Graph -> Map (ID, ID) (Maybe Spline)
-- | edge width attributes
edgeWidth :: Graph -> Map (ID, ID) (Maybe Double)
-- | typical node information after processing a dot bytestring.
data NodeInfo
NodeInfo :: ID -> Double -> Point Double -> NodeInfo
[nlabel] :: NodeInfo -> ID
[nwidth] :: NodeInfo -> Double
[pos] :: NodeInfo -> Point Double
-- | Create a list of NodeInfo from a graph.
nodeInfo :: Graph -> Double -> [NodeInfo]
-- | typical edge information after processing a dot bytestring.
data EdgeInfo
EdgeInfo :: (ID, ID) -> Double -> [PathData Double] -> EdgeInfo
[elabel] :: EdgeInfo -> (ID, ID)
[ewidth] :: EdgeInfo -> Double
[curve] :: EdgeInfo -> [PathData Double]
-- | Create a list of EdgeInfo from a graph
edgeInfo :: Graph -> Double -> [EdgeInfo]
-- | https://graphviz.org/docs/attr-types/splineType/ format of the
-- example is end point point and then triples (5,8,11 lengths are 1, 2
-- and 3 cubics)
splinePath :: Spline -> [PathData Double]
-- | convert a Graph processed via the graphviz commands to a
-- ChartOptions
graphToChartWith :: ChartConfig -> Graph -> ChartOptions
-- | convert a Graph processed via the graphviz commands to a
-- ChartOptions using the default ChartConfig.
graphToChart :: Graph -> ChartOptions
-- | Various configutaion parameters for the chart-svg Chart
data ChartConfig
ChartConfig :: Double -> Double -> Double -> Colour -> Colour -> Double -> Double -> Double -> Double -> (ID -> Text) -> ChartConfig
[chartHeight] :: ChartConfig -> Double
[chartScale] :: ChartConfig -> Double
[edgeSize] :: ChartConfig -> Double
[chartColor] :: ChartConfig -> Colour
[chartBackgroundColor] :: ChartConfig -> Colour
[nodeHeight] :: ChartConfig -> Double
[nodeSize] :: ChartConfig -> Double
[vshift] :: ChartConfig -> Double
[textSize] :: ChartConfig -> Double
[labelf] :: ChartConfig -> ID -> Text
-- | default parameters
defaultChartConfig :: ChartConfig
-- | create Statements from a (no edge label) algebraic graph
toStatements :: Directed -> Graph ByteString -> [Statement]
-- | Convert an algebraic graph to a dotparse graph, starting with the
-- defaultGraph.
toDotGraph :: Graph ByteString -> Graph
-- | Convert an algebraic graph to a dotparse graph.
toDotGraphWith :: Directed -> Graph -> Graph ByteString -> Graph
instance GHC.Generics.Generic DotParse.Types.DotConfig
instance GHC.Show.Show DotParse.Types.DotConfig
instance GHC.Classes.Eq DotParse.Types.DotConfig
instance GHC.Generics.Generic DotParse.Types.Strict
instance GHC.Show.Show DotParse.Types.Strict
instance GHC.Classes.Eq DotParse.Types.Strict
instance GHC.Generics.Generic DotParse.Types.Directed
instance GHC.Show.Show DotParse.Types.Directed
instance GHC.Classes.Eq DotParse.Types.Directed
instance GHC.Classes.Ord DotParse.Types.ID
instance GHC.Generics.Generic DotParse.Types.ID
instance GHC.Show.Show DotParse.Types.ID
instance GHC.Classes.Eq DotParse.Types.ID
instance GHC.Generics.Generic DotParse.Types.Compass
instance GHC.Show.Show DotParse.Types.Compass
instance GHC.Classes.Eq DotParse.Types.Compass
instance GHC.Generics.Generic DotParse.Types.Port
instance GHC.Show.Show DotParse.Types.Port
instance GHC.Classes.Eq DotParse.Types.Port
instance GHC.Generics.Generic DotParse.Types.GlobalAttributeStatement
instance GHC.Show.Show DotParse.Types.GlobalAttributeStatement
instance GHC.Classes.Eq DotParse.Types.GlobalAttributeStatement
instance GHC.Generics.Generic DotParse.Types.AttributeType
instance GHC.Show.Show DotParse.Types.AttributeType
instance GHC.Classes.Eq DotParse.Types.AttributeType
instance GHC.Generics.Generic DotParse.Types.AttributeStatement
instance GHC.Show.Show DotParse.Types.AttributeStatement
instance GHC.Classes.Eq DotParse.Types.AttributeStatement
instance GHC.Generics.Generic DotParse.Types.NodeStatement
instance GHC.Show.Show DotParse.Types.NodeStatement
instance GHC.Classes.Eq DotParse.Types.NodeStatement
instance GHC.Generics.Generic DotParse.Types.EdgeOp
instance GHC.Show.Show DotParse.Types.EdgeOp
instance GHC.Classes.Eq DotParse.Types.EdgeOp
instance GHC.Generics.Generic DotParse.Types.EdgeID
instance GHC.Show.Show DotParse.Types.EdgeID
instance GHC.Classes.Eq DotParse.Types.EdgeID
instance GHC.Generics.Generic DotParse.Types.EdgeStatement
instance GHC.Show.Show DotParse.Types.EdgeStatement
instance GHC.Classes.Eq DotParse.Types.EdgeStatement
instance GHC.Generics.Generic DotParse.Types.Statement
instance GHC.Show.Show DotParse.Types.Statement
instance GHC.Classes.Eq DotParse.Types.Statement
instance GHC.Generics.Generic DotParse.Types.SubGraphStatement
instance GHC.Show.Show DotParse.Types.SubGraphStatement
instance GHC.Classes.Eq DotParse.Types.SubGraphStatement
instance GHC.Generics.Generic DotParse.Types.Graph
instance GHC.Show.Show DotParse.Types.Graph
instance GHC.Classes.Eq DotParse.Types.Graph
instance GHC.Generics.Generic DotParse.Types.NodeInfo
instance GHC.Show.Show DotParse.Types.NodeInfo
instance GHC.Classes.Eq DotParse.Types.NodeInfo
instance GHC.Generics.Generic DotParse.Types.EdgeInfo
instance GHC.Show.Show DotParse.Types.EdgeInfo
instance GHC.Classes.Eq DotParse.Types.EdgeInfo
instance GHC.Generics.Generic DotParse.Types.ChartConfig
instance GHC.Base.Semigroup DotParse.Types.Graph
instance GHC.Base.Monoid DotParse.Types.Graph
instance DotParse.Types.DotParse DotParse.Types.Graph
instance DotParse.Types.DotParse DotParse.Types.Statement
instance DotParse.Types.DotParse DotParse.Types.EdgeID
instance DotParse.Types.DotParse DotParse.Types.EdgeStatement
instance DotParse.Types.DotParse DotParse.Types.SubGraphStatement
instance DotParse.Types.DotParse DotParse.Types.EdgeOp
instance DotParse.Types.DotParse DotParse.Types.NodeStatement
instance DotParse.Types.DotParse DotParse.Types.AttributeStatement
instance DotParse.Types.DotParse DotParse.Types.AttributeType
instance DotParse.Types.DotParse DotParse.Types.GlobalAttributeStatement
instance DotParse.Types.DotParse DotParse.Types.Port
instance DotParse.Types.DotParse DotParse.Types.Compass
instance DotParse.Types.DotParse DotParse.Types.ID
instance DotParse.Types.DotParse (DotParse.Types.ID, DotParse.Types.ID)
instance DotParse.Types.DotParse (Data.Map.Internal.Map DotParse.Types.ID DotParse.Types.ID)
instance DotParse.Types.DotParse DotParse.Types.Directed
instance DotParse.Types.DotParse DotParse.Types.Strict
instance DotParse.Types.DotParse (NumHask.Space.Point.Point GHC.Types.Double)
instance DotParse.Types.DotParse (NumHask.Space.Rect.Rect GHC.Types.Double)
-- | Parser & Printer for the dot language of graphviz
--
-- See DotParse.Examples for usage.
module DotParse
-- | printing options, for separators.
data DotConfig
DotConfig :: ByteString -> ByteString -> ByteString -> ByteString -> DotConfig
[topLevelSep] :: DotConfig -> ByteString
[statementSep] :: DotConfig -> ByteString
[attSep] :: DotConfig -> ByteString
[subGraphSep] :: DotConfig -> ByteString
-- | default separators
defaultDotConfig :: DotConfig
-- | A parser & printer class for a graphviz graph and components of
-- its dot language
class DotParse a
dotPrint :: DotParse a => DotConfig -> a -> ByteString
dotParse :: DotParse a => Parser Error a
-- | dotParse and then dotPrint:
--
--
-- >>> import qualified Data.ByteString.Char8 as B
--
-- >>> B.putStrLn $ dotPrint defaultDotConfig defaultGraph
-- digraph {
-- node [height=0.5;shape=circle]
-- graph [overlap=false;size="1!";splines=spline]
-- edge [arrowsize=0.5]
-- }
--
defaultGraph :: Graph
-- | attributes lens
attL :: AttributeType -> ID -> Lens' Graph (Maybe ID)
-- | global attributes lens
gattL :: ID -> Lens' Graph (Maybe ID)
-- | run a dot string through graphviz, collecting the augmented dot string
-- output
processDot :: Directed -> ByteString -> IO ByteString
-- | run a dot string through graphviz, supplying arguments and collecting
-- stdout
processDotWith :: Directed -> [String] -> ByteString -> IO ByteString
-- | Augment a Graph via the graphviz process
processGraph :: Graph -> IO Graph
-- | Augment a Graph via the graphviz process
processGraphWith :: DotConfig -> Graph -> IO Graph
-- | MergeEdges (strict)
data Strict
MergeEdges :: Strict
NoMergeEdges :: Strict
-- | Default Strict is NoMergeEdges
defStrict :: Last Strict -> Strict
-- | Directed (digraph | graph)
data Directed
Directed :: Directed
UnDirected :: Directed
-- | Default Directed is Directed
defDirected :: Last Directed -> Directed
-- | Identifier as per the dot language specifications.
--
-- -- >>> runDotParser "0" :: ID -- IDInt 0 ---- --
-- >>> runDotParser "-.123" :: ID -- IDDouble (-0.123) ---- --
-- >>> runParser dotParse "apple_1'" :: Result Error ID -- OK (ID "apple_1") "'" ---- --
-- >>> :set -XQuasiQuotes -- -- >>> runParser dotParse "\"hello\"" :: Result Error ID -- OK (IDQuoted "hello") "" ---- --
-- >>> runDotParser "<The <font color='red'><b>foo</b></font>,<br/> the <font point-size='20'>bar</font> and<br/> the <i>baz</i>>" :: ID -- IDHtml "<The <font color='red'><b>foo</b></font>,<br/> the <font point-size='20'>bar</font> and<br/> the <i>baz</i>>" --data ID ID :: ByteString -> ID IDInt :: Int -> ID IDDouble :: Double -> ID IDQuoted :: ByteString -> ID IDHtml :: ByteString -> ID -- | ID as the equivalent plain String -- -- note that the dot language identifier equivalence law is: -- --
-- x == y if label x == label y --label :: ID -> String -- | Compass instructions which are optionally associated with an -- identifier data Compass CompassN :: Compass CompassNE :: Compass CompassE :: Compass CompassSE :: Compass CompassS :: Compass CompassSW :: Compass CompassW :: Compass CompassNW :: Compass CompassC :: Compass Compass_ :: Compass -- | Port instructions which are optionally associated with an identifier newtype Port Port :: These ID Compass -> Port [portID] :: Port -> These ID Compass -- | Category of attribute data AttributeType GraphType :: AttributeType NodeType :: AttributeType EdgeType :: AttributeType -- | Top-level attribute statement -- --
-- >>> runDotParser "graph [overlap=false, splines=spline, size=\"1!\"];" :: Statement
-- StatementAttribute (AttributeStatement {attributeType = GraphType, attributes = fromList [(ID "overlap",ID "false"),(ID "size",IDQuoted "1!"),(ID "splines",ID "spline")]})
--
data AttributeStatement
AttributeStatement :: AttributeType -> Map ID ID -> AttributeStatement
[attributeType] :: AttributeStatement -> AttributeType
[attributes] :: AttributeStatement -> Map ID ID
-- | Node statement
--
--
-- >>> runDotParser "A [shape=diamond; color=blue]" :: Statement
-- StatementNode (NodeStatement {nodeID = ID "A", port = Nothing, nodeAttrs = fromList [(ID "color",ID "blue"),(ID "shape",ID "diamond")]})
--
data NodeStatement
NodeStatement :: ID -> Maybe Port -> Map ID ID -> NodeStatement
[nodeID] :: NodeStatement -> ID
[port] :: NodeStatement -> Maybe Port
[nodeAttrs] :: NodeStatement -> Map ID ID
-- | An edge can be specified in as a NodeID or as a SubGraph
data EdgeID
EdgeID :: ID -> Maybe Port -> EdgeID
EdgeSubGraph :: SubGraphStatement -> EdgeID
-- | An edgeop is -> in directed graphs and -- in undirected graphs.
data EdgeOp
EdgeDirected :: EdgeOp
EdgeUndirected :: EdgeOp
-- | generate an EdgeOp given the type of graph.
fromDirected :: Directed -> EdgeOp
-- | Edge statement
--
--
-- >>> runDotParser "A -> B [style=dashed, color=grey]" :: Statement
-- StatementEdge (EdgeStatement {edgeOp = EdgeDirected, leftEdge = EdgeID (ID "A") Nothing, rightEdges = EdgeID (ID "B") Nothing :| [], edgeAttrs = fromList [(ID "color",ID "grey"),(ID "style",ID "dashed")]})
--
data EdgeStatement
EdgeStatement :: EdgeOp -> EdgeID -> NonEmpty EdgeID -> Map ID ID -> EdgeStatement
[edgeOp] :: EdgeStatement -> EdgeOp
[leftEdge] :: EdgeStatement -> EdgeID
[rightEdges] :: EdgeStatement -> NonEmpty EdgeID
[edgeAttrs] :: EdgeStatement -> Map ID ID
-- | The edge ID or subgraph ID (if any)
edgeID :: EdgeID -> Maybe ID
-- | list of edges in a given EdgeStatement, including anonymous SugGraphs
edgeIDs :: EdgeStatement -> [(Maybe ID, Maybe ID)]
-- | edge IDs
edgeIDsNamed :: EdgeStatement -> [(ID, ID)]
-- | A dot statement as per the dot language specification.
data Statement
StatementNode :: NodeStatement -> Statement
StatementEdge :: EdgeStatement -> Statement
StatementGlobalAttribute :: GlobalAttributeStatement -> Statement
StatementAttribute :: AttributeStatement -> Statement
StatementSubGraph :: SubGraphStatement -> Statement
-- | add a graphviz statement to a Graph
addStatement :: Statement -> Graph -> Graph
-- | add a list of graphviz statements to a Graph
addStatements :: [Statement] -> Graph -> Graph
-- | A subgraph statement.
--
-- Note: each subgraph must have a unique name
--
--
-- >>> runDotParser "subgraph A {A, B, C}" :: Statement
-- StatementSubGraph (SubGraphStatement {subgraphID = Just (ID "A"), subgraphStatements = [StatementNode (NodeStatement {nodeID = ID "A", port = Nothing, nodeAttrs = fromList []}),StatementNode (NodeStatement {nodeID = ID "B", port = Nothing, nodeAttrs = fromList []}),StatementNode (NodeStatement {nodeID = ID "C", port = Nothing, nodeAttrs = fromList []})]})
--
data SubGraphStatement
SubGraphStatement :: Maybe ID -> [Statement] -> SubGraphStatement
[subgraphID] :: SubGraphStatement -> Maybe ID
[subgraphStatements] :: SubGraphStatement -> [Statement]
-- | convert a Graph processed via the graphviz commands to a
-- ChartOptions
graphToChartWith :: ChartConfig -> Graph -> ChartOptions
-- | convert a Graph processed via the graphviz commands to a
-- ChartOptions using the default ChartConfig.
graphToChart :: Graph -> ChartOptions
-- | Various configutaion parameters for the chart-svg Chart
data ChartConfig
ChartConfig :: Double -> Double -> Double -> Colour -> Colour -> Double -> Double -> Double -> Double -> (ID -> Text) -> ChartConfig
[chartHeight] :: ChartConfig -> Double
[chartScale] :: ChartConfig -> Double
[edgeSize] :: ChartConfig -> Double
[chartColor] :: ChartConfig -> Colour
[chartBackgroundColor] :: ChartConfig -> Colour
[nodeHeight] :: ChartConfig -> Double
[nodeSize] :: ChartConfig -> Double
[vshift] :: ChartConfig -> Double
[textSize] :: ChartConfig -> Double
[labelf] :: ChartConfig -> ID -> Text
-- | default parameters
defaultChartConfig :: ChartConfig
-- | create Statements from a (no edge label) algebraic graph
toStatements :: Directed -> Graph ByteString -> [Statement]
-- | Convert an algebraic graph to a dotparse graph, starting with the
-- defaultGraph.
toDotGraph :: Graph ByteString -> Graph
-- | Convert an algebraic graph to a dotparse graph.
toDotGraphWith :: Directed -> Graph -> Graph ByteString -> Graph
-- | Example of Dot graph construction for the NumHask class heirarchy.
module DotParse.Examples.NumHask
data Class
Magma :: Class
Unital :: Class
Associative :: Class
Commutative :: Class
Invertible :: Class
Idempotent :: Class
Absorbing :: Class
Group :: Class
AbelianGroup :: Class
Additive :: Class
Subtractive :: Class
Multiplicative :: Class
Divisive :: Class
Distributive :: Class
Semiring :: Class
Ring :: Class
IntegralDomain :: Class
Field :: Class
ExpField :: Class
QuotientField :: Class
UpperBoundedField :: Class
LowerBoundedField :: Class
TrigField :: Class
AdditiveAction :: Class
SubtractiveAction :: Class
MultiplicativeAction :: Class
DivisiveAction :: Class
Module :: Class
JoinSemiLattice :: Class
MeetSemiLattice :: Class
Lattice :: Class
BoundedJoinSemiLattice :: Class
BoundedMeetSemiLattice :: Class
BoundedLattice :: Class
Integral :: Class
Ratio :: Class
Signed :: Class
Norm :: Class
Basis :: Class
Direction :: Class
Epsilon :: Class
data Family
Addition :: Family
Multiplication :: Family
Actor :: Family
data Dependency
Dependency :: Class -> Class -> Maybe Family -> Dependency
[_class] :: Dependency -> Class
[_dep] :: Dependency -> Class
[_op] :: Dependency -> Maybe Family
dependencies :: [Dependency]
classesNH :: [Class]
classesModule :: [(Class, Text)]
dependenciesNH :: [Dependency] -> [Dependency]
-- | NumHask Classes as an algebraic graph
graphNHG :: Graph Class
-- | NumHask statements in a dot Graph with box shapes for the nodes.
dotGraphNH :: Directed -> Graph
-- | dotGraphNH after being positionally processed via
-- processGraph
dotGraphNH' :: Directed -> Graph
-- | Convert a node ID to a label for chart-svg charts Doing this directly
-- in dot doesn't quite work because the engines get the width of the
-- link wrong.
toLink :: ID -> Text
-- | A chart-svg chart with label links
--
-- -- writeChartOptions "other/nh.svg" (graphToChart toLink (dotGraphNH' Directed)) ---- writeNHChart :: IO () instance GHC.Classes.Ord DotParse.Examples.NumHask.Class instance GHC.Classes.Eq DotParse.Examples.NumHask.Class instance GHC.Show.Show DotParse.Examples.NumHask.Class instance GHC.Classes.Ord DotParse.Examples.NumHask.Family instance GHC.Classes.Eq DotParse.Examples.NumHask.Family instance GHC.Show.Show DotParse.Examples.NumHask.Family instance GHC.Classes.Ord DotParse.Examples.NumHask.Dependency instance GHC.Classes.Eq DotParse.Examples.NumHask.Dependency instance GHC.Show.Show DotParse.Examples.NumHask.Dependency -- | Examples of conversion from dot ByteStrings -- -- Most examples from -- https://renenyffenegger.ch/notes/tools/Graphviz/examples/index module DotParse.Examples -- | minimal definition -- --
-- >>> runDotParser ex0 :: Graph
-- Graph {strict = Last {getLast = Just NoMergeEdges}, directed = Last {getLast = Just UnDirected}, graphid = Last {getLast = Nothing}, nodeAttributes = fromList [], graphAttributes = fromList [], edgeAttributes = fromList [], globalAttributes = fromList [], nodes = [], edges = [], subgraphs = []}
--
--
-- -- >>> testDotParser (Proxy :: Proxy Graph) defaultDotConfig ex0 --ex0 :: ByteString ex1 :: ByteString ex2 :: ByteString ex3 :: ByteString ex4 :: ByteString ex5 :: ByteString ex6 :: ByteString ex7 :: ByteString ex8 :: ByteString ex9 :: ByteString ex10 :: ByteString ex11 :: ByteString ex12 :: ByteString ex13 :: ByteString ex14 :: ByteString ex15 :: ByteString -- | Test all the examples testAll :: IO () -- | Render all the examples svgAll :: IO () -- | algebraic graph example -- --
-- >>> exGraph = defaultGraph & addStatements (toStatements Directed (Char8.pack . show <$> exAGraph)) -- -- >>> exGraphAugmented <- processGraph exGraph -- -- >>> writeChartOptions "other/exga.svg" (graphToChartWith defaultChartConfig exGraphAugmented) ---- exAGraph :: Graph Int