What's New in Version 2
Changes and improvements in Morphir IR schema version 2
Format version 2 introduced capitalized tags for distribution, access control, and types, while keeping value and pattern tags lowercase.
Version 2 of the Morphir IR format represents a transition between version 1 (all lowercase) and version 3 (all capitalized). It uses capitalized tags for distribution, access control, and types, but keeps value expressions and patterns in lowercase.
Version 2 uses a mixed capitalization approach:
Capitalized:
"Library" (capitalized)"Public" and "Private" (capitalized)"Variable", "Reference", "Tuple", "Record", etc.Lowercase:
"apply", "lambda", "let_definition", etc."as_pattern", "wildcard_pattern", etc."bool_literal", "string_literal", etc.Version 2 changed the module structure from objects to arrays:
modules:
type: array
items:
type: array
minItems: 2
maxItems: 2
items:
- $ref: "#/definitions/ModuleName"
- allOf:
- $ref: "#/definitions/AccessControlled"
- properties:
value:
$ref: "#/definitions/ModuleDefinition"
This is a significant change from version 1’s {"name": ..., "def": ...} structure.
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)"Public", "Private")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]"Library" tagdistribution:
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.
[name, accessControlledDefinition] pairsPublic interface of a package.
Complete implementation of a module.
Public interface of a module.
The type system is based on functional programming principles, supporting:
Version 2 note: Type tags are capitalized in version 2.
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.
Version 2 note: Value tags are lowercase in version 2.
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)ApplyValue:
type: array
minItems: 4
maxItems: 4
items:
- const: "apply"
- $ref: "#/definitions/Attributes"
- $ref: "#/definitions/Value"
- $ref: "#/definitions/Value"
Anonymous function.
["lambda", attributes, argumentPattern, body]\x -> x + 1LambdaValue:
type: array
minItems: 4
maxItems: 4
items:
- const: "lambda"
- $ref: "#/definitions/Attributes"
- $ref: "#/definitions/Pattern"
- $ref: "#/definitions/Value"
Let binding introducing a single value.
["let_definition", attributes, bindingName, definition, inExpr]let x = 5 in x + xConditional expression.
["if_then_else", attributes, condition, thenBranch, elseBranch]if x > 0 then "positive" else "non-positive"Pattern matching with multiple cases.
["pattern_match", attributes, valueToMatch, cases]case maybeValue of Just x -> x; Nothing -> 0Used for destructuring and filtering values.
Version 2 note: Pattern tags are lowercase in version 2.
Matches any value without binding.
["wildcard_pattern", attributes]_Binds a name to a matched value.
["as_pattern", attributes, nestedPattern, variableName]as_pattern with wildcard_patternMatches specific type constructor and arguments.
["constructor_pattern", attributes, fqName, argPatterns]Just x matches Just with pattern xVersion 2 note: Literal tags are lowercase in version 2.
Boolean literal.
["bool_literal", boolean]true or falseBoolLiteral:
type: array
minItems: 2
maxItems: 2
items:
- const: "bool_literal"
- type: boolean
Text string literal.
["string_literal", string]"hello"StringLiteral:
type: array
minItems: 2
maxItems: 2
items:
- const: "string_literal"
- type: string
Integer literal.
["whole_number_literal", integer]42, -17When migrating from version 2 to version 3:
"apply" → "Apply", "lambda" → "Lambda", etc."as_pattern" → "AsPattern", "wildcard_pattern" → "WildcardPattern", etc."bool_literal" → "BoolLiteral", "string_literal" → "StringLiteral", etc.For the complete schema definition, see the full schema page.
Changes and improvements in Morphir IR schema version 2
Complete Morphir IR JSON Schema for format version 2
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.