import fs from 'fs'
const bouncer = (f,ini) => { let obj = ini; while (obj.tag) obj = f(obj); return obj.h0 };
let Lib_Error_errorMsg = ( _$$0 ) => { switch (_$$0.tag) { case 2: return _$$0.h2; case 1: return (("") + (_$$0.h1)) + (" not in scope"); case 0: return _$$0.h1; } };
let Prelude_addString = (x,y) => x + y;
let Lib_Error_Lib_Common_HasFC$20Lib_Error_Error$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow = ( _$$0 ) => ((((((((((("") + (_$$0.h0)) + (":")) + (Prelude_showInt((_$$0.h1.h0) + (1)))) + (":")) + (Prelude_showInt((_$$0.h1.h1) + (1)))) + ("--")) + (Prelude_showInt((_$$0.h1.h2) + (1)))) + (":")) + (Prelude_showInt((_$$0.h1.h3) + (1)))) + (""));
let Prelude_addInt = (x,y) => x + y;
let Prelude_showInt = (i) => String(i);
let Node_exitFailure = (_, msg) => {
  console.log(msg);
  process.exit(1);
};
let Prelude_MkIORes = ( h1, h2 ) => ({ tag: 0,  h1: h1,  h2: h2 });
let Prelude_MkUnit = 0;
let Prelude_primPutStrLn = (s) => (w) => {
  //fs.writeSync(1, s + '\n')
  console.log(s)
  return Prelude_MkIORes(Prelude_MkUnit,w)
};
let Prelude_Left = ( h2 ) => ({ tag: 0,  h2: h2 });
let Lib_Common_MkBounds = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Common_emptyFC = { tag: 0,  h0: "",  h1: Lib_Common_MkBounds(0, 0, 0, 0) };
let Lib_Error_E = ( h0, h1 ) => ({ tag: 0,  h0: h0,  h1: h1 });
let Lib_Types_MkM = ( h1 ) => ({ tag: 0,  h1: h1 });
let Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn = ( _$$1 ) => (Lib_Types_MkM(( tc ) => (( eta ) => (Prelude_MkIORes(Prelude_Right({ tag: 0,  h2: tc,  h3: _$$1 }), eta)))));
let Prelude_Right = ( h2 ) => ({ tag: 1,  h2: h2 });
let Main_runString = ( _$$0 ) => { let sc$$1 = Lib_Tokenizer_tokenise("<stdin>", _$$0); if ((sc$$1.tag) == (1)) { let sc$$5 = Lib_Parser_Impl_parse("<stdin>", Lib_ReplParser_parseCommand, sc$$1.h2); return ( (sc$$5.tag) == (1) ? Lib_Types_catchError(Main_runCommand(sc$$5.h2), ( err ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn(Lib_Error_showError(_$$0, err))))) : Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn(Lib_Error_showError(_$$0, sc$$5.h2))) ); } else { return Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn(Lib_Error_showError(_$$0, sc$$1.h2))); } };
let Lib_Error_showError = ( src$$0, _$$1 ) => { let fc = Lib_Error_Lib_Common_HasFC$20Lib_Error_Error$2CgetFC(_$$1); return ((((("ERROR at ") + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(Lib_Error_Lib_Common_HasFC$20Lib_Error_Error$2CgetFC(_$$1)))) + (": ")) + (Lib_Error_errorMsg(_$$1))) + ("\n")) + (Lib_Error_showError_go(src$$0, _$$1, fc, 0, Prelude_splitBy(src$$0, "\n"))); };
let Prelude_splitBy = ( _$$0, _$$1 ) => (Prelude_splitBy_go(_$$0, _$$1, { tag: 0 }, { tag: 0 }, Prelude_unpack(_$$0)));
let Prelude_Nil = (  ) => ({ tag: 0 });
let Prelude__$3A$3A_ = ( h1, h2 ) => ({ tag: 1,  h1: h1,  h2: h2 });
let Prelude_unpack = (s) => {
    let acc = Prelude_Nil()
    for (let i = s.length - 1; 0 <= i; i--) acc = Prelude__$3A$3A_(s[i], acc)
    return acc
};
let Prelude_splitBy_go = ( _, _1, _$$3, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$51.tag) == (1)) { let sc$$9 = Prelude_eqChar(_$$51.h1, _3); switch (sc$$9) { case true: { _ = _2; _1 = _3; _$$3 = { tag: 1,  h1: _$$31,  h2: Prelude_pack(Prelude__$3C$3E$3E_(_$$41, { tag: 0 })) }; _$$4 = { tag: 0 }; _$$5 = _$$51.h2; continue; break; } case false: { _ = _2; _1 = _3; _$$3 = _$$31; _$$4 = { tag: 1,  h1: _$$41,  h2: _$$51.h1 }; _$$5 = _$$51.h2; continue; break; } } } else { return Prelude__$3C$3E$3E_(_$$31, { tag: 1,  h1: Prelude_pack(Prelude__$3C$3E$3E_(_$$41, { tag: 0 })),  h2: { tag: 0 } }); } } };
let Prelude__$3C$3E$3E_ = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$11.tag) == (1)) { _$$1 = _$$11.h1; _$$2 = { tag: 1,  h1: _$$11.h2,  h2: _$$21 }; continue; } else { return _$$21; } } };
let Prelude_pack = (cs) => {
  let rval = ''
  while (cs.tag === '_::_' || cs.tag === 1) {
    rval += cs.h1
    cs = cs.h2
  }
  return rval
}
;
let Prelude_eqChar = (a,b) => a == b;
let Lib_Error_showError_go = ( _, _1, _$$3, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$51.tag) == (1)) { let sc$$9 = Prelude_eqInt(_$$41, _$$31.h1.h0); switch (sc$$9) { case true: { let width = (_$$31.h1.h3) - (_$$31.h1.h1); return (((((("  ") + (_$$51.h1)) + ("\n  ")) + (Lib_Common_padding(_$$31.h1.h1, " "))) + ("")) + (Lib_Common_padding(width, "^"))) + ("\n"); break; } case false: { let sc$$10 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare((_$$31.h1.h0) - (3), _$$41), 0); switch (sc$$10) { case true: return ("  ") + ((_$$51.h1) + (("\n") + (Lib_Error_showError_go(_2, _3, _$$31, (_$$41) + (1), _$$51.h2)))); case false: { _ = _2; _1 = _3; _$$3 = _$$31; _$$4 = (_$$41) + (1); _$$5 = _$$51.h2; continue; break; } } break; } } } else { return ""; } } };
let Prelude_subInt = (x,y) => x - y;
let Prelude_Prelude_Ord$20Prim_Int$2Ccompare = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_eqInt(_$$0, _$$1); switch (sc$$2) { case true: return 1; case false: { let sc$$3 = Prelude_ltInt(_$$0, _$$1); switch (sc$$3) { case true: return 0; case false: return 2; } break; } } };
let Prelude_ltInt = (a,b) => a < b;
let Prelude_eqInt = (a,b) => a == b;
let Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1) { case 2: switch (_$$0) { case 2: return true; default: return false; } break; case 1: switch (_$$0) { case 1: return true; default: return false; } break; case 0: switch (_$$0) { case 0: return true; default: return false; } break; } };
let Lib_Common_padding = ( _$$0, _$$1 ) => (Lib_Common_padding_go(_$$0, _$$1, _$$0, { tag: 0 }));
let Lib_Common_padding_go = ( _, _1, _$$3, _$$4 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; switch (_$$31) { case 0: return Prelude_pack(_$$41); default: { _ = _2; _1 = _3; _$$3 = (_$$31) - (1); _$$4 = { tag: 1,  h1: _3,  h2: _$$41 }; continue; break; } } } };
let Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO = ( _$$1 ) => (Lib_Types_MkM(( tc ) => (( w ) => { let sc$$5 = _$$1(w); return { tag: 0,  h1: Prelude_Right({ tag: 0,  h2: tc,  h3: sc$$5.h1 }),  h2: sc$$5.h2 }; })));
let Main_runCommand = ( _$$0 ) => { switch (_$$0.tag) { case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_jsonTopContext, ( json ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("TOP:") + (Lib_Common_renderJson(json))) + (""))))); case 5: return Main_replHelp; case 4: return Main_browseTop(_$$0.h0); case 3: return Main_getDoc(_$$0.h0); case 2: return ( (_$$0.h0.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, tc.h2, (1) + (tc.h3), tc.h4, tc.h5)))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, tc.h2, _$$0.h0.h1, tc.h4, tc.h5)))) ); case 1: return Main_writeSource(_$$0.h0); case 0: return Main_processFile(_$$0.h0); } };
let Main_processFile = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("*** Process ") + (_$$0)) + (""))), ( _ ) => { let parts = Data_List1_splitBy1(_$$0, "/"); let sc$$3 = Data_List1_unsnoc(parts); let dir; let sc$$8 = Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29$2C_$3D$3D_(Prelude_Prelude_Eq$20Prim_String, sc$$3.h2, { tag: 0 }); switch (sc$$8) { case true: { dir = "."; break; } case false: { dir = Prelude_joinBy("/", sc$$3.h2); break; } } let sc$$9 = Data_List1_splitFileName(sc$$3.h3); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ((((((("") + (dir)) + (" ")) + (sc$$9.h2)) + (" ")) + (sc$$9.h3)) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Node_readFile(_$$0)), ( $$sc ) => { if (($$sc.tag) == (1)) { let sc$$20 = Lib_Tokenizer_tokenise(_$$0, $$sc.h2); if ((sc$$20.tag) == (1)) { let sc$$24 = Lib_Parser_Impl_partialParse(_$$0, Lib_Parser_parseModHeader, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), sc$$20.h2); if ((sc$$24.tag) == (1)) { let modns = Prelude_splitBy(sc$$24.h2.h2.h3, "."); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Util_getBaseDir(_$$0, sc$$24.h2.h2.h2, modns), ( base ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessModule_invalidateModule(sc$$24.h2.h2.h3), ( _2 ) => { let repo = Main_dirFileSource(base); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessModule_processModule(Lib_Common_emptyFC, repo, { tag: 0 }, sc$$24.h2.h2.h3), ( $$sc1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_showErrors(_$$0, $$sc1.h1), ( _3 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0))))))); }))); } else { return Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(sc$$24.h2.h2), eta)))); } } else { return Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(sc$$20.h2), eta)))); } } else { return Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E({ tag: 0,  h0: _$$0,  h1: Lib_Common_MkBounds(0, 0, 0, 0) }, (((("error reading ") + (_$$0)) + (": ")) + ($$sc.h2)) + (""))), eta)))); } }))); }));
let Main_showErrors = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (( (top.h2.h6.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E({ tag: 0,  h0: _$$0,  h1: Lib_Common_MkBounds(0, 0, 0, 0) }, "Compile failed")), eta)))) ))));
let Lib_Types_getTop = Lib_Types_MkM(( tc ) => (( eta ) => (Prelude_MkIORes(Prelude_Right({ tag: 0,  h2: tc,  h3: tc }), eta))));
let Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind = ( _$$2, _$$3 ) => (Lib_Types_MkM(( tc ) => (( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(_$$2.h1(tc), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types__runM(_$$3($$sc.h2.h3))($$sc.h2.h2) : ( eta ) => (Prelude_MkIORes(Prelude_Left($$sc.h2), eta)) )), eta)))));
let Lib_Types__runM = ( $$self$$1 ) => ($$self$$1.h1);
let Prelude_Prelude_Monad$20Prelude_IO$2Cbind = ( _$$2, _$$3, w ) => { let sc$$5 = _$$2(w); return _$$3(sc$$5.h1)(sc$$5.h2); };
let Lib_ProcessModule_processModule = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$7 = Data_SortedMap_lookupMap$27(_$$3, top.h0); if ((sc$$7.tag) == (1)) { let sc$$9 = Prelude_eqString(_$$3, Lib_Common_primNS); switch (sc$$9) { case false: { let freshMC = Lib_Types_MC(Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), { tag: 0 }, 0, 0); let parts = Prelude_splitBy(_$$3, "."); let fn = (Prelude_joinBy("/", parts)) + (".newt"); let mod = Lib_Types_MkModCtx(_$$3, "", Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), freshMC, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), { tag: 0 }, { tag: 0 }, { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), mod, tc.h3, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), tc.h5)))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_tryError(Lib_ProcessModule__getFile(_$$1)(_$$0)(fn)), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, $$sc.h2.h3, tc.h2.h2, tc.h2.h3, tc.h2.h4, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))), ( _1 ) => { let sc$$25 = Lib_Tokenizer_tokenise($$sc.h2.h2, $$sc.h2.h3); if ((sc$$25.tag) == (1)) { let sc$$29 = Lib_Parser_Impl_partialParse($$sc.h2.h2, Lib_Parser_parseModHeader, top.h4, sc$$25.h2); return ( (sc$$29.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _2 ) => ((("scan imports for module ") + (sc$$29.h2.h2.h3)) + (""))), ( _2 ) => { let sc$$46 = Prelude_eqString(_$$3, sc$$29.h2.h2.h3); switch (sc$$46) { case true: { let sc$$47 = Lib_Parser_Impl_partialParse($$sc.h2.h2, Lib_Parser_parseImports, sc$$29.h2.h3.h2, sc$$29.h2.h3.h3); return ( (sc$$47.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, sc$$47.h2.h2, ( $$case ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_elem(Prelude_Prelude_Eq$20Prim_String, $$case.h1.h3, _$$2), ( _3 ) => (Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E($$case.h1.h2, (((("import loop ") + (_$$3)) + (" → ")) + ($$case.h1.h3)) + (""))), eta)))))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessModule_processModule($$case.h1.h2, _$$1, { tag: 1,  h1: _$$3,  h2: _$$2 }, $$case.h1.h3), ( $$sc1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn($$case.h1.h3))))))), ( imported ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessModule_processModule(sc$$29.h2.h2.h2, _$$1, { tag: 1,  h1: _$$3,  h2: _$$2 }, Lib_Common_primNS), ( _3 ) => { let imported1 = Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(imported, { tag: 1,  h1: Lib_Common_primNS,  h2: { tag: 0 } }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("module ") + (sc$$29.h2.h2.h3)) + (""))), ( _4 ) => { let freshMC1 = Lib_Types_MC(Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), { tag: 0 }, 0, 0); let mod1 = Lib_Types_MkModCtx(_$$3, $$sc.h2.h3, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), freshMC1, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), imported1, { tag: 0 }, { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), mod1, tc.h3, sc$$47.h2.h3.h2, tc.h5)))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, sc$$47.h2.h2, ( $$case ) => { let sc$$75 = Data_SortedMap_lookupMap$27($$case.h1.h3, top1.h0); return ( (sc$$75.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessModule_importHints(Data_SortedMap_listValues(sc$$75.h1.h2)), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, tc.h2, tc.h3, Lib_ProcessModule_mergeOps(sc$$75.h1.h4, tc.h4), tc.h5)))), ( _7 ) => (( (sc$$75.h1.h6.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_TopContext_addError(Lib_Error_E($$case.h1.h2, (("Error in import ") + ($$case.h1.h3)) + (""))) ))))) : Lib_Types_MkM(( _6 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("namespace ") + ($$case.h1.h3)) + (" missing"))), eta)))) ); }), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _7 ) => ("parse Decls")), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessModule_parseDecls($$sc.h2.h2, top2.h4, sc$$47.h2.h3.h3, { tag: 0 }), ( $$sc1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, tc.h2.h2, tc.h2.h3, $$sc1.h3, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))), ( _8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _9 ) => ("process Decls")), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessModule_processModule_tryProcessDecl(_$$0, _$$1, _$$2, _$$3, $$sc.h2.h3, _$$3, eta)), Lib_Elab_collectDecl($$sc1.h2)), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_logMetas(Prelude_reverse()(Data_SortedMap_listValues(top3.h2.h3.h0))), ( _11 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_reverse()(top4.h2.h6), ( err ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn(Lib_Error_showError($$sc.h2.h3, err))))), ( _12 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top5 ) => { let modules = Data_SortedMap_updateMap(_$$3, top5.h2, top5.h0); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(modules, tc.h1, tc.h2, tc.h3, tc.h4, tc.h5)))), ( _13 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(top5.h2))); }))))))))))))))))))))))))))); }); }))) : Lib_ProcessModule_processModule_reportError(_$$0, _$$1, _$$2, _$$3, sc$$47.h2.h2) ); break; } default: return Lib_ProcessModule_processModule_reportError(_$$0, _$$1, _$$2, _$$3, Lib_Error_E(sc$$29.h2.h2.h2, (((("module name ") + (sc$$29.h2.h2.h3)) + (" doesn't match file name ")) + ($$sc.h2.h2)) + (""))); } }) : Lib_ProcessModule_processModule_reportError(_$$0, _$$1, _$$2, _$$3, sc$$29.h2.h2) ); } else { return Lib_ProcessModule_processModule_reportError(_$$0, _$$1, _$$2, _$$3, sc$$25.h2); } }) : Lib_ProcessModule_processModule_reportError(_$$0, _$$1, _$$2, _$$3, $$sc.h2) ))))); break; } default: return Lib_ProcessModule_addPrimitives; } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$7.h1); } }));
let Lib_Common_primNS = "Prim";
let Data_SortedMap_updateMap = ( _$$2, _$$3, _$$4 ) => { if ((_$$4.tag) == (1)) { let sc$$10 = Data_SortedMap_insertT23(_$$4.h3, _$$2, _$$3, _$$4.h4); return ( (sc$$10.tag) == (1) ? Data_SortedMap_MapOf((1) + (_$$4.h2), _$$4.h3, Data_SortedMap_Node2(sc$$10.h2.h2, sc$$10.h2.h3.h2, sc$$10.h2.h3.h3)) : Data_SortedMap_MapOf(_$$4.h2, _$$4.h3, sc$$10.h2) ); } else { return Data_SortedMap_MapOf(0, _$$4.h2, Data_SortedMap_Leaf(_$$2, _$$3)); } };
let Data_SortedMap_Leaf = ( h2, h3 ) => ({ tag: 0,  h2: h2,  h3: h3 });
let Data_SortedMap_MapOf = ( h2, h3, h4 ) => ({ tag: 1,  h2: h2,  h3: h3,  h4: h4 });
let Data_SortedMap_Node2 = ( h3, h4, h5 ) => ({ tag: 1,  h3: h3,  h4: h4,  h5: h5 });
let Data_SortedMap_insertT23 = ( _$$3, _$$4, _$$5, _$$6 ) => { switch (_$$6.tag) { case 2: { let sc$$15 = _$$3(_$$4)(_$$6.h4); switch (sc$$15) { case 2: { let sc$$16 = _$$3(_$$4)(_$$6.h6); switch (sc$$16) { case 2: { let sc$$17 = Data_SortedMap_insertT23(_$$3, _$$4, _$$5, _$$6.h7); return ( (sc$$17.tag) == (1) ? Prelude_Right({ tag: 0,  h2: Data_SortedMap_Node2(_$$6.h3, _$$6.h4, _$$6.h5),  h3: { tag: 0,  h2: _$$6.h6,  h3: Data_SortedMap_Node2(sc$$17.h2.h2, sc$$17.h2.h3.h2, sc$$17.h2.h3.h3) } }) : Prelude_Left(Data_SortedMap_Node3(_$$6.h3, _$$6.h4, _$$6.h5, _$$6.h6, sc$$17.h2)) ); break; } default: { let sc$$17 = Data_SortedMap_insertT23(_$$3, _$$4, _$$5, _$$6.h5); return ( (sc$$17.tag) == (1) ? Prelude_Right({ tag: 0,  h2: Data_SortedMap_Node2(_$$6.h3, _$$6.h4, sc$$17.h2.h2),  h3: { tag: 0,  h2: sc$$17.h2.h3.h2,  h3: Data_SortedMap_Node2(sc$$17.h2.h3.h3, _$$6.h6, _$$6.h7) } }) : Prelude_Left(Data_SortedMap_Node3(_$$6.h3, _$$6.h4, sc$$17.h2, _$$6.h6, _$$6.h7)) ); break; } } break; } default: { let sc$$16 = Data_SortedMap_insertT23(_$$3, _$$4, _$$5, _$$6.h3); return ( (sc$$16.tag) == (1) ? Prelude_Right({ tag: 0,  h2: Data_SortedMap_Node2(sc$$16.h2.h2, sc$$16.h2.h3.h2, sc$$16.h2.h3.h3),  h3: { tag: 0,  h2: _$$6.h4,  h3: Data_SortedMap_Node2(_$$6.h5, _$$6.h6, _$$6.h7) } }) : Prelude_Left(Data_SortedMap_Node3(sc$$16.h2, _$$6.h4, _$$6.h5, _$$6.h6, _$$6.h7)) ); break; } } break; } case 1: { let sc$$13 = _$$3(_$$4)(_$$6.h4); switch (sc$$13) { case 2: { let sc$$14 = Data_SortedMap_insertT23(_$$3, _$$4, _$$5, _$$6.h5); return ( (sc$$14.tag) == (1) ? Prelude_Left(Data_SortedMap_Node3(_$$6.h3, _$$6.h4, sc$$14.h2.h2, sc$$14.h2.h3.h2, sc$$14.h2.h3.h3)) : Prelude_Left(Data_SortedMap_Node2(_$$6.h3, _$$6.h4, sc$$14.h2)) ); break; } default: { let sc$$14 = Data_SortedMap_insertT23(_$$3, _$$4, _$$5, _$$6.h3); return ( (sc$$14.tag) == (1) ? Prelude_Left(Data_SortedMap_Node3(sc$$14.h2.h2, sc$$14.h2.h3.h2, sc$$14.h2.h3.h3, _$$6.h4, _$$6.h5)) : Prelude_Left(Data_SortedMap_Node2(sc$$14.h2, _$$6.h4, _$$6.h5)) ); break; } } break; } case 0: { let sc$$11 = _$$3(_$$4)(_$$6.h2); switch (sc$$11) { case 2: return Prelude_Right({ tag: 0,  h2: Data_SortedMap_Leaf(_$$6.h2, _$$6.h3),  h3: { tag: 0,  h2: _$$6.h2,  h3: Data_SortedMap_Leaf(_$$4, _$$5) } }); case 1: return Prelude_Left(Data_SortedMap_Leaf(_$$4, _$$5)); case 0: return Prelude_Right({ tag: 0,  h2: Data_SortedMap_Leaf(_$$4, _$$5),  h3: { tag: 0,  h2: _$$4,  h3: Data_SortedMap_Leaf(_$$6.h2, _$$6.h3) } }); } break; } } };
let Data_SortedMap_Node3 = ( h3, h4, h5, h6, h7 ) => ({ tag: 2,  h3: h3,  h4: h4,  h5: h5,  h6: h6,  h7: h7 });
let Lib_Types_MkTop = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_Types_putTop = ( _$$0 ) => (Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Right({ tag: 0,  h2: _$$0,  h3: 0 }), eta)))));
let Lib_Types_PrimFn = ( h0, h1, h2 ) => ({ tag: 5,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_Erased = ( h0 ) => ({ tag: 11,  h0: h0 });
let Lib_TopContext_setDef = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$6 = Data_SortedMap_lookupMap$27(_$$0, top.h2.h2); return ( (sc$$6.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, Data_SortedMap_updateMap(_$$0, Lib_Types_MkEntry(_$$1, _$$0, _$$2, _$$3, _$$4), tc.h2.h2), tc.h2.h3, tc.h2.h4, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" is already defined at ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(sc$$6.h1.h0))) + (""))), eta)))) ); }));
let Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow = ( _$$0 ) => { switch (_$$0.h0) { case "": return _$$0.h1; default: return (_$$0.h0) + ((".") + (_$$0.h1)); } };
let Lib_Types_MkEntry = ( h0, h1, h2, h3, h4 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Types_MkModCtx = ( h0, h1, h2, h3, h4, h5, h6, h7 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5,  h6: h6,  h7: h7 });
let Data_SortedMap_lookupMap$27 = ( _$$2, _$$3 ) => (( (_$$3.tag) == (1) ? Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( _$$21 ) => (_$$21.h3), Data_SortedMap_lookupT23(_$$3.h3, _$$2, _$$3.h4)) : Prelude_Nothing() ));
let Prelude_Nothing = (  ) => ({ tag: 1 });
let Data_SortedMap_lookupT23 = ( _$$3, _$$4, _$$5 ) => { while (1) { let _$$31 = _$$3; let _$$41 = _$$4; let _$$51 = _$$5; switch (_$$51.tag) { case 2: { let sc$$14 = _$$31(_$$41)(_$$51.h4); switch (sc$$14) { case 2: { let sc$$15 = _$$31(_$$41)(_$$51.h6); switch (sc$$15) { case 2: { _$$3 = _$$31; _$$4 = _$$41; _$$5 = _$$51.h7; continue; break; } default: { _$$3 = _$$31; _$$4 = _$$41; _$$5 = _$$51.h5; continue; break; } } break; } default: { _$$3 = _$$31; _$$4 = _$$41; _$$5 = _$$51.h3; continue; break; } } break; } case 1: { let sc$$12 = _$$31(_$$41)(_$$51.h4); switch (sc$$12) { case 2: { _$$3 = _$$31; _$$4 = _$$41; _$$5 = _$$51.h5; continue; break; } default: { _$$3 = _$$31; _$$4 = _$$41; _$$5 = _$$51.h3; continue; break; } } break; } case 0: { let sc$$10 = _$$31(_$$51.h2)(_$$41); switch (sc$$10) { case 1: return Prelude_Just({ tag: 0,  h2: _$$51.h2,  h3: _$$51.h3 }); default: return Prelude_Nothing(); } break; } } } };
let Prelude_Just = ( h1 ) => ({ tag: 0,  h1: h1 });
let Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap = ( _$$2, _$$3 ) => (( (_$$3.tag) == (1) ? Prelude_Nothing() : Prelude_Just(_$$2(_$$3.h1)) ));
let Lib_Syntax_PType = ( h0, h1, h2 ) => ({ tag: 6,  h0: h0,  h1: h1,  h2: h2 });
let Lib_ProcessDecl_processDecl = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 12: return Lib_ProcessDecl_processExports(_$$0, _$$1.h0, _$$1.h1); case 11: return Lib_ProcessDecl_processRecord(_$$0, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4); case 10: return Lib_ProcessDecl_processInstance(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); case 9: return Lib_ProcessDecl_processClass(_$$0, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3); case 8: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); case 7: return Lib_ProcessDecl_processPrimFn(_$$0, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4); case 6: return Lib_ProcessDecl_processPrimType(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); case 5: return Lib_ProcessDecl_processShortData(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); case 4: return ( (_$$1.h3.tag) == (1) ? Lib_ProcessDecl_processTypeSig(_$$0, _$$1.h0, { tag: 1,  h1: _$$1.h1.h3,  h2: { tag: 0 } }, _$$1.h2) : Lib_ProcessDecl_processData(_$$0, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3.h1) ); case 3: return Lib_ProcessDecl_processDerive(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); case 2: return Lib_ProcessDecl_processCheck(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); case 1: return Lib_ProcessDecl_processDef(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); case 0: return Lib_ProcessDecl_processTypeSig(_$$0, _$$1.h0, _$$1.h1, _$$1.h2); } };
let Lib_ProcessDecl_processTypeSig = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessDecl_checkAlreadyDef(_$$1, eta)), _$$2), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), _$$3, Lib_Types_VU(_$$1)), ( ty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _2 ) => ((((("TypeSig ") + (Prelude_joinBy(" ", _$$2))) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, ty))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$31 ) => (0), Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$2, ( nm ) => (Lib_TopContext_setDef({ tag: 0,  h0: _$$0,  h1: nm }, _$$1, ty, Lib_Types_Axiom, { tag: 0 })))))))))))))));
let Lib_Types_Axiom = { tag: 0 };
let Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_ = ( _$$2, _$$3 ) => (Lib_Types_MkM(( tc ) => (( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(_$$2.h1(tc), ( $$sc ) => (( ($$sc.tag) == (1) ? ( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(_$$3.h1($$sc.h2.h2), ( $$sc1 ) => (( ($$sc1.tag) == (1) ? ( eta ) => (Prelude_MkIORes(Prelude_Right({ tag: 0,  h2: $$sc1.h2.h2,  h3: $$sc.h2.h3($$sc1.h2.h3) }), eta)) : ( eta ) => (Prelude_MkIORes(Prelude_Left($$sc1.h2), eta)) )), eta)) : ( eta ) => (Prelude_MkIORes(Prelude_Left($$sc.h2), eta)) )), eta)))));
let Lib_Types_Prelude_Applicative$20Lib_Types_M = { tag: 0,  h1: ( a ) => (( eta ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(eta))),  h2: ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(eta, eta1))))) };
let Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse = ( _$$3, _$$4, _$$5 ) => (( (_$$5.tag) == (1) ? Prelude__$3C$2A$3E_(_$$3)(null)(null)(Prelude__$3C$2A$3E_(_$$3)(null)(null)(Prelude_return(_$$3)(null)(( eta ) => (( eta1 ) => (Prelude__$3A$3A_(eta, eta1)))))(_$$4(_$$5.h1)))(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(_$$3, _$$4, _$$5.h2)) : Prelude_return(_$$3)(null)({ tag: 0 }) ));
let Prelude_return = ( _$$1 ) => (( a ) => (_$$1.h1(null)));
let Prelude__$3C$2A$3E_ = ( _$$1 ) => (( a ) => (( b ) => (_$$1.h2(null)(null))));
let Prelude_MkTraversable = ( h1 ) => ({ tag: 0,  h1: h1 });
let Prelude_Prelude_Traversable$20Prelude_List = Prelude_MkTraversable(( f ) => (( a ) => (( b ) => (( _ ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(_, eta, eta1))))))));
let Prelude_for = ( _$$2, appf$$3, _$$6, _$$7 ) => (Prelude_traverse(_$$2)(null)(null)(null)(appf$$3)(_$$7)(_$$6));
let Prelude_traverse = ( _$$1 ) => (( f ) => (( a ) => (( b ) => (( _ ) => (_$$1.h1(null)(null)(null)(_))))));
let Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap = ( _$$2, _$$3 ) => (Lib_Types_MkM(( tc ) => (( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(_$$3.h1(tc), ( $$sc ) => (( ($$sc.tag) == (1) ? ( eta ) => (Prelude_MkIORes(Prelude_Right({ tag: 0,  h2: $$sc.h2.h2,  h3: _$$2($$sc.h2.h3) }), eta)) : ( eta ) => (Prelude_MkIORes(Prelude_Left($$sc.h2), eta)) )), eta)))));
let Lib_Types_pprint$27 = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case 11: return Lib_Prettier_Text("ERASED"); case 10: return Lib_Prettier_Text(Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$2.h1)); case 9: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("letrec"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h2))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("in"))), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Nest(2, Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h4))))); case 8: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("let"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h2))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("in"))), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Nest(2, Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h3))))); case 7: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("case"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("of"))), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_pprintAlt(0, _$$1, eta)), _$$2.h2)))))); case 6: switch (_$$2.h2) { case 2: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Text("{{"), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$2.h3)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h4))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("}}"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h5))))); case 1: switch (_$$2.h3) { case true: switch (_$$2.h1) { case "_": return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Types_pprint$27(1, _$$1, _$$2.h4), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, { tag: 1,  h1: "_",  h2: _$$1 }, _$$2.h5)))); default: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$2.h3)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h4))), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(")"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h5)))))); } break; default: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$2.h3)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h4))), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(")"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h5)))))); } break; case 0: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Prettier_Text("{"), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$2.h3)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$2.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, _$$1, _$$2.h4))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("}"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h5))))); } break; case 5: return Lib_Prettier_Text("U"); case 4: return Lib_Types_parens(0, _$$0, Lib_Prettier_Seq(Lib_Types_pprint$27(0, _$$1, _$$2.h1), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(1, _$$1, _$$2.h2)))); case 3: return Lib_Types_parens(0, _$$0, Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text((((("\\ ") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$2.h3))) + ("")) + (_$$2.h1)) + (" =>")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Types_pprint$27(0, { tag: 1,  h1: _$$2.h1,  h2: _$$1 }, _$$2.h4))))); case 2: return Lib_Prettier_Text((("?m:") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$2.h1))) + ("")); case 1: return Lib_Prettier_Text(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$2.h1)); case 0: { let sc$$5 = Prelude_getAt(Prelude_intToNat(_$$2.h1), _$$1); return ( (sc$$5.tag) == (1) ? Lib_Prettier_Text((("BND:") + (Prelude_showInt(_$$2.h1))) + ("")) : Lib_Prettier_Text((((("") + (sc$$5.h1)) + (":")) + (Prelude_showInt(_$$2.h1))) + ("")) ); break; } } };
let Lib_Prettier_Text = ( h0 ) => ({ tag: 2,  h0: h0 });
let Prelude_intToNat = (n) => n>0?n:0;
let Prelude_getAt = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { switch (_$$11) { case 0: return Prelude_Just(_$$21.h1); default: { let x = (_$$11) - (1); _$$1 = x; _$$2 = _$$21.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_Prettier_Line = { tag: 1 };
let Lib_Prettier_line = Lib_Prettier_Line;
let Lib_Prettier_Alt = ( h0, h1 ) => ({ tag: 5,  h0: h0,  h1: h1 });
let Lib_Prettier_Seq = ( h0, h1 ) => ({ tag: 4,  h0: h0,  h1: h1 });
let Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow = ( _$$0 ) => { switch (_$$0) { case true: return ""; case false: return "0 "; } };
let Lib_Prettier_Nest = ( h0, h1 ) => ({ tag: 3,  h0: h0,  h1: h1 });
let Lib_Types_parens = ( _$$0, _$$1, _$$2 ) => { let sc$$3 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0, _$$1), 0); switch (sc$$3) { case true: return Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(_$$2, Lib_Prettier_Text(")"))); case false: return _$$2; } };
let Lib_Types_pprintAlt = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case 2: return Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$2.h0)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("=>"), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Seq(Lib_Types_pprint$27(_$$0, _$$1, _$$2.h1), Lib_Prettier_Text(";"))))))); case 1: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$2.h0)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(Lib_Prettier_text, _$$2.h1)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("=>"), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Types_pprint$27(_$$0, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Prelude_reverse()(_$$2.h1), _$$1), _$$2.h2)))))); case 0: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("_"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("=>"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_pprint$27(_$$0, { tag: 1,  h1: "_",  h2: _$$1 }, _$$2.h0))); } };
let Prelude_reverse = (  ) => (( eta ) => (Prelude_reverse_go({ tag: 0 }, eta)));
let Prelude_reverse_go = ( _$$2, _$$3 ) => { while (1) { let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { _$$2 = { tag: 1,  h1: _$$31.h1,  h2: _$$21 }; _$$3 = _$$31.h2; continue; } else { return _$$21; } } };
let Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_ = ( _$$1, _$$2 ) => (Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B__go(_$$1, _$$2, Prelude_reverse()(_$$1), _$$2));
let Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B__go = ( _, _1, _$$5, _$$6 ) => { while (1) { let _2 = _; let _3 = _1; let _$$51 = _$$5; let _$$61 = _$$6; if ((_$$51.tag) == (1)) { _ = _2; _1 = _3; _$$5 = _$$51.h2; _$$6 = { tag: 1,  h1: _$$51.h1,  h2: _$$61 }; continue; } else { return _$$61; } } };
let Lib_Prettier_text = ( eta ) => (Lib_Prettier_Text(eta));
let Prelude_Prelude_Functor$20Prelude_List$2Cmap = ( _$$2, _$$3 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap_go(_$$2, _$$3, _$$2, _$$3, { tag: 0 }));
let Prelude_Prelude_Functor$20Prelude_List$2Cmap_go = ( _, _1, _$$7, _$$8, _$$9 ) => { while (1) { let _2 = _; let _3 = _1; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; if ((_$$81.tag) == (1)) { _ = _2; _1 = _3; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = { tag: 1,  h1: _$$71(_$$81.h1),  h2: _$$91 }; continue; } else { return Prelude_reverse()(_$$91); } } };
let Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_ = ( _$$0, _$$1 ) => (Lib_Prettier_Seq(_$$0, Lib_Prettier_Seq(Lib_Prettier_Text(" "), _$$1)));
let Lib_Prettier_folddoc = ( _$$0, _$$1 ) => (( (_$$1.tag) == (1) ? ( (_$$1.h2.tag) == (0) ? _$$1.h1 : _$$0(_$$1.h1)(Lib_Prettier_folddoc(_$$0, _$$1.h2)) ) : Lib_Prettier_Empty ));
let Lib_Prettier_Empty = { tag: 0 };
let Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 3: switch (_$$0.h0) { case true: return "true"; case false: return "false"; } break; case 2: return (("'") + (Prelude_pack({ tag: 1,  h1: "'",  h2: { tag: 1,  h1: _$$0.h0,  h2: { tag: 1,  h1: "'",  h2: { tag: 0 } } } }))) + ("'"); case 1: return Prelude_showInt(_$$0.h0); case 0: return Lib_Common_quoteString(_$$0.h0); } };
let Lib_Common_quoteString = ( _$$0 ) => (Prelude_pack(Lib_Common_quoteString_encode(_$$0, Prelude_unpack(_$$0), { tag: 1,  h1: { tag: 0 },  h2: "\"" })));
let Lib_Common_quoteString_encode = ( _, _$$2, _$$3 ) => { while (1) { let _1 = _; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$21.tag) == (1)) { switch (_$$21.h1) { case "\"": { _ = _1; _$$2 = _$$21.h2; _$$3 = { tag: 1,  h1: { tag: 1,  h1: _$$31,  h2: "\\" },  h2: "\"" }; continue; break; } case "\n": { _ = _1; _$$2 = _$$21.h2; _$$3 = { tag: 1,  h1: { tag: 1,  h1: _$$31,  h2: "\\" },  h2: "n" }; continue; break; } case "\\": { _ = _1; _$$2 = _$$21.h2; _$$3 = { tag: 1,  h1: { tag: 1,  h1: _$$31,  h2: "\\" },  h2: "\\" }; continue; break; } default: { let v = Prelude_ord(_$$21.h1); let sc$$8 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(v, 32), 0); switch (sc$$8) { case true: { _ = _1; _$$2 = _$$21.h2; _$$3 = { tag: 1,  h1: { tag: 1,  h1: { tag: 1,  h1: { tag: 1,  h1: { tag: 1,  h1: { tag: 1,  h1: _$$31,  h2: "\\" },  h2: "u" },  h2: Prelude_fromMaybe(" ", Prelude_getAt(Prelude_intToNat(Prelude_mod(((v) / (4096)) | (0), 16)), Lib_Common_hexChars)) },  h2: Prelude_fromMaybe(" ", Prelude_getAt(Prelude_intToNat(Prelude_mod(((v) / (256)) | (0), 16)), Lib_Common_hexChars)) },  h2: Prelude_fromMaybe(" ", Prelude_getAt(Prelude_intToNat(Prelude_mod(((v) / (16)) | (0), 16)), Lib_Common_hexChars)) },  h2: Prelude_fromMaybe(" ", Prelude_getAt(Prelude_intToNat(Prelude_mod(v, 16)), Lib_Common_hexChars)) }; continue; break; } case false: { _ = _1; _$$2 = _$$21.h2; _$$3 = { tag: 1,  h1: _$$31,  h2: _$$21.h1 }; continue; break; } } break; } } } else { return Prelude__$3C$3E$3E_(_$$31, { tag: 1,  h1: "\"",  h2: { tag: 0 } }); } } };
let Lib_Common_hexChars = Prelude_unpack("0123456789ABCDEF");
let Prelude_mod = (a,b) => a % b;
let Prelude_fromMaybe = ( _$$1, _$$2 ) => (( (_$$2.tag) == (1) ? _$$1 : _$$2.h1 ));
let Prelude_divInt = (x,y) => x / y | 0;
let Prelude_ord = (c) => c.charCodeAt(0);
let Lib_Prettier__$3C$2F$3E_ = ( _$$0, _$$1 ) => (Lib_Prettier_Seq(_$$0, Lib_Prettier_Seq(Lib_Prettier_line, _$$1)));
let Lib_Prettier_noAlt = ( _$$0 ) => { while (1) { let _$$01 = _$$0; switch (_$$01.tag) { case 5: { _$$0 = _$$01.h0; continue; break; } case 4: return Lib_Prettier_Seq(Lib_Prettier_noAlt(_$$01.h0), Lib_Prettier_noAlt(_$$01.h1)); case 3: { _$$0 = _$$01.h1; continue; break; } case 2: return Lib_Prettier_Text(_$$01.h0); case 1: return Lib_Prettier_Line; case 0: return Lib_Prettier_Empty; } } };
let Lib_Prettier_best = ( _$$0, _$$1, _$$2 ) => (Prelude_fromMaybe({ tag: 0 }, Lib_Prettier_be(false, { tag: 0 }, _$$0, _$$1, { tag: 1,  h1: { tag: 0,  h2: 0,  h3: _$$2 },  h2: { tag: 0 } })));
let Lib_Prettier_be = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$41.tag) == (1)) { switch (_$$41.h1.h3.tag) { case 5: return Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Prelude__$3C$3E$3E_(_$$11, eta)), Prelude_Prelude_Alternative$20Prelude_Maybe$2C_$3C$7C$3E_(Lib_Prettier_be(true, { tag: 0 }, _$$21, _$$31, { tag: 1,  h1: { tag: 0,  h2: _$$41.h1.h2,  h3: _$$41.h1.h3.h0 },  h2: _$$41.h2 }), Lib_Prettier_be(_$$01, { tag: 0 }, _$$21, _$$31, { tag: 1,  h1: { tag: 0,  h2: _$$41.h1.h2,  h3: _$$41.h1.h3.h1 },  h2: _$$41.h2 }))); case 4: { _$$0 = _$$01; _$$1 = _$$11; _$$2 = _$$21; _$$3 = _$$31; _$$4 = { tag: 1,  h1: { tag: 0,  h2: _$$41.h1.h2,  h3: _$$41.h1.h3.h0 },  h2: { tag: 1,  h1: { tag: 0,  h2: _$$41.h1.h2,  h3: _$$41.h1.h3.h1 },  h2: _$$41.h2 } }; continue; break; } case 3: { _$$0 = _$$01; _$$1 = _$$11; _$$2 = _$$21; _$$3 = _$$31; _$$4 = { tag: 1,  h1: { tag: 0,  h2: (_$$41.h1.h2) + (_$$41.h1.h3.h0),  h3: _$$41.h1.h3.h1 },  h2: _$$41.h2 }; continue; break; } case 2: { let sc$$13 = (Prelude_not(_$$01)) || (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare((_$$31) + (Prelude_slen(_$$41.h1.h3.h0)), _$$21), 0)); switch (sc$$13) { case true: { _$$0 = _$$01; _$$1 = { tag: 1,  h1: _$$11,  h2: Lib_Prettier_TEXT(_$$41.h1.h3.h0) }; _$$2 = _$$21; _$$3 = (_$$31) + (Prelude_slen(_$$41.h1.h3.h0)); _$$4 = _$$41.h2; continue; break; } case false: return Prelude_Nothing(); } break; } case 1: { _$$0 = false; _$$1 = { tag: 1,  h1: _$$11,  h2: Lib_Prettier_LINE(_$$41.h1.h2) }; _$$2 = _$$21; _$$3 = _$$41.h1.h2; _$$4 = _$$41.h2; continue; break; } case 0: { _$$0 = _$$01; _$$1 = _$$11; _$$2 = _$$21; _$$3 = _$$31; _$$4 = _$$41.h2; continue; break; } } } else { return Prelude_Just(Prelude__$3C$3E$3E_(_$$11, { tag: 0 })); } } };
let Lib_Prettier_LINE = ( h0 ) => ({ tag: 1,  h0: h0 });
let Prelude_slen = s => s.length;
let Lib_Prettier_TEXT = ( h0 ) => ({ tag: 0,  h0: h0 });
let Prelude_not = ( _$$0 ) => { switch (_$$0) { case true: return false; case false: return true; } };
let Prelude__$7C$7C_ = ( _$$0, _$$1 ) => { switch (_$$0) { case true: return true; case false: return _$$1; } };
let Prelude_Prelude_Alternative$20Prelude_Maybe$2C_$3C$7C$3E_ = ( _$$1, _$$2 ) => (( (_$$1.tag) == (1) ? _$$2 : Prelude_Just(_$$1.h1) ));
let Lib_Prettier_layout = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$01.tag) == (1)) { if ((_$$01.h1.tag) == (1)) { _$$0 = _$$01.h2; _$$1 = { tag: 1,  h1: { tag: 1,  h1: _$$11,  h2: "\n" },  h2: Lib_Common_padding(_$$01.h1.h0, " ") }; continue; } else { _$$0 = _$$01.h2; _$$1 = { tag: 1,  h1: _$$11,  h2: _$$01.h1.h0 }; continue; } } else { return Prelude_fastConcat(Prelude__$3C$3E$3E_(_$$11, { tag: 0 })); } } };
let Prelude_listToArray = 
(a, l) => {
  let rval = []
  while (l.tag !== 'Nil' && l.tag) {
    rval.push(l.h1)
    l = l.h2
  }
  return rval
}
;
let Prelude_fastConcat = (xs) => Prelude_listToArray(null, xs).join('');
let Prelude_joinBy = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$11.tag) == (1)) { if ((_$$11.h2.tag) == (1)) { _$$0 = _$$01; _$$1 = { tag: 1,  h1: (_$$11.h1) + ((_$$01) + (_$$11.h2.h1)),  h2: _$$11.h2.h2 }; continue; } else { return _$$11.h1; } } else { return ""; } } };
let Lib_Types_log = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0, top.h3), 2)), ( _ ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn(_$$1(0))))))));
let Prelude_when = ( _$$1, _$$2, _$$3 ) => { switch (_$$2) { case true: return _$$3(0); case false: return Prelude_return(_$$1)(null)(0); } };
let Lib_Types_VU = ( h0 ) => ({ tag: 8,  h0: h0 });
let Lib_Types_MkCtx = ( h0, h1, h2, h3, h4 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Elab_check = ( _$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_forceType(_$$0.h1, _$$2), ( ty$27 ) => { let sc$$4 = { tag: 0,  h2: _$$1,  h3: ty$27 }; switch (sc$$4.h2.tag) { case 15: return Lib_Elab_updateRec(_$$0, sc$$4.h2.h0, sc$$4.h2.h1, sc$$4.h2.h2, sc$$4.h3); case 13: return Lib_Elab_checkWhere(_$$0, Lib_Elab_collectDecl(sc$$4.h2.h1), sc$$4.h2.h2, sc$$4.h3); case 12: { let tm$27 = Lib_Syntax_RCase(sc$$4.h2.h0, sc$$4.h2.h1, Prelude_Nothing(), { tag: 1,  h1: { tag: 0,  h0: Lib_Syntax_RVar(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$4.h2.h2), "True"),  h1: Prelude_Just(sc$$4.h2.h2) },  h2: { tag: 1,  h1: { tag: 0,  h0: Lib_Syntax_RVar(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$4.h2.h3), "False"),  h1: Prelude_Just(sc$$4.h2.h3) },  h2: { tag: 0 } } }); return Lib_Elab_check(_$$0, tm$27, sc$$4.h3); break; } case 11: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_undo(sc$$4.h2.h1), ( body ) => (Lib_Elab_check(_$$0, body, sc$$4.h3))); case 10: return Lib_Elab_freshMeta(_$$0, sc$$4.h2.h0, sc$$4.h3, 1); case 9: return Lib_Elab_freshMeta(_$$0, sc$$4.h2.h0, sc$$4.h3, 0); case 8: return ( (sc$$4.h2.h2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(_$$0, sc$$4.h2.h1), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta($$sc.h3), ( scty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("SCTM ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2), $$sc.h2))), { tag: 0 }))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("SCTY ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(scty))) + (""))), ( _1 ) => { let scnm = Lib_Elab_fresh(_$$0, "sc"); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, sc$$4.h2.h3, ( $$case ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_mkPat({ tag: 0,  h2: $$case.h0,  h3: 1 }), ( pat$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC($$case.h0), { tag: 1,  h1: Lib_Types_PC(scnm, pat$27, scty),  h2: { tag: 0 } }, { tag: 0 }, $$case.h1)))))), ( clauses ) => { let ctx$27; let _sc$$21 = Lib_Types_extend(_$$0, scnm, scty); ctx$27 = Lib_Types_MkCtx(_sc$$21.h0, _sc$$21.h1, _sc$$21.h2, _sc$$21.h3, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$1)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: sc$$4.h3 }), ( tree ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Let(sc$$4.h2.h0, scnm, $$sc.h2, tree)))); }))); }))))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, sc$$4.h2.h2.h1, Lib_Types_VU(Lib_Common_emptyFC)), ( scty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, scty), ( vscty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, sc$$4.h2.h1, vscty), ( sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: sc,  h3: vscty }))))))), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta($$sc.h3), ( scty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("SCTM ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2), $$sc.h2))), { tag: 0 }))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("SCTY ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(scty))) + (""))), ( _1 ) => { let scnm = Lib_Elab_fresh(_$$0, "sc"); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, sc$$4.h2.h3, ( $$case ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_mkPat({ tag: 0,  h2: $$case.h0,  h3: 1 }), ( pat$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC($$case.h0), { tag: 1,  h1: Lib_Types_PC(scnm, pat$27, scty),  h2: { tag: 0 } }, { tag: 0 }, $$case.h1)))))), ( clauses ) => { let ctx$27; let _sc$$21 = Lib_Types_extend(_$$0, scnm, scty); ctx$27 = Lib_Types_MkCtx(_sc$$21.h0, _sc$$21.h1, _sc$$21.h2, _sc$$21.h3, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$1)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: sc$$4.h3 }), ( tree ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Let(sc$$4.h2.h0, scnm, $$sc.h2, tree)))); }))); }))))))) ); case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, sc$$4.h2.h2, Lib_Types_VU(Lib_Common_emptyFC)), ( ty$271 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, ty$271), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, sc$$4.h2.h3, vty), ( v$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, v$27), ( vv ) => { let ctx$27 = Lib_Types_define(_$$0, sc$$4.h2.h1, vv, vty); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(ctx$27, sc$$4.h2.h4, sc$$4.h3), ( sc$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Let(sc$$4.h2.h0, sc$$4.h2.h1, v$27, sc$27)))); }))))))); case 1: return ( (sc$$4.h3.tag) == (5) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((((("icits ") + (sc$$4.h2.h1.h1)) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(sc$$4.h2.h1.h2))) + (" ")) + (sc$$4.h3.h1)) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(sc$$4.h3.h2))) + (""))), ( _ ) => { let sc$$23 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(sc$$4.h2.h1.h2, sc$$4.h3.h2); switch (sc$$23) { case true: { let $var = Lib_Types_VVar(sc$$4.h2.h0, Prelude_length$27(_$$0.h1), { tag: 0 }); let ctx$27 = Lib_Types_extend(_$$0, sc$$4.h2.h1.h1, sc$$4.h3.h4); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: $var,  h2: sc$$4.h3.h5.h0 }, sc$$4.h3.h5.h1), ( bapp ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(ctx$27, sc$$4.h2.h2, bapp), ( tm$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lam(sc$$4.h2.h0, sc$$4.h2.h1.h1, sc$$4.h2.h1.h2, sc$$4.h3.h3, tm$27)))))); break; } case false: { let sc$$24 = Prelude_not(Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(sc$$4.h3.h2, 1)); switch (sc$$24) { case true: { let $var = Lib_Types_VVar(sc$$4.h2.h0, Prelude_length$27(_$$0.h1), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: $var,  h2: sc$$4.h3.h5.h0 }, sc$$4.h3.h5.h1), ( ty$271 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_extend(_$$0, sc$$4.h3.h1, sc$$4.h3.h4), sc$$4.h2, ty$271), ( sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lam(sc$$4.h2.h0, sc$$4.h3.h1, sc$$4.h2.h1.h2, sc$$4.h3.h3, sc)))))); break; } case false: return Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$4.h2.h0, (((("Icity issue checking ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(sc$$4.h2))) + (" at ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$4.h3))) + (""))), eta)))); } break; } } }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_prvalCtx(_$$0, sc$$4.h3), ( pty ) => (Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$4.h2.h0, (("Expected ") + (pty)) + (", got a function"))), eta)))))) ); default: { if ((sc$$4.h3.tag) == (5)) { switch (sc$$4.h3.h2) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("elab.insert: Add auto lambda {") + (sc$$4.h3.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$4.h3.h4))) + ("} to ")) + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(sc$$4.h2))) + (""))), ( _ ) => { let $var = Lib_Types_VVar(sc$$4.h3.h0, Prelude_length$27(_$$0.h1), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: $var,  h2: sc$$4.h3.h5.h0 }, sc$$4.h3.h5.h1), ( ty$271 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_logM(2, Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_prvalCtx(Lib_Types_extend(_$$0, sc$$4.h3.h1, sc$$4.h3.h4), ty$271), ( pty$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn((("elab.insert: ty' is ") + (pty$27)) + (""))))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_extend(_$$0, sc$$4.h3.h1, sc$$4.h3.h4), sc$$4.h2, ty$271), ( sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lam(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$4.h2), sc$$4.h3.h1, 2, sc$$4.h3.h3, sc)))))))); }); case 0: { let names = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("elab.insert: Add implicit lambda {") + (sc$$4.h3.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$4.h3.h4))) + ("} to ")) + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(sc$$4.h2))) + (" "))), ( _ ) => { let $var = Lib_Types_VVar(sc$$4.h3.h0, Prelude_length$27(_$$0.h1), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: $var,  h2: sc$$4.h3.h5.h0 }, sc$$4.h3.h5.h1), ( ty$271 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_logM(2, Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_prvalCtx(Lib_Types_extend(_$$0, sc$$4.h3.h1, sc$$4.h3.h4), ty$271), ( pty$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn((("XXX ty' is ") + (pty$27)) + (""))))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_extend(_$$0, sc$$4.h3.h1, sc$$4.h3.h4), sc$$4.h2, ty$271), ( sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lam(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$4.h2), sc$$4.h3.h1, 0, sc$$4.h3.h3, sc)))))))); }); break; } default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(_$$0, sc$$4.h2), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_insert(_$$0, $$sc.h2, $$sc.h3), ( $$sc1 ) => { let names = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((((("INFER ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(sc$$4.h2))) + (" to (")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, $$sc1.h2))), { tag: 0 }))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc1.h3))) + (") expect ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$4.h3))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$4.h2), _$$0, $$sc1.h3, sc$$4.h3), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn($$sc1.h2))))); }))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(_$$0, sc$$4.h2), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_insert(_$$0, $$sc.h2, $$sc.h3), ( $$sc1 ) => { let names = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((((("INFER ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(sc$$4.h2))) + (" to (")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, $$sc1.h2))), { tag: 0 }))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc1.h3))) + (") expect ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$4.h3))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$4.h2), _$$0, $$sc1.h3, sc$$4.h3), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn($$sc1.h2))))); }))); } break; } } }));
let Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case 15: return _$$0.h0; case 14: return _$$0.h0; case 13: return _$$0.h0; case 12: return _$$0.h0; case 11: return _$$0.h0; case 10: return _$$0.h0; case 9: return _$$0.h0; case 8: return _$$0.h0; case 7: return _$$0.h0; case 6: return _$$0.h0; case 5: return _$$0.h0; case 4: return _$$0.h0; case 3: return _$$0.h0; case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Elab_unifyCatch = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_catchError(Lib_Elab_unify(_$$1.h1, false, _$$2, _$$3), ( err ) => { let names = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$1.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("fail ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$2))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$1.h0, _$$2), ( a ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$1.h0, _$$3), ( b ) => { let msg = (((((("unification failure: ") + (Lib_Error_errorMsg(err))) + ("\n  failed to unify ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, a))), { tag: 0 }))) + ("\n             with ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, b))), { tag: 0 }))) + ("\n  "); return Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0, msg)), eta)))); }))))); }), ( res ) => (( (res.h0.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("fail with constraints ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), res.h0))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$1.h0, _$$2), ( a ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$1.h0, _$$3), ( b ) => { let names = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$1.h2); let msg = (((("unification failure\n  failed to unify ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, a))), { tag: 0 }))) + ("\n             with ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, b))), { tag: 0 }))) + (""); let msg1 = (msg) + ((("\nconstraints ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), res.h0))) + ("")); return Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0, msg1)), eta)))); }))))) ))));
let Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 10: return Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$0.h1); case 9: return "ERASED"; case 8: return "U"; case 7: return (((((((("(%letrec ") + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h2))) + (" = ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h3))) + (" in ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h4))) + (""); case 6: return (((((("(%let ") + (_$$0.h1)) + (" = ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h2))) + (" in ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h3.h1))) + (""); case 5: switch (_$$0.h2) { case 2: return (((((((("(%pi {{") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + (" ")) + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h4))) + ("}}. ")) + (Lib_Types_showClosure(_$$0.h5))) + (")"); case 1: return (((((((("(%pi (") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + (" ")) + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h4))) + ("). ")) + (Lib_Types_showClosure(_$$0.h5))) + (")"); case 0: return (((((((("(%pi {") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + (" ")) + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h4))) + ("}. ")) + (Lib_Types_showClosure(_$$0.h5))) + (")"); } break; case 4: return (((((("(%lam ") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + ("")) + (_$$0.h1)) + (" ")) + (Lib_Types_showClosure(_$$0.h4))) + (")"); case 3: return (((("(%meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (" [")) + (Prelude_showInt(Prelude_natToInt(Data_SnocList_snoclen(_$$0.h2))))) + (" sp])"); case 2: return (((("(%case ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h1))) + (" ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(Lib_Types_Prelude_Show$20Lib_Types_CaseAlt$2Cshow, _$$0.h3)))) + (")"); case 1: return ( (_$$0.h2.tag) == (0) ? Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1) : (((("(") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (" ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(eta)), Prelude__$3C$3E$3E_(_$$0.h2, { tag: 0 }))))) + (")") ); case 0: return ( (_$$0.h2.tag) == (0) ? (("%var") + (Prelude_showInt(_$$0.h1))) + ("") : (((("(%var") + (Prelude_showInt(_$$0.h1))) + (" ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(eta)), Prelude__$3C$3E$3E_(_$$0.h2, { tag: 0 }))))) + (")") ); } };
let Lib_Types_showCaseAlt = ( _$$0 ) => { switch (_$$0.tag) { case 2: return (((("") + (Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$0.h0))) + (" => ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h1))) + (""); case 1: return (((((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h0))) + (" ")) + (Prelude_joinBy(" ", _$$0.h1))) + (" => ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h2))) + (""); case 0: return (("_ => ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h0))) + (""); } };
let Lib_Types_Prelude_Show$20Lib_Types_CaseAlt$2Cshow = ( eta ) => (Lib_Types_showCaseAlt(eta));
let Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 11: return "ERASED"; case 10: return (("(Lit ") + (Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$0.h1))) + (")"); case 9: return (((((((("(LetRec ") + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h2))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h3))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h4))) + (")"); case 8: return (((((("(Let ") + (_$$0.h1)) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h2))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h3))) + (")"); case 7: return (((("(Case ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_showCaseAlt(eta)), _$$0.h2)))) + (")"); case 6: switch (_$$0.h2) { case 2: return (((((((("(Pi {{") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + ("")) + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h4))) + ("}} => ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h5))) + (")"); case 1: return (((((((("(Pi (") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + ("")) + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h4))) + (") => ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h5))) + (")"); case 0: return (((((((("(Pi {") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + ("")) + (_$$0.h1)) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h4))) + ("} => ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h5))) + (")"); } break; case 5: return "U"; case 4: return (((("(") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h1))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h2))) + (")"); case 3: return (((((("(\\ ") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + ("")) + (_$$0.h1)) + ("  => ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h4))) + (")"); case 2: return (("(Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (")"); case 1: return (("(Ref ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (")"); case 0: return (("(Bnd ") + (Prelude_showInt(_$$0.h1))) + (")"); } };
let Prelude_Prelude_Show$20Prim_String$2Cshow = ( _$$0 ) => (_$$0);
let Prelude_MkShow = ( h1 ) => ({ tag: 0,  h1: h1 });
let Prelude_Prelude_Show$20Prim_String = Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20Prim_String$2Cshow(eta)));
let Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow = ( _$$1, _$$2 ) => (("[") + ((Prelude_joinBy(", ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(_$$1.h1, _$$2))) + ("]")));
let Data_SnocList_snoclen = ( _$$1 ) => (Data_SnocList_snoclen_go(_$$1, _$$1, 0));
let Data_SnocList_snoclen_go = ( _, _$$3, _$$4 ) => { while (1) { let _1 = _; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$31.tag) == (1)) { _ = _1; _$$3 = _$$31.h1; _$$4 = (1) + (_$$41); continue; } else { return _$$41; } } };
let Prelude_natToInt = (n) => n;
let Lib_Types_showClosure = ( _$$0 ) => ((((("(%cl [") + (Prelude_showInt(Prelude_natToInt(Prelude_length(_$$0.h0))))) + (" env] ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h1))) + (")"));
let Prelude_length = ( _$$1 ) => (( (_$$1.tag) == (1) ? (1) + (Prelude_length(_$$1.h2)) : 0 ));
let Lib_Types_Prelude_Show$20Lib_Types_Val = Prelude_MkShow(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(eta)));
let Prelude_Prelude_Show$20Prim_Int$2Cshow = ( eta ) => (Prelude_showInt(eta));
let Prelude_Prelude_Show$20Prim_Int = Prelude_MkShow(Prelude_Prelude_Show$20Prim_Int$2Cshow);
let Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow = ( _$$2, _$$3, _$$4 ) => (("(") + ((Prelude_show(_$$2)(_$$4.h2)) + ((", ") + ((Prelude_show(_$$3)(_$$4.h3)) + (")")))));
let Prelude_show = ( _$$1 ) => (_$$1.h1);
let Lib_Eval_quote = ( lvl$$0, _$$1 ) => { switch (_$$1.tag) { case 10: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lit(_$$1.h0, _$$1.h1)); case 9: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Erased(_$$1.h0)); case 8: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_UU(_$$1.h0)); case 7: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(lvl$$0, _$$1.h2), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((1) + (lvl$$0), _$$1.h3), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((1) + (lvl$$0), _$$1.h4), ( u$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_LetRec(_$$1.h0, _$$1.h1, ty$27, t$27, u$27)))))))); case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(lvl$$0, _$$1.h2), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(_$$1.h0, lvl$$0, { tag: 0 }),  h2: _$$1.h3.h0 }, _$$1.h3.h1), ( u ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((1) + (lvl$$0), u), ( u$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Let(_$$1.h0, _$$1.h1, t$27, u$27)))))))); case 5: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(lvl$$0, _$$1.h4), ( a$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, lvl$$0, { tag: 0 }),  h2: _$$1.h5.h0 }, _$$1.h5.h1), ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((1) + (lvl$$0), val), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Pi(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, a$27, tm)))))))); case 4: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, lvl$$0, { tag: 0 }),  h2: _$$1.h4.h0 }, _$$1.h4.h1), ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((1) + (lvl$$0), val), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lam(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, tm)))))); case 3: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$1.h1), ( meta ) => (( (meta.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(meta.h2, _$$1.h2), ( eta ) => (Lib_Eval_quote(lvl$$0, eta))) : Lib_Eval_quoteSp(lvl$$0, Lib_Types_Meta(_$$1.h0, _$$1.h1), _$$1.h2) ))); case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(lvl$$0, _$$1.h1), ( sc$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Eval_normAlt(_$$1.h2, lvl$$0, eta)), _$$1.h3), ( alts$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(_$$1.h0, sc$27, alts$27)))))); case 1: return Lib_Eval_quoteSp(lvl$$0, Lib_Types_Ref(_$$1.h0, _$$1.h1), _$$1.h2); case 0: { let sc$$5 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$1.h1, lvl$$0), 0); switch (sc$$5) { case true: return Lib_Eval_quoteSp(lvl$$0, Lib_Types_Bnd(_$$1.h0, ((lvl$$0) - (_$$1.h1)) - (1)), _$$1.h2); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (((("Bad level in quote ") + (Prelude_showInt(_$$1.h1))) + (" depth ")) + (Prelude_showInt(lvl$$0))) + (""))), eta)))); } break; } } };
let Lib_Types_Bnd = ( h0, h1 ) => ({ tag: 0,  h0: h0,  h1: h1 });
let Lib_Eval_quoteSp = ( lvl$$0, _$$1, _$$2 ) => (( (_$$2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quoteSp(lvl$$0, _$$1, _$$2.h1), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(lvl$$0, _$$2.h2), ( x$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_App(Lib_Common_emptyFC, t$27, x$27)))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$1) ));
let Lib_Types_App = ( h0, h1, h2 ) => ({ tag: 4,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_Ref = ( h0, h1 ) => ({ tag: 1,  h0: h0,  h1: h1 });
let Lib_Types_Case = ( h0, h1, h2 ) => ({ tag: 7,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Eval_normAlt = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$2.h1), ( val ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseLit(_$$2.h0, eta)), Lib_Eval_quote(_$$1, val)))); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(Lib_Eval_normAlt_mkenv(_$$0, _$$1, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, _$$1, _$$0, _$$2.h1), _$$2.h2), ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((Prelude_length$27(_$$2.h1)) + (_$$1), val), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_CaseCons(_$$2.h0, _$$2.h1, tm)))))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$2.h0), ( val ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseDefault(eta)), Lib_Eval_quote(_$$1, val)))); } };
let Lib_Types_CaseDefault = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_Eval_eval = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 11: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VErased(_$$1.h0)); case 10: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VLit(_$$1.h0, _$$1.h1)); case 9: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, "eval letrec")), eta)))); case 8: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$1.h2), ( t$27 ) => { switch (true) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VLet(_$$1.h0, _$$1.h1, t$27, { tag: 0,  h0: _$$0,  h1: _$$1.h3 })); case false: return Lib_Eval_eval({ tag: 1,  h1: t$27,  h2: _$$0 }, _$$1.h3); } }); case 7: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$1.h1), ( sc$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_forceType(_$$0, sc$27), ( sc$271 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_evalCase(_$$0, sc$271, _$$1.h2), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$1.h1), ( vsc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VCase(_$$1.h0, vsc, _$$0, _$$1.h2)))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn($$sc.h1) ))))))); case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$1.h4), ( a$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VPi(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, a$27, { tag: 0,  h0: _$$0,  h1: _$$1.h5 })))); case 5: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VU(_$$1.h0)); case 4: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$1.h1), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, _$$1.h2), ( u$27 ) => (Lib_Eval_vapp(t$27, u$27))))); case 3: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VLam(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, { tag: 0,  h0: _$$0,  h1: _$$1.h4 })); case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$1.h1), ( meta ) => (( (meta.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(meta.h2) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VMeta(_$$1.h0, _$$1.h1, { tag: 0 })) ))); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VRef(_$$1.h0, _$$1.h1, { tag: 0 })); case 0: { let sc$$4 = Prelude_getAt(Prelude_intToNat(_$$1.h1), _$$0); return ( (sc$$4.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (("Bad deBruin index ") + (Prelude_showInt(_$$1.h1))) + (""))), eta)))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$4.h1) ); break; } } };
let Lib_Types_VRef = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_VMeta = ( h0, h1, h2 ) => ({ tag: 3,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_lookupMeta = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$4 = Data_SortedMap_lookupMap$27(_$$0, top.h2.h3.h0); if ((sc$$4.tag) == (1)) { let sc$$6 = Data_SortedMap_lookupMap$27(_$$0.h0, top.h0); if ((sc$$6.tag) == (1)) { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (((("missing module: ") + (_$$0.h0)) + (" looking up meta ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (""))), eta)))); } else { let sc$$9 = Data_SortedMap_lookupMap$27(_$$0, sc$$6.h1.h3.h0); return ( (sc$$9.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("missing meta: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (""))), eta)))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$9.h1) ); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$4.h1); } }));
let Lib_Types_VLam = ( h0, h1, h2, h3, h4 ) => ({ tag: 4,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Eval_vapp = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case 4: return Lib_Eval_eval({ tag: 1,  h1: _$$1,  h2: _$$0.h4.h0 }, _$$0.h4.h1); case 3: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VMeta(_$$0.h0, _$$0.h1, { tag: 1,  h1: _$$0.h2,  h2: _$$1 })); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VRef(_$$0.h0, _$$0.h1, { tag: 1,  h1: _$$0.h2,  h2: _$$1 })); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VVar(_$$0.h0, _$$0.h1, { tag: 1,  h1: _$$0.h2,  h2: _$$1 })); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (((("impossible in vapp ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0))) + (" to ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$1))) + ("\n"))), eta)))); } };
let Lib_Types_VVar = ( h0, h1, h2 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_VPi = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: 5,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_Types_VCase = ( h0, h1, h2, h3 ) => ({ tag: 2,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Eval_evalCase = ( _$$0, _$$1, _$$2 ) => { if ((_$$2.tag) == (1)) { switch (_$$2.h1.tag) { case 1: return ( (_$$1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$14 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$1.h1, _$$2.h1.h0); switch (sc$$14) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((((("ECase ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$1.h2, { tag: 0 })))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, _$$2.h1.h1))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$2.h1.h2))) + (""))), ( _ ) => (Lib_Eval_evalCase_pushArgs(_$$0, _$$1, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h1.h0, _$$2.h1.h1, _$$2.h1.h2, _$$1.h0, _$$1.h1, _$$1.h2, _$$0, Prelude__$3C$3E$3E_(_$$1.h2, { tag: 0 }), _$$2.h1.h1))); case false: { let sc$$15 = Lib_TopContext_lookup(_$$1.h1, top); return ( (sc$$15.tag) == (0) ? ( (sc$$15.h1.h3.tag) == (2) ? Lib_Eval_evalCase(_$$0, _$$1, _$$2.h2) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()) ) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()) ); break; } } }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("CASE BAIL sc ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$1))) + (" vs "))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("env is ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$0))) + (""))), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))))) ); case 0: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Just(eta)), Lib_Eval_eval(_$$0, _$$2.h1.h0)); default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("CASE BAIL sc ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$1))) + (" vs "))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("env is ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$0))) + (""))), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("CASE BAIL sc ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$1))) + (" vs "))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("env is ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$0))) + (""))), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))))); } };
let Lib_TopContext_lookup = ( _$$0, _$$1 ) => { let sc$$4 = Prelude_eqString(_$$0.h0, _$$1.h2.h0); switch (sc$$4) { case true: return Data_SortedMap_lookupMap$27(_$$0, _$$1.h2.h2); case false: { let sc$$5 = Data_SortedMap_lookupMap$27(_$$0.h0, _$$1.h0); return ( (sc$$5.tag) == (1) ? Prelude_Nothing() : Data_SortedMap_lookupMap$27(_$$0, sc$$5.h1.h2) ); break; } } };
let Prelude_eqString = (a,b) => a == b;
let Lib_Eval_evalCase_pushArgs = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$13, _$$14, _$$15 ) => { while (1) { let _12 = _; let _13 = _1; let _14 = _2; let _15 = _3; let _16 = _4; let _17 = _5; let _18 = _6; let _19 = _7; let _20 = _8; let _21 = _9; let _22 = _10; let _23 = _11; let _$$131 = _$$13; let _$$141 = _$$14; let _$$151 = _$$15; if ((_$$151.tag) == (1)) { if ((_$$141.tag) == (1)) { _ = _12; _1 = _13; _2 = _14; _3 = _15; _4 = _16; _5 = _17; _6 = _18; _7 = _19; _8 = _20; _9 = _21; _10 = _22; _11 = _23; _$$13 = { tag: 1,  h1: _$$141.h1,  h2: _$$131 }; _$$14 = _$$141.h2; _$$15 = _$$151.h2; continue; } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); } } else { return ( (_$$141.tag) == (0) ? Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Just(eta)), Lib_Eval_eval(_$$131, _20)) : Prelude_fatalError(null, (("Extra args ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$141))) + ("")) ); } } };
let Prelude_fatalError = (_, msg) => { throw new Error(msg) };
let Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_ = ( _$$0, _$$1 ) => { let sc$$6 = Prelude_eqString(_$$0.h1, _$$1.h1); switch (sc$$6) { case true: return Prelude_eqString(_$$0.h0, _$$1.h0); case false: return false; } };
let Lib_Eval_forceType = ( _$$0, _$$1 ) => (( (_$$1.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$1.h1), ( meta ) => (( (meta.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(meta.h2, _$$1.h2), ( eta ) => (Lib_Eval_forceType(_$$0, eta))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VMeta(_$$1.h0, _$$1.h1, _$$1.h2)) ))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_tryEval(_$$0, _$$1), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Eval_forceType(_$$0, $$sc.h1) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$1) ))) ));
let Lib_Eval_tryEval = ( _$$0, _$$1 ) => (( (_$$1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$6 = Lib_TopContext_lookup(_$$1.h1, top); return ( (sc$$6.tag) == (0) ? ( (sc$$6.h1.h3.tag) == (3) ? Lib_Types_catchError(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("app ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$6.h1.h1))) + (" to ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$1.h2, { tag: 0 })))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, sc$$6.h1.h3.h0), ( vtm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("tm is ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$6.h1.h3.h0))), { tag: 0 }))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(vtm, _$$1.h2), ( val ) => { switch (val.tag) { case 7: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(val)); } }))))))), ( _$$3 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("tryEval blocked on undefined ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h1))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))) ) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("tryEval blocked on undefined ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h1))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))) ); }) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()) ));
let Lib_Eval_vappSpine = ( _$$0, _$$1 ) => (( (_$$1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(_$$0, _$$1.h1), ( rest ) => (Lib_Eval_vapp(rest, _$$1.h2))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0) ));
let Lib_Types_catchError = ( _$$1, _$$2 ) => (Lib_Types_MkM(( tc ) => (( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(_$$1.h1(tc), ( $$sc ) => (( ($$sc.tag) == (1) ? ( eta ) => (Prelude_MkIORes(Prelude_Right({ tag: 0,  h2: $$sc.h2.h2,  h3: $$sc.h2.h3 }), eta)) : Lib_Types__runM(_$$2($$sc.h2))(tc) )), eta)))));
let Lib_Types_VLet = ( h0, h1, h2, h3 ) => ({ tag: 6,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Types_VLit = ( h0, h1 ) => ({ tag: 10,  h0: h0,  h1: h1 });
let Lib_Types_VErased = ( h0 ) => ({ tag: 9,  h0: h0 });
let Lib_Types_CaseCons = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Prelude_length$27 = ( _$$1 ) => (Prelude_length$27_go(_$$1, _$$1, 0));
let Prelude_length$27_go = ( _, _$$4, _$$5 ) => { while (1) { let _1 = _; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$41.tag) == (1)) { _ = _1; _$$4 = _$$41.h2; _$$5 = (_$$51) + (1); continue; } else { return _$$51; } } };
let Lib_Eval_normAlt_mkenv = ( _, _1, _2, _3, _4, _5, _$$7, _$$8, _$$9 ) => { while (1) { let _6 = _; let _7 = _1; let _8 = _2; let _9 = _3; let _10 = _4; let _11 = _5; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; if ((_$$91.tag) == (1)) { _ = _6; _1 = _7; _2 = _8; _3 = _9; _4 = _10; _5 = _11; _$$7 = (_$$71) + (1); _$$8 = { tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, _$$71, { tag: 0 }),  h2: _$$81 }; _$$9 = _$$91.h2; continue; } else { return _$$81; } } };
let Lib_Types_CaseLit = ( h0, h1 ) => ({ tag: 2,  h0: h0,  h1: h1 });
let Lib_Types_Meta = ( h0, h1 ) => ({ tag: 2,  h0: h0,  h1: h1 });
let Lib_Types_Lam = ( h0, h1, h2, h3, h4 ) => ({ tag: 3,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Types_Pi = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: 6,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_Types_Let = ( h0, h1, h2, h3 ) => ({ tag: 8,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Types_LetRec = ( h0, h1, h2, h3, h4 ) => ({ tag: 9,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Types_UU = ( h0 ) => ({ tag: 5,  h0: h0 });
let Lib_Types_Lit = ( h0, h1 ) => ({ tag: 10,  h0: h0,  h1: h1 });
let Lib_Elab_unify = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("Unify lvl ") + (Prelude_showInt(Prelude_natToInt(Prelude_length(_$$0))))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("  ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$2))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((("  =?= ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta(_$$2), ( eta ) => (Lib_Eval_unlet(_$$0, eta))), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta(_$$3), ( eta ) => (Lib_Eval_unlet(_$$0, eta))), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("forced ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(t$27))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((("  =?= ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(u$27))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("env ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$0))) + (""))), ( _5 ) => { let l = Prelude_length$27(_$$0); switch (_$$1) { case true: return Lib_Elab_unify_unifyPattern(_$$0, _$$1, _$$2, _$$3, t$27, u$27); case false: return Lib_Elab_unify_unifyMeta(_$$0, _$$1, _$$2, _$$3, t$27, u$27); } }))))))))))))))));
let Lib_Elab_unify_unifyMeta = ( _, _1, _2, _3, _$$9, _$$10 ) => { if ((_$$10.tag) == (3)) { if ((_$$9.tag) == (3)) { let sc$$17 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$9.h1, _$$10.h1); switch (sc$$17) { case true: return Lib_Elab_unifySpine(_, _1, Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$9.h1, _$$10.h1), _$$9.h2, _$$10.h2); case false: { let sc$$18 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prelude_Nat$2Ccompare(Data_SnocList_snoclen(_$$9.h2), Data_SnocList_snoclen(_$$10.h2)), 0); switch (sc$$18) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solve(_, _$$10.h1, _$$10.h2, Lib_Types_VMeta(_$$9.h0, _$$9.h1, _$$9.h2)), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solve(_, _$$9.h1, _$$9.h2, Lib_Types_VMeta(_$$10.h0, _$$10.h1, _$$10.h2)), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral))); } break; } } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solve(_, _$$10.h1, _$$10.h2, _$$9), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral))); } } else { return ( (_$$9.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solve(_, _$$9.h1, _$$9.h2, _$$10), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral))) : Lib_Elab_unify_unifyLam(_, _1, _2, _3, _$$9, _$$10) ); } };
let Lib_Elab_unify_unifyLam = ( _, _1, _2, _3, _$$8, _$$9 ) => { if ((_$$9.tag) == (4)) { if ((_$$8.tag) == (4)) { let fresh = Lib_Types_VVar(_$$8.h0, Prelude_length$27(_), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: fresh,  h2: _$$8.h4.h0 }, _$$8.h4.h1), ( vappt ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: fresh,  h2: _$$9.h4.h0 }, _$$9.h4.h1), ( vappt$27 ) => (Lib_Elab_unify({ tag: 1,  h1: fresh,  h2: _ }, _1, vappt, vappt$27))))); } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((("ETA ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$8))) + (""))), ( _4 ) => { let fresh = Lib_Types_VVar(_$$9.h0, Prelude_length$27(_), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vapp(_$$8, fresh), ( vappt ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: fresh,  h2: _$$9.h4.h0 }, _$$9.h4.h1), ( vappt$27 ) => (Lib_Elab_unify({ tag: 1,  h1: fresh,  h2: _ }, _1, vappt, vappt$27))))); }); } } else { return ( (_$$8.tag) == (4) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((("ETA' ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$9))) + (""))), ( _4 ) => { let fresh = Lib_Types_VVar(_$$8.h0, Prelude_length$27(_), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: fresh,  h2: _$$8.h4.h0 }, _$$8.h4.h1), ( appt ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vapp(_$$9, fresh), ( vappt$27 ) => (Lib_Elab_unify({ tag: 1,  h1: fresh,  h2: _ }, _1, appt, vappt$27))))); }) : Lib_Elab_unify_unifyVar(_, _1, _2, _3, _$$8, _$$9) ); } };
let Lib_Elab_unify_unifyVar = ( _, _1, _2, _3, _$$7, _$$8 ) => { if ((_$$8.tag) == (0)) { if ((_$$7.tag) == (0)) { let sc$$15 = Prelude_eqInt(_$$7.h1, _$$8.h1); switch (sc$$15) { case true: return Lib_Elab_unifySpine(_, _1, Prelude_eqInt(_$$7.h1, _$$8.h1), _$$7.h2, _$$8.h2); case false: return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$7.h0, (((("Failed to unify ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (" and ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$8))) + (""))), eta)))); } } else { return ( (_$$8.h2.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_tryEval(_, _$$7), ( vt ) => (( (vt.tag) == (1) ? Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$8.h0, (((("Failed to unify ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (" and ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$8))) + (""))), eta)))) : Lib_Elab_unify(_, _1, vt.h1, _$$8) ))) : Lib_Elab_unify_unifyRef(_, _1, _2, _3, _$$7, _$$8) ); } } else { return ( (_$$7.tag) == (0) ? ( (_$$7.h2.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_tryEval(_, _$$8), ( vu ) => (( (vu.tag) == (1) ? Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$7.h0, (((("Failed to unify ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (" and ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$8))) + (""))), eta)))) : Lib_Elab_unify(_, _1, _$$7, vu.h1) ))) : Lib_Elab_unify_unifyRef(_, _1, _2, _3, _$$7, _$$8) ) : Lib_Elab_unify_unifyRef(_, _1, _2, _3, _$$7, _$$8) ); } };
let Lib_Elab_unify_unifyRef = ( _, _1, _2, _3, _$$6, _$$7 ) => (( (_$$7.tag) == (1) ? ( (_$$6.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_tryEval(_, _$$6), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_tryEval(_, _$$7), ( $$sc1 ) => { if (($$sc1.tag) == (1)) { let sc$$20 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$6.h1, _$$7.h1); switch (sc$$20) { case true: return Lib_Elab_unifySpine(_, _1, Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$6.h1, _$$7.h1), _$$6.h2, _$$7.h2); case false: return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$6.h0, (((("vref mismatch ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (""))), eta)))); } } else { return Lib_Elab_unify(_, _1, _$$6, $$sc1.h1); } }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((("tryEval ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" to ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc.h1))) + (""))), ( _4 ) => (Lib_Elab_unify(_, _1, $$sc.h1, _$$7))) ))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((("expand ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" =?= %ref ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$7.h1))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$13 = Lib_TopContext_lookup(_$$7.h1, top); return ( (sc$$13.tag) == (0) ? ( (sc$$13.h1.h3.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$13.h1.h3.h0), ( vtm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(vtm, _$$7.h2), ( appvtm ) => (Lib_Elab_unify(_, _1, _$$6, appvtm))))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$7.h0, (((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (" [no Fn]"))), eta)))) ) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$7.h0, (((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (" [no Fn]"))), eta)))) ); }))) ) : ( (_$$6.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((((("expand %ref ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$6.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$6.h2, { tag: 0 })))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$13 = Lib_TopContext_lookup(_$$6.h1, top); return ( (sc$$13.tag) == (0) ? ( (sc$$13.h1.h3.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$13.h1.h3.h0), ( vtm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(vtm, _$$6.h2), ( tmsp ) => (Lib_Elab_unify(_, _1, tmsp, _$$7))))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$6.h0, (((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" [no Fn] =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (""))), eta)))) ) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$6.h0, (((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" [no Fn] =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$7))) + (""))), eta)))) ); }))) : Lib_Elab_unify_unifyRest(_, _1, _2, _3, _$$6, _$$7) ) ));
let Lib_Elab_unify_unifyRest = ( _, _1, _2, _3, _$$5, _$$6 ) => { switch (_$$6.tag) { case 10: { if ((_$$5.tag) == (10)) { let sc$$11 = Lib_Types_Prelude_Eq$20Lib_Types_Literal$2C_$3D$3D_(_$$5.h1, _$$6.h1); switch (sc$$11) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral); case false: return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$5.h0, (((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$5.h1))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$6.h1))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$5), (((((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$5))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" \n  env is ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _))) + (""))), eta)))); } break; } case 8: return ( (_$$5.tag) == (8) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral) : Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$5), (((((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$5))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" \n  env is ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _))) + (""))), eta)))) ); case 5: { if ((_$$5.tag) == (5)) { let fresh = Lib_Types_VVar(_$$5.h0, Prelude_length$27(_), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: fresh,  h2: _$$5.h5.h0 }, _$$5.h5.h1), ( xb ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: fresh,  h2: _$$6.h5.h0 }, _$$6.h5.h1), ( xb$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (( eta1 ) => (Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult$2C_$3C$2B$3E_(eta, eta1))), Lib_Elab_unify(_, _1, _$$5.h4, _$$6.h4)), Lib_Elab_unify({ tag: 1,  h1: fresh,  h2: _ }, _1, xb, xb$27)))))); } else { return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$5), (((((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$5))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" \n  env is ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _))) + (""))), eta)))); } break; } default: return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$5), (((((("unify failed ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$5))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$6))) + (" \n  env is ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _))) + (""))), eta)))); } };
let Lib_Types_getValFC = ( _$$0 ) => { switch (_$$0.tag) { case 10: return _$$0.h0; case 9: return _$$0.h0; case 8: return _$$0.h0; case 7: return _$$0.h0; case 6: return _$$0.h0; case 5: return _$$0.h0; case 4: return _$$0.h0; case 3: return _$$0.h0; case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult$2C_$3C$2B$3E_ = ( _$$0, _$$1 ) => (Lib_Elab_MkResult(Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$0.h0, _$$1.h0)));
let Lib_Elab_MkResult = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral = Lib_Elab_MkResult({ tag: 0 });
let Lib_Types_Prelude_Eq$20Lib_Types_Literal$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 2: return ( (_$$0.tag) == (2) ? Prelude_eqChar(_$$0.h0, _$$1.h0) : false ); case 1: return ( (_$$0.tag) == (1) ? Prelude_eqInt(_$$0.h0, _$$1.h0) : false ); case 0: return ( (_$$0.tag) == (0) ? Prelude_eqString(_$$0.h0, _$$1.h0) : false ); default: return false; } };
let Lib_Elab_unifySpine = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { switch (_$$2) { case true: return ( (_$$3.tag) == (1) ? ( (_$$4.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (( eta1 ) => (Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult$2C_$3C$2B$3E_(eta, eta1))), Lib_Elab_unify(_$$0, _$$1, _$$3.h2, _$$4.h2)), Lib_Elab_unifySpine(_$$0, _$$1, true, _$$3.h1, _$$4.h1)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "meta spine length mismatch")), eta)))) ) : ( (_$$4.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 0 })) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "meta spine length mismatch")), eta)))) ) ); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "unify failed at head")), eta)))); } };
let Lib_Elab_solve = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$1), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((((((("SOLVE ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow($$sc.h4))) + (" lvl ")) + (Prelude_showInt(Prelude_length$27(_$$0)))) + (" sp ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$2, { tag: 0 })))) + (" is ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _ ) => { let size = Prelude_length(Prelude_filter(( x ) => (Lib_Types_Prelude_Eq$20Lib_Types_BD$2C_$3D$3D_(x, false)), $$sc.h2.h3)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((((((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (" size is ")) + (Prelude_showInt(Prelude_natToInt(size)))) + (" sps ")) + (Prelude_showInt(Prelude_natToInt(Data_SnocList_snoclen(_$$2))))) + (""))), ( _1 ) => { let sc$$15 = Prelude_Prelude_Eq$20Prelude_Nat$2C_$3D$3D_(Data_SnocList_snoclen(_$$2), size); switch (sc$$15) { case true: { let l = Prelude_length$27(_$$0); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((("meta ") + (Lib_Types_Prelude_Show$20Lib_Types_MetaEntry$2Cshow($$sc))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_tryError(Lib_Elab_invert(l, _$$2)), ( $$sc1 ) => (( ($$sc1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(l, _$$3), ( hack ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0, hack), ( t ) => (Lib_Types_catchError(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_rename(_$$1, $$sc1.h2, l, t), ( tm ) => { let tm1 = Lib_Elab_lams(Data_SnocList_snoclen(_$$2), Prelude_reverse()(Lib_Elab__boundNames($$sc.h2)), tm); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, tm1), ( soln ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_updateMeta(_$$1, ( $$case ) => { switch ($$case.tag) { case 2: return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h1))) + (" out of scope"))), eta)))); case 1: return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E($$case.h0, (("Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h1))) + (" already solved! [solve2]"))), eta)))); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Solved($$case.h0, $$case.h1, soln)); } }), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_maybeCheck(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, $$sc.h5, ( $$case ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(soln, $$case.h2), ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((((("discharge l=") + (Prelude_showInt(Prelude_length$27($$case.h1)))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(val))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$case.h3))) + (""))), ( _4 ) => (Lib_Elab_unify($$case.h1, false, val, $$case.h3))))))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top1 ) => { switch (top1.h2.h3.h3) { case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((((("check autos depending on ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h1))) + (" ")) + (Prelude_debugStr(null, top1.h2.h3.h3))) + (""))), ( _5 ) => (Lib_Elab_checkAutos($$sc.h1, top1.h2.h3.h1))); default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } })))), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0))))))))); }), ( $$case ) => (( ($$case.tag) == (2) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((((("CONSTRAINT2 ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$case.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$2, { tag: 0 })))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(t))) + (""))), ( _3 ) => (Lib_Elab_addConstraint(_$$0, _$$1, _$$2, t))) : Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Error_Lib_Common_HasFC$20Lib_Error_Error$2CgetFC($$case), (((((((("") + (Lib_Error_errorMsg($$case))) + (" for ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$2, { tag: 0 })))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(t))) + (""))), eta)))) ))))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("postpone constraint ") + (Lib_Error_showError("", $$sc1.h2))) + (""))), ( _3 ) => (Lib_Elab_addConstraint(_$$0, _$$1, _$$2, _$$3))) ))))); break; } default: { let l = Prelude_length$27(_$$0); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((((((("meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (" (")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h1))) + (") applied to ")) + (Prelude_showInt(Prelude_natToInt(Data_SnocList_snoclen(_$$2))))) + (" args instead of ")) + (Prelude_showInt(Prelude_natToInt(size)))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((((("CONSTRAINT ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$2, { tag: 0 })))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _3 ) => (Lib_Elab_addConstraint(_$$0, _$$1, _$$2, _$$3))))); break; } } }); }) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$3), (("Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (" already solved! [solve]"))), eta)))) ))));
let Lib_Elab_addConstraint = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { switch (top.h2.h3.h3) { case 0: return Lib_Elab_updateMeta(_$$1, ( $$case ) => { switch ($$case.tag) { case 2: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (" out of scope"))), eta)))); case 1: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E($$case.h0, (("Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$case.h1))) + (" already solved [addConstraint]"))), eta)))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("Add constraint ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$2, { tag: 0 })))) + (" =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Unsolved($$case.h0, $$case.h1, $$case.h2, $$case.h3, $$case.h4, { tag: 1,  h1: Lib_Types_MkMc(Lib_Types_getValFC(_$$3), _$$0, _$$2, _$$3),  h2: $$case.h5 })))); } }); default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } }));
let Lib_Types_MkMc = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Types_Unsolved = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_Elab_updateMeta = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$4 = Data_SortedMap_lookupMap$27(_$$0, top.h2.h3.h0); return ( (sc$$4.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(_$$1(sc$$4.h1), ( me ) => { let autos = ( (me.tag) == (1) ? Prelude_filter(( _$$3 ) => (Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$0, _$$3))), top.h2.h3.h1) : top.h2.h3.h1 ); return Lib_Elab_setMetaContext(Lib_Types_MC(Data_SortedMap_updateMap(_$$0, me, top.h2.h3.h0), autos, top.h2.h3.h2, top.h2.h3.h3)); }) ); }));
let Lib_Types_MC = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Elab_setMetaContext = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, tc.h2.h2, _$$0, tc.h2.h4, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))));
let Prelude_filter = ( _$$1, _$$2 ) => (Prelude_filter_go(_$$1, _$$2, _$$2, { tag: 0 }));
let Prelude_filter_go = ( _, _1, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$41.tag) == (1)) { let sc$$9 = _2(_$$41.h1); switch (sc$$9) { case true: { _ = _2; _1 = _3; _$$4 = _$$41.h2; _$$5 = { tag: 1,  h1: _$$51,  h2: _$$41.h1 }; continue; break; } case false: { _ = _2; _1 = _3; _$$4 = _$$41.h2; _$$5 = _$$51; continue; break; } } } else { return Prelude__$3C$3E$3E_(_$$51, { tag: 0 }); } } };
let Lib_Elab_checkAutos = ( _$$0, _$$1 ) => (( (_$$1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$1.h1), ( $$sc ) => { if (($$sc.tag) == (0)) { switch ($$sc.h4) { case 2: { if (($$sc.h3.tag) == (1)) { let sc$$18 = Lib_Elab_checkAutos_checkMeta(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, $$sc.h3.h2); switch (sc$$18) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_trySolveAuto($$sc), ( _ ) => (Lib_Elab_checkAutos(_$$0, _$$1.h2))), ( _ ) => (Lib_Elab_checkAutos(_$$0, _$$1.h2))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0), ( _ ) => (Lib_Elab_checkAutos(_$$0, _$$1.h2))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0), ( _ ) => (Lib_Elab_checkAutos(_$$0, _$$1.h2))); } break; } default: return Lib_Elab_checkAutos(_$$0, _$$1.h2); } } else { return Lib_Elab_checkAutos(_$$0, _$$1.h2); } }) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ));
let Lib_Elab_trySolveAuto = ( _$$0 ) => { if ((_$$0.tag) == (0)) { switch (_$$0.h4) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("TRYAUTO solving ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h3))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$0.h2.h0, _$$0.h3), ( x ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h2.h1, x), ( ty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("AUTO ---> ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_contextMatches(_$$0.h2, ty), ( $$sc ) => { if (($$sc.tag) == (1)) { return ( ($$sc.h2.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h2.h1, $$sc.h1.h2), ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("LOCAL SOLUTION ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, $$sc.h1.h2))), { tag: 0 }))) + (" evaled to ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(val))) + (""))), ( _2 ) => { let sp = Lib_Elab_makeSpine(_$$0.h2.h0, _$$0.h2.h3); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solve(_$$0.h2.h1, _$$0.h1, sp, val), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ("<-- AUTO LOCAL")), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => (((">UNIFY ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(Lib_Types_getValFC(ty), _$$0.h2, ty, $$sc.h1.h3), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _7 ) => ((("<UNIFY ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (""))), ( _7 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(true))))))))))); }))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("LOCAL FAILED to solve ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty))) + (", matches: ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier_Seq(Lib_Prettier_Seq(a, Lib_Prettier_Text(",")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), b)))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$5 ) => (Lib_Types_pprint$27(0, { tag: 0 }, _$$5.h2)), $$sc)))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false))) ); } else { if ((ty.tag) == (1)) { let cands = Prelude_fromMaybe({ tag: 0 }, Data_SortedMap_lookupMap$27(ty.h1, top.h1)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_findMatches(_$$0.h2, ty, cands), ( $$sc1 ) => (( ($$sc1.tag) == (1) ? ( ($$sc1.h2.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0.h2, Lib_Syntax_RVar(_$$0.h0, $$sc1.h1.h1), ty), ( tm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h2.h1, tm), ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("SOLUTION ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, tm))), { tag: 0 }))) + (" evaled to ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(val))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("GLOBAL SOLUTION ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(val))) + (""))), ( _3 ) => { let sp = Lib_Elab_makeSpine(_$$0.h2.h0, _$$0.h2.h3); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$0.h1), ( $$sc2 ) => (( ($$sc2.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solve(_$$0.h2.h1, _$$0.h1, sp, val), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(true))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(true) ))); }))))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("GLOBAL FAILED to solve ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty))) + (", matches: ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, $$sc1))) + (""))), ( _2 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false))) ) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("GLOBAL FAILED to solve ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty))) + (", matches: ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, $$sc1))) + (""))), ( _2 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false))) ))); } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false); } } }))))))))))); default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false); } };
let Lib_Common_Prelude_Show$20Lib_Common_QName = Prelude_MkShow(( eta ) => (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(eta)));
let Lib_Elab_makeSpine = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$11.tag) == (1)) { switch (_$$11.h1) { case true: { _$$0 = (_$$01) - (1); _$$1 = _$$11.h2; continue; break; } case false: return { tag: 1,  h1: Lib_Elab_makeSpine((_$$01) - (1), _$$11.h2),  h2: Lib_Types_VVar(Lib_Common_emptyFC, (_$$01) - (1), { tag: 0 }) }; } } else { return { tag: 0 }; } } };
let Lib_Syntax_RVar = ( h0, h1 ) => ({ tag: 0,  h0: h0,  h1: h1 });
let Lib_Elab_findMatches = ( _$$0, _$$1, _$$2 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let sc$$10 = Lib_Elab_isCandidate(_$$11, _$$21.h1.h3); switch (sc$$10) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let fc = Lib_Types_getValFC(_$$11); return Lib_Types_catchError(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("TRY ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$21.h1.h2))) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, _$$21.h1.h3))), { tag: 0 }))) + (" for ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$11))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaMode(1), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$01, Lib_Syntax_RVar(fc, _$$21.h1.h2.h1), _$$11), ( tm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("Found ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, tm))), { tag: 0 }))) + (" for ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$11))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaContext(top.h2.h3), ( _3 ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$3A$3A_(_$$21.h1.h2, eta)), Lib_Elab_findMatches(_$$01, _$$11, _$$21.h2)))))))))))), ( err ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("No match ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$11))) + (" ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, _$$21.h1.h3))), { tag: 0 }))) + (" ")) + (Lib_Error_showError("", err))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaContext(top.h2.h3), ( _1 ) => (Lib_Elab_findMatches(_$$01, _$$11, _$$21.h2))))))); }); case false: { _$$0 = _$$01; _$$1 = _$$11; _$$2 = _$$21.h2; continue; break; } } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }); } } };
let Lib_Elab_setMetaMode = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, tc.h2.h2, Lib_Types_MC(tc.h2.h3.h0, tc.h2.h3.h1, tc.h2.h3.h2, _$$0), tc.h2.h4, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))));
let Lib_Elab_isCandidate = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; switch (_$$11.tag) { case 6: switch (_$$11.h2) { case 1: return false; default: { _$$0 = _$$01; _$$1 = _$$11.h5; continue; break; } } break; case 4: { _$$0 = _$$01; _$$1 = _$$11.h1; continue; break; } case 1: return ( (_$$01.tag) == (1) ? Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$01.h1, _$$11.h1) : false ); default: return false; } } };
let Lib_Elab_contextMatches = ( _$$0, _$$1 ) => (Lib_Elab_contextMatches_go(_$$0, _$$1, Prelude_zip(_$$0.h1, _$$0.h2)));
let Prelude_zip = ( _$$2, _$$3 ) => (( (_$$3.tag) == (1) ? ( (_$$2.tag) == (1) ? { tag: 1,  h1: { tag: 0,  h2: _$$2.h1,  h3: _$$3.h1 },  h2: Prelude_zip(_$$2.h2, _$$3.h2) } : { tag: 0 } ) : { tag: 0 } ));
let Lib_Elab_contextMatches_go = ( _, _1, _$$3 ) => (( (_$$3.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_.h0, _$$3.h1.h3.h3), ( type ) => { let sc$$16 = Lib_Elab_isCandidate(_1, type); switch (sc$$16) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_catchError(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((((("TRY context ") + (_$$3.h1.h3.h2)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _.h2), type))), { tag: 0 }))) + (" for ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_1))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(Lib_Types_getValFC(_1), _, _1, _$$3.h1.h3.h3), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaContext(top.h2.h3), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_.h0, _$$3.h1.h2), ( tm ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$3A$3A_({ tag: 0,  h2: tm,  h3: _$$3.h1.h3.h3 }, eta)), Lib_Elab_contextMatches_go(_, _1, _$$3.h2)))))))))), ( err ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((((("No match ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_1))) + (" ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _.h2), type))), { tag: 0 }))) + (" ")) + (Lib_Error_showError("", err))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaContext(top.h2.h3), ( _3 ) => (Lib_Elab_contextMatches_go(_, _1, _$$3.h2))))))))); case false: return Lib_Elab_contextMatches_go(_, _1, _$$3.h2); } }) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }) ));
let Lib_Elab_checkAutos_checkMeta = ( _, _1, _2, _3, _4, _$$6 ) => { while (1) { let _5 = _; let _6 = _1; let _7 = _2; let _8 = _3; let _9 = _4; let _$$61 = _$$6; if ((_$$61.tag) == (1)) { if ((_$$61.h2.tag) == (3)) { let sc$$13 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$61.h2.h1, _5); switch (sc$$13) { case true: return true; case false: { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$6 = _$$61.h1; continue; break; } } } else { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$6 = _$$61.h1; continue; } } else { return false; } } };
let Prelude_debugStr = (_, obj) => {
 return JSON.stringify(obj)
};
let Prelude_for_ = ( _$$2, appf$$3, _$$6, _$$7 ) => (Prelude__$3C$2A$3E_(appf$$3)(null)(null)(Prelude_return(appf$$3)(null)(( _$$3 ) => (0)))(Prelude_traverse(_$$2)(null)(null)(null)(appf$$3)(_$$7)(_$$6)));
let Lib_Elab_maybeCheck = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { switch (top.h2.h3.h3) { case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaMode(2), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(_$$0, ( _1 ) => (Lib_Elab_setMetaMode(1))))); case 0: return _$$0; } }));
let Lib_Types_Solved = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Elab__boundNames = ( _$$0 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), Prelude_filter(( x ) => (Lib_Types_Prelude_Eq$20Lib_Types_BD$2C_$3D$3D_(x.h2, false)), Prelude_zip(_$$0.h3, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0.h2)))));
let Lib_Types_Prelude_Eq$20Lib_Types_BD$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1) { case true: switch (_$$0) { case true: return true; default: return false; } break; case false: switch (_$$0) { case false: return true; default: return false; } break; } };
let Lib_Elab_lams = ( _$$0, _$$1, _$$2 ) => { switch (_$$0) { case 0: return _$$2; default: { let x = (_$$0) - (1); return ( (_$$1.tag) == (1) ? Lib_Types_Lam(Lib_Common_emptyFC, _$$1.h1, 1, true, Lib_Elab_lams(x, _$$1.h2, _$$2)) : Lib_Types_Lam(Lib_Common_emptyFC, (("arg_") + (Prelude_showInt(Prelude_natToInt(x)))) + (""), 1, true, Lib_Elab_lams(x, { tag: 0 }, _$$2)) ); break; } } };
let Lib_Elab_rename = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case 10: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lit(_$$3.h0, _$$3.h1)); case 9: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Erased(_$$3.h0)); case 8: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_UU(_$$3.h0)); case 5: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_rename(_$$0, _$$1, _$$2, _$$3.h4), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, _$$2, { tag: 0 }),  h2: _$$3.h5.h0 }, _$$3.h5.h1), ( tmapp ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_rename(_$$0, { tag: 1,  h1: _$$2,  h2: _$$1 }, (1) + (_$$2), tmapp), ( scope$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Pi(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, ty$27, scope$27)))))))); case 4: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(_$$3.h0, _$$2, { tag: 0 }),  h2: _$$3.h4.h0 }, _$$3.h4.h1), ( tapp ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_rename(_$$0, { tag: 1,  h1: _$$2,  h2: _$$1 }, (1) + (_$$2), tapp), ( scope ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lam(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, scope)))))); case 3: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("rename Meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h1))) + (" spine ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_$$3.h2, { tag: 0 })))) + (""))), ( _ ) => { let sc$$8 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$3.h1, _$$0); switch (sc$$8) { case true: return Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$3.h0, "meta occurs check")), eta)))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$3.h1), ( meta$27 ) => (( (meta$27.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("rename: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h1))) + (" is solved"))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(meta$27.h2, _$$3.h2), ( val$27 ) => (Lib_Elab_rename(_$$0, _$$1, _$$2, val$27))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("rename: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h1))) + (" is unsolved"))), ( _1 ) => (Lib_Types_catchError(Lib_Elab_renameSpine(_$$0, _$$1, _$$2, Lib_Types_Meta(_$$3.h0, _$$3.h1), _$$3.h2), ( err ) => (Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_Postpone(_$$3.h0, _$$3.h1, Lib_Error_errorMsg(err))), eta)))))))) ))); } }); case 1: return Lib_Elab_renameSpine(_$$0, _$$1, _$$2, Lib_Types_Ref(_$$3.h0, _$$3.h1), _$$3.h2); case 0: { let sc$$7 = Prelude_findIndex$27(( _$$11 ) => (Prelude_eqInt(_$$3.h1, _$$11)), _$$1); return ( (sc$$7.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$3.h0, (((("scope/skolem thinger VVar ") + (Prelude_showInt(_$$3.h1))) + (" ren ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, _$$1))) + (""))), eta)))) : Lib_Elab_renameSpine(_$$0, _$$1, _$$2, Lib_Types_Bnd(_$$3.h0, sc$$7.h1), _$$3.h2) ); break; } default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$3), (("Unhandled term in `rename`: ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), eta)))); } };
let Lib_Elab_renameSpine = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (( (_$$4.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_rename(_$$0, _$$1, _$$2, _$$4.h2), ( xtm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_renameSpine(_$$0, _$$1, _$$2, _$$3, _$$4.h1), ( xs$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_App(Lib_Common_emptyFC, xs$27, xtm)))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$3) ));
let Prelude_findIndex$27 = ( _$$1, _$$2 ) => (Prelude_findIndex$27_go(_$$1, _$$2, _$$2, 0));
let Prelude_findIndex$27_go = ( _, _1, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$41.tag) == (1)) { let sc$$9 = _2(_$$41.h1); switch (sc$$9) { case true: return Prelude_Just(_$$51); case false: { _ = _2; _1 = _3; _$$4 = _$$41.h2; _$$5 = (_$$51) + (1); continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_Error_Postpone = ( h0, h1, h2 ) => ({ tag: 2,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Elab_invert = ( _$$0, _$$1 ) => (Lib_Elab_invert_go(_$$0, _$$1, _$$1, { tag: 0 }));
let Lib_Elab_invert_go = ( _, _1, _$$3, _$$4 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$31.tag) == (1)) { if ((_$$31.h2.tag) == (0)) { if ((_$$31.h2.h2.tag) == (0)) { let sc$$12 = Prelude_elem(Prelude_Prelude_Eq$20Prim_Int, _$$31.h2.h1, _$$41); switch (sc$$12) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((("") + (Prelude_showInt(_$$31.h2.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, _$$41))) + (""))), ( _4 ) => (Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$31.h2.h0, (("non-linear pattern: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Prelude__$3C$3E$3E_(_3, { tag: 0 })))) + (""))), eta)))))); case false: { _ = _2; _1 = _3; _$$3 = _$$31.h1; _$$4 = { tag: 1,  h1: _$$31.h2.h1,  h2: _$$41 }; continue; break; } } } else { return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$31.h2), (("non-variable in pattern ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$31.h2))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$31.h2), (("non-variable in pattern ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$31.h2))) + (""))), eta)))); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_reverse()(_$$41)); } } };
let Prelude_Prelude_Eq$20Prim_Int$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude_eqInt(_$$0, _$$1));
let Prelude_MkEq = ( h1 ) => ({ tag: 0,  h1: h1 });
let Prelude_Prelude_Eq$20Prim_Int = Prelude_MkEq(( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prim_Int$2C_$3D$3D_(eta, eta1))));
let Prelude_elem = ( _$$1, _$$2, _$$3 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { let sc$$7 = Prelude__$3D$3D_(_$$11)(_$$21)(_$$31.h1); switch (sc$$7) { case true: return true; case false: { _$$1 = _$$11; _$$2 = _$$21; _$$3 = _$$31.h2; continue; break; } } } else { return false; } } };
let Prelude__$3D$3D_ = ( _$$1 ) => (_$$1.h1);
let Lib_Types_tryError = ( _$$1 ) => (Lib_Types_catchError(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Right(eta)), _$$1), ( _$$5 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Left(_$$5)))));
let Lib_Types_Prelude_Show$20Lib_Types_MetaEntry$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 2: return "OutOfScope"; case 1: return (((("Solved ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h2))) + (""); case 0: return (((((((((((("Unsolved ") + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0))) + (" ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow(_$$0.h4))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$0.h3))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_BD, _$$0.h2.h3))) + (" cs ")) + (Prelude_showInt(Prelude_natToInt(Prelude_length(_$$0.h5))))) + (""); } };
let Lib_Types_Prelude_Show$20Lib_Types_BD$2Cshow = ( _$$0 ) => { switch (_$$0) { case true: return "Defined"; case false: return "Bound"; } };
let Lib_Types_Prelude_Show$20Lib_Types_BD = Prelude_MkShow(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_BD$2Cshow(eta)));
let Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow = ( _$$0 ) => { switch (_$$0) { case 3: return "ErrorHole"; case 2: return "AutoSolve"; case 1: return "User"; case 0: return "Normal"; } };
let Prelude_Prelude_Eq$20Prelude_Nat$2C_$3D$3D_ = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; switch (_$$11) { case 0: switch (_$$01) { case 0: return true; default: return false; } break; default: { let x = (_$$11) - (1); switch (_$$01) { case 0: return false; default: { let x1 = (_$$01) - (1); _$$0 = x1; _$$1 = x; continue; break; } } break; } } } };
let Prelude_Prelude_Ord$20Prelude_Nat$2Ccompare = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; switch (_$$11) { case 0: switch (_$$01) { case 0: return 1; default: return 2; } break; default: { let x = (_$$11) - (1); switch (_$$01) { case 0: return 0; default: { let x1 = (_$$01) - (1); _$$0 = x1; _$$1 = x; continue; break; } } break; } } } };
let Lib_Elab_unify_unifyPattern = ( _, _1, _2, _3, _$$10, _$$11 ) => { if ((_$$11.tag) == (0)) { if ((_$$10.tag) == (0)) { let sc$$18 = Prelude_eqInt(_$$10.h1, _$$11.h1); switch (sc$$18) { case true: return Lib_Elab_unifySpine(_, _1, Prelude_eqInt(_$$10.h1, _$$11.h1), _$$10.h2, _$$11.h2); case false: { let sc$$19 = { tag: 0,  h2: _$$10.h2,  h3: _$$11.h2 }; if ((sc$$19.h2.tag) == (0)) { if ((sc$$19.h3.tag) == (0)) { let sc$$26 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$10.h1, _$$11.h1), 0); switch (sc$$26) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 1,  h1: { tag: 0,  h2: _$$10.h1,  h3: _$$11 },  h2: { tag: 0 } })); case false: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: _$$10 },  h2: { tag: 0 } })); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 1,  h1: { tag: 0,  h2: _$$10.h1,  h3: _$$11 },  h2: { tag: 0 } })); } } else { return ( (sc$$19.h3.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: _$$10 },  h2: { tag: 0 } })) : Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (((((("Failed to unify ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$10))) + (" and ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$11))) + (" at ")) + (Lib_Elab_Prelude_Show$20Lib_Elab_UnifyMode$2Cshow(_1))) + (""))), eta)))) ); } break; } } } else { return ( (_$$11.h2.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: _$$10 },  h2: { tag: 0 } })) : Lib_Elab_unify_unifyMeta(_, _1, _2, _3, _$$10, _$$11) ); } } else { return ( (_$$10.tag) == (0) ? ( (_$$10.h2.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_MkResult({ tag: 1,  h1: { tag: 0,  h2: _$$10.h1,  h3: _$$11 },  h2: { tag: 0 } })) : Lib_Elab_unify_unifyMeta(_, _1, _2, _3, _$$10, _$$11) ) : Lib_Elab_unify_unifyMeta(_, _1, _2, _3, _$$10, _$$11) ); } };
let Lib_Elab_Prelude_Show$20Lib_Elab_UnifyMode$2Cshow = ( _$$0 ) => { switch (_$$0) { case true: return "UPattern"; case false: return "UNormal"; } };
let Lib_Eval_unlet = ( _$$0, _$$1 ) => { if ((_$$1.tag) == (0)) { let sc$$5 = Lib_Eval_lookupVar(_$$0, _$$1.h1); return ( (sc$$5.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("lookup ") + (Prelude_showInt(_$$1.h1))) + (" is Nothing in env ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$0))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$1))) : ( (sc$$5.h1.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("lookup ") + (Prelude_showInt(_$$1.h1))) + (" is ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$5.h1))) + (""))), ( _ ) => { let sc$$12 = Prelude_eqInt(sc$$5.h1.h1, _$$1.h1); switch (sc$$12) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$1); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(sc$$5.h1, _$$1.h2), ( eta ) => (Lib_Eval_unlet(_$$0, eta))); } }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(sc$$5.h1, _$$1.h2), ( eta ) => (Lib_Eval_unlet(_$$0, eta))) ) ); } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$1); } };
let Lib_Eval_lookupVar = ( _$$0, _$$1 ) => { let l = Prelude_natToInt(Prelude_length(_$$0)); let sc$$3 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$1, l), 2); switch (sc$$3) { case true: return Prelude_Nothing(); case false: { let sc$$4 = Prelude_getAt(Prelude_intToNat(((l) - (_$$1)) - (1)), _$$0); if ((sc$$4.tag) == (1)) { return Prelude_Nothing(); } else { if ((sc$$4.h1.tag) == (0)) { let sc$$10 = Prelude_eqInt(_$$1, sc$$4.h1.h1); switch (sc$$10) { case true: return Prelude_Nothing(); case false: return Prelude_Just(sc$$4.h1); } } else { return Prelude_Just(sc$$4.h1); } } break; } } };
let Lib_Elab_forceMeta = ( _$$0 ) => (( (_$$0.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$0.h1), ( meta ) => (( (meta.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(meta.h2, _$$0.h2), ( eta ) => (Lib_Elab_forceMeta(eta))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_VMeta(_$$0.h0, _$$0.h1, _$$0.h2)) ))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0) ));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 15: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RUpdateRec",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_UpdateClause, _$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 14: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RAs",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 13: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RWhere",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl, _$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 12: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RIf",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 11: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RDo",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_DoStmt, _$$0.h1),  h2: { tag: 0 } } } })) + (")"); case 10: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RHole",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 0 } } })) + (")"); case 9: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RImplicit",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 0 } } })) + (")"); case 8: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RCase",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$0.h2),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt, _$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 7: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RLit",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$0.h1),  h2: { tag: 0 } } } })) + (")"); case 6: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RLet",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h3),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h4),  h2: { tag: 0 } } } } } } })) + (")"); case 5: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RPi",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 4: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RImpossible",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 0 } } })) + (")"); case 3: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RU",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 0 } } })) + (")"); case 2: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RApp",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 1: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RLam",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 0: return (Prelude_joinBy(" ", { tag: 1,  h1: "(RVar",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 0 } } } })) + (")"); } };
let Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo$2Cshow = ( _$$0 ) => ((Prelude_joinBy(" ", { tag: 1,  h1: "(BI",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3),  h2: { tag: 0 } } } } } })) + (")"));
let Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow = ( _$$0 ) => { switch (_$$0) { case 2: return "Auto"; case 1: return "Explicit"; case 0: return "Implicit"; } };
let Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt$2Cshow = ( _$$0 ) => ((Prelude_joinBy(" ", { tag: 1,  h1: "(MkAlt",  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$0.h1),  h2: { tag: 0 } } } })) + (")"));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw = Prelude_MkShow(( eta ) => (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(eta)));
let Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow = ( _$$1, _$$2 ) => (( (_$$2.tag) == (1) ? "Nothing" : (("Just ") + (Prelude_show(_$$1)(_$$2.h1))) + ("") ));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt = Prelude_MkShow(( eta ) => (Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt$2Cshow(eta)));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_DoStmt$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 2: return (Prelude_joinBy(" ", { tag: 1,  h1: "(DoArrow",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt, _$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 1: return (Prelude_joinBy(" ", { tag: 1,  h1: "(DoLet",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 0: return (Prelude_joinBy(" ", { tag: 1,  h1: "(DoExpr",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 0 } } } })) + (")"); } };
let Lib_Syntax_Prelude_Show$20Lib_Syntax_DoStmt = Prelude_MkShow(( eta ) => (Lib_Syntax_Prelude_Show$20Lib_Syntax_DoStmt$2Cshow(eta)));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 12: return (Prelude_joinBy(" ", { tag: 1,  h1: "(Exports",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, eta))), _$$0.h1),  h2: { tag: 0 } } } })) + (")"); case 11: return (Prelude_joinBy(" ", { tag: 1,  h1: "(Record",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, _$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, eta))), _$$0.h2),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, eta))), _$$0.h3),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl, _$$0.h4),  h2: { tag: 0 } } } } } } })) + (")"); case 10: return (Prelude_joinBy(" ", { tag: 1,  h1: "(Instance",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl, eta))), _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 9: return (Prelude_joinBy(" ", { tag: 1,  h1: "(Class",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, _$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, eta))), _$$0.h2),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl, _$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 8: return (Prelude_joinBy(" ", { tag: 1,  h1: "(PMixFix",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, _$$0.h1),  h2: { tag: 1,  h1: Prelude_showInt(_$$0.h2),  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_Fixity$2Cshow(_$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 7: return (Prelude_joinBy(" ", { tag: 1,  h1: "(PFunc",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, _$$0.h2),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h3),  h2: { tag: 1,  h1: _$$0.h4,  h2: { tag: 0 } } } } } } })) + (")"); case 6: return (Prelude_joinBy(" ", { tag: 1,  h1: "(PType",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 5: return (Prelude_joinBy(" ", { tag: 1,  h1: "(ShortData",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 4: return (Prelude_joinBy(" ", { tag: 1,  h1: "(Data",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, _$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl, eta))), _$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 3: return (Prelude_joinBy(" ", { tag: 1,  h1: "(DDerive",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, _$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20Prim_String, _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 2: return (Prelude_joinBy(" ", { tag: 1,  h1: "(DCheck",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 1: return (Prelude_joinBy(" ", { tag: 1,  h1: "(FunDef",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, eta))), eta))), _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 0: return (Prelude_joinBy(" ", { tag: 1,  h1: "(TypeSig",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, _$$0.h1),  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")"); } };
let Lib_Common_Prelude_Show$20Lib_Common_FC = Prelude_MkShow(( eta ) => (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(eta)));
let Lib_Common_Prelude_Show$20Lib_Common_Fixity$2Cshow = ( _$$0 ) => { switch (_$$0) { case 2: return "infix"; case 1: return "infixr"; case 0: return "infixl"; } };
let Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo = Prelude_MkShow(( eta ) => (Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo$2Cshow(eta)));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl = Prelude_MkShow(( eta ) => (Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl$2Cshow(eta)));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_UpdateClause$2Cshow = ( _$$0 ) => (( (_$$0.tag) == (1) ? (Prelude_joinBy(" ", { tag: 1,  h1: "(ModifyField",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")") : (Prelude_joinBy(" ", { tag: 1,  h1: "(AssignField",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: _$$0.h1,  h2: { tag: 1,  h1: Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2),  h2: { tag: 0 } } } } })) + (")") ));
let Lib_Syntax_Prelude_Show$20Lib_Syntax_UpdateClause = Prelude_MkShow(( eta ) => (Lib_Syntax_Prelude_Show$20Lib_Syntax_UpdateClause$2Cshow(eta)));
let Lib_Elab_insert = ( ctx$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta(_$$2), ( ty$27 ) => { if ((ty$27.tag) == (5)) { switch (ty$27.h2) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(ctx$$0, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$1), ty$27.h4, 2), ( m ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("INSERT Auto ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), ctx$$0.h2), m))), { tag: 0 }))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty$27.h4))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("TM ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), ctx$$0.h2), _$$1))), { tag: 0 }))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(ctx$$0.h1, m), ( mv ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: mv,  h2: ty$27.h5.h0 }, ty$27.h5.h1), ( bapp ) => (Lib_Elab_insert(ctx$$0, Lib_Types_App(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$1), _$$1, m), bapp))))))))))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(ctx$$0, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$1), ty$27.h4, 0), ( m ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("INSERT ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), ctx$$0.h2), m))), { tag: 0 }))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty$27.h4))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("TM ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), ctx$$0.h2), _$$1))), { tag: 0 }))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(ctx$$0.h1, m), ( mv ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: mv,  h2: ty$27.h5.h0 }, ty$27.h5.h1), ( bapp ) => (Lib_Elab_insert(ctx$$0, Lib_Types_App(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$1), _$$1, m), bapp))))))))))); default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$1,  h3: ty$27 }); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$1,  h3: ty$27 }); } }));
let Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case 11: return _$$0.h0; case 10: return _$$0.h0; case 9: return _$$0.h0; case 8: return _$$0.h0; case 7: return _$$0.h0; case 6: return _$$0.h0; case 5: return _$$0.h0; case 4: return _$$0.h0; case 3: return _$$0.h0; case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Elab_freshMeta = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("fresh meta ") + (Prelude_showInt(top.h2.h3.h2))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$2))) + (" (")) + (Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow(_$$3))) + (")"))), ( _ ) => { let qn = { tag: 0,  h0: top.h2.h0,  h1: (("$m") + (Prelude_showInt(top.h2.h3.h2))) + ("") }; let newmeta = Lib_Types_Unsolved(_$$1, qn, _$$0, _$$2, _$$3, { tag: 0 }); let autos; switch (_$$3) { case 2: { autos = { tag: 1,  h1: qn,  h2: top.h2.h3.h1 }; break; } default: { autos = top.h2.h3.h1; break; } } return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_setMetaContext(Lib_Types_MC(Data_SortedMap_updateMap(qn, newmeta, top.h2.h3.h0), autos, (1) + (top.h2.h3.h2), top.h2.h3.h3)), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Elab_freshMeta_applyBDs(_$$0, _$$1, _$$2, _$$3, 0, Lib_Types_Meta(_$$1, qn), _$$0.h3)))); }))));
let Lib_Elab_freshMeta_applyBDs = ( _, _1, _2, _3, _$$5, _$$6, _$$7 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$51 = _$$5; let _$$61 = _$$6; let _$$71 = _$$7; if ((_$$71.tag) == (1)) { switch (_$$71.h1) { case true: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = (1) + (_$$51); _$$6 = _$$61; _$$7 = _$$71.h2; continue; break; } case false: return Lib_Types_App(Lib_Common_emptyFC, Lib_Elab_freshMeta_applyBDs(_4, _5, _6, _7, (1) + (_$$51), _$$61, _$$71.h2), Lib_Types_Bnd(Lib_Common_emptyFC, _$$51)); } } else { return _$$61; } } };
let Lib_Elab_infer = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 15: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, "I can't infer record updates")), eta)))); case 14: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, "@ can only be used in patterns")), eta)))); case 9: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0), ( ty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, ty), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$1.h0, vty, 0), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: tm,  h3: vty }))))))); case 7: switch (_$$1.h1.tag) { case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Lit(_$$1.h0, Lib_Types_LChar(_$$1.h1.h0)),  h3: Lib_Types_VRef(_$$1.h0, Lib_Elab_charType, { tag: 0 }) }); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Lit(_$$1.h0, Lib_Types_LInt(_$$1.h1.h0)),  h3: Lib_Types_VRef(_$$1.h0, Lib_Elab_intType, { tag: 0 }) }); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Lit(_$$1.h0, Lib_Types_LString(_$$1.h1.h0)),  h3: Lib_Types_VRef(_$$1.h0, Lib_Elab_stringType, { tag: 0 }) }); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$1), (("Implement infer ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$1))) + (""))), eta)))); } break; case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h2, Lib_Types_VU(Lib_Common_emptyFC)), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, ty$27), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h3, vty), ( v$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, v$27), ( vv ) => { let ctx$27 = Lib_Types_define(_$$0, _$$1.h1, vv, vty); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(ctx$27, _$$1.h4), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Let(_$$1.h0, _$$1.h1, v$27, $$sc.h2),  h3: $$sc.h3 }))); }))))))); case 5: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h2, Lib_Types_VU(_$$1.h1.h0)), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, ty$27), ( vty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_extend(_$$0, _$$1.h1.h1, vty$27), _$$1.h3, Lib_Types_VU(_$$1.h1.h0)), ( ty2$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Pi(_$$1.h1.h0, _$$1.h1.h1, _$$1.h1.h2, _$$1.h1.h3, ty$27, ty2$27),  h3: Lib_Types_VU(_$$1.h1.h0) }))))))); case 3: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_UU(_$$1.h0),  h3: Lib_Types_VU(_$$1.h0) }); case 2: switch (_$$1.h3) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(_$$0, _$$1.h1), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: 2,  h3: { tag: 0,  h2: $$sc.h2,  h3: $$sc.h3 } }))), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta($$sc.h3.h3), ( tty$27 ) => { if ((tty$27.tag) == (5)) { let sc$$24 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(tty$27.h2, $$sc.h2); switch (sc$$24) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: tty$27.h4,  h3: tty$27.h5 }); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (((("IcitMismatch ") + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow($$sc.h2))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(tty$27.h2))) + (""))), eta)))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("unify PI for ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(tty$27))) + (" at ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(Lib_Types_getValFC(tty$27)))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0), ( eta ) => (Lib_Eval_eval(_$$0.h1, eta))), ( a ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_MkClosure(_$$0.h1, eta)), Lib_Elab_freshMeta(Lib_Types_extend(_$$0, ":ins", a), _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0)), ( b ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(_$$1.h0, _$$0, tty$27, Lib_Types_VPi(_$$1.h0, ":ins", $$sc.h2, true, a, b)), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: a,  h3: b }))))))))); } }), ( $$sc1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h2, $$sc1.h2), ( u ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, u), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: u$27,  h2: $$sc1.h3.h0 }, $$sc1.h3.h1), ( bappu ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_App(_$$1.h0, $$sc.h3.h2, u),  h3: bappu }))))))))))); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(_$$0, _$$1.h1), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_insert(_$$0, $$sc.h2, $$sc.h3), ( $$sc1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: 1,  h3: { tag: 0,  h2: $$sc1.h2,  h3: $$sc1.h3 } }))))), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta($$sc.h3.h3), ( tty$27 ) => { if ((tty$27.tag) == (5)) { let sc$$24 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(tty$27.h2, $$sc.h2); switch (sc$$24) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: tty$27.h4,  h3: tty$27.h5 }); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (((("IcitMismatch ") + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow($$sc.h2))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(tty$27.h2))) + (""))), eta)))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("unify PI for ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(tty$27))) + (" at ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(Lib_Types_getValFC(tty$27)))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0), ( eta ) => (Lib_Eval_eval(_$$0.h1, eta))), ( a ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_MkClosure(_$$0.h1, eta)), Lib_Elab_freshMeta(Lib_Types_extend(_$$0, ":ins", a), _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0)), ( b ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(_$$1.h0, _$$0, tty$27, Lib_Types_VPi(_$$1.h0, ":ins", $$sc.h2, true, a, b)), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: a,  h3: b }))))))))); } }), ( $$sc1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h2, $$sc1.h2), ( u ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, u), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: u$27,  h2: $$sc1.h3.h0 }, $$sc1.h3.h1), ( bappu ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_App(_$$1.h0, $$sc.h3.h2, u),  h3: bappu }))))))))))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(_$$0, _$$1.h1), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: 0,  h3: { tag: 0,  h2: $$sc.h2,  h3: $$sc.h3 } }))), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta($$sc.h3.h3), ( tty$27 ) => { if ((tty$27.tag) == (5)) { let sc$$24 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(tty$27.h2, $$sc.h2); switch (sc$$24) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: tty$27.h4,  h3: tty$27.h5 }); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (((("IcitMismatch ") + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow($$sc.h2))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(tty$27.h2))) + (""))), eta)))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("unify PI for ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(tty$27))) + (" at ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(Lib_Types_getValFC(tty$27)))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0), ( eta ) => (Lib_Eval_eval(_$$0.h1, eta))), ( a ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_MkClosure(_$$0.h1, eta)), Lib_Elab_freshMeta(Lib_Types_extend(_$$0, ":ins", a), _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0)), ( b ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_unifyCatch(_$$1.h0, _$$0, tty$27, Lib_Types_VPi(_$$1.h0, ":ins", $$sc.h2, true, a, b)), ( _1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: a,  h3: b }))))))))); } }), ( $$sc1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h2, $$sc1.h2), ( u ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, u), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: u$27,  h2: $$sc1.h3.h0 }, $$sc1.h3.h1), ( bappu ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_App(_$$1.h0, $$sc.h3.h2, u),  h3: bappu }))))))))))); } break; case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$1.h1.h0, Lib_Types_VU(Lib_Common_emptyFC), 0), ( eta ) => (Lib_Eval_eval(_$$0.h1, eta))), ( a ) => { let ctx$27 = Lib_Types_extend(_$$0, _$$1.h1.h1, a); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_infer(ctx$27, _$$1.h2), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("make lam for ") + (_$$1.h1.h1)) + (" scope ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0.h2), $$sc.h2))), { tag: 0 }))) + (" : ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc.h3))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote((1) + (_$$0.h0), $$sc.h3), ( tyb ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Lam(_$$1.h1.h0, _$$1.h1.h1, _$$1.h1.h2, _$$1.h1.h3, $$sc.h2),  h3: Lib_Types_VPi(_$$1.h1.h0, _$$1.h1.h1, _$$1.h1.h2, _$$1.h1.h3, a, { tag: 0,  h0: _$$0.h1,  h1: tyb }) }))))))); }); case 0: return Lib_Elab_infer_go(_$$0, _$$1, _$$1.h0, _$$1.h1, 0, _$$0.h2); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$1), (("Implement infer ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$1))) + (""))), eta)))); } };
let Lib_Elab_infer_go = ( _, _1, _2, _3, _$$5, _$$6 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$51 = _$$5; let _$$61 = _$$6; if ((_$$61.tag) == (1)) { let sc$$14 = Prelude_eqString(_$$61.h1.h2, _7); switch (sc$$14) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Bnd(_6, _$$51),  h3: _$$61.h1.h3 }); case false: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = (_$$51) + (1); _$$6 = _$$61.h2; continue; break; } } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$9 = Lib_TopContext_lookupRaw(_7, top); return ( (sc$$9.tag) == (1) ? Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_ENotInScope(_6, _7)), eta)))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _8 ) => ((((("lookup ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$9.h1.h1))) + (" as ")) + (Lib_Types_Prelude_Show$20Lib_Types_Def$2Cshow(sc$$9.h1.h3))) + (""))), ( _8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$9.h1.h2), ( vty ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Lib_Types_Ref(_6, sc$$9.h1.h1),  h3: vty }))))) ); }); } } };
let Lib_Types_Prelude_Show$20Lib_Types_Def$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 6: return (Prelude_joinBy(" ", { tag: 1,  h1: "(PrimOp",  h2: { tag: 1,  h1: _$$0.h0,  h2: { tag: 0 } } })) + (")"); case 5: return (Prelude_joinBy(" ", { tag: 1,  h1: "(PrimFn",  h2: { tag: 1,  h1: _$$0.h0,  h2: { tag: 1,  h1: Prelude_showInt(Prelude_natToInt(_$$0.h1)),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, _$$0.h2),  h2: { tag: 0 } } } } })) + (")"); case 4: return (Prelude_joinBy(" ", { tag: 1,  h1: "(PrimTCon",  h2: { tag: 1,  h1: Prelude_showInt(_$$0.h0),  h2: { tag: 0 } } })) + (")"); case 3: return (Prelude_joinBy(" ", { tag: 1,  h1: "(Fn",  h2: { tag: 1,  h1: Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$0.h0),  h2: { tag: 0 } } })) + (")"); case 2: return (Prelude_joinBy(" ", { tag: 1,  h1: "(DCon",  h2: { tag: 1,  h1: Prelude_showInt(Prelude_natToInt(_$$0.h0)),  h2: { tag: 1,  h1: Lib_Types_Prelude_Show$20Lib_Types_ConInfo$2Cshow(_$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Quant, _$$0.h2),  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h3),  h2: { tag: 0 } } } } } })) + (")"); case 1: return (Prelude_joinBy(" ", { tag: 1,  h1: "(TCon",  h2: { tag: 1,  h1: Prelude_showInt(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, _$$0.h1),  h2: { tag: 0 } } } })) + (")"); case 0: return "Axiom"; } };
let Lib_Types_Prelude_Show$20Lib_Types_Quant = Prelude_MkShow(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(eta)));
let Lib_Types_Prelude_Show$20Lib_Types_ConInfo$2Cshow = ( _$$0 ) => { switch (_$$0) { case 7: return "[C]"; case 6: return "[N]"; case 5: return "[F]"; case 4: return "[T]"; case 3: return "[E]"; case 2: return "[Z]"; case 1: return "[S]"; case 0: return ""; } };
let Lib_Error_ENotInScope = ( h0, h1 ) => ({ tag: 1,  h0: h0,  h1: h1 });
let Lib_TopContext_lookupRaw = ( _$$0, _$$1 ) => { let sc$$3 = Data_SortedMap_lookupMap$27({ tag: 0,  h0: _$$1.h2.h0,  h1: _$$0 }, _$$1.h2.h2); return ( (sc$$3.tag) == (1) ? Lib_TopContext_lookupRaw_go(_$$0, _$$1, _$$1.h2.h5) : Prelude_Just(sc$$3.h1) ); };
let Lib_TopContext_lookupRaw_go = ( _, _1, _$$3 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { let sc$$7 = Data_SortedMap_lookupMap$27(_$$31.h1, _3.h0); if ((sc$$7.tag) == (1)) { _ = _2; _1 = _3; _$$3 = _$$31.h2; continue; } else { let sc$$10 = Data_SortedMap_lookupMap$27({ tag: 0,  h0: _$$31.h1,  h1: _2 }, sc$$7.h1.h2); if ((sc$$10.tag) == (1)) { _ = _2; _1 = _3; _$$3 = _$$31.h2; continue; } else { return Prelude_Just(sc$$10.h1); } } } else { return Prelude_Nothing(); } } };
let Lib_Types_extend = ( _$$0, _$$1, _$$2 ) => (Lib_Types_MkCtx((1) + (_$$0.h0), { tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, _$$0.h0, { tag: 0 }),  h2: _$$0.h1 }, { tag: 1,  h1: { tag: 0,  h2: _$$1,  h3: _$$2 },  h2: _$$0.h2 }, { tag: 1,  h1: false,  h2: _$$0.h3 }, _$$0.h4));
let Lib_Types_MkClosure = ( h0, h1 ) => ({ tag: 0,  h0: h0,  h1: h1 });
let Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1) { case 2: switch (_$$0) { case 2: return true; default: return false; } break; case 1: switch (_$$0) { case 1: return true; default: return false; } break; case 0: switch (_$$0) { case 0: return true; default: return false; } break; } };
let Lib_Types_define = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_MkCtx((1) + (_$$0.h0), { tag: 1,  h1: _$$2,  h2: _$$0.h1 }, { tag: 1,  h1: { tag: 0,  h2: _$$1,  h3: _$$3 },  h2: _$$0.h2 }, { tag: 1,  h1: true,  h2: _$$0.h3 }, _$$0.h4));
let Lib_Elab_stringType = { tag: 0,  h0: Lib_Common_primNS,  h1: "String" };
let Lib_Types_LString = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_Elab_intType = { tag: 0,  h0: Lib_Common_primNS,  h1: "Int" };
let Lib_Types_LInt = ( h0 ) => ({ tag: 1,  h0: h0 });
let Lib_Elab_charType = { tag: 0,  h0: Lib_Common_primNS,  h1: "Char" };
let Lib_Types_LChar = ( h0 ) => ({ tag: 2,  h0: h0 });
let Lib_Eval_prvalCtx = ( ctx$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(ctx$$0.h0, _$$1), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), ctx$$0.h2), tm))), { tag: 0 })))));
let Lib_Types_logM = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0, top.h3), 2)), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(_$$1, ( msg ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn(msg)))))))));
let Lib_Elab_buildTree = ( _$$0, _$$1 ) => { if ((_$$1.h0.tag) == (1)) { if ((_$$1.h0.h1.h2.tag) == (1)) { if ((_$$1.h1.tag) == (5)) { let l = Prelude_length$27(_$$0.h1); let nm = Lib_Elab_fresh(_$$0, _$$1.h1.h1); let ctx$27 = Lib_Types_extend(_$$0, nm, _$$1.h1.h4); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_introClause(nm, _$$1.h1.h2, _$$1.h1.h4, eta)), _$$1.h0), ( clauses ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(_$$1.h0.h1.h0, l, { tag: 0 }),  h2: _$$1.h1.h5.h0 }, _$$1.h1.h5.h1), ( vb ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_Lam(_$$1.h0.h1.h0, nm, _$$1.h1.h2, _$$1.h1.h3, eta)), Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: vb })))))); } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0.h1.h0, (("Extra pattern variables ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Pattern, _$$1.h0.h1.h2))) + (""))), eta)))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("buildTree ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Constraint, _$$1.h0.h1.h1))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$1.h0.h1.h3))) + (""))), ( _ ) => { let sc$$13 = Lib_Elab_findSplit(_$$1.h0.h1.h1); return ( (sc$$13.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((((((("SPLIT on ") + (sc$$13.h1.h0)) + (" because ")) + (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(sc$$13.h1.h1))) + (" ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(sc$$13.h1.h1)))) + (""))), ( _1 ) => { let sc$$20 = Lib_Elab_lookupName(_$$0, sc$$13.h1.h0); return ( (sc$$20.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_unlet(_$$0.h1, sc$$20.h1.h3), ( eta ) => (Lib_Eval_forceType(_$$0.h1, eta))), ( scty$27 ) => (( (scty$27.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(scty$27.h1), ( meta ) => { switch (meta.tag) { case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(scty$27); case 1: return Lib_Eval_forceType(_$$0.h1, scty$27); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solveAutos, ( _2 ) => (Lib_Eval_forceType(_$$0.h1, scty$27))); } }), ( scty$271 ) => { switch (sc$$13.h1.h1.tag) { case 3: { let tyname = Lib_Elab_litTyName(sc$$13.h1.h1.h1); return ( (scty$271.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(scty$271.h1, tyname)), ( _2 ) => (Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$13.h1.h1.h0, (((("expected ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (" and got ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(tyname))) + (""))), eta)))))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildLitCases(_$$0, _$$1, sc$$13.h1.h1.h0, sc$$13.h1.h0, sc$$20.h1.h3), ( alts ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, alts)))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$13.h1.h1.h0, (((("expected ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (" and got ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(tyname))) + (""))), eta)))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildLitCases(_$$0, _$$1, sc$$13.h1.h1.h0, sc$$13.h1.h0, sc$$20.h1.h3), ( alts ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, alts)))))) ); break; } case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("EXP ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (" -> ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(scty$271))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_getConstructors(_$$0, Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(sc$$13.h1.h1), scty$271), ( cons ) => { let matched = Lib_Elab_matchedConstructors(sc$$13.h1.h0, _$$1.h0); let matched$27 = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), matched); let sc$$39 = Prelude_partition(( _$$5 ) => (Prelude_elem(Lib_Common_Prelude_Eq$20Lib_Common_QName, _$$5.h2, matched$27)), cons); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_filterM(( eta ) => (Lib_Elab_checkCase(_$$0, sc$$13.h1.h0, scty$271, eta)), sc$$39.h3), ( miss$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, matched, ( $$case ) => { let sc$$51 = Prelude_elem(Lib_Common_Prelude_Eq$20Lib_Common_QName, $$case.h3, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), cons)); switch (sc$$51) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); case false: return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E($$case.h2, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$case.h3))) + (" not a constructor for ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (""))), eta)))); } }), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((((((("CONS ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), cons)))) + (" matched ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Lib_Common_Prelude_Show$20Lib_Common_QName, eta))), matched))) + (" miss ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm, eta))), eta))), sc$$39.h3))) + (" miss' ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm, eta))), eta))), miss$27))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_buildCase(_$$0, _$$1, sc$$13.h1.h0, scty$271, eta)), sc$$39.h2), ( alts ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("GOTALTS ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_CaseAlt, eta))), alts))) + (""))), ( _5 ) => { let alts$27 = Prelude_mapMaybe(( _$$11 ) => (_$$11), alts); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(alts$27), 0), ( _6 ) => (Lib_Types_MkM(( _7 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$13.h1.h1.h0, (("no alts for ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(scty$271))) + (""))), eta)))))), ( _6 ) => (( (miss$27.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, Prelude_mapMaybe(( _$$11 ) => (_$$11), alts))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildDefault(_$$0, _$$1, sc$$13.h1.h1.h0, sc$$13.h1.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), miss$27)), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(alts$27, { tag: 1,  h1: $$sc,  h2: { tag: 0 } }))))) ))); }))))))))); }))); default: return Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(sc$$13.h1.h1), (("Internal error - tried to split on ") + (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(sc$$13.h1.h1))) + (""))), eta)))); } }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(scty$27), ( scty$271 ) => { switch (sc$$13.h1.h1.tag) { case 3: { let tyname = Lib_Elab_litTyName(sc$$13.h1.h1.h1); return ( (scty$271.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(scty$271.h1, tyname)), ( _2 ) => (Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$13.h1.h1.h0, (((("expected ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (" and got ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(tyname))) + (""))), eta)))))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildLitCases(_$$0, _$$1, sc$$13.h1.h1.h0, sc$$13.h1.h0, sc$$20.h1.h3), ( alts ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, alts)))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$13.h1.h1.h0, (((("expected ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (" and got ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(tyname))) + (""))), eta)))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildLitCases(_$$0, _$$1, sc$$13.h1.h1.h0, sc$$13.h1.h0, sc$$20.h1.h3), ( alts ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, alts)))))) ); break; } case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("EXP ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (" -> ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(scty$271))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_getConstructors(_$$0, Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(sc$$13.h1.h1), scty$271), ( cons ) => { let matched = Lib_Elab_matchedConstructors(sc$$13.h1.h0, _$$1.h0); let matched$27 = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), matched); let sc$$39 = Prelude_partition(( _$$5 ) => (Prelude_elem(Lib_Common_Prelude_Eq$20Lib_Common_QName, _$$5.h2, matched$27)), cons); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_filterM(( eta ) => (Lib_Elab_checkCase(_$$0, sc$$13.h1.h0, scty$271, eta)), sc$$39.h3), ( miss$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, matched, ( $$case ) => { let sc$$51 = Prelude_elem(Lib_Common_Prelude_Eq$20Lib_Common_QName, $$case.h3, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), cons)); switch (sc$$51) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); case false: return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E($$case.h2, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$case.h3))) + (" not a constructor for ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$20.h1.h3))) + (""))), eta)))); } }), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((((((("CONS ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), cons)))) + (" matched ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_FC, Lib_Common_Prelude_Show$20Lib_Common_QName, eta))), matched))) + (" miss ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm, eta))), eta))), sc$$39.h3))) + (" miss' ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm, eta))), eta))), miss$27))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_buildCase(_$$0, _$$1, sc$$13.h1.h0, scty$271, eta)), sc$$39.h2), ( alts ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("GOTALTS ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_CaseAlt, eta))), alts))) + (""))), ( _5 ) => { let alts$27 = Prelude_mapMaybe(( _$$11 ) => (_$$11), alts); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(alts$27), 0), ( _6 ) => (Lib_Types_MkM(( _7 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$13.h1.h1.h0, (("no alts for ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(scty$271))) + (""))), eta)))))), ( _6 ) => (( (miss$27.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, Prelude_mapMaybe(( _$$11 ) => (_$$11), alts))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildDefault(_$$0, _$$1, sc$$13.h1.h1.h0, sc$$13.h1.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), miss$27)), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(sc$$13.h1.h1.h0, sc$$20.h1.h2, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(alts$27, { tag: 1,  h1: $$sc,  h2: { tag: 0 } }))))) ))); }))))))))); }))); default: return Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(sc$$13.h1.h1), (("Internal error - tried to split on ") + (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(sc$$13.h1.h1))) + (""))), eta)))); } }) ))) : Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0.h1.h0, (("Internal Error: can't find ") + (sc$$13.h1.h0)) + (" in environment"))), eta)))) ); }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("checkDone ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Constraint, _$$1.h0.h1.h1))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_checkDups(_$$1.h0.h1.h0)(_$$1.h0.h1.h1), ( _2 ) => (Lib_Elab_checkDone(_$$1.h0.h1.h0, _$$0, _$$1.h0.h1.h1, _$$1.h0.h1.h3, _$$1.h1))))) ); }); } } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "no clauses")), eta)))); } };
let Lib_Elab_checkDone = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { if ((_$$3.tag) == (1)) { if ((_$$2.tag) == (1)) { switch (_$$2.h1.h1.tag) { case 4: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_getConstructors(_$$1, _$$0, _$$2.h1.h2), ( cons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_filterM(( eta ) => (Lib_Elab_checkCase(_$$1, _$$2.h1.h0, _$$2.h1.h2, eta)), cons), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Erased(_$$0)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$2.h1.h1.h0, (("possible constructors: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), $$sc)))) + (""))), eta)))) ))))); case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(_$$2.h1.h1.h1, 1), ( _ ) => (Lib_TopContext_addInfo(Lib_Types_CaseSplit(_$$2.h1.h1.h0, _$$1, "_", _$$2.h1.h2)))), ( _ ) => (Lib_Elab_checkDone(_$$0, _$$1, _$$2.h2, _$$3, _$$4))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addInfo(Lib_Types_CaseSplit(_$$2.h1.h1.h0, _$$1, _$$2.h1.h1.h2, _$$2.h1.h2)), ( _ ) => { let ctx = Lib_Types_MkCtx(_$$1.h0, _$$1.h1, Lib_Elab_checkDone_rename(_$$0, _$$1, _$$2, _$$3, _$$4, _$$3.h0, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h1.h0, _$$2.h1.h1, _$$2.h1.h2, _$$2.h1.h1.h0, _$$2.h1.h1.h1, _$$2.h1.h1.h2, _$$1.h2), _$$1.h3, _$$1.h4); return Lib_Elab_checkDone(_$$0, ctx, _$$2.h2, _$$3, _$$4); }); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(_$$2.h1.h1), (((("stray constraint ") + (_$$2.h1.h0)) + (" /? ")) + (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(_$$2.h1.h1))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0, "impossible clause needs () on RHS")), eta)))); } } else { if ((_$$2.tag) == (1)) { switch (_$$2.h1.h1.tag) { case 4: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_getConstructors(_$$1, _$$0, _$$2.h1.h2), ( cons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_filterM(( eta ) => (Lib_Elab_checkCase(_$$1, _$$2.h1.h0, _$$2.h1.h2, eta)), cons), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Erased(_$$0)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$2.h1.h1.h0, (("possible constructors: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), $$sc)))) + (""))), eta)))) ))))); case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(_$$2.h1.h1.h1, 1), ( _ ) => (Lib_TopContext_addInfo(Lib_Types_CaseSplit(_$$2.h1.h1.h0, _$$1, "_", _$$2.h1.h2)))), ( _ ) => (Lib_Elab_checkDone(_$$0, _$$1, _$$2.h2, _$$3, _$$4))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addInfo(Lib_Types_CaseSplit(_$$2.h1.h1.h0, _$$1, _$$2.h1.h1.h2, _$$2.h1.h2)), ( _ ) => { let ctx = Lib_Types_MkCtx(_$$1.h0, _$$1.h1, Lib_Elab_checkDone_rename$27(_$$0, _$$1, _$$2, _$$3, _$$4, _$$3.h0, _$$3.h1, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h1.h0, _$$2.h1.h1, _$$2.h1.h2, _$$2.h1.h1.h0, _$$2.h1.h1.h1, _$$2.h1.h1.h2, _$$1.h2), _$$1.h3, _$$1.h4); return Lib_Elab_checkDone(_$$0, ctx, _$$2.h2, _$$3, _$$4); }); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(_$$2.h1.h1), (((("stray constraint ") + (_$$2.h1.h0)) + (" /? ")) + (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(_$$2.h1.h1))) + (""))), eta)))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("DONE-> check body ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$3.h1))) + (" at ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$4))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_logM(2, Lib_Elab_showCtx(_$$1)), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$1.h1, ( val ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(Prelude_length$27(_$$1.h1), val), ( ty ) => (Lib_Eval_eval(_$$1.h1, ty))))), ( env$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$1.h2, ( $$case ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(Prelude_length$27(env$27), $$case.h3), ( nty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(env$27, nty), ( ty$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: $$case.h2,  h3: ty$27 }))))))), ( types$27 ) => { let ctx = Lib_Types_MkCtx(_$$1.h0, env$27, types$27, _$$1.h3, _$$1.h4); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ("AFTER")), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_logM(2, Lib_Elab_showCtx(ctx)), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(Prelude_length$27(ctx.h1), _$$4), ( ty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(ctx.h1, ty), ( ty1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((("check at ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty1))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(ctx, _$$3.h1, ty1), ( got ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("DONE<- got ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), ctx.h2), got))), { tag: 0 }))) + (""))), ( _5 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(got))))))))))))))); }))))))); } } };
let Lib_Elab_showCtx = ( _$$0 ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$5 ) => (Prelude_joinBy("\n", Prelude_reverse()(_$$5))), Lib_Elab_showCtx_go(_$$0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0.h2), 0, Prelude_reverse()(Prelude_zip(_$$0.h1, _$$0.h2)), { tag: 0 })));
let Lib_Elab_showCtx_go = ( _, _$$3, _$$4, _$$5, _$$6 ) => { if ((_$$5.tag) == (1)) { let sc$$18 = Lib_Elab_showCtx_isVar(_, _$$4, _$$5.h1.h2); switch (sc$$18) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_.h0, _$$5.h1.h3.h3), ( tty ) => (Lib_Elab_showCtx_go(_, _$$3, (1) + (_$$4), _$$5.h2, { tag: 1,  h1: (((("  ") + (_$$5.h1.h3.h2)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, _$$3, tty))), { tag: 0 }))) + (""),  h2: _$$6 }))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_.h0, _$$5.h1.h2), ( tm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_.h0, _$$5.h1.h3.h3), ( tty ) => (Lib_Elab_showCtx_go(_, _$$3, (1) + (_$$4), _$$5.h2, { tag: 1,  h1: (((((("  ") + (_$$5.h1.h3.h2)) + (" = ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, _$$3, tm))), { tag: 0 }))) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, _$$3, tty))), { tag: 0 }))) + (""),  h2: _$$6 }))))); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$6); } };
let Lib_Elab_showCtx_isVar = ( _, _$$2, _$$3 ) => (( (_$$3.tag) == (0) ? ( (_$$3.h2.tag) == (0) ? Prelude_eqInt(_$$2, _$$3.h1) : false ) : false ));
let Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case 4: return "PatImp"; case 3: return ("(PatLit ") + ((Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$0.h1)) + (")")); case 2: return ("(PatWild ") + ((Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h1)) + (")")); case 1: return ("(PatCon ") + ((Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h1)) + ((" ") + ((Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h2)) + ((" ") + ((Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Pattern, _$$0.h3)) + ((" ") + ((Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, _$$0.h4)) + (")")))))))); case 0: return ("(PatVar ") + ((Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h1)) + ((" ") + ((_$$0.h2) + (")")))); } };
let Lib_Types_Prelude_Show$20Lib_Types_Pattern = Prelude_MkShow(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(eta)));
let Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case 4: return _$$0.h0; case 3: return _$$0.h0; case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Elab_checkDone_rename$27 = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$17 ) => { if ((_$$17.tag) == (1)) { let sc$$25 = Prelude_eqString(_$$17.h1.h2, _10); switch (sc$$25) { case true: return { tag: 1,  h1: { tag: 0,  h2: _15,  h3: _$$17.h1.h3 },  h2: _$$17.h2 }; case false: return { tag: 1,  h1: { tag: 0,  h2: _$$17.h1.h2,  h3: _$$17.h1.h3 },  h2: Lib_Elab_checkDone_rename$27(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$17.h2) }; } } else { return { tag: 0 }; } };
let Lib_Types_CaseSplit = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_TopContext_addInfo = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, tc.h2.h2, tc.h2.h3, tc.h2.h4, tc.h2.h5, tc.h2.h6, { tag: 1,  h1: _$$0,  h2: tc.h2.h7 }), tc.h3, tc.h4, tc.h5)))));
let Lib_Elab_checkCase = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, _$$3.h3.h3), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_extendPi(_$$0, vty, { tag: 0 }, { tag: 0 }), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_tryError(Lib_Elab_unify($$sc.h2.h1, true, $$sc.h3.h2, _$$2)), ( $$sc1 ) => { if (($$sc1.tag) == (1)) { let sc$$32 = Lib_Elab_lookupDef(_$$0, _$$1); return ( (sc$$32.tag) == (0) ? ( (sc$$32.h1.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(sc$$32.h1.h1, _$$3.h2)) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(true) ) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(true) ); } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h2))) + (" because unify error ")) + (Lib_Error_errorMsg($$sc1.h2))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false))); } }))))));
let Lib_Elab_lookupDef = ( _$$0, _$$1 ) => (Lib_Elab_lookupDef_go(_$$0, _$$1, 0, _$$0.h2, _$$0.h1));
let Lib_Elab_lookupDef_go = ( _, _1, _$$3, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$51.tag) == (1)) { if ((_$$41.tag) == (1)) { let sc$$16 = Prelude_eqString(_$$41.h1.h2, _3); switch (sc$$16) { case true: return Prelude_Just(_$$51.h1); case false: { _ = _2; _1 = _3; _$$3 = (1) + (_$$31); _$$4 = _$$41.h2; _$$5 = _$$51.h2; continue; break; } } } else { return Prelude_Nothing(); } } else { return Prelude_Nothing(); } } };
let Lib_Elab_extendPi = ( _$$0, _$$1, _$$2, _$$3 ) => { if ((_$$1.tag) == (5)) { let nm = Lib_Elab_fresh(_$$0, _$$1.h1); let ctx$27 = Lib_Types_extend(_$$0, nm, _$$1.h4); let v = Lib_Types_VVar(Lib_Common_emptyFC, Prelude_length$27(_$$0.h1), { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: v,  h2: _$$1.h5.h0 }, _$$1.h5.h1), ( tyb ) => (Lib_Elab_extendPi(ctx$27, tyb, { tag: 1,  h1: _$$2,  h2: Lib_Elab_MkBind(nm, _$$1.h2, _$$1.h4) }, { tag: 1,  h1: _$$3,  h2: Lib_Types_VVar(_$$1.h0, Prelude_length$27(_$$0.h1), { tag: 0 }) }))); } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$0,  h3: { tag: 0,  h2: _$$1,  h3: { tag: 0,  h2: Prelude__$3C$3E$3E_(_$$2, { tag: 0 }),  h3: _$$3 } } }); } };
let Lib_Elab_MkBind = ( h0, h1, h2 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Elab_fresh = ( ctx$$0, _$$1 ) => ((_$$1) + (("$") + (Prelude_showInt(Prelude_length$27(ctx$$0.h1)))));
let Lib_Types_filterM = ( _$$1, _$$2 ) => (( (_$$2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(_$$1(_$$2.h1), ( check ) => { switch (check) { case true: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$3A$3A_(_$$2.h1, eta)), Lib_Types_filterM(_$$1, _$$2.h2)); case false: return Lib_Types_filterM(_$$1, _$$2.h2); } }) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }) ));
let Lib_Elab_getConstructors = ( _$$0, _$$1, _$$2 ) => (( (_$$2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_getConstructors_lookupTCon(_$$0, _$$1, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h1), ( $$sc ) => (Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_lookupDCon(eta)), $$sc))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_vprint(_$$0, _$$2), ( tms ) => (Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("Can't split - not VRef: ") + (tms)) + (""))), eta)))))) ));
let Lib_Elab_vprint = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(Prelude_length$27(_$$0.h1), _$$1), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0.h2), tm))), { tag: 0 })))));
let Lib_Elab_lookupDCon = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$2 = Lib_TopContext_lookup(_$$0, top); return ( (sc$$2.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("Internal Error: DCon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" not found"))), eta)))) : ( (sc$$2.h1.h3.tag) == (2) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: sc$$2.h1.h1,  h3: { tag: 0,  h2: Prelude_length$27(sc$$2.h1.h3.h2),  h3: sc$$2.h1.h2 } }) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("Internal Error: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" is not a DCon"))), eta)))) ) ); }));
let Lib_Elab_getConstructors_lookupTCon = ( _, _1, _2, _3, _4, _5, _$$7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$9 = Lib_TopContext_lookup(_4, top); return ( (sc$$9.tag) == (0) ? ( (sc$$9.h1.h3.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$9.h1.h3.h1) : Lib_Types_MkM(( _6 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_1, (("Not a type constructor: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_4))) + (""))), eta)))) ) : Lib_Types_MkM(( _6 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_1, (("Not a type constructor: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_4))) + (""))), eta)))) ); }));
let Lib_Elab_checkDone_rename = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _$$16 ) => { if ((_$$16.tag) == (1)) { let sc$$24 = Prelude_eqString(_$$16.h1.h2, _9); switch (sc$$24) { case true: return { tag: 1,  h1: { tag: 0,  h2: _14,  h3: _$$16.h1.h3 },  h2: _$$16.h2 }; case false: return { tag: 1,  h1: { tag: 0,  h2: _$$16.h1.h2,  h3: _$$16.h1.h3 },  h2: Lib_Elab_checkDone_rename(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _$$16.h2) }; } } else { return { tag: 0 }; } };
let Lib_Elab_checkDups = ( _$$0 ) => (( eta ) => (Lib_Elab_checkDups_go(_$$0, { tag: 0 }, eta)));
let Lib_Elab_checkDups_go = ( _, _$$2, _$$3 ) => { while (1) { let _1 = _; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { let sc$$10 = Prelude_elem(Prelude_Prelude_Eq$20Prim_String, _$$31.h1.h0, _$$21); switch (sc$$10) { case true: return Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_1, (("Duplicate name ") + (_$$31.h1.h0)) + (""))), eta)))); case false: { _ = _1; _$$2 = { tag: 1,  h1: _$$31.h1.h0,  h2: _$$21 }; _$$3 = _$$31.h2; continue; break; } } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } } };
let Prelude_Prelude_Eq$20Prim_String$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude_eqString(_$$0, _$$1));
let Prelude_Prelude_Eq$20Prim_String = Prelude_MkEq(( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prim_String$2C_$3D$3D_(eta, eta1))));
let Lib_Types_Prelude_Show$20Lib_Types_Constraint$2Cshow = ( _$$0 ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Pattern, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), { tag: 0,  h2: _$$0.h0,  h3: { tag: 0,  h2: _$$0.h1,  h3: _$$0.h2 } }));
let Lib_Types_Prelude_Show$20Lib_Types_Constraint = Prelude_MkShow(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Constraint$2Cshow(eta)));
let Lib_Elab_buildDefault = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { let defclauses = Prelude_filter(( eta ) => (Lib_Elab_isDefaultCase(_$$3, eta)), _$$1.h0); return ( (defclauses.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addInfo(Lib_Types_MissingCases(_$$2, _$$0, _$$4)), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addError(Lib_Error_E(_$$2, (("missing cases: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, _$$4))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_freshMeta(_$$0, _$$2, _$$1.h1, 3), ( hole ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_CaseDefault(hole)))))))) : Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseDefault(eta)), Lib_Elab_buildTree(_$$0, { tag: 0,  h0: defclauses,  h1: _$$1.h1 })) ); };
let Lib_TopContext_addError = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, tc.h2.h2, tc.h2.h3, tc.h2.h4, tc.h2.h5, { tag: 1,  h1: _$$0,  h2: tc.h2.h6 }, tc.h2.h7), tc.h3, tc.h4, tc.h5)))));
let Lib_Types_MissingCases = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Elab_isDefaultCase = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_find(( _$$11 ) => (Prelude_eqString(_$$0, _$$11.h0)), _$$1.h1); if ((sc$$2.tag) == (1)) { return true; } else { switch (sc$$2.h1.h1.tag) { case 2: return true; case 0: return true; default: return false; } } };
let Prelude_find = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let sc$$6 = _$$11(_$$21.h1); switch (sc$$6) { case true: return Prelude_Just(_$$21.h1); case false: { _$$1 = _$$11; _$$2 = _$$21.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Prelude_mapMaybe = ( _$$2, _$$3 ) => (Prelude_mapMaybe_go(_$$2, _$$3, { tag: 0 }, _$$3));
let Prelude_mapMaybe_go = ( _, _1, _$$5, _$$6 ) => { while (1) { let _2 = _; let _3 = _1; let _$$51 = _$$5; let _$$61 = _$$6; if ((_$$61.tag) == (1)) { let sc$$10 = _2(_$$61.h1); if ((sc$$10.tag) == (1)) { _ = _2; _1 = _3; _$$5 = _$$51; _$$6 = _$$61.h2; continue; } else { _ = _2; _1 = _3; _$$5 = { tag: 1,  h1: _$$51,  h2: sc$$10.h1 }; _$$6 = _$$61.h2; continue; } } else { return Prelude__$3C$3E$3E_(_$$51, { tag: 0 }); } } };
let Lib_Types_Prelude_Show$20Lib_Types_CaseAlt = Prelude_MkShow(Lib_Types_Prelude_Show$20Lib_Types_CaseAlt$2Cshow);
let Lib_Elab_buildCase = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((((("CASE ") + (_$$2)) + (" match ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" ty ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2), _$$4.h3.h3))), { tag: 0 }))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, _$$4.h3.h3), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_extendPi(_$$0, vty, { tag: 0 }, { tag: 0 }), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((((("unify dcon cod with scrut\n  ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc.h3.h2))) + ("\n  ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_catchError(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Just(eta)), Lib_Elab_unify($$sc.h2.h1, true, $$sc.h3.h2, _$$3)), ( err ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" because unify error ")) + (Lib_Error_errorMsg(err))) + (""))), ( _2 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))))), ( $$sc1 ) => (( ($$sc1.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("scrut ") + (_$$2)) + (" constrained to ")) + (Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, Lib_Elab_lookupDef(_$$0, _$$2)))) + (""))), ( _2 ) => { if ((_$$3.tag) == (1)) { let sc$$44 = Lib_Elab_lookupDef(_$$0, _$$2); if ((sc$$44.tag) == (0)) { if ((sc$$44.h1.tag) == (1)) { let sc$$50 = Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(sc$$44.h1.h1, _$$4.h2)); switch (sc$$50) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" because ")) + (_$$2)) + (" forced to ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$44.h1))) + (""))), ( _3 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((("case ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" dotted ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$44.h1))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Prelude_Prelude_Eq$20Prelude_Nat$2C_$3D$3D_(Prelude_length($$sc.h3.h3.h2), Data_SnocList_snoclen(sc$$44.h1.h2))), ( _4 ) => (Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (((("") + (Prelude_showInt(Prelude_natToInt(Prelude_length($$sc.h3.h3.h2))))) + (" vars /= ")) + (Prelude_showInt(Prelude_natToInt(Data_SnocList_snoclen(sc$$44.h1.h2))))) + (""))), eta)))))), ( _4 ) => { let lvl = (Prelude_length$27($$sc.h2.h1)) - (Prelude_length$27($$sc.h3.h3.h2)); let scons = Lib_Elab_buildCase_constrainSpine(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, lvl, Prelude__$3C$3E$3E_(sc$$44.h1.h2, { tag: 0 })); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_updateContext($$sc.h2, scons), ( ctx$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((((((("(dcon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" ty ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc.h3.h2))) + (" scty ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _6 ) => ((((("(dcon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (") (vars ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Elab_Prelude_Show$20Lib_Elab_Bind, $$sc.h3.h3.h2))) + (") clauses were"))), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$1.h0, ( x ) => (Lib_Types_log(2, ( _7 ) => ((("    ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow(x))) + (""))))), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_mapMaybe(( _$$11 ) => (_$$11), eta)), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_buildCase_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, _$$3.h1, $$sc.h3.h3.h2, eta)), _$$1.h0)), ( clauses ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _8 ) => ("and now:")), ( _8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, clauses, ( x ) => (Lib_Types_log(2, ( _9 ) => ((("    ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow(x))) + (""))))), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(clauses), 0), ( _10 ) => (Lib_Types_MkM(( _11 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (((("Missing case for ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" splitting ")) + (_$$2)) + (""))), eta)))))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: _$$1.h1 }), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(Lib_Types_CaseCons(_$$4.h2, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Elab_buildCase_getName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, eta)), $$sc.h3.h3.h2), tm))))))))))))))))))))); }))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_tryError(Lib_Elab_unify($$sc.h2.h1, true, $$sc.h3.h2, _$$3)), ( $$sc2 ) => { if (($$sc2.tag) == (1)) { let sc$$52 = Prelude_findIndex$27(( _$$5 ) => (Prelude_eqString(_$$2, _$$5.h2)), $$sc.h2.h2); if ((sc$$52.tag) == (1)) { return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (("") + (_$$2)) + (" not is scope?"))), eta)))); } else { let lvl = ((Prelude_length$27($$sc.h2.h1)) - (sc$$52.h1)) - (1); let scon = { tag: 0,  h2: lvl,  h3: Lib_Types_VRef(_$$0.h4, _$$4.h2, $$sc.h3.h3.h3) }; return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("scty ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((("UNIFY results ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), $$sc2.h2.h0))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("before types: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), $$sc.h2.h2))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _6 ) => ((("before env: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, $$sc.h2.h1))) + (""))), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _7 ) => ((("SC CONSTRAINT: ") + (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val, scon))) + (""))), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_updateContext($$sc.h2, { tag: 1,  h1: scon,  h2: $$sc2.h2.h0 }), ( ctx$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _8 ) => ((("context types: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), ctx$27.h2))) + (""))), ( _8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _9 ) => ((("context env: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, ctx$27.h1))) + (""))), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _10 ) => ((((((("(dcon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" ty ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc.h3.h2))) + (" scty ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _11 ) => ((((("(dcon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (") (vars ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Elab_Prelude_Show$20Lib_Elab_Bind, $$sc.h3.h3.h2))) + (") clauses were"))), ( _11 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$1.h0, ( x ) => (Lib_Types_log(2, ( _12 ) => ((("    ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow(x))) + (""))))), ( _12 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_mapMaybe(( _$$11 ) => (_$$11), eta)), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_buildCase_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, _$$3.h1, $$sc.h3.h3.h2, eta)), _$$1.h0)), ( clauses ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _13 ) => ("and now:")), ( _13 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, clauses, ( x ) => (Lib_Types_log(2, ( _14 ) => ((("    ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow(x))) + (""))))), ( _14 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(clauses), 0), ( _15 ) => (Lib_Types_MkM(( _16 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (((("Missing case for ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" splitting ")) + (_$$2)) + (""))), eta)))))), ( _15 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: _$$1.h1 }), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(Lib_Types_CaseCons(_$$4.h2, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Elab_buildCase_getName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, eta)), $$sc.h3.h3.h2), tm))))))))))))))))))))))))))))))))))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" because unify error ")) + (Lib_Error_errorMsg($$sc2.h2))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" because unify error ")) + (Lib_Error_errorMsg($$sc2.h2))) + (""))), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))))); } }); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_tryError(Lib_Elab_unify($$sc.h2.h1, true, $$sc.h3.h2, _$$3)), ( $$sc2 ) => { if (($$sc2.tag) == (1)) { let sc$$50 = Prelude_findIndex$27(( _$$5 ) => (Prelude_eqString(_$$2, _$$5.h2)), $$sc.h2.h2); if ((sc$$50.tag) == (1)) { return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (("") + (_$$2)) + (" not is scope?"))), eta)))); } else { let lvl = ((Prelude_length$27($$sc.h2.h1)) - (sc$$50.h1)) - (1); let scon = { tag: 0,  h2: lvl,  h3: Lib_Types_VRef(_$$0.h4, _$$4.h2, $$sc.h3.h3.h3) }; return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("scty ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((("UNIFY results ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), $$sc2.h2.h0))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("before types: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), $$sc.h2.h2))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _6 ) => ((("before env: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, $$sc.h2.h1))) + (""))), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _7 ) => ((("SC CONSTRAINT: ") + (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val, scon))) + (""))), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_updateContext($$sc.h2, { tag: 1,  h1: scon,  h2: $$sc2.h2.h0 }), ( ctx$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _8 ) => ((("context types: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_MkShow(( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val, eta))), ctx$27.h2))) + (""))), ( _8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _9 ) => ((("context env: ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, ctx$27.h1))) + (""))), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _10 ) => ((((((("(dcon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" ty ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$sc.h3.h2))) + (" scty ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _11 ) => ((((("(dcon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (") (vars ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Elab_Prelude_Show$20Lib_Elab_Bind, $$sc.h3.h3.h2))) + (") clauses were"))), ( _11 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$1.h0, ( x ) => (Lib_Types_log(2, ( _12 ) => ((("    ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow(x))) + (""))))), ( _12 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_mapMaybe(( _$$11 ) => (_$$11), eta)), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_buildCase_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, _$$3.h1, $$sc.h3.h3.h2, eta)), _$$1.h0)), ( clauses ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _13 ) => ("and now:")), ( _13 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, clauses, ( x ) => (Lib_Types_log(2, ( _14 ) => ((("    ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow(x))) + (""))))), ( _14 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(clauses), 0), ( _15 ) => (Lib_Types_MkM(( _16 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (((("Missing case for ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" splitting ")) + (_$$2)) + (""))), eta)))))), ( _15 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: _$$1.h1 }), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(Lib_Types_CaseCons(_$$4.h2, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Elab_buildCase_getName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h3.h0, _$$4.h3.h1, _$$4.h3.h2, _$$4.h3.h3, eta)), $$sc.h3.h3.h2), tm))))))))))))))))))))))))))))))))))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" because unify error ")) + (Lib_Error_errorMsg($$sc2.h2))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((((("SKIP ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h2))) + (" because unify error ")) + (Lib_Error_errorMsg($$sc2.h2))) + (""))), ( _4 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()))))); } }); } } else { return Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$3), (("case split on non-inductive ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$3))) + (""))), eta)))); } }) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()) ))))))))))));
let Lib_Elab_buildCase_getName = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$15 ) => (_$$15.h0);
let Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow = ( _$$0 ) => ((Prelude_joinBy(" ", { tag: 1,  h1: "(MkClause",  h2: { tag: 1,  h1: Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0.h0),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Constraint, _$$0.h1),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Pattern, _$$0.h2),  h2: { tag: 1,  h1: Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, _$$0.h3),  h2: { tag: 0 } } } } } })) + (")"));
let Lib_Elab_buildCase_rewriteClause = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$18, _$$19, _$$20 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_rewriteConstraint(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$18, _$$19, _$$20.h1, { tag: 0 }), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(Lib_Syntax_MkClause(_$$20.h0, $$sc.h1, _$$20.h2, _$$20.h3))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()) ))));
let Lib_Syntax_MkClause = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Elab_buildCase_rewriteConstraint = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$17, _$$18, _$$19, _$$20 ) => { while (1) { let _13 = _; let _14 = _1; let _15 = _2; let _16 = _3; let _17 = _4; let _18 = _5; let _19 = _6; let _20 = _7; let _21 = _8; let _22 = _9; let _23 = _10; let _24 = _11; let _25 = _12; let _$$171 = _$$17; let _$$181 = _$$18; let _$$191 = _$$19; let _$$201 = _$$20; if ((_$$191.tag) == (1)) { let sc$$27 = Prelude_eqString(_$$191.h1.h0, _15); switch (sc$$27) { case true: switch (_$$191.h1.h1.tag) { case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just({ tag: 1,  h1: _$$191.h1,  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$191.h2, _$$201) })); case 3: return Lib_Types_MkM(( _26 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$191.h1.h1.h0, (("Literal ") + (Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$191.h1.h1.h1))) + (" in constructor split"))), eta)))); case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just({ tag: 1,  h1: _$$191.h1,  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$191.h2, _$$201) })); case 1: { let sc$$34 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$191.h1.h1.h2, _20); switch (sc$$34) { case true: return ( (_$$191.h1.h1.h4.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _$$191.h1.h1.h0, _$$181, _$$191.h1.h1.h3), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(rest, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$191.h2, _$$201)))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _$$191.h1.h1.h0, _$$181, _$$191.h1.h1.h3), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just({ tag: 1,  h1: Lib_Types_PC(_15, Lib_Types_PatVar(_$$191.h1.h1.h0, _$$191.h1.h1.h1, _$$191.h1.h1.h4.h1), _$$191.h1.h2),  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(rest, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$191.h2, _$$201)) })))) ); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$36 = Lib_TopContext_lookup(_$$191.h1.h1.h2, top); if ((sc$$36.tag) == (1)) { return Lib_Types_MkM(( _26 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$191.h1.h1.h0, (("Internal Error: DCon ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$191.h1.h1.h2))) + (" not found"))), eta)))); } else { if ((sc$$36.h1.h3.tag) == (2)) { let sc$$48 = Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(sc$$36.h1.h3.h3, _$$171)); switch (sc$$48) { case true: return Lib_Types_MkM(( _26 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$191.h1.h1.h0, (((("Constructor is a ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$36.h1.h3.h3))) + (" expected a ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$171))) + (""))), eta)))); case false: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); } } else { return Lib_Types_MkM(( _26 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$191.h1.h1.h0, (("Internal Error: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$191.h1.h1.h2))) + (" is not a DCon"))), eta)))); } } }); } break; } case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just({ tag: 1,  h1: _$$191.h1,  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$191.h2, _$$201) })); } break; case false: { _ = _13; _1 = _14; _2 = _15; _3 = _16; _4 = _17; _5 = _18; _6 = _19; _7 = _20; _8 = _21; _9 = _22; _10 = _23; _11 = _24; _12 = _25; _$$17 = _$$171; _$$18 = _$$181; _$$19 = _$$191.h2; _$$20 = { tag: 1,  h1: _$$191.h1,  h2: _$$201 }; continue; break; } } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(_$$201)); } } };
let Lib_Types_PatVar = ( h0, h1, h2 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_PC = ( h0, h1, h2 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Elab_buildCase_makeConstr = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$16, _$$17, _$$18 ) => { if ((_$$18.tag) == (1)) { if ((_$$17.tag) == (1)) { switch (_$$17.h1.h1) { case 1: { let sc$$28 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(Lib_Types_getIcit(_$$18.h1), 1); switch (sc$$28) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$16, _$$17.h2, _$$18.h2), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: Lib_Types_PC(_$$17.h1.h0, _$$18.h1, _$$17.h1.h2),  h2: rest }))); case false: return Lib_Types_MkM(( _13 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_.h4, (("mismatch between Explicit and ") + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(Lib_Types_getIcit(_$$18.h1)))) + (""))), eta)))); } break; } default: { let sc$$28 = Prelude_not(Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(Lib_Types_getIcit(_$$18.h1), _$$17.h1.h1)); switch (sc$$28) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$16, _$$17.h2, { tag: 1,  h1: _$$18.h1,  h2: _$$18.h2 }), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: Lib_Types_PC(_$$17.h1.h0, Lib_Types_PatWild(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(_$$18.h1), _$$17.h1.h1), _$$17.h1.h2),  h2: rest }))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$16, _$$17.h2, _$$18.h2), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: Lib_Types_PC(_$$17.h1.h0, _$$18.h1, _$$17.h1.h2),  h2: rest }))); } break; } } } else { return Lib_Types_MkM(( _13 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Pattern$2CgetFC(_$$18.h1), "too many patterns")), eta)))); } } else { if ((_$$17.tag) == (1)) { switch (_$$17.h1.h1) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$16, _$$17.h2, { tag: 0 }), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: Lib_Types_PC(_$$17.h1.h0, Lib_Types_PatWild(Lib_Common_emptyFC, 2), _$$17.h1.h2),  h2: rest }))); case 1: return Lib_Types_MkM(( _13 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$16, "not enough patterns")), eta)))); case 0: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildCase_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$16, _$$17.h2, { tag: 0 }), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: Lib_Types_PC(_$$17.h1.h0, Lib_Types_PatWild(Lib_Common_emptyFC, 0), _$$17.h1.h2),  h2: rest }))); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }); } } };
let Lib_Types_PatWild = ( h0, h1 ) => ({ tag: 2,  h0: h0,  h1: h1 });
let Lib_Types_getIcit = ( _$$0 ) => { switch (_$$0.tag) { case 4: return 1; case 3: return 1; case 2: return _$$0.h1; case 1: return _$$0.h1; case 0: return _$$0.h1; } };
let Lib_Elab_Prelude_Show$20Lib_Elab_Bind$2Cshow = ( _$$0 ) => ((((("") + (_$$0.h0)) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h1))) + (""));
let Lib_Elab_Prelude_Show$20Lib_Elab_Bind = Prelude_MkShow(( eta ) => (Lib_Elab_Prelude_Show$20Lib_Elab_Bind$2Cshow(eta)));
let Lib_Elab_updateContext = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$11.tag) == (1)) { let sc$$11 = Lib_Elab_updateContext_isSelf(_$$01, _$$11, _$$11.h0, _$$11.h1, _$$11.h2, _$$11.h1.h0, _$$11.h1.h1, _$$11.h1.h2, _$$11.h1.h3, _$$11.h1.h2, _$$11.h1.h3); switch (sc$$11) { case true: { _$$0 = _$$01; _$$1 = _$$11.h2; continue; break; } case false: { let ix = Prelude_intToNat(((Prelude_length$27(_$$01.h1)) - (_$$11.h1.h2)) - (1)); let sc$$13 = Prelude_getAt(ix, _$$01.h1); if ((sc$$13.tag) == (1)) { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC(_$$11.h1.h3), "INTERNAL ERROR: bad index in updateContext")), eta)))); } else { if ((sc$$13.h1.tag) == (0)) { if ((sc$$13.h1.h2.tag) == (0)) { let sc$$20 = Prelude_not(Prelude_eqInt(sc$$13.h1.h1, _$$11.h1.h2)); switch (sc$$20) { case true: { _$$0 = _$$01; _$$1 = { tag: 1,  h1: { tag: 0,  h2: sc$$13.h1.h1,  h3: _$$11.h1.h3 },  h2: _$$11.h2 }; continue; break; } case false: { let ctx$27 = Lib_Types_MkCtx(_$$01.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Elab_substVal(_$$11.h1.h2, _$$11.h1.h3, eta)), _$$01.h1), _$$01.h2, Lib_Elab_updateContext_replaceV(_$$01, _$$11, _$$11.h0, _$$11.h1, _$$11.h2, _$$11.h1.h0, _$$11.h1.h1, _$$11.h1.h2, _$$11.h1.h3, ix, true, _$$01.h3), _$$01.h4); _$$0 = ctx$27; _$$1 = _$$11.h2; continue; break; } } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_info(Lib_Types_getValFC(_$$11.h1.h3), (((("need to unify ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$11.h1.h3))) + (" and ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$13.h1))) + (" or something")), ( _ ) => (Lib_Elab_updateContext(_$$01, _$$11.h2))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_info(Lib_Types_getValFC(_$$11.h1.h3), (((("need to unify ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$11.h1.h3))) + (" and ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(sc$$13.h1))) + (" or something")), ( _ ) => (Lib_Elab_updateContext(_$$01, _$$11.h2))); } } break; } } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$01); } } };
let Lib_Types_info = ( _$$0, _$$1 ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((((("INFO at ") + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$0))) + (": ")) + (_$$1)) + (""))));
let Lib_Elab_updateContext_replaceV = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$12, _$$13, _$$14 ) => { if ((_$$14.tag) == (1)) { switch (_$$12) { case 0: return { tag: 1,  h1: _$$13,  h2: _$$14.h2 }; default: { let x = (_$$12) - (1); return { tag: 1,  h1: _$$14.h1,  h2: Lib_Elab_updateContext_replaceV(_, _1, _2, _3, _4, _5, _6, _7, _8, x, _$$13, _$$14.h2) }; break; } } } else { return { tag: 0 }; } };
let Lib_Elab_substVal = ( _$$0, _$$1, _$$2 ) => (Lib_Elab_substVal_go(_$$0, _$$1, _$$2, _$$2));
let Lib_Elab_substVal_go = ( _, _1, _2, _$$4 ) => { switch (_$$4.tag) { case 5: return Lib_Types_VPi(_$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, Lib_Elab_substVal_go(_, _1, _2, _$$4.h4), _$$4.h5); case 3: return Lib_Types_VMeta(_$$4.h0, _$$4.h1, Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap(( eta ) => (Lib_Elab_substVal_go(_, _1, _2, eta)), _$$4.h2)); case 1: return Lib_Types_VRef(_$$4.h0, _$$4.h1, Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap(( eta ) => (Lib_Elab_substVal_go(_, _1, _2, eta)), _$$4.h2)); case 0: { let sc$$8 = Prelude_eqInt(_$$4.h1, _); switch (sc$$8) { case true: return _1; case false: return Lib_Types_VVar(_$$4.h0, _$$4.h1, Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap(( eta ) => (Lib_Elab_substVal_go(_, _1, _2, eta)), _$$4.h2)); } break; } default: return _$$4; } };
let Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap = ( _$$2, _$$3 ) => (( (_$$3.tag) == (1) ? { tag: 1,  h1: Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap(_$$2, _$$3.h1),  h2: _$$2(_$$3.h2) } : { tag: 0 } ));
let Lib_Elab_updateContext_isSelf = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11 ) => (( (_$$11.tag) == (0) ? ( (_$$11.h2.tag) == (0) ? Prelude_eqInt(_$$10, _$$11.h1) : false ) : false ));
let Lib_Elab_buildCase_constrainSpine = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$14, _$$15 ) => (( (_$$15.tag) == (1) ? { tag: 1,  h1: { tag: 0,  h2: _$$14,  h3: _$$15.h1 },  h2: Lib_Elab_buildCase_constrainSpine(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, (1) + (_$$14), _$$15.h2) } : { tag: 0 } ));
let Lib_Types_Prelude_Show$20Lib_Types_Tm = Prelude_MkShow(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(eta)));
let Lib_Common_Prelude_Eq$20Lib_Common_QName = Prelude_MkEq(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(eta, eta1))));
let Prelude_partition = ( _$$1, _$$2 ) => (Prelude_partition_go(_$$1, _$$2, _$$2, { tag: 0 }, { tag: 0 }));
let Prelude_partition_go = ( _, _1, _$$4, _$$5, _$$6 ) => { while (1) { let _2 = _; let _3 = _1; let _$$41 = _$$4; let _$$51 = _$$5; let _$$61 = _$$6; if ((_$$41.tag) == (1)) { let sc$$10 = _2(_$$41.h1); switch (sc$$10) { case true: { _ = _2; _1 = _3; _$$4 = _$$41.h2; _$$5 = { tag: 1,  h1: _$$41.h1,  h2: _$$51 }; _$$6 = _$$61; continue; break; } case false: { _ = _2; _1 = _3; _$$4 = _$$41.h2; _$$5 = _$$51; _$$6 = { tag: 1,  h1: _$$41.h1,  h2: _$$61 }; continue; break; } } } else { return { tag: 0,  h2: _$$51,  h3: _$$61 }; } } };
let Lib_Elab_matchedConstructors = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$11.tag) == (1)) { let sc$$9 = Prelude_find(( _$$12 ) => (Prelude_eqString(_$$01, _$$12.h0)), _$$11.h1.h1); if ((sc$$9.tag) == (0)) { if ((sc$$9.h1.h1.tag) == (1)) { return { tag: 1,  h1: { tag: 0,  h2: sc$$9.h1.h1.h0,  h3: sc$$9.h1.h1.h2 },  h2: Lib_Elab_matchedConstructors(_$$01, _$$11.h2) }; } else { _$$0 = _$$01; _$$1 = _$$11.h2; continue; } } else { _$$0 = _$$01; _$$1 = _$$11.h2; continue; } } else { return { tag: 0 }; } } };
let Lib_Elab_buildLitCases = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_nub(Lib_Types_Prelude_Eq$20Lib_Types_Literal, eta)), Lib_Elab_getLits(_$$4, _$$3, _$$1.h0)), ( lits ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_buildLitCase(_$$0, _$$1, _$$2, _$$3, _$$4, eta)), lits), ( alts ) => { let defclauses = Prelude_filter(( eta ) => (Lib_Elab_isDefaultCase(_$$3, eta)), _$$1.h0); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(defclauses), 0), ( _ ) => (Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$2, (("no default for literal slot on ") + (_$$3)) + (""))), eta)))))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(_$$0, { tag: 0,  h0: defclauses,  h1: _$$1.h1 }), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(alts, { tag: 1,  h1: Lib_Types_CaseDefault(tm),  h2: { tag: 0 } })))))); }))));
let Lib_Elab_buildLitCase = ( _$$0, _$$1, _$$2, _$$3, _$$4, _$$5 ) => { let sc$$8 = Prelude_findIndex$27(( _$$51 ) => (Prelude_eqString(_$$3, _$$51.h2)), _$$0.h2); if ((sc$$8.tag) == (1)) { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (("") + (_$$3)) + (" not is scope?"))), eta)))); } else { let lvl = ((Prelude_length$27(_$$0.h1)) - (sc$$8.h1)) - (1); let scon = { tag: 0,  h2: lvl,  h3: Lib_Types_VLit(_$$2, _$$5) }; return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_updateContext(_$$0, { tag: 1,  h1: scon,  h2: { tag: 0 } }), ( ctx$27 ) => { let clauses = Prelude_mapMaybe(( eta ) => (Lib_Elab_buildLitCase_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$5, eta)), _$$1.h0); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_eqInt(Prelude_length$27(clauses), 0), ( _ ) => (Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h4, (((("Missing case for ") + (Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow(_$$5))) + (" splitting ")) + (_$$3)) + (""))), eta)))))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(ctx$27, { tag: 0,  h0: clauses,  h1: _$$1.h1 }), ( tm ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_CaseLit(_$$5, tm)))))); }); } };
let Lib_Elab_buildLitCase_rewriteClause = ( _, _1, _2, _3, _4, _5, _$$8 ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Lib_Elab_buildLitCase_rewriteConstraint(_, _1, _2, _3, _4, _5, _$$8.h1, { tag: 0 }), ( cons ) => (Prelude_Just(Lib_Syntax_MkClause(_$$8.h0, cons, _$$8.h2, _$$8.h3)))));
let Lib_Elab_buildLitCase_rewriteConstraint = ( _, _1, _2, _3, _4, _5, _$$7, _$$8 ) => { while (1) { let _6 = _; let _7 = _1; let _8 = _2; let _9 = _3; let _10 = _4; let _11 = _5; let _$$71 = _$$7; let _$$81 = _$$8; if ((_$$71.tag) == (1)) { let sc$$15 = Prelude_eqString(_$$71.h1.h0, _9); switch (sc$$15) { case true: switch (_$$71.h1.h1.tag) { case 4: return Prelude_Just({ tag: 1,  h1: _$$71.h1,  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$71.h2, _$$81) }); case 3: { let sc$$19 = Lib_Types_Prelude_Eq$20Lib_Types_Literal$2C_$3D$3D_(_$$71.h1.h1.h1, _11); switch (sc$$19) { case true: return Prelude_Just(Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$71.h2, _$$81)); case false: return Prelude_Nothing(); } break; } case 2: return Prelude_Just({ tag: 1,  h1: _$$71.h1,  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$71.h2, _$$81) }); case 1: return Prelude_Nothing(); case 0: return Prelude_Just({ tag: 1,  h1: _$$71.h1,  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$71.h2, _$$81) }); } break; case false: { _ = _6; _1 = _7; _2 = _8; _3 = _9; _4 = _10; _5 = _11; _$$7 = _$$71.h2; _$$8 = { tag: 1,  h1: _$$71.h1,  h2: _$$81 }; continue; break; } } } else { return Prelude_Just(_$$81); } } };
let Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind = ( _$$2, _$$3 ) => (( (_$$2.tag) == (1) ? Prelude_Nothing() : _$$3(_$$2.h1) ));
let Lib_Elab_getLits = ( _$$0, _$$1, _$$2 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let sc$$10 = Prelude_find(( _$$12 ) => (Prelude_eqString(_$$11, _$$12.h0)), _$$21.h1.h1); if ((sc$$10.tag) == (0)) { switch (sc$$10.h1.h1.tag) { case 3: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$3A$3A_(sc$$10.h1.h1.h1, eta)), Lib_Elab_getLits(_$$01, _$$11, _$$21.h2)); case 1: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$10.h1.h1.h0, (("expected ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$01))) + (""))), eta)))); default: { _$$0 = _$$01; _$$1 = _$$11; _$$2 = _$$21.h2; continue; break; } } } else { _$$0 = _$$01; _$$1 = _$$11; _$$2 = _$$21.h2; continue; } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }); } } };
let Lib_Types_Prelude_Eq$20Lib_Types_Literal = Prelude_MkEq(( eta ) => (( eta1 ) => (Lib_Types_Prelude_Eq$20Lib_Types_Literal$2C_$3D$3D_(eta, eta1))));
let Prelude_nub = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let sc$$6 = Prelude_elem(_$$11, _$$21.h1, _$$21.h2); switch (sc$$6) { case true: { _$$1 = _$$11; _$$2 = _$$21.h2; continue; break; } case false: return { tag: 1,  h1: _$$21.h1,  h2: Prelude_nub(_$$11, _$$21.h2) }; } } else { return { tag: 0 }; } } };
let Lib_Elab_litTyName = ( _$$0 ) => { switch (_$$0.tag) { case 3: return Lib_Elab_boolType; case 2: return Lib_Elab_charType; case 1: return Lib_Elab_intType; case 0: return Lib_Elab_stringType; } };
let Lib_Elab_boolType = { tag: 0,  h0: Lib_Common_primNS,  h1: "Bool" };
let Lib_Elab_solveAutos_run = ( _$$2 ) => (( (_$$2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_trySolveAuto(_$$2.h1), ( res ) => { switch (res) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(true); case false: return Lib_Elab_solveAutos_run(_$$2.h2); } }) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(false) ));
let Lib_Elab_solveAutos_isAuto = ( _$$1 ) => { if ((_$$1.tag) == (0)) { switch (_$$1.h4) { case 2: return true; default: return false; } } else { return false; } };
let Lib_Elab_solveAutos = Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let autos = Prelude_filter(( eta ) => (Lib_Elab_solveAutos_isAuto(eta)), Prelude_mapMaybe(( _$$5 ) => (Data_SortedMap_lookupMap$27(_$$5, top.h2.h3.h0)), top.h2.h3.h1)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solveAutos_run(autos), ( res ) => { switch (res) { case true: return Lib_Elab_solveAutos; case false: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } }); });
let Lib_Elab_lookupName = ( _$$0, _$$1 ) => (Lib_Elab_lookupName_go(_$$0, _$$1, 0, _$$0.h2));
let Lib_Elab_lookupName_go = ( _, _1, _$$3, _$$4 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$41.tag) == (1)) { let sc$$12 = Prelude_eqString(_$$41.h1.h2, _3); switch (sc$$12) { case true: return Prelude_Just({ tag: 0,  h2: Lib_Types_Bnd(Lib_Common_emptyFC, _$$31),  h3: _$$41.h1.h3 }); case false: { _ = _2; _1 = _3; _$$3 = (1) + (_$$31); _$$4 = _$$41.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_Elab_findSplit = ( _$$0 ) => { while (1) { let _$$01 = _$$0; if ((_$$01.tag) == (1)) { switch (_$$01.h1.h1.tag) { case 3: return Prelude_Just(_$$01.h1); case 1: return Prelude_Just(_$$01.h1); default: { _$$0 = _$$01.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_Elab_introClause = ( _$$0, _$$1, _$$2, _$$3 ) => { if ((_$$3.h2.tag) == (1)) { let sc$$11 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(_$$1, Lib_Types_getIcit(_$$3.h2.h1)); switch (sc$$11) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(_$$3.h0, { tag: 1,  h1: Lib_Types_PC(_$$0, _$$3.h2.h1, _$$2),  h2: _$$3.h1 }, _$$3.h2.h2, _$$3.h3)); case false: { let sc$$12 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(_$$1, 0); switch (sc$$12) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(_$$3.h0, { tag: 1,  h1: Lib_Types_PC(_$$0, Lib_Types_PatWild(_$$3.h0, 0), _$$2),  h2: _$$3.h1 }, { tag: 1,  h1: _$$3.h2.h1,  h2: _$$3.h2.h2 }, _$$3.h3)); case false: { let sc$$13 = Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(_$$1, 2); switch (sc$$13) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(_$$3.h0, { tag: 1,  h1: Lib_Types_PC(_$$0, Lib_Types_PatWild(_$$3.h0, 2), _$$2),  h2: _$$3.h1 }, { tag: 1,  h1: _$$3.h2.h1,  h2: _$$3.h2.h2 }, _$$3.h3)); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$3.h0, (((((("Explicit arg and ") + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(Lib_Types_getIcit(_$$3.h2.h1)))) + (" pattern ")) + (_$$0)) + ("  ")) + (Lib_Types_Prelude_Show$20Lib_Types_Pattern$2Cshow(_$$3.h2.h1))) + (""))), eta)))); } break; } } break; } } } else { switch (_$$1) { case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(_$$3.h0, { tag: 1,  h1: Lib_Types_PC(_$$0, Lib_Types_PatWild(_$$3.h0, 2), _$$2),  h2: _$$3.h1 }, { tag: 0 }, _$$3.h3)); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(_$$3.h0, { tag: 1,  h1: Lib_Types_PC(_$$0, Lib_Types_PatWild(_$$3.h0, 0), _$$2),  h2: _$$3.h1 }, { tag: 0 }, _$$3.h3)); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$3.h0, "Clause size doesn't match")), eta)))); } } };
let Lib_Elab_mkPat = ( _$$0 ) => (( (_$$0.h2.tag) == (14) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_mkPat({ tag: 0,  h2: _$$0.h2.h2,  h3: _$$0.h3 }), ( pat ) => (( (pat.tag) == (1) ? ( (pat.h4.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatCon(pat.h0, pat.h1, pat.h2, pat.h3, Prelude_Just(_$$0.h2.h1))) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(pat.h0, (("Double as pattern ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2.h2))) + (""))), eta)))) ) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0.h2.h0, (("Can't put as on non-constructor ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$0.h2.h2))) + (""))), eta)))) ))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$6 = Lib_Elab_splitArgs(_$$0.h2, { tag: 0 }); switch (sc$$6.h2.tag) { case 9: return ( (sc$$6.h3.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatWild(sc$$6.h2.h0, _$$0.h3)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$6.h2.h0, "implicit pat can't be applied to arguments")), eta)))) ); case 7: return ( (sc$$6.h3.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatLit(sc$$6.h2.h0, sc$$6.h2.h1)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$6.h2.h0, "lit cannot be applied to arguments")), eta)))) ); case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatImpossible(sc$$6.h2.h0)); case 0: { let sc$$13 = Lib_TopContext_lookupRaw(sc$$6.h2.h1, top); if ((sc$$13.tag) == (0)) { if ((sc$$13.h1.h3.tag) == (2)) { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_mkPat(eta)), sc$$6.h3), ( bpat ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatCon(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$0.h2), _$$0.h3, sc$$13.h1.h1, bpat, Prelude_Nothing())))); } else { let sc$$21 = Prelude_isUpper(Prelude_strIndex(sc$$6.h2.h1, 0)); switch (sc$$21) { case true: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$0.h2), (("") + (sc$$6.h2.h1)) + (" not in scope"))), eta)))); case false: return ( (sc$$6.h3.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatVar(sc$$6.h2.h0, _$$0.h3, sc$$6.h2.h1)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$0.h2), "patvar applied to args")), eta)))) ); } } } else { let sc$$14 = Prelude_isUpper(Prelude_strIndex(sc$$6.h2.h1, 0)); switch (sc$$14) { case true: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$0.h2), (("") + (sc$$6.h2.h1)) + (" not in scope"))), eta)))); case false: return ( (sc$$6.h3.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_PatVar(sc$$6.h2.h0, _$$0.h3, sc$$6.h2.h1)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$0.h2), "patvar applied to args")), eta)))) ); } } break; } default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$6.h2), (("expected pat var or constructor, got ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(sc$$6.h2))) + (""))), eta)))); } }) ));
let Prelude_strIndex = (s, ix) => s[ix];
let Prelude_isUpper = ( _$$0 ) => { let o = Prelude_ord(_$$0); return ((Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(64, o), 0)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(o, 91), 0))) || ((Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(912, o), 0)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(o, 938), 0))); };
let Prelude__$26$26_ = ( _$$0, _$$1 ) => { switch (_$$0) { case true: return _$$1; case false: return false; } };
let Lib_Types_PatCon = ( h0, h1, h2, h3, h4 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Types_PatImpossible = ( h0 ) => ({ tag: 4,  h0: h0 });
let Lib_Types_PatLit = ( h0, h1 ) => ({ tag: 3,  h0: h0,  h1: h1 });
let Lib_Elab_splitArgs = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$01.tag) == (2)) { _$$0 = _$$01.h1; _$$1 = { tag: 1,  h1: { tag: 0,  h2: _$$01.h2,  h3: _$$01.h3 },  h2: _$$11 }; continue; } else { return { tag: 0,  h2: _$$01,  h3: _$$11 }; } } };
let Lib_Elab_undo = ( _$$0 ) => { if ((_$$0.tag) == (1)) { switch (_$$0.h1.tag) { case 2: return ( (_$$0.h2.tag) == (0) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_DoStmt$2CgetFC(_$$0.h1), "do block must end in expression")), eta)))) : ( (_$$0.h1.h1.tag) == (0) ? ( (_$$0.h1.h3.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$12 = Lib_TopContext_lookupRaw(_$$0.h1.h1.h1, top); return ( (sc$$12.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_undo(_$$0.h2), ( xs$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "_>>=_"), _$$0.h1.h2, 1), Lib_Syntax_RLam(_$$0.h1.h0, Lib_Types_BI(_$$0.h1.h1.h0, _$$0.h1.h1.h1, 1, true), xs$27), 1)))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_undo(_$$0.h2), ( xs$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RCase(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "$sc"), Prelude_Nothing(), { tag: 1,  h1: { tag: 0,  h0: _$$0.h1.h1,  h1: Prelude_Just(xs$27) },  h2: { tag: 0 } })), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "_>>=_"), _$$0.h1.h2, 1), Lib_Syntax_RLam(_$$0.h1.h0, Lib_Types_BI(_$$0.h1.h0, "$sc", 1, true), rest), 1)))))) ); }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_undo(_$$0.h2), ( xs$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RCase(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "$sc"), Prelude_Nothing(), { tag: 1,  h1: { tag: 0,  h0: _$$0.h1.h1,  h1: Prelude_Just(xs$27) },  h2: _$$0.h1.h3 })), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "_>>=_"), _$$0.h1.h2, 1), Lib_Syntax_RLam(_$$0.h1.h0, Lib_Types_BI(_$$0.h1.h0, "$sc", 1, true), rest), 1)))))) ) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_undo(_$$0.h2), ( xs$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RCase(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "$sc"), Prelude_Nothing(), { tag: 1,  h1: { tag: 0,  h0: _$$0.h1.h1,  h1: Prelude_Just(xs$27) },  h2: _$$0.h1.h3 })), ( rest ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "_>>=_"), _$$0.h1.h2, 1), Lib_Syntax_RLam(_$$0.h1.h0, Lib_Types_BI(_$$0.h1.h0, "$sc", 1, true), rest), 1)))))) ) ); case 1: return ( (_$$0.h2.tag) == (0) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_DoStmt$2CgetFC(_$$0.h1), "do block must end in expression")), eta)))) : Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Syntax_RLet(_$$0.h1.h0, _$$0.h1.h1, Lib_Syntax_RImplicit(_$$0.h1.h0), _$$0.h1.h2, eta)), Lib_Elab_undo(_$$0.h2)) ); case 0: return ( (_$$0.h2.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0.h1.h1) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_undo(_$$0.h2), ( xs$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RApp(_$$0.h1.h0, Lib_Syntax_RVar(_$$0.h1.h0, "bind"), _$$0.h1.h1, 1), Lib_Syntax_RLam(_$$0.h1.h0, Lib_Types_BI(_$$0.h1.h0, "_", 1, true), xs$27), 1)))) ); } } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "do block must end in expression")), eta)))); } };
let Lib_Types_BI = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Syntax_RLam = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Syntax_RApp = ( h0, h1, h2, h3 ) => ({ tag: 2,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Syntax_RImplicit = ( h0 ) => ({ tag: 9,  h0: h0 });
let Lib_Syntax_RLet = ( h0, h1, h2, h3, h4 ) => ({ tag: 6,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_DoStmt$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Syntax_RCase = ( h0, h1, h2, h3 ) => ({ tag: 8,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Elab_collectDecl = ( _$$0 ) => { while (1) { let _$$01 = _$$0; if ((_$$01.tag) == (1)) { if ((_$$01.h1.tag) == (1)) { if ((_$$01.h2.tag) == (1)) { if ((_$$01.h2.h1.tag) == (1)) { let sc$$13 = Prelude_eqString(_$$01.h1.h1, _$$01.h2.h1.h1); switch (sc$$13) { case true: { _$$0 = { tag: 1,  h1: Lib_Syntax_FunDef(_$$01.h1.h0, _$$01.h1.h1, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$01.h1.h2, _$$01.h2.h1.h2)),  h2: _$$01.h2.h2 }; continue; break; } case false: return { tag: 1,  h1: Lib_Syntax_FunDef(_$$01.h1.h0, _$$01.h1.h1, _$$01.h1.h2),  h2: Lib_Elab_collectDecl(_$$01.h2) }; } } else { return { tag: 1,  h1: _$$01.h1,  h2: Lib_Elab_collectDecl(_$$01.h2) }; } } else { return { tag: 1,  h1: _$$01.h1,  h2: Lib_Elab_collectDecl(_$$01.h2) }; } } else { return { tag: 1,  h1: _$$01.h1,  h2: Lib_Elab_collectDecl(_$$01.h2) }; } } else { return { tag: 0 }; } } };
let Lib_Syntax_FunDef = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Elab_checkWhere = ( _$$0, _$$1, _$$2, _$$3 ) => (( (_$$1.tag) == (1) ? ( (_$$1.h1.tag) == (0) ? ( (_$$1.h1.h1.tag) == (1) ? ( (_$$1.h1.h1.h2.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(_$$0, _$$1.h1.h2, Lib_Types_VU(_$$1.h1.h0)), ( funTy ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("where clause ") + (_$$1.h1.h1.h1)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$0.h2), funTy))), { tag: 0 }))) + (""))), ( _ ) => (( (_$$1.h2.tag) == (1) ? ( (_$$1.h2.h1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Prelude_eqString(_$$1.h1.h1.h1, _$$1.h2.h1.h1)), ( _1 ) => (Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h2.h1.h0, (("Expected def for ") + (_$$1.h1.h1.h1)) + (""))), eta)))))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_makeClause(eta)), _$$1.h2.h1.h2), ( clauses$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$0.h1, funTy), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((("") + (_$$1.h1.h1.h1)) + (" vty is ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(vty))) + (""))), ( _2 ) => { let ctx$27 = Lib_Types_extend(_$$0, _$$1.h1.h1.h1, vty); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(Lib_Types_MkCtx(ctx$27.h0, ctx$27.h1, ctx$27.h2, ctx$27.h3, _$$1.h2.h1.h0), { tag: 0,  h0: clauses$27,  h1: vty }), ( tm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(ctx$27.h1, tm), ( vtm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_checkWhere(ctx$27, _$$1.h2.h2, _$$2, _$$3), ( ty$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_LetRec(_$$1.h1.h0, _$$1.h1.h1.h1, funTy, tm, ty$27)))))))); }))))))))) : Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(_$$1.h2.h1), "expected function definition")), eta)))) ) : Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h1.h0, "expected function definition after this signature")), eta)))) ))))) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(_$$1.h1), "expected type signature")), eta)))) ) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(_$$1.h1), "expected type signature")), eta)))) ) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(_$$1.h1), "expected type signature")), eta)))) ) : Lib_Elab_check(_$$0, _$$2, _$$3) ));
let Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case 12: return _$$0.h0; case 11: return _$$0.h0; case 10: return _$$0.h0; case 9: return _$$0.h0; case 8: return _$$0.h0; case 7: return _$$0.h0; case 6: return _$$0.h0; case 5: return _$$0.h0; case 4: return _$$0.h0; case 3: return _$$0.h0; case 2: return _$$0.h0; case 1: return _$$0.h0; case 0: return _$$0.h0; } };
let Lib_Elab_makeClause = ( _$$0 ) => { let sc$$5 = Lib_Elab_splitArgs(_$$0.h2, { tag: 0 }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_mkPat(eta)), sc$$5.h3), ( pats ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_MkClause(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$0.h2), { tag: 0 }, pats, _$$0.h3)))); };
let Lib_Elab_updateRec = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_updateRec_getTele(_$$0, _$$1, _$$2, _$$3, _$$4, _$$3, _$$4), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_Elab_updateRec_doClause(_$$0, _$$1, _$$2, _$$3, _$$4, eta, eta1))), $$sc.h3, _$$2), ( args$27 ) => { let tm = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( acc ) => (( tm ) => (Lib_Syntax_RApp(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(tm), acc, tm, 1))), Lib_Syntax_RVar(_$$1, $$sc.h2.h1), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h3), args$27)); let tm1 = ( (_$$3.tag) == (1) ? Lib_Syntax_RLam(_$$1, Lib_Types_BI(_$$1, "$ru", 1, true), tm) : tm ); return Lib_Elab_check(_$$0, tm1, _$$4); }))));
let Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl = ( _$$2, _$$3, _$$4 ) => { while (1) { let _$$21 = _$$2; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$41.tag) == (1)) { _$$2 = _$$21; _$$3 = _$$21(_$$31)(_$$41.h1); _$$4 = _$$41.h2; continue; } else { return _$$31; } } };
let Lib_Elab_updateRec_doClause = ( _, _1, _2, _3, _4, _$$7, _$$8 ) => (( (_$$8.tag) == (1) ? Lib_Elab_updateRec_doClause_go(_, _1, _2, _3, _4, _$$7, _$$8, _$$8.h0, _$$8.h1, _$$8.h2, _$$7) : Lib_Elab_updateRec_doClause_go$27(_, _1, _2, _3, _4, _$$7, _$$8, _$$8.h0, _$$8.h1, _$$8.h2, _$$7) ));
let Lib_Elab_updateRec_doClause_go$27 = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$13 ) => { if ((_$$13.tag) == (1)) { let sc$$17 = Prelude_eqString(_$$13.h1.h2, _8); switch (sc$$17) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: { tag: 0,  h2: _8,  h3: _9 },  h2: _$$13.h2 }); case false: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$3A$3A_(_$$13.h1, eta)), Lib_Elab_updateRec_doClause_go$27(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$13.h2)); } } else { return Lib_Types_MkM(( _10 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_7, (((("") + (_8)) + (" is not a field of ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_4))) + (""))), eta)))); } };
let Lib_Elab_updateRec_doClause_go = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$13 ) => { if ((_$$13.tag) == (1)) { let sc$$17 = Prelude_eqString(_$$13.h1.h2, _8); switch (sc$$17) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: { tag: 0,  h2: _8,  h3: Lib_Elab_updateRec_app(_, _1, _2, _3, _4, _7, _9, _$$13.h1.h3) },  h2: _$$13.h2 }); case false: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$3A$3A_(_$$13.h1, eta)), Lib_Elab_updateRec_doClause_go(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$13.h2)); } } else { return Lib_Types_MkM(( _10 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_7, (((("") + (_8)) + (" is not a field of ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_4))) + (""))), eta)))); } };
let Lib_Elab_updateRec_app = ( _, _1, _2, _3, _4, _$$6, _$$7, _$$8 ) => (( (_$$7.tag) == (15) ? ( (_$$7.h2.tag) == (1) ? Lib_Syntax_RUpdateRec(_$$7.h0, _$$7.h1, Prelude_Just(_$$8)) : Lib_Syntax_RApp(_$$6, _$$7, _$$8, 1) ) : Lib_Syntax_RApp(_$$6, _$$7, _$$8, 1) ));
let Lib_Syntax_RUpdateRec = ( h0, h1, h2 ) => ({ tag: 15,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Types_Prelude_Monad$20Lib_Types_M = { tag: 0,  h1: ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(eta, eta1))))),  h2: ( a ) => (( eta ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(eta))) };
let Prelude_foldlM = ( _$$3, _$$4, _$$5, _$$6 ) => (Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( ma ) => (( b ) => (Prelude_bind(_$$3)(null)(null)(ma)(( _$$51 ) => (_$$4(_$$51)(b))))), Prelude_pure(_$$3)(null)(_$$5), _$$6));
let Prelude_pure = ( _$$1 ) => (( a ) => (_$$1.h2(null)));
let Prelude_bind = ( _$$1 ) => (( a ) => (( b ) => (_$$1.h1(null)(null))));
let Lib_Elab_updateRec_getTele = ( _, _1, _2, _3, _4, _$$9, _$$10 ) => { switch (_$$10.tag) { case 5: return ( (_$$9.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_forceType(_.h1, _$$10.h4), ( a ) => (Lib_Elab_updateRec_getTele(_, _1, _2, _3, _4, Prelude_Just(Lib_Syntax_RVar(_1, "$ru")), a))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$9.h1), (("Expected a record type, got ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$10))) + (""))), eta)))) ); case 1: return ( (_$$9.tag) == (1) ? Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_1, (("Expected a pi type, got ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$10))) + (""))), eta)))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$17 = Lib_TopContext_lookup(_$$10.h1, top); if ((sc$$17.tag) == (0)) { if ((sc$$17.h1.h3.tag) == (1)) { if ((sc$$17.h1.h3.h1.tag) == (1)) { if ((sc$$17.h1.h3.h1.h2.tag) == (0)) { let sc$$31 = Lib_TopContext_lookup(sc$$17.h1.h3.h1.h1, top); return ( (sc$$31.tag) == (0) ? ( (sc$$31.h1.h3.tag) == (2) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: sc$$17.h1.h3.h1.h1,  h3: Lib_Elab_updateRec_collect(_, _1, _2, _3, _4, _$$9.h1, sc$$31.h1.h2) }) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$17.h1.h3.h1.h1))) + (" not a dcon"))), eta)))) ) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$17.h1.h3.h1.h1))) + (" not a dcon"))), eta)))) ); } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$10.h1))) + (" is not a record"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$10.h1))) + (" is not a record"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$10.h1))) + (" is not a record"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$10.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$10.h1))) + (" not in scope"))), eta)))); } }) ); default: return ( (_$$9.tag) == (1) ? Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_1, (("Expected a pi type, got ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$10))) + (""))), eta)))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$9.h1), (("Expected a record type, got ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$10))) + (""))), eta)))) ); } };
let Lib_Elab_updateRec_collect = ( _, _1, _2, _3, _4, _$$8, _$$9 ) => (( (_$$9.tag) == (6) ? { tag: 1,  h1: { tag: 0,  h2: _$$9.h1,  h3: Lib_Syntax_RApp(_1, Lib_Syntax_RVar(_1, (".") + (_$$9.h1)), _$$8, 1) },  h2: Lib_Elab_updateRec_collect(_, _1, _2, _3, _4, _$$8, _$$9.h5) } : { tag: 0 } ));
let Lib_ProcessDecl_checkAlreadyDef = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$3 = Lib_TopContext_lookup({ tag: 0,  h0: top.h2.h0,  h1: _$$1 }, top); return ( (sc$$3.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0, (((("") + (_$$1)) + (" is already defined at ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(sc$$3.h1.h0))) + (""))), eta)))) ); }));
let Lib_ProcessDecl_processDef = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ((("Def ") + (_$$2)) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$8 = Lib_TopContext_lookup({ tag: 0,  h0: _$$0,  h1: _$$2 }, top); return ( (sc$$8.tag) == (1) ? Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("No declaration for ") + (_$$2)) + (""))), eta)))) : ( (sc$$8.h1.h3.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _2 ) => ((((("check ") + (_$$2)) + (" at ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$8.h1.h2))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$8.h1.h2), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((((("") + (_$$2)) + (" vty is ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(vty))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_makeClause(eta)), _$$3), ( clauses$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_buildTree(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, sc$$8.h1.h0), { tag: 0,  h0: clauses$27,  h1: vty }), ( tm ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solveAutos, ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 0 }, tm, { tag: 0 }), ( $$sc ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((((((("Add def ") + (_$$2)) + (" ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, tm))), { tag: 0 }))) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$8.h1.h2))), { tag: 0 }))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_updateDef({ tag: 0,  h0: _$$0,  h1: _$$2 }, sc$$8.h1.h0, sc$$8.h1.h2, Lib_Types_Fn(tm)), ( _6 ) => { let name = Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow({ tag: 0,  h0: _$$0,  h1: _$$2 }); let sc$$28 = (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(Lib_ProcessDecl_complexity(tm), 15), 0)) || ((Prelude_eqString(name, "Prelude.Prelude.Monad Prelude.IO,bind")) || (Prelude_eqString(name, "Prelude._>>=_"))); switch (sc$$28) { case true: return Lib_TopContext_setFlag({ tag: 0,  h0: _$$0,  h1: _$$2 }, sc$$8.h1.h0, 1); case false: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } }))))))))))))))))) : Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (((("") + (_$$2)) + (" already defined at ")) + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(sc$$8.h1.h0))) + (""))), eta)))) ) ); }))))));
let Lib_TopContext_setFlag = ( _$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$4 = Data_SortedMap_lookupMap$27(_$$0, top.h2.h2); return ( (sc$$4.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" not declared"))), eta)))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, Data_SortedMap_updateMap(_$$0, Lib_Types_MkEntry(sc$$4.h1.h0, _$$0, sc$$4.h1.h2, sc$$4.h1.h3, { tag: 1,  h1: _$$2,  h2: sc$$4.h1.h4 }), tc.h2.h2), tc.h2.h3, tc.h2.h4, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))) ); }));
let Lib_ProcessDecl_complexity = ( _$$0 ) => { switch (_$$0.tag) { case 10: return 0; case 7: return ( (_$$0.h2.tag) == (1) ? ( (_$$0.h2.h1.tag) == (1) ? ( (_$$0.h2.h2.tag) == (0) ? ((1) + (Lib_ProcessDecl_complexity(_$$0.h1))) + (Lib_ProcessDecl_complexity(_$$0.h2.h1.h2)) : 100 ) : 100 ) : 100 ); case 5: return 0; case 4: return Lib_ProcessDecl_complexity_go(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h1, Lib_ProcessDecl_complexity(_$$0.h2)); case 3: return (1) + (Lib_ProcessDecl_complexity(_$$0.h4)); case 2: return 1; case 1: return 1; case 0: return 1; default: return 100; } };
let Lib_ProcessDecl_complexity_go = ( _, _1, _2, _3, _$$5, _$$6 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$51 = _$$5; let _$$61 = _$$6; switch (_$$51.tag) { case 4: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = _$$51.h1; _$$6 = (_$$61) + (Lib_ProcessDecl_complexity(_$$51.h2)); continue; break; } case 2: return 1; default: return (_$$61) + (Lib_ProcessDecl_complexity(_$$51)); } } };
let Lib_Types_Fn = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_TopContext_updateDef = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$5 = Data_SortedMap_lookupMap$27(_$$0, top.h2.h2); return ( (sc$$5.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" not declared"))), eta)))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, Lib_Types_MkModCtx(tc.h2.h0, tc.h2.h1, Data_SortedMap_updateMap(_$$0, Lib_Types_MkEntry(sc$$5.h1.h0, _$$0, _$$2, _$$3, sc$$5.h1.h4), top.h2.h2), tc.h2.h3, tc.h2.h4, tc.h2.h5, tc.h2.h6, tc.h2.h7), tc.h3, tc.h4, tc.h5)))) ); }));
let Lib_Erasure_erase = ( _$$0, _$$1, _$$2 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; switch (_$$11.tag) { case 11: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$11.h0, "erased value in relevant context")), eta)))); case 10: return Lib_Erasure_eraseSpine(_$$01, _$$11, _$$21, Prelude_Nothing()); case 9: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: { tag: 0,  h2: true,  h3: Prelude_Just(_$$11.h2) } },  h2: _$$01 }, _$$11.h3, { tag: 0 }), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: { tag: 0,  h2: true,  h3: Prelude_Just(_$$11.h2) } },  h2: _$$01 }, _$$11.h4, { tag: 0 }), ( v$27 ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_LetRec(_$$11.h0, _$$11.h1, _$$11.h2, u$27, v$27), _$$21, Prelude_Nothing()))))); case 8: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase(_$$01, _$$11.h2, { tag: 0 }), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: { tag: 0,  h2: true,  h3: Prelude_Nothing() } },  h2: _$$01 }, _$$11.h3, { tag: 0 }), ( v$27 ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_Let(_$$11.h0, _$$11.h1, u$27, v$27), _$$21, Prelude_Nothing()))))); case 7: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase(_$$01, _$$11.h1, { tag: 0 }), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Erasure_doAlt(_$$01, eta)), _$$11.h2), ( alts$27 ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_Case(_$$11.h0, u$27, alts$27), _$$21, Prelude_Nothing()))))); case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase(_$$01, _$$11.h4, { tag: 0 }), ( u$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: { tag: 0,  h2: true,  h3: Prelude_Just(_$$11.h4) } },  h2: _$$01 }, _$$11.h5, { tag: 0 }), ( v$27 ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_Pi(_$$11.h0, _$$11.h1, _$$11.h2, _$$11.h3, u$27, v$27), _$$21, Prelude_Just(Lib_Types_UU(Lib_Common_emptyFC))))))); case 5: return Lib_Erasure_eraseSpine(_$$01, _$$11, _$$21, Prelude_Just(Lib_Types_UU(_$$11.h0))); case 4: { _$$0 = _$$01; _$$1 = _$$11.h1; _$$2 = { tag: 1,  h1: { tag: 0,  h2: _$$11.h0,  h3: _$$11.h2 },  h2: _$$21 }; continue; break; } case 3: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_Lam(_$$11.h0, _$$11.h1, _$$11.h2, _$$11.h3, eta)), Lib_Erasure_erase({ tag: 1,  h1: { tag: 0,  h2: _$$11.h1,  h3: { tag: 0,  h2: _$$11.h3,  h3: Prelude_Nothing() } },  h2: _$$01 }, _$$11.h4, { tag: 0 })); case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$11); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$7 = Lib_TopContext_lookup(_$$11.h1, top); return ( (sc$$7.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$11.h0, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$11.h1))) + (" not in scope"))), eta)))) : Lib_Erasure_eraseSpine(_$$01, _$$11, _$$21, Prelude_Just(sc$$7.h1.h2)) ); }); case 0: { let sc$$6 = Prelude_getAt(Prelude_intToNat(_$$11.h1), _$$01); if ((sc$$6.tag) == (1)) { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$11.h0, (("Erase: bad index ") + (Prelude_showInt(_$$11.h1))) + (""))), eta)))); } else { switch (sc$$6.h1.h3.h2) { case true: return Lib_Erasure_eraseSpine(_$$01, _$$11, _$$21, sc$$6.h1.h3.h3); case false: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$11.h0, (("used erased value ") + (sc$$6.h1.h2)) + (" (FIXME FC may be wrong here)"))), eta)))); } } break; } } } };
let Lib_Erasure_eraseSpine = ( _$$0, _$$1, _$$2, ty$$3 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; let ty$$31 = ty$$3; if ((_$$21.tag) == (1)) { if ((ty$$31.tag) == (0)) { if ((ty$$31.h1.tag) == (6)) { switch (ty$$31.h1.h3) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase(_$$01, _$$21.h1.h3, { tag: 0 }), ( u ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_App(_$$21.h1.h2, _$$11, u), _$$21.h2, Prelude_Just(ty$$31.h1.h5)))); case false: { let u = Lib_Types_Erased(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$21.h1.h3)); _$$0 = _$$01; _$$1 = Lib_Types_App(_$$21.h1.h2, _$$11, u); _$$2 = _$$21.h2; ty$$3 = Prelude_Just(ty$$31.h1.h5); continue; break; } } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase(_$$01, _$$21.h1.h3, { tag: 0 }), ( u ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_App(_$$21.h1.h2, _$$11, u), _$$21.h2, Prelude_Nothing()))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase(_$$01, _$$21.h1.h3, { tag: 0 }), ( u ) => (Lib_Erasure_eraseSpine(_$$01, Lib_Types_App(_$$21.h1.h2, _$$11, u), _$$21.h2, Prelude_Nothing()))); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$11); } } };
let Lib_Erasure_doAlt = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 2: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseLit(_$$1.h0, eta)), Lib_Erasure_erase(_$$0, _$$1.h1, { tag: 0 })); case 1: return ( (_$$1.h2.tag) == (11) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_CaseCons(_$$1.h0, _$$1.h1, Lib_Types_Erased(_$$1.h2.h0))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$7 = Lib_TopContext_lookup(_$$1.h0, top); if ((sc$$7.tag) == (0)) { let env$27 = Lib_Erasure_doAlt_piEnv(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$0, sc$$7.h1.h2, _$$1.h1); return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseCons(_$$1.h0, _$$1.h1, eta)), Lib_Erasure_erase(env$27, _$$1.h2, { tag: 0 })); } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h0))) + (" dcon missing from context"))), eta)))); } }) ); case 0: return ( (_$$1.h0.tag) == (11) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_CaseDefault(Lib_Types_Erased(_$$1.h0.h0))) : Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseDefault(eta)), Lib_Erasure_erase(_$$0, _$$1.h0, { tag: 0 })) ); } };
let Lib_Erasure_doAlt_piEnv = ( _, _1, _2, _3, _4, _$$6, _$$7, _$$8 ) => { while (1) { let _5 = _; let _6 = _1; let _7 = _2; let _8 = _3; let _9 = _4; let _$$61 = _$$6; let _$$71 = _$$7; let _$$81 = _$$8; if ((_$$81.tag) == (1)) { if ((_$$71.tag) == (6)) { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$6 = { tag: 1,  h1: { tag: 0,  h2: _$$81.h1,  h3: { tag: 0,  h2: _$$71.h3,  h3: Prelude_Just(_$$71.h4) } },  h2: _$$61 }; _$$7 = _$$71.h5; _$$8 = _$$81.h2; continue; } else { return _$$61; } } else { return _$$61; } } };
let Lib_ProcessDecl_processCheck = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("----- DCheck")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_info(_$$1, (((("check ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$2))) + (" at ")) + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$3))) + ("")), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), _$$3, Lib_Types_VU(_$$1)), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("  got type ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, ty$27))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, ty$27), ( vty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), _$$2, vty), ( res ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("  got ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, res))), { tag: 0 }))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, res), ( eta ) => (Lib_Eval_quote(Prelude_length$27({ tag: 0 }), eta))), ( norm ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("  NF ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, norm))), { tag: 0 }))) + (""))))))))))))))))))))));
let Lib_ProcessDecl_processDerive = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$2.h3) { case "Eq": return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Derive_deriveEq(_$$3.h2, _$$3.h3), ( decls ) => (Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, decls, ( eta ) => (Lib_ProcessDecl_processDecl(_$$0, eta))))); case "Show": return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Derive_deriveShow(_$$3.h2, _$$3.h3), ( decls ) => (Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, decls, ( eta ) => (Lib_ProcessDecl_processDecl(_$$0, eta))))); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$3.h2, (("derive ") + (_$$2.h3)) + (" is not supported"))), eta)))); } };
let Lib_Derive_deriveShow = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$11 = Lib_TopContext_lookupRaw(_$$1, top); return ( (sc$$11.tag) == (0) ? ( (sc$$11.h1.h3.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_lookupDCon(eta)), sc$$11.h1.h3.h1), ( dcons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Derive_deriveShow_makeClause(_$$0, _$$1, eta)), dcons), ( clauses ) => { let eqDecl = Lib_Syntax_FunDef(sc$$11.h1.h0, "show", clauses); let inst = Lib_Syntax_Instance(sc$$11.h1.h0, Lib_Derive_deriveShow_buildApp(_$$0, _$$1, "Show", { tag: 1,  h1: Lib_Derive_deriveShow_rvar(_$$0, _$$1, _$$1),  h2: { tag: 0 } }), Prelude_Just({ tag: 1,  h1: eqDecl,  h2: { tag: 0 } })); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: inst,  h2: { tag: 0 } }); }))) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0, (("") + (_$$1)) + (" is not a type constructor"))), eta)))) ) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_ENotInScope(_$$0, _$$1)), eta)))) ); }));
let Lib_Derive_deriveShow_rvar = ( _, _1, _$$4 ) => (Lib_Syntax_RVar(_, _$$4));
let Lib_Derive_deriveShow_buildApp = ( _, _1, _$$7, _$$8 ) => (Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( t ) => (( u ) => (Lib_Syntax_RApp(_, t, u, 1))), Lib_Derive_deriveShow_rvar(_, _1, _$$7), _$$8));
let Lib_Syntax_Instance = ( h0, h1, h2 ) => ({ tag: 10,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Derive_deriveShow_makeClause = ( _, _1, _$$10 ) => { let names = Lib_Derive_deriveShow_getExplictNames(_, _1, { tag: 0 }, _$$10.h3.h3); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Derive_deriveShow_rvar(_, _1, eta)), eta)), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TopContext_freshName(eta)), names)), ( anames ) => { let left = Lib_Derive_deriveShow_buildApp(_, _1, "show", { tag: 1,  h1: Lib_Derive_deriveShow_buildApp(_, _1, _$$10.h2.h1, anames),  h2: { tag: 0 } }); let shows = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( nm ) => (Lib_Syntax_RApp(_, Lib_Derive_deriveShow_rvar(_, _1, "show"), nm, 1)), anames); let right; if ((anames.tag) == (0)) { right = Lib_Derive_deriveShow_lstring(_, _1, _$$10.h2.h1); } else { let parts = Lib_Derive_deriveShow_makeList(_, _1, { tag: 1,  h1: Lib_Derive_deriveShow_lstring(_, _1, ("(") + (_$$10.h2.h1)),  h2: shows }); right = Lib_Derive_deriveShow_buildApp(_, _1, "_++_", { tag: 1,  h1: Lib_Derive_deriveShow_buildApp(_, _1, "joinBy", { tag: 1,  h1: Lib_Derive_deriveShow_lstring(_, _1, " "),  h2: { tag: 1,  h1: parts,  h2: { tag: 0 } } }),  h2: { tag: 1,  h1: Lib_Derive_deriveShow_lstring(_, _1, ")"),  h2: { tag: 0 } } }); } return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: left,  h3: Prelude_Just(right) }); }); };
let Lib_Derive_deriveShow_lstring = ( _, _1, _$$5 ) => (Lib_Syntax_RLit(_, Lib_Types_LString(_$$5)));
let Lib_Syntax_RLit = ( h0, h1 ) => ({ tag: 7,  h0: h0,  h1: h1 });
let Lib_Derive_deriveShow_makeList = ( _, _1, _$$9 ) => (( (_$$9.tag) == (1) ? Lib_Derive_deriveShow_buildApp(_, _1, "_::_", { tag: 1,  h1: _$$9.h1,  h2: { tag: 1,  h1: Lib_Derive_deriveShow_makeList(_, _1, _$$9.h2),  h2: { tag: 0 } } }) : Lib_Derive_deriveShow_rvar(_, _1, "Nil") ));
let Lib_TopContext_freshName = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, tc.h2, tc.h3, tc.h4, (1) + (tc.h5))))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(("f$") + ((_$$0) + (Prelude_showInt(top.h5)))))))));
let Lib_Derive_deriveShow_getExplictNames = ( _, _1, _$$6, _$$7 ) => { while (1) { let _2 = _; let _3 = _1; let _$$61 = _$$6; let _$$71 = _$$7; if ((_$$71.tag) == (6)) { switch (_$$71.h2) { case 2: { _ = _2; _1 = _3; _$$6 = _$$61; _$$7 = _$$71.h5; continue; break; } case 1: { _ = _2; _1 = _3; _$$6 = { tag: 1,  h1: _$$61,  h2: _$$71.h1 }; _$$7 = _$$71.h5; continue; break; } case 0: { _ = _2; _1 = _3; _$$6 = _$$61; _$$7 = _$$71.h5; continue; break; } } } else { return Prelude__$3C$3E$3E_(_$$61, { tag: 0 }); } } };
let Lib_Derive_deriveEq = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$9 = Lib_TopContext_lookupRaw(_$$1, top); return ( (sc$$9.tag) == (0) ? ( (sc$$9.h1.h3.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Elab_lookupDCon(eta)), sc$$9.h1.h3.h1), ( dcons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Derive_deriveEq_makeClause(_$$0, _$$1, eta)), dcons), ( clauses ) => { let fallback = { tag: 0,  h2: Lib_Derive_deriveEq_buildApp(_$$0, _$$1, "_==_", { tag: 1,  h1: Lib_Derive_deriveEq_rvar(_$$0, _$$1, "_"),  h2: { tag: 1,  h1: Lib_Derive_deriveEq_rvar(_$$0, _$$1, "_"),  h2: { tag: 0 } } }),  h3: Prelude_Just(Lib_Derive_deriveEq_rvar(_$$0, _$$1, "False")) }; let eqDecl = Lib_Syntax_FunDef(sc$$9.h1.h0, "_==_", Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(clauses, { tag: 1,  h1: fallback,  h2: { tag: 0 } })); let inst = Lib_Syntax_Instance(sc$$9.h1.h0, Lib_Derive_deriveEq_buildApp(_$$0, _$$1, "Eq", { tag: 1,  h1: Lib_Derive_deriveEq_rvar(_$$0, _$$1, _$$1),  h2: { tag: 0 } }), Prelude_Just({ tag: 1,  h1: eqDecl,  h2: { tag: 0 } })); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: inst,  h2: { tag: 0 } }); }))) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$0, (("") + (_$$1)) + (" is not a type constructor"))), eta)))) ) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_ENotInScope(_$$0, _$$1)), eta)))) ); }));
let Lib_Derive_deriveEq_rvar = ( _, _1, _$$4 ) => (Lib_Syntax_RVar(_, _$$4));
let Lib_Derive_deriveEq_buildApp = ( _, _1, _$$6, _$$7 ) => (Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( t ) => (( u ) => (Lib_Syntax_RApp(_, t, u, 1))), Lib_Derive_deriveEq_rvar(_, _1, _$$6), _$$7));
let Lib_Derive_deriveEq_makeClause = ( _, _1, _$$8 ) => { let names = Lib_Derive_deriveEq_getExplictNames(_, _1, { tag: 0 }, _$$8.h3.h3); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Derive_deriveEq_rvar(_, _1, eta)), eta)), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TopContext_freshName(eta)), names)), ( anames ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Derive_deriveEq_rvar(_, _1, eta)), eta)), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TopContext_freshName(eta)), names)), ( bnames ) => { let a = Lib_Derive_deriveEq_buildApp(_, _1, _$$8.h2.h1, anames); let b = Lib_Derive_deriveEq_buildApp(_, _1, _$$8.h2.h1, bnames); let left = Lib_Derive_deriveEq_equate(_, _1, { tag: 0,  h2: a,  h3: b }); let right; let sc$$25 = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Derive_deriveEq_equate(_, _1, eta)), Prelude_zip(anames, bnames)); right = ( (sc$$25.tag) == (1) ? Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( a1 ) => (( b1 ) => (Lib_Derive_deriveEq_buildApp(_, _1, "_&&_", { tag: 1,  h1: a1,  h2: { tag: 1,  h1: b1,  h2: { tag: 0 } } }))), sc$$25.h1, sc$$25.h2) : Lib_Derive_deriveEq_rvar(_, _1, "True") ); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: left,  h3: Prelude_Just(right) }); }))); };
let Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr = ( _$$2, _$$3, _$$4 ) => (( (_$$4.tag) == (1) ? _$$2(_$$4.h1)(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(_$$2, _$$3, _$$4.h2)) : _$$3 ));
let Lib_Derive_deriveEq_equate = ( _, _1, _$$7 ) => (Lib_Derive_deriveEq_buildApp(_, _1, "_==_", { tag: 1,  h1: _$$7.h2,  h2: { tag: 1,  h1: _$$7.h3,  h2: { tag: 0 } } }));
let Lib_Derive_deriveEq_getExplictNames = ( _, _1, _$$5, _$$6 ) => { while (1) { let _2 = _; let _3 = _1; let _$$51 = _$$5; let _$$61 = _$$6; if ((_$$61.tag) == (6)) { switch (_$$61.h2) { case 2: { _ = _2; _1 = _3; _$$5 = _$$51; _$$6 = _$$61.h5; continue; break; } case 1: { _ = _2; _1 = _3; _$$5 = { tag: 1,  h1: _$$51,  h2: _$$61.h1 }; _$$6 = _$$61.h5; continue; break; } case 0: { _ = _2; _1 = _3; _$$5 = _$$51; _$$6 = _$$61.h5; continue; break; } } } else { return Prelude__$3C$3E$3E_(_$$51, { tag: 0 }); } } };
let Lib_ProcessDecl_processData = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ((("Data ") + (_$$2.h3)) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), _$$3, Lib_Types_VU(_$$1)), ( tyty ) => { let sc$$17 = Lib_TopContext_lookup({ tag: 0,  h0: _$$0,  h1: _$$2.h3 }, top); return ( (sc$$17.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setDef({ tag: 0,  h0: _$$0,  h1: _$$2.h3 }, _$$1, tyty, Lib_Types_Axiom, { tag: 0 }), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$31 ) => (Prelude_Prelude_Monad$20Prelude_List$2Cbind(_$$31, ( _$$11 ) => (_$$11))), Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$4, ( x ) => (( (x.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessDecl_checkAlreadyDef(x.h0, eta)), x.h1), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((("check dcon ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, x.h1))) + (" ")) + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(x.h2))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, x.h0), x.h2, Lib_Types_VU(x.h0)), ( dty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((((("dty ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, x.h1))) + (" is ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, dty))), { tag: 0 }))) + (""))), ( _5 ) => { let sc$$27 = Lib_Util_splitTele(dty); let tnames = Prelude_reverse()(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_processData_binderName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta)), sc$$27.h3)); let sc$$33 = Lib_Util_funArgs(sc$$27.h2); return ( (sc$$33.h2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(sc$$33.h2.h1, { tag: 0,  h0: _$$0,  h1: _$$2.h3 })), ( _6 ) => (Lib_Types_MkM(( _7 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(sc$$27.h2), (((("Constructor codomain is ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, tnames, sc$$27.h2))), { tag: 0 }))) + (" rather than ")) + (_$$2.h3)) + (""))), eta)))))), ( _6 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(dty, eta)), x.h1)))) : Lib_Types_MkM(( _6 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(sc$$33.h2), (((("expected ") + (_$$2.h3)) + (" got ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, tnames, sc$$33.h2))), { tag: 0 }))) + (""))), eta)))) ); }))))))) : Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(x), "expected constructor declaration")), eta)))) )))), ( allCons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solveAutos, ( _3 ) => { let entries = Lib_ProcessDecl_populateConInfo(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_processData_makeConEntry(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta)), Prelude_enumerate(allCons))); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, entries, ( $$case ) => (Lib_TopContext_setDef($$case.h1, $$case.h0, $$case.h2, $$case.h3, $$case.h4))), ( _4 ) => { let cnames = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( x ) => (x.h1), entries); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _5 ) => ((((("setDef ") + (_$$2.h3)) + ("  TCon ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, cnames))) + (""))), ( _5 ) => { let arity = Prelude_natToInt(Lib_Util_piArity(tyty)); return Lib_TopContext_updateDef({ tag: 0,  h0: _$$0,  h1: _$$2.h3 }, _$$1, tyty, Lib_Types_TCon(arity, cnames)); }); }); }))))) : ( (sc$$17.h1.h3.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, tyty), ( tyty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$17.h1.h2), ( type$27 ) => (Lib_Elab_unifyCatch(_$$1, Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), tyty$27, type$27))))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$31 ) => (Prelude_Prelude_Monad$20Prelude_List$2Cbind(_$$31, ( _$$11 ) => (_$$11))), Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$4, ( x ) => (( (x.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessDecl_checkAlreadyDef(x.h0, eta)), x.h1), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((("check dcon ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, x.h1))) + (" ")) + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(x.h2))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, x.h0), x.h2, Lib_Types_VU(x.h0)), ( dty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((((("dty ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, x.h1))) + (" is ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, dty))), { tag: 0 }))) + (""))), ( _5 ) => { let sc$$27 = Lib_Util_splitTele(dty); let tnames = Prelude_reverse()(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_processData_binderName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta)), sc$$27.h3)); let sc$$33 = Lib_Util_funArgs(sc$$27.h2); return ( (sc$$33.h2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(sc$$33.h2.h1, { tag: 0,  h0: _$$0,  h1: _$$2.h3 })), ( _6 ) => (Lib_Types_MkM(( _7 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(sc$$27.h2), (((("Constructor codomain is ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, tnames, sc$$27.h2))), { tag: 0 }))) + (" rather than ")) + (_$$2.h3)) + (""))), eta)))))), ( _6 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(dty, eta)), x.h1)))) : Lib_Types_MkM(( _6 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(sc$$33.h2), (((("expected ") + (_$$2.h3)) + (" got ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, tnames, sc$$33.h2))), { tag: 0 }))) + (""))), eta)))) ); }))))))) : Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(x), "expected constructor declaration")), eta)))) )))), ( allCons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solveAutos, ( _3 ) => { let entries = Lib_ProcessDecl_populateConInfo(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_processData_makeConEntry(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta)), Prelude_enumerate(allCons))); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, entries, ( $$case ) => (Lib_TopContext_setDef($$case.h1, $$case.h0, $$case.h2, $$case.h3, $$case.h4))), ( _4 ) => { let cnames = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( x ) => (x.h1), entries); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _5 ) => ((((("setDef ") + (_$$2.h3)) + ("  TCon ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, cnames))) + (""))), ( _5 ) => { let arity = Prelude_natToInt(Lib_Util_piArity(tyty)); return Lib_TopContext_updateDef({ tag: 0,  h0: _$$0,  h1: _$$2.h3 }, _$$1, tyty, Lib_Types_TCon(arity, cnames)); }); }); }))))) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_MkM(( _2 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$2.h2, (("") + (_$$2.h3)) + (" already declared"))), eta)))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$31 ) => (Prelude_Prelude_Monad$20Prelude_List$2Cbind(_$$31, ( _$$11 ) => (_$$11))), Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$4, ( x ) => (( (x.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessDecl_checkAlreadyDef(x.h0, eta)), x.h1), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _4 ) => ((((("check dcon ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, x.h1))) + (" ")) + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(x.h2))) + (""))), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, x.h0), x.h2, Lib_Types_VU(x.h0)), ( dty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((((("dty ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, x.h1))) + (" is ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, dty))), { tag: 0 }))) + (""))), ( _5 ) => { let sc$$27 = Lib_Util_splitTele(dty); let tnames = Prelude_reverse()(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_processData_binderName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta)), sc$$27.h3)); let sc$$33 = Lib_Util_funArgs(sc$$27.h2); return ( (sc$$33.h2.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(sc$$33.h2.h1, { tag: 0,  h0: _$$0,  h1: _$$2.h3 })), ( _6 ) => (Lib_Types_MkM(( _7 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(sc$$27.h2), (((("Constructor codomain is ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, tnames, sc$$27.h2))), { tag: 0 }))) + (" rather than ")) + (_$$2.h3)) + (""))), eta)))))), ( _6 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(dty, eta)), x.h1)))) : Lib_Types_MkM(( _6 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(sc$$33.h2), (((("expected ") + (_$$2.h3)) + (" got ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, tnames, sc$$33.h2))), { tag: 0 }))) + (""))), eta)))) ); }))))))) : Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC(x), "expected constructor declaration")), eta)))) )))), ( allCons ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_solveAutos, ( _3 ) => { let entries = Lib_ProcessDecl_populateConInfo(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_processData_makeConEntry(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta)), Prelude_enumerate(allCons))); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, entries, ( $$case ) => (Lib_TopContext_setDef($$case.h1, $$case.h0, $$case.h2, $$case.h3, $$case.h4))), ( _4 ) => { let cnames = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( x ) => (x.h1), entries); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _5 ) => ((((("setDef ") + (_$$2.h3)) + ("  TCon ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, cnames))) + (""))), ( _5 ) => { let arity = Prelude_natToInt(Lib_Util_piArity(tyty)); return Lib_TopContext_updateDef({ tag: 0,  h0: _$$0,  h1: _$$2.h3 }, _$$1, tyty, Lib_Types_TCon(arity, cnames)); }); }); }))))) ) ); }))))))));
let Lib_Types_TCon = ( h0, h1 ) => ({ tag: 1,  h0: h0,  h1: h1 });
let Lib_Util_piArity = ( _$$0 ) => (( (_$$0.tag) == (6) ? (1) + (Lib_Util_piArity(_$$0.h5)) : 0 ));
let Prelude_enumerate = ( _$$1 ) => (Prelude_enumerate_go(_$$1, 0, _$$1));
let Prelude_enumerate_go = ( _, _$$3, _$$4 ) => (( (_$$4.tag) == (1) ? { tag: 1,  h1: { tag: 0,  h2: _$$3,  h3: _$$4.h1 },  h2: Prelude_enumerate_go(_, (1) + (_$$3), _$$4.h2) } : { tag: 0 } ));
let Lib_ProcessDecl_processData_makeConEntry = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$10 ) => (Lib_Types_MkEntry(_1, { tag: 0,  h0: _,  h1: _$$10.h3.h3 }, _$$10.h3.h2, Lib_Types_DCon(_$$10.h2, 0, Lib_Elab_getArity(_$$10.h3.h2), { tag: 0,  h0: _,  h1: _8 }), { tag: 0 }));
let Lib_Elab_getArity = ( _$$0 ) => (( (_$$0.tag) == (6) ? { tag: 1,  h1: _$$0.h3,  h2: Lib_Elab_getArity(_$$0.h5) } : { tag: 0 } ));
let Lib_Types_DCon = ( h0, h1, h2, h3 ) => ({ tag: 2,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_ProcessDecl_populateConInfo = ( _$$0 ) => { let sc$$8 = Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Prelude_Prelude_Applicative$20Prelude_Maybe, ( eta ) => (Lib_ProcessDecl_populateConInfo_checkEnum(_$$0, eta)), _$$0); if ((sc$$8.tag) == (1)) { if ((_$$0.tag) == (1)) { if ((_$$0.h2.tag) == (1)) { return ( (_$$0.h2.h2.tag) == (0) ? Prelude_fromMaybe(_$$0, Prelude_Prelude_Alternative$20Prelude_Maybe$2C_$3C$7C$3E_(Lib_ProcessDecl_populateConInfo_checkNat(_$$0, _$$0), Lib_ProcessDecl_populateConInfo_checkCons(_$$0, _$$0))) : _$$0 ); } else { let sc$$15 = Lib_ProcessDecl_populateConInfo_countFields(_$$0, _$$0.h1); switch (sc$$15) { case 0: return { tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_$$0, _$$0.h1, 6),  h2: { tag: 0 } }; case 2: return { tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_$$0, _$$0.h1, 7),  h2: { tag: 0 } }; default: return _$$0; } } } else { return _$$0; } } else { return ( (sc$$8.h1.tag) == (1) ? ( (sc$$8.h1.h2.tag) == (1) ? ( (sc$$8.h1.h2.h2.tag) == (0) ? { tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_$$0, sc$$8.h1.h1, 5),  h2: { tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_$$0, sc$$8.h1.h2.h1, 4),  h2: { tag: 0 } } } : sc$$8.h1 ) : sc$$8.h1 ) : sc$$8.h1 ); } };
let Lib_ProcessDecl_populateConInfo_setInfo = ( _, _$$3, _$$4 ) => (( (_$$3.h3.tag) == (2) ? Lib_Types_MkEntry(_$$3.h0, _$$3.h1, _$$3.h2, Lib_Types_DCon(_$$3.h3.h0, _$$4, _$$3.h3.h2, _$$3.h3.h3), _$$3.h4) : _$$3 ));
let Lib_ProcessDecl_populateConInfo_countFields = ( _, _$$2 ) => (Lib_ProcessDecl_populateConInfo_countFields_go(_, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, _$$2.h4, _$$2.h2));
let Lib_ProcessDecl_populateConInfo_countFields_go = ( _, _1, _2, _3, _4, _5, _6, _$$9 ) => { while (1) { let _7 = _; let _8 = _1; let _9 = _2; let _10 = _3; let _11 = _4; let _12 = _5; let _13 = _6; let _$$91 = _$$9; if ((_$$91.tag) == (6)) { switch (_$$91.h3) { case true: return (1) + (Lib_ProcessDecl_populateConInfo_countFields_go(_7, _8, _9, _10, _11, _12, _13, _$$91.h5)); case false: { _ = _7; _1 = _8; _2 = _9; _3 = _10; _4 = _11; _5 = _12; _6 = _13; _$$9 = _$$91.h5; continue; break; } } } else { return 0; } } };
let Lib_ProcessDecl_populateConInfo_checkCons = ( _, _$$8 ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Prelude_find(( x ) => (Prelude_eqInt(Lib_ProcessDecl_populateConInfo_countFields(_, x), 0)), _$$8), ( nil ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Prelude_find(( x ) => (Prelude_eqInt(Lib_ProcessDecl_populateConInfo_countFields(_, x), 2)), _$$8), ( cons ) => (Prelude_Just({ tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_, nil, 6),  h2: { tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_, cons, 7),  h2: { tag: 0 } } }))))));
let Lib_ProcessDecl_populateConInfo_checkNat = ( _, _$$7 ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Prelude_find(( eta ) => (Lib_ProcessDecl_populateConInfo_isSucc(_, eta)), _$$7), ( succ ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Prelude_find(( eta ) => (Lib_ProcessDecl_populateConInfo_isZero(_, eta)), _$$7), ( zero ) => (Prelude_Just({ tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_, zero, 2),  h2: { tag: 1,  h1: Lib_ProcessDecl_populateConInfo_setInfo(_, succ, 1),  h2: { tag: 0 } } }))))));
let Lib_ProcessDecl_populateConInfo_isZero = ( _, _$$5 ) => (( (_$$5.h3.tag) == (2) ? ( (_$$5.h3.h2.tag) == (0) ? true : false ) : false ));
let Lib_ProcessDecl_populateConInfo_isSucc = ( _, _$$6 ) => { if ((_$$6.h2.tag) == (6)) { if ((_$$6.h2.h4.tag) == (1)) { if ((_$$6.h2.h5.tag) == (1)) { if ((_$$6.h3.tag) == (2)) { if ((_$$6.h3.h2.tag) == (1)) { switch (_$$6.h3.h2.h1) { case true: return ( (_$$6.h3.h2.h2.tag) == (0) ? Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$6.h2.h4.h1, _$$6.h2.h5.h1) : false ); default: return false; } } else { return false; } } else { return false; } } else { return false; } } else { return false; } } else { return false; } };
let Lib_ProcessDecl_populateConInfo_checkEnum = ( _, _$$4 ) => (( (_$$4.h3.tag) == (2) ? ( (_$$4.h3.h2.tag) == (0) ? Prelude_Just(Lib_Types_MkEntry(_$$4.h0, _$$4.h1, _$$4.h2, Lib_Types_DCon(_$$4.h3.h0, 3, { tag: 0 }, _$$4.h3.h3), _$$4.h4)) : Prelude_Nothing() ) : Prelude_Nothing() ));
let Prelude_Prelude_Applicative$20Prelude_Maybe$2C_$3C$2A$3E_ = ( _$$2, _$$3 ) => (( (_$$2.tag) == (1) ? Prelude_Nothing() : Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(_$$2.h1, _$$3) ));
let Prelude_Prelude_Applicative$20Prelude_Maybe = { tag: 0,  h1: ( a ) => (( _$$1 ) => (Prelude_Just(_$$1))),  h2: ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Applicative$20Prelude_Maybe$2C_$3C$2A$3E_(eta, eta1))))) };
let Prelude__$2C_ = ( h2, h3 ) => ({ tag: 0,  h2: h2,  h3: h3 });
let Lib_Util_funArgs = ( _$$0 ) => (Lib_Util_funArgs_go(_$$0, _$$0, { tag: 0 }));
let Lib_Util_funArgs_go = ( _, _$$2, _$$3 ) => { while (1) { let _1 = _; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$21.tag) == (4)) { _ = _1; _$$2 = _$$21.h1; _$$3 = { tag: 1,  h1: _$$21.h2,  h2: _$$31 }; continue; } else { return { tag: 0,  h2: _$$21,  h3: _$$31 }; } } };
let Lib_ProcessDecl_processData_binderName = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$11 ) => (_$$11.h1);
let Lib_Util_splitTele_go = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (6)) { _$$1 = { tag: 1,  h1: Lib_Util_MkBinder(_$$21.h0, _$$21.h1, _$$21.h2, _$$21.h3, _$$21.h4),  h2: _$$11 }; _$$2 = _$$21.h5; continue; } else { return { tag: 0,  h2: _$$21,  h3: Prelude_reverse()(_$$11) }; } } };
let Lib_Util_splitTele = ( eta ) => (Lib_Util_splitTele_go({ tag: 0 }, eta));
let Lib_Util_MkBinder = ( h0, h1, h2, h3, h4 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Prelude_Prelude_Monad$20Prelude_List$2Cbind = ( _$$2, _$$3 ) => (( (_$$2.tag) == (1) ? Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(_$$3(_$$2.h1), Prelude_Prelude_Monad$20Prelude_List$2Cbind(_$$2.h2, _$$3)) : { tag: 0 } ));
let Lib_ProcessDecl_processShortData = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processShortData_getArgs(_$$0, _$$1, _$$2, _$$3, _$$2, { tag: 0 }), ( $$sc ) => { let ty = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( eta ) => (( eta1 ) => (Lib_ProcessDecl_processShortData_mkPi(_$$0, _$$1, _$$2, _$$3, eta, eta1))), Lib_Syntax_RU(_$$1), $$sc.h3.h3); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessDecl_processShortData_mkDecl(_$$0, _$$1, _$$2, _$$3, $$sc.h3.h3, { tag: 0 }, eta)), _$$3), ( cons ) => { let dataDecl = Lib_Syntax_Data(_$$1, { tag: 0,  h2: $$sc.h2,  h3: $$sc.h3.h2 }, ty, Prelude_Just(cons)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("SHORTDATA")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ((("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(dataDecl))), { tag: 0 }))) + (""))), ( _1 ) => (Lib_ProcessDecl_processDecl(_$$0, dataDecl))))); }); }));
let Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty = ( _$$0 ) => { switch (_$$0.tag) { case 12: return Lib_Prettier_Seq(Lib_Prettier_Text("#export"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$5 ) => (Lib_Prettier_Text(_$$5.h3)), _$$0.h1)))); case 11: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("record"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_prettyBind(eta)), _$$0.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("where"), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), { tag: 1,  h1: Prelude_maybe(Lib_Prettier_empty, ( nm$27 ) => (Lib_Prettier_Seq(Lib_Prettier_Text("constructor"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(nm$27.h3)))), _$$0.h3),  h2: Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(eta)), _$$0.h4) })))))); case 10: return ( (_$$0.h2.tag) == (1) ? Lib_Prettier_Seq(Lib_Prettier_Text("instance"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h1))) : Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("instance"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("where"), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(eta)), _$$0.h2.h1))))))) ); case 9: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("class"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_prettyBind(eta)), _$$0.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("where"), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(eta)), _$$0.h3))))))); case 8: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Common_Prelude_Show$20Lib_Common_Fixity$2Cshow(_$$0.h3)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(Prelude_showInt(_$$0.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(Lib_Prettier_text, _$$0.h1)))); case 7: return ( (_$$0.h2.tag) == (0) ? Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("pfunc"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h3), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":="))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Text(_$$0.h4)))))) : Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("pfunc"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("uses"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(Lib_Prettier_text, _$$0.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h3), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":="))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Text(_$$0.h4)))))) ); case 6: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("ptype"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Prelude_maybe(Lib_Prettier_empty, ( ty ) => (Lib_Prettier_Seq(Lib_Prettier_Text(":"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(ty)))), _$$0.h2))); case 5: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("data"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier_Seq(a, Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Seq(Lib_Prettier_Text("|"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), b)))))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty, _$$0.h2)))); case 4: return ( (_$$0.h3.tag) == (1) ? Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("data"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h2))) : Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("data"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h2))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("where"), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(eta)), _$$0.h3.h1))))))) ); case 3: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("derive"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h1.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h2.h3))); case 2: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("#check"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h2))); case 1: return Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty_prettyPair(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, eta)), _$$0.h2)); case 0: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(Lib_Prettier_text, _$$0.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h2)))); } };
let Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc = ( _$$3, _$$4 ) => { switch (_$$4.tag) { case 15: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("{"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("TODO RUpdateRec"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("}"))); case 14: return Lib_Prettier_Seq(Lib_Prettier_Text(_$$4.h1), Lib_Prettier_Seq(Lib_Prettier_Text("@("), Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h2), Lib_Prettier_Text(")")))); case 13: return Lib_Prettier_Text("TODO pretty RWhere"); case 12: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 0, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("if"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h1))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Seq(Lib_Prettier_Text("then"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h2))))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Seq(Lib_Prettier_Text("else"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h3)))))); case 11: return Lib_Prettier_Text("TODO - Pretty RDo"); case 10: return Lib_Prettier_Text("?"); case 9: return Lib_Prettier_Text("_"); case 8: return Lib_Prettier_Text("TODO - Pretty RCase"); case 7: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Types_Literal$2Cpretty(_$$4.h1); case 6: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 0, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("let"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$4.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h3))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h2))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Seq(Lib_Prettier_Text("in"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h4)))))); case 5: switch (_$$4.h1.h1) { case "_": switch (_$$4.h1.h2) { case 1: switch (_$$4.h1.h3) { case true: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 1, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h2), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h3)))); default: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 1, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_wrap(_$$4.h1.h2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text((Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$4.h1.h3)) + (_$$4.h1.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(1, _$$4.h3)))); } break; default: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 1, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_wrap(_$$4.h1.h2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text((Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$4.h1.h3)) + (_$$4.h1.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(1, _$$4.h3)))); } break; default: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 1, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_wrap(_$$4.h1.h2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text((Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$4.h1.h3)) + (_$$4.h1.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(_$$3, _$$4.h2)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("->"))), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(1, _$$4.h3)))); } break; case 4: return Lib_Prettier_Text("()"); case 3: return Lib_Prettier_Text("U"); case 2: switch (_$$4.h3) { case 2: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(2, _$$4.h1), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("{{"))), Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h2), Lib_Prettier_Text("}}")))); case 1: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 2, Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(2, _$$4.h1), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(3, _$$4.h2)))); case 0: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(2, _$$4.h1), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("{"))), Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h2), Lib_Prettier_Text("}")))); } break; case 1: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par(_$$3, 0, Lib_Prettier_Seq(Lib_Prettier_Text("\\"), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_wrap(_$$4.h1.h2, Lib_Prettier_Text(_$$4.h1.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("=>"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, _$$4.h2))))); case 0: return Lib_Prettier_Text(_$$4.h1); } };
let Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty = ( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_asDoc(0, eta));
let Lib_Syntax_wrap = ( _$$0, _$$1 ) => { switch (_$$0) { case 2: return Lib_Prettier_Seq(Lib_Prettier_Text("{{"), Lib_Prettier_Seq(_$$1, Lib_Prettier_Text("}}"))); case 1: return Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(_$$1, Lib_Prettier_Text(")"))); case 0: return Lib_Prettier_Seq(Lib_Prettier_Text("{"), Lib_Prettier_Seq(_$$1, Lib_Prettier_Text("}"))); } };
let Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_par = ( _$$2, _$$3, _$$4 ) => { let sc$$5 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$3, _$$2), 0); switch (sc$$5) { case true: return Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(_$$4, Lib_Prettier_Text(")"))); case false: return _$$4; } };
let Lib_Syntax_Lib_Prettier_Pretty$20Lib_Types_Literal$2Cpretty = ( _$$0 ) => { switch (_$$0.tag) { case 3: switch (_$$0.h0) { case true: return Lib_Prettier_Text("true"); case false: return Lib_Prettier_Text("false"); } break; case 2: return Lib_Prettier_Text(Prelude_pack({ tag: 1,  h1: "'",  h2: { tag: 1,  h1: _$$0.h0,  h2: { tag: 1,  h1: "'",  h2: { tag: 0 } } } })); case 1: return Lib_Prettier_Text(Prelude_showInt(_$$0.h0)); case 0: return Lib_Prettier_Text(_$$0.h0); } };
let Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty_prettyPair = ( _, _1, _2, _3, _$$5 ) => (( (_$$5.h3.tag) == (1) ? Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$5.h2) : Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$5.h2), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$5.h3.h1))) ));
let Lib_Prettier_empty = Lib_Prettier_Empty;
let Prelude_maybe = ( _$$2, _$$3, _$$4 ) => (( (_$$4.tag) == (1) ? _$$2 : _$$3(_$$4.h1) ));
let Lib_Syntax_prettyBind = ( _$$0 ) => (Lib_Syntax_wrap(_$$0.h2.h2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text((Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h2.h3)) + (_$$0.h2.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$0.h3)))));
let Lib_Syntax_Data = ( h0, h1, h2, h3 ) => ({ tag: 4,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_ProcessDecl_processShortData_mkDecl = ( _, _1, _2, _3, _$$7, _$$8, _$$9 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; switch (_$$91.tag) { case 2: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$7 = _$$71; _$$8 = { tag: 1,  h1: _$$91.h2,  h2: _$$81 }; _$$9 = _$$91.h1; continue; break; } case 0: { let base = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( ty ) => (( acc ) => (Lib_Syntax_RPi(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(ty), Lib_Types_BI(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(ty), "_", 1, true), ty, acc))), _6, _$$81); let ty = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( eta ) => (( eta1 ) => (Lib_ProcessDecl_processShortData_mkDecl_mkPi(_4, _5, _6, _7, _$$71, _$$81, _$$91, _$$91.h0, _$$91.h1, eta, eta1))), base, _$$71); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Syntax_TypeSig(_$$91.h0, { tag: 1,  h1: _$$91.h1,  h2: { tag: 0 } }, ty)); break; } default: return Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$91), (("Expected contructor application, got: ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$91))) + (""))), eta)))); } } };
let Lib_Syntax_TypeSig = ( h0, h1, h2 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2 });
let Lib_ProcessDecl_processShortData_mkDecl_mkPi = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$13, _$$14 ) => (Lib_Syntax_RPi(_$$13.h2, Lib_Types_BI(_$$13.h2, _$$13.h3, 0, false), Lib_Syntax_RU(_$$13.h2), _$$14));
let Lib_Syntax_RU = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_Syntax_RPi = ( h0, h1, h2, h3 ) => ({ tag: 5,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_ProcessDecl_processShortData_mkPi = ( _, _1, _2, _3, _$$5, _$$6 ) => (Lib_Syntax_RPi(_$$5.h2, Lib_Types_BI(_$$5.h2, _$$5.h3, 1, false), Lib_Syntax_RU(_$$5.h2), _$$6));
let Lib_ProcessDecl_processShortData_getArgs = ( _, _1, _2, _3, _$$6, _$$7 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$61 = _$$6; let _$$71 = _$$7; switch (_$$61.tag) { case 2: { if ((_$$61.h2.tag) == (0)) { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$6 = _$$61.h1; _$$7 = { tag: 1,  h1: { tag: 0,  h2: _$$61.h2.h0,  h3: _$$61.h2.h1 },  h2: _$$71 }; continue; } else { return Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$61), (("Expected contructor application, got: ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$61))) + (""))), eta)))); } break; } case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$61.h0,  h3: { tag: 0,  h2: _$$61.h1,  h3: _$$71 } }); default: return Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$61), (("Expected contructor application, got: ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow(_$$61))) + (""))), eta)))); } } };
let Lib_ProcessDecl_processPrimType = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), Prelude_maybe(Lib_Syntax_RU(_$$1), ( _$$11 ) => (_$$11), _$$3), Lib_Types_VU(_$$1)), ( ty$27 ) => { let arity = Prelude_natToInt(Lib_Util_piArity(ty$27)); return Lib_TopContext_setDef({ tag: 0,  h0: _$$0,  h1: _$$2 }, _$$1, ty$27, Lib_Types_PrimTCon(arity), { tag: 0 }); }))));
let Lib_Types_PrimTCon = ( h0 ) => ({ tag: 4,  h0: h0 });
let Lib_ProcessDecl_processPrimFn = ( _$$0, _$$1, _$$2, _$$3, _$$4, _$$5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), _$$4, Lib_Types_VU(_$$1)), ( ty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, ty), ( eta ) => (Lib_Eval_quote(Prelude_length$27({ tag: 0 }), eta))), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ((((((("pfunc ") + (_$$2)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, ty$27))), { tag: 0 }))) + (" = ")) + (_$$5)) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$3, ( name ) => { let sc$$11 = Lib_TopContext_lookupRaw(name, top); return ( (sc$$11.tag) == (1) ? Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("") + (name)) + (" not in scope"))), eta)))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$11.h1.h1) ); }), ( used$27 ) => { let arity = Lib_Util_piArity(ty$27); return Lib_TopContext_setDef({ tag: 0,  h0: _$$0,  h1: _$$2 }, _$$1, ty$27, Lib_Types_PrimFn(_$$5, arity, used$27), { tag: 0 }); }))))))))));
let Lib_ProcessDecl_processClass = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ((("Class ") + (_$$2.h3)) + (""))), ( _1 ) => { let fields = Lib_ProcessDecl_getSigs(_$$4); let dcName = (("Mk") + (_$$2.h3)) + (""); let tcType = Lib_ProcessDecl_teleToPi(_$$3, Lib_Syntax_RU(_$$1)); let tail = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_ProcessDecl_processClass_mkApp(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta, eta1))), Lib_Syntax_RVar(_$$1, _$$2.h3), _$$3); let dcType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$3), Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( eta ) => (( eta1 ) => (Lib_ProcessDecl_processClass_mkPi(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta, eta1))), tail, fields)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _2 ) => ((("tcon type ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(tcType))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _3 ) => ((("dcon type ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(dcType))), { tag: 0 }))) + (""))), ( _3 ) => { let decl = Lib_Syntax_Data(_$$1, { tag: 0,  h2: _$$2.h2,  h3: _$$2.h3 }, tcType, Prelude_Just({ tag: 1,  h1: Lib_Syntax_TypeSig(_$$1, { tag: 1,  h1: dcName,  h2: { tag: 0 } }, dcType),  h2: { tag: 0 } })); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _4 ) => ("Decl:")), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _5 ) => (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(_$$0, decl), ( _6 ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$31 ) => (0), Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, fields, ( $$case ) => { let funType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$3), Lib_Syntax_RPi($$case.h2, Lib_Types_BI($$case.h2, "_", 2, true), tail, $$case.h3.h3)); let autoPat = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_ProcessDecl_processClass_mkAutoApp(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, eta, eta1))), Lib_Syntax_RVar(_$$1, dcName), fields); let lhs = Lib_ProcessDecl_processClass_makeLHS(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, Lib_Syntax_RVar($$case.h2, $$case.h3.h2), _$$3); let lhs1 = Lib_Syntax_RApp(_$$1, lhs, autoPat, 2); let decl1 = Lib_Syntax_FunDef($$case.h2, $$case.h3.h2, { tag: 1,  h1: { tag: 0,  h2: lhs1,  h3: Prelude_Just(Lib_Syntax_RVar($$case.h2, $$case.h3.h2)) },  h2: { tag: 0 } }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _7 ) => ((((("") + ($$case.h3.h2)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(funType))), { tag: 0 }))) + (""))), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _8 ) => ((("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl1))), { tag: 0 }))) + (""))), ( _8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(_$$0, Lib_Syntax_TypeSig($$case.h2, { tag: 1,  h1: $$case.h3.h2,  h2: { tag: 0 } }, funType)), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setFlag({ tag: 0,  h0: _$$0,  h1: $$case.h3.h2 }, $$case.h2, 1), ( _10 ) => (Lib_ProcessDecl_processDecl(_$$0, decl1))))))))); })))))))); }))); }))));
let Lib_ProcessDecl_processClass_makeLHS = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11 ) => (( (_$$11.tag) == (1) ? Lib_Syntax_RApp(_$$11.h1.h2.h0, Lib_ProcessDecl_processClass_makeLHS(_, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11.h2), Lib_Syntax_RVar(_$$11.h1.h2.h0, _$$11.h1.h2.h1), 0) : _$$10 ));
let Lib_ProcessDecl_processClass_mkAutoApp = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$11, _$$12 ) => (Lib_Syntax_RApp(_$$12.h2, _$$11, Lib_Syntax_RVar(_$$12.h2, _$$12.h3.h2), 1));
let Lib_ProcessDecl_impTele = ( _$$0 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessDecl_impTele_foo(_$$0, eta)), _$$0));
let Lib_ProcessDecl_impTele_foo = ( _, _$$2 ) => ({ tag: 0,  h2: Lib_Types_BI(_$$2.h2.h0, _$$2.h2.h1, 0, false),  h3: _$$2.h3 });
let Lib_ProcessDecl_teleToPi = ( _$$0, _$$1 ) => (( (_$$0.tag) == (1) ? Lib_Syntax_RPi(_$$0.h1.h2.h0, _$$0.h1.h2, _$$0.h1.h3, Lib_ProcessDecl_teleToPi(_$$0.h2, _$$1)) : _$$1 ));
let Lib_ProcessDecl_processClass_mkPi = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$12, _$$13 ) => (Lib_Syntax_RPi(_$$12.h2, Lib_Types_BI(_$$12.h2, _$$12.h3.h2, 1, true), _$$12.h3.h3, _$$13));
let Lib_ProcessDecl_processClass_mkApp = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$13, _$$14 ) => (Lib_Syntax_RApp(_$$14.h2.h0, _$$13, Lib_Syntax_RVar(_$$14.h2.h0, _$$14.h2.h1), _$$14.h2.h2));
let Lib_ProcessDecl_getSigs = ( _$$0 ) => { while (1) { let _$$01 = _$$0; if ((_$$01.tag) == (1)) { if ((_$$01.h1.tag) == (0)) { if ((_$$01.h1.h1.tag) == (1)) { return { tag: 1,  h1: { tag: 0,  h2: _$$01.h1.h0,  h3: { tag: 0,  h2: _$$01.h1.h1.h1,  h3: _$$01.h1.h2 } },  h2: Lib_ProcessDecl_getSigs(_$$01.h2) }; } else { _$$0 = _$$01.h2; continue; } } else { _$$0 = _$$01.h2; continue; } } else { return { tag: 0 }; } } };
let Lib_ProcessDecl_processInstance = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ((("Instance ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(_$$2))), { tag: 0 }))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let tyFC = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_check(Lib_Types_MkCtx(0, { tag: 0 }, { tag: 0 }, { tag: 0 }, _$$1), _$$2, Lib_Types_VU(_$$1)), ( vty ) => { let sc$$13 = Lib_Util_splitTele(vty); let env = Lib_ProcessDecl_processInstance_tenv(_$$0, _$$1, _$$2, _$$3, Prelude_length(sc$$13.h3)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((("codomain ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$13.h2))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("tele is ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Util_Prelude_Show$20Lib_Util_Binder, sc$$13.h3))) + (""))), ( _3 ) => { let instname = Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$13.h2))), { tag: 0 }); let sigDecl = Lib_Syntax_TypeSig(_$$1, { tag: 1,  h1: instname,  h2: { tag: 0 } }, _$$2); let sc$$23 = Lib_TopContext_lookup({ tag: 0,  h0: _$$0,  h1: instname }, top); return ( (sc$$23.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(_$$0, sigDecl), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setFlag({ tag: 0,  h0: _$$0,  h1: instname }, _$$1, 0), ( _5 ) => (Lib_TopContext_addHint({ tag: 0,  h0: _$$0,  h1: instname }))))), ( _4 ) => { let sc$$24 = Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Lib_Elab_collectDecl(eta)), _$$3); if ((sc$$24.tag) == (0)) { let sc$$27 = Lib_Util_funArgs(sc$$13.h2); if ((sc$$27.h2.tag) == (1)) { let sc$$34 = Lib_TopContext_lookup(sc$$27.h2.h1, top); if ((sc$$34.tag) == (0)) { if ((sc$$34.h1.h3.tag) == (1)) { if ((sc$$34.h1.h3.h1.tag) == (1)) { if ((sc$$34.h1.h3.h1.h2.tag) == (0)) { let sc$$49 = Lib_TopContext_lookup(sc$$34.h1.h3.h1.h1, top); return ( (sc$$49.tag) == (0) ? ( (sc$$49.h1.h3.tag) == (2) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$49.h1.h2), ( $$sc ) => (( ($$sc.tag) == (5) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("dcty ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$49.h1.h2))), { tag: 0 }))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _6 ) => ((("traverse ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(eta)), sc$$27.h3)))) + (""))), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Eval_eval(env, eta)), sc$$27.h3), ( args$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _7 ) => ((("args' is ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, args$27))) + (""))), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processInstance_apply(_$$0, _$$1, _$$2, _$$3, $$sc, args$27), ( appty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processInstance_getFields(_$$0, _$$1, _$$2, _$$3, appty, env, { tag: 0 }), ( conTele ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, conTele, ( $$case ) => { switch ($$case.h2) { case 1: { let ty$27 = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( x ) => (( acc ) => (Lib_Types_Pi(x.h0, x.h1, x.h2, x.h3, x.h4, acc))), $$case.h4, sc$$13.h3); let nm$27 = (((("") + (instname)) + (",")) + ($$case.h1)) + (""); let sc$$84 = Prelude_find(( x ) => (( (x.tag) == (1) ? Prelude_eqString(x.h1, $$case.h1) : false )), sc$$24.h1); return ( (sc$$84.tag) == (0) ? ( (sc$$84.h1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setDef({ tag: 0,  h0: _$$0,  h1: nm$27 }, sc$$84.h1.h0, ty$27, Lib_Types_Axiom, { tag: 0 }), ( _8 ) => { let decl = Lib_Syntax_FunDef(sc$$84.h1.h0, nm$27, sc$$84.h1.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _9 ) => ("***")), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _10 ) => ((((("«") + (nm$27)) + ("» : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, ty$27))), { tag: 0 }))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _11 ) => (Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _11 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(decl)))))))); }) : Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("no definition for ") + ($$case.h1)) + (""))), eta)))) ) : Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("no definition for ") + ($$case.h1)) + (""))), eta)))) ); break; } default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); } }), ( defs ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_mapMaybe(( _$$11 ) => (_$$11), defs), ( decl ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _8 ) => (Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _8 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))), ( _8 ) => { let decl = Lib_Syntax_FunDef(_$$1, instname, { tag: 1,  h1: { tag: 0,  h2: Lib_Syntax_RVar(_$$1, instname),  h3: Prelude_Just(Lib_ProcessDecl_processInstance_mkRHS(_$$0, _$$1, _$$2, _$$3, instname, conTele, Lib_Syntax_RVar(_$$1, sc$$34.h1.h3.h1.h1.h1))) },  h2: { tag: 0 } }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _9 ) => ("SIGDECL")), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _10 ) => ((("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(sigDecl))), { tag: 0 }))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _11 ) => (Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _11 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))))); }))))))))))))))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC($$sc), "dcty not Pi")), eta)))) ))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("can't find constructor ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$34.h1.h3.h1.h1))) + (""))), eta)))) ) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("can't find constructor ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$34.h1.h3.h1.h1))) + (""))), eta)))) ); } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" has multiple constructors ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, sc$$34.h1.h3.h1))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" has multiple constructors ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, sc$$34.h1.h3.h1))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" is not a type constructor"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" is not a type constructor"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$13.h2))), { tag: 0 }))) + (" doesn't appear to be a TCon application"))), eta)))); } } else { return Lib_Types_log(2, ( _5 ) => ((("Forward declaration ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl$2Cshow(sigDecl))) + (""))); } }) : Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0), ( _4 ) => { let sc$$24 = Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Lib_Elab_collectDecl(eta)), _$$3); if ((sc$$24.tag) == (0)) { let sc$$27 = Lib_Util_funArgs(sc$$13.h2); if ((sc$$27.h2.tag) == (1)) { let sc$$34 = Lib_TopContext_lookup(sc$$27.h2.h1, top); if ((sc$$34.tag) == (0)) { if ((sc$$34.h1.h3.tag) == (1)) { if ((sc$$34.h1.h3.h1.tag) == (1)) { if ((sc$$34.h1.h3.h1.h2.tag) == (0)) { let sc$$49 = Lib_TopContext_lookup(sc$$34.h1.h3.h1.h1, top); return ( (sc$$49.tag) == (0) ? ( (sc$$49.h1.h3.tag) == (2) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 0 }, sc$$49.h1.h2), ( $$sc ) => (( ($$sc.tag) == (5) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("dcty ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$49.h1.h2))), { tag: 0 }))) + (""))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _6 ) => ((("traverse ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Prelude_Prelude_Show$20Prim_String, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(eta)), sc$$27.h3)))) + (""))), ( _6 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Eval_eval(env, eta)), sc$$27.h3), ( args$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _7 ) => ((("args' is ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, args$27))) + (""))), ( _7 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processInstance_apply(_$$0, _$$1, _$$2, _$$3, $$sc, args$27), ( appty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processInstance_getFields(_$$0, _$$1, _$$2, _$$3, appty, env, { tag: 0 }), ( conTele ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, conTele, ( $$case ) => { switch ($$case.h2) { case 1: { let ty$27 = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( x ) => (( acc ) => (Lib_Types_Pi(x.h0, x.h1, x.h2, x.h3, x.h4, acc))), $$case.h4, sc$$13.h3); let nm$27 = (((("") + (instname)) + (",")) + ($$case.h1)) + (""); let sc$$84 = Prelude_find(( x ) => (( (x.tag) == (1) ? Prelude_eqString(x.h1, $$case.h1) : false )), sc$$24.h1); return ( (sc$$84.tag) == (0) ? ( (sc$$84.h1.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setDef({ tag: 0,  h0: _$$0,  h1: nm$27 }, sc$$84.h1.h0, ty$27, Lib_Types_Axiom, { tag: 0 }), ( _8 ) => { let decl = Lib_Syntax_FunDef(sc$$84.h1.h0, nm$27, sc$$84.h1.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _9 ) => ("***")), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _10 ) => ((((("«") + (nm$27)) + ("» : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, ty$27))), { tag: 0 }))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _11 ) => (Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _11 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Just(decl)))))))); }) : Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("no definition for ") + ($$case.h1)) + (""))), eta)))) ) : Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("no definition for ") + ($$case.h1)) + (""))), eta)))) ); break; } default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Nothing()); } }), ( defs ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_mapMaybe(( _$$11 ) => (_$$11), defs), ( decl ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _8 ) => (Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _8 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))), ( _8 ) => { let decl = Lib_Syntax_FunDef(_$$1, instname, { tag: 1,  h1: { tag: 0,  h2: Lib_Syntax_RVar(_$$1, instname),  h3: Prelude_Just(Lib_ProcessDecl_processInstance_mkRHS(_$$0, _$$1, _$$2, _$$3, instname, conTele, Lib_Syntax_RVar(_$$1, sc$$34.h1.h3.h1.h1.h1))) },  h2: { tag: 0 } }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _9 ) => ("SIGDECL")), ( _9 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _10 ) => ((("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(sigDecl))), { tag: 0 }))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _11 ) => (Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _11 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))))); }))))))))))))))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_getValFC($$sc), "dcty not Pi")), eta)))) ))) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("can't find constructor ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$34.h1.h3.h1.h1))) + (""))), eta)))) ) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("can't find constructor ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$34.h1.h3.h1.h1))) + (""))), eta)))) ); } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" has multiple constructors ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, sc$$34.h1.h3.h1))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" has multiple constructors ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, sc$$34.h1.h3.h1))) + (""))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" is not a type constructor"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(sc$$27.h2.h1))) + (" is not a type constructor"))), eta)))); } } else { return Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(tyFC, (("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$13.h2))), { tag: 0 }))) + (" doesn't appear to be a TCon application"))), eta)))); } } else { return Lib_Types_log(2, ( _5 ) => ((("Forward declaration ") + (Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl$2Cshow(sigDecl))) + (""))); } }) ); }))); }); }))))));
let Lib_ProcessDecl_processInstance_mkRHS = ( _, _1, _2, _3, _$$7, _$$8, _$$9 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; if ((_$$81.tag) == (1)) { switch (_$$81.h1.h2) { case 1: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = Lib_Syntax_RApp(_$$81.h1.h0, _$$91, Lib_Syntax_RVar(_$$81.h1.h0, (((("") + (_$$71)) + (",")) + (_$$81.h1.h1)) + ("")), 1); continue; break; } default: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = _$$91; continue; break; } } } else { return _$$91; } } };
let Lib_ProcessDecl_processInstance_getFields = ( _, _1, _2, _3, _$$5, _$$6, _$$7 ) => { if ((_$$5.tag) == (5)) { switch (_$$5.h2) { case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Util_MkBinder(_$$5.h0, _$$5.h1, 1, _$$5.h3, eta)), Lib_Eval_quote(Prelude_length$27(_$$6), _$$5.h4)), ( bnd ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(_$$5.h0, Prelude_length$27(_$$6), { tag: 0 }),  h2: _$$5.h5.h0 }, _$$5.h5.h1), ( appsc ) => (Lib_ProcessDecl_processInstance_getFields(_, _1, _2, _3, appsc, _$$6, { tag: 1,  h1: bnd,  h2: _$$7 }))))); default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: Lib_Types_VVar(_$$5.h0, Prelude_length$27(_$$6), { tag: 0 }),  h2: _$$5.h5.h0 }, _$$5.h5.h1), ( appsc ) => (Lib_ProcessDecl_processInstance_getFields(_, _1, _2, _3, appsc, _$$6, _$$7))); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_reverse()(_$$7)); } };
let Lib_ProcessDecl_processInstance_apply = ( _, _1, _2, _3, _$$8, _$$9 ) => (( (_$$9.tag) == (1) ? ( (_$$8.tag) == (5) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval({ tag: 1,  h1: _$$9.h1,  h2: _$$8.h5.h0 }, _$$8.h5.h1), ( bx ) => (Lib_ProcessDecl_processInstance_apply(_, _1, _2, _3, bx, _$$9.h2))) : Lib_Types_MkM(( _4 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_1, (("expected pi type ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(_$$8))) + (""))), eta)))) ) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$8) ));
let Lib_TopContext_addHint = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$2 = Lib_TopContext_lookup(_$$0, top); if ((sc$$2.tag) == (1)) { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } else { let sc$$5 = Lib_TopContext_typeName(sc$$2.h1.h2); if ((sc$$5.tag) == (1)) { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(sc$$2.h1.h0, (("can't find tcon name for ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (""))), eta)))); } else { let xs = Prelude_fromMaybe({ tag: 0 }, Data_SortedMap_lookupMap$27(sc$$5.h1, top.h1)); let hints = Data_SortedMap_updateMap(sc$$5.h1, { tag: 1,  h1: { tag: 0,  h2: _$$0,  h3: sc$$2.h1.h2 },  h2: xs }, top.h1); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, hints, tc.h2, tc.h3, tc.h4, tc.h5)))); } } }));
let Lib_TopContext_typeName = ( _$$0 ) => { while (1) { let _$$01 = _$$0; switch (_$$01.tag) { case 6: switch (_$$01.h2) { case 1: return Prelude_Nothing(); default: { _$$0 = _$$01.h5; continue; break; } } break; case 4: { _$$0 = _$$01.h1; continue; break; } case 1: return Prelude_Just(_$$01.h1); default: return Prelude_Nothing(); } } };
let Lib_Util_Prelude_Show$20Lib_Util_Binder$2Cshow = ( _$$0 ) => ((((((("[") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(_$$0.h3))) + ("")) + (_$$0.h1)) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow(_$$0.h2))) + (" : ...]"));
let Lib_Util_Prelude_Show$20Lib_Util_Binder = Prelude_MkShow(( eta ) => (Lib_Util_Prelude_Show$20Lib_Util_Binder$2Cshow(eta)));
let Lib_ProcessDecl_processInstance_tenv = ( _, _1, _2, _3, _$$6 ) => { switch (_$$6) { case 0: return { tag: 0 }; default: { let x = (_$$6) - (1); return { tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, Prelude_natToInt(x), { tag: 0 }),  h2: Lib_ProcessDecl_processInstance_tenv(_, _1, _2, _3, x) }; break; } } };
let Lib_ProcessDecl_processRecord = ( _$$0, _$$1, _$$2, _$$3, _$$4, _$$5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _1 ) => ("Record")), ( _1 ) => { let fields = Lib_ProcessDecl_getSigs(_$$5); let sc$$14 = Prelude_fromMaybe({ tag: 0,  h2: _$$2.h2,  h3: (("Mk") + (_$$2.h3)) + ("") }, _$$4); let tcType = Lib_ProcessDecl_teleToPi(_$$3, Lib_Syntax_RU(_$$1)); let tail = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( acc ) => (( bi ) => (Lib_Syntax_RApp(bi.h2.h0, acc, Lib_Syntax_RVar(bi.h2.h0, bi.h2.h1), bi.h2.h2))), Lib_Syntax_RVar(_$$2.h2, _$$2.h3), _$$3); let dcType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$3), Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( x ) => (( acc ) => (Lib_Syntax_RPi(x.h2, Lib_Types_BI(x.h2, x.h3.h2, 1, true), x.h3.h3, acc))), tail, fields)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _2 ) => ((("tcon type ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(tcType))), { tag: 0 }))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _3 ) => ((("dcon type ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(dcType))), { tag: 0 }))) + (""))), ( _3 ) => { let decl = Lib_Syntax_Data(_$$1, { tag: 0,  h2: _$$2.h2,  h3: _$$2.h3 }, tcType, Prelude_Just({ tag: 1,  h1: Lib_Syntax_TypeSig(_$$1, { tag: 1,  h1: sc$$14.h3,  h2: { tag: 0 } }, dcType),  h2: { tag: 0 } })); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _4 ) => ("Decl:")), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _5 ) => (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(decl))), { tag: 0 }))), ( _5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(_$$0, decl), ( _6 ) => { let autoPat = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( acc ) => (( x ) => (Lib_Syntax_RApp(x.h2, acc, Lib_Syntax_RVar(_$$2.h2, x.h3.h2), 1))), Lib_Syntax_RVar(_$$2.h2, sc$$14.h3), fields); return Lib_ProcessDecl_processRecord_processFields(_$$0, _$$1, _$$2, _$$3, _$$4, _$$5, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, autoPat, tail, { tag: 0 }, fields); }))))); }))); }))));
let Lib_ProcessDecl_processRecord_processFields = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$11, _$$12, _$$13, _$$14 ) => { if ((_$$14.tag) == (1)) { let funType = Lib_Syntax_substRaw(_$$13, Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_3), Lib_Syntax_RPi(_$$14.h1.h2, Lib_Types_BI(_$$14.h1.h2, "$self", 1, true), _$$12, _$$14.h1.h3.h3))); let pname = (".") + (_$$14.h1.h3.h2); let lhs = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( acc ) => (( x ) => (Lib_Syntax_RApp(x.h2.h0, acc, Lib_Syntax_RVar(x.h2.h0, x.h2.h1), 0))), Lib_Syntax_RVar(_$$14.h1.h2, pname), _3); let lhs1 = Lib_Syntax_RApp(_1, lhs, _$$11, 1); let pdecl = Lib_Syntax_FunDef(_$$14.h1.h2, pname, { tag: 1,  h1: { tag: 0,  h2: lhs1,  h3: Prelude_Just(Lib_Syntax_RVar(_$$14.h1.h2, _$$14.h1.h3.h2)) },  h2: { tag: 0 } }); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _10 ) => ((((("") + (pname)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty(funType))), { tag: 0 }))) + (""))), ( _10 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(1, ( _11 ) => ((("") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty(pdecl))), { tag: 0 }))) + (""))), ( _11 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(_, Lib_Syntax_TypeSig(_$$14.h1.h2, { tag: 1,  h1: pname,  h2: { tag: 0 } }, funType)), ( _12 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(_, pdecl), ( _13 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setFlag({ tag: 0,  h0: _,  h1: pname }, _$$14.h1.h2, 1), ( _14 ) => { let deps = { tag: 1,  h1: { tag: 0,  h2: _$$14.h1.h3.h2,  h3: Lib_Syntax_RApp(_$$14.h1.h2, Lib_Syntax_RVar(_$$14.h1.h2, pname), Lib_Syntax_RVar(_$$14.h1.h2, "$self"), 1) },  h2: _$$13 }; return Lib_ProcessDecl_processRecord_processFields(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$11, _$$12, deps, _$$14.h2); }))))))))); } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } };
let Lib_Syntax_substRaw = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 15: return Lib_Syntax_RUpdateRec(_$$1.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_substRaw_substUC(_$$0, _$$1, eta)), _$$1.h1), Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Lib_Syntax_substRaw(_$$0, eta)), _$$1.h2)); case 14: return Lib_Syntax_RAs(_$$1.h0, _$$1.h1, Lib_Syntax_substRaw(_$$0, _$$1.h2)); case 13: return Lib_Syntax_RWhere(_$$1.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_substRaw_substDecl(_$$0, _$$1, eta)), _$$1.h1), Lib_Syntax_substRaw(_$$0, _$$1.h2)); case 12: return Lib_Syntax_RIf(_$$1.h0, Lib_Syntax_substRaw(_$$0, _$$1.h1), Lib_Syntax_substRaw(_$$0, _$$1.h2), Lib_Syntax_substRaw(_$$0, _$$1.h3)); case 11: return Lib_Syntax_RDo(_$$1.h0, Lib_Syntax_substRaw_substStmts(_$$0, _$$1, _$$0, _$$1.h1)); case 10: return _$$1; case 9: return _$$1; case 8: return Lib_Syntax_RCase(_$$1.h0, Lib_Syntax_substRaw(_$$0, _$$1.h1), Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Lib_Syntax_substRaw(_$$0, eta)), _$$1.h2), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_substRaw_substAlt(_$$0, _$$1, eta)), _$$1.h3)); case 7: return _$$1; case 6: return Lib_Syntax_RLet(_$$1.h0, _$$1.h1, Lib_Syntax_substRaw(_$$0, _$$1.h2), Lib_Syntax_substRaw(_$$0, _$$1.h3), Lib_Syntax_substRaw(_$$0, _$$1.h4)); case 5: return Lib_Syntax_RPi(_$$1.h0, _$$1.h1, Lib_Syntax_substRaw(_$$0, _$$1.h2), Lib_Syntax_substRaw(Lib_Syntax_substRaw_filterBind(_$$0, _$$1, _$$1.h1, _$$0), _$$1.h3)); case 4: return _$$1; case 3: return _$$1; case 2: return Lib_Syntax_RApp(_$$1.h0, Lib_Syntax_substRaw(_$$0, _$$1.h1), Lib_Syntax_substRaw(_$$0, _$$1.h2), _$$1.h3); case 1: return Lib_Syntax_RLam(_$$1.h0, _$$1.h1, Lib_Syntax_substRaw(Lib_Syntax_substRaw_filterBind(_$$0, _$$1, _$$1.h1, _$$0), _$$1.h2)); case 0: return Prelude_fromMaybe(_$$1, Data_List_lookup(Prelude_Prelude_Eq$20Prim_String, _$$1.h1, _$$0)); } };
let Data_List_lookup = ( _$$2, _$$3, _$$4 ) => { while (1) { let _$$21 = _$$2; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$41.tag) == (1)) { let sc$$12 = Prelude__$3D$3D_(_$$21)(_$$41.h1.h2)(_$$31); switch (sc$$12) { case true: return Prelude_Just(_$$41.h1.h3); case false: { _$$2 = _$$21; _$$3 = _$$31; _$$4 = _$$41.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_Syntax_substRaw_filterBind = ( _, _1, _$$5, _$$6 ) => (Lib_Syntax_substRaw_filter(_, _1, { tag: 1,  h1: _$$5.h1,  h2: { tag: 0 } }, _$$6));
let Lib_Syntax_substRaw_filter = ( _, _1, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$51.tag) == (1)) { let sc$$13 = Prelude_elem(Prelude_Prelude_Eq$20Prim_String, _$$51.h1.h2, _$$41); switch (sc$$13) { case true: { _ = _2; _1 = _3; _$$4 = _$$41; _$$5 = _$$51.h2; continue; break; } case false: return { tag: 1,  h1: _$$51.h1,  h2: Lib_Syntax_substRaw_filter(_2, _3, _$$41, _$$51.h2) }; } } else { return { tag: 0 }; } } };
let Lib_Syntax_substRaw_substAlt = ( _, _1, _$$8 ) => ({ tag: 0,  h0: Lib_Syntax_substRaw(_, _$$8.h0),  h1: Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Lib_Syntax_substRaw(Lib_Syntax_substRaw_filter(_, _1, Lib_Syntax_lhsNames(_$$8.h0), _), eta)), _$$8.h1) });
let Lib_Syntax_lhsNames = ( _$$0 ) => { switch (_$$0.tag) { case 14: return { tag: 1,  h1: _$$0.h1,  h2: Lib_Syntax_lhsNames(_$$0.h2) }; case 2: return Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Lib_Syntax_lhsNames(_$$0.h1), Lib_Syntax_lhsNames(_$$0.h2)); case 0: return { tag: 1,  h1: _$$0.h1,  h2: { tag: 0 } }; default: return { tag: 0 }; } };
let Lib_Syntax_substRaw_substStmts = ( _, _1, _$$9, _$$10 ) => { if ((_$$10.tag) == (1)) { switch (_$$10.h1.tag) { case 2: return { tag: 1,  h1: Lib_Syntax_DoArrow(_$$10.h1.h0, Lib_Syntax_substRaw(_$$9, _$$10.h1.h1), Lib_Syntax_substRaw(_$$9, _$$10.h1.h2), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_substRaw_substAlt(_, _1, eta)), _$$10.h1.h3)),  h2: Lib_Syntax_substRaw_substStmts(_, _1, Lib_Syntax_substRaw_filter(_, _1, Lib_Syntax_lhsNames(_$$10.h1.h1), _$$9), _$$10.h2) }; case 1: return { tag: 1,  h1: Lib_Syntax_DoLet(_$$10.h1.h0, _$$10.h1.h1, Lib_Syntax_substRaw(_$$9, _$$10.h1.h2)),  h2: Lib_Syntax_substRaw_substStmts(_, _1, Lib_Syntax_substRaw_filter(_, _1, { tag: 1,  h1: _$$10.h1.h1,  h2: { tag: 0 } }, _$$9), _$$10.h2) }; case 0: return { tag: 1,  h1: Lib_Syntax_DoExpr(_$$10.h1.h0, Lib_Syntax_substRaw(_$$9, _$$10.h1.h1)),  h2: Lib_Syntax_substRaw_substStmts(_, _1, _$$9, _$$10.h2) }; } } else { return { tag: 0 }; } };
let Lib_Syntax_DoExpr = ( h0, h1 ) => ({ tag: 0,  h0: h0,  h1: h1 });
let Lib_Syntax_DoLet = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Syntax_DoArrow = ( h0, h1, h2, h3 ) => ({ tag: 2,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Syntax_RDo = ( h0, h1 ) => ({ tag: 11,  h0: h0,  h1: h1 });
let Lib_Syntax_RIf = ( h0, h1, h2, h3 ) => ({ tag: 12,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Syntax_substRaw_substDecl = ( _, _1, _$$7 ) => { switch (_$$7.tag) { case 1: return Lib_Syntax_FunDef(_$$7.h0, _$$7.h1, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Syntax_substRaw_substClause(_, _1, eta)), _$$7.h2)); case 0: return Lib_Syntax_TypeSig(_$$7.h0, _$$7.h1, Lib_Syntax_substRaw(_, _$$7.h2)); default: return _$$7; } };
let Lib_Syntax_substRaw_substClause = ( _, _1, _$$6 ) => ({ tag: 0,  h2: Lib_Syntax_substRaw(_, _$$6.h2),  h3: Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(( eta ) => (Lib_Syntax_substRaw(_, eta)), _$$6.h3) });
let Lib_Syntax_RWhere = ( h0, h1, h2 ) => ({ tag: 13,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Syntax_RAs = ( h0, h1, h2 ) => ({ tag: 14,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Syntax_substRaw_substUC = ( _, _1, _$$5 ) => (( (_$$5.tag) == (1) ? Lib_Syntax_ModifyField(_$$5.h0, _$$5.h1, Lib_Syntax_substRaw(_, _$$5.h2)) : Lib_Syntax_AssignField(_$$5.h0, _$$5.h1, Lib_Syntax_substRaw(_, _$$5.h2)) ));
let Lib_Syntax_AssignField = ( h0, h1, h2 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Syntax_ModifyField = ( h0, h1, h2 ) => ({ tag: 1,  h0: h0,  h1: h1,  h2: h2 });
let Lib_ProcessDecl_processExports = ( _$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Prelude_traverse_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_ProcessDecl_processExports_setExport(_$$0, _$$1, _$$2, top, eta)), _$$2))));
let Lib_ProcessDecl_processExports_setExport = ( _, _1, _2, _$$4, _$$5 ) => { let sc$$10 = Lib_TopContext_lookupRaw(_$$5.h3, _$$4); return ( (sc$$10.tag) == (0) ? Lib_TopContext_setFlag(sc$$10.h1.h1, _$$5.h2, 2) : Lib_Types_MkM(( _3 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$5.h2, (("") + (_$$5.h3)) + (" not in scope"))), eta)))) ); };
let Prelude_traverse_ = ( _$$4, _$$5, _$$6, _$$7 ) => (Prelude__$3C$2A$3E_(_$$5)(null)(null)(Prelude_return(_$$5)(null)(( _$$3 ) => (0)))(Prelude_traverse(_$$4)(null)(null)(null)(_$$5)(_$$6)(_$$7)));
let Prelude_Prelude_Ord$20Prim_String$2Ccompare = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_eqString(_$$0, _$$1); switch (sc$$2) { case true: return 1; case false: { let sc$$3 = Prelude_ltString(_$$0, _$$1); switch (sc$$3) { case true: return 0; case false: return 2; } break; } } };
let Prelude_ltString = (a,b) => a < b;
let Data_SortedMap_EmptyMap = ( h2 ) => ({ tag: 0,  h2: h2 });
let Lib_Types_emptyModCtx = ( _$$0, _$$1 ) => (Lib_Types_MkModCtx(_$$0, _$$1, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), Lib_Types_MC(Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), { tag: 0 }, 0, 2), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), { tag: 0 }, { tag: 0 }, { tag: 0 }));
let Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare = ( _$$0, _$$1 ) => { let sc$$6 = Prelude_eqString(_$$0.h0, _$$1.h0); switch (sc$$6) { case true: return Prelude_Prelude_Ord$20Prim_String$2Ccompare(_$$0.h1, _$$1.h1); case false: return Prelude_Prelude_Ord$20Prim_String$2Ccompare(_$$0.h0, _$$1.h0); } };
let Lib_ProcessModule_addPrimitives = Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), Lib_Types_emptyModCtx("Prim", ""), tc.h3, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), tc.h5)))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(Lib_Common_primNS, Lib_Syntax_PType(Lib_Common_emptyFC, "Int", Prelude_Nothing())), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(Lib_Common_primNS, Lib_Syntax_PType(Lib_Common_emptyFC, "String", Prelude_Nothing())), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_processDecl(Lib_Common_primNS, Lib_Syntax_PType(Lib_Common_emptyFC, "Char", Prelude_Nothing())), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_setDef({ tag: 0,  h0: Lib_Common_primNS,  h1: "PiType" }, Lib_Common_emptyFC, Lib_Types_Erased(Lib_Common_emptyFC), Lib_Types_PrimFn("(h0, h1) => ({ tag: \"PiType\", h0, h1 });", (1) + ((1) + (0)), { tag: 0 }), { tag: 0 }), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(Data_SortedMap_updateMap(Lib_Common_primNS, top.h2, tc.h0), tc.h1, tc.h2, tc.h3, tc.h4, tc.h5)))), ( _5 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(top.h2)))))))))))))));
let Lib_ProcessModule_processModule_reportError = ( _, _1, _2, _3, _$$5 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addError(_$$5), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(Data_SortedMap_updateMap(_3, top.h2, tc.h0), tc.h1, tc.h2, tc.h3, tc.h4, tc.h5)))), ( _5 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(top.h2))))))));
let Data_SortedMap_listValues = ( _$$2 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h3), Data_SortedMap_toList(_$$2)));
let Data_SortedMap_toList = ( _$$2 ) => (( (_$$2.tag) == (1) ? Prelude_reverse()(Data_SortedMap_toList_go(_$$2, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, _$$2.h4, _$$2.h4, { tag: 0 })) : { tag: 0 } ));
let Data_SortedMap_toList_go = ( _, _1, _2, _3, _4, _5, _$$10, _$$11 ) => { while (1) { let _6 = _; let _7 = _1; let _8 = _2; let _9 = _3; let _10 = _4; let _11 = _5; let _$$101 = _$$10; let _$$111 = _$$11; switch (_$$101.tag) { case 2: { _ = _6; _1 = _7; _2 = _8; _3 = _9; _4 = _10; _5 = _11; _$$10 = _$$101.h7; _$$11 = Data_SortedMap_toList_go(_6, _7, _8, _9, _10, _11, _$$101.h5, Data_SortedMap_toList_go(_6, _7, _8, _9, _10, _11, _$$101.h3, _$$111)); continue; break; } case 1: { _ = _6; _1 = _7; _2 = _8; _3 = _9; _4 = _10; _5 = _11; _$$10 = _$$101.h5; _$$11 = Data_SortedMap_toList_go(_6, _7, _8, _9, _10, _11, _$$101.h3, _$$111); continue; break; } case 0: return { tag: 1,  h1: { tag: 0,  h2: _$$101.h2,  h3: _$$101.h3 },  h2: _$$111 }; } } };
let Lib_ProcessDecl_logMetas = ( _$$0 ) => { while (1) { let _$$01 = _$$0; if ((_$$01.tag) == (1)) { switch (_$$01.h1.tag) { case 2: { _$$0 = _$$01.h2; continue; break; } case 1: { _$$0 = _$$01.h2; continue; break; } case 0: switch (_$$01.h1.h4) { case 3: { _$$0 = _$$01.h2; continue; break; } case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$01.h1.h2.h0, _$$01.h1.h3), ( ty$27 ) => { let names = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$01.h1.h2.h2); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_ProcessDecl_dumpEnv(_$$01.h1.h2), ( env ) => { let msg = (((("") + (env)) + ("\n  -----------\n  ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, names, ty$27))), { tag: 0 }))) + (""); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_info(_$$01.h1.h0, (("User Hole\n") + (msg)) + ("")), ( _ ) => (Lib_ProcessDecl_logMetas(_$$01.h2))); }); }); default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_forceMeta(_$$01.h1.h3), ( ty$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$01.h1.h2.h0, ty$27), ( tm ) => { let msg = (((((((("Unsolved meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$01.h1.h1))) + (" ")) + (Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow(_$$01.h1.h4))) + (" type ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$01.h1.h2.h2), tm))), { tag: 0 }))) + (" ")) + (Prelude_showInt(Prelude_length$27(_$$01.h1.h5)))) + (" constraints"); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$01.h1.h5, ( $$case ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn((((((("  * (m") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$01.h1.h1))) + (" (")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(eta)), Prelude__$3C$3E$3E_($$case.h2, { tag: 0 }))))) + (") =?= ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow($$case.h3))) + ("")))), ( msgs ) => { switch (_$$01.h1.h4) { case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$01.h1.h2.h0, _$$01.h1.h3), ( x ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$01.h1.h2.h1, x), ( ty ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("AUTO ---> ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(ty))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { if ((ty.tag) == (1)) { let cands = Prelude_fromMaybe({ tag: 0 }, Data_SortedMap_lookupMap$27(ty.h1, top.h1)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Elab_findMatches(_$$01.h1.h2, ty, cands), ( matches ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: (((("  ") + (Prelude_showInt(Prelude_length$27(matches)))) + (" Solutions: ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, matches))) + (""),  h2: { tag: 0 } }))); } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }); } }))))))), ( sols ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addError(Lib_Error_E(_$$01.h1.h0, Prelude_joinBy("\n", Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_({ tag: 1,  h1: msg,  h2: { tag: 0 } }, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(msgs, sols))))), ( _ ) => (Lib_ProcessDecl_logMetas(_$$01.h2))))); default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }), ( sols ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addError(Lib_Error_E(_$$01.h1.h0, Prelude_joinBy("\n", Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_({ tag: 1,  h1: msg,  h2: { tag: 0 } }, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(msgs, sols))))), ( _ ) => (Lib_ProcessDecl_logMetas(_$$01.h2))))); } }); }))); } break; } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } } };
let Lib_ProcessDecl_dumpEnv = ( _$$0 ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$5 ) => (Prelude_joinBy("\n", Prelude_reverse()(_$$5))), Lib_ProcessDecl_dumpEnv_go(_$$0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0.h2), 0, Prelude_reverse()(Prelude_zip(_$$0.h1, _$$0.h2)), { tag: 0 })));
let Lib_ProcessDecl_dumpEnv_go = ( _, _$$3, _$$4, _$$5, _$$6 ) => (( (_$$5.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_.h0, _$$5.h1.h3.h3), ( ty$27 ) => (Lib_ProcessDecl_dumpEnv_go(_, _$$3, (1) + (_$$4), _$$5.h2, { tag: 1,  h1: (((("  ") + (_$$5.h1.h3.h2)) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, _$$3, ty$27))), { tag: 0 }))) + (""),  h2: _$$6 }))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$6) ));
let Lib_ProcessModule_processModule_tryProcessDecl = ( _, _1, _2, _3, _$$6, _$$7, _$$8 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_tryError(Lib_ProcessDecl_processDecl(_$$7, _$$8)), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_TopContext_addError($$sc.h2) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ))));
let Lib_ProcessModule_parseDecls = ( _$$0, _$$1, _$$2, _$$3 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$21.tag) == (1)) { let sc$$8 = Lib_Parser_Impl_partialParse(_$$01, Lib_Parser_Impl_sameLevel(Lib_Parser_parseDecl), _$$11, _$$21); if ((sc$$8.tag) == (1)) { _$$0 = _$$01; _$$1 = sc$$8.h2.h3.h2; _$$2 = sc$$8.h2.h3.h3; _$$3 = { tag: 1,  h1: _$$31,  h2: sc$$8.h2.h2 }; continue; } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TopContext_addError(sc$$8.h2.h2), ( _ ) => (Lib_ProcessModule_parseDecls(_$$01, _$$11, Lib_ProcessModule_parseDecls_recover(_$$01, _$$11, _$$21, _$$31, _$$21.h0, _$$21.h1, _$$21.h2, sc$$8.h2.h3), _$$31))); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Prelude__$3C$3E$3E_(_$$31, { tag: 0 }),  h3: _$$11 }); } } };
let Lib_ProcessModule_parseDecls_recover = ( _, _1, _2, _3, _4, _5, _6, _$$8 ) => { while (1) { let _7 = _; let _8 = _1; let _9 = _2; let _10 = _3; let _11 = _4; let _12 = _5; let _13 = _6; let _$$81 = _$$8; if ((_$$81.tag) == (1)) { let sc$$12 = (Prelude_eqInt(_$$81.h1.h2.h1, 0)) && (Prelude_not(Lib_Common_Prelude_Eq$20Lib_Common_Bounds$2C_$3D$3D_(_$$81.h1.h2, _12.h2))); switch (sc$$12) { case true: return { tag: 1,  h1: _$$81.h1,  h2: _$$81.h2 }; case false: { _ = _7; _1 = _8; _2 = _9; _3 = _10; _4 = _11; _5 = _12; _6 = _13; _$$8 = _$$81.h2; continue; break; } } } else { return { tag: 0 }; } } };
let Lib_Common_Prelude_Eq$20Lib_Common_Bounds$2C_$3D$3D_ = ( _$$0, _$$1 ) => ((Prelude_eqInt(_$$0.h1, _$$1.h1)) && ((Prelude_eqInt(_$$0.h2, _$$1.h2)) && ((Prelude_eqInt(_$$0.h3, _$$1.h3)) && (Prelude_eqInt(_$$0.h0, _$$1.h0)))));
let Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_OK(_$$1, last, toks, com, ops))))))));
let Lib_Parser_Impl_OK = ( h1, h2, h3, h4, h5 ) => ({ tag: 0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_Parser_Impl_P = ( h1 ) => ({ tag: 0,  h1: h1 });
let Lib_Parser_Impl_keyword$27 = ( _$$0 ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( _$$3 ) => (0), Lib_Parser_Impl_satisfy(( t ) => ((Prelude_eqString(t.h1.h1, _$$0)) && ((Prelude_eqString(Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(t.h1.h0), Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(2))) || ((Prelude_eqString(Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(t.h1.h0), Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(8))) || ((Prelude_eqString(Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(t.h1.h0), Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(4))) || (Prelude_eqString(Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(t.h1.h0), Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(9))))))), (("Expected '") + (_$$0)) + ("'"))));
let Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow = ( _$$0 ) => { switch (_$$0) { case 14: return "EndInterp"; case 13: return "StartInterp"; case 12: return "EndQuote"; case 11: return "StartQuote"; case 10: return "Projection"; case 9: return "Pragma"; case 8: return "Symbol"; case 7: return "JSLit"; case 6: return "StringKind"; case 5: return "Character"; case 4: return "Number"; case 3: return "MixFix"; case 2: return "Keyword"; case 1: return "UIdent"; case 0: return "Ident"; } };
let Lib_Parser_Impl_satisfy = ( _$$0, _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => { if ((toks.tag) == (1)) { let sc$$11 = _$$0(toks.h1); switch (sc$$11) { case true: return Lib_Parser_Impl_OK(toks.h1.h1.h1, toks.h1.h2, toks.h2, true, ops); case false: return Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(col.h0, toks, (((((("") + (_$$1)) + (" at ")) + (Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(toks.h1.h1.h0))) + (":")) + (toks.h1.h1.h1)) + ("")), last, toks, com, ops); } } else { return Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(col.h0, toks, (("") + (_$$1)) + (" at EOF")), last, toks, com, ops); } }))))));
let Lib_Parser_Impl_perror = ( _$$0, _$$1, _$$2 ) => (( (_$$1.tag) == (1) ? Lib_Error_E({ tag: 0,  h0: _$$0,  h1: _$$1.h1.h2 }, _$$2) : Lib_Error_E({ tag: 0,  h0: _$$0,  h1: Lib_Common_MkBounds(0, 0, 0, 0) }, _$$2) ));
let Lib_Parser_Impl_Fail = ( h1, h2, h3, h4, h5 ) => ({ tag: 1,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap = ( _$$2, _$$3 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Result$2Cmap(_$$2, _$$3.h1(last)(toks)(com)(ops)(col)))))))));
let Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Result$2Cmap = ( _$$2, _$$3 ) => (( (_$$3.tag) == (1) ? Lib_Parser_Impl_Fail(_$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, _$$3.h5) : Lib_Parser_Impl_OK(_$$2(_$$3.h1), _$$3.h2, _$$3.h3, _$$3.h4, _$$3.h5) ));
let Lib_Parser_Impl_indented = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( indent ) => { if ((toks.tag) == (1)) { let sc$$13 = { tag: 0,  h2: toks.h1.h2.h0,  h3: toks.h1.h2.h1 }; let sc$$18 = (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(sc$$13.h3, indent.h1.h1), 2)) || (Prelude_eqInt(sc$$13.h2, indent.h1.h0)); switch (sc$$18) { case true: return _$$1.h1(last)(toks)(com)(ops)(indent); case false: return Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(indent.h0, toks, "unexpected outdent"), last, toks, com, ops); } } else { return _$$1.h1(last)(toks)(com)(ops)(indent); } }))))));
let Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_ = ( _$$1, _$$2 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => { let sc$$12 = _$$1.h1(last)(toks)(false)(ops)(col); if ((sc$$12.tag) == (1)) { switch (sc$$12.h4) { case true: return Lib_Parser_Impl_Fail(sc$$12.h1, sc$$12.h2, sc$$12.h3, true, sc$$12.h5); case false: return _$$2.h1(last)(toks)(com)(sc$$12.h5)(col); } } else { return Lib_Parser_Impl_OK(sc$$12.h1, sc$$12.h2, sc$$12.h3, (com) || (sc$$12.h4), sc$$12.h5); } }))))));
let Lib_Parser_arrow = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("->")), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("→")));
let Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_ = ( _$$2, _$$3 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => { let sc$$13 = _$$2.h1(last)(toks)(com)(ops)(col); if ((sc$$13.tag) == (1)) { return Lib_Parser_Impl_Fail(sc$$13.h1, sc$$13.h2, sc$$13.h3, sc$$13.h4, sc$$13.h5); } else { let sc$$20 = _$$3.h1(sc$$13.h2)(sc$$13.h3)(sc$$13.h4)(sc$$13.h5)(col); return ( (sc$$20.tag) == (1) ? Lib_Parser_Impl_Fail(sc$$20.h1, sc$$20.h2, sc$$20.h3, sc$$20.h4, sc$$20.h5) : Lib_Parser_Impl_OK(sc$$13.h1(sc$$20.h1), sc$$20.h2, sc$$20.h3, sc$$20.h4, sc$$20.h5) ); } }))))));
let Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser = { tag: 0,  h1: ( a ) => (( eta ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(eta))),  h2: ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(eta, eta1))))) };
let Prelude_MkFunctor = ( h1 ) => ({ tag: 0,  h1: h1 });
let Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser = Prelude_MkFunctor(( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(eta, eta1))))));
let Prelude__$2A$3E_ = ( _$$3, _$$4, _$$5, _$$6 ) => (Prelude__$3C$2A$3E_(_$$4)(null)(null)(Prelude_map(_$$3)(null)(null)(( _$$31 ) => (( _$$1 ) => (_$$1)))(_$$5))(_$$6));
let Prelude_map = ( _$$1 ) => (( a ) => (( b ) => (_$$1.h1(null)(null))));
let Lib_Parser_optional = ( _$$1 ) => (Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Prelude_Just(eta)), _$$1), Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Nothing())));
let Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind = ( _$$2, _$$3 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => { let sc$$11 = _$$2.h1(last)(toks)(com)(ops)(col); return ( (sc$$11.tag) == (1) ? Lib_Parser_Impl_Fail(sc$$11.h1, sc$$11.h2, sc$$11.h3, sc$$11.h4, sc$$11.h5) : Lib_Parser_Impl_runP(_$$3(sc$$11.h1))(sc$$11.h2)(sc$$11.h3)(sc$$11.h4)(sc$$11.h5)(col) ); }))))));
let Lib_Parser_Impl_runP = ( _$$1 ) => (_$$1.h1);
let Lib_Parser_term_apply = ( _$$1, _$$2 ) => { if ((_$$2.tag) == (1)) { let u = Lib_Parser_term_apply(_$$2.h1.h3, _$$2.h2); let _sc$$0 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(u); let _sc$$1 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$1); return Lib_Syntax_RApp({ tag: 0,  h0: _sc$$1.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$1.h1, _sc$$0.h1) }, _$$1, u, 1); } else { return _$$1; } };
let Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_ = ( _$$0, _$$1 ) => { let sc$$3 = Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B__empty(_$$0, _$$1, _$$0); switch (sc$$3) { case true: return _$$1; case false: { let sc$$4 = Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B__empty(_$$0, _$$1, _$$1); switch (sc$$4) { case true: return _$$0; case false: { let a$27; let sc$$5 = (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0.h0, _$$1.h0), 0)) || ((Prelude_eqInt(_$$0.h0, _$$1.h0)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0.h1, _$$1.h1), 0))); switch (sc$$5) { case true: { a$27 = _$$0; break; } case false: { a$27 = _$$1; break; } } let b$27; let sc$$6 = (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0.h2, _$$1.h2), 0)) || ((Prelude_eqInt(_$$0.h2, _$$1.h2)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0.h3, _$$1.h3), 0))); switch (sc$$6) { case true: { b$27 = _$$1; break; } case false: { b$27 = _$$0; break; } } return Lib_Common_MkBounds(a$27.h0, a$27.h1, b$27.h2, b$27.h3); break; } } break; } } };
let Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B__empty = ( _, _1, _$$3 ) => { switch (_$$3.h0) { case 0: switch (_$$3.h1) { case 0: switch (_$$3.h2) { case 0: switch (_$$3.h3) { case 0: return true; default: return false; } break; default: return false; } break; default: return false; } break; default: return false; } };
let Lib_Parser_Impl_fail = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(col.h0, toks, _$$1), last, toks, com, ops))))))));
let Lib_Parser_pratt = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_pratt_runPrefix(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2, _$$3, _$$4), ( $$sc ) => { let sc$$15 = Lib_Parser_pratt_projectHead(_$$0, _$$1, _$$2, _$$3, _$$4, $$sc.h2, $$sc.h3); let spine = Lib_Parser_pratt_runProject(_$$0, _$$1, _$$2, _$$3, _$$4, sc$$15.h3); if ((spine.tag) == (1)) { switch (spine.h1.h2) { case 1: { if ((spine.h1.h3.h3.tag) == (0)) { let sc$$35 = Prelude_eqString(spine.h1.h3.h3.h1, _$$2); switch (sc$$35) { case true: return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: sc$$15.h2,  h3: spine }); case false: { let sc$$36 = Data_SortedMap_lookupMap$27(spine.h1.h3.h3.h1, _$$0); if ((sc$$36.tag) == (1)) { let sc$$38 = Prelude_isPrefixOf(".", spine.h1.h3.h3.h1); switch (sc$$38) { case true: { let _sc$$6 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(spine.h1.h3.h3); let _sc$$7 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$15.h2); return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$7.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$7.h1, _sc$$6.h1) }, spine.h1.h3.h3, sc$$15.h2, 1), spine.h2); break; } case false: { let _sc$$6 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(spine.h1.h3.h3); let _sc$$7 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$15.h2); return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$7.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$7.h1, _sc$$6.h1) }, sc$$15.h2, spine.h1.h3.h3, 1), spine.h2); break; } } } else { switch (sc$$36.h1.h3) { case true: return Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_pratt_runPrefix(_$$0, _$$1, _$$2, _$$3, _$$4, _$$2, spine.h1.h3.h3, spine.h2), ( $$sc1 ) => { let _sc$$9 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC($$sc1.h2); let _sc$$10 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$15.h2); return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$10.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$10.h1, _sc$$9.h1) }, sc$$15.h2, $$sc1.h2, 1), $$sc1.h3); }); case false: { let sc$$44 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(sc$$36.h1.h1, _$$1), 0); switch (sc$$44) { case true: return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: sc$$15.h2,  h3: spine }); case false: { let _sc$$15 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$15.h2); return Lib_Parser_pratt_runRule(_$$0, _$$1, _$$2, _$$3, _$$4, sc$$36.h1.h1, sc$$36.h1.h2, _$$2, sc$$36.h1.h4, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$15.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$15.h1, spine.h1.h3.h2.h1) }, Lib_Syntax_RVar(spine.h1.h3.h2, sc$$36.h1.h0), sc$$15.h2, 1), spine.h2); break; } } break; } } } break; } } } else { let _sc$$6 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(spine.h1.h3.h3); let _sc$$7 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$15.h2); return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$7.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$7.h1, _sc$$6.h1) }, sc$$15.h2, spine.h1.h3.h3, spine.h1.h2), spine.h2); } break; } default: { let _sc$$6 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(spine.h1.h3.h3); let _sc$$7 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(sc$$15.h2); return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$7.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$7.h1, _sc$$6.h1) }, sc$$15.h2, spine.h1.h3.h3, spine.h1.h2), spine.h2); break; } } } else { return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: sc$$15.h2,  h3: { tag: 0 } }); } }));
let Lib_Parser_pratt_runRule = ( _, _1, _2, _3, _4, _$$8, _$$9, _$$10, _$$11, _$$12, _$$13 ) => { if ((_$$11.tag) == (1)) { switch (_$$11.h1) { case "": { if ((_$$11.h2.tag) == (0)) { let pr; switch (_$$9) { case 1: { pr = _$$8; break; } default: { pr = (_$$8) + (1); break; } } return ( (_$$13.tag) == (1) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_pratt(_, pr, _$$10, _$$13.h1.h3.h3, _$$13.h2), ( $$sc ) => { let _sc$$6 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC($$sc.h2); let _sc$$7 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$12); return Lib_Parser_pratt(_, _1, _$$10, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$7.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$7.h1, _sc$$6.h1) }, _$$12, $$sc.h2, 1), $$sc.h3); }) : Lib_Parser_pratt(_, _1, _$$10, _$$12, { tag: 0 }) ); } else { return ( (_$$13.tag) == (1) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_pratt(_, 0, _$$11.h1, _$$13.h1.h3.h3, _$$13.h2), ( $$sc ) => { if (($$sc.h3.tag) == (1)) { if (($$sc.h3.h1.h3.h3.tag) == (0)) { let sc$$49 = Prelude_eqString($$sc.h3.h1.h3.h3.h1, _$$11.h1); switch (sc$$49) { case true: { let _sc$$15 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC($$sc.h2); let _sc$$16 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$12); return Lib_Parser_pratt_runRule(_, _1, _2, _3, _4, _$$8, _$$9, _$$10, _$$11.h2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$16.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$16.h1, _sc$$15.h1) }, _$$12, $$sc.h2, 1), $$sc.h3.h2); break; } case false: return Lib_Parser_Impl_fail((("expected ") + (_$$11.h1)) + ("")); } } else { return Lib_Parser_Impl_fail((("expected ") + (_$$11.h1)) + ("")); } } else { return Lib_Parser_Impl_fail((("expected ") + (_$$11.h1)) + ("")); } }) : Lib_Parser_Impl_fail("short") ); } break; } default: return ( (_$$13.tag) == (1) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_pratt(_, 0, _$$11.h1, _$$13.h1.h3.h3, _$$13.h2), ( $$sc ) => { if (($$sc.h3.tag) == (1)) { if (($$sc.h3.h1.h3.h3.tag) == (0)) { let sc$$49 = Prelude_eqString($$sc.h3.h1.h3.h3.h1, _$$11.h1); switch (sc$$49) { case true: { let _sc$$15 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC($$sc.h2); let _sc$$16 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$12); return Lib_Parser_pratt_runRule(_, _1, _2, _3, _4, _$$8, _$$9, _$$10, _$$11.h2, Lib_Syntax_RApp({ tag: 0,  h0: _sc$$16.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_sc$$16.h1, _sc$$15.h1) }, _$$12, $$sc.h2, 1), $$sc.h3.h2); break; } case false: return Lib_Parser_Impl_fail((("expected ") + (_$$11.h1)) + ("")); } } else { return Lib_Parser_Impl_fail((("expected ") + (_$$11.h1)) + ("")); } } else { return Lib_Parser_Impl_fail((("expected ") + (_$$11.h1)) + ("")); } }) : Lib_Parser_Impl_fail("short") ); } } else { return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: _$$12,  h3: _$$13 }); } };
let Lib_Parser_pratt_runPrefix = ( _, _1, _2, _3, _4, _$$9, _$$10, _$$11 ) => { if ((_$$10.tag) == (0)) { let sc$$14 = Data_SortedMap_lookupMap$27(_$$10.h1, _); if ((sc$$14.tag) == (0)) { switch (sc$$14.h1.h3) { case true: return Lib_Parser_pratt_runRule(_, _1, _2, _3, _4, sc$$14.h1.h1, sc$$14.h1.h2, _$$9, sc$$14.h1.h4, Lib_Syntax_RVar(_$$10.h0, sc$$14.h1.h0), _$$11); case false: return Lib_Parser_pratt_runRule(_, _1, _2, _3, _4, sc$$14.h1.h1, sc$$14.h1.h2, _$$9, sc$$14.h1.h4, Lib_Syntax_RApp(_$$10.h0, Lib_Syntax_RVar(_$$10.h0, "flip"), Lib_Syntax_RVar(_$$10.h0, sc$$14.h1.h0), 1), _$$11); } } else { return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: _3,  h3: _$$11 }); } } else { return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: _$$10,  h3: _$$11 }); } };
let Prelude_True = true;
let Prelude_False = false;
let Prelude_isPrefixOf = (pfx, s) => s.startsWith(pfx) ? Prelude_True : Prelude_False;
let Lib_Parser_pratt_runProject = ( _, _1, _2, _3, _4, _$$7 ) => { while (1) { let _5 = _; let _6 = _1; let _7 = _2; let _8 = _3; let _9 = _4; let _$$71 = _$$7; if ((_$$71.tag) == (1)) { switch (_$$71.h1.h2) { case 1: { if ((_$$71.h2.tag) == (1)) { switch (_$$71.h2.h1.h2) { case 1: { if ((_$$71.h2.h1.h3.h3.tag) == (0)) { let sc$$32 = Prelude_isPrefixOf(".", _$$71.h2.h1.h3.h3.h1); switch (sc$$32) { case true: { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; let _sc$$0 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$71.h1.h3.h3); _$$7 = { tag: 1,  h1: { tag: 0,  h2: 1,  h3: { tag: 0,  h2: _$$71.h1.h3.h2,  h3: Lib_Syntax_RApp({ tag: 0,  h0: _$$71.h2.h1.h3.h3.h0.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_$$71.h2.h1.h3.h3.h0.h1, _sc$$0.h1) }, Lib_Syntax_RVar(_$$71.h2.h1.h3.h3.h0, _$$71.h2.h1.h3.h3.h1), _$$71.h1.h3.h3, 1) } },  h2: _$$71.h2.h2 }; continue; break; } case false: return { tag: 1,  h1: _$$71.h1,  h2: { tag: 1,  h1: _$$71.h2.h1,  h2: _$$71.h2.h2 } }; } } else { return _$$71; } break; } default: return _$$71; } } else { return _$$71; } break; } default: return _$$71; } } else { return _$$71; } } };
let Lib_Parser_pratt_projectHead = ( _, _1, _2, _3, _4, _$$6, _$$7 ) => { while (1) { let _5 = _; let _6 = _1; let _7 = _2; let _8 = _3; let _9 = _4; let _$$61 = _$$6; let _$$71 = _$$7; if ((_$$71.tag) == (1)) { switch (_$$71.h1.h2) { case 1: { if ((_$$71.h1.h3.h3.tag) == (0)) { let sc$$21 = Prelude_isPrefixOf(".", _$$71.h1.h3.h3.h1); switch (sc$$21) { case true: { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; let _sc$$0 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$61); _$$6 = Lib_Syntax_RApp({ tag: 0,  h0: _$$71.h1.h3.h3.h0.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(_$$71.h1.h3.h3.h0.h1, _sc$$0.h1) }, Lib_Syntax_RVar(_$$71.h1.h3.h3.h0, _$$71.h1.h3.h3.h1), _$$61, 1); _$$7 = _$$71.h2; continue; break; } case false: return { tag: 0,  h2: _$$61,  h3: _$$71 }; } } else { return { tag: 0,  h2: _$$61,  h3: _$$71 }; } break; } default: return { tag: 0,  h2: _$$61,  h3: _$$71 }; } } else { return { tag: 0,  h2: _$$61,  h3: _$$71 }; } } };
let Lib_Parser_dbraces = ( _$$1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("{{")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(_$$1, ( t ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("}}")), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(t))))))));
let Lib_Parser_braces = ( _$$1 ) => (Lib_Parser_Impl_try(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("{")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(_$$1, ( t ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("}")), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(t)))))))));
let Lib_Parser_Impl_try = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => { let sc$$9 = _$$1.h1(last)(toks)(com)(ops)(col); return ( (sc$$9.tag) == (1) ? Lib_Parser_Impl_Fail(sc$$9.h1, sc$$9.h2, sc$$9.h3, com, sc$$9.h5) : sc$$9 ); }))))));
let Lib_Parser_Impl_getPos = Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( indent ) => (( (toks.tag) == (1) ? Lib_Parser_Impl_OK({ tag: 0,  h0: indent.h0,  h1: toks.h1.h2 }, last, toks, com, ops) : Lib_Parser_Impl_OK({ tag: 0,  h0: indent.h0,  h1: last }, last, toks, com, ops) )))))));
let Lib_Parser_Impl_many = ( _$$1 ) => (Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_some(_$$1), Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0 })));
let Lib_Parser_Impl_some = ( _$$1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(_$$1, ( x ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(_$$1), ( xs ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 1,  h1: x,  h2: xs }))))));
let Lib_Parser_Impl_getOps = Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_OK(ops, last, toks, com, ops)))))));
let Lib_Parser_parseIfThen = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("if")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( a ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("then")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( b ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("else")), ( _2 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( c ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RIf(fc, a, b, c))))))))))))))));
let Lib_Parser_caseAlt = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(0), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( pat ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=>")), ( _1 ) => (Lib_Parser_term))), ( t ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h0: pat,  h1: t })))))));
let Lib_Parser_Impl_sameLevel = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( indent ) => { if ((toks.tag) == (1)) { let sc$$13 = { tag: 0,  h2: toks.h1.h2.h0,  h3: toks.h1.h2.h1 }; let sc$$25 = Prelude_eqInt(sc$$13.h3, indent.h1.h1); switch (sc$$25) { case true: return _$$1.h1(last)(toks)(com)(ops)({ tag: 0,  h0: indent.h0,  h1: toks.h1.h2 }); case false: { let sc$$26 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(indent.h1.h1, sc$$13.h3), 0); switch (sc$$26) { case true: return Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(indent.h0, toks, "unexpected indent"), last, toks, com, ops); case false: return Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(indent.h0, toks, "unexpected indent"), last, toks, com, ops); } break; } } } else { return _$$1.h1(last)(toks)(com)(ops)(indent); } }))))));
let Lib_Parser_Impl_startBlock = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( indent ) => { if ((toks.tag) == (1)) { let sc$$13 = { tag: 0,  h2: toks.h1.h2.h0,  h3: toks.h1.h2.h1 }; return _$$1.h1(last)(toks)(com)(ops)({ tag: 0,  h0: indent.h0,  h1: Prelude_ite(Prelude_not(Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(sc$$13.h3, indent.h1.h1), 2)), Lib_Common_MkBounds(sc$$13.h2, (indent.h1.h1) + (1), 0, 0), toks.h1.h2) }); } else { return _$$1.h1(last)(toks)(com)(ops)(indent); } }))))));
let Prelude_ite = ( _$$1, _$$2, _$$3 ) => { switch (_$$1) { case true: return _$$2; case false: return _$$3; } };
let Lib_Parser_doArrow = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( left ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("<-"))), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( right ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("|")), Lib_Parser_caseAlt)))), ( alts ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_DoArrow(fc, left, right, alts)))))) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_DoExpr(fc, left)) )))))));
let Lib_Parser_Impl_token$27 = ( _$$0 ) => (Lib_Parser_Impl_satisfy(( t ) => (Prelude_eqString(Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(t.h1.h0), Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(_$$0))), (("Expected a ") + (Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow(_$$0))) + (" token")));
let Lib_Parser_ident = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(0)), Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(3)));
let Lib_Parser_doLet = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("let")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_ident, ( nm ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( tm ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_DoLet(fc, nm, tm))))))))))));
let Lib_Parser_doCaseLet = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_try(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("let")), ( _ ) => (Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("("))))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( pat ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(")")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=")), ( _2 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("|")), Lib_Parser_caseAlt)))), ( alts ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( bodyFC ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Lib_Syntax_RDo(eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_some(Lib_Parser_Impl_sameLevel(Lib_Parser_doStmt))), ( body ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_DoExpr(fc, Lib_Syntax_RCase(fc, sc, Prelude_Nothing(), { tag: 1,  h1: { tag: 0,  h0: pat,  h1: Prelude_Just(body) },  h2: alts })))))))))))))))))))));
let Lib_Parser_doStmt = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_doCaseLet, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_doLet, Lib_Parser_doArrow));
let Prelude__$3C$2A_ = ( _$$3, _$$4, _$$5 ) => (Prelude__$3C$2A$3E_(_$$3)(null)(null)(Prelude__$3C$2A$3E_(_$$3)(null)(null)(Prelude_return(_$$3)(null)(( _$$2 ) => (( _$$31 ) => (_$$2))))(_$$4))(_$$5));
let Lib_Parser_doExpr = Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Lib_Syntax_RDo(eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("do"))), Lib_Parser_Impl_startBlock(Lib_Parser_Impl_some(Lib_Parser_Impl_sameLevel(Lib_Parser_doStmt))));
let Lib_Parser_lamExpr_mkLam = ( _$$1, _$$2, _$$3 ) => (Lib_Syntax_RLam(_$$1, Lib_Types_BI(_$$2.h2, _$$2.h3.h3.h2, _$$2.h3.h2, true), _$$3));
let Lib_Parser_uident = Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(1));
let Lib_Parser_pLamArg_expArg = (  ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Prelude__$2C_(1, eta)), Lib_Parser_parenWrap(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Prelude__$2C_(eta, eta1))), Lib_Parser_ident), Lib_Parser_optional(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), ( _ ) => (Lib_Parser_typeExpr)))))));
let Lib_Parser_parenWrap = ( _$$1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("(")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(_$$1, ( t ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(")")), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(t))))))));
let Lib_Parser_pLamArg_impArg = (  ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Prelude__$2C_(0, eta)), Lib_Parser_braces(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Prelude__$2C_(eta, eta1))), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ident, Lib_Parser_uident)), Lib_Parser_optional(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), ( _ ) => (Lib_Parser_typeExpr)))))));
let Lib_Parser_pLamArg = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_pLamArg_impArg(), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_pLamArg_expArg(), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( x ) => ({ tag: 0,  h2: 1,  h3: { tag: 0,  h2: x,  h3: Prelude_Nothing() } }), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ident, Lib_Parser_uident)), Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("_")), Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: 1,  h3: { tag: 0,  h2: "_",  h3: Prelude_Nothing() } })))));
let Lib_Parser_addPos = ( _$$1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Prelude__$2C_(eta, eta1))), Lib_Parser_Impl_getPos), _$$1));
let Lib_Parser_Impl_withFC = ( _$$1 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( indent ) => { let sc$$7 = Lib_Parser_Impl_runP(_$$1)(last)(toks)(com)(ops)(indent); return ( (sc$$7.tag) == (1) ? Lib_Parser_Impl_Fail(sc$$7.h1, sc$$7.h2, sc$$7.h3, sc$$7.h4, sc$$7.h5) : Lib_Parser_Impl_OK({ tag: 0,  h2: { tag: 0,  h0: indent.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(Lib_Parser_Impl_tokStart(toks), sc$$7.h2) },  h3: sc$$7.h1 }, sc$$7.h2, sc$$7.h3, sc$$7.h4, sc$$7.h5) ); }))))));
let Lib_Parser_Impl_tokStart = ( _$$0 ) => (( (_$$0.tag) == (1) ? _$$0.h1.h2 : Lib_Common_emptyBounds ));
let Lib_Common_emptyBounds = Lib_Common_MkBounds(0, 0, 0, 0);
let Lib_Parser_lamExpr = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( pos ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("\\")), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("λ"))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_some(Lib_Parser_addPos(Lib_Parser_pLamArg)), ( args ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=>")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( scope ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: args,  h3: scope })))))))))), ( $$sc ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( eta ) => (( eta1 ) => (Lib_Parser_lamExpr_mkLam($$sc.h2, eta, eta1))), $$sc.h3.h3, $$sc.h3.h2))))));
let Lib_Parser_caseLamExpr = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_try(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("\\")), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("λ"))), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("case")))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_some(Lib_Parser_Impl_sameLevel(Lib_Parser_caseAlt))), ( alts ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RLam(fc, Lib_Types_BI(fc, "$case", 1, true), Lib_Syntax_RCase(fc, Lib_Syntax_RVar(fc, "$case"), Prelude_Nothing(), alts)))))))));
let Lib_Parser_letExpr_mkLet = ( _$$1, _$$2 ) => (Lib_Syntax_RLet(_$$2.h3.h2, _$$2.h2, Prelude_fromMaybe(Lib_Syntax_RImplicit(_$$2.h3.h2), _$$2.h3.h3.h2), _$$2.h3.h3.h3, _$$1));
let Lib_Parser_letExpr_letAssign = (  ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_ident, ( name ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), Lib_Parser_typeExpr)), ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( t ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: name,  h3: { tag: 0,  h2: fc,  h3: { tag: 0,  h2: ty,  h3: t } } }))))))))))));
let Lib_Parser_letExpr = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("let")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_some(Lib_Parser_Impl_sameLevel(Lib_Parser_letExpr_letAssign()))), ( alts ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_keyword$27("in"), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( scope ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_Parser_letExpr_mkLet(eta, eta1))), scope, Prelude_reverse()(alts)))))))))));
let Lib_Parser_caseLet = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_try(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("let")), ( _ ) => (Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("("))))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( pat ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(")")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=")), ( _2 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("|")), Lib_Parser_caseAlt)))), ( alts ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("in")), ( _3 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( body ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RCase(fc, sc, Prelude_Nothing(), { tag: 1,  h1: { tag: 0,  h0: pat,  h1: Prelude_Just(body) },  h2: alts }))))))))))))))))))));
let Lib_Parser_caseExpr = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("case")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), Lib_Parser_typeExpr)), ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("of")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_some(Lib_Parser_Impl_sameLevel(Lib_Parser_caseAlt))), ( alts ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RCase(fc, sc, ty, alts))))))))))))));
let Prelude__$3C$$_ = ( _$$3, _$$4, _$$5 ) => (Prelude_map(_$$3)(null)(null)(( _$$31 ) => (_$$4))(_$$5));
let Lib_Parser_updateClause = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_ident, ( nm ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Prelude__$3C$$_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, true, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":="))), Prelude__$3C$$_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, false, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("$=")))), ( op ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( tm ) => { switch (op) { case true: return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_AssignField(fc, nm, tm)); default: return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_ModifyField(fc, nm, tm)); } })))))));
let Lib_Parser_Impl_sepBy = ( _$$2, _$$3 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Prelude__$3A$3A_(eta, eta1))), _$$3), Lib_Parser_Impl_many(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, _$$2, _$$3))));
let Lib_Syntax_RImpossible = ( h0 ) => ({ tag: 4,  h0: h0 });
let Lib_Parser_parenTypeExp = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("(")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc$27 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(")"))), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( t ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(")")), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(t))))) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RImpossible({ tag: 0,  h0: fc.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(fc.h1, fc$27.h1) })) )))))))));
let Lib_Syntax_RHole = ( h0 ) => ({ tag: 10,  h0: h0 });
let Lib_Parser_charLit = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(5)), ( v ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RLit(fc, Lib_Types_LChar(Prelude_strIndex(v, 0))))))));
let Lib_Parser_stringLit = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(6)), ( t ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RLit(fc, Lib_Types_LString(t)))))));
let Lib_Parser_interpString_append = ( _$$1, _$$2 ) => { let fc = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$1); let _sc$$0 = Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(_$$2); return Lib_Syntax_RApp({ tag: 0,  h0: fc.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_(fc.h1, _sc$$0.h1) }, Lib_Syntax_RApp(fc, Lib_Syntax_RVar(fc, "_++_"), _$$1, 1), _$$2, 1); };
let Lib_Parser_interp = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(13)), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( tm ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(14)), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(tm)))))));
let Lib_Parser_interpString = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( _$$3 ) => (0), Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(11))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( part ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_stringLit, Lib_Parser_interp)), ( parts ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( _$$3 ) => (0), Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(12))), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_Parser_interpString_append(eta, eta1))), part, parts))))))))));
let Prelude_stringToInt = (s) => {
  let rval = Number(s)
  return isNaN(rval) ? 0 : rval
};
let Lib_Parser_intLit = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(4)), ( t ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RLit(fc, Lib_Types_LInt(Prelude_stringToInt(t))))))));
let Lib_Parser_lit = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_intLit, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_interpString, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_stringLit, Lib_Parser_charLit)));
let Lib_Parser_asAtom = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_ident, ( nm ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("@")), Lib_Parser_parenWrap(Lib_Parser_typeExpr))), ( asPat ) => (( (asPat.tag) == (1) ? Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RVar(fc, nm)) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RAs(fc, nm, asPat.h1)) )))))));
let Lib_Parser_recordUpdate$27 = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("{")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_sepBy(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(";")), Lib_Parser_updateClause), ( clauses ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("}")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_atom), ( tm ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RUpdateRec(fc, clauses, tm))))))))))));
let Lib_Parser_recordUpdate = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("[")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_sepBy(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(";")), Lib_Parser_updateClause), ( clauses ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("]")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_atom), ( tm ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RUpdateRec(fc, clauses, tm))))))))))));
let Lib_Parser_atom = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(0), ( _ ) => (Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Lib_Syntax_RU(eta)), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("U"))), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_recordUpdate$27, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_asAtom, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Lib_Syntax_RVar(eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_uident), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Lib_Syntax_RVar(eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(10))), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_lit, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Lib_Syntax_RImplicit(eta)), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("_"))), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Lib_Syntax_RHole(eta)), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("?"))), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parenTypeExp, Lib_Parser_recordUpdate)))))))))));
let Lib_Parser_pArg = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( x ) => ({ tag: 0,  h2: 0,  h3: { tag: 0,  h2: fc,  h3: x } }), Lib_Parser_braces(Lib_Parser_typeExpr)), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( x ) => ({ tag: 0,  h2: 2,  h3: { tag: 0,  h2: fc,  h3: x } }), Lib_Parser_dbraces(Lib_Parser_typeExpr)), Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( x ) => ({ tag: 0,  h2: 1,  h3: { tag: 0,  h2: fc,  h3: x } }), Lib_Parser_atom)))));
let Lib_Parser_parseOp = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getOps, ( ops ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_atom, ( hd ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_pArg), ( rest ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_pratt(ops, 0, "", hd, rest), ( $$sc ) => (( ($$sc.h3.tag) == (0) ? Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn($$sc.h2) : Lib_Parser_Impl_fail("extra stuff") )))))))))));
let Lib_Parser_term$27 = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_caseExpr, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_caseLet, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_letExpr, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_caseLamExpr, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_lamExpr, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_doExpr, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseIfThen, Lib_Parser_parseOp)))))));
let Lib_Parser_term = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term$27, ( t ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (Prelude__$2C_(eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("$"))), Lib_Parser_term$27)), ( rest ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Parser_term_apply(t, rest))))));
let Lib_Parser_forAll_mkPi = ( _$$1, _$$2 ) => (Lib_Syntax_RPi(_$$1.h2, Lib_Types_BI(_$$1.h2, _$$1.h3, 0, false), Lib_Syntax_RImplicit(_$$1.h2), _$$2));
let Lib_Parser_varname = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ident, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_uident, Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("_")), Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn("_"))));
let Lib_Parser_forAll = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("forall")), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("∀"))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_some(Lib_Parser_addPos(Lib_Parser_varname)), ( all ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(".")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( scope ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( eta ) => (( eta1 ) => (Lib_Parser_forAll_mkPi(eta, eta1))), scope, all))))))))));
let Lib_Parser_binders_mkBind = ( _$$1, _$$2 ) => (Lib_Syntax_RPi(_$$1.h2.h0, _$$1.h2, _$$1.h3, _$$2));
let Lib_Parser_ebind_makeBind = ( _$$1, _$$2, _$$3 ) => ({ tag: 0,  h2: Lib_Types_BI(_$$3.h2, _$$3.h3, 1, _$$1),  h3: _$$2 });
let Lib_Parser_quantity = Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (Prelude_fromMaybe(true, eta)), Lib_Parser_optional(Prelude__$3C$$_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, false, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("0")))));
let Lib_Parser_ebind = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_try(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("(")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_quantity, ( quant ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(Lib_Parser_addPos(Lib_Parser_varname)), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":"))), ( $$sc ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: quant,  h3: $$sc })))))))), ( $$sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(")")), ( _ ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Parser_ebind_makeBind($$sc.h2, ty, eta)), $$sc.h3))))))));
let Lib_Parser_ibind_makeBind = ( _$$1, _$$2, _$$3 ) => ({ tag: 0,  h2: Lib_Types_BI(_$$3.h2, _$$3.h3, 0, _$$1),  h3: Prelude_fromMaybe(Lib_Syntax_RImplicit(_$$3.h2), _$$2) });
let Lib_Parser_ibind = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_try(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("{")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_quantity, ( quant ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_some(Lib_Parser_addPos(Lib_Parser_varname)), ( $$sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: quant,  h3: $$sc })))))))))), ( $$sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("}")), ( _ ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Parser_ibind_makeBind($$sc.h2, Prelude_Just(ty), eta)), $$sc.h3))))))));
let Lib_Parser_abind = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("{{")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_try(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_addPos(Lib_Parser_varname), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":"))))), ( name ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("}}")), ( _1 ) => (( (name.tag) == (1) ? Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 1,  h1: { tag: 0,  h2: Lib_Types_BI(Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC(ty), "_", 2, true),  h3: ty },  h2: { tag: 0 } }) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 1,  h1: { tag: 0,  h2: Lib_Types_BI(name.h1.h2, name.h1.h3, 2, true),  h3: ty },  h2: { tag: 0 } }) )))))))));
let Lib_Parser_binders = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_abind, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ibind, Lib_Parser_ebind))), ( binds ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_arrow, ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( scope ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( eta ) => (( eta1 ) => (Lib_Parser_binders_mkBind(eta, eta1))), scope, Prelude_Prelude_Monad$20Prelude_List$2Cbind(binds, ( _$$1 ) => (_$$1))))))))));
let Lib_Parser_typeExpr = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_binders, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_forAll, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_term, ( exp ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_arrow, Lib_Parser_typeExpr)), ( scope ) => (( (scope.tag) == (1) ? Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(exp) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_RPi(fc, Lib_Types_BI(fc, "_", 1, true), exp, scope.h1)) )))))))));
let Lib_Parser_parseSig = Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (( eta2 ) => (Lib_Syntax_TypeSig(eta, eta1, eta2)))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_try(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ident, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_uident, Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(10))))), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":"))))), Lib_Parser_typeExpr);
let Lib_Parser_getName = ( _$$0 ) => { while (1) { let _$$01 = _$$0; switch (_$$01.tag) { case 2: { _$$0 = _$$01.h1; continue; break; } case 0: return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(_$$01.h1); default: return Lib_Parser_Impl_fail("bad LHS"); } } };
let Lib_Parser_parseDef = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( t ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_getName(t), ( nm ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("="))), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_FunDef(fc, nm, { tag: 1,  h1: { tag: 0,  h2: t,  h3: Prelude_Nothing() },  h2: { tag: 0 } })) : Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( body ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_optional(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("where")), ( _ ) => (Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseSig, Lib_Parser_parseDef)))))))), ( $$sc1 ) => { let body1 = Prelude_maybe(body, ( decls ) => (Lib_Syntax_RWhere($$sc1.h2, decls, body)), $$sc1.h3); return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_FunDef(fc, nm, { tag: 1,  h1: { tag: 0,  h2: t,  h3: Prelude_Just(body1) },  h2: { tag: 0 } })); }))) )))))))));
let Lib_Syntax_DDerive = ( h0, h1, h2 ) => ({ tag: 3,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Parser_parseDerive = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( loc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("derive")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_uident), ( className ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_uident), ( name ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_DDerive(loc, className, name))))))))));
let Lib_Syntax_Exports = ( h0, h1 ) => ({ tag: 12,  h0: h0,  h1: h1 });
let Lib_Parser_parseExport = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( loc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("#export")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_withFC(Lib_Parser_ident)), ( $$sc ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Exports(loc, $$sc))))))));
let Lib_Syntax_Record = ( h0, h1, h2, h3, h4 ) => ({ tag: 11,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Parser_nakedBind_makeBind = ( _$$1 ) => ({ tag: 0,  h2: Lib_Types_BI(_$$1.h2, _$$1.h3, 1, true),  h3: Lib_Syntax_RImplicit(_$$1.h2) });
let Lib_Parser_nakedBind = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_some(Lib_Parser_addPos(Lib_Parser_varname)), ( $$sc ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Parser_nakedBind_makeBind(eta)), $$sc))));
let Lib_Parser_parseRecord = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("record")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_uident), ( name ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ebind, Lib_Parser_nakedBind)), ( teles ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("where")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("constructor")), Lib_Parser_Impl_withFC(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_uident, Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(3)))))), ( cname ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Lib_Parser_parseSig))), ( decls ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Record(fc, name, Prelude_Prelude_Monad$20Prelude_List$2Cbind(teles, ( _$$1 ) => (_$$1)), cname, decls))))))))))))))));
let Lib_Parser_parseInstance = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("instance")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("where"))), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Lib_Parser_parseDef))), ( decls ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Instance(fc, ty, Prelude_Just(decls))))) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Instance(fc, ty, Prelude_Nothing())) )))))))));
let Lib_Syntax_Class = ( h0, h1, h2, h3 ) => ({ tag: 9,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Parser_parseClass = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("class")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_uident), ( name ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ebind, Lib_Parser_nakedBind)), ( teles ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("where")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Lib_Parser_parseSig))), ( decls ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Class(fc, name, Prelude_Prelude_Monad$20Prelude_List$2Cbind(teles, ( _$$1 ) => (_$$1)), decls))))))))))))));
let Lib_Syntax_ShortData = ( h0, h1, h2 ) => ({ tag: 5,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Parser_parseShortData = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("data")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( lhs ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("=")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_sepBy(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("|")), Lib_Parser_typeExpr), ( sigs ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_ShortData(fc, lhs, sigs))))))))))));
let Lib_Parser_parseData = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_try(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$2A$3E_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("data")), Lib_Parser_Impl_withFC(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_uident, Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(3))))), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")))), ( name ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("where"))), ( $$sc ) => (( ($$sc.tag) == (0) ? Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_startBlock(Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Lib_Parser_parseSig))), ( decls ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Data(fc, name, ty, Prelude_Just(decls))))) : Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_Data(fc, name, ty, Prelude_Nothing())) )))))))));
let Lib_Syntax_DCheck = ( h0, h1, h2 ) => ({ tag: 2,  h0: h0,  h1: h1,  h2: h2 });
let Lib_Parser_parseNorm = Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(Prelude__$3C$2A_(Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(( eta ) => (( eta1 ) => (( eta2 ) => (Lib_Syntax_DCheck(eta, eta1, eta2)))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("#check"))), Lib_Parser_typeExpr), Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":"))), Lib_Parser_typeExpr);
let Lib_Syntax_PFunc = ( h0, h1, h2, h3, h4 ) => ({ tag: 7,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Parser_parsePFunc = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("pfunc")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_ident, ( nm ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("uses")), ( _1 ) => (Lib_Parser_parenWrap(Lib_Parser_Impl_many(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_uident, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ident, Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(3))))))))), ( used ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), ( _1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_typeExpr, ( ty ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":=")), ( _2 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(7)), ( src ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_PFunc(fc, nm, Prelude_fromMaybe({ tag: 0 }, used), ty, src))))))))))))))))));
let Lib_Parser_parsePType = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("ptype")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_uident, ( $$sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_optional(Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27(":")), ( _1 ) => (Lib_Parser_typeExpr))), ( ty ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_PType(fc, $$sc, ty))))))))));
let Lib_Syntax_PMixFix = ( h0, h1, h2, h3 ) => ({ tag: 8,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Parser_Impl_addOp = ( _$$0, _$$1, _$$2 ) => (Lib_Parser_Impl_P(( last ) => (( toks ) => (( com ) => (( ops ) => (( col ) => { let parts = Prelude_splitBy(_$$0, "_"); if ((parts.tag) == (1)) { switch (parts.h1) { case "": return ( (parts.h2.tag) == (1) ? Lib_Parser_Impl_OK(0, last, toks, com, Data_SortedMap_updateMap(parts.h2.h1, Lib_Common_MkOp(_$$0, _$$1, _$$2, false, parts.h2.h2), ops)) : Lib_Parser_Impl_OK(0, last, toks, com, Data_SortedMap_updateMap(parts.h1, Lib_Common_MkOp(_$$0, _$$1, _$$2, true, parts.h2), ops)) ); default: return Lib_Parser_Impl_OK(0, last, toks, com, Data_SortedMap_updateMap(parts.h1, Lib_Common_MkOp(_$$0, _$$1, _$$2, true, parts.h2), ops)); } } else { return Lib_Parser_Impl_Fail(Lib_Parser_Impl_perror(col.h0, toks, "Internal error parsing mixfix"), last, toks, com, ops); } }))))));
let Lib_Common_MkOp = ( h0, h1, h2, h3, h4 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Parser_parseMixfix = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Prelude__$3C$$_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, 0, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("infixl"))), Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Prelude__$3C$$_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, 1, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("infixr"))), Prelude__$3C$$_(Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, 2, Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("infix"))))), ( fix ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(4)), ( prec ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_some(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(3))), ( ops ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, ops, ( op ) => (Lib_Parser_Impl_addOp(op, Prelude_stringToInt(prec), fix))), ( _ ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Lib_Syntax_PMixFix(fc, ops, Prelude_stringToInt(prec), fix))))))))))));
let Lib_Parser_parseDecl = Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseMixfix, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parsePType, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parsePFunc, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseNorm, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseData, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseShortData, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseClass, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseInstance, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseRecord, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseExport, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseDerive, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_parseSig, Lib_Parser_parseDef))))))))))));
let Lib_Parser_Impl_partialParse = ( _$$1, _$$2, _$$3, _$$4 ) => { let sc$$5 = Lib_Parser_Impl_runP(_$$2)(Lib_Common_emptyBounds)(_$$4)(false)(_$$3)({ tag: 0,  h0: _$$1,  h1: Lib_Common_MkBounds(0, 0, 0, 0) }); return ( (sc$$5.tag) == (1) ? Prelude_Left({ tag: 0,  h2: sc$$5.h1,  h3: sc$$5.h3 }) : Prelude_Right({ tag: 0,  h2: sc$$5.h1,  h3: { tag: 0,  h2: sc$$5.h5,  h3: sc$$5.h3 } }) ); };
let Lib_ProcessModule_mergeOps = ( _$$0, _$$1 ) => (Data_SortedMap_foldMap(( _$$4 ) => (( _$$5 ) => (_$$5)), _$$1, Data_SortedMap_toList(_$$0)));
let Data_SortedMap_foldMap = ( _$$2, _$$3, _$$4 ) => { while (1) { let _$$21 = _$$2; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$41.tag) == (1)) { let sc$$12 = Data_SortedMap_lookupMap(_$$41.h1.h2, _$$31); if ((sc$$12.tag) == (1)) { _$$2 = _$$21; _$$3 = Data_SortedMap_updateMap(_$$41.h1.h2, _$$41.h1.h3, _$$31); _$$4 = _$$41.h2; continue; } else { _$$2 = _$$21; _$$3 = Data_SortedMap_updateMap(_$$41.h1.h2, _$$21(sc$$12.h1.h3)(_$$41.h1.h3), _$$31); _$$4 = _$$41.h2; continue; } } else { return _$$31; } } };
let Data_SortedMap_lookupMap = ( _$$2, _$$3 ) => (( (_$$3.tag) == (1) ? Data_SortedMap_lookupT23(_$$3.h3, _$$2, _$$3.h4) : Prelude_Nothing() ));
let Lib_ProcessModule_importHints = ( _$$0 ) => (( (_$$0.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_elem(Lib_Types_Prelude_Eq$20Lib_Types_EFlag, 0, _$$0.h1.h4), ( _ ) => (Lib_TopContext_addHint(_$$0.h1.h1))), ( _ ) => (Lib_ProcessModule_importHints(_$$0.h2))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ));
let Lib_Types_Prelude_Eq$20Lib_Types_EFlag$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1) { case 2: switch (_$$0) { case 2: return true; default: return false; } break; case 1: switch (_$$0) { case 1: return true; default: return false; } break; case 0: switch (_$$0) { case 0: return true; default: return false; } break; } };
let Lib_Types_Prelude_Eq$20Lib_Types_EFlag = Prelude_MkEq(( eta ) => (( eta1 ) => (Lib_Types_Prelude_Eq$20Lib_Types_EFlag$2C_$3D$3D_(eta, eta1))));
let Lib_Parser_parseImport = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("import")), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_uident), ( $$sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_withFC(Lib_Parser_Impl_many(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(10)))), ( $$sc1 ) => { let nameFC = ( ($$sc1.h3.tag) == (1) ? { tag: 0,  h0: $$sc.h2.h0,  h1: Lib_Common_Prelude_Add$20Lib_Common_Bounds$2C_$2B_($$sc.h2.h1, $$sc1.h2.h1) } : $$sc.h2 ); let name = Prelude_joinBy("", { tag: 1,  h1: $$sc.h3,  h2: $$sc1.h3 }); return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h0: fc,  h1: { tag: 0,  h2: nameFC,  h3: name } }); })))))));
let Lib_Parser_parseImports = Lib_Parser_Impl_many(Lib_Parser_Impl_sameLevel(Lib_Parser_parseImport));
let Lib_Parser_parseModHeader = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_sameLevel(Lib_Parser_Impl_indented(Lib_Parser_Impl_keyword$27("module"))), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_getPos, ( fc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_uident, ( name ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(10))), ( rest ) => { let name1 = Prelude_joinBy("", { tag: 1,  h1: name,  h2: rest }); return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h2: fc,  h3: name1 }); })))))));
let Lib_Tokenizer_tokenise = ( _$$0, _$$1 ) => { let sc$$2 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(0, 0, { tag: 0 }, Prelude_unpack(_$$1))); return ( (sc$$2.tag) == (1) ? ( (sc$$2.h2.h3.tag) == (0) ? Prelude_Right(Prelude__$3C$3E$3E_(sc$$2.h2.h2, { tag: 0 })) : Prelude_Left(Lib_Error_E({ tag: 0,  h0: _$$0,  h1: Lib_Common_MkBounds(sc$$2.h2.h0, sc$$2.h2.h1, sc$$2.h2.h0, (sc$$2.h2.h1) + (1)) }, "Extra toks")) ) : ( (sc$$2.h2.tag) == (0) ? Prelude_Left(Lib_Error_E({ tag: 0,  h0: _$$0,  h1: sc$$2.h2.h0.h1 }, sc$$2.h2.h1)) : Prelude_Left(sc$$2.h2) ) ); };
let Lib_Tokenizer_TS = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_Tokenizer_rawTokenise = ( _$$0 ) => (bouncer(Lib_Tokenizer_REC_rawTokenise, { tag: 1,  h0: _$$0 }));
let Lib_Tokenizer_REC_rawTokenise = ( arg ) => { switch (arg.tag) { case 1: { if ((arg.h0.h3.tag) == (1)) { switch (arg.h0.h3.h1) { case " ": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), arg.h0.h2, arg.h0.h3.h2) }; case "\n": return { tag: 1,  h0: Lib_Tokenizer_TS((arg.h0.h0) + (1), 0, arg.h0.h2, arg.h0.h3.h2) }; case "\"": { let tok = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (1), 11, "\""); let sc$$18 = Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), { tag: 1,  h1: arg.h0.h2,  h2: tok }, arg.h0.h3.h2), arg.h0.h0, (arg.h0.h1) + (1), { tag: 0 }); if ((sc$$18.tag) == (1)) { if ((sc$$18.h2.h3.tag) == (1)) { switch (sc$$18.h2.h3.h1) { case "\"": { let tok1 = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, sc$$18.h2.h0, (sc$$18.h2.h1) + (1), 12, "\""); return { tag: 1,  h0: Lib_Tokenizer_TS(sc$$18.h2.h0, (sc$$18.h2.h1) + (1), { tag: 1,  h1: sc$$18.h2.h2,  h2: tok1 }, sc$$18.h2.h3.h2) }; break; } default: return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$18.h2.h0, sc$$18.h2.h1, sc$$18.h2.h0, (sc$$18.h2.h1) + (1)) }, "Expected '\"'")) }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$18.h2.h0, sc$$18.h2.h1, sc$$18.h2.h0, (sc$$18.h2.h1) + (1)) }, "Expected '\"'")) }; } } else { return { tag: 0,  h0: Prelude_Left(sc$$18.h2) }; } break; } case "}": return { tag: 0,  h0: Prelude_Right(arg.h0) }; case "{": { if ((arg.h0.h3.h2.tag) == (1)) { switch (arg.h0.h3.h2.h1) { case "{": { let tok = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (2), 2, "{{"); let sc$$21 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (2), { tag: 1,  h1: arg.h0.h2,  h2: tok }, arg.h0.h3.h2.h2)); if ((sc$$21.tag) == (1)) { if ((sc$$21.h2.h3.tag) == (1)) { switch (sc$$21.h2.h3.h1) { case "}": { if ((sc$$21.h2.h3.h2.tag) == (1)) { switch (sc$$21.h2.h3.h2.h1) { case "}": { let tok1 = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, sc$$21.h2.h0, (sc$$21.h2.h1) + (2), 2, "}}"); return { tag: 1,  h0: Lib_Tokenizer_TS(sc$$21.h2.h0, (sc$$21.h2.h1) + (2), { tag: 1,  h1: sc$$21.h2.h2,  h2: tok1 }, sc$$21.h2.h3.h2.h2) }; break; } default: return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$21.h2.h0, sc$$21.h2.h1, sc$$21.h2.h0, (sc$$21.h2.h1) + (1)) }, "Expected '}}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$21.h2.h0, sc$$21.h2.h1, sc$$21.h2.h0, (sc$$21.h2.h1) + (1)) }, "Expected '}}'")) }; } break; } default: return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$21.h2.h0, sc$$21.h2.h1, sc$$21.h2.h0, (sc$$21.h2.h1) + (1)) }, "Expected '}}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$21.h2.h0, sc$$21.h2.h1, sc$$21.h2.h0, (sc$$21.h2.h1) + (1)) }, "Expected '}}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(sc$$21.h2) }; } break; } default: { let tok = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (1), 8, "{"); let sc$$21 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), { tag: 1,  h1: arg.h0.h2,  h2: tok }, arg.h0.h3.h2)); if ((sc$$21.tag) == (1)) { if ((sc$$21.h2.h3.tag) == (1)) { switch (sc$$21.h2.h3.h1) { case "}": { let tok1 = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, sc$$21.h2.h0, (sc$$21.h2.h1) + (1), 8, "}"); return { tag: 1,  h0: Lib_Tokenizer_TS(sc$$21.h2.h0, (sc$$21.h2.h1) + (1), { tag: 1,  h1: sc$$21.h2.h2,  h2: tok1 }, sc$$21.h2.h3.h2) }; break; } default: return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$21.h2.h0, sc$$21.h2.h1, sc$$21.h2.h0, (sc$$21.h2.h1) + (1)) }, "Expected '}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$21.h2.h0, sc$$21.h2.h1, sc$$21.h2.h0, (sc$$21.h2.h1) + (1)) }, "Expected '}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(sc$$21.h2) }; } break; } } } else { let tok = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (1), 8, "{"); let sc$$18 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), { tag: 1,  h1: arg.h0.h2,  h2: tok }, arg.h0.h3.h2)); if ((sc$$18.tag) == (1)) { if ((sc$$18.h2.h3.tag) == (1)) { switch (sc$$18.h2.h3.h1) { case "}": { let tok1 = Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, sc$$18.h2.h0, (sc$$18.h2.h1) + (1), 8, "}"); return { tag: 1,  h0: Lib_Tokenizer_TS(sc$$18.h2.h0, (sc$$18.h2.h1) + (1), { tag: 1,  h1: sc$$18.h2.h2,  h2: tok1 }, sc$$18.h2.h3.h2) }; break; } default: return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$18.h2.h0, sc$$18.h2.h1, sc$$18.h2.h0, (sc$$18.h2.h1) + (1)) }, "Expected '}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$18.h2.h0, sc$$18.h2.h1, sc$$18.h2.h0, (sc$$18.h2.h1) + (1)) }, "Expected '}'")) }; } } else { return { tag: 0,  h0: Prelude_Left(sc$$18.h2) }; } } break; } case ",": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (1), 0, ",") }, arg.h0.h3.h2) }; case "_": { if ((arg.h0.h3.h2.tag) == (1)) { switch (arg.h0.h3.h2.h1) { case ",": { if ((arg.h0.h3.h2.h2.tag) == (1)) { switch (arg.h0.h3.h2.h2.h1) { case "_": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (3), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (3), 3, "_,_") }, arg.h0.h3.h2.h2.h2) }; default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } case ".": { if ((arg.h0.h3.h2.h2.tag) == (1)) { switch (arg.h0.h3.h2.h2.h1) { case "_": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (3), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (3), 3, "_._") }, arg.h0.h3.h2.h2.h2) }; default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } case "'": { if ((arg.h0.h3.h2.tag) == (1)) { switch (arg.h0.h3.h2.h1) { case "\\": { if ((arg.h0.h3.h2.h2.tag) == (1)) { if ((arg.h0.h3.h2.h2.h2.tag) == (1)) { switch (arg.h0.h3.h2.h2.h2.h1) { case "'": { let ch; switch (arg.h0.h3.h2.h2.h1) { case "n": { ch = "\n"; break; } case "t": { ch = Prelude_chr(9); break; } default: { ch = arg.h0.h3.h2.h2.h1; break; } } return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (4), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (4), 5, Prelude_pack({ tag: 1,  h1: ch,  h2: { tag: 0 } })) }, arg.h0.h3.h2.h2.h2.h2) }; break; } default: switch (arg.h0.h3.h2.h2.h1) { case "'": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (3), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (3), 5, Prelude_pack({ tag: 1,  h1: arg.h0.h3.h2.h1,  h2: { tag: 0 } })) }, arg.h0.h3.h2.h2.h2) }; default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } } else { switch (arg.h0.h3.h2.h2.h1) { case "'": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (3), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (3), 5, Prelude_pack({ tag: 1,  h1: arg.h0.h3.h2.h1,  h2: { tag: 0 } })) }, arg.h0.h3.h2.h2.h2) }; default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } default: { if ((arg.h0.h3.h2.h2.tag) == (1)) { switch (arg.h0.h3.h2.h2.h1) { case "'": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (3), { tag: 1,  h1: arg.h0.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, false, arg.h0.h0, (arg.h0.h1) + (3), 5, Prelude_pack({ tag: 1,  h1: arg.h0.h3.h2.h1,  h2: { tag: 0 } })) }, arg.h0.h3.h2.h2.h2) }; default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } case "#": return { tag: 3,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), arg.h0.h2, arg.h0.h3.h2),  h13: 9,  h14: ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, eta)),  h15: { tag: 1,  h1: { tag: 0 },  h2: "#" } }; case "/": { if ((arg.h0.h3.h2.tag) == (1)) { switch (arg.h0.h3.h2.h1) { case "-": return { tag: 4,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (2), arg.h0.h2, arg.h0.h3.h2.h2) }; default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } case "`": return { tag: 5,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), arg.h0.h2, arg.h0.h3.h2),  h9: { tag: 0 } }; case ".": return { tag: 3,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), arg.h0.h2, arg.h0.h3.h2),  h13: 10,  h14: ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, eta)),  h15: { tag: 1,  h1: { tag: 0 },  h2: "." } }; case "-": { if ((arg.h0.h3.h2.tag) == (1)) { switch (arg.h0.h3.h2.h1) { case "-": return { tag: 6,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (2), arg.h0.h2, arg.h0.h3.h2.h2) }; default: { let sc$$20 = Prelude_isDigit(arg.h0.h3.h2.h1); switch (sc$$20) { case true: return { tag: 3,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (2), arg.h0.h2, arg.h0.h3.h2.h2),  h13: 4,  h14: ( eta ) => (Prelude_isDigit(eta)),  h15: { tag: 1,  h1: { tag: 1,  h1: { tag: 0 },  h2: "-" },  h2: arg.h0.h3.h2.h1 } }; case false: return { tag: 3,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: Lib_Tokenizer_TS(arg.h0.h0, (arg.h0.h1) + (1), arg.h0.h2, { tag: 1,  h1: arg.h0.h3.h2.h1,  h2: arg.h0.h3.h2.h2 }),  h13: 0,  h14: ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(arg.h0, arg.h0.h0, arg.h0.h1, arg.h0.h2, arg.h0.h3, eta)),  h15: { tag: 1,  h1: { tag: 0 },  h2: "-" } }; } break; } } } else { return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } break; } default: return { tag: 2,  h0: arg.h0,  h1: arg.h0.h0,  h2: arg.h0.h1,  h3: arg.h0.h2,  h4: arg.h0.h3,  h5: null,  h6: null,  h7: null,  h8: null,  h9: null,  h10: null,  h11: null,  h12: null,  h13: arg.h0.h3.h1,  h14: arg.h0.h3.h2 }; } } else { return { tag: 0,  h0: Prelude_Right(arg.h0) }; } break; } case 2: { let sc$$15 = Prelude_elem(Prelude_Prelude_Eq$20Prim_Char, arg.h13, Lib_Tokenizer_standalone); switch (sc$$15) { case true: return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h1, (arg.h2) + (1), { tag: 1,  h1: arg.h3,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h1, arg.h2, arg.h3, arg.h4, true, arg.h1, (arg.h2) + (1), 8, Prelude_pack({ tag: 1,  h1: arg.h13,  h2: { tag: 0 } })) }, arg.h14) }; case false: { let sc$$16 = Prelude_isDigit(arg.h13); switch (sc$$16) { case true: return { tag: 3,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: arg.h11,  h12: Lib_Tokenizer_TS(arg.h1, arg.h2, arg.h3, { tag: 1,  h1: arg.h13,  h2: arg.h14 }),  h13: 4,  h14: ( eta ) => (Prelude_isDigit(eta)),  h15: { tag: 0 } }; case false: { let kind; let sc$$17 = Prelude_isUpper(arg.h13); switch (sc$$17) { case true: { kind = 1; break; } case false: { kind = 0; break; } } return { tag: 3,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: arg.h11,  h12: Lib_Tokenizer_TS(arg.h1, arg.h2, arg.h3, { tag: 1,  h1: arg.h13,  h2: arg.h14 }),  h13: kind,  h14: ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(arg.h0, arg.h1, arg.h2, arg.h3, arg.h4, eta)),  h15: { tag: 0 } }; break; } } break; } } break; } case 3: { if ((arg.h12.h3.tag) == (1)) { let sc$$23 = arg.h14(arg.h12.h3.h1); switch (sc$$23) { case true: return { tag: 3,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: arg.h11,  h12: Lib_Tokenizer_TS(arg.h12.h0, (arg.h12.h1) + (1), arg.h12.h2, arg.h12.h3.h2),  h13: arg.h13,  h14: arg.h14,  h15: { tag: 1,  h1: arg.h15,  h2: arg.h12.h3.h1 } }; case false: { let kind; let sc$$24 = Data_SnocList_snocelem(Prelude_Prelude_Eq$20Prim_Char, "_", arg.h15); switch (sc$$24) { case true: { kind = 3; break; } case false: { kind = arg.h13; break; } } return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h12.h0, arg.h12.h1, { tag: 1,  h1: arg.h12.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h1, arg.h2, arg.h3, arg.h4, true, arg.h12.h0, (arg.h12.h1) - (1), kind, Prelude_pack(Prelude__$3C$3E$3E_(arg.h15, { tag: 0 }))) }, { tag: 1,  h1: arg.h12.h3.h1,  h2: arg.h12.h3.h2 }) }; break; } } } else { return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h12.h0, arg.h12.h1, { tag: 1,  h1: arg.h12.h2,  h2: Lib_Tokenizer_rawTokenise_mktok(arg.h0, arg.h1, arg.h2, arg.h3, arg.h4, true, arg.h12.h0, arg.h12.h1, arg.h13, Prelude_pack(Prelude__$3C$3E$3E_(arg.h15, { tag: 0 }))) }, { tag: 0 }) }; } break; } case 4: { if ((arg.h11.h3.tag) == (1)) { switch (arg.h11.h3.h1) { case "-": { if ((arg.h11.h3.h2.tag) == (1)) { switch (arg.h11.h3.h2.h1) { case "/": return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h11.h0, (arg.h11.h1) + (2), arg.h11.h2, arg.h11.h3.h2.h2) }; default: return { tag: 4,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: Lib_Tokenizer_TS(arg.h11.h0, (arg.h11.h1) + (1), arg.h11.h2, arg.h11.h3.h2) }; } } else { return { tag: 4,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: Lib_Tokenizer_TS(arg.h11.h0, (arg.h11.h1) + (1), arg.h11.h2, arg.h11.h3.h2) }; } break; } case "\n": return { tag: 4,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: Lib_Tokenizer_TS((arg.h11.h0) + (1), 0, arg.h11.h2, arg.h11.h3.h2) }; default: return { tag: 4,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: arg.h10,  h11: Lib_Tokenizer_TS(arg.h11.h0, (arg.h11.h1) + (1), arg.h11.h2, arg.h11.h3.h2) }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(arg.h11.h0, arg.h11.h1, arg.h11.h0, arg.h11.h1) }, "EOF in block comment")) }; } break; } case 5: { if ((arg.h8.h3.tag) == (1)) { switch (arg.h8.h3.h1) { case "`": { let tok = { tag: 0,  h1: { tag: 0,  h0: 7,  h1: Prelude_pack(Prelude__$3C$3E$3E_(arg.h9, { tag: 0 })) },  h2: Lib_Common_MkBounds(arg.h1, arg.h2, arg.h8.h0, (arg.h8.h1) + (1)) }; return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h8.h0, (arg.h8.h1) + (1), { tag: 1,  h1: arg.h8.h2,  h2: tok }, arg.h8.h3.h2) }; break; } case "\n": return { tag: 5,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: Lib_Tokenizer_TS((arg.h8.h0) + (1), 0, arg.h8.h2, arg.h8.h3.h2),  h9: { tag: 1,  h1: arg.h9,  h2: "\n" } }; default: return { tag: 5,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: Lib_Tokenizer_TS(arg.h8.h0, (arg.h8.h1) + (1), arg.h8.h2, arg.h8.h3.h2),  h9: { tag: 1,  h1: arg.h9,  h2: arg.h8.h3.h1 } }; } } else { return { tag: 0,  h0: Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(arg.h8.h0, arg.h8.h1, arg.h8.h0, arg.h8.h1) }, "EOF in backtick string")) }; } break; } case 6: { if ((arg.h10.h3.tag) == (1)) { switch (arg.h10.h3.h1) { case "\n": return { tag: 1,  h0: Lib_Tokenizer_TS((arg.h10.h0) + (1), 0, arg.h10.h2, arg.h10.h3.h2) }; default: return { tag: 6,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: Lib_Tokenizer_TS(arg.h10.h0, (arg.h10.h1) + (1), arg.h10.h2, arg.h10.h3.h2) }; } } else { return { tag: 1,  h0: Lib_Tokenizer_TS(arg.h10.h0, arg.h10.h1, arg.h10.h2, { tag: 0 }) }; } break; } } };
let Lib_Tokenizer_rawTokenise_mktok = ( _, _1, _2, _3, _4, _$$9, _$$10, _$$11, _$$12, _$$13 ) => { let kind; let sc$$14 = (_$$9) && (Prelude_elem(Prelude_Prelude_Eq$20Prim_String, _$$13, Lib_Tokenizer_keywords)); switch (sc$$14) { case true: { kind = 2; break; } case false: { kind = _$$12; break; } } return { tag: 0,  h1: { tag: 0,  h0: kind,  h1: _$$13 },  h2: Lib_Common_MkBounds(_1, _2, _$$10, (_$$11) + (1)) }; };
let Lib_Tokenizer_keywords = { tag: 1,  h1: "let",  h2: { tag: 1,  h1: "in",  h2: { tag: 1,  h1: "where",  h2: { tag: 1,  h1: "case",  h2: { tag: 1,  h1: "of",  h2: { tag: 1,  h1: "data",  h2: { tag: 1,  h1: "U",  h2: { tag: 1,  h1: "do",  h2: { tag: 1,  h1: "ptype",  h2: { tag: 1,  h1: "pfunc",  h2: { tag: 1,  h1: "module",  h2: { tag: 1,  h1: "infixl",  h2: { tag: 1,  h1: "infixr",  h2: { tag: 1,  h1: "infix",  h2: { tag: 1,  h1: "∀",  h2: { tag: 1,  h1: "forall",  h2: { tag: 1,  h1: "import",  h2: { tag: 1,  h1: "uses",  h2: { tag: 1,  h1: "derive",  h2: { tag: 1,  h1: "class",  h2: { tag: 1,  h1: "instance",  h2: { tag: 1,  h1: "record",  h2: { tag: 1,  h1: "constructor",  h2: { tag: 1,  h1: "if",  h2: { tag: 1,  h1: "then",  h2: { tag: 1,  h1: "else",  h2: { tag: 1,  h1: "$",  h2: { tag: 1,  h1: "λ",  h2: { tag: 1,  h1: "?",  h2: { tag: 1,  h1: "@",  h2: { tag: 1,  h1: ".",  h2: { tag: 1,  h1: "->",  h2: { tag: 1,  h1: "→",  h2: { tag: 1,  h1: ":",  h2: { tag: 1,  h1: "=>",  h2: { tag: 1,  h1: ":=",  h2: { tag: 1,  h1: "$=",  h2: { tag: 1,  h1: "=",  h2: { tag: 1,  h1: "<-",  h2: { tag: 1,  h1: "\\",  h2: { tag: 1,  h1: "_",  h2: { tag: 1,  h1: "|",  h2: { tag: 0 } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } };
let Prelude_Prelude_Eq$20Prim_Char$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude_eqChar(_$$0, _$$1));
let Prelude_Prelude_Eq$20Prim_Char = Prelude_MkEq(( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prim_Char$2C_$3D$3D_(eta, eta1))));
let Data_SnocList_snocelem = ( _$$1, _$$2, _$$3 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { let sc$$7 = Prelude__$3D$3D_(_$$11)(_$$21)(_$$31.h2); switch (sc$$7) { case true: return true; case false: { _$$1 = _$$11; _$$2 = _$$21; _$$3 = _$$31.h1; continue; break; } } } else { return false; } } };
let Lib_Tokenizer_rawTokenise_isIdent = ( _, _1, _2, _3, _4, _$$6 ) => (Prelude_not((Prelude_isSpace(_$$6)) || (Prelude_elem(Prelude_Prelude_Eq$20Prim_Char, _$$6, Lib_Tokenizer_standalone))));
let Lib_Tokenizer_standalone = Prelude_unpack("()\\{}[],.@;");
let Prelude_isSpace = ( _$$0 ) => { switch (_$$0) { case " ": return true; case "\n": return true; default: return false; } };
let Prelude_isDigit = ( _$$0 ) => { switch (_$$0) { case "0": return true; case "1": return true; case "2": return true; case "3": return true; case "4": return true; case "5": return true; case "6": return true; case "7": return true; case "8": return true; case "9": return true; default: return false; } };
let Prelude_chr = (c) => String.fromCharCode(c);
let Lib_Tokenizer_quoteTokenise = ( _$$0, _$$1, _$$2, _$$3 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$01.h3.tag) == (1)) { switch (_$$01.h3.h1) { case "\"": return Prelude_Right(Lib_Tokenizer_TS(_$$01.h0, _$$01.h1, { tag: 1,  h1: _$$01.h2,  h2: Lib_Tokenizer_quoteTokenise_stok(_$$01, _$$11, _$$21, _$$31, _$$01.h0, _$$01.h1, _$$01.h2, _$$01.h3) }, _$$01.h3)); case "\n": return Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(_$$01.h0, _$$01.h1, _$$01.h0, _$$01.h1) }, "Newline in string")); case "\\": { if ((_$$01.h3.h2.tag) == (1)) { switch (_$$01.h3.h2.h1) { case "{": { let tok = { tag: 0,  h1: { tag: 0,  h0: 13,  h1: "\\{" },  h2: Lib_Common_MkBounds(_$$01.h0, _$$01.h1, _$$01.h0, (_$$01.h1) + (2)) }; let sc$$17 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$01.h0, (_$$01.h1) + (2), { tag: 1,  h1: { tag: 1,  h1: _$$01.h2,  h2: Lib_Tokenizer_quoteTokenise_stok(_$$01, _$$11, _$$21, _$$31, _$$01.h0, _$$01.h1, _$$01.h2, _$$01.h3) },  h2: tok }, _$$01.h3.h2.h2)); if ((sc$$17.tag) == (1)) { if ((sc$$17.h2.h3.tag) == (1)) { switch (sc$$17.h2.h3.h1) { case "}": { let tok1 = { tag: 0,  h1: { tag: 0,  h0: 14,  h1: "}" },  h2: Lib_Common_MkBounds(sc$$17.h2.h0, sc$$17.h2.h1, sc$$17.h2.h0, (sc$$17.h2.h1) + (1)) }; _$$0 = Lib_Tokenizer_TS(sc$$17.h2.h0, (sc$$17.h2.h1) + (1), { tag: 1,  h1: sc$$17.h2.h2,  h2: tok1 }, sc$$17.h2.h3.h2); _$$1 = sc$$17.h2.h0; _$$2 = (sc$$17.h2.h1) + (1); _$$3 = { tag: 0 }; continue; break; } default: return Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$17.h2.h0, sc$$17.h2.h1, sc$$17.h2.h0, sc$$17.h2.h1) }, "Expected '{'")); } } else { return Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(sc$$17.h2.h0, sc$$17.h2.h1, sc$$17.h2.h0, sc$$17.h2.h1) }, "Expected '{'")); } } else { return Prelude_Left(sc$$17.h2); } break; } case "n": { _$$0 = Lib_Tokenizer_TS(_$$01.h0, (_$$01.h1) + (2), _$$01.h2, _$$01.h3.h2.h2); _$$1 = _$$11; _$$2 = _$$21; _$$3 = { tag: 1,  h1: _$$31,  h2: "\n" }; continue; break; } case "t": { _$$0 = Lib_Tokenizer_TS(_$$01.h0, (_$$01.h1) + (2), _$$01.h2, _$$01.h3.h2.h2); _$$1 = _$$11; _$$2 = _$$21; _$$3 = { tag: 1,  h1: _$$31,  h2: Prelude_chr(9) }; continue; break; } default: { _$$0 = Lib_Tokenizer_TS(_$$01.h0, (_$$01.h1) + (2), _$$01.h2, _$$01.h3.h2.h2); _$$1 = _$$11; _$$2 = _$$21; _$$3 = { tag: 1,  h1: _$$31,  h2: _$$01.h3.h2.h1 }; continue; break; } } } else { _$$0 = Lib_Tokenizer_TS(_$$01.h0, (_$$01.h1) + (1), _$$01.h2, _$$01.h3.h2); _$$1 = _$$11; _$$2 = _$$21; _$$3 = { tag: 1,  h1: _$$31,  h2: _$$01.h3.h1 }; continue; } break; } default: { _$$0 = Lib_Tokenizer_TS(_$$01.h0, (_$$01.h1) + (1), _$$01.h2, _$$01.h3.h2); _$$1 = _$$11; _$$2 = _$$21; _$$3 = { tag: 1,  h1: _$$31,  h2: _$$01.h3.h1 }; continue; break; } } } else { return Prelude_Left(Lib_Error_E({ tag: 0,  h0: "",  h1: Lib_Common_MkBounds(_$$01.h0, _$$01.h1, _$$01.h0, _$$01.h1) }, "Expected '\"' at EOF")); } } };
let Lib_Tokenizer_quoteTokenise_stok = ( _, _1, _2, _3, _4, _5, _6, _7 ) => ({ tag: 0,  h1: { tag: 0,  h0: 6,  h1: Prelude_pack(Prelude__$3C$3E$3E_(_3, { tag: 0 })) },  h2: Lib_Common_MkBounds(_1, _2, _4, (_5) + (1)) });
let Lib_ProcessModule__getFile = ( $$self$$0 ) => ($$self$$0.h1);
let Main_dirFileSource = ( _$$0 ) => ({ tag: 0,  h0: _$$0,  h1: ( fc ) => (( fn ) => { let fn1 = (_$$0) + (("/") + (fn)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Node_readFile(fn1)), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: fn1,  h3: $$sc.h2 }) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(fc, (((("error reading ") + (fn1)) + (": ")) + ($$sc.h2)) + (""))), eta)))) ))); }) });
let Node_readFile = (fn) => (w) => {
  let result
  try {
    let content = fs.readFileSync(fn, 'utf8')
    result = Prelude_Right(content)
  } catch (e) {
    result = Prelude_Left(e+'')
  }
  return Prelude_MkIORes(result, w)
};
let Lib_ProcessModule_invalidateModule = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let modules = Prelude_Prelude_Monad$20Prelude_List$2Cbind(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_ProcessModule_invalidateModule_getDeps(_$$0, eta)), Data_SortedMap_toList(top.h0)), ( _$$1 ) => (_$$1)); let revMap = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => ({ tag: 0,  h2: _$$2.h3,  h3: _$$2.h2 }), modules); let deps = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_ProcessModule_invalidateModule_accumulate(_$$0, eta, eta1))), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), revMap); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(Lib_ProcessModule_invalidateModule_go(_$$0, deps, { tag: 1,  h1: _$$0,  h2: { tag: 0 } }, tc.h0), tc.h1, tc.h2, tc.h3, tc.h4, tc.h5)))); }));
let Lib_ProcessModule_invalidateModule_go = ( _, _$$4, _$$5, _$$6 ) => { while (1) { let _1 = _; let _$$41 = _$$4; let _$$51 = _$$5; let _$$61 = _$$6; if ((_$$51.tag) == (1)) { let sc$$10 = Data_SortedMap_lookupMap(_$$51.h1, _$$61); if ((sc$$10.tag) == (0)) { let ds = Prelude_fromMaybe({ tag: 0 }, Data_SortedMap_lookupMap$27(_$$51.h1, _$$41)); _ = _1; _$$4 = _$$41; _$$5 = Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(ds, _$$51.h2); _$$6 = Data_SortedMap_deleteMap(_$$51.h1, _$$61); continue; } else { _ = _1; _$$4 = _$$41; _$$5 = _$$51.h2; _$$6 = _$$61; continue; } } else { return _$$61; } } };
let Data_SortedMap_deleteMap = ( _$$2, _$$3 ) => { if ((_$$3.tag) == (1)) { switch (_$$3.h2) { case 0: { let sc$$9 = Data_SortedMap_deleteT23(_$$3.h3, 0, _$$2, _$$3.h4); return ( (sc$$9.tag) == (1) ? Data_SortedMap_EmptyMap(_$$3.h3) : Data_SortedMap_MapOf(0, _$$3.h3, sc$$9.h2) ); break; } default: { let x = (_$$3.h2) - (1); let sc$$10 = Data_SortedMap_deleteT23(_$$3.h3, (1) + (x), _$$2, _$$3.h4); return ( (sc$$10.tag) == (1) ? Data_SortedMap_MapOf(x, _$$3.h3, sc$$10.h2) : Data_SortedMap_MapOf((1) + (x), _$$3.h3, sc$$10.h2) ); break; } } } else { return _$$3; } };
let Data_SortedMap_deleteT23 = ( _$$2, h$$3, _$$4, _$$5 ) => { switch (_$$5.tag) { case 2: { let x = (h$$3) - (1); switch (x) { case 0: { let sc$$15 = _$$2(_$$4)(_$$5.h4); switch (sc$$15) { case 2: { let sc$$16 = _$$2(_$$4)(_$$5.h6); switch (sc$$16) { case 2: { let sc$$17 = Data_SortedMap_deleteT23(_$$2, 0, _$$4, _$$5.h7); return ( (sc$$17.tag) == (1) ? Prelude_Left(Data_SortedMap_Node2(_$$5.h3, _$$5.h4, _$$5.h5)) : Prelude_Left(Data_SortedMap_Node3(_$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, sc$$17.h2)) ); break; } default: { let sc$$17 = Data_SortedMap_deleteT23(_$$2, 0, _$$4, _$$5.h5); return ( (sc$$17.tag) == (1) ? Prelude_Left(Data_SortedMap_Node2(_$$5.h3, _$$5.h4, _$$5.h7)) : Prelude_Left(Data_SortedMap_Node3(_$$5.h3, _$$5.h4, sc$$17.h2, _$$5.h6, _$$5.h7)) ); break; } } break; } default: { let sc$$16 = Data_SortedMap_deleteT23(_$$2, 0, _$$4, _$$5.h3); return ( (sc$$16.tag) == (1) ? Prelude_Left(Data_SortedMap_Node2(_$$5.h5, _$$5.h6, _$$5.h7)) : Prelude_Left(Data_SortedMap_Node3(sc$$16.h2, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7)) ); break; } } break; } default: { let x1 = (x) - (1); let sc$$16 = _$$2(_$$4)(_$$5.h4); switch (sc$$16) { case 2: { let sc$$17 = _$$2(_$$4)(_$$5.h6); switch (sc$$17) { case 2: { let sc$$18 = Data_SortedMap_deleteT23(_$$2, (1) + (x1), _$$4, _$$5.h7); return ( (sc$$18.tag) == (1) ? Prelude_Left(Data_SortedMap_merge3(_$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, sc$$18.h2)) : Prelude_Left(Data_SortedMap_Node3(_$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, sc$$18.h2)) ); break; } default: { let sc$$18 = Data_SortedMap_deleteT23(_$$2, (1) + (x1), _$$4, _$$5.h5); return ( (sc$$18.tag) == (1) ? Prelude_Left(Data_SortedMap_merge2(_$$5.h3, _$$5.h4, sc$$18.h2, _$$5.h6, _$$5.h7)) : Prelude_Left(Data_SortedMap_Node3(_$$5.h3, _$$5.h4, sc$$18.h2, _$$5.h6, _$$5.h7)) ); break; } } break; } default: { let sc$$17 = Data_SortedMap_deleteT23(_$$2, (1) + (x1), _$$4, _$$5.h3); return ( (sc$$17.tag) == (1) ? Prelude_Left(Data_SortedMap_merge1(sc$$17.h2, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7)) : Prelude_Left(Data_SortedMap_Node3(sc$$17.h2, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7)) ); break; } } break; } } break; } case 1: { let x = (h$$3) - (1); switch (x) { case 0: { let sc$$13 = _$$2(_$$4)(_$$5.h4); switch (sc$$13) { case 2: { let sc$$14 = Data_SortedMap_deleteT23(_$$2, 0, _$$4, _$$5.h5); return ( (sc$$14.tag) == (1) ? Prelude_Right(_$$5.h3) : Prelude_Left(Data_SortedMap_Node2(_$$5.h3, _$$5.h4, sc$$14.h2)) ); break; } default: { let sc$$14 = Data_SortedMap_deleteT23(_$$2, 0, _$$4, _$$5.h3); return ( (sc$$14.tag) == (1) ? Prelude_Right(_$$5.h5) : Prelude_Left(Data_SortedMap_Node2(sc$$14.h2, _$$5.h4, _$$5.h5)) ); break; } } break; } default: { let x1 = (x) - (1); let sc$$14 = _$$2(_$$4)(_$$5.h4); switch (sc$$14) { case 2: { let sc$$15 = Data_SortedMap_deleteT23(_$$2, (1) + (x1), _$$4, _$$5.h5); return ( (sc$$15.tag) == (1) ? ( (_$$5.h3.tag) == (2) ? Prelude_Left(Data_SortedMap_Node4(_$$5.h3.h3, _$$5.h3.h4, _$$5.h3.h5, _$$5.h3.h6, _$$5.h3.h7, _$$5.h4, sc$$15.h2)) : Prelude_Right(Data_SortedMap_Node3(_$$5.h3.h3, _$$5.h3.h4, _$$5.h3.h5, _$$5.h4, sc$$15.h2)) ) : Prelude_Left(Data_SortedMap_Node2(_$$5.h3, _$$5.h4, sc$$15.h2)) ); break; } default: { let sc$$15 = Data_SortedMap_deleteT23(_$$2, (1) + (x1), _$$4, _$$5.h3); return ( (sc$$15.tag) == (1) ? ( (_$$5.h5.tag) == (2) ? Prelude_Left(Data_SortedMap_Node4(sc$$15.h2, _$$5.h4, _$$5.h5.h3, _$$5.h5.h4, _$$5.h5.h5, _$$5.h5.h6, _$$5.h5.h7)) : Prelude_Right(Data_SortedMap_Node3(sc$$15.h2, _$$5.h4, _$$5.h5.h3, _$$5.h5.h4, _$$5.h5.h5)) ) : Prelude_Left(Data_SortedMap_Node2(sc$$15.h2, _$$5.h4, _$$5.h5)) ); break; } } break; } } break; } case 0: { let sc$$10 = _$$2(_$$5.h2)(_$$4); switch (sc$$10) { case 1: return Prelude_Right(0); default: return Prelude_Left(Data_SortedMap_Leaf(_$$5.h2, _$$5.h3)); } break; } } };
let Data_SortedMap_Node4 = ( _$$3, _$$4, _$$5, _$$6, _$$7, _$$8, _$$9 ) => (Data_SortedMap_Node2(Data_SortedMap_Node2(_$$3, _$$4, _$$5), _$$6, Data_SortedMap_Node2(_$$7, _$$8, _$$9)));
let Data_SortedMap_merge1 = ( _$$3, _$$4, _$$5, _$$6, _$$7 ) => (( (_$$7.tag) == (2) ? ( (_$$5.tag) == (2) ? Data_SortedMap_Node7(_$$3, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7, _$$6, _$$7.h3, _$$7.h4, _$$7.h5, _$$7.h6, _$$7.h7) : Data_SortedMap_Node6(_$$3, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$6, _$$7.h3, _$$7.h4, _$$7.h5, _$$7.h6, _$$7.h7) ) : ( (_$$5.tag) == (2) ? Data_SortedMap_Node6(_$$3, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7, _$$6, _$$7.h3, _$$7.h4, _$$7.h5) : Data_SortedMap_Node5(_$$3, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$6, _$$7.h3, _$$7.h4, _$$7.h5) ) ));
let Data_SortedMap_Node5 = ( _$$3, _$$4, _$$5, _$$6, _$$7, _$$8, _$$9, _$$10, _$$11 ) => (Data_SortedMap_Node2(Data_SortedMap_Node2(_$$3, _$$4, _$$5), _$$6, Data_SortedMap_Node3(_$$7, _$$8, _$$9, _$$10, _$$11)));
let Data_SortedMap_Node6 = ( _$$3, _$$4, _$$5, _$$6, _$$7, _$$8, _$$9, _$$10, _$$11, _$$12, _$$13 ) => (Data_SortedMap_Node2(Data_SortedMap_Node3(_$$3, _$$4, _$$5, _$$6, _$$7), _$$8, Data_SortedMap_Node3(_$$9, _$$10, _$$11, _$$12, _$$13)));
let Data_SortedMap_Node7 = ( _$$3, _$$4, _$$5, _$$6, _$$7, _$$8, _$$9, _$$10, _$$11, _$$12, _$$13, _$$14, _$$15 ) => (Data_SortedMap_Node3(Data_SortedMap_Node3(_$$3, _$$4, _$$5, _$$6, _$$7), _$$8, Data_SortedMap_Node2(_$$9, _$$10, _$$11), _$$12, Data_SortedMap_Node2(_$$13, _$$14, _$$15)));
let Data_SortedMap_merge2 = ( _$$3, _$$4, _$$5, _$$6, _$$7 ) => (( (_$$7.tag) == (2) ? ( (_$$3.tag) == (2) ? Data_SortedMap_Node7(_$$3.h3, _$$3.h4, _$$3.h5, _$$3.h6, _$$3.h7, _$$4, _$$5, _$$6, _$$7.h3, _$$7.h4, _$$7.h5, _$$7.h6, _$$7.h7) : Data_SortedMap_Node6(_$$3.h3, _$$3.h4, _$$3.h5, _$$4, _$$5, _$$6, _$$7.h3, _$$7.h4, _$$7.h5, _$$7.h6, _$$7.h7) ) : ( (_$$3.tag) == (2) ? Data_SortedMap_Node6(_$$3.h3, _$$3.h4, _$$3.h5, _$$3.h6, _$$3.h7, _$$4, _$$5, _$$6, _$$7.h3, _$$7.h4, _$$7.h5) : Data_SortedMap_Node5(_$$3.h3, _$$3.h4, _$$3.h5, _$$4, _$$5, _$$6, _$$7.h3, _$$7.h4, _$$7.h5) ) ));
let Data_SortedMap_merge3 = ( _$$3, _$$4, _$$5, _$$6, _$$7 ) => (( (_$$5.tag) == (2) ? ( (_$$3.tag) == (2) ? Data_SortedMap_Node7(_$$3.h3, _$$3.h4, _$$3.h5, _$$3.h6, _$$3.h7, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7, _$$6, _$$7) : Data_SortedMap_Node6(_$$3.h3, _$$3.h4, _$$3.h5, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$5.h6, _$$5.h7, _$$6, _$$7) ) : ( (_$$3.tag) == (2) ? Data_SortedMap_Node6(_$$3.h3, _$$3.h4, _$$3.h5, _$$3.h6, _$$3.h7, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$6, _$$7) : Data_SortedMap_Node5(_$$3.h3, _$$3.h4, _$$3.h5, _$$4, _$$5.h3, _$$5.h4, _$$5.h5, _$$6, _$$7) ) ));
let Lib_ProcessModule_invalidateModule_accumulate = ( _, _$$2, _$$3 ) => { let prev = Prelude_fromMaybe({ tag: 0 }, Data_SortedMap_lookupMap$27(_$$3.h2, _$$2)); return Data_SortedMap_updateMap(_$$3.h2, { tag: 1,  h1: _$$3.h3,  h2: prev }, _$$2); };
let Lib_ProcessModule_invalidateModule_getDeps = ( _, _$$3 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(_$$3.h2, eta)), _$$3.h3.h5));
let Lib_Util_getBaseDir = ( _$$0, _$$1, _$$2 ) => { let path; let _sc$$0 = Data_List1_splitFileName(_$$0); path = _sc$$0.h2; let dirs = Prelude_splitBy(path, "/"); let sc$$6 = Lib_Util_getBaseDir_baseDir(_$$0, _$$1, _$$2, Prelude__$3C$3E$3C_({ tag: 0 }, dirs), Prelude__$3C$3E$3C_({ tag: 0 }, _$$2)); if ((sc$$6.tag) == (1)) { let base; let sc$$10 = Prelude_eqString(sc$$6.h2, ""); switch (sc$$10) { case true: { base = "."; break; } case false: { base = sc$$6.h2; break; } } return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(base); } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, sc$$6.h2)), eta)))); } };
let Prelude__$3C$3E$3C_ = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { _$$1 = { tag: 1,  h1: _$$11,  h2: _$$21.h1 }; _$$2 = _$$21.h2; continue; } else { return _$$11; } } };
let Lib_Util_getBaseDir_baseDir = ( _, _1, _2, _$$4, _$$5 ) => { while (1) { let _3 = _; let _4 = _1; let _5 = _2; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$51.tag) == (1)) { if ((_$$41.tag) == (1)) { let sc$$12 = Prelude_eqString(_$$41.h2, _$$51.h2); switch (sc$$12) { case true: { _ = _3; _1 = _4; _2 = _5; _$$4 = _$$41.h1; _$$5 = _$$51.h1; continue; break; } case false: return Prelude_Left((((("module name ") + (Prelude_joinBy(".", _5))) + (" doesn't match path ")) + (_3)) + ("")); } } else { return Prelude_Left((((("module name ") + (Prelude_joinBy(".", _5))) + (" doesn't match path ")) + (_3)) + ("")); } } else { return Prelude_Right(Prelude_joinBy("/", Prelude__$3C$3E$3E_(_$$41, { tag: 0 }))); } } };
let Data_List1_splitFileName = ( _$$0 ) => { let sc$$1 = Data_List1_splitBy1(_$$0, "."); return ( (sc$$1.h2.tag) == (0) ? { tag: 0,  h2: sc$$1.h1,  h3: "" } : Prelude_mapFst(Prelude_Prelude_Bifunctor$20Prelude__$D7_, ( eta ) => (Prelude_joinBy(".", eta)), Data_List1_unsnoc(sc$$1)) ); };
let Data_List1_unsnoc = ( _$$1 ) => (Data_List1_unsnoc_go(_$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h1, _$$1.h2));
let Data_List1_unsnoc_go = ( _, _1, _2, _3, _$$6, _$$7 ) => { if ((_$$7.tag) == (1)) { let sc$$11 = Data_List1_unsnoc_go(_, _1, _2, _3, _$$7.h1, _$$7.h2); return { tag: 0,  h2: { tag: 1,  h1: _$$6,  h2: sc$$11.h2 },  h3: sc$$11.h3 }; } else { return { tag: 0,  h2: { tag: 0 },  h3: _$$6 }; } };
let Prelude_Prelude_Bifunctor$20Prelude__$D7_$2Cbimap = ( _$$4, _$$5, _$$6 ) => ({ tag: 0,  h2: _$$4(_$$6.h2),  h3: _$$5(_$$6.h3) });
let Prelude_MkBifunctor = ( h1 ) => ({ tag: 0,  h1: h1 });
let Prelude_Prelude_Bifunctor$20Prelude__$D7_ = Prelude_MkBifunctor(( a ) => (( b ) => (( c ) => (( d ) => (( eta ) => (( eta1 ) => (( eta2 ) => (Prelude_Prelude_Bifunctor$20Prelude__$D7_$2Cbimap(eta, eta1, eta2)))))))));
let Prelude_mapFst = ( _$$4, _$$5, _$$6 ) => (Prelude_bimap(_$$4)(null)(null)(null)(null)(_$$5)(( _$$1 ) => (_$$1))(_$$6));
let Prelude_bimap = ( _$$1 ) => (( a ) => (( b ) => (( c ) => (( d ) => (_$$1.h1(null)(null)(null)(null))))));
let Data_List1_splitBy1 = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_splitBy(_$$0, _$$1); return ( (sc$$2.tag) == (1) ? { tag: 0,  h1: sc$$2.h1,  h2: sc$$2.h2 } : { tag: 0,  h1: _$$0,  h2: { tag: 0 } } ); };
let Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29$2C_$3D$3D_ = ( _$$1, _$$2, _$$3 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { if ((_$$21.tag) == (1)) { let sc$$10 = Prelude__$3D$3D_(_$$11)(_$$21.h1)(_$$31.h1); switch (sc$$10) { case true: { _$$1 = _$$11; _$$2 = _$$21.h2; _$$3 = _$$31.h2; continue; break; } case false: return false; } } else { return false; } } else { return ( (_$$21.tag) == (0) ? true : false ); } } };
let Main_writeSource = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileJS_compile, ( docs ) => { let src = Prelude_joinBy("\n", Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_({ tag: 1,  h1: "import fs from 'fs'",  h2: { tag: 1,  h1: "const bouncer = (f,ini) => { let obj = ini; while (obj.tag) obj = f(obj); return obj.h0 };",  h2: { tag: 0 } } }, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$5 ) => (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Prettier_noAlt(_$$5))), { tag: 0 })), docs))); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Node_writeFile(_$$0, src)), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E({ tag: 0,  h0: _$$0,  h1: Lib_Common_MkBounds(0, 0, 0, 0) }, $$sc.h2)), eta)))) ))); }));
let Node_writeFile = (fn, content) => (w) => {
  let result
  try {
    fs.writeFileSync(fn, content, 'utf8')
    result = Prelude_Right( Prelude_MkUnit)
  } catch (e) {
      result = Prelude_Left(e+"")
  }
  return Prelude_MkIORes(result, w)
};
let Lib_CompileJS_Var = ( h0 ) => ({ tag: 5,  h0: h0 });
let Lib_CompileJS_Apply = ( h0, h1 ) => ({ tag: 4,  h0: h0,  h1: h1 });
let Lib_CompileJS_JPlain = ( h0 ) => ({ tag: 1,  h0: h0 });
let Lib_CompileJS_stmtToDoc = ( _$$1 ) => { switch (_$$1.tag) { case 11: return Lib_Prettier_Seq(Lib_Prettier_Text("continue"), Lib_Prettier_Text(";")); case 10: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_CompileJS_jsIdent(_$$1.h0), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$1.h1))), Lib_Prettier_Text(";")); case 9: return Lib_Prettier_Seq(Lib_Prettier_Text("while (1)"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_bracket("{", Lib_CompileJS_stmtToDoc(_$$1.h1), "}"))); case 8: return Lib_Prettier_Seq(Lib_Prettier_Text("throw new Error("), Lib_Prettier_Seq(Lib_Prettier_Text(Lib_Common_quoteString(_$$1.h1)), Lib_Prettier_Text(");"))); case 7: return Lib_Prettier_Seq(Lib_Prettier_Text("if ("), Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$1.h1), Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text(")"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_bracket("{", Lib_CompileJS_stmtToDoc(_$$1.h2), "}"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("else"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_bracket("{", Lib_CompileJS_stmtToDoc(_$$1.h3), "}"))))); case 6: return Lib_Prettier_Seq(Lib_Prettier_Text("switch ("), Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$1.h1), Lib_Prettier_Seq(Lib_Prettier_Text(")"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_bracket("{", Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_altToDoc(eta)), _$$1.h2)), "}"))))); case 5: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_CompileJS_jsIdent(_$$1.h0), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("="))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$1.h1))), Lib_Prettier_Text(";")); case 4: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("let"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_jsIdent(_$$1.h0))), Lib_Prettier_Text(";")), Lib_Prettier_Seq(Lib_Prettier_line, Lib_CompileJS_stmtToDoc(_$$1.h1))); case 3: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("return"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$1.h0))), Lib_Prettier_Text(";")); case 2: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("let"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_jsIdent(_$$1.h0))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Text("="), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$1.h1), Lib_Prettier_Text(";"))))))); case 1: return Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$1.h0), Lib_Prettier_Text(";")); case 0: return Lib_Prettier_Seq(Lib_CompileJS_stmtToDoc(_$$1.h1), Lib_Prettier_Seq(Lib_Prettier_line, Lib_CompileJS_stmtToDoc(_$$1.h2))); } };
let Lib_CompileJS_expToDoc = ( _$$0 ) => { switch (_$$0.tag) { case 12: return Lib_Prettier_Text(_$$0.h0); case 11: return Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h0), Lib_Prettier_Seq(Lib_Prettier_Text("."), Lib_CompileJS_jsIdent(_$$0.h1))); case 10: return Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h0), Lib_Prettier_Seq(Lib_Prettier_Text("["), Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h1), Lib_Prettier_Text("]")))); case 9: return Lib_Prettier_bracket("(", Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h0), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("?"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(":"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$0.h2))), ")"); case 8: return Lib_Prettier_Text("null"); case 7: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Types_parens(0, 1, Lib_CompileJS_expToDoc(_$$0.h1)), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(_$$0.h0))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Types_parens(0, 1, Lib_CompileJS_expToDoc(_$$0.h2)))); case 6: return ( (_$$0.h1.tag) == (3) ? Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier_Seq(Lib_Prettier_Seq(a, Lib_Prettier_Text(",")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), b)))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_jsIdent(eta)), _$$0.h0)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(") =>"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("("))), Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h1.h0), Lib_Prettier_Text(")"))) : Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier_Seq(Lib_Prettier_Seq(a, Lib_Prettier_Text(",")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), b)))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_jsIdent(eta)), _$$0.h0)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(") =>"))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_bracket("{", Lib_CompileJS_stmtToDoc(_$$0.h1), "}"))) ); case 5: return Lib_CompileJS_jsIdent(_$$0.h0); case 4: return ( (_$$0.h0.tag) == (6) ? Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h0), Lib_Prettier_Seq(Lib_Prettier_Text(")"), Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_Prettier_Nest(2, Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier_Seq(Lib_Prettier_Seq(a, Lib_Prettier_Text(",")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), b)))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_expToDoc(eta)), _$$0.h1))), Lib_Prettier_Text(")")))))) : Lib_Prettier_Seq(Lib_CompileJS_expToDoc(_$$0.h0), Lib_Prettier_Seq(Lib_Prettier_Text("("), Lib_Prettier_Seq(Lib_Prettier_Nest(2, Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier_Seq(Lib_Prettier_Seq(a, Lib_Prettier_Text(",")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), b)))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_expToDoc(eta)), _$$0.h1))), Lib_Prettier_Text(")")))) ); case 3: return Lib_Prettier_Text(Prelude_showInt(_$$0.h0)); case 2: switch (_$$0.h0) { case true: return Lib_Prettier_Text("true"); case false: return Lib_Prettier_Text("false"); } break; case 1: return Lib_Prettier_Text(Lib_Common_quoteString(_$$0.h0)); case 0: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("{"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_folddoc(( a ) => (( e ) => (Lib_Prettier_Seq(Lib_Prettier_Seq(a, Lib_Prettier_Text(", ")), Lib_Prettier_Seq(Lib_Prettier_Alt(Lib_Prettier_Text(" "), Lib_Prettier_line), e)))), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_expToDoc_entry(_$$0, _$$0.h0, eta)), _$$0.h0)))), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text("}"))); } };
let Lib_CompileJS_expToDoc_entry = ( _, _1, _$$3 ) => (Lib_Prettier_Seq(Lib_CompileJS_jsIdent(_$$3.h2), Lib_Prettier_Seq(Lib_Prettier_Text(":"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$3.h3)))));
let Lib_CompileJS_jsIdent = ( _$$0 ) => { let sc$$2 = Prelude_elem(Prelude_Prelude_Eq$20Prim_String, _$$0, Lib_CompileJS_jsKeywords); switch (sc$$2) { case true: return Lib_Prettier_Text(("$") + (_$$0)); case false: return Lib_Prettier_Text(Prelude_pack(Lib_CompileJS_jsIdent_fix(_$$0, Prelude_unpack(_$$0)))); } };
let Lib_CompileJS_jsIdent_fix = ( _, _$$2 ) => { if ((_$$2.tag) == (1)) { let sc$$6 = (Prelude_isAlphaNum(_$$2.h1)) || (Prelude_eqChar(_$$2.h1, "_")); switch (sc$$6) { case true: return { tag: 1,  h1: _$$2.h1,  h2: Lib_CompileJS_jsIdent_fix(_, _$$2.h2) }; case false: { let sc$$7 = Prelude_eqChar(_$$2.h1, "."); switch (sc$$7) { case true: return { tag: 1,  h1: "_",  h2: Lib_CompileJS_jsIdent_fix(_, _$$2.h2) }; case false: { let sc$$8 = Prelude_eqChar(_$$2.h1, "$"); switch (sc$$8) { case true: return { tag: 1,  h1: "$",  h2: { tag: 1,  h1: "$",  h2: Lib_CompileJS_jsIdent_fix(_, _$$2.h2) } }; case false: return { tag: 1,  h1: "$",  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Lib_Common_toHex(Prelude_ord(_$$2.h1)), Lib_CompileJS_jsIdent_fix(_, _$$2.h2)) }; } break; } } break; } } } else { return { tag: 0 }; } };
let Lib_Common_toHex = ( _$$0 ) => { switch (_$$0) { case 0: return { tag: 0 }; default: return Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Lib_Common_toHex(((_$$0) / (16)) | (0)), { tag: 1,  h1: Prelude_fromMaybe(" ", Prelude_getAt(Prelude_intToNat(Prelude_mod(_$$0, 16)), Lib_Common_hexChars)),  h2: { tag: 0 } }); } };
let Prelude_isAlphaNum = ( _$$0 ) => { let o = Prelude_ord(_$$0); return ((Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(64, o), 0)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(o, 91), 0))) || (((Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(47, o), 0)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(o, 58), 0))) || ((Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(96, o), 0)) && (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(o, 123), 0)))); };
let Lib_CompileJS_jsKeywords = { tag: 1,  h1: "break",  h2: { tag: 1,  h1: "case",  h2: { tag: 1,  h1: "catch",  h2: { tag: 1,  h1: "continue",  h2: { tag: 1,  h1: "debugger",  h2: { tag: 1,  h1: "default",  h2: { tag: 1,  h1: "delete",  h2: { tag: 1,  h1: "do",  h2: { tag: 1,  h1: "else",  h2: { tag: 1,  h1: "finally",  h2: { tag: 1,  h1: "for",  h2: { tag: 1,  h1: "function",  h2: { tag: 1,  h1: "if",  h2: { tag: 1,  h1: "in",  h2: { tag: 1,  h1: "instanceof",  h2: { tag: 1,  h1: "new",  h2: { tag: 1,  h1: "return",  h2: { tag: 1,  h1: "switch",  h2: { tag: 1,  h1: "this",  h2: { tag: 1,  h1: "throw",  h2: { tag: 1,  h1: "try",  h2: { tag: 1,  h1: "typeof",  h2: { tag: 1,  h1: "var",  h2: { tag: 1,  h1: "void",  h2: { tag: 1,  h1: "while",  h2: { tag: 1,  h1: "with",  h2: { tag: 1,  h1: "class",  h2: { tag: 1,  h1: "const",  h2: { tag: 1,  h1: "enum",  h2: { tag: 1,  h1: "export",  h2: { tag: 1,  h1: "extends",  h2: { tag: 1,  h1: "import",  h2: { tag: 1,  h1: "super",  h2: { tag: 1,  h1: "implements",  h2: { tag: 1,  h1: "class",  h2: { tag: 1,  h1: "let",  h2: { tag: 1,  h1: "package",  h2: { tag: 1,  h1: "private",  h2: { tag: 1,  h1: "protected",  h2: { tag: 1,  h1: "public",  h2: { tag: 1,  h1: "static",  h2: { tag: 1,  h1: "yield",  h2: { tag: 1,  h1: "null",  h2: { tag: 1,  h1: "true",  h2: { tag: 1,  h1: "false",  h2: { tag: 1,  h1: "String",  h2: { tag: 1,  h1: "Number",  h2: { tag: 1,  h1: "Array",  h2: { tag: 1,  h1: "BigInt",  h2: { tag: 0 } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } };
let Lib_Prettier_bracket = ( _$$0, _$$1, _$$2 ) => (Lib_Prettier_Alt(Lib_Prettier_flatten(Lib_Prettier_Seq(Lib_Prettier_Text(_$$0), Lib_Prettier_Seq(Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_line, _$$1)), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Text(_$$2))))), Lib_Prettier_Seq(Lib_Prettier_Text(_$$0), Lib_Prettier_Seq(Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_line, _$$1)), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Text(_$$2))))));
let Lib_Prettier_flatten = ( _$$0 ) => { while (1) { let _$$01 = _$$0; switch (_$$01.tag) { case 5: { _$$0 = _$$01.h0; continue; break; } case 4: return Lib_Prettier_Seq(Lib_Prettier_flatten(_$$01.h0), Lib_Prettier_flatten(_$$01.h1)); case 3: { _$$0 = _$$01.h1; continue; break; } case 2: return Lib_Prettier_Text(_$$01.h0); case 1: return Lib_Prettier_Text(" "); case 0: return Lib_Prettier_Empty; } } };
let Lib_CompileJS_altToDoc = ( _$$0 ) => { switch (_$$0.tag) { case 2: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("case"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_expToDoc(_$$0.h1))), Lib_Prettier_Seq(Lib_Prettier_Text(":"), Lib_CompileJS_caseBody(_$$0.h2))); case 1: return Lib_Prettier_Seq(Lib_Prettier_Text("default"), Lib_Prettier_Seq(Lib_Prettier_Text(":"), Lib_CompileJS_caseBody(_$$0.h1))); case 0: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_Text("case"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_Prettier_Text(Prelude_showInt(Prelude_natToInt(_$$0.h1))))), Lib_Prettier_Seq(Lib_Prettier_Text(":"), Lib_CompileJS_caseBody(_$$0.h2))); } };
let Lib_CompileJS_caseBody = ( _$$1 ) => { switch (_$$1.tag) { case 6: return Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_line, Lib_CompileJS_stmtToDoc(_$$1)), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Text("break;")))); case 3: return Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_line, Lib_CompileJS_stmtToDoc(_$$1))); default: return Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Seq(Lib_Prettier_Text("{"), Lib_Prettier_Nest(2, Lib_Prettier_Seq(Lib_Prettier_Seq(Lib_Prettier_line, Lib_CompileJS_stmtToDoc(_$$1)), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Text("break;")))))), Lib_Prettier_Seq(Lib_Prettier_line, Lib_Prettier_Text("}"))); } };
let Lib_CompileJS_process = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_CompileJS_getEntries(eta, eta1))), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), _$$0), ( entries ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primNewIORef(null, entries)), ( ref ) => { let foo = Lib_Ref2_MkRef(ref); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileJS_eraseEntries(Lib_Ref2_MkRef(ref)), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhere(Lib_Ref2_MkRef(ref)), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, ref)), ( entries1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_mapM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (Lib_CompileExp_defToCExp(Lib_Ref2_MkRef(ref), eta)), Data_SortedMap_toList(entries1)), ( exprs ) => { let cexpMap = Data_SortedMap_foldMap(( _$$2 ) => (( _$$3 ) => (_$$2)), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), exprs); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TCO_tailCallOpt(cexpMap), ( cexpMap1 ) => { let names = Lib_CompileJS_sortedNames(cexpMap1, _$$0); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_mapMaybe(( eta ) => (Lib_CompileJS_process_go(_$$0, cexpMap1, eta)), names)); }); }))))))); }))))));
let Lib_CompileJS_process_go = ( _, _$$2, _$$3 ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Data_SortedMap_lookupMap(_$$3, _$$2), ( cexp ) => { let sc$$5 = Prelude_elem(Lib_Common_Prelude_Eq$20Lib_Common_QName, _$$3, _); switch (sc$$5) { case true: return Prelude_Just(Lib_Prettier_Seq(Lib_Prettier_Text("export"), Lib_Prettier_Seq(Lib_Prettier_Text(" "), Lib_CompileJS_cexpToDoc(cexp)))); case false: return Prelude_Just(Lib_CompileJS_cexpToDoc(cexp)); } }));
let Lib_CompileJS_cexpToDoc = ( _$$0 ) => { let exp = Lib_CompileJS_maybeWrap(Lib_CompileJS_termToJS(Lib_CompileJS_emptyJSEnv, _$$0.h3, ( eta ) => (Lib_CompileJS_JReturn(eta)))); return Lib_CompileJS_stmtToDoc(Lib_CompileJS_JConst(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h2), exp)); };
let Lib_CompileJS_JConst = ( h0, h1 ) => ({ tag: 2,  h0: h0,  h1: h1 });
let Lib_CompileJS_JReturn = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_CompileJS_emptyJSEnv = { tag: 0,  h0: { tag: 0 },  h1: 0 };
let Lib_CompileJS_termToJS = ( _$$1, _$$2, _$$3 ) => (bouncer(Lib_CompileJS_REC_termToJS, { tag: 1,  h0: null,  h1: _$$1,  h2: _$$2,  h3: _$$3 }));
let Lib_CompileJS_REC_termToJS = ( arg ) => { switch (arg.tag) { case 1: switch (arg.h2.tag) { case 16: return { tag: 1,  h0: null,  h1: arg.h1,  h2: arg.h2.h1,  h3: ( t ) => (Lib_CompileJS_termToJS(arg.h1, arg.h2.h2, ( u ) => (arg.h3(Lib_CompileJS_JPrimOp(arg.h2.h0, t, u))))) }; case 15: return { tag: 0,  h0: arg.h3(Lib_CompileJS_Raw(arg.h2.h0)) }; case 14: return { tag: 2,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h2.h0,  h5: arg.h2.h1,  h6: arg.h2.h2,  h7: arg.h2.h3,  h8: arg.h2.h4,  h9: null,  h10: null,  h11: arg.h2.h2,  h12: arg.h2.h3,  h13: 0,  h14: ( args ) => (arg.h3(Lib_CompileJS_LitObject({ tag: 1,  h1: { tag: 0,  h2: "tag",  h3: Lib_CompileJS_LitInt(Prelude_natToInt(arg.h2.h0)) },  h2: args }))) }; case 13: return { tag: 0,  h0: arg.h3(Lib_CompileJS_JUndefined) }; case 12: return { tag: 3,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h2.h0,  h5: arg.h2.h1,  h6: null,  h7: Prelude_reverse()(arg.h1.h0),  h8: arg.h2.h0,  h9: arg.h2.h1 }; case 11: { let off = Prelude_length$27(arg.h2.h0); let sc$$8 = Lib_CompileJS_termToJS_go$27(arg.h1, arg.h2, arg.h3, arg.h2.h0, arg.h2.h1, (Prelude_length$27(arg.h2.h0)) - (1), arg.h2.h0, arg.h1, { tag: 0 }); return { tag: 0,  h0: Lib_CompileJS_JWhile(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldr(( a ) => (( b ) => (Lib_CompileJS_JSnoc(a, b))), Lib_CompileJS_termToJS(sc$$8.h3, arg.h2.h1, arg.h3), sc$$8.h2)) }; break; } case 10: { if ((arg.h2.h1.tag) == (13)) { return { tag: 1,  h0: null,  h1: { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_JUndefined,  h2: arg.h1.h0 },  h1: arg.h1.h1 },  h2: arg.h2.h2,  h3: arg.h3 }; } else { let nm$27 = Lib_CompileJS_freshName(arg.h2.h0, arg.h1); let env$27 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Var(nm$27),  h2: arg.h1.h0 },  h1: arg.h1.h1 }; let sc$$9 = Lib_CompileJS_termToJS(env$27, arg.h2.h1, ( eta ) => (Lib_CompileJS_JAssign(nm$27, eta))); return ( (sc$$9.tag) == (5) ? { tag: 0,  h0: Lib_CompileJS_JSnoc(Lib_CompileJS_JConst(nm$27, sc$$9.h1), Lib_CompileJS_termToJS(env$27, arg.h2.h2, arg.h3)) } : { tag: 0,  h0: Lib_CompileJS_JSnoc(Lib_CompileJS_JLet(nm$27, sc$$9), Lib_CompileJS_termToJS(env$27, arg.h2.h2, arg.h3)) } ); } break; } case 9: { if ((arg.h2.h1.tag) == (0)) { return { tag: 1,  h0: null,  h1: { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_getEnv(arg.h2.h1.h0, arg.h1.h0),  h2: arg.h1.h0 },  h1: arg.h1.h1 },  h2: arg.h2.h2,  h3: arg.h3 }; } else { let nm$27 = Lib_CompileJS_freshName(arg.h2.h0, arg.h1); let env$27 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Var(nm$27),  h2: arg.h1.h0 },  h1: arg.h1.h1 }; let sc$$9 = Lib_CompileJS_termToJS(arg.h1, arg.h2.h1, ( eta ) => (Lib_CompileJS_JAssign(nm$27, eta))); if ((sc$$9.tag) == (5)) { let sc$$12 = Lib_CompileJS_simpleJSExp(sc$$9.h1); switch (sc$$12) { case true: return { tag: 1,  h0: null,  h1: { tag: 0,  h0: { tag: 1,  h1: sc$$9.h1,  h2: arg.h1.h0 },  h1: arg.h1.h1 },  h2: arg.h2.h2,  h3: arg.h3 }; case false: return { tag: 0,  h0: Lib_CompileJS_JSnoc(Lib_CompileJS_JConst(nm$27, sc$$9.h1), Lib_CompileJS_termToJS(env$27, arg.h2.h2, arg.h3)) }; } } else { return { tag: 0,  h0: Lib_CompileJS_JSnoc(Lib_CompileJS_JLet(nm$27, sc$$9), Lib_CompileJS_termToJS(env$27, arg.h2.h2, arg.h3)) }; } } break; } case 8: return { tag: 0,  h0: arg.h3(Lib_CompileJS_litToJS(arg.h2.h0)) }; case 7: return { tag: 0,  h0: arg.h3(Lib_CompileJS_LitString((("META ") + (Prelude_showInt(arg.h2.h0))) + (""))) }; case 6: return { tag: 0,  h0: arg.h3(Lib_CompileJS_Var(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(arg.h2.h0))) }; case 5: return { tag: 1,  h0: null,  h1: arg.h1,  h2: arg.h2.h0,  h3: ( $$case ) => { if (($$case.tag) == (5)) { return Lib_CompileJS_termToJS_maybeCaseStmt(arg.h1, arg.h2, arg.h3, arg.h2.h0, arg.h2.h1, arg.h1, Lib_CompileJS_Var($$case.h0), arg.h2.h1); } else { let nm = (("_sc$") + (Prelude_showInt(arg.h1.h1))) + (""); let env$27 = { tag: 0,  h0: arg.h1.h0,  h1: (1) + (arg.h1.h1) }; let sc$$14 = Lib_CompileJS_simpleJSExp($$case); switch (sc$$14) { case true: return Lib_CompileJS_termToJS_maybeCaseStmt(arg.h1, arg.h2, arg.h3, arg.h2.h0, arg.h2.h1, arg.h1, $$case, arg.h2.h1); case false: return Lib_CompileJS_JSnoc(Lib_CompileJS_JConst(nm, $$case), Lib_CompileJS_termToJS_maybeCaseStmt(arg.h1, arg.h2, arg.h3, arg.h2.h0, arg.h2.h1, env$27, Lib_CompileJS_Var(nm), arg.h2.h1)); } } } }; case 4: return { tag: 1,  h0: null,  h1: arg.h1,  h2: arg.h2.h0,  h3: ( t$27 ) => (Lib_CompileJS_termToJS(arg.h1, arg.h2.h1, ( arg$27 ) => (arg.h3(Lib_CompileJS_Apply(t$27, { tag: 1,  h1: arg$27,  h2: { tag: 0 } }))))) }; case 3: { let sc$$10 = Lib_CompileJS_compilePrimOp(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(arg.h2.h0), arg.h2.h1); return ( (sc$$10.tag) == (1) ? { tag: 1,  h0: null,  h1: arg.h1,  h2: Lib_CompileExp_CRef(arg.h2.h0),  h3: ( t$27 ) => (Lib_CompileJS_termToJS_argsToJS(arg.h1, arg.h2, arg.h3, arg.h2.h0, arg.h2.h1, arg.h2.h2, arg.h1, t$27, arg.h2.h1, arg.h2.h2, { tag: 0 }, arg.h3)) } : { tag: 1,  h0: null,  h1: arg.h1,  h2: sc$$10.h1,  h3: arg.h3 } ); break; } case 2: { let sc$$6 = Lib_CompileJS_freshNames(arg.h2.h0, arg.h1); return { tag: 0,  h0: arg.h3(Lib_CompileJS_JLam(sc$$6.h2, Lib_CompileJS_termToJS(sc$$6.h3, arg.h2.h1, ( eta ) => (Lib_CompileJS_JReturn(eta))))) }; break; } case 1: { let sc$$6 = Lib_CompileJS_freshName$27(arg.h2.h0, arg.h1); return { tag: 0,  h0: arg.h3(Lib_CompileJS_JLam({ tag: 1,  h1: sc$$6.h2,  h2: { tag: 0 } }, Lib_CompileJS_termToJS(sc$$6.h3, arg.h2.h1, ( eta ) => (Lib_CompileJS_JReturn(eta))))) }; break; } case 0: return { tag: 0,  h0: arg.h3(Lib_CompileJS_getEnv(arg.h2.h0, arg.h1.h0)) }; } break; case 2: { if ((arg.h12.tag) == (1)) { switch (arg.h12.h1) { case true: return ( (arg.h11.tag) == (1) ? { tag: 1,  h0: null,  h1: arg.h1,  h2: arg.h11.h1,  h3: ( t$27 ) => (Lib_CompileJS_termToJS_go(arg.h1, arg.h2, arg.h3, arg.h4, arg.h5, arg.h6, arg.h7, arg.h8, arg.h11.h2, arg.h12.h2, (arg.h13) + (1), ( args ) => (arg.h14({ tag: 1,  h1: { tag: 0,  h2: (("h") + (Prelude_showInt(arg.h13))) + (""),  h3: t$27 },  h2: args })))) } : { tag: 0,  h0: arg.h14({ tag: 0 }) } ); default: return ( (arg.h11.tag) == (1) ? { tag: 2,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7,  h8: arg.h8,  h9: arg.h9,  h10: null,  h11: arg.h11.h2,  h12: arg.h12.h2,  h13: (arg.h13) + (1),  h14: ( args ) => (arg.h14(args)) } : { tag: 0,  h0: arg.h14({ tag: 0 }) } ); } } else { return { tag: 0,  h0: arg.h14({ tag: 0 }) }; } break; } case 3: { if ((arg.h9.tag) == (1)) { if ((arg.h8.tag) == (1)) { if ((arg.h7.tag) == (1)) { switch (arg.h7.h1.tag) { case 8: return { tag: 3,  h0: arg.h0,  h1: arg.h1,  h2: arg.h2,  h3: arg.h3,  h4: arg.h4,  h5: arg.h5,  h6: arg.h6,  h7: arg.h7.h2,  h8: arg.h8.h2,  h9: arg.h9.h2 }; case 5: switch (arg.h9.h1) { case true: return { tag: 1,  h0: null,  h1: arg.h1,  h2: arg.h8.h1,  h3: ( arg$27 ) => (Lib_CompileJS_JSnoc(Lib_CompileJS_JLoopAssign(arg.h7.h1.h0, arg$27), Lib_CompileJS_termToJS_runArgs(arg.h1, arg.h2, arg.h3, arg.h4, arg.h5, arg.h7.h2, arg.h8.h2, arg.h9.h2))) }; default: return { tag: 0,  h0: Prelude_fatalError(null, (("bad env for quant ") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(arg.h9.h1))) + ("")) }; } break; default: return { tag: 0,  h0: Prelude_fatalError(null, (("bad env for quant ") + (Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow(arg.h9.h1))) + ("")) }; } } else { return { tag: 0,  h0: Prelude_fatalError(null, (((((("FALLBACK ") + (Prelude_showInt(Prelude_length$27(arg.h7)))) + (" ")) + (Prelude_showInt(Prelude_length$27(arg.h8)))) + (" ")) + (Prelude_showInt(Prelude_length$27(arg.h9)))) + ("")) }; } } else { return { tag: 0,  h0: Prelude_fatalError(null, "too few CExp") }; } } else { return ( (arg.h8.tag) == (0) ? { tag: 0,  h0: Lib_CompileJS_JContinue() } : { tag: 0,  h0: Prelude_fatalError(null, (((((("FALLBACK ") + (Prelude_showInt(Prelude_length$27(arg.h7)))) + (" ")) + (Prelude_showInt(Prelude_length$27(arg.h8)))) + (" ")) + (Prelude_showInt(Prelude_length$27(arg.h9)))) + ("")) } ); } break; } } };
let Lib_CompileJS_JContinue = (  ) => ({ tag: 11 });
let Lib_CompileJS_termToJS_runArgs = ( _, _1, _2, _3, _4, _$$7, _$$8, _$$9 ) => (bouncer(Lib_CompileJS_REC_termToJS, { tag: 3,  h0: null,  h1: _,  h2: _1,  h3: _2,  h4: _3,  h5: _4,  h6: null,  h7: _$$7,  h8: _$$8,  h9: _$$9 }));
let Lib_CompileJS_JLoopAssign = ( h0, h1 ) => ({ tag: 10,  h0: h0,  h1: h1 });
let Lib_CompileJS_JSnoc = ( h1, h2 ) => ({ tag: 0,  h1: h1,  h2: h2 });
let Lib_CompileJS_termToJS_go = ( _, _1, _2, _3, _4, _5, _6, _7, _$$11, _$$12, _$$13, _$$14 ) => (bouncer(Lib_CompileJS_REC_termToJS, { tag: 2,  h0: null,  h1: _,  h2: _1,  h3: _2,  h4: _3,  h5: _4,  h6: _5,  h7: _6,  h8: _7,  h9: null,  h10: null,  h11: _$$11,  h12: _$$12,  h13: _$$13,  h14: _$$14 }));
let Lib_CompileJS_getEnv = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_getAt(Prelude_intToNat(_$$0), _$$1); return ( (sc$$2.tag) == (1) ? Prelude_fatalError(null, (("Bad bounds ") + (Prelude_showInt(_$$0))) + ("")) : sc$$2.h1 ); };
let Lib_CompileJS_JLam = ( h0, h1 ) => ({ tag: 6,  h0: h0,  h1: h1 });
let Lib_CompileJS_freshName$27 = ( _$$0, _$$1 ) => { let nm$27 = Lib_CompileJS_freshName(_$$0, _$$1); let env$27 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Var(nm$27),  h2: _$$1.h0 },  h1: _$$1.h1 }; return { tag: 0,  h2: nm$27,  h3: env$27 }; };
let Lib_CompileJS_freshName = ( _$$0, _$$1 ) => { let sc$$4 = Lib_CompileJS_freshName_free(_$$0, _$$1, _$$1.h0, _$$0); switch (sc$$4) { case true: return _$$0; case false: return Lib_CompileJS_freshName_go(_$$0, _$$1, _$$0, 1); } };
let Lib_CompileJS_freshName_go = ( _, _1, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$41 = _$$4; let _$$51 = _$$5; let nm$27 = (((("") + (_$$41)) + ("")) + (Prelude_showInt(_$$51))) + (""); let sc$$7 = Lib_CompileJS_freshName_free(_2, _3, _3.h0, nm$27); switch (sc$$7) { case true: return nm$27; case false: { _ = _2; _1 = _3; _$$4 = _$$41; _$$5 = (1) + (_$$51); continue; break; } } } };
let Lib_CompileJS_freshName_free = ( _, _1, _$$3, _$$4 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$31.tag) == (1)) { if ((_$$31.h1.tag) == (5)) { let sc$$9 = Prelude_eqString(_$$31.h1.h0, _$$41); switch (sc$$9) { case true: return false; case false: { _ = _2; _1 = _3; _$$3 = _$$31.h2; _$$4 = _$$41; continue; break; } } } else { _ = _2; _1 = _3; _$$3 = _$$31.h2; _$$4 = _$$41; continue; } } else { return true; } } };
let Lib_CompileJS_freshNames = ( _$$0, _$$1 ) => (Lib_CompileJS_freshNames_go(_$$0, _$$1, _$$0, _$$1, { tag: 0 }));
let Lib_CompileJS_freshNames_go = ( _, _1, _$$3, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$31.tag) == (1)) { switch (_$$31.h1.h2) { case true: { let sc$$13 = Lib_CompileJS_freshName$27(_$$31.h1.h3, _$$41); _ = _2; _1 = _3; _$$3 = _$$31.h2; _$$4 = sc$$13.h3; _$$5 = { tag: 1,  h1: _$$51,  h2: sc$$13.h2 }; continue; break; } case false: { let env$27 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_JUndefined,  h2: _$$41.h0 },  h1: _$$41.h1 }; _ = _2; _1 = _3; _$$3 = _$$31.h2; _$$4 = env$27; _$$5 = _$$51; continue; break; } } } else { return { tag: 0,  h2: Prelude__$3C$3E$3E_(_$$51, { tag: 0 }),  h3: _$$41 }; } } };
let Lib_CompileJS_JUndefined = { tag: 8 };
let Lib_CompileJS_termToJS_argsToJS = ( _, _1, _2, _3, _4, _5, _$$11, _$$12, _$$13, _$$14, _$$15, _$$16 ) => { while (1) { let _6 = _; let _7 = _1; let _8 = _2; let _9 = _3; let _10 = _4; let _11 = _5; let _$$111 = _$$11; let _$$121 = _$$12; let _$$131 = _$$13; let _$$141 = _$$14; let _$$151 = _$$15; let _$$161 = _$$16; if ((_$$131.tag) == (1)) { if ((_$$141.tag) == (1)) { switch (_$$141.h1) { case true: return Lib_CompileJS_termToJS(_$$111, _$$131.h1, ( x$27 ) => (Lib_CompileJS_termToJS_argsToJS(_6, _7, _8, _9, _10, _11, { tag: 0,  h0: _$$111.h0,  h1: (1) + (_$$111.h1) }, _$$121, _$$131.h2, _$$141.h2, { tag: 1,  h1: _$$151,  h2: x$27 }, _$$161))); default: { _ = _6; _1 = _7; _2 = _8; _3 = _9; _4 = _10; _5 = _11; _$$11 = { tag: 0,  h0: _$$111.h0,  h1: (1) + (_$$111.h1) }; _$$12 = _$$121; _$$13 = _$$131.h2; _$$14 = _$$141.h2; _$$15 = _$$151; _$$16 = _$$161; continue; break; } } } else { return ( (_11.tag) == (0) ? Lib_CompileJS_termToJS_apply(_6, _7, _8, _9, _10, _11, _$$111, _$$121, { tag: 1,  h1: _$$131.h1,  h2: _$$131.h2 }, _$$161) : Lib_CompileJS_termToJS_apply(_6, _7, _8, _9, _10, _11, _$$111, Lib_CompileJS_Apply(_$$121, Prelude__$3C$3E$3E_(_$$151, { tag: 0 })), { tag: 1,  h1: _$$131.h1,  h2: _$$131.h2 }, _$$161) ); } } else { return _$$161(Lib_CompileJS_termToJS_etaExpand(_6, _7, _8, _9, _10, _11, _$$111, _$$141, _$$151, _$$121)); } } };
let Lib_CompileJS_termToJS_etaExpand = ( _, _1, _2, _3, _4, _5, _$$8, _$$9, _$$10, _$$11 ) => { if ((_$$9.tag) == (1)) { let nm$27 = Lib_CompileJS_freshName("eta", _$$8); let env$27 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Var(nm$27),  h2: _$$8.h0 },  h1: _$$8.h1 }; switch (_$$9.h1) { case true: return Lib_CompileJS_JLam({ tag: 1,  h1: nm$27,  h2: { tag: 0 } }, Lib_CompileJS_JReturn(Lib_CompileJS_termToJS_etaExpand(_, _1, _2, _3, _4, _5, { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Var(nm$27),  h2: _$$8.h0 },  h1: _$$8.h1 }, _$$9.h2, { tag: 1,  h1: _$$10,  h2: Lib_CompileJS_Var(nm$27) }, _$$11))); default: return Lib_CompileJS_JLam({ tag: 1,  h1: nm$27,  h2: { tag: 0 } }, Lib_CompileJS_JReturn(Lib_CompileJS_termToJS_etaExpand(_, _1, _2, _3, _4, _5, { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Var(nm$27),  h2: _$$8.h0 },  h1: _$$8.h1 }, _$$9.h2, _$$10, _$$11))); } } else { return Lib_CompileJS_Apply(_$$11, Prelude__$3C$3E$3E_(_$$10, { tag: 0 })); } };
let Lib_CompileJS_termToJS_apply = ( _, _1, _2, _3, _4, _5, _$$10, _$$11, _$$12, _$$13 ) => (( (_$$12.tag) == (1) ? Lib_CompileJS_termToJS(_$$10, _$$12.h1, ( x$27 ) => (Lib_CompileJS_termToJS_apply(_, _1, _2, _3, _4, _5, _$$10, Lib_CompileJS_Apply(_$$11, { tag: 1,  h1: x$27,  h2: { tag: 0 } }), _$$12.h2, _$$13))) : _$$13(_$$11) ));
let Lib_CompileExp_CRef = ( h0 ) => ({ tag: 6,  h0: h0 });
let Lib_CompileJS_compilePrimOp = ( _$$0, _$$1 ) => { if ((_$$1.tag) == (1)) { if ((_$$1.h2.tag) == (1)) { if ((_$$1.h2.h2.tag) == (1)) { if ((_$$1.h2.h2.h2.tag) == (0)) { switch (_$$0) { case "Prelude.jsEq": return Prelude_Just(Lib_CompileExp_CPrimOp("==", _$$1.h2.h1, _$$1.h2.h2.h1)); case "Prelude.eqChar": return Prelude_Just(Lib_CompileExp_CPrimOp("==", _$$1.h2.h1, _$$1.h2.h2.h1)); case "Prelude.ltChar": return Prelude_Just(Lib_CompileExp_CPrimOp("<", _$$1.h2.h1, _$$1.h2.h2.h1)); case "Prelude.eqInt": return Prelude_Just(Lib_CompileExp_CPrimOp("==", _$$1.h2.h1, _$$1.h2.h2.h1)); case "Prelude.ltInt": return Prelude_Just(Lib_CompileExp_CPrimOp("<", _$$1.h2.h1, _$$1.h2.h2.h1)); case "Prelude.eqString": return Prelude_Just(Lib_CompileExp_CPrimOp("==", _$$1.h2.h1, _$$1.h2.h2.h1)); case "Prelude.ltString": return Prelude_Just(Lib_CompileExp_CPrimOp("<", _$$1.h2.h1, _$$1.h2.h2.h1)); default: return Prelude_Nothing(); } } else { return Prelude_Nothing(); } } else { switch (_$$0) { case "Prelude.addString": return Prelude_Just(Lib_CompileExp_CPrimOp("+", _$$1.h1, _$$1.h2.h1)); case "Prelude.addInt": return Prelude_Just(Lib_CompileExp_CPrimOp("+", _$$1.h1, _$$1.h2.h1)); case "Prelude.mulInt": return Prelude_Just(Lib_CompileExp_CPrimOp("*", _$$1.h1, _$$1.h2.h1)); case "Prelude.subInt": return Prelude_Just(Lib_CompileExp_CPrimOp("-", _$$1.h1, _$$1.h2.h1)); case "Prelude._&&_": return Prelude_Just(Lib_CompileExp_CPrimOp("&&", _$$1.h1, _$$1.h2.h1)); case "Prelude._||_": return Prelude_Just(Lib_CompileExp_CPrimOp("||", _$$1.h1, _$$1.h2.h1)); case "Prelude.divInt": return Prelude_Just(Lib_CompileExp_CPrimOp("|", Lib_CompileExp_CPrimOp("/", _$$1.h1, _$$1.h2.h1), Lib_CompileExp_CLit(Lib_Types_LInt(0)))); default: return Prelude_Nothing(); } } } else { return Prelude_Nothing(); } } else { return Prelude_Nothing(); } };
let Lib_CompileExp_CLit = ( h0 ) => ({ tag: 8,  h0: h0 });
let Lib_CompileExp_CPrimOp = ( h0, h1, h2 ) => ({ tag: 16,  h0: h0,  h1: h1,  h2: h2 });
let Lib_CompileJS_termToJS_maybeCaseStmt = ( _, _1, _2, _3, _4, _$$10, _$$11, _$$12 ) => { if ((_$$12.tag) == (1)) { switch (_$$12.h1.tag) { case 2: return ( (_$$12.h2.tag) == (0) ? Lib_CompileJS_termToJS(_$$10, _$$12.h1.h1, _2) : Lib_CompileJS_JCase(_$$11, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)) ); case 1: { if ((_$$12.h2.tag) == (0)) { return Lib_CompileJS_termToJS(_$$10, _$$12.h1.h0, _2); } else { if ((_$$12.tag) == (1)) { switch (_$$12.h1.tag) { case 2: { if ((_$$12.h1.h0.tag) == (3)) { if ((_$$12.h2.tag) == (1)) { if ((_$$12.h2.h2.tag) == (0)) { let t$27 = Lib_CompileJS_termToJS(_$$10, _$$12.h1.h1, _2); let e$27 = Lib_CompileJS_termToJS(_$$10, Lib_CompileExp_getBody(_$$12.h2.h1), _2); switch (_$$12.h1.h0.h0) { case true: return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, _$$11, t$27, e$27, _2); case false: return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, _$$11, e$27, t$27, _2); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } break; } case 0: { if ((_$$12.h2.tag) == (1)) { if ((_$$12.h2.h2.tag) == (0)) { let cond = Lib_CompileJS_JPrimOp("==", Lib_CompileJS_Dot(_$$11, "tag"), Lib_CompileJS_LitInt(Prelude_natToInt(_$$12.h1.h0))); let t$27 = Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, _$$12.h1.h3), _$$12.h1.h5, _2); let u$27 = Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, Lib_CompileJS_termToJS_getArgs(_, _1, _2, _3, _4, _$$12.h2.h1)), Lib_CompileExp_getBody(_$$12.h2.h1), _2); return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, cond, t$27, u$27, _2); } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } break; } default: return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } break; } case 0: { if ((_$$12.h2.tag) == (0)) { return Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, _$$12.h1.h3), _$$12.h1.h5, _2); } else { if ((_$$12.tag) == (1)) { switch (_$$12.h1.tag) { case 2: { if ((_$$12.h1.h0.tag) == (3)) { if ((_$$12.h2.tag) == (1)) { if ((_$$12.h2.h2.tag) == (0)) { let t$27 = Lib_CompileJS_termToJS(_$$10, _$$12.h1.h1, _2); let e$27 = Lib_CompileJS_termToJS(_$$10, Lib_CompileExp_getBody(_$$12.h2.h1), _2); switch (_$$12.h1.h0.h0) { case true: return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, _$$11, t$27, e$27, _2); case false: return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, _$$11, e$27, t$27, _2); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } break; } case 0: { if ((_$$12.h2.tag) == (1)) { if ((_$$12.h2.h2.tag) == (0)) { let cond = Lib_CompileJS_JPrimOp("==", Lib_CompileJS_Dot(_$$11, "tag"), Lib_CompileJS_LitInt(Prelude_natToInt(_$$12.h1.h0))); let t$27 = Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, _$$12.h1.h3), _$$12.h1.h5, _2); let u$27 = Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, Lib_CompileJS_termToJS_getArgs(_, _1, _2, _3, _4, _$$12.h2.h1)), Lib_CompileExp_getBody(_$$12.h2.h1), _2); return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, cond, t$27, u$27, _2); } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } break; } default: return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } break; } } } else { if ((_$$12.tag) == (1)) { switch (_$$12.h1.tag) { case 2: { if ((_$$12.h1.h0.tag) == (3)) { if ((_$$12.h2.tag) == (1)) { if ((_$$12.h2.h2.tag) == (0)) { let t$27 = Lib_CompileJS_termToJS(_$$10, _$$12.h1.h1, _2); let e$27 = Lib_CompileJS_termToJS(_$$10, Lib_CompileExp_getBody(_$$12.h2.h1), _2); switch (_$$12.h1.h0.h0) { case true: return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, _$$11, t$27, e$27, _2); case false: return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, _$$11, e$27, t$27, _2); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } break; } case 0: { if ((_$$12.h2.tag) == (1)) { if ((_$$12.h2.h2.tag) == (0)) { let cond = Lib_CompileJS_JPrimOp("==", Lib_CompileJS_Dot(_$$11, "tag"), Lib_CompileJS_LitInt(Prelude_natToInt(_$$12.h1.h0))); let t$27 = Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, _$$12.h1.h3), _$$12.h1.h5, _2); let u$27 = Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$11, 0, _$$10, Lib_CompileJS_termToJS_getArgs(_, _1, _2, _3, _4, _$$12.h2.h1)), Lib_CompileExp_getBody(_$$12.h2.h1), _2); return Lib_CompileJS_termToJS_tertiary(_, _1, _2, _3, _4, cond, t$27, u$27, _2); } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } break; } default: return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } else { return Lib_CompileJS_JCase(Lib_CompileJS_Dot(_$$11, "tag"), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_termToJS_termToJSAlt(_, _1, _2, _3, _4, _$$10, _$$11, eta)), _$$12)); } } };
let Lib_CompileJS_termToJS_termToJSAlt = ( _, _1, _2, _3, _4, _$$8, _$$9, _$$10 ) => { switch (_$$10.tag) { case 2: return Lib_CompileJS_JLitAlt(Lib_CompileJS_litToJS(_$$10.h0), Lib_CompileJS_termToJS(_$$8, _$$10.h1, _2)); case 1: return Lib_CompileJS_JDefAlt(Lib_CompileJS_termToJS(_$$8, _$$10.h0, _2)); case 0: return Lib_CompileJS_JConAlt(_$$10.h0, Lib_CompileJS_termToJS(Lib_CompileJS_conAltEnv(_$$9, 0, _$$8, _$$10.h3), _$$10.h5, _2)); } };
let Lib_CompileJS_conAltEnv = ( _$$0, _$$1, _$$2, _$$3 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; let _$$31 = _$$3; if ((_$$31.tag) == (1)) { _$$0 = _$$01; _$$1 = (1) + (_$$11); _$$2 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_Dot(_$$01, (("h") + (Prelude_showInt(_$$11))) + ("")),  h2: _$$21.h0 },  h1: _$$21.h1 }; _$$3 = _$$31.h2; continue; } else { return _$$21; } } };
let Lib_CompileJS_Dot = ( h0, h1 ) => ({ tag: 11,  h0: h0,  h1: h1 });
let Lib_CompileJS_JConAlt = ( h1, h2 ) => ({ tag: 0,  h1: h1,  h2: h2 });
let Lib_CompileJS_JDefAlt = ( h1 ) => ({ tag: 1,  h1: h1 });
let Lib_CompileJS_litToJS = ( _$$0 ) => { switch (_$$0.tag) { case 3: return Lib_CompileJS_LitBool(_$$0.h0); case 2: return Lib_CompileJS_LitString(Prelude_pack({ tag: 1,  h1: _$$0.h0,  h2: { tag: 0 } })); case 1: return Lib_CompileJS_LitInt(_$$0.h0); case 0: return Lib_CompileJS_LitString(_$$0.h0); } };
let Lib_CompileJS_LitString = ( h0 ) => ({ tag: 1,  h0: h0 });
let Lib_CompileJS_LitInt = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_CompileJS_LitBool = ( h0 ) => ({ tag: 2,  h0: h0 });
let Lib_CompileJS_JLitAlt = ( h1, h2 ) => ({ tag: 2,  h1: h1,  h2: h2 });
let Lib_CompileJS_JCase = ( h1, h2 ) => ({ tag: 6,  h1: h1,  h2: h2 });
let Lib_CompileJS_termToJS_tertiary = ( _, _1, _2, _3, _4, _$$7, _$$8, _$$9, _$$10 ) => { switch (_$$9.tag) { case 5: return ( (_$$8.tag) == (5) ? Lib_CompileJS_JAssign(_$$8.h0, Lib_CompileJS_JTernary(_$$7, _$$8.h1, _$$9.h1)) : Lib_CompileJS_JIfThen(_$$7, _$$8, _$$9) ); case 3: return ( (_$$8.tag) == (3) ? Lib_CompileJS_JReturn(Lib_CompileJS_JTernary(_$$7, _$$8.h0, _$$9.h0)) : Lib_CompileJS_JIfThen(_$$7, _$$8, _$$9) ); default: return Lib_CompileJS_JIfThen(_$$7, _$$8, _$$9); } };
let Lib_CompileJS_JIfThen = ( h1, h2, h3 ) => ({ tag: 7,  h1: h1,  h2: h2,  h3: h3 });
let Lib_CompileJS_JTernary = ( h0, h1, h2 ) => ({ tag: 9,  h0: h0,  h1: h1,  h2: h2 });
let Lib_CompileJS_JAssign = ( h0, h1 ) => ({ tag: 5,  h0: h0,  h1: h1 });
let Lib_CompileExp_getBody = ( _$$0 ) => { switch (_$$0.tag) { case 2: return _$$0.h1; case 1: return _$$0.h0; case 0: return _$$0.h5; } };
let Lib_CompileJS_termToJS_getArgs = ( _, _1, _2, _3, _4, _$$9 ) => { switch (_$$9.tag) { case 2: return { tag: 0 }; case 1: return { tag: 0 }; case 0: return _$$9.h3; } };
let Lib_CompileJS_JPrimOp = ( h0, h1, h2 ) => ({ tag: 7,  h0: h0,  h1: h1,  h2: h2 });
let Lib_CompileJS_simpleJSExp = ( _$$0 ) => { while (1) { let _$$01 = _$$0; switch (_$$01.tag) { case 11: { _$$0 = _$$01.h0; continue; break; } case 10: { let sc$$3 = Lib_CompileJS_simpleJSExp(_$$01.h0); switch (sc$$3) { case true: { _$$0 = _$$01.h1; continue; break; } case false: return false; } break; } case 8: return true; case 5: return true; case 3: return true; case 2: return true; case 1: return true; default: return false; } } };
let Lib_CompileJS_JLet = ( h0, h1 ) => ({ tag: 4,  h0: h0,  h1: h1 });
let Lib_CompileJS_JWhile = ( h1 ) => ({ tag: 9,  h1: h1 });
let Lib_CompileJS_termToJS_go$27 = ( _, _1, _2, _3, _4, _$$7, _$$8, _$$9, _$$10 ) => { while (1) { let _5 = _; let _6 = _1; let _7 = _2; let _8 = _3; let _9 = _4; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; let _$$101 = _$$10; if ((_$$81.tag) == (1)) { switch (_$$81.h1.h2) { case true: { let sc$$18 = Lib_CompileJS_freshName$27(_$$81.h1.h3, _$$91); _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = sc$$18.h3; _$$10 = { tag: 1,  h1: _$$101,  h2: Lib_CompileJS_JConst(sc$$18.h2, Lib_CompileJS_getEnv(_$$71, _$$91.h0)) }; continue; break; } case false: { let env$27 = { tag: 0,  h0: { tag: 1,  h1: Lib_CompileJS_JUndefined,  h2: _$$91.h0 },  h1: _$$91.h1 }; _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = env$27; _$$10 = _$$101; continue; break; } } } else { return { tag: 0,  h2: Prelude__$3C$3E$3E_(_$$101, { tag: 0 }),  h3: _$$91 }; } } };
let Lib_CompileJS_LitObject = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_CompileJS_Raw = ( h0 ) => ({ tag: 12,  h0: h0 });
let Lib_CompileJS_maybeWrap = ( _$$0 ) => (( (_$$0.tag) == (3) ? _$$0.h0 : Lib_CompileJS_Apply(Lib_CompileJS_JLam({ tag: 0 }, _$$0), { tag: 0 }) ));
let Lib_CompileJS_sortedNames = ( _$$0, _$$1 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), Prelude_filter(( _$$5 ) => (Prelude_not(_$$5.h2)), Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_go(_$$0, _$$1, { tag: 0 }, eta, eta1))), { tag: 0 }, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(true, eta)), _$$1)))));
let Lib_CompileJS_sortedNames_go = ( _, _1, _$$5, _$$6, _$$7 ) => { let acc; let sc$$12 = (_$$7.h2) && ((Prelude_not(Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), { tag: 0,  h2: false,  h3: _$$7.h3 }, _$$6))) && (Prelude_not(Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), { tag: 0,  h2: false,  h3: _$$7.h3 }, _$$5)))); switch (sc$$12) { case true: { acc = Lib_CompileJS_sortedNames_go(_, _1, _$$5, _$$6, { tag: 0,  h2: false,  h3: _$$7.h3 }); break; } case false: { acc = _$$6; break; } } let sc$$13 = Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), _$$7, _$$5); switch (sc$$13) { case true: return acc; case false: { let sc$$14 = Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), _$$7, acc); switch (sc$$14) { case true: return acc; case false: { let sc$$15 = Data_SortedMap_lookupMap$27(_$$7.h3, _); return ( (sc$$15.tag) == (1) ? acc : { tag: 1,  h1: _$$7,  h2: Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_go(_, _1, { tag: 1,  h1: _$$7,  h2: _$$5 }, eta, eta1))), acc, Lib_CompileJS_sortedNames_getNames(_, _1, _$$7.h2, { tag: 0 }, sc$$15.h1)) } ); break; } } break; } } };
let Lib_CompileJS_sortedNames_getNames = ( _, _1, deep$$4, _$$5, _$$6 ) => { while (1) { let _2 = _; let _3 = _1; let deep$$41 = deep$$4; let _$$51 = _$$5; let _$$61 = _$$6; switch (_$$61.tag) { case 16: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h2; continue; break; } case 15: return Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(deep$$41, eta)), _$$61.h1), _$$51); case 14: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, eta, eta1))), _$$51, _$$61.h2); case 13: return _$$51; case 12: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_getNames(_2, _3, true, eta, eta1))), _$$51, _$$61.h0); case 11: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = _$$51; _$$6 = _$$61.h1; continue; break; } case 10: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h2; continue; break; } case 9: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h2; continue; break; } case 8: return _$$51; case 7: return _$$51; case 6: return { tag: 1,  h1: { tag: 0,  h2: deep$$41,  h3: _$$61.h0 },  h2: _$$51 }; case 5: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, eta, eta1))), _$$51, { tag: 1,  h1: _$$61.h0,  h2: Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileJS_sortedNames_getBody(_2, _3, eta)), _$$61.h1) }); case 4: { _ = _2; _1 = _3; deep$$4 = true; _$$5 = Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h0; continue; break; } case 3: { let sc$$10 = Prelude_eqInt(Prelude_length$27(_$$61.h1), Prelude_length$27(_$$61.h2)); switch (sc$$10) { case true: return ( (_$$61.h1.tag) == (0) ? { tag: 1,  h1: { tag: 0,  h2: true,  h3: _$$61.h0 },  h2: _$$51 } : Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_getNames(_2, _3, true, eta, eta1))), { tag: 1,  h1: { tag: 0,  h2: true,  h3: _$$61.h0 },  h2: _$$51 }, _$$61.h1) ); case false: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_sortedNames_getNames(_2, _3, deep$$41, eta, eta1))), { tag: 1,  h1: { tag: 0,  h2: deep$$41,  h3: _$$61.h0 },  h2: _$$51 }, _$$61.h1); } break; } case 2: switch (deep$$41) { case true: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = _$$51; _$$6 = _$$61.h1; continue; break; } case false: return _$$51; } break; case 1: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = _$$51; _$$6 = _$$61.h1; continue; break; } case 0: return _$$51; } } };
let Lib_CompileJS_sortedNames_getBody = ( _, _1, _$$3 ) => { switch (_$$3.tag) { case 2: return _$$3.h1; case 1: return _$$3.h0; case 0: return _$$3.h5; } };
let Prelude_Prelude_Eq$20Prelude_Bool$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$0) { case true: return _$$1; case false: switch (_$$1) { case false: return true; default: return false; } break; } };
let Prelude_Prelude_Eq$20Prelude_Bool = Prelude_MkEq(( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prelude_Bool$2C_$3D$3D_(eta, eta1))));
let Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29 = ( _, _1 ) => (Prelude_MkEq(( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2C_$3D$3D_(_, _1, eta, eta1)))));
let Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2C_$3D$3D_ = ( _$$2, _$$3, _$$4, _$$5 ) => ((Prelude__$3D$3D_(_$$2)(_$$4.h2)(_$$5.h2)) && (Prelude__$3D$3D_(_$$3)(_$$4.h3)(_$$5.h3)));
let Lib_TCO_tailCallOpt = ( _$$0 ) => { let graph = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude_Prelude_Bifunctor$20Prelude__$D7_$2Cbimap(( _$$1 ) => (_$$1), ( eta ) => (Lib_TCO_tailNames(eta)), eta)), Data_SortedMap_toList(_$$0)); let groups = Data_Graph_tarjan(Lib_Common_Prelude_Eq$20Lib_Common_QName, Lib_Common_Prelude_Ord$20Lib_Common_QName, graph); return Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_TCO_tailCallOpt_processGroup(_$$0, eta, eta1))), _$$0, groups); };
let Lib_TCO_tailCallOpt_processGroup = ( _, _$$3, _$$4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((((("compile.tco: group ") + (Prelude_showInt(Prelude_length$27(_$$4)))) + (" ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Common_Prelude_Show$20Lib_Common_QName, _$$4))) + (""))), ( _1 ) => { let pairs = Prelude_mapMaybe(( _$$5 ) => (Data_SortedMap_lookupMap(_$$5, _$$3)), _$$4); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TCO_doOptimize(pairs), ( updates ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_TCO_tailCallOpt_doUpdate(_, eta, eta1))), _$$3, updates)))); }));
let Lib_TCO_tailCallOpt_doUpdate = ( _, _$$2, _$$3 ) => (Data_SortedMap_updateMap(_$$3.h2, _$$3.h3, _$$2));
let Lib_TCO_doOptimize = ( _$$0 ) => { if ((_$$0.tag) == (1)) { if ((_$$0.h2.tag) == (0)) { if ((_$$0.h1.h3.tag) == (2)) { let body = Lib_TCO_rewriteLoop(_$$0.h1.h2, _$$0.h1.h3.h1); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: { tag: 0,  h2: _$$0.h1.h2,  h3: Lib_CompileExp_CFun(_$$0.h1.h3.h0, Lib_CompileExp_CLetLoop(_$$0.h1.h3.h0, body)) },  h2: { tag: 0 } }); } else { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("doOptimize ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0.h1.h2))) + (" not a CFun"))), eta)))); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TCO_doOptimize_splitFun(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h1.h0, _$$0.h1.h1, _$$0.h1.h2, _$$0.h1.h3, eta)), _$$0), ( splitFuns ) => { let nms = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0); let alts = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_TCO_doOptimize_mkAlt(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h1.h0, _$$0.h1.h1, _$$0.h1.h2, _$$0.h1.h3, nms, eta)), Prelude_enumerate(splitFuns)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TCO_doOptimize_mkRecName(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h1.h0, _$$0.h1.h1, _$$0.h1.h2, _$$0.h1.h3, nms), ( recName ) => { let recfun = Lib_CompileExp_CFun({ tag: 1,  h1: { tag: 0,  h2: true,  h3: "arg" },  h2: { tag: 0 } }, Lib_CompileExp_CCase(Lib_CompileExp_CBnd(0), alts)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TCO_doOptimize_mkWrap(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h1.h0, _$$0.h1.h1, _$$0.h1.h2, _$$0.h1.h3, recName, eta)), Prelude_enumerate(_$$0)), ( wrapped ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: { tag: 0,  h2: recName,  h3: recfun },  h2: wrapped }))); }); }); } } else { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TCO_doOptimize_splitFun$27(_$$0, eta)), _$$0), ( splitFuns ) => { let nms = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$0); let alts = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_TCO_doOptimize_mkAlt$27(_$$0, nms, eta)), Prelude_enumerate(splitFuns)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_TCO_doOptimize_mkRecName$27(_$$0, nms), ( recName ) => { let recfun = Lib_CompileExp_CFun({ tag: 1,  h1: { tag: 0,  h2: true,  h3: "arg" },  h2: { tag: 0 } }, Lib_CompileExp_CCase(Lib_CompileExp_CBnd(0), alts)); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_TCO_doOptimize_mkWrap$27(_$$0, recName, eta)), Prelude_enumerate(_$$0)), ( wrapped ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: { tag: 0,  h2: recName,  h3: recfun },  h2: wrapped }))); }); }); } };
let Lib_TCO_doOptimize_mkWrap$27 = ( _, _$$2, _$$3 ) => { if ((_$$3.h3.h3.tag) == (2)) { let arglen = Prelude_length$27(_$$3.h3.h3.h0); let conargs = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( k ) => (Lib_CompileExp_CBnd(((arglen) - (k)) - (1))), Lib_Common_range(0, arglen)); let conquant = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$31 ) => (true), conargs); let arg = Lib_CompileExp_CConstr((1) + (_$$3.h2), Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h3.h2), conargs, conquant, 0); let body = Lib_CompileExp_CAppRef(Lib_TCO_bouncer, { tag: 1,  h1: Lib_CompileExp_CRef(_$$2),  h2: { tag: 1,  h1: arg,  h2: { tag: 0 } } }, { tag: 1,  h1: true,  h2: { tag: 1,  h1: true,  h2: { tag: 0 } } }); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$3.h3.h2,  h3: Lib_CompileExp_CFun(_$$3.h3.h3.h0, body) }); } else { return Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("error in mkWrap: ") + (Prelude_showInt(Prelude_natToInt(_$$3.h2)))) + (" not a CFun"))), eta)))); } };
let Lib_CompileExp_CFun = ( h0, h1 ) => ({ tag: 2,  h0: h0,  h1: h1 });
let Lib_TCO_bouncer = { tag: 0,  h0: "",  h1: "bouncer" };
let Lib_CompileExp_CAppRef = ( h0, h1, h2 ) => ({ tag: 3,  h0: h0,  h1: h1,  h2: h2 });
let Lib_CompileExp_CConstr = ( h0, h1, h2, h3, h4 ) => ({ tag: 14,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Lib_Common_range = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$0, _$$1), 0); switch (sc$$2) { case true: return { tag: 1,  h1: _$$0,  h2: Lib_Common_range((_$$0) + (1), _$$1) }; case false: return { tag: 0 }; } };
let Lib_CompileExp_CBnd = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_CompileExp_CCase = ( h0, h1 ) => ({ tag: 5,  h0: h0,  h1: h1 });
let Lib_TCO_doOptimize_mkRecName$27 = ( _, _$$3 ) => (( (_$$3.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h0: _$$3.h1.h0,  h1: (("REC_") + (_$$3.h1.h1)) + ("") }) : Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "INTERNAL ERROR: Empty List in doOptimize")), eta)))) ));
let Lib_TCO_doOptimize_mkAlt$27 = ( _, _$$4, _$$5 ) => (Lib_CompileExp_CConAlt((1) + (_$$5.h2), Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$5.h3.h2), 0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), _$$5.h3.h3.h2), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$5.h3.h3.h2), Lib_TCO_rewriteTailCalls(_$$4, _$$5.h3.h3.h3)));
let Lib_TCO_rewriteTailCalls = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 10: return Lib_CompileExp_CLetRec(_$$1.h0, _$$1.h1, Lib_TCO_rewriteTailCalls(_$$0, _$$1.h2)); case 9: return Lib_CompileExp_CLet(_$$1.h0, _$$1.h1, Lib_TCO_rewriteTailCalls(_$$0, _$$1.h2)); case 5: return Lib_CompileExp_CCase(_$$1.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_TCO_rewriteTailCalls_rewriteAlt(_$$0, _$$1, eta)), _$$1.h1)); case 3: { let sc$$8 = Prelude_eqInt(Prelude_length$27(_$$1.h1), Prelude_length$27(_$$1.h2)); switch (sc$$8) { case true: { let sc$$9 = Lib_TCO_rewriteTailCalls_getTag(_$$0, _$$1, (1) + (0), _$$1.h0, _$$0); return ( (sc$$9.tag) == (1) ? Lib_CompileExp_CConstr(0, "return", { tag: 1,  h1: _$$1,  h2: { tag: 0 } }, { tag: 1,  h1: true,  h2: { tag: 0 } }, 0) : Lib_CompileExp_CConstr(sc$$9.h1, Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h0), _$$1.h1, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$3 ) => (true), _$$1.h1), 0) ); break; } case false: return Lib_CompileExp_CConstr(0, "return", { tag: 1,  h1: _$$1,  h2: { tag: 0 } }, { tag: 1,  h1: true,  h2: { tag: 0 } }, 0); } break; } default: return Lib_CompileExp_CConstr(0, "return", { tag: 1,  h1: _$$1,  h2: { tag: 0 } }, { tag: 1,  h1: true,  h2: { tag: 0 } }, 0); } };
let Lib_TCO_rewriteTailCalls_getTag = ( _, _1, _$$3, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; let _$$51 = _$$5; if ((_$$51.tag) == (1)) { let sc$$9 = Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$51.h1, _$$41); switch (sc$$9) { case true: return Prelude_Just(_$$31); case false: { _ = _2; _1 = _3; _$$3 = (1) + (_$$31); _$$4 = _$$41; _$$5 = _$$51.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_TCO_rewriteTailCalls_rewriteAlt = ( _, _1, _$$4 ) => { switch (_$$4.tag) { case 2: return Lib_CompileExp_CLitAlt(_$$4.h0, Lib_TCO_rewriteTailCalls(_, _$$4.h1)); case 1: return Lib_CompileExp_CDefAlt(Lib_TCO_rewriteTailCalls(_, _$$4.h0)); case 0: return Lib_CompileExp_CConAlt(_$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _$$4.h4, Lib_TCO_rewriteTailCalls(_, _$$4.h5)); } };
let Lib_CompileExp_CConAlt = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Lib_CompileExp_CDefAlt = ( h0 ) => ({ tag: 1,  h0: h0 });
let Lib_CompileExp_CLitAlt = ( h0, h1 ) => ({ tag: 2,  h0: h0,  h1: h1 });
let Lib_CompileExp_CLet = ( h0, h1, h2 ) => ({ tag: 9,  h0: h0,  h1: h1,  h2: h2 });
let Lib_CompileExp_CLetRec = ( h0, h1, h2 ) => ({ tag: 10,  h0: h0,  h1: h1,  h2: h2 });
let Lib_TCO_doOptimize_splitFun$27 = ( _, _$$5 ) => (( (_$$5.h3.tag) == (2) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$5.h2,  h3: { tag: 0,  h2: _$$5.h3.h0,  h3: _$$5.h3.h1 } }) : Lib_Types_MkM(( _1 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("TCO error: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$5.h2))) + (" not a function"))), eta)))) ));
let Lib_TCO_doOptimize_mkWrap = ( _, _1, _2, _3, _4, _5, _6, _7, _$$9, _$$10 ) => { if ((_$$10.h3.h3.tag) == (2)) { let arglen = Prelude_length$27(_$$10.h3.h3.h0); let conargs = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( k ) => (Lib_CompileExp_CBnd(((arglen) - (k)) - (1))), Lib_Common_range(0, arglen)); let conquant = Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$3 ) => (true), conargs); let arg = Lib_CompileExp_CConstr((1) + (_$$10.h2), Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$10.h3.h2), conargs, conquant, 0); let body = Lib_CompileExp_CAppRef(Lib_TCO_bouncer, { tag: 1,  h1: Lib_CompileExp_CRef(_$$9),  h2: { tag: 1,  h1: arg,  h2: { tag: 0 } } }, { tag: 1,  h1: true,  h2: { tag: 1,  h1: true,  h2: { tag: 0 } } }); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$10.h3.h2,  h3: Lib_CompileExp_CFun(_$$10.h3.h3.h0, body) }); } else { return Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("error in mkWrap: ") + (Prelude_showInt(Prelude_natToInt(_$$10.h2)))) + (" not a CFun"))), eta)))); } };
let Lib_TCO_doOptimize_mkRecName = ( _, _1, _2, _3, _4, _5, _6, _7, _$$10 ) => (( (_$$10.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h0: _$$10.h1.h0,  h1: (("REC_") + (_$$10.h1.h1)) + ("") }) : Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "INTERNAL ERROR: Empty List in doOptimize")), eta)))) ));
let Lib_TCO_doOptimize_mkAlt = ( _, _1, _2, _3, _4, _5, _6, _7, _$$11, _$$12 ) => (Lib_CompileExp_CConAlt((1) + (_$$12.h2), Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$12.h3.h2), 0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), _$$12.h3.h3.h2), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), _$$12.h3.h3.h2), Lib_TCO_rewriteTailCalls(_$$11, _$$12.h3.h3.h3)));
let Lib_TCO_doOptimize_splitFun = ( _, _1, _2, _3, _4, _5, _6, _7, _$$12 ) => (( (_$$12.h3.tag) == (2) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$12.h2,  h3: { tag: 0,  h2: _$$12.h3.h0,  h3: _$$12.h3.h1 } }) : Lib_Types_MkM(( _8 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("TCO error: ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$12.h2))) + (" not a function"))), eta)))) ));
let Lib_CompileExp_CLetLoop = ( h0, h1 ) => ({ tag: 11,  h0: h0,  h1: h1 });
let Lib_TCO_rewriteLoop = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 10: return Lib_CompileExp_CLetRec(_$$1.h0, _$$1.h1, Lib_TCO_rewriteLoop(_$$0, _$$1.h2)); case 9: return Lib_CompileExp_CLet(_$$1.h0, _$$1.h1, Lib_TCO_rewriteLoop(_$$0, _$$1.h2)); case 5: return Lib_CompileExp_CCase(_$$1.h0, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_TCO_rewriteLoop_rewriteAlt(_$$0, _$$1, eta)), _$$1.h1)); case 3: { let sc$$7 = (Prelude_eqInt(Prelude_length$27(_$$1.h1), Prelude_length$27(_$$1.h2))) && (Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(_$$1.h0, _$$0)); switch (sc$$7) { case true: return Lib_CompileExp_CLoop(_$$1.h1, _$$1.h2); case false: return _$$1; } break; } default: return _$$1; } };
let Lib_CompileExp_CLoop = ( h0, h1 ) => ({ tag: 12,  h0: h0,  h1: h1 });
let Lib_TCO_rewriteLoop_rewriteAlt = ( _, _1, _$$3 ) => { switch (_$$3.tag) { case 2: return Lib_CompileExp_CLitAlt(_$$3.h0, Lib_TCO_rewriteLoop(_, _$$3.h1)); case 1: return Lib_CompileExp_CDefAlt(Lib_TCO_rewriteLoop(_, _$$3.h0)); case 0: return Lib_CompileExp_CConAlt(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, Lib_TCO_rewriteLoop(_, _$$3.h5)); } };
let Prelude_MkOrd = ( h1 ) => ({ tag: 0,  h1: h1 });
let Lib_Common_Prelude_Ord$20Lib_Common_QName = Prelude_MkOrd(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1))));
let Data_Graph_tarjan = ( _$$1, _$$2, _$$3 ) => { let g = Data_SortedMap_foldMap(( _$$21 ) => (( _$$31 ) => (_$$21)), Data_SortedMap_EmptyMap(_$$2.h1), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Data_Graph_tarjan_mkVertex(_$$1, _$$2, _$$3, eta)), _$$3)); let _sc$$0 = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Data_Graph_tarjan_checkVertex(_$$1, _$$2, _$$3, eta, eta1))), Data_Graph_MkTState(0, { tag: 0 }, { tag: 0 }, g), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$3)); return _sc$$0.h3; };
let Data_Graph_MkTState = ( h1, h2, h3, h4 ) => ({ tag: 0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
let Data_Graph_tarjan_checkVertex = ( _, _1, _2, _$$6, _$$7 ) => { let sc$$8 = Data_SortedMap_lookupMap$27(_$$7, _$$6.h4); if ((sc$$8.tag) == (0)) { let sc$$11 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(sc$$8.h1.h3, 0), 2); switch (sc$$11) { case true: return _$$6; case false: return Data_Graph_strongConnect(_, _1, _$$6, sc$$8.h1); } } else { return _$$6; } };
let Data_Graph_strongConnect = ( _$$1, _$$2, _$$3, _$$4 ) => { let index$27 = (_$$3.h1) + (1); let vtx$27 = Data_Graph_MkTV(_$$4.h1, _$$4.h2, index$27, index$27, true); let stack$27 = { tag: 1,  h1: _$$4.h1,  h2: _$$3.h2 }; let graph$27 = Data_SortedMap_updateMap(vtx$27.h1, vtx$27, _$$3.h4); let st$27 = Data_Graph_MkTState(index$27, stack$27, _$$3.h3, graph$27); return Data_Graph_strongConnect_checkRoot(_$$1, _$$2, _$$3, _$$4, Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Data_Graph_strongConnect_doEdge(_$$1, _$$2, _$$3, _$$4, eta, eta1))), st$27, _$$4.h2)); };
let Data_Graph_strongConnect_doEdge = ( _, _1, _2, _3, _$$11, _$$12 ) => { let sc$$13 = Data_SortedMap_lookupMap$27(_$$12, _$$11.h4); if ((sc$$13.tag) == (0)) { switch (sc$$13.h1.h5) { case true: return Data_Graph_strongConnect_updateLowLink(_, _1, _2, _3, _$$11, _3.h1, sc$$13.h1.h3); case false: { let sc$$17 = Prelude_eqInt(sc$$13.h1.h3, 0); switch (sc$$17) { case true: { let st$27 = Data_Graph_strongConnect(_, _1, _$$11, sc$$13.h1); let sc$$19 = Data_SortedMap_lookupMap$27(_$$12, st$27.h4); return ( (sc$$19.tag) == (0) ? Data_Graph_strongConnect_updateLowLink(_, _1, _2, _3, st$27, _3.h1, sc$$19.h1.h4) : st$27 ); break; } case false: return _$$11; } break; } } } else { return _$$11; } };
let Data_Graph_strongConnect_updateLowLink = ( _, _1, _2, _3, _$$9, _$$10, _$$11 ) => (Data_Graph_strongConnect_updateNode(_, _1, _2, _3, _$$9, _$$10, ( vt ) => (Data_Graph_MkTV(vt.h1, vt.h2, vt.h3, Data_Graph_strongConnect_min(_, _1, _2, _3, vt.h4, _$$11), vt.h5))));
let Data_Graph_strongConnect_min = ( _, _1, _2, _3, _$$6, _$$7 ) => { let sc$$8 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(_$$6, _$$7), 0); switch (sc$$8) { case true: return _$$6; case false: return _$$7; } };
let Data_Graph_MkTV = ( h1, h2, h3, h4, h5 ) => ({ tag: 0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
let Data_Graph_strongConnect_updateNode = ( _, _1, _2, _3, _$$8, _$$9, _$$10 ) => { let sc$$16 = Data_SortedMap_lookupMap$27(_$$9, _$$8.h4); return ( (sc$$16.tag) == (1) ? _$$8 : Data_Graph_MkTState(_$$8.h1, _$$8.h2, _$$8.h3, Data_SortedMap_updateMap(_$$9, _$$10(sc$$16.h1), _$$8.h4)) ); };
let Data_Graph_strongConnect_checkRoot = ( _, _1, _2, _3, _$$12 ) => { let sc$$13 = Data_SortedMap_lookupMap$27(_3.h1, _$$12.h4); if ((sc$$13.tag) == (0)) { let sc$$16 = Prelude_eqInt(sc$$13.h1.h4, sc$$13.h1.h3); switch (sc$$16) { case true: { let sc$$17 = Data_Graph_strongConnect_splitComp(_, _1, _2, _3, { tag: 0 }, _$$12.h2); let st = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Data_Graph_strongConnect_offStack(_, _1, _2, _3, eta, eta1))), _$$12, sc$$17.h2); let sc$$23 = (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_Prelude_Ord$20Prim_Int$2Ccompare(Prelude_length$27(sc$$17.h2), 1), 2)) || (Prelude_elem(_, sc$$13.h1.h1, sc$$13.h1.h2)); switch (sc$$23) { case true: return Data_Graph_MkTState(st.h1, sc$$17.h3, { tag: 1,  h1: sc$$17.h2,  h2: st.h3 }, st.h4); case false: return Data_Graph_MkTState(st.h1, sc$$17.h3, st.h3, st.h4); } break; } case false: return _$$12; } } else { return _$$12; } };
let Data_Graph_strongConnect_offStack = ( _, _1, _2, _3, _$$10, _$$11 ) => (Data_Graph_strongConnect_updateNode(_, _1, _2, _3, _$$10, _$$11, ( vt ) => (Data_Graph_MkTV(vt.h1, vt.h2, vt.h3, vt.h4, false))));
let Data_Graph_strongConnect_splitComp = ( _, _1, _2, _3, _$$7, _$$8 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$71 = _$$7; let _$$81 = _$$8; if ((_$$81.tag) == (1)) { let sc$$12 = Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(Prelude_compare(_5)(_$$81.h1)(_7.h1), 1); switch (sc$$12) { case true: return { tag: 0,  h2: { tag: 1,  h1: _$$81.h1,  h2: _$$71 },  h3: _$$81.h2 }; case false: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$7 = { tag: 1,  h1: _$$81.h1,  h2: _$$71 }; _$$8 = _$$81.h2; continue; break; } } } else { return { tag: 0,  h2: _$$71,  h3: { tag: 0 } }; } } };
let Prelude_compare = ( _$$1 ) => (_$$1.h1);
let Data_Graph_tarjan_mkVertex = ( _, _1, _2, _$$5 ) => ({ tag: 0,  h2: _$$5.h2,  h3: Data_Graph_MkTV(_$$5.h2, _$$5.h3, 0, 0, false) });
let Lib_TCO_tailNames = ( _$$0 ) => { while (1) { let _$$01 = _$$0; switch (_$$01.tag) { case 16: return { tag: 0 }; case 15: return { tag: 0 }; case 14: return { tag: 0 }; case 13: return { tag: 0 }; case 12: return { tag: 0 }; case 11: return { tag: 0 }; case 10: { _$$0 = _$$01.h2; continue; break; } case 9: { _$$0 = _$$01.h2; continue; break; } case 8: return { tag: 0 }; case 7: return { tag: 0 }; case 6: return { tag: 0 }; case 5: return Prelude_Prelude_Monad$20Prelude_List$2Cbind(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_TCO_tailNames_altTailNames(_$$01, _$$01.h0, _$$01.h1, eta)), _$$01.h1), ( _$$1 ) => (_$$1)); case 4: return { tag: 0 }; case 3: return { tag: 1,  h1: _$$01.h0,  h2: { tag: 0 } }; case 2: { _$$0 = _$$01.h1; continue; break; } case 1: return { tag: 0 }; case 0: return { tag: 0 }; } } };
let Lib_TCO_tailNames_altTailNames = ( _, _1, _2, _$$4 ) => { switch (_$$4.tag) { case 2: return Lib_TCO_tailNames(_$$4.h1); case 1: return Lib_TCO_tailNames(_$$4.h0); case 0: return Lib_TCO_tailNames(_$$4.h5); } };
let Lib_Ref2_MkRef = ( h2 ) => ({ tag: 0,  h2: h2 });
let Lib_CompileExp_defToCExp = ( _$$0, _$$1 ) => { switch (_$$1.h3.tag) { case 6: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$2C_(_$$1.h2, eta)), Lib_CompileExp_compilePop(_$$1.h2)); case 5: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$1.h2,  h3: Lib_CompileExp_CRaw(_$$1.h3.h0, _$$1.h3.h2) }); case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$1.h2,  h3: Lib_CompileExp_compileDCon(0, _$$1.h2, 0, Prelude_replicate(Prelude_intToNat(_$$1.h3.h0), true)) }); case 3: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Prelude__$2C_(_$$1.h2, eta)), Lib_CompileExp_compileFun(_$$0, _$$1.h3.h0)); case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$1.h2,  h3: Lib_CompileExp_compileDCon(_$$1.h3.h0, _$$1.h2, _$$1.h3.h1, _$$1.h3.h2) }); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: _$$1.h2,  h3: Lib_CompileExp_compileDCon(0, _$$1.h2, 0, Prelude_replicate(Prelude_intToNat(_$$1.h3.h0), true)) }); case 0: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h2))) + (" is Axiom"))), eta)))); } };
let Prelude_replicate = ( _$$1, _$$2 ) => (Prelude_replicate_go(_$$1, _$$2, _$$1, { tag: 0 }));
let Prelude_replicate_go = ( _, _1, _$$4, _$$5 ) => { while (1) { let _2 = _; let _3 = _1; let _$$41 = _$$4; let _$$51 = _$$5; switch (_$$41) { case 0: return _$$51; default: { let x = (_$$41) - (1); _ = _2; _1 = _3; _$$4 = x; _$$5 = { tag: 1,  h1: _3,  h2: _$$51 }; continue; break; } } } };
let Lib_CompileExp_compileDCon = ( _$$0, _$$1, _$$2, _$$3 ) => { if ((_$$3.tag) == (0)) { switch (_$$2) { case 5: return Lib_CompileExp_CLit(Lib_Types_LBool(false)); case 4: return Lib_CompileExp_CLit(Lib_Types_LBool(true)); case 3: return Lib_CompileExp_CLit(Lib_Types_LInt(Prelude_natToInt(_$$0))); default: return Lib_CompileExp_CConstr(_$$0, _$$1.h1, { tag: 0 }, { tag: 0 }, _$$2); } } else { let args = Lib_CompileExp_compileDCon_mkArgs(_$$0, _$$1, _$$2, _$$3, _$$1.h0, _$$1.h1, 0, _$$3); let alen = Prelude_length$27(_$$3); return Lib_CompileExp_CFun(args, Lib_CompileExp_CConstr(_$$0, _$$1.h1, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( k ) => (Lib_CompileExp_CBnd(((alen) - (k)) - (1))), Lib_Common_range(0, alen)), _$$3, _$$2)); } };
let Lib_CompileExp_compileDCon_mkArgs = ( _, _1, _2, _3, _4, _5, _$$7, _$$8 ) => (( (_$$8.tag) == (1) ? { tag: 1,  h1: { tag: 0,  h2: _$$8.h1,  h3: (("h") + (Prelude_showInt(Prelude_natToInt(_$$7)))) + ("") },  h2: Lib_CompileExp_compileDCon_mkArgs(_, _1, _2, _3, _4, _5, (1) + (_$$7), _$$8.h2) } : { tag: 0 } ));
let Lib_Types_LBool = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_CompileExp_compileFun = ( _$$0, _$$1 ) => (Lib_CompileExp_compileFun_go(_$$0, _$$1, _$$1, { tag: 0 }));
let Lib_CompileExp_compileFun_go = ( _, _1, _$$3, _$$4 ) => { while (1) { let _2 = _; let _3 = _1; let _$$31 = _$$3; let _$$41 = _$$4; if ((_$$31.tag) == (3)) { _ = _2; _1 = _3; _$$3 = _$$31.h4; _$$4 = { tag: 1,  h1: _$$41,  h2: { tag: 0,  h2: _$$31.h3,  h3: _$$31.h1 } }; continue; } else { return ( (_$$41.tag) == (0) ? Lib_CompileExp_compileTerm(_2, _$$31) : Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_CompileExp_CFun(Prelude__$3C$3E$3E_(_$$41, { tag: 0 }), eta)), Lib_CompileExp_compileTerm(_2, _$$31)) ); } } };
let Lib_CompileExp_compileTerm = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 11: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CErased); case 10: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLit(_$$1.h1)); case 9: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h3), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h4), ( u$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLetRec(_$$1.h1, t$27, u$27)))))); case 8: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h2), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h3), ( u$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLet(_$$1.h1, t$27, u$27)))))); case 7: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h1), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_for(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, _$$1.h2, ( $$case ) => { switch ($$case.tag) { case 2: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_CompileExp_CLitAlt($$case.h0, eta)), Lib_CompileExp_compileTerm(_$$0, $$case.h1)); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _$$0.h2)), ( defs ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_lookupDef(_$$0, Lib_Common_emptyFC, $$case.h0), ( def ) => (( (def.tag) == (2) ? Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_CompileExp_CConAlt(def.h0, $$case.h0.h1, def.h1, $$case.h1, def.h2, eta)), Lib_CompileExp_compileTerm(_$$0, $$case.h2)) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (("") + ($$case.h0.h1)) + (" is not a data constructor"))), eta)))) ))))); case 0: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_CompileExp_CDefAlt(eta)), Lib_CompileExp_compileTerm(_$$0, $$case.h0)); } }), ( alts$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CCase(t$27, Lib_CompileExp_compileTerm_fancyCons(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, t$27, alts$27))))))); case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h4), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, _$$1.h5), ( u$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CAppRef({ tag: 0,  h0: Lib_Common_primNS,  h1: "PiType" }, { tag: 1,  h1: t$27,  h2: { tag: 1,  h1: Lib_CompileExp_CLam(_$$1.h1, u$27),  h2: { tag: 0 } } }, { tag: 1,  h1: true,  h2: { tag: 1,  h1: true,  h2: { tag: 0 } } })))))); case 5: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CRef({ tag: 0,  h0: "",  h1: "U" })); case 4: { let sc$$6 = Lib_Util_funArgs(_$$1); switch (sc$$6.h2.tag) { case 2: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$1), (("Compiling an unsolved meta ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$1))) + (""))), eta)))); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _$$0.h2)), ( defs ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_CompileExp_compileTerm(_$$0, eta)), sc$$6.h3), ( args$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_arityForName(_$$0, sc$$6.h2.h0, sc$$6.h2.h1), ( arity ) => { let sc$$16 = Data_SortedMap_lookupMap$27(sc$$6.h2.h1, defs); if ((sc$$16.tag) == (0)) { if ((sc$$16.h1.tag) == (2)) { switch (sc$$16.h1.h1) { case 7: { let sc$$23 = Prelude_eqInt(Prelude_length$27(sc$$16.h1.h2), Prelude_length$27(sc$$6.h3)); switch (sc$$23) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CConstr(sc$$16.h1.h0, sc$$6.h2.h1.h1, args$27, sc$$16.h1.h2, 7)); case false: return Lib_CompileExp_apply(sc$$6.h2.h1, args$27, arity); } break; } case 6: { let sc$$23 = Prelude_eqInt(Prelude_length$27(sc$$16.h1.h2), Prelude_length$27(sc$$6.h3)); switch (sc$$23) { case true: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CConstr(sc$$16.h1.h0, sc$$6.h2.h1.h1, args$27, sc$$16.h1.h2, 6)); case false: return Lib_CompileExp_apply(sc$$6.h2.h1, args$27, arity); } break; } case 1: return Lib_CompileExp_compileTerm_applySucc(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, args$27); default: return Lib_CompileExp_apply(sc$$6.h2.h1, args$27, arity); } } else { return Lib_CompileExp_apply(sc$$6.h2.h1, args$27, arity); } } else { return Lib_CompileExp_apply(sc$$6.h2.h1, args$27, arity); } }))))); default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((("apply other ") + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, sc$$6.h2))), { tag: 0 }))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_compileTerm(_$$0, sc$$6.h2), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_CompileExp_compileTerm(_$$0, eta)), sc$$6.h3), ( args$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileExp_CApp(eta, eta1))), t$27, args$27)))))))); } break; } case 3: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_CompileExp_CLam(_$$1.h1, eta)), Lib_CompileExp_compileTerm(_$$0, _$$1.h4)); case 2: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1.h0, (("Compiling meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h1))) + (""))), eta)))); case 1: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileExp_arityForName(_$$0, _$$1.h0, _$$1.h1), ( arity ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _$$0.h2)), ( defs ) => { if ((arity.tag) == (0)) { let sc$$10 = Data_SortedMap_lookupMap$27(_$$1.h1, defs); if ((sc$$10.tag) == (0)) { if ((sc$$10.h1.tag) == (2)) { switch (sc$$10.h1.h1) { case 5: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLit(Lib_Types_LBool(false))); case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLit(Lib_Types_LBool(true))); case 3: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLit(Lib_Types_LInt(Prelude_natToInt(sc$$10.h1.h0)))); case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLit(Lib_Types_LInt(0))); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLam("x", Lib_CompileExp_CPrimOp("+", Lib_CompileExp_CLit(Lib_Types_LInt(1)), Lib_CompileExp_CBnd(0)))); default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CRef(_$$1.h1)); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CRef(_$$1.h1)); } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CRef(_$$1.h1)); } } else { return Lib_CompileExp_apply(_$$1.h1, { tag: 0 }, arity); } }))); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CBnd(_$$1.h1)); } };
let Lib_CompileExp_apply = ( _$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CAppRef(_$$0, _$$1, _$$2)));
let Lib_CompileExp_CLam = ( h0, h1 ) => ({ tag: 1,  h0: h0,  h1: h1 });
let Data_IORef_primReadIORef = (_, ref) => (w) => Prelude_MkIORes(ref[0], w);
let Lib_CompileExp_arityForName = ( _$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _$$0.h2)), ( defs ) => { let sc$$4 = Data_SortedMap_lookupMap$27(_$$2, defs); if ((sc$$4.tag) == (1)) { return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("Name ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$2))) + (" not in scope"))), eta)))); } else { switch (sc$$4.h1.tag) { case 6: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: true,  h2: { tag: 1,  h1: true,  h2: { tag: 0 } } }); case 5: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_replicate(sc$$4.h1.h1, true)); case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_replicate(Prelude_intToNat(sc$$4.h1.h0), true)); case 3: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_lamArity(sc$$4.h1.h0)); case 2: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$4.h1.h2); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_replicate(Prelude_intToNat(sc$$4.h1.h0), true)); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0 }); } } }));
let Lib_CompileExp_lamArity = ( _$$0 ) => (( (_$$0.tag) == (3) ? { tag: 1,  h1: _$$0.h3,  h2: Lib_CompileExp_lamArity(_$$0.h4) } : { tag: 0 } ));
let Lib_CompileExp_CApp = ( h0, h1 ) => ({ tag: 4,  h0: h0,  h1: h1 });
let Lib_CompileExp_compileTerm_applySucc = ( _, _1, _2, _3, _4, _$$6 ) => (( (_$$6.tag) == (1) ? ( (_$$6.h2.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CPrimOp("+", Lib_CompileExp_CLit(Lib_Types_LInt(1)), _$$6.h1)) : Lib_Types_MkM(( _5 ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_1), (("overapplied Succ ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_1))) + (""))), eta)))) ) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CLam("x", Lib_CompileExp_CPrimOp("+", Lib_CompileExp_CLit(Lib_Types_LInt(1)), Lib_CompileExp_CBnd(0)))) ));
let Lib_CompileExp_compileTerm_fancyCons = ( _, _1, _2, _3, _4, _$$11, _$$12 ) => { let sc$$13 = Lib_CompileExp_any(( eta ) => (Lib_CompileExp_compileTerm_numAltP(_, _1, _2, _3, _4, eta)), _$$12); switch (sc$$13) { case true: return Lib_CompileExp_compileTerm_doNumCon(_, _1, _2, _3, _4, _$$11, _$$12); case false: return Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileExp_compileTerm_enumAlt(_, _1, _2, _3, _4, eta)), _$$12); } };
let Lib_CompileExp_compileTerm_enumAlt = ( _, _1, _2, _3, _4, _$$7 ) => { if ((_$$7.tag) == (0)) { switch (_$$7.h2) { case 5: return Lib_CompileExp_CLitAlt(Lib_Types_LBool(false), _$$7.h5); case 4: return Lib_CompileExp_CLitAlt(Lib_Types_LBool(true), _$$7.h5); case 3: return Lib_CompileExp_CLitAlt(Lib_Types_LInt(Prelude_natToInt(_$$7.h0)), _$$7.h5); default: return _$$7; } } else { return _$$7; } };
let Lib_CompileExp_compileTerm_doNumCon = ( _, _1, _2, _3, _4, _$$10, _$$11 ) => { let zeroAlt; let sc$$12 = Prelude_find(( eta ) => (Lib_CompileExp_compileTerm_isInfo(_, _1, _2, _3, _4, 2, eta)), _$$11); if ((sc$$12.tag) == (0)) { zeroAlt = ( (sc$$12.h1.tag) == (0) ? { tag: 1,  h1: Lib_CompileExp_CLitAlt(Lib_Types_LInt(0), sc$$12.h1.h5),  h2: { tag: 0 } } : Prelude_fatalError(null, (("ERROR zeroAlt mismatch ") + (Prelude_debugStr(null, sc$$12.h1))) + ("")) ); } else { let sc$$13 = Prelude_find(( eta ) => (Lib_CompileExp_compileTerm_isDef(_, _1, _2, _3, _4, eta)), _$$11); zeroAlt = ( (sc$$13.tag) == (0) ? ( (sc$$13.h1.tag) == (1) ? { tag: 1,  h1: Lib_CompileExp_CLitAlt(Lib_Types_LInt(0), sc$$13.h1.h0),  h2: { tag: 0 } } : { tag: 0 } ) : { tag: 0 } ); } let succAlt; let sc$$13 = Prelude_find(( eta ) => (Lib_CompileExp_compileTerm_isInfo(_, _1, _2, _3, _4, 1, eta)), _$$11); if ((sc$$13.tag) == (0)) { succAlt = ( (sc$$13.h1.tag) == (0) ? { tag: 1,  h1: Lib_CompileExp_CDefAlt(Lib_CompileExp_CLet("x", Lib_CompileExp_CPrimOp("-", _$$10, Lib_CompileExp_CLit(Lib_Types_LInt(1))), sc$$13.h1.h5)),  h2: { tag: 0 } } : Prelude_fatalError(null, (("ERROR succAlt mismatch ") + (Prelude_debugStr(null, sc$$13.h1))) + ("")) ); } else { let sc$$14 = Prelude_find(( eta ) => (Lib_CompileExp_compileTerm_isDef(_, _1, _2, _3, _4, eta)), _$$11); succAlt = ( (sc$$14.tag) == (0) ? { tag: 1,  h1: sc$$14.h1,  h2: { tag: 0 } } : { tag: 0 } ); } return Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(zeroAlt, succAlt); };
let Lib_CompileExp_compileTerm_isDef = ( _, _1, _2, _3, _4, _$$9 ) => (( (_$$9.tag) == (1) ? true : false ));
let Lib_CompileExp_compileTerm_isInfo = ( _, _1, _2, _3, _4, _$$8, _$$9 ) => (( (_$$9.tag) == (0) ? Lib_Types_Prelude_Eq$20Lib_Types_ConInfo$2C_$3D$3D_(_$$8, _$$9.h2) : false ));
let Lib_Types_Prelude_Eq$20Lib_Types_ConInfo$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1) { case 7: switch (_$$0) { case 7: return true; default: return false; } break; case 6: switch (_$$0) { case 6: return true; default: return false; } break; case 5: switch (_$$0) { case 5: return true; default: return false; } break; case 4: switch (_$$0) { case 4: return true; default: return false; } break; case 3: switch (_$$0) { case 3: return true; default: return false; } break; case 2: switch (_$$0) { case 2: return true; default: return false; } break; case 1: switch (_$$0) { case 1: return true; default: return false; } break; case 0: switch (_$$0) { case 0: return true; default: return false; } break; } };
let Lib_CompileExp_compileTerm_numAltP = ( _, _1, _2, _3, _4, _$$6 ) => { if ((_$$6.tag) == (0)) { switch (_$$6.h2) { case 2: return true; case 1: return true; default: return false; } } else { return false; } };
let Lib_CompileExp_any = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let sc$$6 = _$$11(_$$21.h1); switch (sc$$6) { case true: return true; case false: { _$$1 = _$$11; _$$2 = _$$21.h2; continue; break; } } } else { return false; } } };
let Lib_CompileExp_lookupDef = ( _$$0, _$$1, _$$2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _$$0.h2)), ( defs ) => { let sc$$4 = Data_SortedMap_lookupMap$27(_$$2, defs); return ( (sc$$4.tag) == (1) ? Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(_$$1, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$2))) + (" not in scope"))), eta)))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(sc$$4.h1) ); }));
let Lib_CompileExp_CErased = { tag: 13 };
let Lib_CompileExp_CRaw = ( h0, h1 ) => ({ tag: 15,  h0: h0,  h1: h1 });
let Lib_CompileExp_compilePop = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$2 = Lib_TopContext_lookup(_$$0, top); return ( (sc$$2.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_CompileExp_CErased) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" not found"))), eta)))) ); }));
let Prelude_mapM = ( _$$1, _$$4, _$$5 ) => (( (_$$5.tag) == (1) ? Prelude_bind(_$$1)(null)(null)(_$$4(_$$5.h1))(( b ) => (Prelude_bind(_$$1)(null)(null)(Prelude_mapM(_$$1, _$$4, _$$5.h2))(( bs ) => (Prelude_pure(_$$1)(null)({ tag: 1,  h1: b,  h2: bs }))))) : Prelude_pure(_$$1)(null)({ tag: 0 }) ));
let Lib_LiftWhere_liftWhere = ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _.h2)), ( defs ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$3 ) => (0), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_LiftWhere_liftWhereFn(_, eta)), Data_SortedMap_toList(defs))))));
let Lib_LiftWhere_liftWhereFn = ( _$$0, _$$1 ) => (( (_$$1.h3.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1.h2, { tag: 0 }, _$$1.h3.h0), ( tm$27 ) => (Lib_Ref2_modifyRef(Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$0, ( eta ) => (Data_SortedMap_updateMap(_$$1.h2, Lib_Types_Fn(tm$27), eta))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ));
let Lib_Ref2_Defs = { tag: 0 };
let Prelude_MkHasIO = ( h1 ) => ({ tag: 0,  h1: h1 });
let Lib_Types_Prelude_HasIO$20Lib_Types_M = Prelude_MkHasIO(( a ) => (( eta ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(eta))));
let Lib_Ref2_modifyRef = ( _$$2, l$$3, _$$4, _$$5 ) => (Prelude_liftIO(_$$2)(null)(Data_IORef_modifyIORef(Prelude_Prelude_Monad$20Prelude_IO, Prelude_Prelude_HasIO$20Prelude_IO, _$$4.h2, _$$5)));
let Prelude_Prelude_HasIO$20Prelude_IO = Prelude_MkHasIO(( a ) => (( _$$1 ) => (_$$1)));
let Prelude_Prelude_Monad$20Prelude_IO = { tag: 0,  h1: ( a ) => (( b ) => (( _$$2 ) => (( _$$3 ) => (( w ) => { let sc$$5 = _$$2(w); return _$$3(sc$$5.h1)(sc$$5.h2); })))),  h2: ( a ) => (( eta ) => (( eta1 ) => (Prelude_MkIORes(eta, eta1)))) };
let Data_IORef_modifyIORef = ( _$$2, _$$3, _$$4, _$$5 ) => (Prelude_bind(_$$2)(null)(null)(Prelude_liftIO(_$$3)(null)(Data_IORef_primReadIORef(null, _$$4)))(( a ) => (Prelude_liftIO(_$$3)(null)(Data_IORef_primWriteIORef(null, _$$4, _$$5(a))))));
let Data_IORef_primWriteIORef = (_, ref, a) => (w) => {
  ref[0] = a
  return Prelude_MkIORes(Prelude_MkUnit,w)
};
let Prelude_liftIO = ( _$$1 ) => (( a ) => (_$$1.h1(null)));
let Lib_LiftWhere_liftWhereTm = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case 9: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm_getName(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, _$$1, _$$3.h1), ( qn ) => { let qs = { tag: 1,  h1: false,  h2: Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$21 ) => (_$$21.h2), _$$2) }; let env$27 = { tag: 1,  h1: { tag: 0,  h2: false,  h3: Prelude_Just({ tag: 0,  h2: qn,  h3: qs }) },  h2: _$$2 }; return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, qn, env$27, _$$3.h3), ( t$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Ref2_modifyRef(Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$0, ( eta ) => (Data_SortedMap_updateMap(qn, Lib_Types_Fn(Lib_LiftWhere_liftWhereTm_wrapLam(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, qs, t$27)), eta))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1, env$27, _$$3.h4), ( u$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_LetRec(_$$3.h0, _$$3.h1, Lib_Types_Erased(_$$3.h0), Lib_Types_Erased(_$$3.h0), u$27)))))))); }); case 8: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h2), ( v ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1, { tag: 1,  h1: { tag: 0,  h2: true,  h3: Prelude_Nothing() },  h2: _$$2 }, _$$3.h3), ( sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Let(_$$3.h0, _$$3.h1, v, sc)))))); case 7: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h1), ( t ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_LiftWhere_liftWhereTm_liftWhereAlt(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, eta)), _$$3.h2), ( alts$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(_$$3.h0, t, alts$27)))))); case 6: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h4), ( t ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhereTm(_$$0, _$$1, { tag: 1,  h1: { tag: 0,  h2: _$$3.h3,  h3: Prelude_Nothing() },  h2: _$$2 }, _$$3.h5), ( u ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Pi(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, t, u)))))); case 4: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (( eta1 ) => (Lib_Types_App(_$$3.h0, eta, eta1))), Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h1)), Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h2)); case 3: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_Lam(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, eta)), Lib_LiftWhere_liftWhereTm(_$$0, _$$1, { tag: 1,  h1: { tag: 0,  h2: _$$3.h3,  h3: Prelude_Nothing() },  h2: _$$2 }, _$$3.h4)); case 0: { let sc$$7 = Prelude_getAt(Prelude_intToNat(_$$3.h1), _$$2); return ( (sc$$7.tag) == (0) ? ( (sc$$7.h1.h3.tag) == (0) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_LiftWhere_liftWhereTm_apply(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, Prelude_length$27(_$$2), Prelude_length$27(sc$$7.h1.h3.h1.h3), Lib_Types_Ref(_$$3.h0, sc$$7.h1.h3.h1.h2))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$3) ) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$3) ); break; } default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$3); } };
let Lib_LiftWhere_liftWhereTm_apply = ( _, _1, _2, _3, _4, _5, _$$7, _$$8, _$$9 ) => { switch (_$$8) { case 0: return _$$9; default: return Lib_Types_App(_4, Lib_LiftWhere_liftWhereTm_apply(_, _1, _2, _3, _4, _5, _$$7, (_$$8) - (1), _$$9), Lib_Types_Bnd(_4, (_$$7) - (_$$8))); } };
let Lib_LiftWhere_liftWhereTm_liftWhereAlt = ( _, _1, _2, _3, _4, _5, _6, _$$8 ) => { switch (_$$8.tag) { case 2: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseLit(_$$8.h0, eta)), Lib_LiftWhere_liftWhereTm(_, _1, _2, _$$8.h1)); case 1: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseCons(_$$8.h0, _$$8.h1, eta)), Lib_LiftWhere_liftWhereTm(_, _1, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$3 ) => ({ tag: 0,  h2: true,  h3: Prelude_Nothing() }), _$$8.h1), _2), _$$8.h2)); case 0: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseDefault(eta)), Lib_LiftWhere_liftWhereTm(_, _1, _2, _$$8.h0)); } };
let Lib_LiftWhere_liftWhereTm_wrapLam = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$11, _$$12 ) => { while (1) { let _9 = _; let _10 = _1; let _11 = _2; let _12 = _3; let _13 = _4; let _14 = _5; let _15 = _6; let _16 = _7; let _17 = _8; let _$$111 = _$$11; let _$$121 = _$$12; if ((_$$111.tag) == (1)) { _ = _9; _1 = _10; _2 = _11; _3 = _12; _4 = _13; _5 = _14; _6 = _15; _7 = _16; _8 = _17; _$$11 = _$$111.h2; _$$12 = Lib_Types_Lam(_13, "_", 1, _$$111.h1, _$$121); continue; } else { return _$$121; } } };
let Lib_LiftWhere_liftWhereTm_getName = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11 ) => { let qn$27 = { tag: 0,  h0: _$$10.h0,  h1: (_$$10.h1) + ((".") + (_$$11)) }; return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _.h2)), ( top ) => { let sc$$16 = Data_SortedMap_lookupMap(qn$27, top); return ( (sc$$16.tag) == (0) ? Lib_LiftWhere_liftWhereTm_getName(_, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, (_$$11) + ("'")) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(qn$27) ); }); };
let Lib_CompileJS_eraseEntries_go = ( _$$1, _$$2 ) => (( (_$$2.h3.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 0 }, _$$2.h3.h0, { tag: 0 }), ( tm$27 ) => (Lib_Ref2_modifyRef(Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$1, ( eta ) => (Data_SortedMap_updateMap(_$$2.h2, Lib_Types_Fn(tm$27), eta))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ));
let Lib_CompileJS_eraseEntries = ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _.h2)), ( defs ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$3 ) => (0), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_CompileJS_eraseEntries_go(_, eta)), Data_SortedMap_toList(defs))))));
let Data_IORef_primNewIORef = (_, a) => (w) => Prelude_MkIORes([a], w);
let Lib_CompileJS_getEntries = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$3 = Lib_TopContext_lookup(_$$1, top); if ((sc$$3.tag) == (1)) { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("bad name ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0))); } else { switch (sc$$3.h1.h3.tag) { case 5: { let acc = Data_SortedMap_updateMap(sc$$3.h1.h1, sc$$3.h1.h3, _$$0); return Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_CompileJS_getEntries(eta, eta1))), acc, sc$$3.h1.h3.h2); break; } case 3: { let sc$$12 = Data_SortedMap_lookupMap$27(sc$$3.h1.h1, _$$0); return ( (sc$$12.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_zonk(top1, 0, { tag: 0 }, sc$$3.h1.h3.h0), ( exp ) => { let acc = Data_SortedMap_updateMap(sc$$3.h1.h1, Lib_Types_Fn(exp), _$$0); return Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_CompileJS_getEntries(eta, eta1))), acc, Lib_CompileJS_getNames(exp, { tag: 0 })); }))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0) ); break; } default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Data_SortedMap_updateMap(_$$1, sc$$3.h1.h3, _$$0)); } } }));
let Lib_CompileJS_getNames = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; switch (_$$01.tag) { case 9: { _$$0 = _$$01.h4; _$$1 = Lib_CompileJS_getNames(_$$01.h3, _$$11); continue; break; } case 8: { _$$0 = _$$01.h3; _$$1 = Lib_CompileJS_getNames(_$$01.h2, _$$11); continue; break; } case 7: { _$$0 = _$$01.h1; _$$1 = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileJS_getNames_getAltNames(_$$01, _$$11, _$$01.h0, _$$01.h1, _$$01.h2, eta, eta1))), _$$11, _$$01.h2); continue; break; } case 6: { _$$0 = _$$01.h5; _$$1 = Lib_CompileJS_getNames(_$$01.h4, { tag: 1,  h1: { tag: 0,  h0: Lib_Common_primNS,  h1: "PiType" },  h2: _$$11 }); continue; break; } case 4: { _$$0 = _$$01.h2; _$$1 = Lib_CompileJS_getNames(_$$01.h1, _$$11); continue; break; } case 3: { _$$0 = _$$01.h4; _$$1 = _$$11; continue; break; } case 1: return { tag: 1,  h1: _$$01.h1,  h2: _$$11 }; default: return _$$11; } } };
let Lib_CompileJS_getNames_getAltNames = ( _, _1, _2, _3, _4, _$$6, _$$7 ) => { switch (_$$7.tag) { case 2: return Lib_CompileJS_getNames(_$$7.h1, _$$6); case 1: return { tag: 1,  h1: _$$7.h0,  h2: Lib_CompileJS_getNames(_$$7.h2, _$$6) }; case 0: return Lib_CompileJS_getNames(_$$7.h0, _$$6); } };
let Lib_Eval_zonk = ( _$$0, _$$1, _$$2, _$$3 ) => { let env$27 = { tag: 1,  h1: Lib_Types_VVar(Lib_Common_emptyFC, _$$1, { tag: 0 }),  h2: _$$2 }; switch (_$$3.tag) { case 11: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Erased(_$$3.h0)); case 10: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Lit(_$$3.h0, _$$3.h1)); case 9: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (( eta1 ) => (( eta2 ) => (Lib_Types_LetRec(_$$3.h0, _$$3.h1, eta, eta1, eta2)))), Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h2)), Lib_Eval_zonkBind(_$$0, (_$$1) + (1), env$27, _$$3.h3)), Lib_Eval_zonkBind(_$$0, (_$$1) + (1), env$27, _$$3.h4)); case 8: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (( eta1 ) => (Lib_Types_Let(_$$3.h0, _$$3.h1, eta, eta1))), Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h2)), Lib_Eval_zonkBind(_$$0, (_$$1) + (1), env$27, _$$3.h3)); case 7: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h1), ( sc$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Eval_zonkAlt(_$$0, _$$1, _$$2, eta)), _$$3.h2), ( alts$27 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Case(_$$3.h0, sc$27, alts$27)))))); case 6: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (( eta1 ) => (Lib_Types_Pi(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, eta, eta1))), Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h4)), Lib_Eval_zonkBind(_$$0, (_$$1) + (1), env$27, _$$3.h5)); case 5: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_UU(_$$3.h0)); case 4: return Lib_Eval_zonkApp(_$$0, _$$1, _$$2, _$$3, { tag: 0 }); case 3: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_Lam(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, eta)), Lib_Eval_zonk(_$$0, (1) + (_$$1), env$27, _$$3.h4)); case 2: return Lib_Eval_zonkApp(_$$0, _$$1, _$$2, _$$3, { tag: 0 }); case 1: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Ref(_$$3.h0, _$$3.h1)); case 0: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Types_Bnd(_$$3.h0, _$$3.h1)); } };
let Lib_Eval_zonkApp = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { switch (_$$3.tag) { case 4: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h2), ( u$27 ) => (Lib_Eval_zonkApp(_$$0, _$$1, _$$2, _$$3.h1, { tag: 1,  h1: u$27,  h2: _$$4 }))); case 2: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_lookupMeta(_$$3.h1), ( meta ) => (( (meta.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("zonk for ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h1))) + (" env ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$2))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("spine ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Tm, _$$4))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Eval_eval(_$$2, eta)), _$$4), ( sp$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((((("zonk meta ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$3.h1))) + (" -> ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(meta.h2))) + (" spine ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, sp$27))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(meta.h2, Prelude__$3C$3E$3C_({ tag: 0 }, sp$27)), ( foo ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("-> result is ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(foo))) + (""))), ( _3 ) => { let sc$$18 = Prelude_not(Prelude_eqInt(Prelude_length$27(_$$2), _$$1)); switch (sc$$18) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_fatalError(null, (((("MM2 ") + (Prelude_showInt(_$$1))) + (" /= ")) + (Prelude_showInt(Prelude_length$27(_$$2)))) + ("")), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Eval_tweakFC(_$$3.h0, eta)), Lib_Eval_quote(_$$1, foo)), ( res ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("quoted ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(res))) + (""))), ( _5 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(res))))))); case false: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0), ( _4 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Eval_tweakFC(_$$3.h0, eta)), Lib_Eval_quote(_$$1, foo)), ( res ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _5 ) => ((("quoted ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(res))) + (""))), ( _5 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(res))))))); } }))))))))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Eval_appSpine(_$$3, _$$4)) ))); default: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _ ) => ((((("zonk2 for ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(_$$3))) + (" env ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, _$$2))) + (""))), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _1 ) => ((("spine ") + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Tm, _$$4))) + (""))), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3), ( t$27 ) => { let sc$$9 = Lib_Eval_zonkApp_inlineDef(_$$0, _$$1, _$$2, _$$3, _$$4, t$27); return ( (sc$$9.tag) == (0) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_Eval_eval(_$$2, eta)), _$$4), ( sp$27 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_eval(_$$2, sc$$9.h1), ( vtm ) => (Lib_Types_catchError(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((((((((("zonk will app ") + (Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow(t$27))) + (" @ ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Tm, _$$4))) + (" ~> ")) + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(vtm))) + (" @ ")) + (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(Lib_Types_Prelude_Show$20Lib_Types_Val, sp$27))) + (""))), ( _2 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_vappSpine(vtm, Prelude__$3C$3E$3C_({ tag: 0 }, sp$27)), ( res ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _3 ) => ((("result is ") + (Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow(res))) + (""))), ( _3 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_quote(_$$1, res), ( t$271 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_zonk(_$$0, _$$1, _$$2, t$271), ( x ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(x))))))))))), ( err ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_log(2, ( _2 ) => ((("result err ") + (Lib_Error_showError("", err))) + (""))), ( _2 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Eval_appSpine(t$27, _$$4)))))))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Eval_appSpine(t$27, _$$4)) ); }))))); } };
let Lib_Eval_appSpine = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; if ((_$$11.tag) == (1)) { _$$0 = Lib_Types_App(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$01), _$$01, _$$11.h1); _$$1 = _$$11.h2; continue; } else { return _$$01; } } };
let Lib_Eval_zonkApp_inlineDef = ( _, _1, _2, _3, _4, _$$6 ) => { if ((_$$6.tag) == (1)) { let sc$$9 = Lib_TopContext_lookup(_$$6.h1, _); if ((sc$$9.tag) == (0)) { if ((sc$$9.h1.h3.tag) == (3)) { let sc$$18 = Prelude_elem(Lib_Types_Prelude_Eq$20Lib_Types_EFlag, 1, sc$$9.h1.h4); switch (sc$$18) { case true: return Prelude_Just(sc$$9.h1.h3.h0); case false: return Prelude_Nothing(); } } else { return Prelude_Nothing(); } } else { return Prelude_Nothing(); } } else { return Prelude_Nothing(); } };
let Lib_Eval_tweakFC = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 11: return Lib_Types_Erased(_$$0); case 10: return Lib_Types_Lit(_$$0, _$$1.h1); case 9: return Lib_Types_LetRec(_$$0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4); case 8: return Lib_Types_Let(_$$0, _$$1.h1, _$$1.h2, _$$1.h3); case 7: return Lib_Types_Case(_$$0, _$$1.h1, _$$1.h2); case 6: return Lib_Types_Pi(_$$0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4, _$$1.h5); case 5: return Lib_Types_UU(_$$0); case 4: return Lib_Types_App(_$$0, _$$1.h1, _$$1.h2); case 3: return Lib_Types_Lam(_$$0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4); case 2: return Lib_Types_Meta(_$$0, _$$1.h1); case 1: return Lib_Types_Ref(_$$0, _$$1.h1); case 0: return Lib_Types_Bnd(_$$0, _$$1.h1); } };
let Lib_Eval_zonkBind = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Eval_zonk(_$$0, (1) + (_$$1), { tag: 1,  h1: Lib_Types_VVar(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$3), _$$1, { tag: 0 }),  h2: _$$2 }, _$$3));
let Lib_Eval_zonkAlt = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case 2: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseLit(_$$3.h0, eta)), Lib_Eval_zonkBind(_$$0, _$$1, _$$2, _$$3.h1)); case 1: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseCons(_$$3.h0, _$$3.h1, eta)), Lib_Eval_zonkAlt_go(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, _$$1, _$$2, _$$3.h1, _$$3.h2)); case 0: return Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( eta ) => (Lib_Types_CaseDefault(eta)), Lib_Eval_zonkBind(_$$0, _$$1, _$$2, _$$3.h0)); } };
let Lib_Eval_zonkAlt_go = ( _, _1, _2, _3, _4, _5, _6, _$$8, _$$9, _$$10, _$$11 ) => { while (1) { let _7 = _; let _8 = _1; let _9 = _2; let _10 = _3; let _11 = _4; let _12 = _5; let _13 = _6; let _$$81 = _$$8; let _$$91 = _$$9; let _$$101 = _$$10; let _$$111 = _$$11; if ((_$$101.tag) == (1)) { _ = _7; _1 = _8; _2 = _9; _3 = _10; _4 = _11; _5 = _12; _6 = _13; _$$8 = (1) + (_$$81); _$$9 = { tag: 1,  h1: Lib_Types_VVar(Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC(_$$111), _$$81, { tag: 0 }),  h2: _$$91 }; _$$10 = _$$101.h2; _$$11 = _$$111; continue; } else { return Lib_Eval_zonk(_7, _$$81, _$$91, _13); } } };
let Lib_CompileJS_compile_getExports = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let acc; let sc$$13 = Prelude_elem(Lib_Types_Prelude_Eq$20Lib_Types_EFlag, 2, _$$21.h1.h4); switch (sc$$13) { case true: { acc = { tag: 1,  h1: _$$21.h1.h1,  h2: _$$11 }; break; } case false: { acc = _$$11; break; } } _$$1 = acc; _$$2 = _$$21.h2; continue; } else { return _$$11; } } };
let Lib_CompileJS_compile = Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let exports = Lib_CompileJS_compile_getExports({ tag: 0 }, Data_SortedMap_listValues(top.h2.h2)); let mainName = { tag: 0,  h0: top.h2.h0,  h1: "main" }; let main = Lib_TopContext_lookup(mainName, top); let todo = ( (main.tag) == (1) ? exports : { tag: 1,  h1: mainName,  h2: exports } ); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileJS_process(todo), ( defs ) => { let sc$$7 = Lib_TopContext_lookup(mainName, top); if ((sc$$7.tag) == (1)) { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_reverse()(defs)); } else { let exec = Lib_CompileJS_stmtToDoc(Lib_CompileJS_JPlain(Lib_CompileJS_Apply(Lib_CompileJS_Var(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(mainName)), { tag: 0 }))); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_reverse()({ tag: 1,  h1: exec,  h2: defs })); } }); });
let Main_getDoc = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, Lib_TopContext_lookupAll(_$$0, top), ( e ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((((("") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(e.h1))) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, e.h2))), { tag: 0 }))) + (""))))))));
let Lib_TopContext_lookupAll = ( _$$0, _$$1 ) => (Prelude_mapMaybe(( _$$5 ) => (Lib_TopContext_lookup(_$$5, _$$1)), { tag: 1,  h1: { tag: 0,  h0: _$$1.h2.h0,  h1: _$$0 },  h2: Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$5 ) => ({ tag: 0,  h0: _$$5,  h1: _$$0 }), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h2), Data_SortedMap_toList(_$$1.h0))) }));
let Main_browseTop = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let ns = (_$$0.h0) + ((".") + (_$$0.h1)); let sc$$6 = Data_SortedMap_lookupMap$27(ns, top.h0); return ( (sc$$6.tag) == (0) ? Main_browseTop_go(_$$0, _$$0.h0, _$$0.h1, Data_SortedMap_listValues(sc$$6.h1.h2)) : Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("module ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$0))) + (" not loaded"))) ); }));
let Main_browseTop_go = ( _, _1, _2, _$$4 ) => (( (_$$4.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((((((("") + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(_$$4.h1.h0))) + (" ")) + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$4.h1.h1))) + (" : ")) + (Lib_Prettier_layout(Lib_Prettier_best(90, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, _$$4.h1.h2))), { tag: 0 }))) + (""))), ( _3 ) => (Main_browseTop_go(_, _1, _2, _$$4.h2))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ));
let Lib_ReplParser_DumpTop = { tag: 6 };
let Lib_ReplParser_MkCmd = ( h0, h1, h2, h3 ) => ({ tag: 0,  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
let Lib_ReplParser_BrowseCmd = ( h0 ) => ({ tag: 4,  h0: h0 });
let Lib_ReplParser_GetDoc = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_ReplParser_Verbose = ( h0 ) => ({ tag: 2,  h0: h0 });
let Lib_ReplParser_OutputJS = ( h0 ) => ({ tag: 1,  h0: h0 });
let Lib_ReplParser_Load = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_ReplParser_HelpCmd = { tag: 5 };
let Lib_ReplParser_commands = { tag: 1,  h1: Lib_ReplParser_MkCmd(":h", "Show this help", 0, Lib_ReplParser_HelpCmd),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":help", "Show this help", 0, Lib_ReplParser_HelpCmd),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":l", "load file", 1, ( eta ) => (Lib_ReplParser_Load(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":load", "load file", 1, ( eta ) => (Lib_ReplParser_Load(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":o", "write javascript file", 1, ( eta ) => (Lib_ReplParser_OutputJS(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":out", "write javascript file", 1, ( eta ) => (Lib_ReplParser_OutputJS(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":v", "change verbosity", 3, ( eta ) => (Lib_ReplParser_Verbose(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":d", "document function", 2, ( eta ) => (Lib_ReplParser_GetDoc(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":doc", "document function", 2, ( eta ) => (Lib_ReplParser_GetDoc(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":b", "browse namespace", 4, ( eta ) => (Lib_ReplParser_BrowseCmd(eta))),  h2: { tag: 1,  h1: Lib_ReplParser_MkCmd(":top", "dump top context as json", 0, Lib_ReplParser_DumpTop),  h2: { tag: 0 } } } } } } } } } } } };
let Main_replHelp = Prelude_for_(Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, Lib_ReplParser_commands, ( cmd ) => { let args; switch (cmd.h2) { case 4: { args = " Lib.Types"; break; } case 3: { args = " [ 1 ]"; break; } case 2: { args = " map"; break; } case 1: { args = " \"name\""; break; } case 0: { args = ""; break; } } return Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((((((("") + (cmd.h0)) + ("")) + (args)) + (" - ")) + (cmd.h1)) + (""))); });
let Lib_Common_renderJson = ( _$$0 ) => { switch (_$$0.tag) { case 5: return "null"; case 4: return ("[") + ((Prelude_joinBy(",", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Common_renderJson(eta)), _$$0.h0))) + ("]")); case 3: return Prelude_showInt(_$$0.h0); case 2: return Prelude_ite(_$$0.h0, "true", "false"); case 1: return Lib_Common_quoteString(_$$0.h0); case 0: return ("{") + ((Prelude_joinBy(",", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_Common_renderJson_renderPair(_$$0, _$$0.h0, eta)), _$$0.h0))) + ("}")); } };
let Lib_Common_renderJson_renderPair = ( _, _1, _$$3 ) => ((Lib_Common_quoteString(_$$3.h2)) + ((":") + (Lib_Common_renderJson(_$$3.h3))));
let Main_jsonTopContext_jsonDef = ( _$$1 ) => (Lib_Common_JsonObj({ tag: 1,  h1: { tag: 0,  h2: "fc",  h3: Lib_Common_Lib_Common_ToJSON$20Lib_Common_FC$2CtoJson(_$$1.h0) },  h2: { tag: 1,  h1: { tag: 0,  h2: "name",  h3: Lib_Common_JsonStr(_$$1.h1.h1) },  h2: { tag: 1,  h1: { tag: 0,  h2: "type",  h3: Lib_Common_JsonStr(Lib_Prettier_layout(Lib_Prettier_best(80, 0, Lib_Prettier_noAlt(Lib_Types_pprint$27(0, { tag: 0 }, _$$1.h2))), { tag: 0 })) },  h2: { tag: 0 } } } }));
let Lib_Common_JsonStr = ( h0 ) => ({ tag: 1,  h0: h0 });
let Lib_Common_Lib_Common_ToJSON$20Lib_Common_FC$2CtoJson = ( _$$0 ) => (Lib_Common_JsonObj({ tag: 1,  h1: { tag: 0,  h2: "file",  h3: Lib_Common_JsonStr(_$$0.h0) },  h2: { tag: 1,  h1: { tag: 0,  h2: "line",  h3: Lib_Common_JsonInt(_$$0.h1.h0) },  h2: { tag: 1,  h1: { tag: 0,  h2: "col",  h3: Lib_Common_JsonInt(_$$0.h1.h1) },  h2: { tag: 1,  h1: { tag: 0,  h2: "endline",  h3: Lib_Common_JsonInt(_$$0.h1.h2) },  h2: { tag: 1,  h1: { tag: 0,  h2: "endcol",  h3: Lib_Common_JsonInt(_$$0.h1.h3) },  h2: { tag: 0 } } } } } }));
let Lib_Common_JsonInt = ( h0 ) => ({ tag: 3,  h0: h0 });
let Lib_Common_JsonObj = ( h0 ) => ({ tag: 0,  h0: h0 });
let Lib_Common_JsonArray = ( h0 ) => ({ tag: 4,  h0: h0 });
let Main_jsonTopContext = Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let defs = Prelude_Prelude_Monad$20Prelude_List$2Cbind(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( mod ) => (Data_SortedMap_listValues(mod.h2)), Data_SortedMap_listValues(top.h0)), ( _$$1 ) => (_$$1)); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Lib_Common_JsonObj({ tag: 1,  h1: { tag: 0,  h2: "context",  h3: Lib_Common_JsonArray(Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Main_jsonTopContext_jsonDef(eta)), defs)) },  h2: { tag: 0 } })); });
let Lib_ReplParser_replString = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(11)), ( _ ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(6)), ( s ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(12)), ( _1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(s)))))));
let Lib_ReplParser_replInt = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(4)), ( t ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(Prelude_stringToInt(t))));
let Lib_ReplParser_replQN = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_uident, ( $$sc ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_Impl_many(Lib_Parser_Impl_indented(Lib_Parser_Impl_token$27(10))), ( rest ) => { let name = Prelude_joinBy("", { tag: 1,  h1: $$sc,  h2: rest }); let sc$$4 = Data_List1_unsnoc(Data_List1_splitBy1(name, ".")); return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn({ tag: 0,  h0: Prelude_joinBy(".", sc$$4.h2),  h1: sc$$4.h3 }); })));
let Lib_ReplParser_parseCommand_lookup = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let sc$$10 = Prelude_eqString(_$$11, _$$21.h1.h0); switch (sc$$10) { case true: return Prelude_Just(_$$21.h1); case false: { _$$1 = _$$11; _$$2 = _$$21.h2; continue; break; } } } else { return Prelude_Nothing(); } } };
let Lib_ReplParser_parseCommand = Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(Lib_Parser_ident, ( key ) => { let sc$$2 = Lib_ReplParser_parseCommand_lookup(key, Lib_ReplParser_commands); if ((sc$$2.tag) == (0)) { switch (sc$$2.h1.h2) { case 4: return Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(sc$$2.h1.h3, Lib_ReplParser_replQN); case 3: return Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(sc$$2.h1.h3, Lib_Parser_optional(Lib_ReplParser_replInt)); case 2: return Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(sc$$2.h1.h3, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(Lib_Parser_ident, Lib_Parser_uident)); case 1: return Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(sc$$2.h1.h3, Lib_ReplParser_replString); case 0: return Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(sc$$2.h1.h3); } } else { return Lib_Parser_Impl_fail("Unknown command"); } });
let Lib_Parser_Impl_parse = ( _$$1, _$$2, _$$3 ) => { let sc$$4 = Lib_Parser_Impl_runP(_$$2)(Lib_Common_emptyBounds)(_$$3)(false)(Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))))({ tag: 0,  h0: _$$1,  h1: Lib_Common_MkBounds(-1, -1, -1, -1) }); return ( (sc$$4.tag) == (1) ? Prelude_Left(sc$$4.h1) : ( (sc$$4.h3.tag) == (0) ? Prelude_Right(sc$$4.h1) : Prelude_Left(Lib_Parser_Impl_perror(_$$1, sc$$4.h3, "Extra toks")) ) ); };
let Node_readLine = (w) => {
    let {readSync} = fs;
    let buf = new Uint8Array(1024);
    let p = 0
    while (readSync(0, buf, p, 1, null)) {
        if (buf[p++] == 10) return Prelude_MkIORes(Prelude_Right(new TextDecoder().decode(buf.slice(0,p))),w);
        if (p + 10 > buf.length) {
            let tmp = new Uint8Array(buf.length * 1.5);
            tmp.set(buf);
            buf = tmp;
        }
    }
    return Prelude_MkIORes(Prelude_Left("EOF"));
};
let Node_putStr = (s) => (w) => {
  let {writeSync} = fs;
  let buf = new TextEncoder().encode(s);
  writeSync(1, buf);
  return Prelude_MkIORes(Prelude_MkUnit, w);
};
let Main_runRepl = Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Node_putStr("> ")), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Node_readLine), ( $$sc ) => (( ($$sc.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_runString($$sc.h2), ( _1 ) => (Main_runRepl)) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) )))));
let Revision_gitRevision = "cb394d3";
let Main_replHeader = Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("Newt REPL (") + (Revision_gitRevision)) + (")\n")));
let Prelude_isSuffixOf = (pfx, s) => s.endsWith(pfx) ? Prelude_True : Prelude_False;
let Main_writeScheme = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileScheme_compileScheme, ( $$sc ) => { let src = Prelude_joinBy("\n", $$sc); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Node_writeFile(_$$0, src)), ( $$sc1 ) => (( ($$sc1.tag) == (1) ? Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) : Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E({ tag: 0,  h0: _$$0,  h1: Lib_Common_MkBounds(0, 0, 0, 0) }, $$sc1.h2)), eta)))) ))); }));
let Lib_CompileScheme_process = ( _$$0 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_CompileScheme_getEntries(eta, eta1))), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), _$$0), ( entries ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primNewIORef(null, entries)), ( ref ) => { let foo = Lib_Ref2_MkRef(ref); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileScheme_eraseEntries(Lib_Ref2_MkRef(ref)), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_LiftWhere_liftWhere(Lib_Ref2_MkRef(ref)), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, ref)), ( entries1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_mapM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (Lib_CompileExp_defToCExp(Lib_Ref2_MkRef(ref), eta)), Data_SortedMap_toList(entries1)), ( exprs ) => { let cexpMap = Data_SortedMap_foldMap(( _$$2 ) => (( _$$3 ) => (_$$2)), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), exprs); let names = Lib_CompileScheme_sortedNames(cexpMap, _$$0); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_mapMaybe(( eta ) => (Lib_CompileScheme_process_go(_$$0, cexpMap, eta)), names)); }))))))); }))))));
let Lib_CompileScheme_process_go = ( _, _$$2, _$$3 ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(Data_SortedMap_lookupMap(_$$3, _$$2), ( $$sc ) => (( ($$sc.h3.tag) == (15) ? Prelude_Nothing() : Prelude_Just((((("(define ") + (Lib_CompileScheme_scmIdent(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow($$sc.h2)))) + (" ")) + (Lib_CompileScheme_cexpToScm({ tag: 0 }, $$sc.h3))) + (")")) ))));
let Lib_CompileScheme_cexpToScm = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case 16: return (((((("(") + (_$$1.h0)) + (" ")) + (Lib_CompileScheme_cexpToScm(_$$0, _$$1.h1))) + (" ")) + (Lib_CompileScheme_cexpToScm(_$$0, _$$1.h2))) + (")"); case 15: return Prelude_fatalError(null, "Stray CRaw"); case 14: switch (_$$1.h4) { case 7: { let sc$$7 = Lib_CompileScheme_argsToScm(_$$0, _$$1.h2, _$$1.h3); return ( (sc$$7.tag) == (1) ? ( (sc$$7.h2.tag) == (1) ? ( (sc$$7.h2.h2.tag) == (0) ? (((("(cons ") + (sc$$7.h1)) + (" ")) + (sc$$7.h2.h1)) + (")") : Prelude_fatalError(null, "Wrong number of args on a ConsCon") ) : Prelude_fatalError(null, "Wrong number of args on a ConsCon") ) : Prelude_fatalError(null, "Wrong number of args on a ConsCon") ); break; } case 6: return "'()"; default: return (((("(vector ") + (Prelude_showInt(Prelude_natToInt(_$$1.h0)))) + (" ")) + (Prelude_joinBy(" ", Lib_CompileScheme_argsToScm(_$$0, _$$1.h2, _$$1.h3)))) + (")"); } break; case 13: return "#f"; case 12: return Prelude_fatalError(null, "CLoop in scheme codegen"); case 11: return Prelude_fatalError(null, "CLetLoop in scheme codegen"); case 10: { let sc$$5 = Lib_CompileScheme_scbind(_$$1.h0, _$$0); return (((((("(let ((") + (sc$$5.h2)) + (" ")) + (Lib_CompileScheme_cexpToScm(sc$$5.h3, _$$1.h1))) + (")) ")) + (Lib_CompileScheme_cexpToScm(sc$$5.h3, _$$1.h2))) + (")"); break; } case 9: { let sc$$5 = Lib_CompileScheme_scbind(_$$1.h0, _$$0); return (((((("(let ((") + (sc$$5.h2)) + (" ")) + (Lib_CompileScheme_cexpToScm(_$$0, _$$1.h1))) + (")) ")) + (Lib_CompileScheme_cexpToScm(sc$$5.h3, _$$1.h2))) + (")"); break; } case 8: return Lib_CompileScheme_scmLit(_$$1.h0); case 7: return Prelude_fatalError(null, "meta in code gen"); case 6: return Lib_CompileScheme_scmIdent(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h0)); case 5: return Lib_CompileScheme_withVar(_$$0, _$$1.h0, ( nm ) => (Lib_CompileScheme_cexpToScm_doCase(_$$0, _$$1, _$$1.h0, _$$1.h1, nm, _$$1.h1))); case 4: return (((("(") + (Lib_CompileScheme_cexpToScm(_$$0, _$$1.h0))) + (" ")) + (Lib_CompileScheme_cexpToScm(_$$0, _$$1.h1))) + (")"); case 3: return ( (_$$1.h2.tag) == (0) ? Lib_CompileScheme_cexpToScm_go(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h2.h0, Lib_CompileScheme_scmIdent(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h0)), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_cexpToScm(_$$0, eta)), _$$1.h1)) : Lib_CompileScheme_cexpToScm_go$27(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$0, (("(") + (Lib_CompileScheme_scmIdent(Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1.h0)))) + (""), Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_cexpToScm(_$$0, eta)), _$$1.h1), _$$1.h2) ); case 2: { let sc$$5 = Lib_CompileScheme_cexpToScm_bindAll(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h0, { tag: 0 }, _$$0); return (((("(lambda (") + (Prelude_joinBy(" ", sc$$5.h2))) + (") ")) + (Lib_CompileScheme_cexpToScm(sc$$5.h3, _$$1.h1))) + (")"); break; } case 1: { let sc$$4 = Lib_CompileScheme_scbind(_$$1.h0, _$$0); return (((("(lambda (") + (sc$$4.h2)) + (") ")) + (Lib_CompileScheme_cexpToScm(sc$$4.h3, _$$1.h1))) + (")"); break; } case 0: return Lib_CompileScheme_getEnv(_$$1.h0, _$$0); } };
let Lib_CompileScheme_getEnv = ( _$$0, _$$1 ) => { let sc$$2 = Prelude_getAt(Prelude_intToNat(_$$0), _$$1); return ( (sc$$2.tag) == (1) ? Prelude_fatalError(null, (("Bad bounds ") + (Prelude_showInt(_$$0))) + ("")) : sc$$2.h1 ); };
let Lib_CompileScheme_scbind = ( _$$0, _$$1 ) => { let x = Prelude_length$27(_$$1); let nm$27 = (("nm-") + (Prelude_showInt(x))) + (""); return { tag: 0,  h2: nm$27,  h3: { tag: 1,  h1: nm$27,  h2: _$$1 } }; };
let Lib_CompileScheme_cexpToScm_bindAll = ( _, _1, _2, _3, _$$5, _$$6, _$$7 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$51 = _$$5; let _$$61 = _$$6; let _$$71 = _$$7; if ((_$$51.tag) == (1)) { switch (_$$51.h1.h2) { case true: { let sc$$15 = Lib_CompileScheme_scbind(_$$51.h1.h3, _$$71); _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = _$$51.h2; _$$6 = { tag: 1,  h1: _$$61,  h2: sc$$15.h2 }; _$$7 = sc$$15.h3; continue; break; } case false: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = _$$51.h2; _$$6 = _$$61; _$$7 = { tag: 1,  h1: "#f",  h2: _$$71 }; continue; break; } } } else { return { tag: 0,  h2: Prelude__$3C$3E$3E_(_$$61, { tag: 0 }),  h3: _$$71 }; } } };
let Lib_CompileScheme_scmIdent = ( _$$0 ) => { let sc$$2 = Prelude_elem(Prelude_Prelude_Eq$20Prim_String, _$$0, Lib_CompileScheme_scmKeywords); switch (sc$$2) { case true: return ("$") + (_$$0); case false: return Prelude_pack(Lib_CompileScheme_scmIdent_fix(_$$0, Prelude_unpack(_$$0))); } };
let Lib_CompileScheme_scmIdent_fix = ( _, _$$2 ) => { if ((_$$2.tag) == (1)) { let sc$$6 = (Prelude_isAlphaNum(_$$2.h1)) || ((Prelude_eqChar(_$$2.h1, "_")) || (Prelude_eqChar(_$$2.h1, "."))); switch (sc$$6) { case true: return { tag: 1,  h1: _$$2.h1,  h2: Lib_CompileScheme_scmIdent_fix(_, _$$2.h2) }; case false: { let sc$$7 = Prelude_eqChar(_$$2.h1, ","); switch (sc$$7) { case true: return { tag: 1,  h1: "_",  h2: Lib_CompileScheme_scmIdent_fix(_, _$$2.h2) }; case false: { let sc$$8 = Prelude_eqChar(_$$2.h1, " "); switch (sc$$8) { case true: return { tag: 1,  h1: "_",  h2: Lib_CompileScheme_scmIdent_fix(_, _$$2.h2) }; case false: { let sc$$9 = Prelude_eqChar(_$$2.h1, "$"); switch (sc$$9) { case true: return { tag: 1,  h1: "$",  h2: { tag: 1,  h1: "$",  h2: Lib_CompileScheme_scmIdent_fix(_, _$$2.h2) } }; case false: return { tag: 1,  h1: "$",  h2: Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(Lib_Common_toHex(Prelude_ord(_$$2.h1)), Lib_CompileScheme_scmIdent_fix(_, _$$2.h2)) }; } break; } } break; } } break; } } } else { return { tag: 0 }; } };
let Lib_CompileScheme_scmKeywords = { tag: 1,  h1: "lambda",  h2: { tag: 0 } };
let Lib_CompileScheme_cexpToScm_go$27 = ( _, _1, _2, _3, _4, _$$6, _$$7, _$$8, _$$9 ) => { while (1) { let _5 = _; let _6 = _1; let _7 = _2; let _8 = _3; let _9 = _4; let _$$61 = _$$6; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; if ((_$$91.tag) == (1)) { if ((_$$81.tag) == (1)) { switch (_$$91.h1) { case true: { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$6 = _$$61; _$$7 = (((("") + (_$$71)) + (" ")) + (_$$81.h1)) + (""); _$$8 = _$$81.h2; _$$9 = _$$91.h2; continue; break; } case false: { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$6 = _$$61; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = _$$91.h2; continue; break; } } } else { let sc$$14 = Lib_CompileScheme_scbind("_", _$$61); let acc = (((("") + (_$$71)) + (" ")) + (sc$$14.h2)) + (""); return (((("(lambda (") + (sc$$14.h2)) + (") ")) + (Lib_CompileScheme_cexpToScm_go$27(_5, _6, _7, _8, _9, sc$$14.h3, acc, { tag: 0 }, _$$91.h2))) + (")"); } } else { if ((_$$81.tag) == (1)) { _ = _5; _1 = _6; _2 = _7; _3 = _8; _4 = _9; _$$6 = _$$61; _$$7 = (((("(") + (_$$71)) + (") ")) + (_$$81.h1)) + (""); _$$8 = _$$81.h2; _$$9 = { tag: 0 }; continue; } else { return (_$$71) + (")"); } } } };
let Lib_CompileScheme_cexpToScm_go = ( _, _1, _2, _3, _4, _5, _$$7, _$$8 ) => { while (1) { let _6 = _; let _7 = _1; let _8 = _2; let _9 = _3; let _10 = _4; let _11 = _5; let _$$71 = _$$7; let _$$81 = _$$8; if ((_$$81.tag) == (1)) { _ = _6; _1 = _7; _2 = _8; _3 = _9; _4 = _10; _5 = _11; _$$7 = (((("(") + (_$$71)) + (" ")) + (_$$81.h1)) + (")"); _$$8 = _$$81.h2; continue; } else { return _$$71; } } };
let Lib_CompileScheme_cexpToScm_doCase = ( _, _1, _2, _3, _$$10, _$$11 ) => { if ((_$$11.tag) == (1)) { switch (_$$11.h1.tag) { case 2: return ( (_$$11.h2.tag) == (0) ? Lib_CompileScheme_cexpToScm(_, _$$11.h1.h1) : (((("(case ") + (_$$10)) + (" ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_cexpToScm_doAlt(_, _1, _2, _3, _$$10, eta)), _$$11)))) + (")") ); case 1: return ( (_$$11.h2.tag) == (0) ? Lib_CompileScheme_cexpToScm(_, _$$11.h1.h0) : (((("(case (vector-ref ") + (Lib_CompileScheme_cexpToScm(_, _2))) + (" 0) ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_cexpToScm_doAlt(_, _1, _2, _3, _$$10, eta)), _$$11)))) + (")") ); case 0: switch (_$$11.h1.h2) { case 7: { let consBranch = Lib_CompileScheme_cexpToScm_consAlt(_, _1, _2, _3, _, _$$10, _$$11.h1.h4, _$$11.h1.h5); if ((_$$11.h2.tag) == (1)) { switch (_$$11.h2.h1.tag) { case 2: return Prelude_fatalError(null, "lit alt after cons"); case 1: return ( (_$$11.h2.h2.tag) == (0) ? (((((("(if (null? ") + (_$$10)) + (") ")) + (Lib_CompileScheme_cexpToScm(_, _$$11.h2.h1.h0))) + (" ")) + (consBranch)) + (")") : Prelude_fatalError(null, "too many alts after cons") ); case 0: switch (_$$11.h2.h1.h2) { case 6: return (((((("(if (null? ") + (_$$10)) + (") ")) + (Lib_CompileScheme_cexpToScm_nilAlt(_, _1, _2, _3, _, _$$11.h2.h1.h4, _$$11.h2.h1.h5))) + (" ")) + (consBranch)) + (")"); default: return Prelude_fatalError(null, (("") + (Lib_Types_Prelude_Show$20Lib_Types_ConInfo$2Cshow(_$$11.h2.h1.h2))) + (" alt after cons")); } break; } } else { return consBranch; } break; } case 6: { let nilBranch = Lib_CompileScheme_cexpToScm_consAlt(_, _1, _2, _3, _, _$$10, _$$11.h1.h4, _$$11.h1.h5); if ((_$$11.h2.tag) == (1)) { switch (_$$11.h2.h1.tag) { case 2: return Prelude_fatalError(null, "lit alt after nil"); case 1: return ( (_$$11.h2.h2.tag) == (0) ? (((((("(if (null? ") + (_$$10)) + (") ")) + (nilBranch)) + (" ")) + (Lib_CompileScheme_cexpToScm(_, _$$11.h2.h1.h0))) + (")") : Prelude_fatalError(null, "too many alts after cons") ); case 0: switch (_$$11.h2.h1.h2) { case 7: return (((((("(if (null? ") + (_$$10)) + (") ")) + (nilBranch)) + (" ")) + (Lib_CompileScheme_cexpToScm_consAlt(_, _1, _2, _3, _, _$$10, _$$11.h2.h1.h4, _$$11.h2.h1.h5))) + (")"); default: return Prelude_fatalError(null, (("") + (Lib_Types_Prelude_Show$20Lib_Types_ConInfo$2Cshow(_$$11.h2.h1.h2))) + (" alt after nil")); } break; } } else { return nilBranch; } break; } default: return ( (_$$11.h2.tag) == (0) ? Lib_CompileScheme_cexpToScm_conAlt(_, _1, _2, _3, _, _$$10, 1, _$$11.h1.h3, _$$11.h1.h4, _$$11.h1.h5) : (((("(case (vector-ref ") + (Lib_CompileScheme_cexpToScm(_, _2))) + (" 0) ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_cexpToScm_doAlt(_, _1, _2, _3, _$$10, eta)), _$$11)))) + (")") ); } break; } } else { return (((("(case (vector-ref ") + (Lib_CompileScheme_cexpToScm(_, _2))) + (" 0) ")) + (Prelude_joinBy(" ", Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_cexpToScm_doAlt(_, _1, _2, _3, _$$10, eta)), _$$11)))) + (")"); } };
let Lib_CompileScheme_cexpToScm_doAlt = ( _, _1, _2, _3, _$$9, _$$10 ) => { switch (_$$10.tag) { case 2: return (((("((") + (Lib_CompileScheme_scmLit(_$$10.h0))) + (") ")) + (Lib_CompileScheme_cexpToScm(_, _$$10.h1))) + (")"); case 1: return (("(else ") + (Lib_CompileScheme_cexpToScm(_, _$$10.h0))) + (")"); case 0: return (((("((") + (Prelude_showInt(Prelude_natToInt(_$$10.h0)))) + (") ")) + (Lib_CompileScheme_cexpToScm_conAlt(_, _1, _2, _3, _, _$$9, 1, _$$10.h3, _$$10.h4, _$$10.h5))) + (")"); } };
let Lib_CompileScheme_cexpToScm_conAlt = ( _, _1, _2, _3, _$$5, _$$6, _$$7, _$$8, _$$9, _$$10 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$51 = _$$5; let _$$61 = _$$6; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; let _$$101 = _$$10; if ((_$$91.tag) == (1)) { switch (_$$91.h1) { case true: { if ((_$$81.tag) == (1)) { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = { tag: 1,  h1: (((("(vector-ref ") + (_$$61)) + (" ")) + (Prelude_showInt(_$$71))) + (")"),  h2: _$$51 }; _$$6 = _$$61; _$$7 = (_$$71) + (1); _$$8 = _$$81.h2; _$$9 = _$$91.h2; _$$10 = _$$101; continue; } else { return Prelude_fatalError(null, "arg/qs mismatch in conAlt"); } break; } case false: { if ((_$$81.tag) == (1)) { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$5 = { tag: 1,  h1: "#f",  h2: _$$51 }; _$$6 = _$$61; _$$7 = _$$71; _$$8 = _$$81.h2; _$$9 = _$$91.h2; _$$10 = _$$101; continue; } else { return Prelude_fatalError(null, "arg/qs mismatch in conAlt"); } break; } } } else { return ( (_$$81.tag) == (0) ? Lib_CompileScheme_cexpToScm(_$$51, _$$101) : Prelude_fatalError(null, "arg/qs mismatch in conAlt") ); } } };
let Lib_CompileScheme_scmLit = ( _$$0 ) => { switch (_$$0.tag) { case 3: return Prelude_ite(_$$0.h0, "#t", "#f"); case 2: return Prelude_pack({ tag: 1,  h1: "#",  h2: { tag: 1,  h1: "\\",  h2: { tag: 1,  h1: _$$0.h0,  h2: { tag: 0 } } } }); case 1: return Prelude_showInt(_$$0.h0); case 0: return Lib_Common_quoteString(_$$0.h0); } };
let Lib_CompileScheme_cexpToScm_consAlt = ( _, _1, _2, _3, _$$8, _$$9, _$$10, _$$11 ) => (Lib_CompileScheme_cexpToScm_consAlt$27(_, _1, _2, _3, _$$8, { tag: 1,  h1: (("(car ") + (_$$9)) + (")"),  h2: { tag: 1,  h1: (("(cdr ") + (_$$9)) + (")"),  h2: { tag: 0 } } }, _$$10, _$$11));
let Lib_CompileScheme_cexpToScm_consAlt$27 = ( _, _1, _2, _3, _$$7, _$$8, _$$9, _$$10 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$71 = _$$7; let _$$81 = _$$8; let _$$91 = _$$9; let _$$101 = _$$10; if ((_$$91.tag) == (1)) { switch (_$$91.h1) { case true: { if ((_$$81.tag) == (1)) { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$7 = { tag: 1,  h1: _$$81.h1,  h2: _$$71 }; _$$8 = _$$81.h2; _$$9 = _$$91.h2; _$$10 = _$$101; continue; } else { return Prelude_fatalError(null, "Too many fields on cons constructor"); } break; } case false: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$7 = { tag: 1,  h1: "#f",  h2: _$$71 }; _$$8 = _$$81; _$$9 = _$$91.h2; _$$10 = _$$101; continue; break; } } } else { return Lib_CompileScheme_cexpToScm(_$$71, _$$101); } } };
let Lib_CompileScheme_cexpToScm_nilAlt = ( _, _1, _2, _3, _$$6, _$$7, _$$8 ) => { while (1) { let _4 = _; let _5 = _1; let _6 = _2; let _7 = _3; let _$$61 = _$$6; let _$$71 = _$$7; let _$$81 = _$$8; if ((_$$71.tag) == (1)) { switch (_$$71.h1) { case true: return Prelude_fatalError(null, "Non-empty field on nil constructor"); case false: { _ = _4; _1 = _5; _2 = _6; _3 = _7; _$$6 = { tag: 1,  h1: "#f",  h2: _$$61 }; _$$7 = _$$71.h2; _$$8 = _$$81; continue; break; } } } else { return Lib_CompileScheme_cexpToScm(_$$61, _$$81); } } };
let Lib_CompileScheme_withVar = ( _$$0, _$$1, _$$2 ) => { if ((_$$1.tag) == (0)) { return _$$2(Lib_CompileScheme_getEnv(_$$1.h0, _$$0)); } else { let nm = (("wv$") + (Prelude_showInt(Prelude_length$27(_$$0)))) + (""); return (((((("(let ((") + (nm)) + (" ")) + (Lib_CompileScheme_cexpToScm(_$$0, _$$1))) + (")) ")) + (_$$2(nm))) + (")"); } };
let Lib_CompileScheme_argsToScm = ( _$$0, _$$1, _$$2 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { switch (_$$21.h1) { case true: return ( (_$$11.tag) == (1) ? { tag: 1,  h1: Lib_CompileScheme_cexpToScm(_$$01, _$$11.h1),  h2: Lib_CompileScheme_argsToScm(_$$01, _$$11.h2, _$$21.h2) } : Prelude_fatalError(null, "Arg count mismatch") ); case false: { if ((_$$11.tag) == (1)) { _$$0 = _$$01; _$$1 = _$$11.h2; _$$2 = _$$21.h2; continue; } else { return Prelude_fatalError(null, "Arg count mismatch"); } break; } } } else { return ( (_$$11.tag) == (0) ? { tag: 0 } : Prelude_fatalError(null, "Arg count mismatch") ); } } };
let Lib_CompileScheme_sortedNames = ( _$$0, _$$1 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(( _$$2 ) => (_$$2.h3), Prelude_filter(( _$$5 ) => (Prelude_not(_$$5.h2)), Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_go(_$$0, _$$1, { tag: 0 }, eta, eta1))), { tag: 0 }, Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Prelude__$2C_(true, eta)), _$$1)))));
let Lib_CompileScheme_sortedNames_go = ( _, _1, _$$5, _$$6, _$$7 ) => { let acc; let sc$$12 = (_$$7.h2) && ((Prelude_not(Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), { tag: 0,  h2: false,  h3: _$$7.h3 }, _$$6))) && (Prelude_not(Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), { tag: 0,  h2: false,  h3: _$$7.h3 }, _$$5)))); switch (sc$$12) { case true: { acc = Lib_CompileScheme_sortedNames_go(_, _1, _$$5, _$$6, { tag: 0,  h2: false,  h3: _$$7.h3 }); break; } case false: { acc = _$$6; break; } } let sc$$13 = Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), _$$7, _$$5); switch (sc$$13) { case true: return acc; case false: { let sc$$14 = Prelude_elem(Prelude_Prelude_Eq$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(Prelude_Prelude_Eq$20Prelude_Bool, Lib_Common_Prelude_Eq$20Lib_Common_QName), _$$7, acc); switch (sc$$14) { case true: return acc; case false: { let sc$$15 = Data_SortedMap_lookupMap$27(_$$7.h3, _); return ( (sc$$15.tag) == (1) ? acc : { tag: 1,  h1: _$$7,  h2: Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_go(_, _1, { tag: 1,  h1: _$$7,  h2: _$$5 }, eta, eta1))), acc, Lib_CompileScheme_sortedNames_getNames(_, _1, _$$7.h2, { tag: 0 }, sc$$15.h1)) } ); break; } } break; } } };
let Lib_CompileScheme_sortedNames_getNames = ( _, _1, deep$$4, _$$5, _$$6 ) => { while (1) { let _2 = _; let _3 = _1; let deep$$41 = deep$$4; let _$$51 = _$$5; let _$$61 = _$$6; switch (_$$61.tag) { case 16: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h2; continue; break; } case 15: return _$$51; case 14: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, eta, eta1))), _$$51, _$$61.h2); case 13: return _$$51; case 12: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_getNames(_2, _3, true, eta, eta1))), _$$51, _$$61.h0); case 11: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = _$$51; _$$6 = _$$61.h1; continue; break; } case 10: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h2; continue; break; } case 9: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h2; continue; break; } case 8: return _$$51; case 7: return _$$51; case 6: return { tag: 1,  h1: { tag: 0,  h2: deep$$41,  h3: _$$61.h0 },  h2: _$$51 }; case 5: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, eta, eta1))), _$$51, { tag: 1,  h1: _$$61.h0,  h2: Prelude_Prelude_Functor$20Prelude_List$2Cmap(( eta ) => (Lib_CompileScheme_sortedNames_getBody(_2, _3, eta)), _$$61.h1) }); case 4: { _ = _2; _1 = _3; deep$$4 = true; _$$5 = Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, _$$51, _$$61.h1); _$$6 = _$$61.h0; continue; break; } case 3: { let sc$$10 = Prelude_eqInt(Prelude_length$27(_$$61.h1), Prelude_length$27(_$$61.h2)); switch (sc$$10) { case true: return ( (_$$61.h1.tag) == (0) ? { tag: 1,  h1: { tag: 0,  h2: true,  h3: _$$61.h0 },  h2: _$$51 } : Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_getNames(_2, _3, true, eta, eta1))), { tag: 1,  h1: { tag: 0,  h2: true,  h3: _$$61.h0 },  h2: _$$51 }, _$$61.h1) ); case false: return Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_sortedNames_getNames(_2, _3, deep$$41, eta, eta1))), { tag: 1,  h1: { tag: 0,  h2: deep$$41,  h3: _$$61.h0 },  h2: _$$51 }, _$$61.h1); } break; } case 2: switch (deep$$41) { case true: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = _$$51; _$$6 = _$$61.h1; continue; break; } case false: return _$$51; } break; case 1: { _ = _2; _1 = _3; deep$$4 = deep$$41; _$$5 = _$$51; _$$6 = _$$61.h1; continue; break; } case 0: return _$$51; } } };
let Lib_CompileScheme_sortedNames_getBody = ( _, _1, _$$3 ) => { switch (_$$3.tag) { case 2: return _$$3.h1; case 1: return _$$3.h0; case 0: return _$$3.h5; } };
let Lib_CompileScheme_eraseEntries_go = ( _$$1, _$$2 ) => (( (_$$2.h3.tag) == (3) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Erasure_erase({ tag: 0 }, _$$2.h3.h0, { tag: 0 }), ( tm$27 ) => (Lib_Ref2_modifyRef(Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$1, ( eta ) => (Data_SortedMap_updateMap(_$$2.h2, Lib_Types_Fn(tm$27), eta))))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0) ));
let Lib_CompileScheme_eraseEntries = ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Data_IORef_primReadIORef(null, _.h2)), ( defs ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(( _$$3 ) => (0), Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Lib_CompileScheme_eraseEntries_go(_, eta)), Data_SortedMap_toList(defs))))));
let Lib_CompileScheme_getEntries = ( _$$0, _$$1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let sc$$3 = Lib_TopContext_lookup(_$$1, top); if ((sc$$3.tag) == (1)) { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("bad name ") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(_$$1))) + (""))), ( _ ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0))); } else { switch (sc$$3.h1.h3.tag) { case 5: { let acc = Data_SortedMap_updateMap(sc$$3.h1.h1, sc$$3.h1.h3, _$$0); return Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_CompileScheme_getEntries(eta, eta1))), acc, sc$$3.h1.h3.h2); break; } case 3: { let sc$$12 = Data_SortedMap_lookupMap$27(sc$$3.h1.h1, _$$0); return ( (sc$$12.tag) == (1) ? Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Eval_zonk(top1, 0, { tag: 0 }, sc$$3.h1.h3.h0), ( exp ) => { let acc = Data_SortedMap_updateMap(sc$$3.h1.h1, Lib_Types_Fn(exp), _$$0); return Prelude_foldlM(Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_CompileScheme_getEntries(eta, eta1))), acc, Lib_CompileScheme_getNames(exp, { tag: 0 })); }))) : Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(_$$0) ); break; } default: return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Data_SortedMap_updateMap(_$$1, sc$$3.h1.h3, _$$0)); } } }));
let Lib_CompileScheme_getNames = ( _$$0, _$$1 ) => { while (1) { let _$$01 = _$$0; let _$$11 = _$$1; switch (_$$01.tag) { case 9: { _$$0 = _$$01.h4; _$$1 = Lib_CompileScheme_getNames(_$$01.h3, _$$11); continue; break; } case 8: { _$$0 = _$$01.h3; _$$1 = Lib_CompileScheme_getNames(_$$01.h2, _$$11); continue; break; } case 7: { _$$0 = _$$01.h1; _$$1 = Prelude_Prelude_Foldable$20Prelude_List$2Cfoldl(( eta ) => (( eta1 ) => (Lib_CompileScheme_getNames_getAltNames(_$$01, _$$11, _$$01.h0, _$$01.h1, _$$01.h2, eta, eta1))), _$$11, _$$01.h2); continue; break; } case 6: { _$$0 = _$$01.h5; _$$1 = Lib_CompileScheme_getNames(_$$01.h4, { tag: 1,  h1: { tag: 0,  h0: Lib_Common_primNS,  h1: "PiType" },  h2: _$$11 }); continue; break; } case 4: { _$$0 = _$$01.h2; _$$1 = Lib_CompileScheme_getNames(_$$01.h1, _$$11); continue; break; } case 3: { _$$0 = _$$01.h4; _$$1 = _$$11; continue; break; } case 1: return { tag: 1,  h1: _$$01.h1,  h2: _$$11 }; default: return _$$11; } } };
let Lib_CompileScheme_getNames_getAltNames = ( _, _1, _2, _3, _4, _$$6, _$$7 ) => { switch (_$$7.tag) { case 2: return Lib_CompileScheme_getNames(_$$7.h1, _$$6); case 1: return { tag: 1,  h1: _$$7.h0,  h2: Lib_CompileScheme_getNames(_$$7.h2, _$$6) }; case 0: return Lib_CompileScheme_getNames(_$$7.h0, _$$6); } };
let Lib_CompileScheme_compileScheme_getExports = ( _$$1, _$$2 ) => { while (1) { let _$$11 = _$$1; let _$$21 = _$$2; if ((_$$21.tag) == (1)) { let acc; let sc$$13 = Prelude_elem(Lib_Types_Prelude_Eq$20Lib_Types_EFlag, 2, _$$21.h1.h4); switch (sc$$13) { case true: { acc = { tag: 1,  h1: _$$21.h1.h1,  h2: _$$11 }; break; } case false: { acc = _$$11; break; } } _$$1 = acc; _$$2 = _$$21.h2; continue; } else { return _$$11; } } };
let Lib_CompileScheme_compileScheme = Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( top ) => { let exports = Lib_CompileScheme_compileScheme_getExports({ tag: 0 }, Data_SortedMap_listValues(top.h2.h2)); let mainName = { tag: 0,  h0: top.h2.h0,  h1: "main" }; let main = Lib_TopContext_lookup(mainName, top); let todo = ( (main.tag) == (1) ? exports : { tag: 1,  h1: mainName,  h2: exports } ); return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_CompileScheme_process(todo), ( defs ) => { let sc$$7 = Lib_TopContext_lookup(mainName, top); if ((sc$$7.tag) == (1)) { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(Prelude_reverse()(defs)); } else { let exec = (("(") + (Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow(mainName))) + (" 'world)"); return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 1,  h1: "(import (chezscheme))",  h2: { tag: 1,  h1: "(include \"prim.ss\")",  h2: Prelude_reverse()({ tag: 1,  h1: exec,  h2: defs }) } }); } }); });
let Main_cmdLine = ( _$$0 ) => { while (1) { let _$$01 = _$$0; if ((_$$01.tag) == (1)) { switch (_$$01.h1) { case "--top": { _$$0 = _$$01.h2; continue; break; } case "-v": return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(Lib_Types_MkTop(tc.h0, tc.h1, tc.h2, (1) + (tc.h3), tc.h4, tc.h5)))), ( _ ) => (Main_cmdLine(_$$01.h2))); case "-o": { if ((_$$01.h2.tag) == (1)) { return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_cmdLine(_$$01.h2.h2), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Prelude_Prelude_Alternative$20Prelude_Maybe$2C_$3C$7C$3E_($$sc.h2, Prelude_Just(_$$01.h2.h1)),  h3: $$sc.h3 }))); } else { let sc$$4 = Prelude_isSuffixOf(".newt", _$$01.h1); switch (sc$$4) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_cmdLine(_$$01.h2), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: $$sc.h2,  h3: { tag: 1,  h1: _$$01.h1,  h2: $$sc.h3 } }))); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("Bad argument ") + (_$$01.h1)) + (""))), eta)))); } } break; } default: { let sc$$4 = Prelude_isSuffixOf(".newt", _$$01.h1); switch (sc$$4) { case true: return Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_cmdLine(_$$01.h2), ( $$sc ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: $$sc.h2,  h3: { tag: 1,  h1: _$$01.h1,  h2: $$sc.h3 } }))); default: return Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, (("Bad argument ") + (_$$01.h1)) + (""))), eta)))); } break; } } } else { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn({ tag: 0,  h2: Prelude_Nothing(),  h3: { tag: 0 } }); } } };
let Lib_TopContext_emptyTop = Lib_Types_MkTop(Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1)))), Lib_Types_emptyModCtx("", ""), 0, Data_SortedMap_EmptyMap(( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1)))), 0);
let Prelude_arrayToList = (a,arr) => {
  let rval = Prelude_Nil()
  for (let i = arr.length - 1;i >= 0; i--) {
    rval = Prelude__$3A$3A_(arr[i], rval)
  }
  return rval
};
let Node_getArgs = (w) => Prelude_MkIORes( Prelude_arrayToList(null, process.argv.slice(1)), w);
export let Main_main = ( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(( eta ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(( w ) => { let sc$$5 = Node_getArgs(w); return { tag: 0,  h1: Prelude_Right({ tag: 0,  h2: Lib_TopContext_emptyTop,  h3: sc$$5.h1 }),  h2: sc$$5.h2 }; }, ( $$sc ) => (( ($$sc.tag) == (1) ? ( ($$sc.h2.h3.tag) == (1) ? ( ($$sc.h2.h3.h2.tag) == (1) ? Lib_Types__runM(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_cmdLine($$sc.h2.h3.h2), ( $$sc1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(Lib_Types_Prelude_Applicative$20Lib_Types_M, ( eta ) => (Main_processFile(eta)), $$sc1.h3), ( _ ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Prelude_when(Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_elem(Prelude_Prelude_Eq$20Prim_String, "--top", $$sc.h2.h3.h2), ( _1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_jsonTopContext, ( json ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(Prelude_primPutStrLn((("TOP:") + (Lib_Common_renderJson(json))) + (""))))))), ( _1 ) => { if (($$sc1.h2.tag) == (1)) { return Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(0); } else { let sc$$20 = Prelude_isSuffixOf(".ss", $$sc1.h2.h1); switch (sc$$20) { case true: return Main_writeScheme($$sc1.h2.h1); case false: { let sc$$21 = Prelude_isSuffixOf(".js", $$sc1.h2.h1); switch (sc$$21) { case true: return Main_writeSource($$sc1.h2.h1); case false: return Node_exitFailure(null, (("Unknown extension for output file ") + ($$sc1.h2.h1)) + (" - I only know .js and .ss")); } break; } } } }))))))($$sc.h2.h2) : Lib_Types__runM(Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(Main_replHeader, ( _ ) => (Main_runRepl)))($$sc.h2.h2) ) : Lib_Types__runM(Lib_Types_MkM(( _ ) => (( eta ) => (Prelude_MkIORes(Prelude_Left(Lib_Error_E(Lib_Common_emptyFC, "error reading args")), eta)))))($$sc.h2.h2) ) : ( eta ) => (Prelude_MkIORes(Prelude_Left($$sc.h2), eta)) )), eta)), ( $$sc ) => (( ($$sc.tag) == (1) ? Prelude_primPutStrLn("done") : Node_exitFailure(null, (((("ERROR at ") + (Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow(Lib_Error_Lib_Common_HasFC$20Lib_Error_Error$2CgetFC($$sc.h2)))) + (": ")) + (Lib_Error_errorMsg($$sc.h2))) + ("")) )), eta));
Main_main();