finos / morphir-elm / Morphir.Graph.Grapher

The Grapher module analyses a distribution to build a graph for dependency and lineage tracking purposes. The goal is to understand data flow and to automate contribution to the types of products that are commonly used in enterprises. The result of processing is a Graph, which is a collection of Nodes and Edges.

Types


type Node
    = Record Morphir.IR.FQName.FQName
    | Field Morphir.IR.FQName.FQName Morphir.IR.Name.Name
    | Type Morphir.IR.FQName.FQName
    | Function Morphir.IR.FQName.FQName
    | Enum Morphir.IR.FQName.FQName
    | UnitOfMeasure Morphir.IR.FQName.FQName
    | Unknown String

Node defines a node in the graph. We capture specific node types for this purpose. The types of constructs that we're interested in tracking are:


type Verb
    = IsA
    | Aliases
    | Contains
    | Uses
    | Calls
    | Produces
    | Parameterizes
    | Measures
    | Unions
    | Enumerates

Verb defines the possible relationships that we're interested in tracking. These are used to define the relationships in the edges of our graph.


type alias Edge =
{ subject : Node
, verb : Verb
, object : Node 
}

Defines an edge in the graph as a triple of the subject node, the relationship, and the object node.


type GraphEntry
    = NodeEntry Node
    | EdgeEntry Edge

Defines the possible graph entries of Node and Edge.


type alias Graph =
List GraphEntry

Defines a graph as a collection of nodes and edges.

Processing

mapDistribution : Morphir.IR.Distribution.Distribution -> Graph

Process this distribution into a Graph of its packages.

mapPackageDefinition : Morphir.IR.Package.PackageName -> Morphir.IR.Package.Definition ta va -> Graph

Process this package into a Graph of its modules. We take two passes to the IR. The first collects all of the types and the second processes the functions and their relationships to those types.

mapModuleTypes : Morphir.IR.Package.PackageName -> Morphir.IR.Module.ModuleName -> Morphir.IR.Module.Definition ta va -> Graph

Process this module to collect the types used and produced by it.

mapModuleValues : Morphir.IR.Package.PackageName -> Morphir.IR.Module.ModuleName -> Morphir.IR.Module.Definition ta va -> Dict String Node -> Graph

Process this module to collect the functions and relationships to types.

mapTypeDefinition : Morphir.IR.Package.PackageName -> Morphir.IR.Module.ModuleName -> Morphir.IR.Name.Name -> Morphir.IR.Type.Definition ta -> Graph

Process a type since there are a lot of variations.

mapValueDefinition : Morphir.IR.Package.PackageName -> Morphir.IR.Module.ModuleName -> Morphir.IR.Name.Name -> Morphir.IR.Value.Definition ta va -> Dict String Node -> Graph

Process Functions specifically and ignore the rest.

Utilities

graphEntryToComparable : GraphEntry -> String

Utility for dealing with comparable.

nodeType : Node -> String

Utility to extract the Node type as a String.

verbToString : Verb -> String

Utility for dealing with comparable.

nodeFQN : Node -> Morphir.IR.FQName.FQName

Utility to extract the Fully Qualified Name from a Node. This is required because a Field contains both an FQN and field name.

asEnum : Morphir.IR.Type.Definition ta -> List Morphir.IR.Name.Name

edgeFromTuple : ( Node, Verb, Node ) -> Edge

Converte Edge record to tuple

edgeToTuple : Edge -> ( Node, Verb, Node )

Converte Edge record to tuple

fqnToString : Morphir.IR.FQName.FQName -> String

Utility for dealing with comparable.