What's New in Version 3
Changes and improvements in Morphir IR schema version 3
Format version 3 is the current version of the Morphir IR format. It uses capitalized tags throughout for consistency and clarity.
Version 3 of the Morphir IR format standardizes on capitalized tags for all constructs. This provides a consistent naming convention across the entire IR structure.
All tags in version 3 are capitalized:
"Library""Public" and "Private""Variable", "Reference", "Tuple", "Record", etc."Apply", "Lambda", "LetDefinition", etc."AsPattern", "WildcardPattern", "ConstructorPattern", etc."BoolLiteral", "StringLiteral", "WholeNumberLiteral", etc.The Morphir IR uses a sophisticated naming system independent of any specific naming convention.
A Name represents a human-readable identifier made up of one or more words.
["value", "in", "u", "s", "d"] renders as valueInUSD or value_in_USDName:
type: array
items:
type: string
pattern: "^[a-z][a-z0-9]*$"
minItems: 1
A Path represents a hierarchical location in the IR structure.
[["morphir"], ["s", "d", "k"], ["string"]] for the String modulePath:
type: array
items:
$ref: "#/definitions/Name"
minItems: 1
Provides globally unique identifiers for types and values.
[packagePath, modulePath, localName]FQName:
type: array
minItems: 3
maxItems: 3
items:
- $ref: "#/definitions/PackageName"
- $ref: "#/definitions/ModuleName"
- $ref: "#/definitions/Name"
Manages visibility of types and values.
{access, value}"Public" (visible externally) or "Private" (package-only)AccessControlled:
type: object
required: ["access", "value"]
properties:
access:
type: string
enum: ["Public", "Private"]
value:
description: "The value being access controlled."
A Distribution represents a complete, self-contained package with all dependencies.
["Library", packageName, dependencies, packageDefinition]distribution:
type: array
minItems: 4
maxItems: 4
items:
- type: string
const: "Library"
- $ref: "#/definitions/PackageName"
- $ref: "#/definitions/Dependencies"
- $ref: "#/definitions/PackageDefinition"
Complete implementation of a package with all details.
Public interface of a package.
Complete implementation of a module.
Public interface of a module.
The type system is based on functional programming principles, supporting:
Represents a type variable (generic parameter).
["Variable", attributes, name]a in List aVariableType:
type: array
minItems: 3
maxItems: 3
items:
- const: "Variable"
- $ref: "#/definitions/Attributes"
- $ref: "#/definitions/Name"
Reference to another type or type alias.
["Reference", attributes, fqName, typeArgs]String, List Int, Maybe aReferenceType:
type: array
minItems: 4
maxItems: 4
items:
- const: "Reference"
- $ref: "#/definitions/Attributes"
- $ref: "#/definitions/FQName"
- type: array
items:
$ref: "#/definitions/Type"
Composition of multiple types in fixed order.
["Tuple", attributes, elementTypes](Int, String, Bool)Composition of named fields with types.
["Record", attributes, fields]{firstName: String, age: Int}Function type representation.
["Function", attributes, argType, returnType]Int -> StringAn alias for another type.
["TypeAliasSpecification", typeParams, aliasedType]type alias UserId = StringTagged union type (sum type).
["CustomTypeSpecification", typeParams, constructors]type Result e a = Ok a | Err eType with unknown structure.
["OpaqueTypeSpecification", typeParams]All data and logic in Morphir are represented as value expressions.
Literal constant value.
["Literal", attributes, literal]Reference to a variable in scope.
["Variable", attributes, name]Reference to a defined value (function or constant).
["Reference", attributes, fqName]Morphir.SDK.List.map, Basics.addFunction application.
["Apply", attributes, function, argument]add 1 2 (nested Apply nodes for currying)Anonymous function.
["Lambda", attributes, argumentPattern, body]\x -> x + 1Let binding introducing a single value.
["LetDefinition", attributes, bindingName, definition, inExpr]let x = 5 in x + xConditional expression.
["IfThenElse", attributes, condition, thenBranch, elseBranch]if x > 0 then "positive" else "non-positive"Pattern matching with multiple cases.
["PatternMatch", attributes, valueToMatch, cases]case maybeValue of Just x -> x; Nothing -> 0Used for destructuring and filtering values.
Matches any value without binding.
["WildcardPattern", attributes]_Binds a name to a matched value.
["AsPattern", attributes, nestedPattern, variableName]AsPattern with WildcardPatternMatches specific type constructor and arguments.
["ConstructorPattern", attributes, fqName, argPatterns]Just x matches Just with pattern xBoolean literal.
["BoolLiteral", boolean]true or falseBoolLiteral:
type: array
minItems: 2
maxItems: 2
items:
- const: "BoolLiteral"
- type: boolean
Text string literal.
["StringLiteral", string]"hello"StringLiteral:
type: array
minItems: 2
maxItems: 2
items:
- const: "StringLiteral"
- type: string
Integer literal.
["WholeNumberLiteral", integer]42, -17Version 3 is the recommended format for new Morphir IR files. It provides:
For the complete schema definition, see the full schema page.
Changes and improvements in Morphir IR schema version 3
Complete Morphir IR JSON Schema for format version 3
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.