{ "schema": "ailang/v0", "name": "box", "imports": [], "defs": [ { "kind": "type", "name": "Box", "vars": ["a"], "doc": "A unary box around a polymorphic value.", "ctors": [ { "name": "MkBox", "fields": [{ "k": "var", "name": "a" }] } ] }, { "kind": "fn", "name": "unbox", "type": { "k": "forall", "vars": ["a"], "body": { "k": "fn", "params": [ { "k": "con", "name": "Box", "args": [{ "k": "var", "name": "a" }] } ], "ret": { "k": "var", "name": "a" }, "effects": [] } }, "params": ["b"], "doc": "Polymorphic projection out of a Box.", "body": { "t": "match", "scrutinee": { "t": "var", "name": "b" }, "arms": [ { "pat": { "p": "ctor", "ctor": "MkBox", "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": "Round-trip 42 through MkBox + unbox.", "body": { "t": "do", "op": "io/print_int", "args": [ { "t": "app", "fn": { "t": "var", "name": "unbox" }, "args": [ { "t": "ctor", "type": "Box", "ctor": "MkBox", "args": [ { "t": "lit", "lit": { "kind": "int", "value": 42 } } ] } ] } ] } } ] }