{"id":27991248,"url":"https://github.com/ta0kira/zeolite","last_synced_at":"2025-05-08T16:57:05.001Z","repository":{"id":44139282,"uuid":"166813141","full_name":"ta0kira/zeolite","owner":"ta0kira","description":" Zeolite is a statically-typed, general-purpose programming language.","archived":false,"fork":false,"pushed_at":"2024-10-19T20:42:38.000Z","size":3675,"stargazers_count":19,"open_issues_count":10,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T16:56:52.177Z","etag":null,"topics":["compiler","freebsd","linux","macos","programming-language","zeolite-lang"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ta0kira.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-01-21T12:48:36.000Z","updated_at":"2024-11-03T23:41:20.000Z","dependencies_parsed_at":"2023-11-26T01:25:37.161Z","dependency_job_id":"1adcda01-8f98-4f44-b486-3687f2c49268","html_url":"https://github.com/ta0kira/zeolite","commit_stats":{"total_commits":1826,"total_committers":2,"mean_commits":913.0,"dds":0.0005476451259583959,"last_synced_commit":"f8a4a4995b6e296cf5272ef241ce0be7769c4f5a"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ta0kira%2Fzeolite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ta0kira%2Fzeolite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ta0kira%2Fzeolite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ta0kira%2Fzeolite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ta0kira","download_url":"https://codeload.github.com/ta0kira/zeolite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112073,"owners_count":21856070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","freebsd","linux","macos","programming-language","zeolite-lang"],"created_at":"2025-05-08T16:57:03.243Z","updated_at":"2025-05-08T16:57:04.970Z","avatar_url":"https://github.com/ta0kira.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Zeolite Programming Language][zeolite]\n\n[![Haskell CI Status][action-status]][action-zeolite]\n[![Hackage Status][hackage-status]][hackage-zeolite-lang]\n\nZeolite is a statically-typed, general-purpose programming language. The type\nsystem revolves around defining objects and their usage patterns.\n\nZeolite prioritizes making it easy to write maintainable and understandable\ncode. This is done by rethinking standard language idioms and limiting\nflexibility in some places while increasing it in others. In particular,\nemphasis is placed on the user's experience when troubleshooting code that is\n*incorrect*.\n\nThe design of the type system and the language itself is influenced by positive\nand negative experiences with Java, C++, Haskell, Python, Ruby, and Go, with\ncollaborative development, and with various systems of code-quality enforcement.\n\nDue to the way GitHub renders embedded HTML, the colors might not show up in the\nsyntax-highlighted code in this document. If you use the Chrome browser, you can\nview the intended formatting using the\n[Markdown Viewer](https://chrome.google.com/webstore/detail/markdown-viewer/ckkdlimhmcjmikdlpkmbgfkaikojcbjk)\nextension to view the\n[raw version](https://raw.githubusercontent.com/ta0kira/zeolite/master/README.md)\nof this document.\n\n## Table of Contents\n\n- [Project Status](#project-status)\n- [Language Overview](#language-overview)\n  - [Programming Paradigms](#programming-paradigms)\n  - [Parameter Variance](#parameter-variance)\n  - [Parameters as Variables](#parameters-as-variables)\n  - [Integrated Test Runner](#integrated-test-runner)\n  - [Integrated Build System](#integrated-build-system)\n  - [Data Encapsulation](#data-encapsulation)\n- [Quick Start](#quick-start)\n  - [Installation](#installation)\n  - [Hello World](#hello-world)\n- [Writing Programs](#writing-programs)\n  - [Basic Ideas](#basic-ideas)\n  - [Declaring Functions](#declaring-functions)\n  - [Defining Functions](#defining-functions)\n    - [Using Variables](#using-variables)\n    - [Calling Functions](#calling-functions)\n    - [Functions As Operators](#functions-as-operators)\n    - [Data Members and Value Creation](#data-members-and-value-creation)\n    - [Conditionals](#conditionals)\n    - [Scoping and Cleanup](#scoping-and-cleanup)\n    - [Loops](#loops)\n    - [Multiple Returns](#multiple-returns)\n    - [Optional and Weak Values](#optional-and-weak-values)\n    - [Deferred Variable Initialization](#deferred-variable-initialization)\n    - [Immediate Program Termination](#immediate-program-termination)\n    - [Call Delegation](#call-delegation)\n  - [Function Argument Labels](#function-argument-labels)\n  - [Using Parameters](#using-parameters)\n  - [Using Interfaces](#using-interfaces)\n  - [Immutable Types](#immutable-types)\n  - [The `#self` Parameter](#the-self-parameter)\n  - [Type Inference](#type-inference)\n  - [Other Features](#other-features)\n    - [Meta Types](#meta-types)\n    - [Explicit Type Conversion](#explicit-type-conversion)\n    - [Runtime Type Reduction](#runtime-type-reduction)\n    - [Value Instance Comparison](#value-instance-comparison)\n    - [Limited Function Visibility](#limited-function-visibility)\n  - [Builtins](#builtins)\n    - [Reserved Words](#reserved-words)\n    - [Builtin Types](#builtin-types)\n    - [Builtin Constants](#builtin-constants)\n    - [Builtin Functions](#builtin-functions)\n    - [Procedural Operators](#procedural-operators)\n- [Layout and Dependencies](#layout-and-dependencies)\n  - [Using Public Source Files](#using-public-source-files)\n  - [Standard Library](#standard-library)\n  - [Modules](#modules)\n- [Unit Testing](#unit-testing)\n  - [Writing Tests](#writing-tests)\n  - [Code Coverage](#code-coverage)\n- [Compiler Pragmas and Macros](#compiler-pragmas-and-macros)\n  - [Source File Pragmas](#source-file-pragmas)\n  - [Procedure Pragmas](#procedure-pragmas)\n  - [`define` Pragmas](#define-pragmas)\n  - [`unittest` Pragmas](#unittest-pragmas)\n  - [Local Variable Rules](#local-variable-rules)\n  - [Expression Macros](#expression-macros)\n- [Known Language Limitations](#known-language-limitations)\n  - [Reference Counting](#reference-counting)\n\n## Project Status\n\nZeolite is still evolving in all areas (syntax, build system, etc.), and it\nstill lacks a lot of standard library functionality. That said, it was designed\nwith practical applications in mind. It *does not* prioritize having\nimpressive toy examples (e.g., merge-sort or \"Hello World\" in one line); the\nreal value is seen in programs with higher relational complexity.\n\n## Language Overview\n\nThis section discusses some of the features that make Zeolite unique. It does\nnot go into detail about all of the language's features; see\n[Writing Programs](#writing-programs) and the [full examples][examples] for more\nspecific language information.\n\n### Programming Paradigms\n\nZeolite currently uses both [procedural][procedural] and [object-oriented][oop]\nprogramming paradigms. It shares many features with Java, but it also has\nadditional features and restrictions meant to simplify code maintenance.\n\n### Parameter Variance\n\nThe initial motivation for Zeolite was a type system that allows implicit\nconversions between different parameterizations of parameterized types. A\nparameterized type is a type with type \"place-holders\", e.g., `template`s in C++\nand generics in Java.\n\nJava and C++ *do not* allow you to safely convert between different\nparameterizations. For example, you cannot safely convert a `List\u003cString\u003e` into\na `List\u003cObject\u003e` in Java. This is primarily because `List` uses its type\nparameter for both input and output.\n\nZeolite, on the other hand, uses [declaration-site variance][variance] for each\nparameter. (C# also does this to a lesser extent.) This allows the language to\nsupport very powerful recursive type conversions for parameterized types.\nZeolite *also* allows [use-site variance][variance] declarations, like Java\nuses.\n\nBuilding variance into the core of the type system also allows Zeolite to have a\n[special meta-type](#the-self-parameter) that interfaces can use to require that\nimplementations return a value of *their own type* rather than *the type of the\ninterface*. This is particularly useful for defining interfaces for iterators\nand builders, whose methods often perform an update and return a value of the\nsame type.\n\n### Parameters as Variables\n\nZeolite treats type parameters both as type place-holders (like in C++ and\nJava) and as *type variables* that you can call functions on. This further\nallows Zeolite to have interfaces that declare functions that operate on *types*\nin addition to interfaces that declare functions that operate on *values*. (This\nwould be like having `abstract static` methods in Java.)\n\nThis helps solve a few separate problems:\n\n- Operations like `equals` comparisons in Java are always dispatched to the\n  *left* object, which could lead to inconsistent results if the objects are\n  swapped: `foo.equals(bar)` is not the same as `bar.equals(foo)`. This\n  dispatching asymmetry can be eliminated by making `equals` a type function\n  (e.g., `MyType.equals(foo, bar)`), and further creating an interface that\n  requires implementations to support such calls.\n\n- Factory patterns can be abstracted out into interfaces. For example, you could\n  create a factory interface that requires an implementation to parse a new\n  object from a `String`, without needing to instantiate the factory object\n  itself. You could just implement the factory function directly in `MyType`,\n  without needing a separate `MyTypeFactory`.\n\n### Integrated Test Runner\n\nThe major advantage of statically-typed programming languages is their\ncompile-time detection of code that *should not* be allowed. On the other hand,\nthere is a major testability gap when it comes to ensuring that your\nstatically-typed code *disallows* what you expect it to.\n\nZeolite has a special source-file extension for unit tests, and a built-in\ncompiler mode to run them.\n\n- Tests can check for runtime success, compilation success, compilation failure,\n  and even crashes. Normally you would need a third-party test runner to check\n  for required compilation failures and crashes.\n\n- The test mode includes a command-line option to collect code-coverage data,\n  which can be critical for determining test efficacy.\n\nNearly all of the integration testing of the Zeolite language itself is done\nusing this feature, but it is also supported for general use with Zeolite\nprojects.\n\n### Integrated Build System\n\nThe Zeolite compiler supports a module system that can incrementally compile\nprojects without the user needing to create build scripts or `Makefile`s.\n\n- Modules are configured via a simple config file.\n- File-level and symbol-level imports and includes *are not* necessary, allowing\n  module authors to freely rearrange file structure.\n- Type dependencies are automatically resolved during linking so that output\n  binaries contain only the code that is relevant.\n- Module authors can back Zeolite code with C++.\n- The module system is integrated with the compiler's built-in testing mode.\n\nThis means that the programmer can focus on code rather than on build rules, and\nmodule authors can avoid writing verbose build instructions for the users of\ntheir modules.\n\n### Data Encapsulation\n\nThe overall design of Zeolite revolves around data encapsulation:\n\n- **No default construction or copying.** This means that objects can only be\n  created by explicit factory functions. (A very common mistake in C++ code is\n  forgetting to *disallow or override* default construction or copying.) This\n  also means that accidental deep copying is not even possible in Zeolite.\n\n- **Only abstract interfaces can be inherited.** Types that define procedures or\n  contain data members *cannot* be further extended. This encourages the\n  programmer to think more about usage patterns and less about data\n  representation when designing interactions between types.\n\n- **No \"privileged\" data-member access.** No object has *direct* access to the\n  data members of any other object; not even other objects of the same type.\n  This forces the programmer to also think about usage patterns when dealing\n  with other objects of the same type.\n\n- **No `null` values.** Every variable must be explicitly initialized. This\n  obviates questions of whether or not a variable actually contains a value.\n  When combined with the elimination of default construction, this means that a\n  variable can only hold values that a type author has specifically allowed.\n\n  Zeolite has an `optional` storage modifier for use in a variable's type, but\n  it creates a new and incompatible type, whose value cannot be used without\n  first extracting it. This is in contrast to Java allowing any variable to be\n  `null`. (It is more like `Optional` in Java 8, but as built-in syntax, and\n  with nesting disallowed.)\n\n- **No reflection or down-casting.** The only thing that has access to the\n  \"real\" type of a value is the value itself. This means that the reflection and\n  down-casting tricks available in Java to circumvent the compiler *are not*\n  available in Zeolite. (User-defined types can selectively allow \"down-casting\n  like\" semantics by reasoning about\n  [parameters as variables](#parameters-as-variables), however.)\n\n- **Implementation details are kept separate.** In Zeolite, only *public\n  inheritance* and *public functions* show up where an object type is declared,\n  to discourage relying on implementation details of the type.\n\n  C++ and Java allow (and in some cases *require*) implementation details (data\n  members, function definitions, etc.) to show up in the same place as the\n  user-accessible parts of a `class`. The result is that the user of the `class`\n  will often rely on knowledge of how it works internally.\n\nAlthough all of these limitations preclude a lot of design decisions allowed in\nlanguages like Java, C++, and Python, they also drastically reduce the possible\ncomplexity of inter-object interactions. Additionally, they generally *do not*\nrequire ugly work-arounds; see the [full examples][examples].\n\n## Quick Start\n\n### Installation\n\nRequirements:\n\n- A POSIX-compliant operating system. Zeolite has been tested on Linux and\n  FreeBSD, and to a limited extent on MacOS. It probably _won't_ work on\n  Windows, due to how it interacts with the filesystem and subprocesses.\n- A Haskell compiler such as [`ghc`][ghc] that can install packages using\n  [`cabal`][cabal], as well as the [`cabal`][cabal] installer.\n- A C++ compiler such as [`clang++`][clang] or [`g++`][gcc] and the standard\n  `ar` archiver present on most Unix-like operating systems.\n\nIf you use a modern Linux distribution, most of the above can be installed using\nthe package manager that comes with your distribution. On MacOS, you can install\n[Xcode][xcode] for a C++ compiler and [`brew install cabal-install`][brew-cabal]\nfor `cabal`.\n\nOnce you meet all of those requirements, follow the installation instructions\nfor the [**`zeolite-lang`**][hackage-zeolite-lang] package on\n[Hackage][hackage]. Please take a look at the [issues page][zeolite-issues] if\nyou run into problems.\n\nThe entire process will probably look like this, once you have `cabal` and a C++\ncompiler installed:\n\n```shell\n$ cabal update\n# Also add --overwrite-policy=always if you're upgrading to a specific version.\n$ cabal install zeolite-lang\n$ zeolite-setup -j8\n# Follow interactive prompts...\n```\n\n**You might also need to add `$HOME/.cabal/bin` or  `$HOME/.local/bin` to your\n`$PATH`.**\n\nFor syntax highlighting in [Visual Studio Code][vscode], See \"VS Code Support\"\nin the [Zeolite releases][zeolite-releases] and download the `.vsix` file. If\nyou happen to use the [`kate`][kate] text editor, you can use the syntax\nhighlighting in [`zeolite.xml`][zeolite.xml].\n\n### Hello World\n\nIt's the [any%](https://en.wiktionary.org/wiki/any%25) of programming.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// hello-world.0rx\u003c/span\u003e\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelloWorld\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e run () -\u0026gt; ()\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelloWorld\u003c/span\u003e\u003c/b\u003e {\n  run () {\n    \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eBasicOutput\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003estderr()\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ewriteNow(\u003cspan style='color:#bf0303;'\u003e\u0026quot;Hello World\u003c/span\u003e\u003cspan style='color:#924c9d;'\u003e\\n\u003c/span\u003e\u003cspan style='color:#bf0303;'\u003e\u0026quot;\u003c/span\u003e)\n  }\n}\u003c/pre\u003e\n\n```shell\n# Compile.\nzeolite -I lib/util --fast HelloWorld hello-world.0rx\n\n# Execute.\n./HelloWorld\n```\n\nAlso see some [full examples][examples] for more complete feature usage.\n\n## Writing Programs\n\nThis section breaks down the separate parts of a Zeolite program. See the\n[full examples][examples] for a more integrated language overview.\n\n### Basic Ideas\n\nZeolite programs use object-oriented and procedural programming paradigms.\n**Type categories** are used to define object types, much like `class`es in\nJava and C++. They *are not* called \"classes\", just to avoid confusion about\nsemantic differences with Java and C++.\n\nAll type-category names start with an uppercase letter and contain only letters\nand digits.\n\nAll procedures and data live inside `concrete` type categories. Every program\nmust have at least one `concrete` category with the procedure to be executed\nwhen the program is run.\n\n`concrete` categories are split into a **declaration** and a **definition**.\nCode for both should be in files ending with `.0rx`. (The `.0rp` file type\ncontains only declarations, and will be discussed later.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// myprogram/myprogram.0rx\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// This declares the type.\u003c/span\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyProgram\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// The entry point must be a () -\u0026gt; () function. This means that it takes no\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// arguments and returns no arguments. (@type will be discussed later.)\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e run () -\u0026gt; ()\n}\n\n\u003cspan style='color:#898887;'\u003e// This defines the type.\u003c/span\u003e\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyProgram\u003c/span\u003e\u003c/b\u003e {\n  run () {\n    \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n  }\n}\u003c/pre\u003e\n\n**IMPORTANT:** All programs or modules must be in their own directory so that\n`zeolite` is able to cache information about the build. Unlike some other\ncompilers, you *do not* specify all command-line options every time you\nrecompile a binary or module.\n\n```shell\n# Create a new .zeolite-module config. (Only once!)\nzeolite -m MyProgram myprogram\n\n# Recompile the module and binary. (After any config or code updates.)\n# All sources in myprogram will be compiled. -m MyProgram selects the entry\n# point. The default output name for the binary here is myprogram/MyProgram.\nzeolite -r myprogram\n\n# Execute.\nmyprogram/MyProgram\n```\n\n```shell\n# An alternative, if you only have one .0rx and want to quickly iterate.\nzeolite --fast MyProgram myprogram/myprogram.0rx\n```\n\n### Declaring Functions\n\nA **function declaration** specifies the **scope** of the function and its\n**argument** and **return** types. (And optionally type parameters and parameter\nfilters, to be discussed later.) The declaration simply indicates the existence\nof a function, without specifying its behavior.\n\nAll function names start with a lowercase letter and contain only letters and\ndigits.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// @value indicates that this function requires a value of type MyCategory.\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// This function takes 2x Int and returns 2x Int.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e minMax (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e)\n\n  \u003cspan style='color:#898887;'\u003e// @type indicates that this function operates on MyCategory itself. This is\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// like a static function in C++.\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// This function takes no arguments and returns MyCategory.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e create () -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e)\n\n  \u003cspan style='color:#898887;'\u003e// @category indicates that this function operates on MyCategory itself. This\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// is like a static function in Java. (The semantics of @category are similar\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// to those of @type unless there are type parameters.)\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@category\u003c/span\u003e copy (\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e)\n}\u003c/pre\u003e\n\nIn many cases, the choice between using a `@category` function or a `@type`\nfunction is arbitrary, but there are pros and cons of each:\n\n- **`@category` functions** *do not* inherit any of the\n  [category's parameters](#using-parameters), or their filters. This can be\n  useful in a few situations:\n\n  1. You want to impose additional restrictions on what parameters can be used.\n     For example, `Vector:createSize` ([`lib/container`][lib/container])\n     requires that param `#y defines Default` so that it can populate the\n     `Vector` with default values.\n\n  2. The caller will pass arguments that can be used to [infer the category's\n     parameters](#type-inference). For example, `Vector:duplicateSize`\n     ([`lib/container`][lib/container]) takes a single `#y`. Since `#y` is a\n     function param, it can be inferred from the argument that gets passed,\n     e.g., `Vector:duplicateSize(0, 25)`.\n\n  If neither of these situations apply, a `@type` function might be better.\n\n- **`@type` functions** *do* inherit the\n  [category's parameters](#using-parameters) and their filters, which means that\n  they do not need to be specified again, and they do not need to be passed\n  again when calling from another `@type` or `@value` function. This is more\n  efficient to maintain and execute.\n\n  [`@type interface`s](#using-interfaces) are another advantage of `@type`\n  functions.\n\n### Defining Functions\n\nFunctions are defined in the category definition. They *do not* need to repeat\nthe function declaration; however, they can do so in order to refine the\nargument and return types for internal use.\n\nAll function names start with a lowercase letter and contain only letters and\ndigits.\n\nThe category definition can also declare *additional* functions that are not\nvisible externally.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e minMax (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// minMax is defined here.\u003c/span\u003e\n  minMax (x, y) {\n    \u003cb\u003eif\u003c/b\u003e (superfluousCheck(x, y)) {\n      \u003cb\u003ereturn\u003c/b\u003e x, y\n    } \u003cb\u003eelse\u003c/b\u003e {\n      \u003cb\u003ereturn\u003c/b\u003e y, x\n    }\n  }\n\n  \u003cspan style='color:#898887;'\u003e// superfluousCheck is only available inside of MyCategory.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e superfluousCheck (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eBool\u003c/span\u003e\u003c/i\u003e)\n  superfluousCheck (x, y) {\n    \u003cb\u003ereturn\u003c/b\u003e x \u0026lt; y\n  }\n}\u003c/pre\u003e\n\nAll arguments must either have a unique name or be ignored with `_`.\n\n`@value` functions have access to a special constant **`self`**, which refers to\nthe object against which the function was called.\n\n#### Using Variables\n\n**Variables** are assigned with `\u003c-` to indicate the direction of assignment.\n*Every* variable must be initialized; there are no `null` values in Zeolite.\n(However, see `optional` later on.)\n\nAll variable names start with a lowercase letter and contain only letters and\ndigits.\n\nWhen a location is needed for assignment (e.g., handling a function return,\ntaking a function argument), you can use `_` in place of a variable name to\nignore the value.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// Initialize with a literal.\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u0026lt;- \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// Initialize with a function result.\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u0026lt;- getValue()\u003c/pre\u003e\n\nUnlike other languages, Zeolite *does not* allow variable masking. For example,\nif there is already a variable named `x` available, you *cannot* create a new\n`x` variable even in a smaller scope.\n\nAll variables are **shared** and their values *are not* scoped like they are in\nC++. You should not count on knowing the lifetime of any given value.\n\nAs of compiler version `0.24.0.0`, you can also **swap** the values of two\nvariables that have the same type, as long as both are writable. This is more\nefficient than \"manually\" swapping using a temp variable.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e foo \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e bar \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e456\u003c/span\u003e\nfoo \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u0026gt;\u003c/span\u003e\u003c/b\u003e bar\u003c/pre\u003e\n\n#### Calling Functions\n\nReturn values from **function calls** must *always* be explicitly handled by\nassigning them to a variable, passing them to another function or ignoring them.\n(This is required even if the function does not return anything, primarily to\nsimplify parsing.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// Utilize the return.\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u0026lt;- getValue()\n\n\u003cspan style='color:#898887;'\u003e// Explicitly ignore a single value.\u003c/span\u003e\n\u003cb\u003e_\u003c/b\u003e \u0026lt;- getValue()\n\n\u003cspan style='color:#898887;'\u003e// Ignore all aspects of the return.\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// (Prior to compiler version 0.3.0.0, ~ was used instead of \\.)\u003c/span\u003e\n\u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e printHelp()\u003c/pre\u003e\n\n- Calling a function with `@value` scope requires a value of the correct type,\n  and uses `.` notation, e.g., `foo.getValue()`.\n- Calling a function with `@type` scope requires the type with parameter\n  substitution (if applicable), and uses `.` notation, e.g.,\n  `MyCategory\u003cInt\u003e.create()`. (Prior to compiler version `0.9.0.0`, `$` was used\n  instead of `.`.)\n- Calling a function with `@category` scope requires the category itself, and\n  uses the `:` notation, e.g., `MyCategory:foo()`. (Prior to compiler version\n  `0.9.0.0`, `$$` was used instead of `:`.)\n- You can skip qualifying function calls (e.g., in the example above) if the\n  function being called is in the same scope or higher. For example, you can\n  call a `@type` function from the procedure for a `@value` function in the\n  same category.\n\nFunctions *cannot* be overloaded like in Java and C++. Every function must have\na unique name. Functions inherited from different places can be explicitly\nmerged, however. This can be useful if you want interfaces to have overlapping\nfunctionality without having an explicit parent for the overlap.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eForwardIterator\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  next () -\u0026gt; (\u003cb\u003eoptional\u003c/b\u003e \u003cb\u003e#self\u003c/b\u003e)\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eReverseIterator\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  prev () -\u0026gt; (\u003cb\u003eoptional\u003c/b\u003e \u003cb\u003e#self\u003c/b\u003e)\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eIterator\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eForwardIterator\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eReverseIterator\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n\n  \u003cspan style='color:#898887;'\u003e// An explicit override is required in order to merge get from both parents.\u003c/span\u003e\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\u003c/pre\u003e\n\n#### Functions As Operators\n\nZeolite allows some functions to be used as **operators**. This allows users to\navoid excessive parentheses when using named mathematical  functions.\n\nFunctions with two arguments can use **infix** notation. The operator precedence\nis always between comparisons (e.g., `==`) and logical (e.g., `\u0026\u0026`).\n\nFunctions with one argument can use **prefix** notation. These are evaluated\nstrictly before all infix operators.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMath\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e plus (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e)\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e neg (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// Math.plus is evaluated first.\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e x \u0026lt;- \u003cspan style='color:#b08000;'\u003e1\u003c/span\u003e \u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#0057ae;'\u003eMath\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eplus\u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e2\u003c/span\u003e * \u003cspan style='color:#b08000;'\u003e5\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// Math.neg is evaluated first.\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e y \u0026lt;- \u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#0057ae;'\u003eMath\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eneg\u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e x \u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#0057ae;'\u003eMath\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eplus\u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e2\u003c/span\u003e\u003c/pre\u003e\n\n#### Data Members and Value Creation\n\nUnlike Java and C++, there is no \"default construction\" in Zeolite. In addition,\nZeolite also lacks the concept of \"copy construction\" that C++ has. This means\nthat new values can only be created using a factory function. In combination\nwith required variable initialization, this ensures that the programmer never\nneeds to worry about unexpected missing or uninitialized values.\n\nData members are never externally visible; they only exist in the category\ndefinition. Any access outside of the category must be done using\nexplicitly-defined functions.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e create () -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// A data member unique to each MyCategory value.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value\n\n  create () {\n    \u003cspan style='color:#898887;'\u003e// Initialization is done with direct assignment.\u003c/span\u003e\n    \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e{ \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e }\n  }\n}\n\n\u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// Create a new value in some other procedure.\u003c/span\u003e\n\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e myValue \u0026lt;- \u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ecreate()\u003c/pre\u003e\n\nThere *is no syntax* for accessing a data member from another object; even\nobjects of the same type. This effectively makes all variables **internal**\nrather than just `private` like in Java and C++. As long as parameter variance\nis respected, you can provide access to an individual member with getters and\nsetters.\n\nAs of compiler version `0.14.0.0`, you can use [`#self`](#the-self-parameter) in\nplace of the full type when you are creating a value of the same type from a\n`@type` or `@value` function.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e create () -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value\n\n  create () {\n    \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003e#self\u003c/b\u003e{ \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e }\n  }\n}\u003c/pre\u003e\n\nA category can also have `@category` members, but *not* `@type` members. (The\nlatter is so that the runtime implementation can clean up unused `@type`s\nwithout introducing ambiguitites regarding member lifespan.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e global () -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value\n\n  \u003cspan style='color:#898887;'\u003e// @category members use inline initialization.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@category\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e singleton \u0026lt;- \u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e{ \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e }\n\n  global () {\n    \u003cspan style='color:#898887;'\u003e// @category members are accessible from all functions in the category.\u003c/span\u003e\n    \u003cb\u003ereturn\u003c/b\u003e singleton\n  }\n}\u003c/pre\u003e\n\n#### Conditionals\n\nZeolite uses the `if`/`elif`/`else` conditional construct. The `elif` and `else`\nclauses are always optional.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003eif\u003c/b\u003e (x) {\n  \u003cspan style='color:#898887;'\u003e// something\u003c/span\u003e\n} \u003cb\u003eelif\u003c/b\u003e (y) {\n  \u003cspan style='color:#898887;'\u003e// something\u003c/span\u003e\n} \u003cb\u003eelse\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// something\u003c/span\u003e\n}\u003c/pre\u003e\n\n#### Scoping and Cleanup\n\nVariables can be scoped to specific blocks of code. Additionally, you can\nprovide a cleanup procedure to be executed upon exit from the block of code.\nThis is useful if you want to free resources without needing to explicitly do so\nfor every `return` statement.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// Simple scoping during evaluation.\u003c/span\u003e\n\u003cb\u003escoped\u003c/b\u003e {\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e x \u0026lt;- getValue()\n} \u003cb\u003ein\u003c/b\u003e \u003cb\u003eif\u003c/b\u003e (x \u0026lt; \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e) {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n} \u003cb\u003eelif\u003c/b\u003e (x \u0026gt; \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e) {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n} \u003cb\u003eelse\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n}\n\n\u003cspan style='color:#898887;'\u003e// Simple scoping during assignment.\u003c/span\u003e\n\u003cb\u003escoped\u003c/b\u003e {\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e x \u0026lt;- getValue1()\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e y \u0026lt;- getValue2()\n} \u003cb\u003ein\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e z \u0026lt;- x+y\n\n\u003cspan style='color:#898887;'\u003e// Scoping with cleanup.\u003c/span\u003e\n\u003cb\u003escoped\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n} \u003cb\u003ecleanup\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n} \u003cb\u003ein\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n}\n\n\u003cspan style='color:#898887;'\u003e// Cleanup without scoping.\u003c/span\u003e\n\u003cb\u003ecleanup\u003c/b\u003e {\n  i \u0026lt;- i+\u003cspan style='color:#b08000;'\u003e1\u003c/span\u003e  \u003cspan style='color:#898887;'\u003e// Post-increment behavior.\u003c/span\u003e\n} \u003cb\u003ein\u003c/b\u003e \u003cb\u003ereturn\u003c/b\u003e i\u003c/pre\u003e\n\nThe `cleanup` block is executed at every `return`, `break`, and `continue` in\nthe respective `in` block, and right after the `in` block. For this reason, you\n*cannot* use `return`, `break`, or `continue` within a `cleanup` block.\nAdditionally, you cannot overwrite named returns. You *can* use `fail`, however,\nsince that just ends program execution.\n\nWhen `cleanup` is executed at a `return` statement in the `in` block, the\nreturns from the `return` statement are \"locked in\", then `cleanup` is executed,\n*then* those locked-in return values are returned. (This is what allows the\npost-increment example above to work.)\n\n#### Loops\n\nZeolite supports two loop types:\n\n1. **`while`** loops, which are the traditional repetition of a procedure while\n   a predicate holds.\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cspan style='color:#898887;'\u003e// With break and continue.\u003c/span\u003e\n   \u003cb\u003ewhile\u003c/b\u003e (\u003cb\u003etrue\u003c/b\u003e) {\n     \u003cb\u003eif\u003c/b\u003e (\u003cb\u003etrue\u003c/b\u003e) {\n       \u003cb\u003ebreak\u003c/b\u003e\n     } \u003cb\u003eelse\u003c/b\u003e {\n       \u003cb\u003econtinue\u003c/b\u003e\n     }\n   }\n\n   \u003cspan style='color:#898887;'\u003e// With an update after each iteration.\u003c/span\u003e\n   \u003cb\u003ewhile\u003c/b\u003e (\u003cb\u003etrue\u003c/b\u003e) {\n     \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n   } \u003cb\u003eupdate\u003c/b\u003e {\n     \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n   }\u003c/pre\u003e\n\n2. **`traverse`** loops (as of compiler version `0.16.0.0`), which automatically\n   iterate over the `#x` values in an `optional Order\u003c#x\u003e`. This is similar to\n   `for (int i : container) { ... }` in C++ and `for i in container: ...` in\n   Python.\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cb\u003etraverse\u003c/b\u003e (orderedStrings -\u0026gt; \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e s) {\n     \u003cspan style='color:#898887;'\u003e// executed once per String s in orderedStrings\u003c/span\u003e\n     \u003cspan style='color:#898887;'\u003e// you can also use break and continue\u003c/span\u003e\n   }\n\n   \u003cspan style='color:#898887;'\u003e// With an update after each iteration.\u003c/span\u003e\n   \u003cb\u003etraverse\u003c/b\u003e (orderedStrings -\u0026gt; \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e s) {\n     \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n   } \u003cb\u003eupdate\u003c/b\u003e {\n     \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n   }\u003c/pre\u003e\n\n   Since the `Order` is optional, `empty` can be used to iterate zero times.\n\n   **IMPORTANT:** Most containers *are not* iterable by `traverse` as-is; you\n   will need to call a `@value` function to get the `Order`. Some categories\n   `refine DefaultOrder\u003c#x\u003e` (such as `String`, and `Vector` in\n   `lib/container`), which allows you to use its `defaultOrder()`. Other\n   categories provide multiple ways to `Order` the container, such as\n   `SearchTree` in `lib/container`.\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cb\u003etraverse\u003c/b\u003e (\u003cspan style='color:#bf0303;'\u003e\u0026quot;hello\u0026quot;\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003edefaultOrder() -\u0026gt; \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e c) {\n     \u003cspan style='color:#898887;'\u003e// executed once per Char c in \u0026quot;hello\u0026quot;\u003c/span\u003e\n   }\u003c/pre\u003e\n\n`for` loops (e.g., `for (int i = 0; i \u003c foo; ++i) { ... }` in C++) *are not*\nsupported, since such syntax is too restrictive to scale, and they can be\nreplaced with `traverse` or `scoped`+`while` in nearly all situations.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// Combine while with scoped to create a for loop.\u003c/span\u003e\n\u003cb\u003escoped\u003c/b\u003e {\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e i \u0026lt;- \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e limit \u0026lt;- \u003cspan style='color:#b08000;'\u003e10\u003c/span\u003e\n} \u003cb\u003ein\u003c/b\u003e \u003cb\u003ewhile\u003c/b\u003e (i \u0026lt; limit) {\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n} \u003cb\u003eupdate\u003c/b\u003e {\n  i \u0026lt;- i+\u003cspan style='color:#b08000;'\u003e1\u003c/span\u003e\n}\u003c/pre\u003e\n\n#### Multiple Returns\n\nA procedure definition has two options for returning multiple values:\n\n1. Return all values. (Prior to compiler version `0.3.0.0`, multiple returns\nwere enclosed in  `{}`, e.g., `return { x, y }`.)\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n     minMax (x, y) {\n       \u003cb\u003eif\u003c/b\u003e (x \u0026lt; y) {\n         \u003cb\u003ereturn\u003c/b\u003e x, y\n       } \u003cb\u003eelse\u003c/b\u003e {\n         \u003cb\u003ereturn\u003c/b\u003e y, x\n       }\n     }\n   }\u003c/pre\u003e\n\n2. Naming the return values and assigning them individually. This can be useful\n   (and less error-prone) if the values are determined at different times.\n   The compiler uses static analysis to ensure that all named variables are\n   guaranteed to be set via all possible control paths.\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyCategory\u003c/span\u003e\u003c/b\u003e {\n     \u003cspan style='color:#898887;'\u003e// Returns are named on the first line.\u003c/span\u003e\n     minMax (x, y) (min, max) {\n       \u003cspan style='color:#898887;'\u003e// Returns are optionally initialized up front.\u003c/span\u003e\n       min \u0026lt;- y\n       max \u0026lt;- x\n       \u003cb\u003eif\u003c/b\u003e (x \u0026lt; y) {\n         \u003cspan style='color:#898887;'\u003e// Returns are overwritten.\u003c/span\u003e\n         min \u0026lt;- x\n         max \u0026lt;- y\n       }\n       \u003cspan style='color:#898887;'\u003e// Implicit return makes sure that all returns are assigned. Optionally,\u003c/span\u003e\n       \u003cspan style='color:#898887;'\u003e// you can use return _.\u003c/span\u003e\n     }\n   }\u003c/pre\u003e\n\n3. To return early when using named returns or when the function has no returns,\n   use `return _`. You will get an error if a named return might not be set.\n\nThe caller of a function with multiple returns also has a few options:\n\n1. Assign the returns to a set of variables. You can ignore a position by using\n   `_` in that position. (Prior to compiler version `0.3.0.0`, multiple\n   assignments were enclosed in `{}`, e.g., `{ Int min, _ } \u003c- minMax(4,3)`.)\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e min, \u003cb\u003e_\u003c/b\u003e \u0026lt;- minMax(\u003cspan style='color:#b08000;'\u003e4\u003c/span\u003e, \u003cspan style='color:#b08000;'\u003e3\u003c/span\u003e)\u003c/pre\u003e\n\n2. Pass them directly to a function that requires the same number of\n   compatible arguments. (Note that you *cannot* concatenate the returns of\n   multiple functions.)\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e delta \u0026lt;- diff(minMax(\u003cspan style='color:#b08000;'\u003e4\u003c/span\u003e, \u003cspan style='color:#b08000;'\u003e3\u003c/span\u003e))\u003c/pre\u003e\n\n3. If you need to immediately perform an operation on just one of the returned\n   values while ignoring the others, you can select just that return inline. (As\n   of compiler version `0.21.0.0`.)\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cspan style='color:#898887;'\u003e// Select return 0 from minMax.\u003c/span\u003e\n   \u003cb\u003ereturn\u003c/b\u003e minMax(\u003cspan style='color:#b08000;'\u003e4\u003c/span\u003e, \u003cspan style='color:#b08000;'\u003e3\u003c/span\u003e){\u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e}\u003c/pre\u003e\n\n   Note that the position *must* be an integer literal so that the compiler can\n   validate both the position and the return type.\n\n#### Optional and Weak Values\n\nZeolite requires that all variables be initialized; however, it provides the\n**`optional`** storage modifier to allow a *specific* variable to be\n**`empty`**. This *is not* the same as `null` in Java because `optional`\nvariables need to be `require`d before use.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// empty is a special value for use with optional.\u003c/span\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u0026lt;- \u003cb\u003eempty\u003c/b\u003e\n\n\u003cspan style='color:#898887;'\u003e// Non-optional values automatically convert to optional.\u003c/span\u003e\nvalue \u0026lt;- \u003cspan style='color:#b08000;'\u003e1\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// present returns true iff the value is not empty.\u003c/span\u003e\n\u003cb\u003eif\u003c/b\u003e (\u003cb\u003epresent\u003c/b\u003e(value)) {\n  \u003cspan style='color:#898887;'\u003e// Use require to convert the value to something usable.\u003c/span\u003e\n  \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e foo(\u003cb\u003erequire\u003c/b\u003e(value))\n}\u003c/pre\u003e\n\nAs of compiler version `0.24.0.0`, you can use **`\u003c-|`** to conditionally\noverwrite an `optional` variable if it's currently `empty`.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cb\u003eempty\u003c/b\u003e\nvalue \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-|\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e    \u003cspan style='color:#898887;'\u003e// Assigned, because value was empty.\u003c/span\u003e\nvalue \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-|\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e456\u003c/span\u003e    \u003cspan style='color:#898887;'\u003e// Not assigned, because value wasn't empty.\u003c/span\u003e\nvalue \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-|\u003c/span\u003e\u003c/b\u003e foo()  \u003cspan style='color:#898887;'\u003e// foo() isn't called unless value is empty.\u003c/span\u003e\u003c/pre\u003e\n\nNote that if the right side _isn't_ optional then you can use the result as\nnon-optional.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cb\u003eempty\u003c/b\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value2 \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e (value \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-|\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e)\u003c/pre\u003e\n\nAs of compiler version `0.24.0.0`, you can conditionally call a function on an\n`optional` value if it's non-`empty` using **`\u0026.`**.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// All returned values will be optional.\u003c/span\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e formatted \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e value\u0026amp;\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eformatted()\n\u003cspan style='color:#898887;'\u003e// foo() won't be called unless the readAt call is going to be made.\u003c/span\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e char \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e formatted\u0026amp;\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ereadAt(foo())\u003c/pre\u003e\n\nAs of compiler version `0.24.1.0`, you can use **`x \u003c|| y`** to use `y` if `x`\nis empty. Note that `x` must have an `optional` type, and the resulting type of\nthe entire expression is the [type union](#meta-types) of the types of `x` and\n`y`.\n\n**`weak`** values allow your program to access a value *if it is available*,\nwithout holding up that value's cleanup if nothing else needs it. This can be\nused to let threads clean themselves up (example below) or to handle cycles in\nreferences between objects.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyRoutine\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e createAndRun () -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyRoutine\u003c/span\u003e)\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e waitCompletion () -\u0026gt; ()\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyRoutine\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eRoutine\u003c/span\u003e\n\n  \u003cspan style='color:#898887;'\u003e// (See lib/thread.)\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003eweak\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eThread\u003c/span\u003e thread\n\n  createAndRun () {\n    \u003cspan style='color:#898887;'\u003e// Create a new MyRoutine and then start the thread.\u003c/span\u003e\n    \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eMyRoutine\u003c/span\u003e{ \u003cb\u003eempty\u003c/b\u003e }\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003estart()\n  }\n\n  run () {\n    \u003cspan style='color:#898887;'\u003e// routine\u003c/span\u003e\n  }\n\n  waitCompletion () {\n    \u003cb\u003escoped\u003c/b\u003e {\n      \u003cspan style='color:#898887;'\u003e// Use strong to turn weak into optional. If the return is non-empty, the\u003c/span\u003e\n      \u003cspan style='color:#898887;'\u003e// value is guaranteed to remain valid while using thread2.\u003c/span\u003e\n      \u003cb\u003eoptional\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eThread\u003c/span\u003e thread2 \u0026lt;- \u003cb\u003estrong\u003c/b\u003e(thread)\n    } \u003cb\u003ein\u003c/b\u003e \u003cb\u003eif\u003c/b\u003e (\u003cb\u003epresent\u003c/b\u003e(thread2)) {\n      \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cb\u003erequire\u003c/b\u003e(thread2)\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ejoin()\n    }\n  }\n\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e start () -\u0026gt; (\u003cb\u003e#self\u003c/b\u003e)\n  start () {\n    \u003cspan style='color:#898887;'\u003e// ProcessThread holds a reference to itself only while the Routine is\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// running. Making thread weak means that the ProcessThread can clean itself\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// up once the Routine terminates.\u003c/span\u003e\n    thread \u0026lt;- \u003cspan style='color:#0057ae;'\u003eProcessThread\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003efrom(\u003cb\u003eself\u003c/b\u003e)\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003estart()\n    \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003eself\u003c/b\u003e\n  }\n}\u003c/pre\u003e\n\n#### Deferred Variable Initialization\n\nIn some situations, a variable's value depends on conditional logic, and there\nis no low-cost default value. In such situations, you can use the **`defer`**\nkeyword to allow a variable to be *temporarily* uninitialized. (As of compiler\nversion `0.20.0.0`.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#0057ae;'\u003eLargeObject\u003c/span\u003e object \u0026lt;- \u003cb\u003edefer\u003c/b\u003e\n\n\u003cb\u003eif\u003c/b\u003e (debug) {\n  object \u0026lt;- \u003cspan style='color:#0057ae;'\u003eLargeObject\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enewDebug()\n} \u003cb\u003eelse\u003c/b\u003e {\n  object \u0026lt;- \u003cspan style='color:#0057ae;'\u003eLargeObject\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enew()\n}\n\n\u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e object\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eexecute()\u003c/pre\u003e\n\nIn this example, `object` is declared without an initializer, and is then\ninitialized in *both* the `if` and `else` clauses.\n\n- A variable initialized with `defer` *must* be initialized via *all possible*\n  control paths prior to its use. This is checked at compile time.\n- An *existing* variable can also be marked as `defer`red. This *will not*\n  change its value, but will instead require that it be assigned a new value\n  before it gets used again.\n- If you never *read* the variable in a particular control branch then you do\n  not need to initialize it; initialization is only checked where necessary.\n\n#### Immediate Program Termination\n\nThere are two ways to terminate the program immediately.\n\n1. The `fail` builtin can be used to immediately terminate the program _with a\n   stack trace_. This *is not* considered a function call since it cannot\n   return; therefore, _do not_ precede it with `\\`.\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyProgram\u003c/span\u003e\u003c/b\u003e {\n     run () {\n       \u003cb\u003efail\u003c/b\u003e(\u003cspan style='color:#bf0303;'\u003e\u0026quot;MyProgram does nothing\u0026quot;\u003c/span\u003e)\n     }\n   }\u003c/pre\u003e\n\n   The value passed to `fail` must implement the\n   [`Formatted` builtin](#builtins) `@value interface`.\n\n   The output to `stderr` will look something like this:\n\n   ```text\n   ./MyProgram: Failed condition: MyProgram does nothing\n     From MyProgram.run at line 7 column 5 of myprogram.0rx\n     From main\n   Terminated\n   ```\n\n1. The `exit` builtin can be used to immediately terminate the program _with a\n   traditional `Int` exit code_. (0 conventionally means program success.) This\n   *is not* considered a function call since it cannot return; therefore, _do\n   not_ precede it with `\\`.\n\n   \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n   \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyProgram\u003c/span\u003e\u003c/b\u003e {\n     run () {\n       \u003cb\u003eexit\u003c/b\u003e(\u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e)\n     }\n   }\u003c/pre\u003e\n\n   The value passed to `exit` must be an `Int`.\n\n#### Call Delegation\n\nAs of compiler version `0.24.0.0`, you can delegate function calls using the\n**`delegate`** keyword. This has the effect of forwarding _all_ of the\narguments passed to the enclosing function call to the handler specified. (The\ncall is actually rewritten using a substitution during compilation.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\nnew (value1,value2) {\n  \u003cspan style='color:#898887;'\u003e// Same as Value{ value1, value2 }.\u003c/span\u003e\n  \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cb\u003edelegate\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\n\n  \u003cspan style='color:#898887;'\u003e// Same as foo(value1,value2).\u003c/span\u003e\n  \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cb\u003edelegate\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003efoo\u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e\n\n  \u003cspan style='color:#898887;'\u003e// Same as something(123).bar(value1,value2).\u003c/span\u003e\n  \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cb\u003edelegate\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003esomething(\u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e)\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ebar\u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e\n}\u003c/pre\u003e\n\n**IMPORTANT:** If the enclosing function specifies\n[argument labels](#function-argument-labels) then those will be used in the\nforwarded call.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e \u003cspan style='color:#006e28;'\u003ename:\u003c/span\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e)\nnew (value1,value2) {\n  \u003cspan style='color:#898887;'\u003e// Same as foo(name: value1, value2).\u003c/span\u003e\n  \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003edelegate\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003efoo\u003cb\u003e\u003cspan style='color:#c02040;'\u003e`\u003c/span\u003e\u003c/b\u003e\n}\u003c/pre\u003e\n\n**IMPORTANT:** Delegation will fail to compile if:\n\n1. One or more function arguments is ignored with `_`, e.g., `call(_) { ... }`.\n2. One or more function arguments is hidden with `$Hidden[]$`, e.g.,\n   `$Hidden[someArg]$`.\n\nThis is primarily as a sanity check, since all of the above imply that a given\nargument should not be used.\n\n### Function Argument Labels\n\nAs of compiler version `0.24.0.0`, function declarations in Zeolite can\n_optionally_ have labels for any individual argument. Note that this is a\n_label_ and _not_ an argument name.\n\nAll labels start with a lowercase letter and contain only letters and digits,\nand end with `:`.\n\n- The syntax for labeling an argument in the function declaration is to specify\n  it after the type.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#898887;'\u003e// The first argument requires start: as a label.\u003c/span\u003e\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e \u003cspan style='color:#006e28;'\u003estart:\u003c/span\u003e) \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e)\n  }\u003c/pre\u003e\n\n- The syntax for labeling an argument in the function call is to precede the\n  argument with the label.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cspan style='color:#898887;'\u003e// The first argument is labeled with start:.\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e foo \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enew(\u003cspan style='color:#006e28;'\u003estart:\u003c/span\u003e \u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e)\u003c/pre\u003e\n\n\n  **IMPORTANT:** If the function declaration specifies a label, the label must\n  _always_ be used when calling that function. Additionally, arguments must\n  still be passed in the same order; labels _don't_ allow you to reorder\n  arguments.\n\n  When defining a function, the name you give to an argument _should_ match the\n  label, but that isn't a requirement. Also note that labels _can_ be reused,\n  e.g., `@value swapRows (Int row:, Int row:) -\u003e ()`. This allows the label to\n  be descriptive rather than just an identifier.\n\n### Using Parameters\n\nAll `concrete` categories and all `interface`s can have type parameters. Each\nparameter can have a variance rule assigned to it. This allows the compiler to\ndo type conversions between different parameterizations.\n\nParameter names must start with `#` and a lowercase letter, and can only contain\nletters and digits.\n\nParameters are *never* repeated in the category or function definitions. (Doing\nso would just create more opportunity for unnecessary compile-time errors.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// #x is covariant (indicated by being to the right of |), which means that it\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// can only be used for output purposes.\u003c/span\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  read () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cspan style='color:#898887;'\u003e// #x is contravariant (indicated by being to the left of |), which means that\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// it can only be used for input purposes.\u003c/span\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  write (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; ()\n}\n\n\u003cspan style='color:#898887;'\u003e// #x is for output and #y is for input, from the caller's perspective.\u003c/span\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eFunction\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#y\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  call (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#y\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cspan style='color:#898887;'\u003e// By default, parameters are invariant, i.e., cannot be converted. You can also\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// explicitly specify invariance with \u0026lt;|#x|\u0026gt;. This allows all three variance\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// types to be present.\u003c/span\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eList\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e append (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; ()\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e head () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cspan style='color:#898887;'\u003e// Use , to separate multiple parameters that have the same variance.\u003c/span\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eKeyValue\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#k\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#v\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#k\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#v\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cb\u003e#self\u003c/b\u003e)\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e key   () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#k\u003c/span\u003e\u003c/i\u003e)\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e value () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#v\u003c/span\u003e\u003c/i\u003e)\n}\u003c/pre\u003e\n\n\n- Specifying parameter variance allows the compiler to automatically convert\n  between different types. This is done recursively in terms of parameter\n  substitution.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cspan style='color:#898887;'\u003e// Covariance allows conversion upward.\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e reader \u0026lt;- \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyBase\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e  reader2 \u0026lt;- reader\n\n  \u003cspan style='color:#898887;'\u003e// Contravariance allows conversion downward.\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyBase\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e  writer \u0026lt;- \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e writer2 \u0026lt;- writer\n\n  \u003cspan style='color:#898887;'\u003e// Conversion is also recursive.\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyBase\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u0026gt;\u003c/span\u003e  readerWriter \u0026lt;- \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u0026gt;\u003c/span\u003e readerWriter2 \u0026lt;- readerWriter\n\n  \u003cspan style='color:#898887;'\u003e// Invariance does not allow conversions.\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eList\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e list \u0026lt;- \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n  \u003cspan style='color:#0057ae;'\u003eList\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyBase\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e  list2 \u0026lt;- \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\u003c/pre\u003e\n\n- You can apply **filters** to type parameters to require that the parameters\n  meet certain requirements. This allows you to call `interface` functions on\n  parameters and their values in procedure definitions.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e format\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;\n      \u003cspan style='color:#898887;'\u003e// Ensures that #x -\u0026gt; Formatted. (Like T extends Foo in Java.)\u003c/span\u003e\n      \u003cspan style='color:#898887;'\u003e// Example: String f \u0026lt;- Helper.format(123)\u003c/span\u003e\n      \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003erequires\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e\n    (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e)\n\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e get\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;\n      \u003cspan style='color:#898887;'\u003e// Ensures that #x \u0026lt;- String. (Like T super Foo in Java.)\u003c/span\u003e\n      \u003cspan style='color:#898887;'\u003e// Example: AsBool v \u0026lt;- Helper.get\u0026lt;AsBool\u0026gt;()\u003c/span\u003e\n      \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003eallows\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e\n    () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e create\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;\n      \u003cspan style='color:#898887;'\u003e// Ensures that #x defines the Default @type interface.\u003c/span\u003e\n      \u003cspan style='color:#898887;'\u003e// Example: Int v \u0026lt;- Helper.create\u0026lt;Int\u0026gt;()\u003c/span\u003e\n      \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003edefines\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eDefault\u003c/span\u003e\u003c/i\u003e\n    () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n  }\n\n  \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n    format (x) {\n      \u003cspan style='color:#898887;'\u003e// #x -\u0026gt; Formatted means x has formatted().\u003c/span\u003e\n      \u003cb\u003ereturn\u003c/b\u003e x\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eformatted()\n    }\n\n    get () {\n      \u003cspan style='color:#898887;'\u003e// #x \u0026lt;- String means we can return a String here.\u003c/span\u003e\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#bf0303;'\u003e\u0026quot;message\u0026quot;\u003c/span\u003e\n    }\n\n    create () {\n      \u003cspan style='color:#898887;'\u003e// #x defines Default means #x has default().\u003c/span\u003e\n      \u003cb\u003ereturn\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003edefault()\n    }\n  }\u003c/pre\u003e\n\n  Filters on category params must be specified after all `refines`/`defines` and\n  before any function declarations.\n\n  **IMPORTANT:** As of compiler version `0.16.0.0`, you can no longer use\n  parameter filters in `@value interface`s and `@type interface`s.\n\n### Using Interfaces\n\nZeolite has `@value interface`s that are similar to Java `interface`s, which\ndeclare functions that implementations must define. In addition, Zeolite also\nhas `@type interface`s that declare `@type` functions that must be defined.\n(This would be like having `abstract static` functions in Java.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// @value indicates that the interface declares @value functions.\u003c/span\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003ePrintable\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// @value is not allowed in the declaration.\u003c/span\u003e\n  print () -\u0026gt; ()\n}\n\n\u003cspan style='color:#898887;'\u003e// @type indicates that the interface declares @type functions.\u003c/span\u003e\n\u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eDiffable\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cspan style='color:#898887;'\u003e// @type is not allowed in the declaration.\u003c/span\u003e\n  diff (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\u003c/pre\u003e\n\n|Type|Param Variance|Param Filters|Can Inherit|`@category` Funcs|`@type` Funcs|`@value` Funcs|Define Procedures|\n|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|\n|**`concrete`**|✓|✓|`@value interface` `@type interface`|✓|✓|✓|✓|\n|**`@value interface`**|✓||`@value interface`|||✓||\n|**`@type interface`**|✓||--||✓||\n\n- `@value interface`s can be **inherited** by other `@value interface`s and\n  `concrete` categories using `refines`.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003ePrintable\u003c/span\u003e\n\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e)\n\n    \u003cspan style='color:#898887;'\u003e// The functions of Printable do not need to be declared again, but you can do\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// so to refine the argument and return types.\u003c/span\u003e\n  }\n\n  \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value\n\n    new (value) {\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e{ value }\n    }\n\n    \u003cspan style='color:#898887;'\u003e// Define Printable.print like any other MyValue function.\u003c/span\u003e\n    print () {\n      \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eBasicOutput\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ewriteNow(value)\n    }\n  }\u003c/pre\u003e\n\n- `@type interface`s can only be **inherited** by `concrete` categories.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cb\u003edefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eDiffable\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e)\n\n    \u003cspan style='color:#898887;'\u003e// The functions of Diffable do not need to be declared again, but you can do\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// so to refine the argument and return types.\u003c/span\u003e\n  }\n\n  \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value\n\n    new (value) {\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e{ value }\n    }\n\n    \u003cspan style='color:#898887;'\u003e// Define Diffable.diff like any other MyValue function.\u003c/span\u003e\n    diff (x, y) {\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e{ x\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eget() - y\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eget() }\n    }\n\n    \u003cspan style='color:#898887;'\u003e// A getter is needed to access the value outside of the object that owns it.\u003c/span\u003e\n    \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e)\n    get () {\n      \u003cb\u003ereturn\u003c/b\u003e value\n    }\n  }\u003c/pre\u003e\n\n- You can also specify `refines` and `defines` when *defining* a `concrete`\n  category. This allows the inheritance to be private.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e create () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e)\n  }\n\n  \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#898887;'\u003e// Formatted is not a visible parent outside of MyValue.\u003c/span\u003e\n    \u003cb\u003erefines\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e\n\n    create () {\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eMyValue\u003c/span\u003e{ }\n    }\n\n    \u003cspan style='color:#898887;'\u003e// Inherited from Formatted.\u003c/span\u003e\n    formatted () {\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#bf0303;'\u003e\u0026quot;MyValue\u0026quot;\u003c/span\u003e\n    }\n  }\u003c/pre\u003e\n\n### Immutable Types\n\nYou can modify `interface` and `concrete` with **`immutable`** at the very top\nof the declaration. (As of compiler version `0.20.0.0`.) This creates two\nrequirements for `@value` members:\n\n1. They are marked as read-only, and cannot be overwritten with `\u003c-`.\n2. They must have a type that is also `immutable`.\n\n(`@category` members are not affected.)\n\nNote that this applies to the *entire* implementation; not just to the\nimplementations of functions required by the `immutable` `interface`.\n`immutable` is therefore intended for objects that cannot be modified, rather\nthan as a way to define a read-only view (e.g., `const` in C++) of an object.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eFoo\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003eimmutable\u003c/b\u003e\n\n  call () -\u0026gt; ()\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eBar\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eFoo\u003c/span\u003e\n\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new () -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eBar\u003c/span\u003e)\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e mutate () -\u0026gt; ()\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eBar\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value\n\n  new () { \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eBar\u003c/span\u003e{ \u003cspan style='color:#b08000;'\u003e0\u003c/span\u003e } }\n\n  call () {\n    \u003cspan style='color:#898887;'\u003e// call cannot overwrite value\u003c/span\u003e\n  }\n\n  mutate () {\n    \u003cspan style='color:#898887;'\u003e// mutate also cannot overwrite value, even though mutate isn't in Foo.\u003c/span\u003e\n  }\n}\u003c/pre\u003e\n\nFor members that use a parameter as a type, you can use `immutable` as a filter\nif the other filters do not otherwise imply it. Note that this will prevent\nsubstituting in a non-`immutable` type when calling `@type` functions.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eType\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cb\u003eimmutable\u003c/b\u003e\n\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003eimmutable\u003c/b\u003e\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eType\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// #x is allowed as a member type because of the immutable filter.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e value\n}\u003c/pre\u003e\n\n### The `#self` Parameter\n\nEvery category has an implicit *covariant* parameter **`#self`**. (As of\ncompiler version `0.14.0.0`.) It *always* means the type of the current\ncategory, even when inherited. (`#self` is covariant because it needs to be\nconvertible to a parent of the current category.)\n\nFor example:\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eIterator\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  next () -\u0026gt; (\u003cb\u003e#self\u003c/b\u003e)\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eCharIterator\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eIterator\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// next must return CharIterator because #self = CharIterator here.\u003c/span\u003e\n}\u003c/pre\u003e\n\nThe primary purpose of this is to support combining multiple interfaces with\niterator or builder semantics into composite types *without* getting backed into\na corner when calling functions from a single interface.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eForwardIterator\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  next () -\u0026gt; (\u003cb\u003e#self\u003c/b\u003e)\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eReverseIterator\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  prev () -\u0026gt; (\u003cb\u003e#self\u003c/b\u003e)\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eCharIterator\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eForwardIterator\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eReverseIterator\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n  get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e)  \u003cspan style='color:#898887;'\u003e// (Remember that merging needs to be done explicitly.)\u003c/span\u003e\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eParser\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// trimWhitespace can call next and still return the original type. In\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// contrast, if next returned ForwardIterator\u0026lt;#x\u0026gt; then trimWhitespace would\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// need to return ForwardIterator\u0026lt;Char\u0026gt; to the caller instead of #i.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e trimWhitespace\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#i\u003c/span\u003e\u003c/i\u003e\u0026gt;\n    \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#i\u003c/span\u003e\u003c/i\u003e \u003cb\u003erequires\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eForwardIterator\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eChar\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n  (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#i\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#i\u003c/span\u003e\u003c/i\u003e)\n}\u003c/pre\u003e\n\n`#self` can also be used to generalize a factory pattern:\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eParseFactory\u003c/span\u003e\u003c/b\u003e {\n  fromString (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cb\u003e#self\u003c/b\u003e)\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eFileParser\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e parseFromFile\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;\n    \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003edefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eParseFactory\u003c/span\u003e\n  (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eFileParser\u003c/span\u003e\u003c/b\u003e {\n  parseFromFile (filename) {\n    \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e content \u0026lt;- \u003cspan style='color:#0057ae;'\u003eFileHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ereadAll(filename)\n    \u003cspan style='color:#898887;'\u003e// Notice that ParseFactory doesn't need a type parameter to indicate what\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// type is going to be parsed in fromString; it's sufficient to know that #x\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// implements ParseFactory and that fromString returns #self.\u003c/span\u003e\n    \u003cb\u003ereturn\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003efromString(content)\n  }\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003edefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eParseFactory\u003c/span\u003e\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003c/b\u003e {\n  fromString (string) {\n    \u003cb\u003eif\u003c/b\u003e (string == \u003cspan style='color:#bf0303;'\u003e\u0026quot;Value\u0026quot;\u003c/span\u003e) {\n      \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e{ }\n    } \u003cb\u003eelse\u003c/b\u003e {\n      \u003cb\u003efail\u003c/b\u003e(\u003cspan style='color:#bf0303;'\u003e\u0026quot;could not parse input\u0026quot;\u003c/span\u003e)\n    }\n  }\n}\u003c/pre\u003e\n\n`#self` is nothing magical; this could all be done by explicitly adding a\ncovariant `#self` parameter to *every* type, with the appropriate `requires` and\n`defines` filters.\n\n### Type Inference\n\nStarting with compiler version `0.7.0.0`, Zeolite supports optional inference of\nspecific function parameters by using **`?`**. This must be at the top level (no\nnesting), and it cannot be used outside of the parameters of the function.\n\nThe type-inference system is intentionally \"just clever enough\" to do things\nthat the programmer can easily guess. More sophisticated inference is feasible\nin theory (like Haskell uses); however, type errors with such systems can draw\na significant amount of attention away from the task at hand. (For example, a\ncommon issue with Haskell is not knowing *which line of code* contains the\nactual mistake causing a type error.)\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@category\u003c/span\u003e create1\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e)\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e     create2     (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e)\n}\n\n\u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// This is fine.\u003c/span\u003e\n\u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e value1 \u0026lt;- \u003cspan style='color:#0057ae;'\u003eValue\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e:\u003c/span\u003ecreate1\u0026lt;\u003cb\u003e?\u003c/b\u003e\u0026gt;(\u003cspan style='color:#b08000;'\u003e10\u003c/span\u003e)\n\n\u003cspan style='color:#898887;'\u003e// These uses of ? are not allowed:\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// Value\u0026lt;Int\u0026gt; value2 \u0026lt;- Value\u0026lt;?\u0026gt;.create2(10)\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// Value\u0026lt;?\u0026gt;   value2 \u0026lt;- Value\u0026lt;Int\u0026gt;.create2(10)\u003c/span\u003e\n\u003c/pre\u003e\n\nOnly the function arguments and the parameter filters are used to infer the type\nsubstitution; return types are ignored. If inference fails, you will see a\ncompiler error and will need to explicitly write out the type.\n\nAs of compiler version `0.21.0.0`, if you want to infer *all* params, you can\nskip `\u003c...\u003e` entirely. If you only want to infer some of the params, you must\nspecify all params, using `?` for those that should be inferred.\n\nType inference will *only* succeed if:\n\n1. There is a valid pattern match between the expected argument types and the\n   types of the passed arguments.\n\n2. There is *exactly one* type that matches best:\n\n   - For params only used in *covariant* positions, the *lower bound* of the\n     type is unambiguous.\n   - For params only used in *contravariant* positions, the *upper bound* of the\n     type is unambiguous.\n   - For all other situations, the *upper and lower bounds* are unambiguous and\n     *equal* to each other.\n\nType inference in the context of parameterized types is specifically disallowed\nin order to limit the amount of code the reader needs to search to figure out\nwhat types are being used. Forcing explicit specification of types for local\nvariables is more work for the programmer, but it makes the code easier to\nreason about later on.\n\n### Other Features\n\nThis section discusses language features that are less frequently used.\n\n#### Meta Types\n\nZeolite provides two **meta types** that allow unnamed combinations of other\ntypes.\n\n- A value with an **intersection type** `[A \u0026 B]` can be assigned from something\n  that is *both* `A` and `B`, and can be assigned to *either* an `A` or `B`.\n  There is a special empty intersection named **`any`** that can be assigned\n  from any value but cannot be assigned to any other type.\n\n  Intersections can be useful for requiring multiple interfaces without creating\n  a new category that refines all of those interfaces. An intersection\n  `[Foo \u0026 Bar]` in Zeolite is semantically similar to the existential type\n  `forall a. (Foo a, Bar a) =\u003e a` in Haskell and `? extends Foo \u0026 Bar` in Java,\n  except that in Zeolite `[Foo \u0026 Bar]` can be used as a first-class type.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\u003c/b\u003e { }\n\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003c/b\u003e { }\n\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eData\u003c/span\u003e\u003c/b\u003e {\n    \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e\n    \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new () \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003cspan style='color:#0057ae;'\u003eData\u003c/span\u003e)\n  }\n\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n  \u003cb\u003e\u003cspan style='color:#006e28;'\u003e[\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e \u003cspan style='color:#006e28;'\u003e\u0026amp;\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cb\u003e\u003cspan style='color:#006e28;'\u003e]\u003c/span\u003e\u003c/b\u003e val \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eData\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enew()\n  \u003cspan style='color:#0057ae;'\u003eReader\u003c/span\u003e val2 \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e val\n  \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e val3 \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e val\u003c/pre\u003e\n\n- A value with a **union type** `[A | B]` can be assigned from *either* `A` or\n  `B`, but can only be assigned to something that *both* `A` and `B` can be\n  assigned to. There is a special empty union named **`all`** that cannot ever\n  be assigned a value but that can be assigned to everything. (`empty` is\n  actually of type `optional all`.)\n\n  Unions can be useful if you want to artificially limit what types can be used\n  in a particular context. This can be useful for disallowing use of \"unknown\"\n  implementations in critical or risky functions, etc.\n\n  - When used with `requires`, a union can limit the allowed types _without_\n    losing the original type.\n\n    \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n    \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n      \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e describe\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;\n        \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003erequires\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e\n        \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e \u003cb\u003erequires\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#006e28;'\u003e[\u003c/span\u003e\u003c/b\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e \u003cspan style='color:#006e28;'\u003e|\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e\u003cb\u003e\u003cspan style='color:#006e28;'\u003e]\u003c/span\u003e\u003c/b\u003e  \u003cspan style='color:#898887;'\u003e// \u0026lt;- limits allowed types\u003c/span\u003e\n      (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e)\n    }\n\n    \u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n      describe (value) {\n        \u003cb\u003ereturn\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ebuilder()\n            \u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eappend(\u003cb\u003etypename\u003c/b\u003e\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;())  \u003cspan style='color:#898887;'\u003e// \u0026lt;- original type is still available\u003c/span\u003e\n            \u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eappend(\u003cspan style='color:#bf0303;'\u003e\u0026quot;: \u0026quot;\u003c/span\u003e)\n            \u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eappend(value)\n            \u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003ebuild()\n      }\n    }\n\n    \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n    \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003edescribe(\u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e)        \u003cspan style='color:#898887;'\u003e// Fine.\u003c/span\u003e\n    \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003edescribe(\u003cspan style='color:#bf0303;'\u003e\u0026quot;message\u0026quot;\u003c/span\u003e)  \u003cspan style='color:#898887;'\u003e// Fine.\u003c/span\u003e\n    \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003edescribe(\u003cspan style='color:#b08000;'\u003e123.0\u003c/span\u003e)      \u003cspan style='color:#898887;'\u003e// Error!\u003c/span\u003e\u003c/pre\u003e\n\n  - When used as a variable type, the original type is lost, but you can still\n    convert to a common parent type.\n\n    \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n    \u003cb\u003e\u003cspan style='color:#006e28;'\u003e[\u003c/span\u003e\u003c/b\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e \u003cspan style='color:#006e28;'\u003e|\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e\u003cb\u003e\u003cspan style='color:#006e28;'\u003e]\u003c/span\u003e\u003c/b\u003e value \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e\n    \u003cspan style='color:#898887;'\u003e// You can only convert to types that _all_ constituent types convert to.\u003c/span\u003e\n    \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e formatted \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e value  \u003cspan style='color:#898887;'\u003e// Fine.\u003c/span\u003e\n    \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e number \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e value           \u003cspan style='color:#898887;'\u003e// Error!\u003c/span\u003e\u003c/pre\u003e\n\nIntersection and union types also come up in [type inference](#type-inference).\n\n- If there are two or more incompatible guesses for an inferred type _used only\n  for input_, the union of those types will be used.\n\n- If there are two or more incompatible guesses for an inferred type _used only\n  for output_, the intersection of those types will be used.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// (Just for creating an output parameter.)\u003c/span\u003e\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new () \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003cb\u003e#self\u003c/b\u003e)\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n  \u003cspan style='color:#898887;'\u003e// #x is only used for input to the function.\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e inferInput\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e)\n\n  \u003cspan style='color:#898887;'\u003e// #x is only used for output from the function.\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// (This is due to contravariance of #x in Writer.)\u003c/span\u003e\n  \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e inferOutput\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt; (\u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e, \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e) \u003cb\u003e\u003cspan style='color:#006e28;'\u003e-\u0026gt;\u003c/span\u003e\u003c/b\u003e (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n  inferInput (\u003cb\u003e_\u003c/b\u003e, \u003cb\u003e_\u003c/b\u003e) { \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003etypename\u003c/b\u003e\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;()\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eformatted() }\n  inferOutput (\u003cb\u003e_\u003c/b\u003e, \u003cb\u003e_\u003c/b\u003e) { \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003etypename\u003c/b\u003e\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt;()\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eformatted() }\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003c/b\u003e {\n  new () { \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003e#self\u003c/b\u003e{ } }\n}\n\n\u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n\u003cspan style='color:#898887;'\u003e// Returns \u0026quot;[Int | String]\u0026quot;.\u003c/span\u003e\n\u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003einferInput(\u003cspan style='color:#b08000;'\u003e123\u003c/span\u003e, \u003cspan style='color:#bf0303;'\u003e\u0026quot;message\u0026quot;\u003c/span\u003e)\n\n\u003cspan style='color:#898887;'\u003e// Returns \u0026quot;[Int \u0026amp; String]\u0026quot;.\u003c/span\u003e\n\u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003einferOutput(\u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enew(), \u003cspan style='color:#0057ae;'\u003eWriter\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enew())\u003c/pre\u003e\n\nIn this context, unions/intersections are the _most restrictive_ valid types\nthat will work for the substution. (They are respectively the\n[coproduct][category-coproduct]/[product][category-product] of the provided\ntypes under implicit type conversion.)\n\n#### Explicit Type Conversion\n\nIn some situations, you might want to peform an explicit type conversion on a\n`@value`. The syntax for such conversions is _`value`_**`?`**_`Type`_, where\n*`value`* is any `@value` and *`Type`* is any type, including params and\n[meta types](#meta-types).\n\n- With values that have a [union type](#meta-types) (e.g., `[A | B]`), you might\n  need an explicit type conversion when making a function call.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003cspan style='color:#c04040;'\u003e|\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n    get () -\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e)\n  }\n\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eIntObject\u003c/span\u003e\u003c/b\u003e {\n    \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eIntObject\u003c/span\u003e)\n  }\n\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eStringObject\u003c/span\u003e\u003c/b\u003e {\n    \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\n    \u003cspan style='color:#644a9b;'\u003e@type\u003c/span\u003e new (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eStringObject\u003c/span\u003e)\n  }\n\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n  \u003cb\u003e\u003cspan style='color:#006e28;'\u003e[\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#0057ae;'\u003eIntObject\u003c/span\u003e \u003cspan style='color:#006e28;'\u003e|\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eStringObject\u003c/span\u003e\u003cb\u003e\u003cspan style='color:#006e28;'\u003e]\u003c/span\u003e\u003c/b\u003e value \u0026lt;- \u003cspan style='color:#0057ae;'\u003eStringObject\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003enew(\u003cspan style='color:#bf0303;'\u003e\u0026quot;message\u0026quot;\u003c/span\u003e)\n\n  \u003cspan style='color:#898887;'\u003e// Convert to Object\u0026lt;Formatted\u0026gt; before calling get().\u003c/span\u003e\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e formatted \u0026lt;- value\u003cb\u003e?\u003c/b\u003e\u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003eget()\n\n  \u003cspan style='color:#898887;'\u003e// Should get() return Int or String here?\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// Formatted formatted \u0026lt;- value.get()\u003c/span\u003e\u003c/pre\u003e\n\n- Type conversions of function arguments can be used for influencing\n  [type inference](#type-inference).\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003c/b\u003e {\n    \u003cspan style='color:#644a9b;'\u003e@category\u003c/span\u003e call\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; ()\n  }\n\n  \u003cspan style='color:#898887;'\u003e// ...\u003c/span\u003e\n\n  \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u0026lt;- \u003cspan style='color:#b08000;'\u003e1\u003c/span\u003e\n\n  \u003cspan style='color:#898887;'\u003e// #x will be inferred as Formatted rather than as Int here.\u003c/span\u003e\n  \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e \u003cspan style='color:#0057ae;'\u003eHelper\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e:\u003c/span\u003ecall(value\u003cb\u003e?\u003c/b\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e)\u003c/pre\u003e\n\n- You can also explicitly convert `optional` and `weak` values, although they\n  will still retain their original storage modifier.\n\n  \u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n  \u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value \u0026lt;- \u003cspan style='color:#b08000;'\u003e1\u003c/span\u003e\n\n  \u003cspan style='color:#898887;'\u003e// Passed as optional Formatted.\u003c/span\u003e\n  \u003cspan style='color:#006e28;'\u003e\\\u003c/span\u003e call(value\u003cb\u003e?\u003c/b\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e)\n\n  \u003cspan style='color:#898887;'\u003e// Not allowed, since value.Formatted is still optional.\u003c/span\u003e\n  \u003cspan style='color:#898887;'\u003e// String string \u0026lt;- value?Formatted.formatted()\u003c/span\u003e\u003c/pre\u003e\n\n#### Runtime Type Reduction\n\nThe **`reduce`** builtin function enables very limited runtime reasoning about\ntype conversion.\n\n- The call `reduce\u003cFoo, Bar\u003e(value)` will return `value` with type\n  `optional Bar` iff `Foo` can be converted to `Bar`. Note that `value` must\n  itself be convertible to `optional Foo`.\n- When type params are used, the types that are assigned at the point of\n  execution are checked. For example, the result of `reduce\u003c#x, #y\u003e(value)` will\n  depend on the *specific* types assigned to `#x` and `#y` upon execution.\n\nHere are a few motivating use-cases:\n\n- Allowing creation of a container that can hold objects of different types\n  while still being able to access the objects with their original types. (Also\n  see `TypeMap` in [`lib/container`][lib/container], which was actually the\n  original target use-case for the initial version of Zeolite.)\n\n- Enabling optional functionality for a parameter without using a filter. For\n  example, printing info about `value` if available using\n  `reduce\u003c#x, Formatted\u003e(value)` during debugging.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003cb\u003einterface\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eAnyObject\u003c/span\u003e\u003c/b\u003e {\n  getAs\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#y\u003c/span\u003e\u003c/i\u003e\u0026gt; () -\u0026gt; (\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#y\u003c/span\u003e\u003c/i\u003e)\n}\n\n\u003cb\u003econcrete\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003c/b\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e {\n  \u003cspan style='color:#644a9b;'\u003e@category\u003c/span\u003e create\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u0026gt; (\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e) -\u0026gt; (\u003cspan style='color:#0057ae;'\u003eAnyObject\u003c/span\u003e)\n}\n\n\u003cb\u003edefine\u003c/b\u003e \u003cb\u003e\u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003c/b\u003e {\n  \u003cb\u003erefines\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eAnyObject\u003c/span\u003e\n\n  \u003cspan style='color:#644a9b;'\u003e@value\u003c/span\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e value\n\n  create (value) { \u003cb\u003ereturn\u003c/b\u003e \u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026gt;\u003c/span\u003e{ value } }\n  getAs  ()      { \u003cb\u003ereturn\u003c/b\u003e \u003cb\u003ereduce\u003c/b\u003e\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#x\u003c/span\u003e\u003c/i\u003e, \u003ci\u003e\u003cspan style='color:#0057ae;'\u003e#y\u003c/span\u003e\u003c/i\u003e\u0026gt;(value) }\n}\u003c/pre\u003e\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#0057ae;'\u003eAnyObject\u003c/span\u003e value \u0026lt;- \u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e:\u003c/span\u003ecreate\u0026lt;\u003cb\u003e?\u003c/b\u003e\u0026gt;(\u003cspan style='color:#bf0303;'\u003e\u0026quot;message\u0026quot;\u003c/span\u003e)\n\n\u003cspan style='color:#898887;'\u003e// This will be empty because String does not convert to Int.\u003c/span\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e value1 \u0026lt;- value\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003egetAs\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eInt\u003c/span\u003e\u003c/i\u003e\u0026gt;()\n\n\u003cspan style='color:#898887;'\u003e// This will be \u0026quot;message\u0026quot; as Formatted because String converts to Formatted.\u003c/span\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e value2 \u0026lt;- value\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003egetAs\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e\u0026gt;()\u003c/pre\u003e\n\n`reduce` *cannot* be used to \"downcast\" a value (e.g., converting a `Formatted`\nto a `Float`) since the argument has the same type as the first parameter.\n\nFor example, `reduce\u003c#x, #y\u003e(value)` checks `#x`\u0026rarr;`#y`, and since `value`\nmust be `optional #x`, `value` can only be converted upward. In other words, it\nonly allows conversions that would otherwise be allowed, returning `empty` for\nall other conversions.\n\nThe `AnyObject` example above works because `Object` stores the *original type*\npassed to `create` as `#x`, which it then has available for the `reduce` call.\nThe type variables `#x` and `#y` are the primary inputs to `reduce`; there is\nabsolutely no examination of the \"real\" type of `value` at runtime.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003cspan style='color:#898887;'\u003e// Here we explicitly set #x = Formatted when calling create.\u003c/span\u003e\n\u003cspan style='color:#0057ae;'\u003eAnyObject\u003c/span\u003e value \u0026lt;- \u003cspan style='color:#0057ae;'\u003eObject\u003c/span\u003e\u003cspan style='color:#644a9b;'\u003e:\u003c/span\u003ecreate\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eFormatted\u003c/span\u003e\u003c/i\u003e\u0026gt;(\u003cspan style='color:#bf0303;'\u003e\u0026quot;message\u0026quot;\u003c/span\u003e)\n\n\u003cspan style='color:#898887;'\u003e// This will be empty even though the actual value is a String because getAs\u003c/span\u003e\n\u003cspan style='color:#898887;'\u003e// uses #x = Formatted in the reduce call.\u003c/span\u003e\n\u003cb\u003eoptional\u003c/b\u003e \u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e value1 \u0026lt;- value\u003cspan style='color:#644a9b;'\u003e.\u003c/span\u003egetAs\u0026lt;\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e\u0026gt;()\u003c/pre\u003e\n\n#### Value Instance Comparison\n\nAs of compiler version `0.24.0.0`, you can get a value that identifies a\nspecific `@value` instance using the **`identify`** builtin.. This can be useful\nfor creating identifiers that don't otherwise have a unique member.\n\n\u003cpre style='color:#1f1c1b;background-color:#f6f8fa;'\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/i\u003e value \u003cb\u003e\u003cspan style='color:#006e28;'\u003e\u0026lt;-\u003c/span\u003e\u003c/b\u003e \u003cspan style='color:#bf0303;'\u003e\u0026quot;value\u0026quot;\u003c/span\u003e\n\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eIdentifier\u003c/span\u003e\u003c/i\u003e\u003cspan style='color:#c02040;'\u003e\u0026lt;\u003c/span\u003e\u003ci\u003e\u003cspan style='color:#0057ae;'\u003eString\u003c/span\u003e\u003c/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fta0kira%2Fzeolite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fta0kira%2Fzeolite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fta0kira%2Fzeolite/lists"}