Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Nested datatype to track the resolution algorithm
From this data type we can draw a graph of the full instantiation of a value
Synopsis
- makeEdges :: Operations -> [(Value, Value)]
- newtype Dot = Dot {}
- type DotState = State ValuesByType
- type ValuesByType = Map SomeTypeRep ValueHashes
- type Hash = Int
- type ValueId = Int
- type ValueHashes = [Hash]
- type Edge = (Value, Value)
- type Edges = [Edge]
- type ValueCounter = Maybe Int
- toDot :: Operations -> Dot
- countValueTypes :: Value -> DotState ()
- toDotEdge :: ValuesByType -> (Value, Value) -> Text
- toDotVertex :: ValuesByType -> Value -> Text
- hashOf :: Value -> Int
- nodeDescription :: ValueDescription -> ValueCounter -> Text
- showValueCounter :: ValueCounter -> Text
- adjust :: Text -> Text
- removeQuotes :: Text -> Text
- escapeNewlines :: Text -> Text
Documentation
makeEdges :: Operations -> [(Value, Value)] Source #
Make a list of graph edges from the list of function applications
DOT GRAPH
A DOT graph
type DotState = State ValuesByType Source #
Use a State type to get the current index of a value when there are values of the same type and different hash values
type ValuesByType = Map SomeTypeRep ValueHashes Source #
List of value hashes by value type
type ValueHashes = [Hash] Source #
Type alias for a list of hashes
type ValueCounter = Maybe Int Source #
Type alias for associating a number to a value
toDot :: Operations -> Dot Source #
Make a DOT graph out of all the function applications
countValueTypes :: Value -> DotState () Source #
Update a map classifying values by type
toDotEdge :: ValuesByType -> (Value, Value) -> Text Source #
A DOT edge representing the dependency between 2 values
toDotVertex :: ValuesByType -> Value -> Text Source #
Represent a value as a vertex in a dot graph we use some state to keep track of values of the same type The values are numbered starting from 1 when there are several of them for the same type
nodeDescription :: ValueDescription -> ValueCounter -> Text Source #
Description of a Value in the DOT graph
showValueCounter :: ValueCounter -> Text Source #
Don't show the counter if there
adjust :: Text -> Text Source #
We need to process the node descriptions - we add quotes arountd the text - we remove quotes (") inside the text - we escape newlines
removeQuotes :: Text -> Text Source #
Remove quotes from a textual description to avoid breaking the DOT format
escapeNewlines :: Text -> Text Source #
Replace n with \n so that newlines are kept in node descriptions