A data type that represents a node in the IR
Represents a node in the IR. Could be a Type, Value or Module
List NodePathStep
Represents a path in the IR. This is a recursive structure made up of the following building blocks:
The path should be constructed in a reverse order: the node at the top will be the last step in the path
Example usage:
type alias Foo =
{ field1 : Bool
, field2 :
{ field1 : Int
, field2 : ( String, Float )
}
}
NodePath.fromList [] -- Refers to type "Foo" itself
NodePath.fromList [ ChildByName "field1" ] -- Refers to Bool
NodePath.fromList [ ChildByName "field2", ChildByName "field1" ] -- Refers to Int
NodePath.fromList [ ChildByName "field2", ChildByName "field2", ChildByIndex 1 ] -- Refers to Float
Represents a path to a child node
nodeIdFromString : String -> Result Error NodeID
Try to parse a string into NodeID. Return an Error if it's not a valid NodeID.
nodeIdToString : NodeID -> String
Convert a NodeID to String.
nodePathFromString : String -> NodePath
Parse a String into a NodePath.
nodePathToString : NodePath -> String
Convert a NodePath to String.
getAttribute : Morphir.IR.Package.Definition attr attr -> NodeID -> Result Error attr
Get attribute from a module, type or value by NodeID. Return error, if the NodeID is invalid.
mapPatternAttributesWithNodePath : (NodePath -> attr -> attr2) -> Morphir.IR.Value.Pattern attr -> Morphir.IR.Value.Pattern attr2
Applies the given map function to the attributes of every node of the given pattern.
mapTypeAttributeWithNodePath : (NodePath -> attr -> attr2) -> Morphir.IR.Type.Type attr -> Morphir.IR.Type.Type attr2
Applies the given map function to the attributes of every node of the given type.
mapValueAttributesWithNodePath : (NodePath -> attr -> attr2) -> Morphir.IR.Value.Value attr attr -> Morphir.IR.Value.Value attr2 attr2
Applies the given map function to the attributes of every node of the given value.
getTypeAttributeByPath : NodePath -> Morphir.IR.Type.Type attr -> Result Error attr
Get type attribute by NodePath. Return an Error if the NodePath is invalid.
getValueAttributeByPath : NodePath -> Morphir.IR.Value.Value attr attr -> Result Error attr
Get value attribute by NodePath. Return an Error if the NodePath is invalid.
Represents an error that might occur during node operations