{
  "schema": "ailang/v0",
  "name": "test_mono_ctor_main",
  "imports": [{ "module": "test_mono_ctor_listmod" }],
  "defs": [
    {
      "kind": "class",
      "name": "Trivial",
      "param": "a",
      "methods": [
        {
          "name": "trivial",
          "type": {
            "k": "fn",
            "params": [{ "k": "var", "name": "a" }],
            "ret": { "k": "con", "name": "Int" },
            "effects": []
          }
        }
      ]
    },
    {
      "kind": "instance",
      "class": "Trivial",
      "type": { "k": "con", "name": "Int" },
      "methods": [
        {
          "name": "trivial",
          "body": {
            "t": "lam",
            "params": ["x"],
            "paramTypes": [{ "k": "con", "name": "Int" }],
            "retType": { "k": "con", "name": "Int" },
            "body": { "t": "var", "name": "x" }
          }
        }
      ]
    },
    {
      "kind": "fn",
      "name": "head_or_zero",
      "doc": "Pattern-matches Cons from an imported module's List<Int>. Bug repro: with a class+instance present in the workspace, the mono pass walks this body and synth's local-flat ctor_index resolves Cons to bare \"List\", which mismatches the qualified scrutinee type \"test_mono_ctor_listmod.List<Int>\".",
      "type": {
        "k": "fn",
        "params": [
          {
            "k": "con",
            "name": "test_mono_ctor_listmod.List",
            "args": [{ "k": "con", "name": "Int" }]
          }
        ],
        "ret": { "k": "con", "name": "Int" },
        "effects": []
      },
      "params": ["xs"],
      "body": {
        "t": "match",
        "scrutinee": { "t": "var", "name": "xs" },
        "arms": [
          {
            "pat": {
              "p": "ctor",
              "ctor": "Cons",
              "fields": [
                { "p": "var", "name": "h" },
                { "p": "wild" }
              ]
            },
            "body": { "t": "var", "name": "h" }
          },
          {
            "pat": { "p": "ctor", "ctor": "Nil", "fields": [] },
            "body": { "t": "lit", "lit": { "kind": "int", "value": 0 } }
          }
        ]
      }
    },
    {
      "kind": "fn",
      "name": "main",
      "type": {
        "k": "fn",
        "params": [],
        "ret": { "k": "con", "name": "Unit" },
        "effects": ["IO"]
      },
      "params": [],
      "body": {
        "t": "do",
        "op": "io/print_int",
        "args": [
          {
            "t": "app",
            "fn": { "t": "var", "name": "head_or_zero" },
            "args": [
              {
                "t": "ctor",
                "ctor": "Cons",
                "type": "test_mono_ctor_listmod.List",
                "args": [
                  { "t": "lit", "lit": { "kind": "int", "value": 7 } },
                  {
                    "t": "ctor",
                    "ctor": "Nil",
                    "type": "test_mono_ctor_listmod.List",
                    "args": []
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  ]
}
