Replies: 2 comments 3 replies
-
|
As we discussed on our community call yesterday we want to slightly change this and move the type/value flag as a suffix of the local name. This has a few benefits:
So the examples would change as such:
|
Beta Was this translation helpful? Give feedback.
-
|
@AttilaMihaly , @stephengoldbaum , @bekand where did we finally land on this. I'm looking at the I have a use-case for See: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
NodeID - a way to identify Morphir IR nodes
Introduction
Several requirements of the Decorations feature require us to have the ability to refer to specific nodes inside of a Morphir IR. To that end, the following proposal describes "NodeID", a way to refer to Morphir IR nodes in a way that resembles URLs.
Structure
A NodeID can have two slightly different structures depending on if we are refering to modules or definitions (types/values).
"<Package>:<Module>""<Package>:<Module>:<localName><.type or .value>#<nodePath>", where nodePath is optionalExamples of valid NodeIDs:
"Morphir.Reference.Model:BooksAndRecords""Morphir.Reference.Model:BooksAndRecords:deal.type""Morphir.Reference.Model:BooksAndRecords:deal.value#1"Referring to modules
We can refer to modules by their Qualified Name. Types and Values are differentiated with a
.typeor.valuesuffix on the last Name before the NodePath part. If no such suffix is present, the ID in question must refer to a moduleFor example:
"Morphir.Reference.Model:BooksAndRecords"refers to the
Books and Recordsmodule inside theMorphir.Reference.Modelpackage.Referring to top level types and values
We can refer to Morphir types and values inside modules with their Fully Qualified Name, suffixed with a
.typeor.valuetag. This is necessary, because it is valid (and not unusual) for a Morphir module to contain both a type and a value under the same name (e.g.: ANumbermodule containing a type calledIntand a function calledint)."Some.Package:SomeModule:foo.type"would refer to theFootype inside theSomeModulemodule inside theSome.Packagepackage. while"Some.Package:SomeModule:foo.value"would refer to thefoofunction inside theSomeModulemodule inside theSome.Packagepackage.NodePath - Referring to types and values inside other types and values
We can refer to nodes inside top level type or value node with a node path.
A node path is composed of node path steps, which can be either a string when referring to something by name (for example a record field, or function arguments), or an integer, when referring to something by it's position (for example in the case of lists, tuples, pattern match cases, but can also be used for function arguments)
For example if, you have a type defined as:
then a NodeID with the following node path (starting with #)
"Morphir.Package:FooModule:foo.type#tuplefield:1"would refer to the
Stringmember of thetupleFieldfield of theFootype.The general rule of thumb would be that when things have a well defined name (e.g.: record fields or arguments of a function definition) they would be referred to with a string, and anything else with an index.
Frequent usecases
...foo#fieldNamerefers to the fieldName field of the foo recordsomeTypeis declared asa -> b -> c -> dyou will be able to refer toaassomeType.type#args:0,cassomeType.type#args:2anddassomeType.type#outputyou will be able to refer to the arguments by index (as seen in the previous case), or by specifying the argument name, like
add3.value#args:bBeta Was this translation helpful? Give feedback.
All reactions