{ "schema": "ailang/v0", "name": "maybe_int", "imports": [], "defs": [ { "kind": "type", "name": "Maybe", "vars": ["a"], "doc": "Optional value with a polymorphic payload.", "ctors": [ { "name": "None", "fields": [] }, { "name": "Some", "fields": [{ "k": "var", "name": "a" }] } ] }, { "kind": "fn", "name": "or_else", "type": { "k": "fn", "params": [ { "k": "con", "name": "Maybe", "args": [{ "k": "con", "name": "Int" }] }, { "k": "con", "name": "Int" } ], "ret": { "k": "con", "name": "Int" }, "effects": [] }, "params": ["m", "d"], "doc": "Returns the wrapped Int for Some(x) and the default d for None.", "body": { "t": "match", "scrutinee": { "t": "var", "name": "m" }, "arms": [ { "pat": { "p": "ctor", "ctor": "None", "fields": [] }, "body": { "t": "var", "name": "d" } }, { "pat": { "p": "ctor", "ctor": "Some", "fields": [{ "p": "var", "name": "x" }] }, "body": { "t": "var", "name": "x" } } ] } }, { "kind": "fn", "name": "main", "type": { "k": "fn", "params": [], "ret": { "k": "con", "name": "Unit" }, "effects": ["IO"] }, "params": [], "doc": "Print or_else for both arms; expected 7 then 99.", "body": { "t": "seq", "lhs": { "t": "do", "op": "io/print_int", "args": [ { "t": "app", "fn": { "t": "var", "name": "or_else" }, "args": [ { "t": "ctor", "type": "Maybe", "ctor": "Some", "args": [ { "t": "lit", "lit": { "kind": "int", "value": 7 } } ] }, { "t": "lit", "lit": { "kind": "int", "value": 99 } } ] } ] }, "rhs": { "t": "do", "op": "io/print_int", "args": [ { "t": "app", "fn": { "t": "var", "name": "or_else" }, "args": [ { "t": "ctor", "type": "Maybe", "ctor": "None", "args": [] }, { "t": "lit", "lit": { "kind": "int", "value": 99 } } ] } ] } } } ] }