| Copyright | (C) 2023 Alexey Tochin |
|---|---|
| License | BSD3 (see the file LICENSE) |
| Maintainer | Alexey Tochin <Alexey.Tochin@gmail.com> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
| Extensions |
|
Debug.SimpleExpr.GraphUtils
Description
Tools for transforming simple expressions to graphs from graphite.
Synopsis
- exprToGraph :: Expr d => d -> DGraph String ()
- plotExpr :: Expr d => d -> IO ThreadId
- plotDGraphPng :: (Hashable v, Ord v, PrintDot v, Show v, Show e) => DGraph v e -> FilePath -> IO FilePath
- simpleExprToGraph :: SimpleExpr -> DGraph String ()
- appendNodeToGraph :: String -> [String] -> DGraph String () -> DGraph String ()
Conversion simple expressions to graphs
exprToGraph :: Expr d => d -> DGraph String () Source #
Transforms an expression to graph.
Examples of usage
>>>import Debug.SimpleExpr (variable)>>>import NumHask ((+), (-))
>>>x = variable "x">>>y = variable "y">>>exprToGraph [x + y, x - y]...
We expect something like
fromList [("y",[("x-y",()),("x+y",())]),("x-y",[]),("x",[("x-y",()),("x+y",())]),("x+y",[])]
depending on the packages version version.
Visualisation
plotExpr :: Expr d => d -> IO ThreadId Source #
Visualizes an expression.
Examples of usage
>>>import Debug.SimpleExpr (number, variable)>>>import NumHask ((+), (-))>>>import Data.Graph.VisualizeAlternative (plotDGraphPng)
>>> plotExpr (number 1 + variable "x")

>>>x = variable "x">>>y = variable "y"
>>> plotExpr [x + y, x - y]

plotDGraphPng :: (Hashable v, Ord v, PrintDot v, Show v, Show e) => DGraph v e -> FilePath -> IO FilePath Source #
Auxiliary functions
simpleExprToGraph :: SimpleExpr -> DGraph String () Source #
Transforms a simple expression to graph.