{ "schema": "ailang/v0", "name": "match_literal_pattern", "imports": [], "defs": [ { "kind": "fn", "name": "classify", "doc": "Classify an Int via literal patterns plus a wildcard fallback. Exercises PatternLit and PatternWild.", "type": { "k": "fn", "params": [ { "k": "con", "name": "Int" } ], "param_modes": ["own"], "ret": { "k": "con", "name": "Int" }, "ret_mode": "own", "effects": [] }, "params": ["n"], "body": { "t": "match", "scrutinee": { "t": "var", "name": "n" }, "arms": [ { "pat": { "p": "lit", "lit": { "kind": "int", "value": 0 } }, "body": { "t": "lit", "lit": { "kind": "int", "value": 100 } } }, { "pat": { "p": "wild" }, "body": { "t": "lit", "lit": { "kind": "int", "value": 200 } } } ] } }, { "kind": "fn", "name": "sign_if", "doc": "Return -1 / 0 / 1 for the sign of n using nested TermIf. Exercises TermIf in both then/else positions plus TermApp on the polymorphic comparison.", "type": { "k": "fn", "params": [ { "k": "con", "name": "Int" } ], "param_modes": ["own"], "ret": { "k": "con", "name": "Int" }, "ret_mode": "own", "effects": [] }, "params": ["n"], "body": { "t": "if", "cond": { "t": "app", "fn": { "t": "var", "name": "lt" }, "args": [ { "t": "var", "name": "n" }, { "t": "lit", "lit": { "kind": "int", "value": 0 } } ] }, "then": { "t": "lit", "lit": { "kind": "int", "value": -1 } }, "else": { "t": "if", "cond": { "t": "app", "fn": { "t": "var", "name": "eq" }, "args": [ { "t": "var", "name": "n" }, { "t": "lit", "lit": { "kind": "int", "value": 0 } } ] }, "then": { "t": "lit", "lit": { "kind": "int", "value": 0 } }, "else": { "t": "lit", "lit": { "kind": "int", "value": 1 } } } } } ] }