Overview
Types are data classifications that tell the MUFL development environment how to handle data at compile time. As a compile-time construct, MUFL types define the statically-known sets of values valid in a given context.
For a description of the difference between compile-time types and runtime domains, refer to Types vs. Domains.
Types are represented by type expressions and are used to:
- Declare variable types during initialization.
- Specify arguments to functions and transactions.
- Specify return values from functions and transactions.
- Provide type arguments to generic modules.
For example,
A is int = 1. // declare A is an integer type
B is int||str = "hello". // declare B as either an integer or string.
fn F (x:int) -> str = (_str x). // declare a function that takes an integer `x` and returns a string.
When type is omitted, the corresponding item is implicitly declared depending on the context:
- In variable initialization, an omitted type is inferred from context.
- In all other contexts, an omitted type is treated as type
any
.