"use strict";
const PiType = (h0, h1) => ({ tag: "PiType", h0, h1 })
const Lib_Types_errorMsg = ( _$$0 ) => { switch (_$$0.tag) { case "Postpone": return _$$0.h2; case "E": return _$$0.h1; } };
const Lib_Types_Lib_Common_HasFC$20Lib_Common_Error$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case "Postpone": return _$$0.h0; case "E": return _$$0.h0; } };
const Lib_Common_MkHasFC = ( h0, h1 ) => ({ tag: "MkHasFC",  h0: h0,  h1: h1 });
const Lib_Types_Lib_Common_HasFC$20Lib_Common_Error = Lib_Common_MkHasFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Common_Error$2CgetFC);
const Lib_Common_getFC = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Common__start = ( _$$0 ) => (_$$0.h1);
const Prelude_showInt = (i) => String(i)
const Prelude_Prelude_Show$20Prim_Int$2Cshow = Prelude_showInt;
const Prelude_MkShow = ( h0, h1 ) => ({ tag: "MkShow",  h0: h0,  h1: h1 });
const Prelude_Prelude_Show$20Prim_Int = Prelude_MkShow(null, Prelude_Prelude_Show$20Prim_Int$2Cshow);
const Prelude_show = ( a$$0, _$$1 ) => (_$$1.h1);
const Prelude_sconcat = (x,y) => x + y
const Prelude_Prelude_Concat$20Prim_String$2C_$2B$2B_ = ( eta ) => (( eta1 ) => (Prelude_sconcat(eta, eta1)));
const Prelude_MkConcat = ( h0, h1 ) => ({ tag: "MkConcat",  h0: h0,  h1: h1 });
const Prelude_Prelude_Concat$20Prim_String = Prelude_MkConcat(null, Prelude_Prelude_Concat$20Prim_String$2C_$2B$2B_);
const Prelude__$2B$2B_ = ( a$$0, _$$1 ) => (_$$1.h1);
const Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow = ( a$$0, b$$1, _$$2, _$$3, _$$4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_show(null, _$$2)(_$$4.h2))(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(", ")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_show(null, _$$3)(_$$4.h3))(")")))));
const Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29 = ( a, b, _, _1 ) => (Prelude_MkShow(null, ( eta ) => (Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29$2Cshow(null, null, _, _1, eta))));
const Lib_Common__file = ( _$$0 ) => (_$$0.h0);
const Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow = ( _$$0 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Common__file(_$$0)))(":"))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Prelude_Prelude_Show$20Prim_Int))(Lib_Common__start(_$$0))))(""));
const Lib_Common_Prelude_Show$20Lib_Common_FC = Prelude_MkShow(null, Lib_Common_Prelude_Show$20Lib_Common_FC$2Cshow);
const Node_exitFailure = (_, msg) => {
  console.log(msg);
  process.exit(1);
}
const Prelude_Prelude_HasIO$20Prelude_IO$2CliftIO = ( a$$0, _$$1 ) => (_$$1);
const Prelude_MkHasIO = ( h0, h1 ) => ({ tag: "MkHasIO",  h0: h0,  h1: h1 });
const Prelude_Prelude_HasIO$20Prelude_IO = Prelude_MkHasIO(null, ( a ) => (( eta ) => (Prelude_Prelude_HasIO$20Prelude_IO$2CliftIO(null, eta))));
const Prelude_MkIORes = ( h0, h1, h2 ) => ({ tag: "MkIORes",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_MkUnit = { tag: "MkUnit" };
const Prelude_primPutStrLn = (s) => (w) => {
  console.log(s)
  return Prelude_MkIORes(null,Prelude_MkUnit,w)
}
const Prelude_liftIO = ( m$$0, _$$1 ) => (( a ) => (_$$1.h1(null)));
const Prelude_putStrLn = ( io$$0, _$$1, _$$2 ) => (Prelude_liftIO(null, _$$1)(null)(Prelude_primPutStrLn(_$$2)));
const Prelude__$2C_ = ( h0, h1, h2, h3 ) => ({ tag: "_,_",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Common_MkFC = ( h0, h1 ) => ({ tag: "MkFC",  h0: h0,  h1: h1 });
const Lib_Common_emptyFC = Lib_Common_MkFC("", Prelude__$2C_(null, null, 0, 0));
const Lib_Common_E = ( h0, h1 ) => ({ tag: "E",  h0: h0,  h1: h1 });
const Prelude_Left = ( h0, h1, h2 ) => ({ tag: "Left",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_Prelude_Monad$20Prelude_IO$2Cpure = ( a ) => (( eta ) => (( eta1 ) => (Prelude_MkIORes(null, eta, eta1))));
const Prelude_Prelude_Monad$20Prelude_IO$2Cbind = ( a$$0, b$$1, _$$2, _$$3, w ) => { const sc$$5 = _$$2(w); return _$$3(sc$$5.h1)(sc$$5.h2); };
const Prelude_MkMonad = ( h0, h1, h2 ) => ({ tag: "MkMonad",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_Prelude_Monad$20Prelude_IO = Prelude_MkMonad(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (( eta2 ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cbind(null, null, eta, eta1, eta2)))))), ( a ) => (Prelude_Prelude_Monad$20Prelude_IO$2Cpure(null)));
const Prelude_pure = ( m$$0, _$$1 ) => (( a ) => (_$$1.h2(null)));
const Lib_Types_MkM = ( h0, h1 ) => ({ tag: "MkM",  h0: h0,  h1: h1 });
const Lib_Types_throwError = ( a$$0, _$$1 ) => (Lib_Types_MkM(null, ( _ ) => (Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Left(null, null, _$$1)))));
const Lib_Types_error = ( a$$0, _$$1, _$$2 ) => (Lib_Types_throwError(null, Lib_Common_E(_$$1, _$$2)));
const Prelude_Prelude_Show$20Prim_String$2Cshow = ( _$$0 ) => (_$$0);
const Prelude_Prelude_Show$20Prim_String = Prelude_MkShow(null, Prelude_Prelude_Show$20Prim_String$2Cshow);
const Prelude_Right = ( h0, h1, h2 ) => ({ tag: "Right",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_bind = ( m$$0, _$$1 ) => (( a ) => (( b ) => (_$$1.h1(null)(null))));
const Prelude__$3E$3E$3D_ = ( m$$0, a$$1, b$$2, _$$3, _$$4, _$$5 ) => (Prelude_bind(null, _$$3)(null)(null)(_$$4)(_$$5));
const Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_ = ( a$$0, b$$1, _$$2, _$$3 ) => (Lib_Types_MkM(null, ( tc ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, _$$2.h1(tc), ( $$sc ) => { switch ($$sc.tag) { case "Right": { const _sc$$0 = $$sc.h2; return Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, _$$3.h1(_sc$$0.h2), ( $$sc1 ) => { switch ($$sc1.tag) { case "Right": { const _sc$$1 = $$sc1.h2; return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, _sc$$1.h2, _sc$$0.h3(_sc$$1.h3)))); break; } case "Left": return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Left(null, null, $$sc1.h2)); } }); break; } case "Left": return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Left(null, null, $$sc.h2)); } }))));
const Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn = ( a$$0, _$$1 ) => (Lib_Types_MkM(null, ( tc ) => (Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, tc, _$$1))))));
const Prelude_MkApplicative = ( h0, h1, h2 ) => ({ tag: "MkApplicative",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_Prelude_Applicative$20Lib_Types_M = Prelude_MkApplicative(null, ( a ) => (( eta ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2Creturn(null, eta))), ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Types_Prelude_Applicative$20Lib_Types_M$2C_$3C$2A$3E_(null, null, eta, eta1))))));
const Prelude_return = ( f$$0, _$$1 ) => (( a ) => (_$$1.h1(null)));
const Lib_Types_Prelude_Monad$20Lib_Types_M$2Cpure = ( a ) => (Prelude_return(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null));
const Lib_Types__runM = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind = ( a$$0, b$$1, _$$2, _$$3 ) => (Lib_Types_MkM(null, ( tc ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, _$$2.h1(tc), ( $$sc ) => { switch ($$sc.tag) { case "Right": { const _sc$$0 = $$sc.h2; return Lib_Types__runM(null, _$$3(_sc$$0.h3))(_sc$$0.h2); break; } case "Left": return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Left(null, null, $$sc.h2)); } }))));
const Lib_Types_Prelude_Monad$20Lib_Types_M = Prelude_MkMonad(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cbind(null, null, eta, eta1))))), ( a ) => (Lib_Types_Prelude_Monad$20Lib_Types_M$2Cpure(null)));
const Node_writeFile = (fn, content) => (w) => {
  let fs = require('fs')
  let result
  try {
    fs.writeFileSync(fn, content, 'utf8')
    result = Prelude_Right(null, null, Prelude_MkUnit)
  } catch (e) {
      let err = ""+e
      result = Prelude_Left(null, null, e)
  }
  return Prelude_MkIORes(null, result, w)
}
const Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO = ( a$$0, _$$1 ) => (Lib_Types_MkM(null, ( tc ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, _$$1, ( result ) => (Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, tc, result))))))));
const Lib_Types_Prelude_HasIO$20Lib_Types_M = Prelude_MkHasIO(null, ( a ) => (( eta ) => (Lib_Types_Prelude_HasIO$20Lib_Types_M$2CliftIO(null, eta))));
const Lib_Prettier_Empty = { tag: "Empty" };
const Lib_Prettier_Line = { tag: "Line" };
const Lib_Prettier_Text = ( h0 ) => ({ tag: "Text",  h0: h0 });
const Lib_Prettier_Seq = ( h0, h1 ) => ({ tag: "Seq",  h0: h0,  h1: h1 });
const Lib_Prettier_noAlt = ( _$$0 ) => { switch (_$$0.tag) { case "Alt": return Lib_Prettier_noAlt(_$$0.h0); case "Seq": return Lib_Prettier_Seq(Lib_Prettier_noAlt(_$$0.h0), Lib_Prettier_noAlt(_$$0.h1)); case "Nest": return Lib_Prettier_noAlt(_$$0.h1); case "Text": return Lib_Prettier_Text(_$$0.h0); case "Line": return Lib_Prettier_Line; case "Empty": return Lib_Prettier_Empty; } };
const Prelude_Lin = ( h0 ) => ({ tag: "Lin",  h0: h0 });
const Prelude_Nil = ( h0 ) => ({ tag: "Nil",  h0: h0 });
const Prelude__$3A$3A_ = ( h0, h1, h2 ) => ({ tag: "_::_",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_False = { tag: "False" };
const Prelude__$3C$3E$3E_ = ( a$$0, _$$1, _$$2 ) => { switch (_$$1.tag) { case "_:<_": return Prelude__$3C$3E$3E_(null, _$$1.h1, Prelude__$3A$3A_(null, _$$1.h2, _$$2)); case "Lin": return _$$2; } };
const Prelude_Just = ( h0, h1 ) => ({ tag: "Just",  h0: h0,  h1: h1 });
const Lib_Prettier_LINE = ( h0 ) => ({ tag: "LINE",  h0: h0 });
const Prelude__$3A$3C_ = ( h0, h1, h2 ) => ({ tag: "_:<_",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_slen = s => s.length
const Prelude_addInt = (x,y) => x + y
const Prelude_Prelude_Add$20Prim_Int$2C_$2B_ = ( _$$0, _$$1 ) => (Prelude_addInt(_$$0, _$$1));
const Prelude_MkAdd = ( h0, h1 ) => ({ tag: "MkAdd",  h0: h0,  h1: h1 });
const Prelude_Prelude_Add$20Prim_Int = Prelude_MkAdd(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Add$20Prim_Int$2C_$2B_(eta, eta1))));
const Prelude__$2B_ = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Prettier_TEXT = ( h0 ) => ({ tag: "TEXT",  h0: h0 });
const Prelude_Nothing = ( h0 ) => ({ tag: "Nothing",  h0: h0 });
const Prelude_LT = { tag: "LT" };
const Prelude_EQ = { tag: "EQ" };
const Prelude_GT = { tag: "GT" };
const Prelude_jsCompare = (_, a, b) => a == b ? Prelude_EQ : a < b ? Prelude_LT : Prelude_GT
const Prelude_Prelude_Ord$20Prim_Int$2Ccompare = ( _$$0, _$$1 ) => (Prelude_jsCompare(null, _$$0, _$$1));
const Prelude_MkOrd = ( h0, h1 ) => ({ tag: "MkOrd",  h0: h0,  h1: h1 });
const Prelude_Prelude_Ord$20Prim_Int = Prelude_MkOrd(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_Int$2Ccompare(eta, eta1))));
const Prelude_compare = ( a$$0, _$$1 ) => (_$$1.h1);
const Prelude_True = { tag: "True" };
const Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "GT": switch (_$$0.tag) { case "GT": return Prelude_True; default: return Prelude_False; } break; case "EQ": switch (_$$0.tag) { case "EQ": return Prelude_True; default: return Prelude_False; } break; case "LT": switch (_$$0.tag) { case "LT": return Prelude_True; default: return Prelude_False; } break; } };
const Prelude_MkEq = ( h0, h1 ) => ({ tag: "MkEq",  h0: h0,  h1: h1 });
const Prelude_Prelude_Eq$20Prelude_Ordering = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prelude_Ordering$2C_$3D$3D_(eta, eta1))));
const Prelude__$3D$3D_ = ( a$$0, _$$1 ) => (_$$1.h1);
const Prelude__$3C_ = ( a$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prelude_Ordering)(Prelude_compare(null, _$$1)(_$$2)(_$$3))(Prelude_LT));
const Prelude_not = ( _$$0 ) => { switch (_$$0.tag) { case "False": return Prelude_True; case "True": return Prelude_False; } };
const Prelude__$7C$7C_ = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "False": return _$$1; case "True": return Prelude_True; } };
const Prelude_Prelude_Alternative$20Prelude_Maybe$2C_$3C$7C$3E_ = ( a$$0, _$$1, _$$2 ) => { switch (_$$1.tag) { case "Nothing": return _$$2; case "Just": return Prelude_Just(null, _$$1.h1); } };
const Prelude_MkAlternative = ( h0, h1 ) => ({ tag: "MkAlternative",  h0: h0,  h1: h1 });
const Prelude_Prelude_Alternative$20Prelude_Maybe = Prelude_MkAlternative(null, ( a ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Alternative$20Prelude_Maybe$2C_$3C$7C$3E_(null, eta, eta1)))));
const Prelude__$3C$7C$3E_ = ( m$$0, _$$1 ) => (( a ) => (_$$1.h1(null)));
const Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "Nothing": return Prelude_Nothing(null); case "Just": return Prelude_Just(null, _$$2(_$$3.h1)); } };
const Prelude_MkFunctor = ( h0, h1 ) => ({ tag: "MkFunctor",  h0: h0,  h1: h1 });
const Prelude_Prelude_Functor$20Prelude_Maybe = Prelude_MkFunctor(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Functor$20Prelude_Maybe$2Cmap(null, null, eta, eta1))))));
const Prelude_map = ( m$$0, _$$1 ) => (( a ) => (( b ) => (_$$1.h1(null)(null))));
const Prelude__$3C$$$3E_ = ( f$$0, _$$1, a$$2, b$$3, _$$4, _$$5 ) => (Prelude_map(null, _$$1)(null)(null)(_$$4)(_$$5));
const Lib_Prettier_be = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "_::_": { const _sc$$0 = _$$4.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Alt": return Prelude__$3C$$$3E_(null, Prelude_Prelude_Functor$20Prelude_Maybe, null, null, ( eta ) => (Prelude__$3C$3E$3E_(null, _$$1, eta)), Prelude__$3C$7C$3E_(null, Prelude_Prelude_Alternative$20Prelude_Maybe)(null)(Lib_Prettier_be(Prelude_True, Prelude_Lin(null), _$$2, _$$3, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h2, _sc$$1.h0), _$$4.h2)))(Lib_Prettier_be(_$$0, Prelude_Lin(null), _$$2, _$$3, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h2, _sc$$1.h1), _$$4.h2)))); case "Seq": return Lib_Prettier_be(_$$0, _$$1, _$$2, _$$3, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h2, _sc$$1.h0), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h2, _sc$$1.h1), _$$4.h2))); case "Nest": return Lib_Prettier_be(_$$0, _$$1, _$$2, _$$3, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$0.h2)(_sc$$1.h0), _sc$$1.h1), _$$4.h2)); case "Text": { const sc$$13 = Prelude__$7C$7C_(Prelude_not(_$$0), Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$3)(Prelude_slen(_sc$$1.h0)), _$$2)); switch (sc$$13.tag) { case "False": return Prelude_Nothing(null); case "True": return Lib_Prettier_be(_$$0, Prelude__$3A$3C_(null, _$$1, Lib_Prettier_TEXT(_sc$$1.h0)), _$$2, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$3)(Prelude_slen(_sc$$1.h0)), _$$4.h2); } break; } case "Line": return Lib_Prettier_be(Prelude_False, Prelude__$3A$3C_(null, _$$1, Lib_Prettier_LINE(_sc$$0.h2)), _$$2, _sc$$0.h2, _$$4.h2); case "Empty": return Lib_Prettier_be(_$$0, _$$1, _$$2, _$$3, _$$4.h2); } break; } case "Nil": return Prelude_Just(null, Prelude__$3C$3E$3E_(null, _$$1, Prelude_Nil(null))); } };
const Prelude_fromMaybe = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "Nothing": return _$$1; case "Just": return _$$2.h1; } };
const Lib_Prettier_best = ( _$$0, _$$1, _$$2 ) => (Prelude_fromMaybe(null, Prelude_Nil(null), Lib_Prettier_be(Prelude_False, Prelude_Lin(null), _$$0, _$$1, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, 0, _$$2), Prelude_Nil(null)))));
const Prelude_listToArray = 
(a, l) => {
  let rval = []
  while (l.tag !== 'Nil') {
    rval.push(l.h1)
    l = l.h2
  }
  return rval
}

const Prelude_fastConcat = (xs) => Prelude_listToArray(null, xs).join('')
const Prelude_Z = { tag: "Z" };
const Prelude_S = ( h0 ) => ({ tag: "S",  h0: h0 });
const Prelude_intToNat = (n) => {
  let rval = Prelude_Z
  for (;n>0;n--) rval = Prelude_S(rval);
  return rval;
}
const Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat$2Ccast = ( _$$0 ) => (Prelude_intToNat(_$$0));
const Prelude_MkCast = ( h0, h1, h2 ) => ({ tag: "MkCast",  h0: h0,  h1: h1,  h2: h2 });
const Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat = Prelude_MkCast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat$2Ccast);
const Prelude_cast = ( a$$0, b$$1, _$$2 ) => (_$$2.h2);
const Prelude_natToInt = (n) => {
  let rval = 0
  while (n.tag === 'S') {
    n = n.h0
    rval++
  }
  return rval
}
const Prelude_replicate = (n,c) => c.repeat(Prelude_natToInt(n))
const Lib_Prettier_layout = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; switch (_sc$$0.tag) { case "LINE": return Lib_Prettier_layout(_$$0.h2, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, _$$1, "\n"), Prelude_replicate(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_sc$$0.h0), " "))); case "TEXT": return Lib_Prettier_layout(_$$0.h2, Prelude__$3A$3C_(null, _$$1, _sc$$0.h0)); } break; } case "Nil": return Prelude_fastConcat(Prelude__$3C$3E$3E_(null, _$$1, Prelude_Nil(null))); } };
const Lib_Prettier_render = ( _$$0, _$$1 ) => (Lib_Prettier_layout(Lib_Prettier_best(_$$0, 0, Lib_Prettier_noAlt(_$$1)), Prelude_Lin(null)));
const Prelude__$2218_ = ( A$$0, B$$1, C$$2, _$$3, _$$4, _$$5 ) => (_$$3(_$$4(_$$5)));
const Prelude_reverse_go = ( _, _1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": return Prelude_reverse_go(_, _1, Prelude__$3A$3A_(null, _$$3.h1, _$$2), _$$3.h2); case "Nil": return _$$2; } };
const Prelude_reverse = ( a$$0 ) => { const go = null; return ( eta ) => (Prelude_reverse_go(a$$0, go, Prelude_Nil(null), eta)); };
const Prelude_Prelude_Functor$20Prelude_List$2Cmap_go = ( _, _1, _2, _3, _4, a$$5, b$$6, _$$7, _$$8, _$$9 ) => { switch (_$$8.tag) { case "_::_": return Prelude_Prelude_Functor$20Prelude_List$2Cmap_go(_, _1, _2, _3, _4, null, null, _$$7, _$$8.h2, Prelude__$3A$3A_(null, _$$7(_$$8.h1), _$$9)); case "Nil": return Prelude_reverse(null)(_$$9); } };
const Prelude_Prelude_Functor$20Prelude_List$2Cmap = ( a$$0, b$$1, _$$2, _$$3 ) => { const go = null; return Prelude_Prelude_Functor$20Prelude_List$2Cmap_go(a$$0, b$$1, _$$2, _$$3, go, null, null, _$$2, _$$3, Prelude_Nil(null)); };
const Prelude_Prelude_Functor$20Prelude_List = Prelude_MkFunctor(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Functor$20Prelude_List$2Cmap(null, null, eta, eta1))))));
const Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_ = ( a$$0, _$$1, _$$2 ) => { switch (_$$1.tag) { case "_::_": return Prelude__$3A$3A_(null, _$$1.h1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$1.h2)(_$$2)); case "Nil": return _$$2; } };
const Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29 = ( a ) => (Prelude_MkConcat(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29$2C_$2B$2B_(null, eta, eta1)))));
const Prelude_joinBy = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h2; switch (_sc$$0.tag) { case "_::_": return Prelude_joinBy(_$$0, Prelude__$3A$3A_(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$1.h1)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$0)(_sc$$0.h1)), _sc$$0.h2)); case "Nil": return _$$1.h1; } break; } case "Nil": return ""; } };
const Prelude_unlines = ( _$$0 ) => (Prelude_joinBy("\n", _$$0));
const Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow = ( _$$0 ) => { const _sc$$0 = _$$0.h0; switch (_sc$$0.tag) { case "Nil": return _$$0.h1; default: return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_joinBy(".", _$$0.h0))(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(".")(_$$0.h1)); } };
const Lib_Common_Prelude_Show$20Lib_Common_QName = Prelude_MkShow(null, Lib_Common_Prelude_Show$20Lib_Common_QName$2Cshow);
const Lib_Compile_Var = ( h0 ) => ({ tag: "Var",  h0: h0 });
const Lib_Compile_Apply = ( h0, h1 ) => ({ tag: "Apply",  h0: h0,  h1: h1 });
const Lib_Compile_JPlain = ( h0 ) => ({ tag: "JPlain",  h0: h0 });
const Lib_Prettier_line = Lib_Prettier_Line;
const Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc$2C_$2B$2B_ = ( _$$0, _$$1 ) => (Lib_Prettier_Seq(_$$0, _$$1));
const Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc = Prelude_MkConcat(null, ( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc$2C_$2B$2B_(eta, eta1))));
const Lib_Prettier__$3C$2F$3E_ = ( _$$0, _$$1 ) => (Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$0)(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(_$$1)));
const Lib_Prettier_text = Lib_Prettier_Text;
const Prelude_fatalError = (_, msg) => { throw new Error(msg) }
const Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_ = ( _$$0, _$$1 ) => (Lib_Prettier_Seq(_$$0, Lib_Prettier_Seq(Lib_Prettier_Text(" "), _$$1)));
const Prelude_MkSemigroup = ( h0, h1 ) => ({ tag: "MkSemigroup",  h0: h0,  h1: h1 });
const Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc = Prelude_MkSemigroup(null, ( eta ) => (( eta1 ) => (Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc$2C_$3C$2B$3E_(eta, eta1))));
const Prelude__$3C$2B$3E_ = ( a$$0, _$$1 ) => (_$$1.h1);
const Prelude_unpack = (s) => {
    let acc = Prelude_Nil(null)
    for (let i = s.length - 1; 0 <= i; i--) acc = Prelude__$3A$3A_(null, s[i], acc)
    return acc
}
const Prelude_ord = (c) => c.charCodeAt(0)
const Data_Int_Prelude_Cast$20Prim_Char$20Prim_Int$2Ccast = Prelude_ord;
const Data_Int_Prelude_Cast$20Prim_Char$20Prim_Int = Prelude_MkCast(null, null, Data_Int_Prelude_Cast$20Prim_Char$20Prim_Int$2Ccast);
const Lib_Common_hexChars = Prelude_unpack("0123456789ABCDEF");
const Prelude_mod = (a,b) => a % b
const Prelude_getAt = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": switch (_$$1.tag) { case "S": return Prelude_getAt(null, _$$1.h0, _$$2.h2); case "Z": return Prelude_Just(null, _$$2.h1); } break; case "Nil": return Prelude_Nothing(null); } };
const Lib_Common_hexDigit = ( _$$0 ) => (Prelude_fromMaybe(null, " ", Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(Prelude_mod(_$$0, 16)), Lib_Common_hexChars)));
const Prelude_divInt = (x,y) => x / y | 0
const Prelude_Prelude_Div$20Prim_Int$2C_$2F_ = ( _$$0, _$$1 ) => (Prelude_divInt(_$$0, _$$1));
const Prelude_MkDiv = ( h0, h1 ) => ({ tag: "MkDiv",  h0: h0,  h1: h1 });
const Prelude_Prelude_Div$20Prim_Int = Prelude_MkDiv(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Div$20Prim_Int$2C_$2F_(eta, eta1))));
const Prelude__$2F_ = ( a$$0, _$$1 ) => (_$$1.h1);
const Data_Int_div = ( _$$0, _$$1 ) => (Prelude__$2F_(null, Prelude_Prelude_Div$20Prim_Int)(_$$0)(_$$1));
const Prelude_snoc = ( a$$0, _$$1, _$$2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$1)(Prelude__$3A$3A_(null, _$$2, Prelude_Nil(null))));
const Lib_Common_toHex = ( _$$0 ) => { switch (_$$0) { case 0: return Prelude_Nil(null); default: return Prelude_snoc(null, Lib_Common_toHex(Data_Int_div(_$$0, 16)), Lib_Common_hexDigit(_$$0)); } };
const Prelude_jsEq = (_, a, b) => a == b ? Prelude_True : Prelude_False
const Prelude_Prelude_Eq$20Prim_Char$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude_jsEq(null, _$$0, _$$1));
const Prelude_Prelude_Eq$20Prim_Char = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prim_Char$2C_$3D$3D_(eta, eta1))));
const Prelude__$26$26_ = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "False": return Prelude_False; case "True": return _$$1; } };
const Prelude_isAlphaNum = ( _$$0 ) => { const o = Prelude_ord(_$$0); return Prelude__$7C$7C_(Prelude__$26$26_(Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, 64, o), Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, o, 91)), Prelude__$7C$7C_(Prelude__$26$26_(Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, 47, o), Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, o, 58)), Prelude__$26$26_(Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, 96, o), Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, o, 123)))); };
const Lib_Compile_jsIdent_fix = ( _, _1, _$$2 ) => { switch (_$$2.tag) { case "_::_": { const sc$$6 = Prelude__$7C$7C_(Prelude_isAlphaNum(_$$2.h1), Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Char)(_$$2.h1)("_")); switch (sc$$6.tag) { case "False": { const sc$$7 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Char)(_$$2.h1)("."); switch (sc$$7.tag) { case "False": { const sc$$8 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Char)(_$$2.h1)("$"); switch (sc$$8.tag) { case "False": return Prelude__$3A$3A_(null, "$", Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(Lib_Common_toHex(Prelude_cast(null, null, Data_Int_Prelude_Cast$20Prim_Char$20Prim_Int)(_$$2.h1)))(Lib_Compile_jsIdent_fix(_, _1, _$$2.h2))); case "True": return Prelude__$3A$3A_(null, "$", Prelude__$3A$3A_(null, "$", Lib_Compile_jsIdent_fix(_, _1, _$$2.h2))); } break; } case "True": return Prelude__$3A$3A_(null, "_", Lib_Compile_jsIdent_fix(_, _1, _$$2.h2)); } break; } case "True": return Prelude__$3A$3A_(null, _$$2.h1, Lib_Compile_jsIdent_fix(_, _1, _$$2.h2)); } break; } case "Nil": return Prelude_Nil(null); } };
const Prelude_pack = (cs) => {
  let rval = ''
  while (cs.tag === '_::_') {
    rval += cs.h1
    cs = cs.h2
  }
  return rval
}

const Lib_Compile_jsKeywords = Prelude__$3A$3A_(null, "break", Prelude__$3A$3A_(null, "case", Prelude__$3A$3A_(null, "catch", Prelude__$3A$3A_(null, "continue", Prelude__$3A$3A_(null, "debugger", Prelude__$3A$3A_(null, "default", Prelude__$3A$3A_(null, "delete", Prelude__$3A$3A_(null, "do", Prelude__$3A$3A_(null, "else", Prelude__$3A$3A_(null, "finally", Prelude__$3A$3A_(null, "for", Prelude__$3A$3A_(null, "function", Prelude__$3A$3A_(null, "if", Prelude__$3A$3A_(null, "in", Prelude__$3A$3A_(null, "instanceof", Prelude__$3A$3A_(null, "new", Prelude__$3A$3A_(null, "return", Prelude__$3A$3A_(null, "switch", Prelude__$3A$3A_(null, "this", Prelude__$3A$3A_(null, "throw", Prelude__$3A$3A_(null, "try", Prelude__$3A$3A_(null, "typeof", Prelude__$3A$3A_(null, "var", Prelude__$3A$3A_(null, "void", Prelude__$3A$3A_(null, "while", Prelude__$3A$3A_(null, "with", Prelude__$3A$3A_(null, "class", Prelude__$3A$3A_(null, "const", Prelude__$3A$3A_(null, "enum", Prelude__$3A$3A_(null, "export", Prelude__$3A$3A_(null, "extends", Prelude__$3A$3A_(null, "import", Prelude__$3A$3A_(null, "super", Prelude__$3A$3A_(null, "implements", Prelude__$3A$3A_(null, "class", Prelude__$3A$3A_(null, "let", Prelude__$3A$3A_(null, "package", Prelude__$3A$3A_(null, "private", Prelude__$3A$3A_(null, "protected", Prelude__$3A$3A_(null, "public", Prelude__$3A$3A_(null, "static", Prelude__$3A$3A_(null, "yield", Prelude__$3A$3A_(null, "null", Prelude__$3A$3A_(null, "true", Prelude__$3A$3A_(null, "false", Prelude__$3A$3A_(null, "String", Prelude__$3A$3A_(null, "Number", Prelude__$3A$3A_(null, "Array", Prelude__$3A$3A_(null, "BigInt", Prelude_Nil(null))))))))))))))))))))))))))))))))))))))))))))))))));
const Prelude_Prelude_Eq$20Prim_String$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude_jsEq(null, _$$0, _$$1));
const Prelude_Prelude_Eq$20Prim_String = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prim_String$2C_$3D$3D_(eta, eta1))));
const Prelude_elem = ( a$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": { const sc$$7 = Prelude__$3D$3D_(null, _$$1)(_$$2)(_$$3.h1); switch (sc$$7.tag) { case "False": return Prelude_elem(null, _$$1, _$$2, _$$3.h2); case "True": return Prelude_True; } break; } case "Nil": return Prelude_False; } };
const Lib_Compile_jsIdent = ( _$$0 ) => { const fix = null; const sc$$2 = Prelude_elem(null, Prelude_Prelude_Eq$20Prim_String, _$$0, Lib_Compile_jsKeywords); switch (sc$$2.tag) { case "False": return Lib_Prettier_text(Prelude_pack(Lib_Compile_jsIdent_fix(_$$0, fix, Prelude_unpack(_$$0)))); case "True": return Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("$")(_$$0)); } };
const Lib_Compile_expToDoc_entry = ( _, _1, _2, _$$3 ) => (Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_jsIdent(_$$3.h2))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(":"))(Lib_Compile_expToDoc(_$$3.h3))));
const Lib_Prettier_Alt = ( h0, h1 ) => ({ tag: "Alt",  h0: h0,  h1: h1 });
const Lib_Prettier__$3C$2B$2F$3E_ = ( _$$0, _$$1 ) => (Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$0)(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_Alt(Lib_Prettier_text(" "), Lib_Prettier_line))(_$$1)));
const Lib_Prettier_folddoc = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h2; switch (_sc$$0.tag) { case "Nil": return _$$1.h1; default: return _$$0(_$$1.h1)(Lib_Prettier_folddoc(_$$0, _$$1.h2)); } break; } case "Nil": return Lib_Prettier_Empty; } };
const Lib_Common_quoteString_encode = ( _, _1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "_::_": { const _sc$$0 = _$$2.h1; switch (_sc$$0) { case "\"": return Lib_Common_quoteString_encode(_, _1, _$$2.h2, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, _$$3, "\\"), "\"")); case "\n": return Lib_Common_quoteString_encode(_, _1, _$$2.h2, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, _$$3, "\\"), "n")); case "\\": return Lib_Common_quoteString_encode(_, _1, _$$2.h2, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, _$$3, "\\"), "\\")); default: { const v = Prelude_cast(null, null, Data_Int_Prelude_Cast$20Prim_Char$20Prim_Int)(_$$2.h1); const sc$$8 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, v, 32); switch (sc$$8.tag) { case "False": return Lib_Common_quoteString_encode(_, _1, _$$2.h2, Prelude__$3A$3C_(null, _$$3, _$$2.h1)); case "True": return Lib_Common_quoteString_encode(_, _1, _$$2.h2, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, _$$3, "\\"), "u"), Lib_Common_hexDigit(Data_Int_div(v, 4096))), Lib_Common_hexDigit(Data_Int_div(v, 256))), Lib_Common_hexDigit(Data_Int_div(v, 16))), Lib_Common_hexDigit(v))); } break; } } break; } case "Nil": return Prelude__$3C$3E$3E_(null, _$$3, Prelude__$3A$3A_(null, "\"", Prelude_Nil(null))); } };
const Lib_Common_quoteString = ( _$$0 ) => { const encode = null; return Prelude_pack(Lib_Common_quoteString_encode(_$$0, encode, Prelude_unpack(_$$0), Prelude__$3A$3C_(null, Prelude_Lin(null), "\""))); };
const Lib_Prettier_commaSep = ( eta ) => (Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier__$3C$2B$2F$3E_(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(a)(Lib_Prettier_text(",")), b))), eta));
const Lib_Prettier_Nest = ( h0, h1 ) => ({ tag: "Nest",  h0: h0,  h1: h1 });
const Lib_Prettier_nest = ( eta ) => (( eta1 ) => (Lib_Prettier_Nest(eta, eta1)));
const Lib_Prettier_flatten = ( _$$0 ) => { switch (_$$0.tag) { case "Alt": return Lib_Prettier_flatten(_$$0.h0); case "Seq": return Lib_Prettier_Seq(Lib_Prettier_flatten(_$$0.h0), Lib_Prettier_flatten(_$$0.h1)); case "Nest": return Lib_Prettier_flatten(_$$0.h1); case "Text": return Lib_Prettier_Text(_$$0.h0); case "Line": return Lib_Prettier_Text(" "); case "Empty": return Lib_Prettier_Empty; } };
const Lib_Prettier_group = ( _$$0 ) => (Lib_Prettier_Alt(Lib_Prettier_flatten(_$$0), _$$0));
const Lib_Prettier_bracket = ( _$$0, _$$1, _$$2 ) => (Lib_Prettier_group(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(_$$0))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_nest(2)(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(_$$1)))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(Lib_Prettier_text(_$$2))))));
const Lib_Compile_expToDoc = ( _$$0 ) => { switch (_$$0.tag) { case "Dot": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$0.h0))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("."))(Lib_Compile_jsIdent(_$$0.h1))); case "Index": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$0.h0))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$0.h1))(Lib_Prettier_text(" :: Nil)")))); case "JUndefined": return Lib_Prettier_text("null"); case "JLam": { const _sc$$0 = _$$0.h1; switch (_sc$$0.tag) { case "JReturn": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Lib_Prettier_commaSep(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Compile_jsIdent)(_$$0.h0))))(Lib_Prettier_text(") =>")))(Lib_Prettier_text("(")))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_sc$$0.h0))(Lib_Prettier_text(")"))); default: return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Lib_Prettier_commaSep(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Compile_jsIdent)(_$$0.h0))))(Lib_Prettier_text(") =>")))(Lib_Prettier_bracket("{", Lib_Compile_stmtToDoc(null, _$$0.h1), "}")); } break; } case "Var": return Lib_Compile_jsIdent(_$$0.h0); case "Apply": { const _sc$$0 = _$$0.h0; switch (_sc$$0.tag) { case "JLam": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$0.h0))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(")"))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_nest(2)(Lib_Prettier_commaSep(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Compile_expToDoc)(_$$0.h1))))(Lib_Prettier_text(")")))))); default: return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$0.h0))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_nest(2)(Lib_Prettier_commaSep(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Compile_expToDoc)(_$$0.h1))))(Lib_Prettier_text(")")))); } break; } case "LitInt": return Lib_Prettier_text(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h0)); case "LitString": return Lib_Prettier_text(Lib_Common_quoteString(_$$0.h0)); case "LitObject": { const entry = null; return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("{"))(Lib_Prettier_folddoc(( a ) => (( e ) => (Lib_Prettier__$3C$2B$2F$3E_(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(a)(Lib_Prettier_text(", ")), e))), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Compile_expToDoc_entry(_$$0, _$$0.h0, entry, eta)))(_$$0.h0))))(Lib_Prettier_text("}")); break; } case "LitArray": return Prelude_fatalError(null, "TODO - LitArray to doc"); } };
const Lib_Compile_caseBody = ( e$$0, _$$1 ) => { switch (_$$1.tag) { case "JCase": return Lib_Prettier_nest(2)(Lib_Prettier__$3C$2F$3E_(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(Lib_Compile_stmtToDoc(null, _$$1)), Lib_Prettier_text("break;"))); case "JReturn": return Lib_Prettier_nest(2)(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(Lib_Compile_stmtToDoc(null, _$$1))); default: return Lib_Prettier__$3C$2F$3E_(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("{"))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2F$3E_(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(Lib_Compile_stmtToDoc(null, _$$1)), Lib_Prettier_text("break;"))))), Lib_Prettier_text("}")); } };
const Lib_Compile_altToDoc = ( _$$0 ) => { switch (_$$0.tag) { case "JLitAlt": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("case"))(Lib_Compile_expToDoc(_$$0.h1)))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(":"))(Lib_Compile_caseBody(null, _$$0.h2))); case "JDefAlt": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("default"))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(":"))(Lib_Compile_caseBody(null, _$$0.h1))); case "JConAlt": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("case"))(Lib_Prettier_text(Lib_Common_quoteString(_$$0.h1))))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(":"))(Lib_Compile_caseBody(null, _$$0.h2))); } };
const Lib_Prettier_stack = ( eta ) => (Lib_Prettier_folddoc(( eta ) => (( eta1 ) => (Lib_Prettier__$3C$2F$3E_(eta, eta1))), eta));
const Lib_Compile_stmtToDoc = ( e$$0, _$$1 ) => { switch (_$$1.tag) { case "JError": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("throw new Error("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(Lib_Common_quoteString(_$$1.h1)))(Lib_Prettier_text(");"))); case "JCase": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("switch ("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$1.h1))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(")"))(Lib_Prettier_bracket("{", Lib_Prettier_stack(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Compile_altToDoc)(_$$1.h2)), "}")))); case "JAssign": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Compile_jsIdent(_$$1.h0))(Lib_Prettier_text("=")))(Lib_Compile_expToDoc(_$$1.h1)))(Lib_Prettier_text(";")); case "JLet": return Lib_Prettier__$3C$2F$3E_(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("let"))(Lib_Compile_jsIdent(_$$1.h0)))(Lib_Prettier_text(";")), Lib_Compile_stmtToDoc(null, _$$1.h1)); case "JReturn": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("return"))(Lib_Compile_expToDoc(_$$1.h0)))(Lib_Prettier_text(";")); case "JConst": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("const"))(Lib_Compile_jsIdent(_$$1.h0)))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2B$2F$3E_(Lib_Prettier_text("="), Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$1.h1))(Lib_Prettier_text(";"))))); case "JPlain": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(_$$1.h0))(Lib_Prettier_text(";")); case "JSnoc": return Lib_Prettier__$3C$2F$3E_(Lib_Compile_stmtToDoc(null, _$$1.h1), Lib_Compile_stmtToDoc(null, _$$1.h2)); } };
const Prelude_Prelude_Ord$20Prim_String$2Ccompare = ( _$$0, _$$1 ) => (Prelude_jsCompare(null, _$$0, _$$1));
const Prelude_Prelude_Ord$20Prim_String = Prelude_MkOrd(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prim_String$2Ccompare(eta, eta1))));
const Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29$2Ccompare = ( a$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": switch (_$$2.tag) { case "_::_": { const sc$$10 = Prelude_compare(null, _$$1)(_$$2.h1)(_$$3.h1); switch (sc$$10.tag) { case "EQ": return Prelude_compare(null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, _$$1))(_$$2.h2)(_$$3.h2); default: return sc$$10; } break; } case "Nil": return Prelude_LT; } break; case "Nil": switch (_$$2.tag) { case "Nil": return Prelude_EQ; default: return Prelude_GT; } break; } };
const Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29 = ( a, _ ) => (Prelude_MkOrd(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29$2Ccompare(null, _, eta, eta1)))));
const Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29$2C_$3D$3D_ = ( a$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": switch (_$$2.tag) { case "_::_": { const sc$$10 = Prelude__$3D$3D_(null, _$$1)(_$$2.h1)(_$$3.h1); switch (sc$$10.tag) { case "False": return Prelude_False; case "True": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29(null, _$$1))(_$$2.h2)(_$$3.h2); } break; } default: return Prelude_False; } break; case "Nil": switch (_$$2.tag) { case "Nil": return Prelude_True; default: return Prelude_False; } break; } };
const Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29 = ( a, _ ) => (Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29$2C_$3D$3D_(null, _, eta, eta1)))));
const Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare = ( _$$0, _$$1 ) => { const sc$$6 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Eq$20Prim_String))(_$$0.h0)(_$$1.h0); switch (sc$$6.tag) { case "False": return Prelude_compare(null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String))(_$$0.h0)(_$$1.h0); case "True": return Prelude_compare(null, Prelude_Prelude_Ord$20Prim_String)(_$$0.h1)(_$$1.h1); } };
const Lib_Common_Prelude_Ord$20Lib_Common_QName = Prelude_MkOrd(null, ( eta ) => (( eta1 ) => (Lib_Common_Prelude_Ord$20Lib_Common_QName$2Ccompare(eta, eta1))));
const Prelude__$2F$3D_ = ( a$$0, _$$1, _$$2, _$$3 ) => (Prelude_not(Prelude__$3D$3D_(null, _$$1)(_$$2)(_$$3)));
const Prelude__$3C$3D_ = ( a$$0, _$$1, _$$2, _$$3 ) => (Prelude__$2F$3D_(null, Prelude_Prelude_Eq$20Prelude_Ordering, Prelude_compare(null, _$$1)(_$$2)(_$$3), Prelude_GT));
const Data_SortedMap_lookupT23 = ( h$$0, k$$1, v$$2, _$$3, _$$4, _$$5 ) => { switch (_$$5.tag) { case "Node3": { const sc$$14 = Prelude__$3C$3D_(null, _$$3, _$$4, _$$5.h4); switch (sc$$14.tag) { case "False": { const sc$$15 = Prelude__$3C$3D_(null, _$$3, _$$4, _$$5.h6); switch (sc$$15.tag) { case "False": return Data_SortedMap_lookupT23(null, null, null, _$$3, _$$4, _$$5.h7); case "True": return Data_SortedMap_lookupT23(null, null, null, _$$3, _$$4, _$$5.h5); } break; } case "True": return Data_SortedMap_lookupT23(null, null, null, _$$3, _$$4, _$$5.h3); } break; } case "Node2": { const sc$$12 = Prelude__$3C$3D_(null, _$$3, _$$4, _$$5.h4); switch (sc$$12.tag) { case "False": return Data_SortedMap_lookupT23(null, null, null, _$$3, _$$4, _$$5.h5); case "True": return Data_SortedMap_lookupT23(null, null, null, _$$3, _$$4, _$$5.h3); } break; } case "Leaf": { const sc$$10 = Prelude_compare(null, _$$3)(_$$5.h2)(_$$4); switch (sc$$10.tag) { case "EQ": return Prelude_Just(null, Prelude__$2C_(null, null, _$$5.h2, _$$5.h3)); default: return Prelude_Nothing(null); } break; } } };
const Data_SortedMap_lookupMap = ( k$$0, v$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "MapOf": return Data_SortedMap_lookupT23(null, null, null, _$$2, _$$3, _$$4.h3); case "EmptyMap": return Prelude_Nothing(null); } };
const Prelude_mapMaybe = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": { const sc$$7 = _$$2(_$$3.h1); switch (sc$$7.tag) { case "Nothing": return Prelude_mapMaybe(null, null, _$$2, _$$3.h2); case "Just": return Prelude__$3A$3A_(null, sc$$7.h1, Prelude_mapMaybe(null, null, _$$2, _$$3.h2)); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Ref2_MkRef = ( h0, h1, h2 ) => ({ tag: "MkRef",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Compile_JConst = ( h0, h1 ) => ({ tag: "JConst",  h0: h0,  h1: h1 });
const Lib_Compile_JReturn = ( h0 ) => ({ tag: "JReturn",  h0: h0 });
const Lib_Compile_MkEnv = ( h0, h1 ) => ({ tag: "MkEnv",  h0: h0,  h1: h1 });
const Lib_Compile_emptyJSEnv = Lib_Compile_MkEnv(Prelude_Nil(null), 0);
const Lib_Compile__jsenv = ( _$$0 ) => (_$$0.h0);
const Lib_Compile_JLam = ( h0, h1 ) => ({ tag: "JLam",  h0: h0,  h1: h1 });
const Lib_Compile_push = ( _$$0, _$$1 ) => (Lib_Compile_MkEnv(Prelude__$3A$3A_(null, _$$1, _$$0.h0), _$$0.h1));
const Lib_Compile_freshName_free = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$3.tag) { case "_::_": { const _sc$$0 = _$$3.h1; switch (_sc$$0.tag) { case "Var": { const sc$$9 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h0)(_$$4); switch (sc$$9.tag) { case "False": return Lib_Compile_freshName_free(_, _1, _2, _$$3.h2, _$$4); case "True": return Prelude_False; } break; } default: return Lib_Compile_freshName_free(_, _1, _2, _$$3.h2, _$$4); } break; } case "Nil": return Prelude_True; } };
const Lib_Compile_freshName_free_go = ( _, _1, _2, _3, _$$4, _$$5 ) => { const nm$27 = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$4))(""))(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$5)))(""); const sc$$7 = Lib_Compile_freshName_free(_, _1, _2, Lib_Compile__jsenv(_1), nm$27); switch (sc$$7.tag) { case "False": return Lib_Compile_freshName_free_go(_, _1, _2, _3, _$$4, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$5)); case "True": return nm$27; } };
const Lib_Compile_freshName = ( _$$0, _$$1 ) => { const free = null; const go = null; const sc$$4 = Lib_Compile_freshName_free(_$$0, _$$1, free, Lib_Compile__jsenv(_$$1), _$$0); switch (sc$$4.tag) { case "False": return Lib_Compile_freshName_free_go(_$$0, _$$1, free, go, _$$0, 1); case "True": return _$$0; } };
const Lib_Compile_freshName$27 = ( _$$0, _$$1 ) => { const nm$27 = Lib_Compile_freshName(_$$0, _$$1); const env$27 = Lib_Compile_push(_$$1, Lib_Compile_Var(nm$27)); return Prelude__$2C_(null, null, nm$27, env$27); };
const Lib_Compile_freshNames_go = ( _, _1, _2, _$$3, _$$4, _$$5 ) => { switch (_$$3.tag) { case "_::_": { const sc$$9 = Lib_Compile_freshName$27(_$$3.h1, _$$4); return Lib_Compile_freshNames_go(_, _1, _2, _$$3.h2, sc$$9.h3, Prelude__$3A$3C_(null, _$$5, sc$$9.h2)); break; } case "Nil": return Prelude__$2C_(null, null, Prelude__$3C$3E$3E_(null, _$$5, Prelude_Nil(null)), _$$4); } };
const Lib_Compile_freshNames = ( _$$0, _$$1 ) => { const go = null; return Lib_Compile_freshNames_go(_$$0, _$$1, go, _$$0, _$$1, Prelude_Lin(null)); };
const Lib_Compile_termToJS_etaExpand = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10, _$$11 ) => { switch (_$$9.tag) { case "S": { const nm$27 = Lib_Compile_freshName("eta", _$$8); const env$27 = Lib_Compile_push(_$$8, Lib_Compile_Var(nm$27)); return Lib_Compile_JLam(Prelude__$3A$3A_(null, nm$27, Prelude_Nil(null)), Lib_Compile_JReturn(Lib_Compile_termToJS_etaExpand(_, _1, _2, _3, _4, _5, _6, _7, Lib_Compile_push(_$$8, Lib_Compile_Var(nm$27)), _$$9.h0, Prelude__$3A$3C_(null, _$$10, Lib_Compile_Var(nm$27)), _$$11))); break; } case "Z": return Lib_Compile_Apply(_$$11, Prelude__$3C$3E$3E_(null, _$$10, Prelude_Nil(null))); } };
const Lib_Compile_termToJS_etaExpand_argsToJS = ( _, _1, _2, _3, _4, _5, _6, _7, _8, e$$9, _$$10, _$$11, _$$12, _$$13 ) => { switch (_$$11.tag) { case "_::_": return Lib_Compile_termToJS(null, _1, _$$11.h1, ( x$27 ) => (Lib_Compile_termToJS_etaExpand_argsToJS(_, _1, _2, _3, _4, _5, _6, _7, _8, null, _$$10, _$$11.h2, Prelude__$3A$3C_(null, _$$12, x$27), _$$13))); case "Nil": return _$$13(Lib_Compile_termToJS_etaExpand(_, _1, _2, _3, _4, _5, _6, _7, _1, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_6), _$$12, _$$10)); } };
const Lib_Compile_Dot = ( h0, h1 ) => ({ tag: "Dot",  h0: h0,  h1: h1 });
const Lib_Compile_mkEnv = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": return Lib_Compile_mkEnv(_$$0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$1), Lib_Compile_push(_$$2, Lib_Compile_Dot(Lib_Compile_Var(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("h")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$1)))(""))), _$$3.h2); case "Nil": return _$$2; } };
const Lib_Compile_JConAlt = ( h0, h1, h2 ) => ({ tag: "JConAlt",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Compile_JDefAlt = ( h0, h1 ) => ({ tag: "JDefAlt",  h0: h0,  h1: h1 });
const Lib_Compile_LitString = ( h0 ) => ({ tag: "LitString",  h0: h0 });
const Lib_Compile_LitInt = ( h0 ) => ({ tag: "LitInt",  h0: h0 });
const Lib_Compile_litToJS = ( _$$0 ) => { switch (_$$0.tag) { case "LChar": return Lib_Compile_LitString(Prelude_pack(Prelude__$3A$3A_(null, _$$0.h0, Prelude_Nil(null)))); case "LInt": return Lib_Compile_LitInt(_$$0.h0); case "LString": return Lib_Compile_LitString(_$$0.h0); } };
const Lib_Compile_JLitAlt = ( h0, h1, h2 ) => ({ tag: "JLitAlt",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Compile_termToJS_termToJSAlt = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8, _$$9 ) => { switch (_$$9.tag) { case "CLitAlt": return Lib_Compile_JLitAlt(null, Lib_Compile_litToJS(_$$9.h0), Lib_Compile_termToJS(null, _$$7, _$$9.h1, _3)); case "CDefAlt": return Lib_Compile_JDefAlt(null, Lib_Compile_termToJS(null, _$$7, _$$9.h0, _3)); case "CConAlt": return Lib_Compile_JConAlt(null, _$$9.h0, Lib_Compile_termToJS(null, Lib_Compile_mkEnv(_$$8, 0, _$$7, _$$9.h1), _$$9.h2, _3)); } };
const Lib_Compile_JCase = ( h0, h1, h2 ) => ({ tag: "JCase",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Compile_termToJS_termToJSAlt_maybeCaseStmt = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10 ) => { switch (_$$10.tag) { case "_::_": { const _sc$$0 = _$$10.h1; switch (_sc$$0.tag) { case "CLitAlt": return Lib_Compile_JCase(null, Lib_Compile_Var(_$$9), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Compile_termToJS_termToJSAlt(_, _1, _2, _3, _4, _5, _6, _$$8, _$$9, eta)))(_$$10)); case "CConAlt": { const _sc$$1 = _$$10.h2; switch (_sc$$1.tag) { case "Nil": return Lib_Compile_termToJS(null, Lib_Compile_mkEnv(_$$9, 0, _$$8, _sc$$0.h1), _sc$$0.h2, _3); default: return Lib_Compile_JCase(null, Lib_Compile_Dot(Lib_Compile_Var(_$$9), "tag"), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Compile_termToJS_termToJSAlt(_, _1, _2, _3, _4, _5, _6, _$$8, _$$9, eta)))(_$$10)); } break; } default: return Lib_Compile_JCase(null, Lib_Compile_Dot(Lib_Compile_Var(_$$9), "tag"), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Compile_termToJS_termToJSAlt(_, _1, _2, _3, _4, _5, _6, _$$8, _$$9, eta)))(_$$10)); } break; } default: return Lib_Compile_JCase(null, Lib_Compile_Dot(Lib_Compile_Var(_$$9), "tag"), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Compile_termToJS_termToJSAlt(_, _1, _2, _3, _4, _5, _6, _$$8, _$$9, eta)))(_$$10)); } };
const Lib_Compile_JSnoc = ( h0, h1, h2 ) => ({ tag: "JSnoc",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Compile__depth = ( _$$0 ) => (_$$0.h1);
const Lib_Compile_JLet = ( h0, h1 ) => ({ tag: "JLet",  h0: h0,  h1: h1 });
const Lib_Compile_JAssign = ( h0, h1 ) => ({ tag: "JAssign",  h0: h0,  h1: h1 });
const Lib_Compile_JUndefined = { tag: "JUndefined" };
const Lib_Compile_LitObject = ( h0 ) => ({ tag: "LitObject",  h0: h0 });
const Lib_Compile_termToJS_go = ( _, _1, _2, _3, _4, _5, _6, e$$7, _$$8, _$$9, _$$10 ) => { switch (_$$8.tag) { case "_::_": return Lib_Compile_termToJS(null, _1, _$$8.h1, ( t$27 ) => (Lib_Compile_termToJS_go(_, _1, _2, _3, _4, _5, _6, null, _$$8.h2, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$9)(1), ( args ) => (_$$10(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("h")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$9)))(""), t$27), args)))))); case "Nil": return _$$10(Prelude_Nil(null)); } };
const Lib_Compile_termToJS = ( e$$0, _$$1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "CConstr": { const go = null; return Lib_Compile_termToJS_go(e$$0, _$$1, _$$2, _$$3, _$$2.h0, _$$2.h1, go, null, _$$2.h1, 0, ( args ) => (_$$3(Lib_Compile_LitObject(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "tag", Lib_Compile_LitString(_$$2.h0)), args))))); break; } case "CErased": return _$$3(Lib_Compile_JUndefined); case "CLetRec": { const nm$27 = Lib_Compile_freshName(_$$2.h0, _$$1); const env$27 = Lib_Compile_push(_$$1, Lib_Compile_Var(nm$27)); const sc$$9 = Lib_Compile_termToJS(null, env$27, _$$2.h1, ( eta ) => (Lib_Compile_JAssign(nm$27, eta))); switch (sc$$9.tag) { case "JAssign": return Lib_Compile_JSnoc(null, Lib_Compile_JConst(nm$27, sc$$9.h1), Lib_Compile_termToJS(null, env$27, _$$2.h2, _$$3)); default: return Lib_Compile_JSnoc(null, Lib_Compile_JLet(nm$27, sc$$9), Lib_Compile_termToJS(null, env$27, _$$2.h2, _$$3)); } break; } case "CLet": { const _sc$$0 = _$$2.h1; switch (_sc$$0.tag) { case "CBnd": { const sc$$8 = Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_sc$$0.h0), Lib_Compile__jsenv(_$$1)); switch (sc$$8.tag) { case "Nothing": return Prelude_fatalError(null, "bad bounds"); case "Just": return Lib_Compile_termToJS(null, Lib_Compile_push(_$$1, sc$$8.h1), _$$2.h2, _$$3); } break; } default: { const nm$27 = Lib_Compile_freshName(_$$2.h0, _$$1); const env$27 = Lib_Compile_push(_$$1, Lib_Compile_Var(nm$27)); const sc$$9 = Lib_Compile_termToJS(null, _$$1, _$$2.h1, ( eta ) => (Lib_Compile_JAssign(nm$27, eta))); switch (sc$$9.tag) { case "JAssign": return Lib_Compile_JSnoc(null, Lib_Compile_JConst(nm$27, sc$$9.h1), Lib_Compile_termToJS(null, env$27, _$$2.h2, _$$3)); default: return Lib_Compile_JSnoc(null, Lib_Compile_JLet(nm$27, sc$$9), Lib_Compile_termToJS(null, env$27, _$$2.h2, _$$3)); } break; } } break; } case "CLit": return _$$3(Lib_Compile_litToJS(_$$2.h0)); case "CMeta": return _$$3(Lib_Compile_LitString(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("META ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h0)))(""))); case "CRef": return _$$3(Lib_Compile_Var(_$$2.h0)); case "CCase": { const termToJSAlt = null; const maybeCaseStmt = null; return Lib_Compile_termToJS(null, _$$1, _$$2.h0, ( $$case ) => { switch ($$case.tag) { case "Var": return Lib_Compile_termToJS_termToJSAlt_maybeCaseStmt(e$$0, _$$1, _$$2, _$$3, _$$2.h0, _$$2.h1, termToJSAlt, maybeCaseStmt, _$$1, $$case.h0, _$$2.h1); default: { const nm = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("_sc$")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Lib_Compile__depth(_$$1))))(""); const env$27 = Lib_Compile_MkEnv(Lib_Compile__jsenv(_$$1), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(Lib_Compile__depth(_$$1))); return Lib_Compile_JSnoc(null, Lib_Compile_JConst(nm, $$case), Lib_Compile_termToJS_termToJSAlt_maybeCaseStmt(e$$0, _$$1, _$$2, _$$3, _$$2.h0, _$$2.h1, termToJSAlt, maybeCaseStmt, env$27, nm, _$$2.h1)); break; } } }); break; } case "CApp": { const etaExpand = null; const argsToJS = null; return Lib_Compile_termToJS(null, _$$1, _$$2.h0, ( t$27 ) => (Lib_Compile_termToJS_etaExpand_argsToJS(e$$0, _$$1, _$$2, _$$3, _$$2.h0, _$$2.h1, _$$2.h2, etaExpand, argsToJS, null, t$27, _$$2.h1, Prelude_Lin(null), _$$3))); break; } case "CFun": { const sc$$6 = Lib_Compile_freshNames(_$$2.h0, _$$1); return _$$3(Lib_Compile_JLam(sc$$6.h2, Lib_Compile_termToJS(null, sc$$6.h3, _$$2.h1, Lib_Compile_JReturn))); break; } case "CLam": { const sc$$6 = Lib_Compile_freshName$27(_$$2.h0, _$$1); return _$$3(Lib_Compile_JLam(Prelude__$3A$3A_(null, sc$$6.h2, Prelude_Nil(null)), Lib_Compile_termToJS(null, sc$$6.h3, _$$2.h1, Lib_Compile_JReturn))); break; } case "CBnd": { const sc$$5 = Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_$$2.h0), Lib_Compile__jsenv(_$$1)); switch (sc$$5.tag) { case "Nothing": return Prelude_fatalError(null, "Bad bounds"); case "Just": return _$$3(sc$$5.h1); } break; } } };
const Lib_Compile_maybeWrap = ( _$$0 ) => { switch (_$$0.tag) { case "JReturn": return _$$0.h0; default: return Lib_Compile_Apply(Lib_Compile_JLam(Prelude_Nil(null), _$$0), Prelude_Nil(null)); } };
const Lib_Common_range = ( _$$0, _$$1 ) => { const sc$$2 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _$$0, _$$1); switch (sc$$2.tag) { case "False": return Prelude_Nil(null); case "True": return Prelude__$3A$3A_(null, _$$0, Lib_Common_range(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0)(1), _$$1)); } };
const Prelude_subInt = (x,y) => x - y
const Prelude_Prelude_Sub$20Prim_Int$2C_$2D_ = ( _$$0, _$$1 ) => (Prelude_subInt(_$$0, _$$1));
const Prelude_MkSub = ( h0, h1 ) => ({ tag: "MkSub",  h0: h0,  h1: h1 });
const Prelude_Prelude_Sub$20Prim_Int = Prelude_MkSub(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Sub$20Prim_Int$2C_$2D_(eta, eta1))));
const Prelude__$2D_ = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_CompileExp_CBnd = ( h0 ) => ({ tag: "CBnd",  h0: h0 });
const Lib_CompileExp_CConstr = ( h0, h1 ) => ({ tag: "CConstr",  h0: h0,  h1: h1 });
const Lib_CompileExp_CFun = ( h0, h1 ) => ({ tag: "CFun",  h0: h0,  h1: h1 });
const Lib_CompileExp_compileDCon = ( _$$0, _$$1 ) => { switch (_$$1) { case 0: return Lib_CompileExp_CConstr(_$$0.h1, Prelude_Nil(null)); default: { const args = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( k ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("h")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(k)))("")))(Lib_Common_range(0, _$$1)); return Lib_CompileExp_CFun(args, Lib_CompileExp_CConstr(_$$0.h1, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( k ) => (Lib_CompileExp_CBnd(Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$1)(k))(1))))(Lib_Common_range(0, _$$1)))); break; } } };
const Lib_Compile_dcon = ( _$$0, _$$1 ) => { const ct = Lib_CompileExp_compileDCon(_$$0, _$$1); const exp = Lib_Compile_maybeWrap(Lib_Compile_termToJS(null, Lib_Compile_emptyJSEnv, ct, Lib_Compile_JReturn)); return Lib_Compile_stmtToDoc(null, Lib_Compile_JConst(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0), exp)); };
const Lib_CompileExp_CRef = ( h0 ) => ({ tag: "CRef",  h0: h0 });
const Lib_CompileExp_CApp = ( h0, h1, h2 ) => ({ tag: "CApp",  h0: h0,  h1: h1,  h2: h2 });
const Lib_CompileExp_apply_go = ( _, _1, _2, _3, _4, _$$5, _$$6 ) => { switch (_$$5.tag) { case "CApp": { const _sc$$0 = _$$5.h1; switch (_sc$$0.tag) { case "Nil": { const _sc$$1 = _$$5.h2; switch (_sc$$1) { case 0: return Lib_CompileExp_apply_go(_, _1, _2, _3, _4, _$$5.h0, _$$6); default: switch (_$$6.tag) { case "_::_": return Lib_CompileExp_apply_go(_, _1, _2, _3, _4, Lib_CompileExp_CApp(_$$5, Prelude__$3A$3A_(null, _$$6.h1, Prelude_Nil(null)), 0), _$$6.h2); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$5); } break; } break; } default: switch (_$$6.tag) { case "_::_": return Lib_CompileExp_apply_go(_, _1, _2, _3, _4, Lib_CompileExp_CApp(_$$5, Prelude__$3A$3A_(null, _$$6.h1, Prelude_Nil(null)), 0), _$$6.h2); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$5); } break; } break; } default: switch (_$$6.tag) { case "_::_": return Lib_CompileExp_apply_go(_, _1, _2, _3, _4, Lib_CompileExp_CApp(_$$5, Prelude__$3A$3A_(null, _$$6.h1, Prelude_Nil(null)), 0), _$$6.h2); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$5); } break; } };
const Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int$2Ccast = Prelude_natToInt;
const Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int = Prelude_MkCast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int$2Ccast);
const Lib_CompileExp_apply = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "S": switch (_$$1.tag) { case "_::_": return Lib_CompileExp_apply(_$$0, _$$1.h2, Prelude__$3A$3C_(null, _$$2, _$$1.h1), _$$3.h0); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CApp(_$$0, Prelude__$3C$3E$3E_(null, _$$2, Prelude_Nil(null)), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(_$$3.h0)))); } break; case "Z": { const go = null; return Lib_CompileExp_apply_go(_$$0, _$$1, _$$2, _$$3, go, Lib_CompileExp_CApp(_$$0, Prelude__$3C$3E$3E_(null, _$$2, Prelude_Nil(null)), 0), _$$1); break; } } };
const Lib_CompileExp_lamArity = ( _$$0 ) => { switch (_$$0.tag) { case "Lam": return Prelude_S(Lib_CompileExp_lamArity(_$$0.h4)); default: return Prelude_Z; } };
const Prelude_snd = ( a$$0, b$$1, _$$2 ) => (_$$2.h3);
const Data_SortedMap_lookupMap$27 = ( k$$0, v$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "MapOf": return Prelude__$3C$$$3E_(null, Prelude_Prelude_Functor$20Prelude_Maybe, null, null, ( eta ) => (Prelude_snd(null, null, eta)), Data_SortedMap_lookupT23(null, null, null, _$$2, _$$3, _$$4.h3)); case "EmptyMap": return Prelude_Nothing(null); } };
const Lib_Ref2_Defs = { tag: "Defs" };
const Data_IORef_primReadIORef = (_, ref) => (w) => Prelude_MkIORes(null, ref[0], w)
const Data_IORef_readIORef = ( io$$0, a$$1, _$$2, _$$3 ) => (Prelude_liftIO(null, _$$2)(null)(Data_IORef_primReadIORef(null, _$$3)));
const Lib_Ref2_getRef = ( io$$0, a$$1, _$$2, l$$3, _$$4 ) => (Data_IORef_readIORef(null, null, _$$2, _$$4.h2));
const Lib_CompileExp_arityForName = ( _$$0, _$$1, _$$2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Ref2_getRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$0), ( defs ) => { const sc$$4 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$2, defs); switch (sc$$4.tag) { case "Nothing": return Lib_Types_error(null, _$$1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Name ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$2)))(" not in scope")); case "Just": { const _sc$$0 = sc$$4.h1; switch (_sc$$0.tag) { case "PrimFn": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_sc$$0.h1); case "PrimTCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_sc$$0.h0)); case "Fn": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_lamArity(_sc$$0.h0)); case "DCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_sc$$0.h0)); case "TCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_sc$$0.h0)); case "Axiom": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Z); } break; } } }));
const Lib_CompileExp_CLam = ( h0, h1 ) => ({ tag: "CLam",  h0: h0,  h1: h1 });
const Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap = ( a$$0, b$$1, _$$2, _$$3 ) => (Lib_Types_MkM(null, ( tc ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, _$$3.h1(tc), ( $$sc ) => { switch ($$sc.tag) { case "Right": { const _sc$$0 = $$sc.h2; return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, _sc$$0.h2, _$$2(_sc$$0.h3)))); break; } case "Left": return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Left(null, null, $$sc.h2)); } }))));
const Lib_Types_Prelude_Functor$20Lib_Types_M = Prelude_MkFunctor(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Types_Prelude_Functor$20Lib_Types_M$2Cmap(null, null, eta, eta1))))));
const Prelude_traverse = ( t$$0, _$$1 ) => (( f ) => (( a ) => (( b ) => (( _ ) => (_$$1.h1(null)(null)(null)(_))))));
const Prelude__$3C$2A$3E_ = ( f$$0, _$$1 ) => (( a ) => (( b ) => (_$$1.h2(null)(null))));
const Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse = ( f$$0, a$$1, b$$2, _$$3, _$$4, _$$5 ) => { switch (_$$5.tag) { case "_::_": return Prelude__$3C$2A$3E_(null, _$$3)(null)(null)(Prelude__$3C$2A$3E_(null, _$$3)(null)(null)(Prelude_return(null, _$$3)(null)(( eta ) => (( eta1 ) => (Prelude__$3A$3A_(null, eta, eta1)))))(_$$4(_$$5.h1)))(Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(_$$3)(_$$4)(_$$5.h2)); case "Nil": return Prelude_return(null, _$$3)(null)(Prelude_Nil(null)); } };
const Prelude_MkTraversable = ( h0, h1 ) => ({ tag: "MkTraversable",  h0: h0,  h1: h1 });
const Prelude_Prelude_Traversable$20Prelude_List = Prelude_MkTraversable(null, ( f ) => (( a ) => (( b ) => (( _ ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Traversable$20Prelude_List$2Ctraverse(null, null, null, _, eta, eta1))))))));
const Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "Many": return ""; case "Zero": return "0 "; } };
const Lib_Types_Prelude_Show$20Lib_Types_Quant = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_Quant$2Cshow);
const Lib_Types_parens = ( _$$0, _$$1, _$$2 ) => { const sc$$3 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _$$0, _$$1); switch (sc$$3.tag) { case "False": return _$$2; case "True": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$2)(Lib_Prettier_text(")"))); } };
const Lib_Prettier_spread = ( eta ) => (Lib_Prettier_folddoc(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc), eta));
const Prelude_jsShow = (_,a) => ''+a
const Prelude_Prelude_Show$20Prim_Char$2Cshow = ( _$$0 ) => (Prelude_jsShow(null, _$$0));
const Prelude_Prelude_Show$20Prim_Char = Prelude_MkShow(null, Prelude_Prelude_Show$20Prim_Char$2Cshow);
const Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "LChar": return Prelude_show(null, Prelude_Prelude_Show$20Prim_Char)(_$$0.h0); case "LInt": return Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h0); case "LString": return Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h0); } };
const Lib_Types_Prelude_Show$20Lib_Types_Literal = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_Literal$2Cshow);
const Lib_Types_pprintAlt = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "CaseLit": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$2.h0)))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2B$2F$3E_(Lib_Prettier_text("=>"), Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Types_pprint$27(_$$0, _$$1, _$$2.h1))(Lib_Prettier_text(";"))))); case "CaseCons": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$2.h0)))(Lib_Prettier_spread(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_text)(_$$2.h1))))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2B$2F$3E_(Lib_Prettier_text("=>"), Lib_Types_pprint$27(_$$0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(Prelude_reverse(null)(_$$2.h1))(_$$1), _$$2.h2)))); case "CaseDefault": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("_"))(Lib_Prettier_text("=>")))(Lib_Types_pprint$27(_$$0, Prelude__$3A$3A_(null, "_", _$$1), _$$2.h0)); } };
const Lib_Types_pprint$27 = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "Erased": return Lib_Prettier_text("ERASED"); case "Lit": return Lib_Prettier_text(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$2.h1)); case "LetRec": return Lib_Types_parens(0, _$$0, Lib_Prettier__$3C$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("letrec"))(Lib_Prettier_text(_$$2.h1)))(Lib_Prettier_text(":")))(Lib_Types_pprint$27(0, _$$1, _$$2.h2)))(Lib_Prettier_text(":=")))(Lib_Types_pprint$27(0, _$$1, _$$2.h3)))(Lib_Prettier_text("in")), Lib_Prettier_nest(2)(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h4)))); case "Let": return Lib_Types_parens(0, _$$0, Lib_Prettier__$3C$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("let"))(Lib_Prettier_text(_$$2.h1)))(Lib_Prettier_text(":=")))(Lib_Types_pprint$27(0, _$$1, _$$2.h2)))(Lib_Prettier_text("in")), Lib_Prettier_nest(2)(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h3)))); case "Case": return Lib_Types_parens(0, _$$0, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("case"))(Lib_Types_pprint$27(0, _$$1, _$$2.h1)))(Lib_Prettier_text("of")))(Lib_Prettier_nest(2)(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_line)(Lib_Prettier_stack(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Types_pprintAlt(0, _$$1, eta)))(_$$2.h2)))))); case "Pi": { const _sc$$0 = _$$2.h2; switch (_sc$$0.tag) { case "Auto": return Lib_Types_parens(0, _$$0, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("{{"))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$2.h3)))(Lib_Prettier_text(_$$2.h1)))(Lib_Prettier_text(":")))(Lib_Types_pprint$27(0, _$$1, _$$2.h4)))(Lib_Prettier_text("}}")))(Lib_Prettier_text("->")))(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h5)))); case "Explicit": { const _sc$$1 = _$$2.h3; switch (_sc$$1.tag) { case "Many": { const _sc$$2 = _$$2.h1; switch (_sc$$2) { case "_": return Lib_Types_parens(0, _$$0, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Types_pprint$27(1, _$$1, _$$2.h4))(Lib_Prettier_text("->")))(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, "_", _$$1), _$$2.h5))); default: return Lib_Types_parens(0, _$$0, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$2.h3)))(Lib_Prettier_text(_$$2.h1)))(Lib_Prettier_text(":")))(Lib_Types_pprint$27(0, _$$1, _$$2.h4)))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(")"))(Lib_Prettier_text("->")))(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h5))))); } break; } default: return Lib_Types_parens(0, _$$0, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$2.h3)))(Lib_Prettier_text(_$$2.h1)))(Lib_Prettier_text(":")))(Lib_Types_pprint$27(0, _$$1, _$$2.h4)))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(")"))(Lib_Prettier_text("->")))(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h5))))); } break; } case "Implicit": return Lib_Types_parens(0, _$$0, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("{"))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$2.h3)))(Lib_Prettier_text(_$$2.h1)))(Lib_Prettier_text(":")))(Lib_Types_pprint$27(0, _$$1, _$$2.h4)))(Lib_Prettier_text("}")))(Lib_Prettier_text("->")))(Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h5)))); } break; } case "UU": return Lib_Prettier_text("U"); case "App": return Lib_Types_parens(0, _$$0, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Types_pprint$27(0, _$$1, _$$2.h1))(Lib_Types_pprint$27(1, _$$1, _$$2.h2))); case "Lam": return Lib_Types_parens(0, _$$0, Lib_Prettier_nest(2)(Lib_Prettier__$3C$2B$2F$3E_(Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("\\ ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$2.h3)))(""))(_$$2.h1))(" =>")), Lib_Types_pprint$27(0, Prelude__$3A$3A_(null, _$$2.h1, _$$1), _$$2.h4)))); case "Meta": return Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("?m:")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$2.h1)))("")); case "Ref": return Lib_Prettier_text(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$2.h1)); case "Bnd": { const sc$$5 = Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_$$2.h1), _$$1); switch (sc$$5.tag) { case "Nothing": return Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("BND:")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))("")); case "Just": return Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(sc$$5.h1))(":"))(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))("")); } break; } } };
const Lib_Types_pprint = ( _$$0, _$$1 ) => (Lib_Types_pprint$27(0, _$$0, _$$1));
const Prelude_force = ( a$$0, _$$1 ) => (_$$1(Prelude_MkUnit));
const Lib_Types__verbose = ( _$$0 ) => (_$$0.h5);
const Prelude_when = ( f$$0, _$$1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "False": return Prelude_return(null, _$$1)(null)(Prelude_MkUnit); case "True": return Prelude_force(null, _$$3); } };
const Lib_Types_getTop = Lib_Types_MkM(null, ( tc ) => (Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, tc, tc)))));
const Lib_Types_log = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3C$3D_(null, Prelude_Prelude_Ord$20Prim_Int, _$$0, Lib_Types__verbose(top)), ( _ ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude_force(null, _$$1)))))));
const Lib_Types_debug = ( _$$0 ) => (Lib_Types_log(2, _$$0));
const Data_String_unwords = ( _$$0 ) => (Prelude_joinBy(" ", _$$0));
const Lib_Types_showCaseAlt = ( _$$0 ) => { switch (_$$0.tag) { case "CaseLit": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$0.h0)))(" => "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h1)))(""); case "CaseCons": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h0)))(" "))(Data_String_unwords(_$$0.h1)))(" => "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h2)))(""); case "CaseDefault": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("_ => ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h0)))(""); } };
const Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow = ( a$$0, _$$1, _$$2 ) => (Prelude_joinBy(", ", Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Prelude_show(null, _$$1))(_$$2)));
const Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29 = ( a, _ ) => (Prelude_MkShow(null, ( eta ) => (Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29$2Cshow(null, _, eta))));
const Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "Erased": return "ERASED"; case "Lit": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Lit ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$0.h1)))(")"); case "LetRec": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(LetRec ")(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h2)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h3)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h4)))(")"); case "Let": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Let ")(_$$0.h1))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h2)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h3)))(")"); case "Case": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Case ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Types_showCaseAlt)(_$$0.h2))))(")"); case "Pi": { const _sc$$0 = _$$0.h2; switch (_sc$$0.tag) { case "Auto": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Pi {{")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(""))(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h4)))("}} => "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h5)))(")"); case "Explicit": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Pi (")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(""))(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h4)))(") => "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h5)))(")"); case "Implicit": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Pi {")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(""))(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h4)))("} => "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h5)))(")"); } break; } case "UU": return "U"; case "App": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h1)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h2)))(")"); case "Lam": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(\\ ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(""))(_$$0.h1))("  => "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h4)))(")"); case "Meta": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(")"); case "Ref": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Ref ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(")"); case "Bnd": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(Bnd ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h1)))(")"); } };
const Lib_Types_Prelude_Show$20Lib_Types_Tm = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_Tm$2Cshow);
const Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case "Erased": return _$$0.h0; case "Lit": return _$$0.h0; case "LetRec": return _$$0.h0; case "Let": return _$$0.h0; case "Case": return _$$0.h0; case "Pi": return _$$0.h0; case "UU": return _$$0.h0; case "App": return _$$0.h0; case "Lam": return _$$0.h0; case "Meta": return _$$0.h0; case "Ref": return _$$0.h0; case "Bnd": return _$$0.h0; } };
const Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm = Lib_Common_MkHasFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm$2CgetFC);
const Lib_Util_funArgs_go = ( _, _1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "App": return Lib_Util_funArgs_go(_, _1, _$$2.h1, Prelude__$3A$3A_(null, _$$2.h2, _$$3)); default: return Prelude__$2C_(null, null, _$$2, _$$3); } };
const Lib_Util_funArgs = ( _$$0 ) => { const go = null; return Lib_Util_funArgs_go(_$$0, go, _$$0, Prelude_Nil(null)); };
const Lib_CompileExp_CCase = ( h0, h1 ) => ({ tag: "CCase",  h0: h0,  h1: h1 });
const Lib_CompileExp_CDefAlt = ( h0 ) => ({ tag: "CDefAlt",  h0: h0 });
const Lib_CompileExp_CConAlt = ( h0, h1, h2 ) => ({ tag: "CConAlt",  h0: h0,  h1: h1,  h2: h2 });
const Lib_CompileExp_CLitAlt = ( h0, h1 ) => ({ tag: "CLitAlt",  h0: h0,  h1: h1 });
const Prelude_for = ( t$$0, f$$1, _$$2, appf$$3, a$$4, b$$5, _$$6, _$$7 ) => (Prelude_traverse(null, _$$2)(null)(null)(null)(appf$$3)(_$$7)(_$$6));
const Lib_CompileExp_CLet = ( h0, h1, h2 ) => ({ tag: "CLet",  h0: h0,  h1: h1,  h2: h2 });
const Lib_CompileExp_CLetRec = ( h0, h1, h2 ) => ({ tag: "CLetRec",  h0: h0,  h1: h1,  h2: h2 });
const Lib_CompileExp_CLit = ( h0 ) => ({ tag: "CLit",  h0: h0 });
const Lib_CompileExp_CErased = { tag: "CErased" };
const Lib_CompileExp_compileTerm = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Erased": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CErased); case "Lit": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CLit(_$$1.h1)); case "LetRec": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h3), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h4), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CLetRec(_$$1.h1, t$27, u$27)))))); case "Let": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h2), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h3), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CLet(_$$1.h1, t$27, u$27)))))); case "Case": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h1), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h2, ( $$case ) => { switch ($$case.tag) { case "CaseLit": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_CompileExp_CLitAlt($$case.h0, eta)), Lib_CompileExp_compileTerm(_$$0, $$case.h1)); case "CaseCons": { const _sc$$0 = $$case.h0; return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_CompileExp_CConAlt(_sc$$0.h1, $$case.h1, eta)), Lib_CompileExp_compileTerm(_$$0, $$case.h2)); break; } case "CaseDefault": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Lib_CompileExp_CDefAlt, Lib_CompileExp_compileTerm(_$$0, $$case.h0)); } }), ( alts$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CCase(t$27, alts$27)))))); case "Pi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h4), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, _$$1.h5), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CApp(Lib_CompileExp_CRef("PiType"), Prelude__$3A$3A_(null, t$27, Prelude__$3A$3A_(null, Lib_CompileExp_CLam(_$$1.h1, u$27), Prelude_Nil(null))), 0)))))); case "UU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CRef("U")); case "App": { const sc$$5 = Lib_Util_funArgs(_$$1); const _sc$$0 = sc$$5.h2; switch (_sc$$0.tag) { case "Meta": return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$1), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Compiling an unsolved meta ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$1)))("")); case "Ref": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_CompileExp_compileTerm(_$$0, eta)))(sc$$5.h3), ( args$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_arityForName(_$$0, _sc$$0.h0, _sc$$0.h1), ( arity ) => (Lib_CompileExp_apply(Lib_CompileExp_CRef(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)), args$27, Prelude_Lin(null), arity))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("apply other ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), sc$$5.h2))))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileTerm(_$$0, sc$$5.h2), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_CompileExp_compileTerm(_$$0, eta)))(sc$$5.h3), ( args$27 ) => (Lib_CompileExp_apply(t$27, args$27, Prelude_Lin(null), Prelude_Z))))))); } break; } case "Lam": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_CompileExp_CLam(_$$1.h1, eta)), Lib_CompileExp_compileTerm(_$$0, _$$1.h4)); case "Meta": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CRef(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("meta$")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h1)))(""))); case "Ref": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_arityForName(_$$0, _$$1.h0, _$$1.h1), ( arity ) => { switch (arity.tag) { case "S": { const _sc$$0 = arity.h0; switch (_sc$$0.tag) { case "Z": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CRef(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h1))); default: return Lib_CompileExp_apply(Lib_CompileExp_CRef(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h1)), Prelude_Nil(null), Prelude_Lin(null), arity); } break; } default: return Lib_CompileExp_apply(Lib_CompileExp_CRef(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h1)), Prelude_Nil(null), Prelude_Lin(null), arity); } }); case "Bnd": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_CompileExp_CBnd(_$$1.h1)); } };
const Lib_CompileExp_compileFun_go = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$3.tag) { case "Lam": return Lib_CompileExp_compileFun_go(_, _1, _2, _$$3.h4, Prelude__$3A$3C_(null, _$$4, _$$3.h1)); default: switch (_$$4.tag) { case "Lin": return Lib_CompileExp_compileTerm(_, _$$3); default: return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_CompileExp_CFun(Prelude__$3C$3E$3E_(null, _$$4, Prelude_Nil(null)), eta)), Lib_CompileExp_compileTerm(_, _$$3)); } break; } };
const Lib_CompileExp_compileFun = ( _$$0, _$$1 ) => { const go = null; return Lib_CompileExp_compileFun_go(_$$0, _$$1, go, _$$1, Prelude_Lin(null)); };
const Lib_Compile_defToDoc = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "PrimFn": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("const"))(Lib_Compile_jsIdent(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1))))(Lib_Prettier_text("=")))(Lib_Prettier_text(_$$2.h0))); case "PrimTCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Compile_dcon(_$$1, _$$2.h0)); case "Fn": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("compileFun ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), _$$2.h0))))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_CompileExp_compileFun(_$$0, _$$2.h0), ( ct ) => { const exp = Lib_Compile_maybeWrap(Lib_Compile_termToJS(null, Lib_Compile_emptyJSEnv, ct, Lib_Compile_JReturn)); return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("const"))(Lib_Compile_jsIdent(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1))))(Lib_Prettier_text("=")), Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Compile_expToDoc(exp))(Lib_Prettier_text(";")))); }))); case "DCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Compile_dcon(_$$1, _$$2.h0)); case "TCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Compile_dcon(_$$1, _$$2.h0)); case "Axiom": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Prettier_text("")); } };
const Prelude_uncurry = ( a$$0, b$$1, c$$2, _$$3, _$$4 ) => (_$$3(_$$4.h2)(_$$4.h3));
const Prelude_mapM = ( m$$0, _$$1, a$$2, b$$3, _$$4, _$$5 ) => { switch (_$$5.tag) { case "_::_": return Prelude__$3E$3E$3D_(null, null, null, _$$1, _$$4(_$$5.h1), ( b ) => (Prelude__$3E$3E$3D_(null, null, null, _$$1, Prelude_mapM(null, _$$1, null, null, _$$4, _$$5.h2), ( bs ) => (Prelude_pure(null, _$$1)(null)(Prelude__$3A$3A_(null, b, bs)))))); case "Nil": return Prelude_pure(null, _$$1)(null)(Prelude_Nil(null)); } };
const Lib_Compile_getNames_getAltNames = ( _, _1, _2, _3, _4, _5, _$$6, _$$7 ) => { switch (_$$7.tag) { case "CaseLit": return Lib_Compile_getNames(_$$7.h1, _$$6); case "CaseCons": return Lib_Compile_getNames(_$$7.h2, _$$6); case "CaseDefault": return Lib_Compile_getNames(_$$7.h0, _$$6); } };
const Prelude_foldl = ( A$$0, B$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "_::_": return Prelude_foldl(null, null, _$$2, _$$2(_$$3)(_$$4.h1), _$$4.h2); case "Nil": return _$$3; } };
const Lib_Compile_getNames = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "LetRec": return Lib_Compile_getNames(_$$0.h4, Lib_Compile_getNames(_$$0.h3, _$$1)); case "Let": return Lib_Compile_getNames(_$$0.h3, Lib_Compile_getNames(_$$0.h2, _$$1)); case "Case": { const getAltNames = null; return Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_Compile_getNames_getAltNames(_$$0, _$$1, _$$0.h0, _$$0.h1, _$$0.h2, getAltNames, eta, eta1))), _$$1, _$$0.h2); break; } case "Pi": return Lib_Compile_getNames(_$$0.h5, Lib_Compile_getNames(_$$0.h4, _$$1)); case "App": return Lib_Compile_getNames(_$$0.h2, Lib_Compile_getNames(_$$0.h1, _$$1)); case "Lam": return Lib_Compile_getNames(_$$0.h4, _$$1); case "Ref": return Prelude__$3A$3A_(null, _$$0.h1, _$$1); default: return _$$1; } };
const Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude__$26$26_(Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$0.h1)(_$$1.h1), Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Eq$20Prim_String))(_$$0.h0)(_$$1.h0)));
const Lib_Common_Prelude_Eq$20Lib_Common_QName = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Lib_Common_Prelude_Eq$20Lib_Common_QName$2C_$3D$3D_(eta, eta1))));
const Lib_Compile_sortedNames_go = ( _, _1, _2, _$$3, _$$4, _$$5 ) => { const sc$$6 = Prelude__$7C$7C_(Prelude_elem(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _$$5, _$$3), Prelude_elem(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _$$5, _$$4)); switch (sc$$6.tag) { case "False": { const sc$$7 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$5, _); switch (sc$$7.tag) { case "Nothing": return _$$4; case "Just": { const _sc$$0 = sc$$7.h1; switch (_sc$$0.tag) { case "PrimFn": return Prelude__$3A$3A_(null, _$$5, Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_Compile_sortedNames_go(_, _1, _2, Prelude__$3A$3A_(null, _$$5, _$$3), eta, eta1))), _$$4, _sc$$0.h2)); case "Fn": return Prelude__$3A$3A_(null, _$$5, Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_Compile_sortedNames_go(_, _1, _2, Prelude__$3A$3A_(null, _$$5, _$$3), eta, eta1))), _$$4, Lib_Compile_getNames(_sc$$0.h0, Prelude_Nil(null)))); default: return Prelude__$3A$3A_(null, _$$5, _$$4); } break; } } break; } case "True": return _$$4; } };
const Lib_Compile_sortedNames = ( _$$0, _$$1 ) => { const go = null; return Lib_Compile_sortedNames_go(_$$0, _$$1, go, Prelude_Nil(null), Prelude_Nil(null), _$$1); };
const Lib_TCO_tailCallOpt = ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Ref2_getRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _), ( defs ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, "TODO TCO"))));
const Data_SortedMap_toList_go = ( _, _1, _2, _3, _4, _5, _6, _7, h$$8, _$$9, _$$10 ) => { switch (_$$9.tag) { case "Node3": return Data_SortedMap_toList_go(_, _1, _2, _3, _4, _5, _6, _7, null, _$$9.h7, Data_SortedMap_toList_go(_, _1, _2, _3, _4, _5, _6, _7, null, _$$9.h5, Data_SortedMap_toList_go(_, _1, _2, _3, _4, _5, _6, _7, null, _$$9.h3, _$$10))); case "Node2": return Data_SortedMap_toList_go(_, _1, _2, _3, _4, _5, _6, _7, null, _$$9.h5, Data_SortedMap_toList_go(_, _1, _2, _3, _4, _5, _6, _7, null, _$$9.h3, _$$10)); case "Leaf": return Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$9.h2, _$$9.h3), _$$10); } };
const Data_SortedMap_toList = ( k$$0, v$$1, _$$2 ) => { switch (_$$2.tag) { case "MapOf": { const go = null; return Prelude_reverse(null)(Data_SortedMap_toList_go(k$$0, v$$1, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, go, null, _$$2.h3, Prelude_Nil(null))); break; } default: return Prelude_Nil(null); } };
const Lib_Types_Fn = ( h0 ) => ({ tag: "Fn",  h0: h0 });
const Data_SortedMap_Leaf = ( h0, h1, h2, h3 ) => ({ tag: "Leaf",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Data_SortedMap_MapOf = ( h0, h1, h2, h3 ) => ({ tag: "MapOf",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Data_SortedMap_Node2 = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: "Node2",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
const Data_SortedMap_Node3 = ( h0, h1, h2, h3, h4, h5, h6, h7 ) => ({ tag: "Node3",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5,  h6: h6,  h7: h7 });
const Data_SortedMap_insertT23 = ( h$$0, k$$1, v$$2, _$$3, _$$4, _$$5, _$$6 ) => { switch (_$$6.tag) { case "Node3": { const sc$$15 = Prelude__$3C$3D_(null, _$$3, _$$4, _$$6.h4); switch (sc$$15.tag) { case "False": { const sc$$16 = Prelude__$3C$3D_(null, _$$3, _$$4, _$$6.h6); switch (sc$$16.tag) { case "False": { const sc$$17 = Data_SortedMap_insertT23(null, null, null, _$$3, _$$4, _$$5, _$$6.h7); switch (sc$$17.tag) { case "Right": { const _sc$$0 = sc$$17.h2; const _sc$$1 = _sc$$0.h3; return Prelude_Right(null, null, Prelude__$2C_(null, null, Data_SortedMap_Node2(null, null, null, _$$6.h3, _$$6.h4, _$$6.h5), Prelude__$2C_(null, null, _$$6.h6, Data_SortedMap_Node2(null, null, null, _sc$$0.h2, _sc$$1.h2, _sc$$1.h3)))); break; } case "Left": return Prelude_Left(null, null, Data_SortedMap_Node3(null, null, null, _$$6.h3, _$$6.h4, _$$6.h5, _$$6.h6, sc$$17.h2)); } break; } case "True": { const sc$$17 = Data_SortedMap_insertT23(null, null, null, _$$3, _$$4, _$$5, _$$6.h5); switch (sc$$17.tag) { case "Right": { const _sc$$0 = sc$$17.h2; const _sc$$1 = _sc$$0.h3; return Prelude_Right(null, null, Prelude__$2C_(null, null, Data_SortedMap_Node2(null, null, null, _$$6.h3, _$$6.h4, _sc$$0.h2), Prelude__$2C_(null, null, _sc$$1.h2, Data_SortedMap_Node2(null, null, null, _sc$$1.h3, _$$6.h6, _$$6.h7)))); break; } case "Left": return Prelude_Left(null, null, Data_SortedMap_Node3(null, null, null, _$$6.h3, _$$6.h4, sc$$17.h2, _$$6.h6, _$$6.h7)); } break; } } break; } case "True": { const sc$$16 = Data_SortedMap_insertT23(null, null, null, _$$3, _$$4, _$$5, _$$6.h3); switch (sc$$16.tag) { case "Right": { const _sc$$0 = sc$$16.h2; const _sc$$1 = _sc$$0.h3; return Prelude_Right(null, null, Prelude__$2C_(null, null, Data_SortedMap_Node2(null, null, null, _sc$$0.h2, _sc$$1.h2, _sc$$1.h3), Prelude__$2C_(null, null, _$$6.h4, Data_SortedMap_Node2(null, null, null, _$$6.h5, _$$6.h6, _$$6.h7)))); break; } case "Left": return Prelude_Left(null, null, Data_SortedMap_Node3(null, null, null, sc$$16.h2, _$$6.h4, _$$6.h5, _$$6.h6, _$$6.h7)); } break; } } break; } case "Node2": { const sc$$13 = Prelude__$3C$3D_(null, _$$3, _$$4, _$$6.h4); switch (sc$$13.tag) { case "False": { const sc$$14 = Data_SortedMap_insertT23(null, null, null, _$$3, _$$4, _$$5, _$$6.h5); switch (sc$$14.tag) { case "Right": { const _sc$$0 = sc$$14.h2; const _sc$$1 = _sc$$0.h3; return Prelude_Left(null, null, Data_SortedMap_Node3(null, null, null, _$$6.h3, _$$6.h4, _sc$$0.h2, _sc$$1.h2, _sc$$1.h3)); break; } case "Left": return Prelude_Left(null, null, Data_SortedMap_Node2(null, null, null, _$$6.h3, _$$6.h4, sc$$14.h2)); } break; } case "True": { const sc$$14 = Data_SortedMap_insertT23(null, null, null, _$$3, _$$4, _$$5, _$$6.h3); switch (sc$$14.tag) { case "Right": { const _sc$$0 = sc$$14.h2; const _sc$$1 = _sc$$0.h3; return Prelude_Left(null, null, Data_SortedMap_Node3(null, null, null, _sc$$0.h2, _sc$$1.h2, _sc$$1.h3, _$$6.h4, _$$6.h5)); break; } case "Left": return Prelude_Left(null, null, Data_SortedMap_Node2(null, null, null, sc$$14.h2, _$$6.h4, _$$6.h5)); } break; } } break; } case "Leaf": { const sc$$11 = Prelude_compare(null, _$$3)(_$$4)(_$$6.h2); switch (sc$$11.tag) { case "GT": return Prelude_Right(null, null, Prelude__$2C_(null, null, Data_SortedMap_Leaf(null, null, _$$6.h2, _$$6.h3), Prelude__$2C_(null, null, _$$6.h2, Data_SortedMap_Leaf(null, null, _$$4, _$$5)))); case "EQ": return Prelude_Left(null, null, Data_SortedMap_Leaf(null, null, _$$4, _$$5)); case "LT": return Prelude_Right(null, null, Prelude__$2C_(null, null, Data_SortedMap_Leaf(null, null, _$$4, _$$5), Prelude__$2C_(null, null, _$$4, Data_SortedMap_Leaf(null, null, _$$6.h2, _$$6.h3)))); } break; } } };
const Data_SortedMap_updateMap = ( k$$0, v$$1, _$$2, _$$3, _$$4, _$$5 ) => { switch (_$$5.tag) { case "MapOf": { const sc$$10 = Data_SortedMap_insertT23(null, null, null, _$$2, _$$3, _$$4, _$$5.h3); switch (sc$$10.tag) { case "Right": { const _sc$$0 = sc$$10.h2; const _sc$$1 = _sc$$0.h3; return Data_SortedMap_MapOf(null, null, Prelude_S(_$$5.h2), Data_SortedMap_Node2(null, null, null, _sc$$0.h2, _sc$$1.h2, _sc$$1.h3)); break; } case "Left": return Data_SortedMap_MapOf(null, null, _$$5.h2, sc$$10.h2); } break; } case "EmptyMap": return Data_SortedMap_MapOf(null, null, Prelude_Z, Data_SortedMap_Leaf(null, null, _$$3, _$$4)); } };
const Data_IORef_primWriteIORef = (_, ref, a) => (w) => {
  ref[0] = a
  return Prelude_MkIORes(null,Prelude_MkUnit,w)
}
const Data_IORef_writeIORef = ( io$$0, a$$1, _$$2, _$$3, _$$4 ) => (Prelude_liftIO(null, _$$2)(null)(Data_IORef_primWriteIORef(null, _$$3, _$$4)));
const Data_IORef_modifyIORef = ( io$$0, a$$1, _$$2, _$$3, _$$4, _$$5 ) => (Prelude_bind(null, _$$2)(null)(null)(Data_IORef_readIORef(null, null, _$$3, _$$4))(( a ) => (Data_IORef_writeIORef(null, null, _$$3, _$$4, _$$5(a)))));
const Lib_Ref2_modifyRef = ( io$$0, a$$1, _$$2, l$$3, _$$4, _$$5 ) => (Prelude_liftIO(null, _$$2)(null)(Data_IORef_modifyIORef(null, null, Prelude_Prelude_Monad$20Prelude_IO, Prelude_Prelude_HasIO$20Prelude_IO, _$$4.h2, _$$5)));
const Lib_Types_Ref = ( h0, h1 ) => ({ tag: "Ref",  h0: h0,  h1: h1 });
const Prelude_length$27_go = ( _, _1, _2, a$$3, _$$4, _$$5 ) => { switch (_$$4.tag) { case "_::_": return Prelude_length$27_go(_, _1, _2, null, _$$4.h2, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$5)(1)); case "Nil": return _$$5; } };
const Prelude_length$27 = ( a$$0, _$$1 ) => { const go = null; return Prelude_length$27_go(a$$0, _$$1, go, null, _$$1, 0); };
const Lib_Types_Bnd = ( h0, h1 ) => ({ tag: "Bnd",  h0: h0,  h1: h1 });
const Lib_Types_App = ( h0, h1, h2 ) => ({ tag: "App",  h0: h0,  h1: h1,  h2: h2 });
const Lib_LiftWhere_liftWhereTm_apply = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8, _$$9 ) => { switch (_$$8) { case 0: return _$$9; default: return Lib_Types_App(_4, Lib_LiftWhere_liftWhereTm_apply(_, _1, _2, _3, _4, _5, _6, _$$7, Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$8)(1), _$$9), Lib_Types_Bnd(_4, Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$7)(_$$8))); } };
const Lib_Types_Lam = ( h0, h1, h2, h3, h4 ) => ({ tag: "Lam",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Types_Pi = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: "Pi",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
const Lib_Types_Case = ( h0, h1, h2 ) => ({ tag: "Case",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_CaseDefault = ( h0 ) => ({ tag: "CaseDefault",  h0: h0 });
const Prelude_const = ( a$$0, b$$1, _$$2, _$$3 ) => (_$$2);
const Lib_Types_CaseCons = ( h0, h1, h2 ) => ({ tag: "CaseCons",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_CaseLit = ( h0, h1 ) => ({ tag: "CaseLit",  h0: h0,  h1: h1 });
const Lib_LiftWhere_liftWhereTm_liftWhereAlt = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8 ) => { switch (_$$8.tag) { case "CaseLit": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_CaseLit(_$$8.h0, eta)), Lib_LiftWhere_liftWhereTm(_, _1, _2, _$$8.h1)); case "CaseCons": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_CaseCons(_$$8.h0, _$$8.h1, eta)), Lib_LiftWhere_liftWhereTm(_, _1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_const(null, null, Prelude_Nothing(null), eta)))(_$$8.h1))(_2), _$$8.h2)); case "CaseDefault": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Lib_Types_CaseDefault, Lib_LiftWhere_liftWhereTm(_, _1, _2, _$$8.h0)); } };
const Lib_Types_Let = ( h0, h1, h2, h3 ) => ({ tag: "Let",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Types_Erased = ( h0 ) => ({ tag: "Erased",  h0: h0 });
const Lib_Types_LetRec = ( h0, h1, h2, h3, h4 ) => ({ tag: "LetRec",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Types_Many = { tag: "Many" };
const Lib_Types_Explicit = { tag: "Explicit" };
const Lib_LiftWhere_liftWhereTm_getName_wrapPi_wrapLam = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$12, _$$13 ) => { switch (_$$12.tag) { case "S": return Lib_Types_Lam(_4, "_", Lib_Types_Explicit, Lib_Types_Many, Lib_LiftWhere_liftWhereTm_getName_wrapPi_wrapLam(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$12.h0, _$$13)); case "Z": return _$$13; } };
const Lib_Common_QN = ( h0, h1 ) => ({ tag: "QN",  h0: h0,  h1: h1 });
const Lib_LiftWhere_liftWhereTm_getName = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$10, _$$11 ) => { const qn$27 = Lib_Common_QN(_$$10.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$10.h1)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(".")(_$$11))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Ref2_getRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _), ( top ) => { const sc$$16 = Data_SortedMap_lookupMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, qn$27, top); switch (sc$$16.tag) { case "Just": return Lib_LiftWhere_liftWhereTm_getName(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$10, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$11)("'")); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(qn$27); } }); };
const Prelude_length = ( a$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": return Prelude_S(Prelude_length(null, _$$1.h2)); case "Nil": return Prelude_Z; } };
const Lib_LiftWhere_liftWhereTm = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "LetRec": { const getName = null; const wrapPi = null; const wrapLam = null; const l = Prelude_length(null, _$$2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm_getName(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, getName, _$$1, _$$3.h1), ( qn ) => { const env$27 = Prelude__$3A$3A_(null, Prelude_Just(null, Prelude__$2C_(null, null, qn, Prelude_S(l))), _$$2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, qn, env$27, _$$3.h3), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Ref2_modifyRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$0, ( eta ) => (Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, qn, Lib_Types_Fn(Lib_LiftWhere_liftWhereTm_getName_wrapPi_wrapLam(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, getName, wrapPi, wrapLam, Prelude_S(l), t$27)), eta))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, qn, env$27, _$$3.h4), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_LetRec(_$$3.h0, _$$3.h1, Lib_Types_Erased(_$$3.h0), Lib_Types_Erased(_$$3.h0), u$27)))))))); }); break; } case "Let": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h2), ( v ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, _$$1, Prelude__$3A$3A_(null, Prelude_Nothing(null), _$$2), _$$3.h3), ( sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Let(_$$3.h0, _$$3.h1, v, sc)))))); case "Case": { const liftWhereAlt = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h1), ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_LiftWhere_liftWhereTm_liftWhereAlt(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, liftWhereAlt, eta)))(_$$3.h2), ( alts$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_$$3.h0, t, alts$27)))))); break; } case "Pi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, _$$1, _$$2, _$$3.h4), ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, _$$1, Prelude__$3A$3A_(null, Prelude_Nothing(null), _$$2), _$$3.h5), ( u ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Pi(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, t, u)))))); case "App": return Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( 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 "Lam": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_Lam(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, eta)), Lib_LiftWhere_liftWhereTm(_$$0, _$$1, Prelude__$3A$3A_(null, Prelude_Nothing(null), _$$2), _$$3.h4)); case "Bnd": { const apply = null; const sc$$7 = Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_$$3.h1), _$$2); switch (sc$$7.tag) { case "Just": { const _sc$$0 = sc$$7.h1; switch (_sc$$0.tag) { case "Just": { const _sc$$1 = _sc$$0.h1; return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_LiftWhere_liftWhereTm_apply(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, apply, Prelude_length$27(null, _$$2), Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(_sc$$1.h3), Lib_Types_Ref(_$$3.h0, _sc$$1.h2))); break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$3); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$3); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$3); } };
const Lib_LiftWhere_liftWhereFn = ( _$$0, _$$1 ) => { const _sc$$0 = _$$1.h3; switch (_sc$$0.tag) { case "Fn": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhereTm(_$$0, _$$1.h2, Prelude_Nil(null), _sc$$0.h0), ( tm$27 ) => (Lib_Ref2_modifyRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$0, ( eta ) => (Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$1.h2, Lib_Types_Fn(tm$27), eta))))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } };
const Prelude_ignore = ( f, a, _ ) => (Prelude_map(null, _)(null)(null)(( eta ) => (Prelude_const(null, null, Prelude_MkUnit, eta))));
const Lib_LiftWhere_liftWhere = ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Ref2_getRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _), ( defs ) => (Prelude_ignore(null, null, Lib_Types_Prelude_Functor$20Lib_Types_M)(Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_LiftWhere_liftWhereFn(_, eta)))(Data_SortedMap_toList(null, null, defs))))));
const Lib_Erasure_eraseSpine = ( _$$0, _$$1, _$$2, ty$$3 ) => { switch (_$$2.tag) { case "_::_": { const _sc$$0 = _$$2.h1; switch (ty$$3.tag) { case "Just": { const _sc$$1 = ty$$3.h1; switch (_sc$$1.tag) { case "Pi": { const _sc$$2 = _sc$$1.h3; switch (_sc$$2.tag) { case "Many": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(_$$0, _sc$$0.h3, Prelude_Nil(null)), ( u ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_App(_sc$$0.h2, _$$1, u), _$$2.h2, Prelude_Just(null, _sc$$1.h5)))); case "Zero": { const u = Lib_Types_Erased(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_sc$$0.h3)); return Lib_Erasure_eraseSpine(_$$0, Lib_Types_App(_sc$$0.h2, _$$1, u), _$$2.h2, Prelude_Just(null, _sc$$1.h5)); break; } } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(_$$0, _sc$$0.h3, Prelude_Nil(null)), ( u ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_App(_sc$$0.h2, _$$1, u), _$$2.h2, Prelude_Nothing(null)))); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(_$$0, _sc$$0.h3, Prelude_Nil(null)), ( u ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_App(_sc$$0.h2, _$$1, u), _$$2.h2, Prelude_Nothing(null)))); } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1); } };
const Lib_Types__modDefs = ( _$$0 ) => (_$$0.h0);
const Lib_Types__modules = ( _$$0 ) => (_$$0.h0);
const Lib_Types__defs = ( _$$0 ) => (_$$0.h3);
const Lib_TopContext_lookup = ( _$$0, _$$1 ) => { const sc$$4 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__defs(_$$1)); switch (sc$$4.tag) { case "Nothing": { const sc$$6 = Data_SortedMap_lookupMap$27(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), _$$0.h0, Lib_Types__modules(_$$1)); switch (sc$$6.tag) { case "Nothing": return Prelude_Nothing(null); case "Just": return Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__modDefs(sc$$6.h1)); } break; } case "Just": return Prelude_Just(null, sc$$4.h1); } };
const Lib_Types_UU = ( h0 ) => ({ tag: "UU",  h0: h0 });
const Lib_Erasure_doAlt_piEnv = ( _, _1, _2, _3, _4, _5, _$$6, _$$7, _$$8 ) => { switch (_$$8.tag) { case "_::_": switch (_$$7.tag) { case "Pi": return Lib_Erasure_doAlt_piEnv(_, _1, _2, _3, _4, _5, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$8.h1, Prelude__$2C_(null, null, _$$7.h3, Prelude_Just(null, _$$7.h4))), _$$6), _$$7.h5, _$$8.h2); default: return _$$6; } break; default: return _$$6; } };
const Lib_Erasure_doAlt = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "CaseLit": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_CaseLit(_$$1.h0, eta)), Lib_Erasure_erase(_$$0, _$$1.h1, Prelude_Nil(null))); case "CaseCons": { const piEnv = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$7 = Lib_TopContext_lookup(_$$1.h0, top); switch (sc$$7.tag) { case "Just": { const _sc$$0 = sc$$7.h1; const env$27 = Lib_Erasure_doAlt_piEnv(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, piEnv, _$$0, _sc$$0.h2, _$$1.h1); return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_CaseCons(_$$1.h0, _$$1.h1, eta)), Lib_Erasure_erase(env$27, _$$1.h2, Prelude_Nil(null))); break; } default: return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h0)))(" dcon missing from context")); } }); break; } case "CaseDefault": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Lib_Types_CaseDefault, Lib_Erasure_erase(_$$0, _$$1.h0, Prelude_Nil(null))); } };
const Lib_Erasure_erase = ( _$$0, _$$1, _$$2 ) => { switch (_$$1.tag) { case "Erased": return Lib_Types_error(null, _$$1.h0, "erased value in relevant context"); case "Lit": return Lib_Erasure_eraseSpine(_$$0, _$$1, _$$2, Prelude_Nothing(null)); case "LetRec": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1.h1, Prelude__$2C_(null, null, Lib_Types_Many, Prelude_Just(null, _$$1.h2))), _$$0), _$$1.h3, Prelude_Nil(null)), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1.h1, Prelude__$2C_(null, null, Lib_Types_Many, Prelude_Just(null, _$$1.h2))), _$$0), _$$1.h4, Prelude_Nil(null)), ( v$27 ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_LetRec(_$$1.h0, _$$1.h1, _$$1.h2, u$27, v$27), _$$2, Prelude_Nothing(null)))))); case "Let": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(_$$0, _$$1.h2, Prelude_Nil(null)), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1.h1, Prelude__$2C_(null, null, Lib_Types_Many, Prelude_Nothing(null))), _$$0), _$$1.h3, Prelude_Nil(null)), ( v$27 ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_Let(_$$1.h0, _$$1.h1, u$27, v$27), _$$2, Prelude_Nothing(null)))))); case "Case": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(_$$0, _$$1.h1, Prelude_Nil(null)), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Erasure_doAlt(_$$0, eta)))(_$$1.h2), ( alts$27 ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_Case(_$$1.h0, u$27, alts$27), _$$2, Prelude_Nothing(null)))))); case "Pi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(_$$0, _$$1.h4, Prelude_Nil(null)), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1.h1, Prelude__$2C_(null, null, Lib_Types_Many, Prelude_Just(null, _$$1.h4))), _$$0), _$$1.h5, Prelude_Nil(null)), ( v$27 ) => (Lib_Erasure_eraseSpine(_$$0, Lib_Types_Pi(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, u$27, v$27), _$$2, Prelude_Just(null, Lib_Types_UU(Lib_Common_emptyFC))))))); case "UU": return Lib_Erasure_eraseSpine(_$$0, _$$1, _$$2, Prelude_Just(null, Lib_Types_UU(_$$1.h0))); case "App": return Lib_Erasure_erase(_$$0, _$$1.h1, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1.h0, _$$1.h2), _$$2)); case "Lam": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_Lam(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, eta)), Lib_Erasure_erase(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1.h1, Prelude__$2C_(null, null, _$$1.h3, Prelude_Nothing(null))), _$$0), _$$1.h4, Prelude_Nil(null))); case "Meta": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1); case "Ref": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$7 = Lib_TopContext_lookup(_$$1.h1, top); switch (sc$$7.tag) { case "Nothing": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h1)))(" not in scope")); case "Just": { const _sc$$0 = sc$$7.h1; return Lib_Erasure_eraseSpine(_$$0, _$$1, _$$2, Prelude_Just(null, _sc$$0.h2)); break; } } }); case "Bnd": { const sc$$6 = Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_$$1.h1), _$$0); switch (sc$$6.tag) { case "Nothing": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("bad index ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$1.h1)))("")); case "Just": { const _sc$$0 = sc$$6.h1; const _sc$$1 = _sc$$0.h3; const _sc$$2 = _sc$$1.h2; switch (_sc$$2.tag) { case "Many": return Lib_Erasure_eraseSpine(_$$0, _$$1, _$$2, _sc$$1.h3); case "Zero": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("used erased value ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_sc$$0.h2)))(" (FIXME FC may be wrong here)")); } break; } } break; } } };
const Lib_Compile_eraseEntries_go = ( _, _$$1, _$$2 ) => { const _sc$$0 = _$$2.h3; switch (_sc$$0.tag) { case "Fn": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Erasure_erase(Prelude_Nil(null), _sc$$0.h0, Prelude_Nil(null)), ( tm$27 ) => (Lib_Ref2_modifyRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _$$1, ( eta ) => (Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$2.h2, Lib_Types_Fn(tm$27), eta))))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } };
const Lib_Compile_eraseEntries = ((  ) => { const go = null; return ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Ref2_getRef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Ref2_Defs, _), ( defs ) => (Prelude_ignore(null, null, Lib_Types_Prelude_Functor$20Lib_Types_M)(Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Compile_eraseEntries_go(go, _, eta)))(Data_SortedMap_toList(null, null, defs)))))); })();
const Data_IORef_primNewIORef = (_, a) => (w) => Prelude_MkIORes(null, [a], w)
const Data_IORef_newIORef = ( io$$0, a$$1, _$$2, _$$3 ) => (Prelude_liftIO(null, _$$2)(null)(Data_IORef_primNewIORef(null, _$$3)));
const Data_SortedMap_EmptyMap = ( h0, h1 ) => ({ tag: "EmptyMap",  h0: h0,  h1: h1 });
const Lib_Types__def = ( _$$0 ) => (_$$0.h3);
const Prelude_flip = ( a$$0, b$$1, c$$2, _$$3, _$$4, _$$5 ) => (_$$3(_$$5)(_$$4));
const Prelude_foldlM = ( m$$0, a$$1, e$$2, _$$3, _$$4, _$$5, _$$6 ) => (Prelude_foldl(null, null, ( ma ) => (( b ) => (Prelude__$3E$3E$3D_(null, null, null, _$$3, ma, ( eta ) => (Prelude_flip(null, null, null, _$$4, b, eta))))), Prelude_pure(null, _$$3)(null)(_$$5), _$$6));
const Lib_Compile_getEntries = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$3 = Lib_TopContext_lookup(_$$1, top); switch (sc$$3.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("bad name ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))("")), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$0))); case "Just": { const _sc$$0 = sc$$3.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PrimFn": { const acc = Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _sc$$0.h1, _sc$$0.h3, _$$0); return Prelude_foldlM(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_Compile_getEntries(eta, eta1))), acc, _sc$$1.h2); break; } case "Fn": { const sc$$11 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _sc$$0.h1, _$$0); switch (sc$$11.tag) { case "Nothing": { const acc = Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _sc$$0.h1, _sc$$0.h3, _$$0); return Prelude_foldlM(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, ( eta ) => (( eta1 ) => (Lib_Compile_getEntries(eta, eta1))), acc, Lib_Compile_getNames(_sc$$1.h0, Prelude_Nil(null))); break; } case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$0); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$1, Lib_Types__def(sc$$3.h1), _$$0)); } break; } } }));
const Lib_Compile_process = ( _$$0 ) => { const wat = Lib_Common_QN(Prelude__$3A$3A_(null, "Prelude", Prelude_Nil(null)), "arrayToList"); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Compile_getEntries(Data_SortedMap_EmptyMap(null, null), _$$0), ( entries ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_newIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, entries), ( ref ) => { const foo = Lib_Ref2_MkRef(null, null, ref); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Compile_eraseEntries(Lib_Ref2_MkRef(null, null, ref)), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_LiftWhere_liftWhere(Lib_Ref2_MkRef(null, null, ref)), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_TCO_tailCallOpt(Lib_Ref2_MkRef(null, null, ref)), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, ref), ( entries1 ) => { const names = Lib_Compile_sortedNames(entries1, _$$0); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, names, ( nm ) => { const sc$$11 = Data_SortedMap_lookupMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, nm, entries1); switch (sc$$11.tag) { case "Nothing": return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("MISS ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(nm)))("")); case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } }), ( _3 ) => (Prelude_mapM(null, Lib_Types_Prelude_Monad$20Lib_Types_M, null, null, ( eta ) => (Prelude_uncurry(null, null, null, ( eta ) => (( eta1 ) => (Lib_Compile_defToDoc(Lib_Ref2_MkRef(null, null, ref), eta, eta1))), eta)), Prelude_mapMaybe(null, null, ( x ) => (Data_SortedMap_lookupMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, x, entries1)), names)))); }))))))); }))); };
const Lib_Types__imported = ( _$$0 ) => (_$$0.h1);
const Lib_TopContext_lookupRaw_go = ( _, _1, _2, _$$3 ) => { switch (_$$3.tag) { case "_::_": { const sc$$7 = Data_SortedMap_lookupMap$27(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), _$$3.h1, Lib_Types__modules(_1)); switch (sc$$7.tag) { case "Nothing": return Lib_TopContext_lookupRaw_go(_, _1, _2, _$$3.h2); case "Just": { const sc$$10 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, Lib_Common_QN(_$$3.h1, _), Lib_Types__modDefs(sc$$7.h1)); switch (sc$$10.tag) { case "Nothing": return Lib_TopContext_lookupRaw_go(_, _1, _2, _$$3.h2); case "Just": return Prelude_Just(null, sc$$10.h1); } break; } } break; } case "Nil": return Prelude_Nothing(null); } };
const Lib_Types__ns = ( _$$0 ) => (_$$0.h2);
const Lib_TopContext_lookupRaw = ( _$$0, _$$1 ) => { const go = null; const sc$$3 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, Lib_Common_QN(Lib_Types__ns(_$$1), _$$0), Lib_Types__defs(_$$1)); switch (sc$$3.tag) { case "Nothing": return Lib_TopContext_lookupRaw_go(_$$0, _$$1, go, Lib_Types__imported(_$$1)); case "Just": return Prelude_Just(null, sc$$3.h1); } };
const Lib_Compile_compile = Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$1 = Lib_TopContext_lookupRaw("main", top); switch (sc$$1.tag) { case "Nothing": return Lib_Types_error(null, Lib_Common_emptyFC, "No main function found"); case "Just": { const _sc$$0 = sc$$1.h1; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Compile_process(_sc$$0.h1), ( tmp ) => { const exec = Lib_Compile_stmtToDoc(null, Lib_Compile_JPlain(Lib_Compile_Apply(Lib_Compile_Var(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)), Prelude_Nil(null)))); return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_reverse(null)(Prelude__$3A$3A_(null, exec, tmp))); }); break; } } });
const Main_writeSource = ( _$$0 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Compile_compile, ( docs ) => { const src = Prelude_unlines(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(Prelude__$3A$3A_(null, "\"use strict\";", Prelude__$3A$3A_(null, "const PiType = (h0, h1) => ({ tag: \"PiType\", h0, h1 })", Prelude_Nil(null))))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude__$2218_(null, null, null, ( eta ) => (Lib_Prettier_render(90, eta)), Lib_Prettier_noAlt, eta)))(docs))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_liftIO(null, Lib_Types_Prelude_HasIO$20Lib_Types_M)(null)(Node_writeFile(_$$0, src)), ( $$sc ) => { switch ($$sc.tag) { case "Right": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "Left": return Node_exitFailure(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)($$sc.h2)); } }); }));
const Lib_Common_renderJson_renderPair = ( _, _1, _2, _$$3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Lib_Common_quoteString(_$$3.h2))(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(":")(Lib_Common_renderJson(_$$3.h3))));
const Prelude_ite = ( a$$0, _$$1, _$$2, _$$3 ) => { switch (_$$1.tag) { case "False": return _$$3; case "True": return _$$2; } };
const Data_Int_Prelude_Cast$20Prim_Int$20Prim_String$2Ccast = Prelude_show(null, Prelude_Prelude_Show$20Prim_Int);
const Data_Int_Prelude_Cast$20Prim_Int$20Prim_String = Prelude_MkCast(null, null, Data_Int_Prelude_Cast$20Prim_Int$20Prim_String$2Ccast);
const Lib_Common_renderJson = ( _$$0 ) => { switch (_$$0.tag) { case "JsonArray": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("[")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_joinBy(",", Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Common_renderJson)(_$$0.h0)))("]")); case "JsonInt": return Prelude_cast(null, null, Data_Int_Prelude_Cast$20Prim_Int$20Prim_String)(_$$0.h0); case "JsonBool": return Prelude_ite(null, _$$0.h0, "true", "false"); case "JsonStr": return Lib_Common_quoteString(_$$0.h0); case "JsonObj": { const renderPair = null; return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("{")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_joinBy(",", Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Common_renderJson_renderPair(_$$0, _$$0.h0, renderPair, eta)))(_$$0.h0)))("}")); break; } } };
const Data_SortedMap_listValues = ( k$$0, v$$1, _$$2 ) => (Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_snd(null, null, eta)))(Data_SortedMap_toList(null, null, _$$2)));
const Lib_Common_JsonStr = ( h0 ) => ({ tag: "JsonStr",  h0: h0 });
const Lib_Common_Lib_Common_ToJSON$20Prim_String$2CtoJson = Lib_Common_JsonStr;
const Lib_Common_MkToJSON = ( h0, h1 ) => ({ tag: "MkToJSON",  h0: h0,  h1: h1 });
const Lib_Common_Lib_Common_ToJSON$20Prim_String = Lib_Common_MkToJSON(null, Lib_Common_Lib_Common_ToJSON$20Prim_String$2CtoJson);
const Lib_Common_toJson = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Common_JsonInt = ( h0 ) => ({ tag: "JsonInt",  h0: h0 });
const Lib_Common_Lib_Common_ToJSON$20Prim_Int$2CtoJson = Lib_Common_JsonInt;
const Lib_Common_Lib_Common_ToJSON$20Prim_Int = Lib_Common_MkToJSON(null, Lib_Common_Lib_Common_ToJSON$20Prim_Int$2CtoJson);
const Lib_Common_JsonObj = ( h0 ) => ({ tag: "JsonObj",  h0: h0 });
const Lib_Common_Lib_Common_ToJSON$20Lib_Common_FC$2CtoJson = ( _$$0 ) => { const _sc$$0 = _$$0.h1; return Lib_Common_JsonObj(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "file", Lib_Common_toJson(null, Lib_Common_Lib_Common_ToJSON$20Prim_String)(_$$0.h0)), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "line", Lib_Common_toJson(null, Lib_Common_Lib_Common_ToJSON$20Prim_Int)(_sc$$0.h2)), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "col", Lib_Common_toJson(null, Lib_Common_Lib_Common_ToJSON$20Prim_Int)(_sc$$0.h3)), Prelude_Nil(null))))); };
const Lib_Common_Lib_Common_ToJSON$20Lib_Common_FC = Lib_Common_MkToJSON(null, Lib_Common_Lib_Common_ToJSON$20Lib_Common_FC$2CtoJson);
const Main_jsonTopContext_jsonDef = ( _, _$$1 ) => { const _sc$$0 = _$$1.h1; return Lib_Common_JsonObj(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "fc", Lib_Common_toJson(null, Lib_Common_Lib_Common_ToJSON$20Lib_Common_FC)(_$$1.h0)), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "name", Lib_Common_toJson(null, Lib_Common_Lib_Common_ToJSON$20Prim_String)(_sc$$0.h1)), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "type", Lib_Common_toJson(null, Lib_Common_Lib_Common_ToJSON$20Prim_String)(Lib_Prettier_render(80, Lib_Types_pprint(Prelude_Nil(null), _$$1.h2)))), Prelude_Nil(null))))); };
const Lib_Common_JsonArray = ( h0 ) => ({ tag: "JsonArray",  h0: h0 });
const Main_jsonTopContext = ((  ) => { const jsonDef = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Common_JsonObj(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, "context", Lib_Common_JsonArray(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Main_jsonTopContext_jsonDef(jsonDef, eta)))(Data_SortedMap_listValues(null, null, Lib_Types__defs(top))))), Prelude_Nil(null)))))); })();
const Prelude_arrayToList = (a,arr) => {
  let rval = Prelude_Nil(null)
  for (let i = arr.length - 1;i >= 0; i--) {
    rval = Prelude__$3A$3A_(a, arr[i], rval)
  }
  return rval
}
const Prelude_lines = (s) => Prelude_arrayToList(null,s.split('\n'))
const Lib_Common_fcCol = ( _$$0 ) => { const _sc$$0 = _$$0.h1; return _sc$$0.h3; };
const Lib_Common_fcLine = ( _$$0 ) => { const _sc$$0 = _$$0.h1; return _sc$$0.h2; };
const Prelude_Prelude_Eq$20Prim_Int$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude_jsEq(null, _$$0, _$$1));
const Prelude_Prelude_Eq$20Prim_Int = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prim_Int$2C_$3D$3D_(eta, eta1))));
const Lib_Common_showError_go$27 = ( _, _1, _2, _3, _4, _$$5, _$$6 ) => { switch (_$$6.tag) { case "_::_": { const sc$$10 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$5)(Lib_Common_fcLine(_2)); switch (sc$$10.tag) { case "False": { const sc$$11 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(Lib_Common_fcLine(_2))(3), _$$5); switch (sc$$11.tag) { case "False": return Lib_Common_showError_go$27(_, _1, _2, _3, _4, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$5)(1), _$$6.h2); case "True": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$6.h1)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("\n")(Lib_Common_showError_go$27(_, _1, _2, _3, _4, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$5)(1), _$$6.h2)))); } break; } case "True": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(_$$6.h1))("\n  "))(Prelude_replicate(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(Lib_Common_fcCol(_2)), " ")))("^\n"); } break; } case "Nil": return ""; } };
const Lib_Common_showError_go = ( _, _1, _2, _3, _4, _5, _$$6, _$$7 ) => { switch (_$$7.tag) { case "_::_": { const sc$$11 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$6)(Lib_Common_fcLine(_2)); switch (sc$$11.tag) { case "False": { const sc$$12 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(Lib_Common_fcLine(_2))(3), _$$6); switch (sc$$12.tag) { case "False": return Lib_Common_showError_go(_, _1, _2, _3, _4, _5, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$6)(1), _$$7.h2); case "True": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$7.h1)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("\n")(Lib_Common_showError_go(_, _1, _2, _3, _4, _5, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$6)(1), _$$7.h2)))); } break; } case "True": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(_$$7.h1))("\n  "))(Prelude_replicate(Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(Lib_Common_fcCol(_2)), " ")))("^\n"); } break; } case "Nil": return ""; } };
const Lib_Common_showError = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Postpone": { const go = null; return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ERROR at ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_$$1.h0)))(": Postpone "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1.h1)))(" "))(_$$1.h2))("\n"))(Lib_Common_showError_go(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, go, 0, Prelude_lines(_$$0))); break; } case "E": { const go = null; return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ERROR at ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_$$1.h0)))(": "))(_$$1.h1))("\n"))(Lib_Common_showError_go$27(_$$0, _$$1, _$$1.h0, _$$1.h1, go, 0, Prelude_lines(_$$0))); break; } } };
const Prelude_for_ = ( t$$0, f$$1, _$$2, appf$$3, a$$4, b$$5, _$$6, _$$7 ) => (Prelude__$3C$2A$3E_(null, appf$$3)(null)(null)(Prelude_return(null, appf$$3)(null)(( eta ) => (Prelude_const(null, null, Prelude_MkUnit, eta))))(Prelude_traverse(null, _$$2)(null)(null)(null)(appf$$3)(_$$7)(_$$6)));
const Lib_Types__errors = ( _$$0 ) => (_$$0.h6);
const Main_showErrors = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_liftIO(null, Lib_Types_Prelude_HasIO$20Lib_Types_M)(null)(Data_IORef_readIORef(null, null, Prelude_Prelude_HasIO$20Prelude_IO, Lib_Types__errors(top))), ( $$sc ) => { switch ($$sc.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for_(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, $$sc, ( err ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Common_showError(_$$1, err)))), ( _ ) => (Node_exitFailure(null, "Compile failed"))); } }))));
const Lib_Types__metas = ( _$$0 ) => (_$$0.h0);
const Lib_Types_info = ( _$$0, _$$1 ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("INFO at ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_$$0)))(": "))(_$$1))("")));
const Lib_Types__metaCtx = ( _$$0 ) => (_$$0.h4);
const Lib_Elab_rpprint = ( _$$0, _$$1 ) => (Lib_Prettier_render(90, Lib_Types_pprint(_$$0, _$$1)));
const Data_SnocList_snoclen_go = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$3.tag) { case "_:<_": return Data_SnocList_snoclen_go(_, _1, _2, _$$3.h1, Prelude_S(_$$4)); case "Lin": return _$$4; } };
const Data_SnocList_snoclen = ( a$$0, _$$1 ) => { const go = null; return Data_SnocList_snoclen_go(a$$0, _$$1, go, _$$1, Prelude_Z); };
const Prelude_Prelude_Show$20Prelude_Nat$2Cshow = ( _$$0 ) => (Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Prelude_natToInt(_$$0)));
const Prelude_Prelude_Show$20Prelude_Nat = Prelude_MkShow(null, Prelude_Prelude_Show$20Prelude_Nat$2Cshow);
const Lib_Types_showClosure = ( _$$0 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%cl (")(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Prelude_length(null, _$$0.h0))))(" env :: Nil) "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h1)))(")"));
const Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "VLit": return Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$0.h1); case "VErased": return "ERASED"; case "VU": return "U"; case "VLetRec": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%letrec ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h2)))(" = "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h3)))(" in "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h4)))(""); case "VLet": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%let ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1)))(" = "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h2)))(" in "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h3)))(""); case "VPi": { const _sc$$0 = _$$0.h2; switch (_sc$$0.tag) { case "Auto": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%pi {{")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(" "))(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h4)))("}}. "))(Lib_Types_showClosure(_$$0.h5)))(")"); case "Explicit": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%pi (")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(" "))(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h4)))("). "))(Lib_Types_showClosure(_$$0.h5)))(")"); case "Implicit": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%pi {")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(" "))(_$$0.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h4)))("}. "))(Lib_Types_showClosure(_$$0.h5)))(")"); } break; } case "VLam": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%lam ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(""))(_$$0.h1))(" "))(Lib_Types_showClosure(_$$0.h4)))(")"); case "VMeta": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(" ("))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Data_SnocList_snoclen(null, _$$0.h2))))(" sp :: Nil))"); case "VCase": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%case ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h1)))(" ...)"); case "VRef": { const _sc$$0 = _$$0.h2; switch (_sc$$0.tag) { case "Lin": return Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1); default: return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(" "))(Data_String_unwords(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Prelude__$3C$3E$3E_(null, _$$0.h2, Prelude_Nil(null))))))(")"); } break; } case "VVar": { const _sc$$0 = _$$0.h2; switch (_sc$$0.tag) { case "Lin": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("%var")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h1)))(""); default: return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(%var")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h1)))(" "))(Data_String_unwords(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Prelude__$3C$3E$3E_(null, _$$0.h2, Prelude_Nil(null))))))(")"); } break; } } };
const Lib_Types_Prelude_Show$20Lib_Types_Val = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_Val$2Cshow);
const Lib_Syntax_RVar = ( h0, h1 ) => ({ tag: "RVar",  h0: h0,  h1: h1 });
const Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case "RAs": return _$$0.h0; case "RWhere": return _$$0.h0; case "RIf": return _$$0.h0; case "RDo": return _$$0.h0; case "RHole": return _$$0.h0; case "RImplicit": return _$$0.h0; case "RCase": return _$$0.h0; case "RLit": return _$$0.h0; case "RAnn": return _$$0.h0; case "RLet": return _$$0.h0; case "RPi": return _$$0.h0; case "RU": return _$$0.h0; case "RApp": return _$$0.h0; case "RLam": return _$$0.h0; case "RVar": return _$$0.h0; } };
const Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw = Lib_Common_MkHasFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw$2CgetFC);
const Lib_Elab__constraints = ( _$$0 ) => (_$$0.h0);
const Lib_Types__types = ( _$$0 ) => (_$$0.h2);
const Prelude_fst = ( a$$0, b$$1, _$$2 ) => (_$$2.h2);
const Lib_Types__lvl = ( _$$0 ) => (_$$0.h0);
const Lib_Common_lvl2ix = ( _$$0, _$$1 ) => (Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$0)(_$$1))(1));
const Lib_Eval_quoteSp = ( lvl$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_:<_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quoteSp(lvl$$0, _$$1, _$$2.h1), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(lvl$$0, _$$2.h2), ( x$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_App(Lib_Common_emptyFC, t$27, x$27)))))); case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1); } };
const Lib_Types_Meta = ( h0, h1 ) => ({ tag: "Meta",  h0: h0,  h1: h1 });
const Lib_Types_error$27 = ( a$$0, _$$1 ) => (Lib_Types_throwError(null, Lib_Common_E(Lib_Common_emptyFC, _$$1)));
const Lib_Types_VVar = ( h0, h1, h2 ) => ({ tag: "VVar",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_VRef = ( h0, h1, h2 ) => ({ tag: "VRef",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_VMeta = ( h0, h1, h2 ) => ({ tag: "VMeta",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_CBN = { tag: "CBN" };
const Prelude_getAt$27 = ( a$$0, _$$1, _$$2 ) => (Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(_$$1), _$$2));
const Lib_Types__modMetaCtx = ( _$$0 ) => (_$$0.h1);
const Lib_Types_lookupMeta = ( _$$0 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => { const sc$$5 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__metas(mc)); switch (sc$$5.tag) { case "Nothing": { const sc$$7 = Data_SortedMap_lookupMap$27(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), _$$0.h0, Lib_Types__modules(top)); switch (sc$$7.tag) { case "Nothing": return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("missing module: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_$$0.h0)))("")); case "Just": { const sc$$10 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__metas(Lib_Types__modMetaCtx(sc$$7.h1))); switch (sc$$10.tag) { case "Nothing": return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("missing meta: ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0)))("")); case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(sc$$10.h1); } break; } } break; } case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(sc$$5.h1); } }))));
const Lib_Types_MkClosure = ( h0, h1 ) => ({ tag: "MkClosure",  h0: h0,  h1: h1 });
const Lib_Types_VLam = ( h0, h1, h2, h3, h4 ) => ({ tag: "VLam",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Types_VU = ( h0 ) => ({ tag: "VU",  h0: h0 });
const Lib_Types_VPi = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: "VPi",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
const Lib_Types_VCase = ( h0, h1, h2 ) => ({ tag: "VCase",  h0: h0,  h1: h1,  h2: h2 });
const Prelude__$3E_ = ( a$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prelude_Ordering)(Prelude_compare(null, _$$1)(_$$2)(_$$3))(Prelude_GT));
const Lib_Eval_lookupVar = ( _$$0, _$$1 ) => { const l = Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(Prelude_length(null, _$$0)); const sc$$3 = Prelude__$3E_(null, Prelude_Prelude_Ord$20Prim_Int, _$$1, l); switch (sc$$3.tag) { case "False": { const sc$$4 = Prelude_getAt(null, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(Lib_Common_lvl2ix(l, _$$1)), _$$0); switch (sc$$4.tag) { case "Nothing": return Prelude_Nothing(null); case "Just": { const _sc$$0 = sc$$4.h1; switch (_sc$$0.tag) { case "VVar": { const sc$$10 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$1)(_sc$$0.h1); switch (sc$$10.tag) { case "False": return Prelude_Just(null, sc$$4.h1); case "True": return Prelude_Nothing(null); } break; } default: return Prelude_Just(null, sc$$4.h1); } break; } } break; } case "True": return Prelude_Nothing(null); } };
const Prelude__$3C$3E$3C_ = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": return Prelude__$3C$3E$3C_(null, Prelude__$3A$3C_(null, _$$1, _$$2.h1), _$$2.h2); case "Nil": return _$$1; } };
const Lib_Eval_evalCase_go = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _$$14, _$$15, _$$16 ) => { switch (_$$16.tag) { case "_::_": switch (_$$15.tag) { case "_::_": return Lib_Eval_evalCase_go(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, Prelude__$3A$3A_(null, _$$15.h1, _$$14), _$$15.h2, _$$16.h2); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } break; case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$14, _1, _9), ( t$27 ) => (Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_Just(null, eta)), Lib_Eval_vappSpine(t$27, Prelude__$3C$3E$3C_(null, Prelude_Lin(null), _$$15))))); } };
const Lib_Types_showTm = Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm);
const Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29$2Cshow = ( a$$0, _$$1, _$$2 ) => (Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, _$$1))(Prelude__$3C$3E$3E_(null, _$$2, Prelude_Nil(null))));
const Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29 = ( a, _ ) => (Prelude_MkShow(null, ( eta ) => (Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29$2Cshow(null, _, eta))));
const Lib_Eval_evalCase = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": { const _sc$$0 = _$$3.h1; switch (_sc$$0.tag) { case "CaseCons": switch (_$$2.tag) { case "VRef": { const go = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$15 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$2.h1)(_sc$$0.h0); switch (sc$$15.tag) { case "False": { const sc$$16 = Lib_TopContext_lookup(_$$2.h1, top); switch (sc$$16.tag) { case "Just": { const _sc$$1 = sc$$16.h1; const _sc$$2 = _sc$$1.h3; switch (_sc$$2.tag) { case "DCon": return Lib_Eval_evalCase(_$$0, _$$1, _$$2, _$$3.h2); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } break; } case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ECase ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$2.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$2.h2)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_sc$$0.h1)))(" "))(Lib_Types_showTm(_sc$$0.h2)))(""))), ( _ ) => (Lib_Eval_evalCase_go(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _$$2.h0, _$$2.h1, _$$2.h2, go, _$$0, Prelude__$3C$3E$3E_(null, _$$2.h2, Prelude_Nil(null)), _sc$$0.h1))); } }); break; } case "VVar": { const sc$$13 = Lib_Eval_lookupVar(_$$0, _$$2.h1); switch (sc$$13.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is Nothing in env "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); case "Just": { const _sc$$1 = sc$$13.h1; switch (_sc$$1.tag) { case "VVar": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$13.h1)))(""))), ( _ ) => { const sc$$20 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_sc$$1.h1)(_$$2.h1); switch (sc$$20.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(Lib_Types_VVar(_sc$$1.h0, _sc$$1.h1, _sc$$1.h2), _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(sc$$13.h1, _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); } break; } } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CASE BAIL sc ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$2)))(" vs "))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("env is ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))))); } break; case "CaseDefault": switch (_$$2.tag) { case "VVar": { const sc$$11 = Lib_Eval_lookupVar(_$$0, _$$2.h1); switch (sc$$11.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is Nothing in env "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); case "Just": { const _sc$$1 = sc$$11.h1; switch (_sc$$1.tag) { case "VVar": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$11.h1)))(""))), ( _ ) => { const sc$$18 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_sc$$1.h1)(_$$2.h1); switch (sc$$18.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(Lib_Types_VVar(_sc$$1.h0, _sc$$1.h1, _sc$$1.h2), _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(sc$$11.h1, _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); } break; } } break; } default: return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_Just(null, eta)), Lib_Eval_eval(Prelude__$3A$3A_(null, _$$2, _$$0), _$$1, _sc$$0.h0)); } break; default: switch (_$$2.tag) { case "VVar": { const sc$$10 = Lib_Eval_lookupVar(_$$0, _$$2.h1); switch (sc$$10.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is Nothing in env "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); case "Just": { const _sc$$1 = sc$$10.h1; switch (_sc$$1.tag) { case "VVar": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$10.h1)))(""))), ( _ ) => { const sc$$17 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_sc$$1.h1)(_$$2.h1); switch (sc$$17.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(Lib_Types_VVar(_sc$$1.h0, _sc$$1.h1, _sc$$1.h2), _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(sc$$10.h1, _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); } break; } } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CASE BAIL sc ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$2)))(" vs "))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("env is ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))))); } break; } break; } default: switch (_$$2.tag) { case "VVar": { const sc$$7 = Lib_Eval_lookupVar(_$$0, _$$2.h1); switch (sc$$7.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is Nothing in env "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); case "Just": { const _sc$$0 = sc$$7.h1; switch (_sc$$0.tag) { case "VVar": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))(" is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$7.h1)))(""))), ( _ ) => { const sc$$14 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_sc$$0.h1)(_$$2.h1); switch (sc$$14.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(Lib_Types_VVar(_sc$$0.h0, _sc$$0.h1, _sc$$0.h2), _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(sc$$7.h1, _$$2.h2), ( val ) => (Lib_Eval_evalCase(_$$0, _$$1, val, _$$3))); } break; } } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CASE BAIL sc ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$2)))(" vs "))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("env is ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))))); } break; } };
const Lib_Types_catchError = ( a$$0, _$$1, _$$2 ) => (Lib_Types_MkM(null, ( tc ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, _$$1.h1(tc), ( $$sc ) => { switch ($$sc.tag) { case "Right": { const _sc$$0 = $$sc.h2; return Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, _sc$$0.h2, _sc$$0.h3))); break; } case "Left": return Lib_Types__runM(null, _$$2($$sc.h2))(tc); } }))));
const Lib_Eval_tryEval = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "VRef": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$6 = Lib_TopContext_lookup(_$$1.h1, top); switch (sc$$6.tag) { case "Just": { const _sc$$0 = sc$$6.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Fn": return Lib_Types_catchError(null, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("app ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" to "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$1.h2)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$1.h0), ( vtm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("tm is ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), _sc$$1.h0))))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(vtm, _$$1.h2), ( val ) => { switch (val.tag) { case "VLetRec": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); case "VCase": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, val)); } }))))))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } };
const Lib_Eval_forceType = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "VMeta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$1.h1), ( meta ) => { switch (meta.tag) { case "Solved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(meta.h2, _$$1.h2), ( eta ) => (Lib_Eval_forceType(_$$0, eta))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VMeta(_$$1.h0, _$$1.h1, _$$1.h2)); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_tryEval(_$$0, _$$1), ( $$sc ) => { switch ($$sc.tag) { case "Just": return Lib_Eval_forceType(_$$0, $$sc.h1); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1); } }); } };
const Lib_Eval_unlet = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "VVar": { const sc$$5 = Lib_Eval_lookupVar(_$$0, _$$1.h1); switch (sc$$5.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$1.h1)))(" is Nothing in env "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1))); case "Just": { const _sc$$0 = sc$$5.h1; switch (_sc$$0.tag) { case "VVar": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$1.h1)))(" is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$5.h1)))(""))), ( _ ) => { const sc$$12 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_sc$$0.h1)(_$$1.h1); switch (sc$$12.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(Lib_Types_VVar(_sc$$0.h0, _sc$$0.h1, _sc$$0.h2), _$$1.h2), ( eta ) => (Lib_Eval_unlet(_$$0, eta))); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(sc$$5.h1, _$$1.h2), ( eta ) => (Lib_Eval_unlet(_$$0, eta))); } break; } } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$1); } };
const Lib_Types_VLet = ( h0, h1, h2, h3 ) => ({ tag: "VLet",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Types_VLetRec = ( h0, h1, h2, h3, h4 ) => ({ tag: "VLetRec",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Types_VLit = ( h0, h1 ) => ({ tag: "VLit",  h0: h0,  h1: h1 });
const Lib_Types_VErased = ( h0 ) => ({ tag: "VErased",  h0: h0 });
const Lib_Eval_eval = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "Erased": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VErased(_$$2.h0)); case "Lit": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VLit(_$$2.h0, _$$2.h1)); case "LetRec": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h2), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude__$3A$3A_(null, Lib_Types_VVar(_$$2.h0, Prelude_length$27(null, _$$0), Prelude_Lin(null)), _$$0), _$$1, _$$2.h3), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude__$3A$3A_(null, Lib_Types_VVar(_$$2.h0, Prelude_length$27(null, _$$0), Prelude_Lin(null)), _$$0), _$$1, _$$2.h4), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VLetRec(_$$2.h0, _$$2.h1, ty$27, t$27, u$27)))))))); case "Let": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h2), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude__$3A$3A_(null, Lib_Types_VVar(_$$2.h0, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(Prelude_length(null, _$$0)), Prelude_Lin(null)), _$$0), _$$1, _$$2.h3), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VLet(_$$2.h0, _$$2.h1, t$27, u$27)))))); case "Case": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h1), ( sc$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_unlet(_$$0, sc$27), ( sc$271 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_forceType(_$$0, sc$271), ( sc$272 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h1), ( vsc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_evalCase(_$$0, _$$1, sc$272, _$$2.h2), ( vcase ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_fromMaybe(null, Lib_Types_VCase(_$$2.h0, vsc, _$$2.h2), vcase)))))))))))); case "Pi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h4), ( a$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VPi(_$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, a$27, Lib_Types_MkClosure(_$$0, _$$2.h5))))); case "UU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VU(_$$2.h0)); case "App": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h1), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, _$$1, _$$2.h2), ( u$27 ) => (Lib_Eval_vapp(t$27, u$27))))); case "Lam": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VLam(_$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, Lib_Types_MkClosure(_$$0, _$$2.h4))); case "Meta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$2.h1), ( meta ) => { switch (meta.tag) { case "Solved": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(meta.h2); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VMeta(_$$2.h0, _$$2.h1, Prelude_Lin(null))); } }); case "Ref": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VRef(_$$2.h0, _$$2.h1, Prelude_Lin(null))); case "Bnd": { const sc$$5 = Prelude_getAt$27(null, _$$2.h1, _$$0); switch (sc$$5.tag) { case "Nothing": return Lib_Types_error(null, _$$2.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Bad deBruin index ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$2.h1)))("")); case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(sc$$5.h1); } break; } } };
const Lib_Eval__$$$$_ = ( _$$0, _$$1 ) => (Lib_Eval_eval(Prelude__$3A$3A_(null, _$$1, _$$0.h0), Lib_Types_CBN, _$$0.h1));
const Lib_Eval_vapp = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "VLam": return Lib_Eval__$$$$_(_$$0.h4, _$$1); case "VMeta": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VMeta(_$$0.h0, _$$0.h1, Prelude__$3A$3C_(null, _$$0.h2, _$$1))); case "VRef": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VRef(_$$0.h0, _$$0.h1, Prelude__$3A$3C_(null, _$$0.h2, _$$1))); case "VVar": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VVar(_$$0.h0, _$$0.h1, Prelude__$3A$3C_(null, _$$0.h2, _$$1))); default: return Lib_Types_error$27(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("impossible in vapp ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0)))(" to "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$1)))("\n")); } };
const Lib_Eval_vappSpine = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_:<_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(_$$0, _$$1.h1), ( rest ) => (Lib_Eval_vapp(rest, _$$1.h2))); case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$0); } };
const Lib_Types_Lit = ( h0, h1 ) => ({ tag: "Lit",  h0: h0,  h1: h1 });
const Lib_Eval_quote = ( lvl$$0, _$$1 ) => { switch (_$$1.tag) { case "VLit": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lit(_$$1.h0, _$$1.h1)); case "VErased": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Erased(_$$1.h0)); case "VU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_UU(_$$1.h0)); case "VLetRec": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(lvl$$0, _$$1.h2), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(lvl$$0), _$$1.h3), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(lvl$$0), _$$1.h4), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_LetRec(_$$1.h0, _$$1.h1, ty$27, t$27, u$27)))))))); case "VLet": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(lvl$$0, _$$1.h2), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(lvl$$0), _$$1.h3), ( u$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Let(_$$1.h0, _$$1.h1, t$27, u$27)))))); case "VPi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(lvl$$0, _$$1.h4), ( a$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$1.h5, Lib_Types_VVar(Lib_Common_emptyFC, lvl$$0, Prelude_Lin(null))), ( val ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(lvl$$0), val), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Pi(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, a$27, tm)))))))); case "VLam": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$1.h4, Lib_Types_VVar(Lib_Common_emptyFC, lvl$$0, Prelude_Lin(null))), ( val ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(lvl$$0), val), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lam(_$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, tm)))))); case "VMeta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$1.h1), ( meta ) => { switch (meta.tag) { case "Solved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(meta.h2, _$$1.h2), ( eta ) => (Lib_Eval_quote(lvl$$0, eta))); default: return Lib_Eval_quoteSp(lvl$$0, Lib_Types_Meta(_$$1.h0, _$$1.h1), _$$1.h2); } }); case "VCase": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(lvl$$0, _$$1.h1), ( sc$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_$$1.h0, sc$27, _$$1.h2)))); case "VRef": return Lib_Eval_quoteSp(lvl$$0, Lib_Types_Ref(_$$1.h0, _$$1.h1), _$$1.h2); case "VVar": { const sc$$5 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _$$1.h1, lvl$$0); switch (sc$$5.tag) { case "False": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Bad index in quote ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$1.h1)))(" depth "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(lvl$$0)))("")); case "True": return Lib_Eval_quoteSp(lvl$$0, Lib_Types_Bnd(_$$1.h0, Lib_Common_lvl2ix(lvl$$0, _$$1.h1)), _$$1.h2); } break; } } };
const Lib_Elab_UNormal = { tag: "UNormal" };
const Lib_Types__env = ( _$$0 ) => (_$$0.h1);
const Lib_Types_getValFC = ( _$$0 ) => { switch (_$$0.tag) { case "VLit": return _$$0.h0; case "VErased": return _$$0.h0; case "VU": return _$$0.h0; case "VLetRec": return _$$0.h0; case "VLet": return _$$0.h0; case "VPi": return _$$0.h0; case "VLam": return _$$0.h0; case "VMeta": return _$$0.h0; case "VCase": return _$$0.h0; case "VRef": return _$$0.h0; case "VVar": return _$$0.h0; } };
const Lib_Types_Lib_Common_HasFC$20Lib_Types_Val$2CgetFC = Lib_Types_getValFC;
const Lib_Types_Lib_Common_HasFC$20Lib_Types_Val = Lib_Common_MkHasFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val$2CgetFC);
const Lib_Elab_MkResult = ( h0 ) => ({ tag: "MkResult",  h0: h0 });
const Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult$2C_$3C$2B$3E_ = ( _$$0, _$$1 ) => (Lib_Elab_MkResult(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$0.h0)(_$$1.h0)));
const Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult = Prelude_MkSemigroup(null, ( eta ) => (( eta1 ) => (Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult$2C_$3C$2B$3E_(eta, eta1))));
const Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral = Lib_Elab_MkResult(Prelude_Nil(null));
const Prelude_MkMonoid = ( h0, h1 ) => ({ tag: "MkMonoid",  h0: h0,  h1: h1 });
const Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult = Prelude_MkMonoid(null, Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult$2Cneutral);
const Prelude_neutral = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Elab_unify_unifyRest = ( _, _1, _2, _3, _4, _$$5, _$$6 ) => { switch (_$$6.tag) { case "VU": switch (_$$5.tag) { case "VU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_neutral(null, Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult)); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$5), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$5)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" \n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } break; case "VPi": switch (_$$5.tag) { case "VPi": { const fresh = Lib_Types_VVar(_$$5.h0, Prelude_length$27(null, _), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$5.h5, fresh), ( xb ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$6.h5, fresh), ( xb$27 ) => (Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Prelude__$3C$2B$3E_(null, Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult), Lib_Elab_unify(_, _1, _$$5.h4, _$$6.h4)))(Lib_Elab_unify(Prelude__$3A$3A_(null, fresh, _), _1, xb, xb$27)))))); break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$5), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$5)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" \n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } break; default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$5), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$5)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" \n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } };
const Lib_Elab_unifySpine = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { switch (_$$2.tag) { case "False": return Lib_Types_error(null, Lib_Common_emptyFC, "unify failed at head"); case "True": switch (_$$3.tag) { case "_:<_": switch (_$$4.tag) { case "_:<_": return Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Prelude__$3C$2B$3E_(null, Lib_Elab_Prelude_Semigroup$20Lib_Elab_UnifyResult), Lib_Elab_unify(_$$0, _$$1, _$$3.h2, _$$4.h2)))(Lib_Elab_unifySpine(_$$0, _$$1, Prelude_True, _$$3.h1, _$$4.h1)); default: return Lib_Types_error(null, Lib_Common_emptyFC, "meta spine length mismatch"); } break; case "Lin": switch (_$$4.tag) { case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Elab_MkResult(Prelude_Nil(null))); default: return Lib_Types_error(null, Lib_Common_emptyFC, "meta spine length mismatch"); } break; } break; } };
const Lib_Elab_unify_unifyRest_unifyRef = ( _, _1, _2, _3, _4, _5, _$$6, _$$7 ) => { switch (_$$7.tag) { case "VRef": switch (_$$6.tag) { case "VRef": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_tryEval(_, _$$6), ( $$sc ) => { switch ($$sc.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_tryEval(_, _$$7), ( $$sc1 ) => { switch ($$sc1.tag) { case "Nothing": { const sc$$20 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$6.h1)(_$$7.h1); switch (sc$$20.tag) { case "False": return Lib_Types_error(null, _$$6.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("vref mismatch ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))("")); case "True": return Lib_Elab_unifySpine(_, _1, Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$6.h1)(_$$7.h1), _$$6.h2, _$$7.h2); } break; } case "Just": return Lib_Elab_unify(_, _1, _$$6, $$sc1.h1); } }); case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("tryEval ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" to "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)($$sc.h1)))(""))), ( _6 ) => (Lib_Elab_unify(_, _1, $$sc.h1, _$$7))); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expand ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" =?= %ref "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$7.h1)))(""))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$13 = Lib_TopContext_lookup(_$$7.h1, top); switch (sc$$13.tag) { case "Just": { const _sc$$0 = sc$$13.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Fn": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$1.h0), ( vtm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(vtm, _$$7.h2), ( appvtm ) => (Lib_Elab_unify(_, _1, _$$6, appvtm))))); default: return Lib_Types_error(null, _$$7.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))(" (no Fn :: Nil)\n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } break; } default: return Lib_Types_error(null, _$$7.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))(" (no Fn :: Nil)\n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } }))); } break; default: switch (_$$6.tag) { case "VRef": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expand %ref ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$6.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$6.h2)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))(""))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$13 = Lib_TopContext_lookup(_$$6.h1, top); switch (sc$$13.tag) { case "Just": { const _sc$$0 = sc$$13.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Fn": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$1.h0), ( vtm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(vtm, _$$6.h2), ( tmsp ) => (Lib_Elab_unify(_, _1, tmsp, _$$7))))); default: return Lib_Types_error(null, _$$6.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" (no Fn :: Nil) =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))("\n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } break; } default: return Lib_Types_error(null, _$$6.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify failed ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$6)))(" (no Fn :: Nil) =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))("\n  env is "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_)))("")); } }))); default: return Lib_Elab_unify_unifyRest(_, _1, _2, _3, _4, _$$6, _$$7); } break; } };
const Lib_Elab_unify_unifyRest_unifyRef_unifyVar = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8 ) => { switch (_$$8.tag) { case "VVar": switch (_$$7.tag) { case "VVar": { const sc$$15 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$7.h1)(_$$8.h1); switch (sc$$15.tag) { case "False": return Lib_Types_error(null, _$$7.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Failed to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$8)))("")); case "True": return Lib_Elab_unifySpine(_, _1, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$7.h1)(_$$8.h1), _$$7.h2, _$$8.h2); } break; } default: { const _sc$$0 = _$$8.h2; switch (_sc$$0.tag) { case "Lin": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_tryEval(_, _$$7), ( vt ) => { switch (vt.tag) { case "Nothing": return Lib_Types_error(null, _$$8.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Failed to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$8)))("")); case "Just": return Lib_Elab_unify(_, _1, vt.h1, _$$8); } }); default: return Lib_Elab_unify_unifyRest_unifyRef(_, _1, _2, _3, _4, _5, _$$7, _$$8); } break; } } break; default: switch (_$$7.tag) { case "VVar": { const _sc$$0 = _$$7.h2; switch (_sc$$0.tag) { case "Lin": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_tryEval(_, _$$8), ( vu ) => { switch (vu.tag) { case "Nothing": return Lib_Types_error(null, _$$7.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Failed to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$7)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$8)))("")); case "Just": return Lib_Elab_unify(_, _1, _$$7, vu.h1); } }); default: return Lib_Elab_unify_unifyRest_unifyRef(_, _1, _2, _3, _4, _5, _$$7, _$$8); } break; } default: return Lib_Elab_unify_unifyRest_unifyRef(_, _1, _2, _3, _4, _5, _$$7, _$$8); } break; } };
const Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9 ) => { switch (_$$9.tag) { case "VLam": switch (_$$8.tag) { case "VLam": { const fresh = Lib_Types_VVar(_$$8.h0, Prelude_length$27(null, _), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$8.h4, fresh), ( vappt ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$9.h4, fresh), ( vappt$27 ) => (Lib_Elab_unify(Prelude__$3A$3A_(null, fresh, _), _1, vappt, vappt$27))))); break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ETA ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$8)))(""))), ( _8 ) => { const fresh = Lib_Types_VVar(_$$9.h0, Prelude_length$27(null, _), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vapp(_$$8, fresh), ( vappt ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$9.h4, fresh), ( vappt$27 ) => (Lib_Elab_unify(Prelude__$3A$3A_(null, fresh, _), _1, vappt, vappt$27))))); }); } break; default: switch (_$$8.tag) { case "VLam": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ETA' ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$9)))(""))), ( _8 ) => { const fresh = Lib_Types_VVar(_$$8.h0, Prelude_length$27(null, _), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$8.h4, fresh), ( appt ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vapp(_$$9, fresh), ( vappt$27 ) => (Lib_Elab_unify(Prelude__$3A$3A_(null, fresh, _), _1, appt, vappt$27))))); }); default: return Lib_Elab_unify_unifyRest_unifyRef_unifyVar(_, _1, _2, _3, _4, _5, _6, _$$8, _$$9); } break; } };
const Lib_Types__bds = ( _$$0 ) => (_$$0.h3);
const Lib_Elab_makeSpine = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; switch (_sc$$0.tag) { case "Defined": return Lib_Elab_makeSpine(Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$0)(1), _$$1.h2); case "Bound": return Prelude__$3A$3C_(null, Lib_Elab_makeSpine(Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$0)(1), _$$1.h2), Lib_Types_VVar(Lib_Common_emptyFC, Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$0)(1), Prelude_Lin(null))); } break; } case "Nil": return Prelude_Lin(null); } };
const Prelude_Prelude_Monad$20Prelude_List$2Cpure = ( a$$0, _$$1 ) => (Prelude__$3A$3A_(null, _$$1, Prelude_Nil(null)));
const Prelude_Prelude_Monad$20Prelude_List$2Cbind = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "_::_": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$3(_$$2.h1))(Prelude_bind(null, Prelude_Prelude_Monad$20Prelude_List)(null)(null)(_$$2.h2)(_$$3)); case "Nil": return Prelude_Nil(null); } };
const Prelude_Prelude_Monad$20Prelude_List = Prelude_MkMonad(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Monad$20Prelude_List$2Cbind(null, null, eta, eta1))))), ( a ) => (( eta ) => (Prelude_Prelude_Monad$20Prelude_List$2Cpure(null, eta))));
const Prelude_id = ( a$$0, _$$1 ) => (_$$1);
const Prelude_join = ( m$$0, a$$1, _$$2, _$$3 ) => (Prelude__$3E$3E$3D_(null, null, null, _$$2, _$$3, ( eta ) => (Prelude_id(null, eta))));
const Prelude_zip = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_::_": switch (_$$2.tag) { case "_::_": return Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$2.h1, _$$3.h1), Prelude_zip(null, null, _$$2.h2, _$$3.h2)); default: return Prelude_Nil(null); } break; default: return Prelude_Nil(null); } };
const Lib_Types_names = ( _$$0 ) => (Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$0)));
const Lib_Elab_isCandidate = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Pi": { const _sc$$0 = _$$1.h2; switch (_sc$$0.tag) { case "Explicit": return Prelude_False; default: return Lib_Elab_isCandidate(_$$0, _$$1.h5); } break; } case "App": return Lib_Elab_isCandidate(_$$0, _$$1.h1); case "Ref": switch (_$$0.tag) { case "VRef": return Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$0.h1)(_$$1.h1); default: return Prelude_False; } break; default: return Prelude_False; } };
const Lib_Elab_contextMatches_go = ( _, _1, _2, _$$3 ) => { switch (_$$3.tag) { case "_::_": { const _sc$$0 = _$$3.h1; const _sc$$1 = _sc$$0.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$1.h3), ( type ) => { const sc$$16 = Lib_Elab_isCandidate(_1, type); switch (sc$$16.tag) { case "False": return Lib_Elab_contextMatches_go(_, _1, _2, _$$3.h2); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Lib_Types_catchError(null, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TRY context ")(_sc$$1.h2))(" : "))(Lib_Elab_rpprint(Lib_Types_names(_), type)))(" for "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_1)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_1), _, _1, _sc$$1.h3), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_writeIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), mc), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$0.h2), ( tm ) => (Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude__$3A$3A_(null, Prelude__$2C_(null, null, tm, _sc$$1.h3), eta)), Lib_Elab_contextMatches_go(_, _1, _2, _$$3.h2)))))))))))), ( err ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("No match ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_1)))(" "))(Lib_Elab_rpprint(Lib_Types_names(_), type)))(" "))(Lib_Common_showError("", err)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_writeIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), mc), ( _4 ) => (Lib_Elab_contextMatches_go(_, _1, _2, _$$3.h2))))))))))); } }); break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nil(null)); } };
const Lib_Elab_contextMatches = ( _$$0, _$$1 ) => { const go = null; return Lib_Elab_contextMatches_go(_$$0, _$$1, go, Prelude_zip(null, null, Lib_Types__env(_$$0), Lib_Types__types(_$$0))); };
const Lib_Elab_trySolveAuto = ( _$$0 ) => { switch (_$$0.tag) { case "Unsolved": { const _sc$$0 = _$$0.h4; switch (_sc$$0.tag) { case "AutoSolve": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TRYAUTO solving ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_$$0.h2), _$$0.h3), ( x ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0.h2), Lib_Types_CBN, x), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("AUTO ---> ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_contextMatches(_$$0.h2, ty), ( $$sc ) => { switch ($$sc.tag) { case "_::_": { const _sc$$1 = $$sc.h1; const _sc$$2 = $$sc.h2; switch (_sc$$2.tag) { case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(ty), _$$0.h2, ty, _sc$$1.h3), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0.h2), Lib_Types_CBN, _sc$$1.h2), ( val ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SOLUTION ")(Lib_Elab_rpprint(Prelude_Nil(null), _sc$$1.h2)))(" evaled to "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(val)))(""))), ( _3 ) => { const sp = Lib_Elab_makeSpine(Lib_Types__lvl(_$$0.h2), Lib_Types__bds(_$$0.h2)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solve(Lib_Types__env(_$$0.h2), _$$0.h1, sp, val), ( _4 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_True))); }))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("FAILED to solve ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty)))(", matches: "))(Lib_Prettier_render(90, Lib_Prettier_commaSep(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude__$2218_(null, null, null, ( eta ) => (Lib_Types_pprint(Prelude_Nil(null), eta)), ( eta ) => (Prelude_fst(null, null, eta)), eta)))($$sc)))))(""))), ( _2 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False))); } break; } case "Nil": { const te = Data_SortedMap_listValues(null, null, Lib_Types__defs(top)); const rest = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( x1 ) => (Data_SortedMap_listValues(null, null, Lib_Types__modDefs(x1))))(Prelude_mapMaybe(null, null, ( eta ) => (Prelude_flip(null, null, null, ( eta ) => (( eta1 ) => (Data_SortedMap_lookupMap$27(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), eta, eta1))), Lib_Types__modules(top), eta)), Lib_Types__imported(top))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_findMatches(_$$0.h2, ty, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, Prelude__$3A$3A_(null, te, rest))), ( $$sc1 ) => { switch ($$sc1.tag) { case "_::_": { const _sc$$1 = $$sc1.h2; switch (_sc$$1.tag) { case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0.h2, Lib_Syntax_RVar(_$$0.h0, $$sc1.h1), ty), ( tm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0.h2), Lib_Types_CBN, tm), ( val ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SOLUTION ")(Lib_Elab_rpprint(Prelude_Nil(null), tm)))(" evaled to "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(val)))(""))), ( _2 ) => { const sp = Lib_Elab_makeSpine(Lib_Types__lvl(_$$0.h2), Lib_Types__bds(_$$0.h2)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solve(Lib_Types__env(_$$0.h2), _$$0.h1, sp, val), ( _3 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_True))); }))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("FAILED to solve ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty)))(", matches: "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))($$sc1)))(""))), ( _2 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False))); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("FAILED to solve ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty)))(", matches: "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))($$sc1)))(""))), ( _2 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False))); } }); break; } } }))))))))))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False); } };
const Lib_Elab_checkAutos_usesMeta = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$12 ) => { switch (_$$12.tag) { case "App": { const _sc$$0 = _$$12.h1; switch (_sc$$0.tag) { case "Meta": { const sc$$18 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_sc$$0.h1)(_); switch (sc$$18.tag) { case "False": return Lib_Elab_checkAutos_usesMeta(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$12.h2); case "True": return Prelude_True; } break; } default: return Lib_Elab_checkAutos_usesMeta(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$12.h2); } break; } default: return Prelude_False; } };
const Lib_Elab_checkAutos = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; switch (_sc$$0.tag) { case "Unsolved": { const _sc$$1 = _sc$$0.h4; switch (_sc$$1.tag) { case "AutoSolve": { const usesMeta = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_sc$$0.h2), _sc$$0.h3), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Lib_Elab_checkAutos_usesMeta(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, _sc$$0.h4, _sc$$0.h5, usesMeta, ty$27), ( _ ) => (Prelude_ignore(null, null, Lib_Types_Prelude_Functor$20Lib_Types_M)(Lib_Elab_trySolveAuto(_$$1.h1)))), ( _ ) => (Lib_Elab_checkAutos(_$$0, _$$1.h2))))); break; } default: return Lib_Elab_checkAutos(_$$0, _$$1.h2); } break; } default: return Lib_Elab_checkAutos(_$$0, _$$1.h2); } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } };
const Lib_Types_MkMc = ( h0, h1, h2, h3 ) => ({ tag: "MkMc",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Types_Unsolved = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: "Unsolved",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
const Lib_Types__mcmode = ( _$$0 ) => (_$$0.h2);
const Lib_Types__next = ( _$$0 ) => (_$$0.h1);
const Lib_Types_MC = ( h0, h1, h2 ) => ({ tag: "MC",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Elab_updateMeta = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => { const sc$$4 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__metas(mc)); switch (sc$$4.tag) { case "Nothing": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, _$$1(sc$$4.h1), ( me ) => (Data_IORef_writeIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), Lib_Types_MC(Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, me, Lib_Types__metas(mc)), Lib_Types__next(mc), Lib_Types__mcmode(mc))))); } }))));
const Lib_Elab_addConstraint = ( _$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => { const sc$$6 = Lib_Types__mcmode(mc); switch (sc$$6.tag) { case "CheckAll": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_updateMeta(_$$1, ( $$case ) => { switch ($$case.tag) { case "OutOfScope": return Lib_Types_error$27(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" out of scope")); case "Solved": return Lib_Types_error$27(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)($$case.h1)))(" already solved [addConstraint]")); case "Unsolved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Add constraint m")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$2)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Unsolved($$case.h0, $$case.h1, $$case.h2, $$case.h3, $$case.h4, Prelude__$3A$3A_(null, Lib_Types_MkMc(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$3), _$$0, _$$2, _$$3), $$case.h5))))); } }), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_checkAutos(_$$1, Data_SortedMap_listValues(null, null, Lib_Types__metas(mc1))), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit))))))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } }))));
const Lib_Types_CheckFirst = { tag: "CheckFirst" };
const Lib_Types_NoCheck = { tag: "NoCheck" };
const Lib_Elab_maybeCheck = ( _$$0 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => { const sc$$3 = Lib_Types__mcmode(mc); switch (sc$$3.tag) { case "NoCheck": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "CheckFirst": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_modifyIORef(null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), ( mc1 ) => (Lib_Types_MC(Lib_Types__metas(mc1), Lib_Types__next(mc1), Lib_Types_NoCheck))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, _$$0, ( _1 ) => (Data_IORef_modifyIORef(null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), ( mc1 ) => (Lib_Types_MC(Lib_Types__metas(mc1), Lib_Types__next(mc1), Lib_Types_CheckFirst))))))); case "CheckAll": return _$$0; } }))));
const Lib_Types_Solved = ( h0, h1, h2 ) => ({ tag: "Solved",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types_Bound = { tag: "Bound" };
const Lib_Types_Prelude_Eq$20Lib_Types_BD$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Defined": switch (_$$0.tag) { case "Defined": return Prelude_True; default: return Prelude_False; } break; case "Bound": switch (_$$0.tag) { case "Bound": return Prelude_True; default: return Prelude_False; } break; } };
const Lib_Types_Prelude_Eq$20Lib_Types_BD = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Lib_Types_Prelude_Eq$20Lib_Types_BD$2C_$3D$3D_(eta, eta1))));
const Prelude_filter = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": { const sc$$6 = _$$1(_$$2.h1); switch (sc$$6.tag) { case "False": return Prelude_filter(null, _$$1, _$$2.h2); case "True": return Prelude__$3A$3A_(null, _$$2.h1, Prelude_filter(null, _$$1, _$$2.h2)); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Elab__boundNames = ( _$$0 ) => (Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_snd(null, null, eta)))(Prelude_filter(null, ( x ) => (Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_BD)(Prelude_fst(null, null, x))(Lib_Types_Bound)), Prelude_zip(null, null, Lib_Types__bds(_$$0), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$0))))));
const Lib_Elab_lams = ( _$$0, _$$1, _$$2 ) => { switch (_$$0.tag) { case "S": switch (_$$1.tag) { case "_::_": return Lib_Types_Lam(Lib_Common_emptyFC, _$$1.h1, Lib_Types_Explicit, Lib_Types_Many, Lib_Elab_lams(_$$0.h0, _$$1.h2, _$$2)); case "Nil": return Lib_Types_Lam(Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("arg_")(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(_$$0.h0)))(""), Lib_Types_Explicit, Lib_Types_Many, Lib_Elab_lams(_$$0.h0, Prelude_Nil(null), _$$2)); } break; case "Z": return _$$2; } };
const Lib_Elab_renameSpine = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "_:<_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, _$$1, _$$2, _$$4.h2), ( xtm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_renameSpine(_$$0, _$$1, _$$2, _$$3, _$$4.h1), ( xs$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_App(Lib_Common_emptyFC, xs$27, xtm)))))); case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$3); } };
const Prelude_findIndex$27_go = ( _, _1, _2, _3, _$$4, _$$5 ) => { switch (_$$4.tag) { case "_::_": { const sc$$9 = _1(_$$4.h1); switch (sc$$9.tag) { case "False": return Prelude_findIndex$27_go(_, _1, _2, _3, _$$4.h2, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$5)(1)); case "True": return Prelude_Just(null, _$$5); } break; } case "Nil": return Prelude_Nothing(null); } };
const Prelude_findIndex$27 = ( a$$0, _$$1, _$$2 ) => { const go = null; return Prelude_findIndex$27_go(a$$0, _$$1, _$$2, go, _$$2, 0); };
const Lib_Common_Postpone = ( h0, h1, h2 ) => ({ tag: "Postpone",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Elab_rename = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "VLit": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lit(_$$3.h0, _$$3.h1)); case "VErased": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Erased(_$$3.h0)); case "VU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_UU(_$$3.h0)); case "VLetRec": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, _$$1, _$$2, _$$3.h2), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, Prelude__$3A$3A_(null, _$$2, _$$1), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$2), _$$3.h3), ( val$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, Prelude__$3A$3A_(null, _$$2, _$$1), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$2), _$$3.h4), ( body$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_LetRec(_$$3.h0, _$$3.h1, ty$27, val$27, body$27)))))))); case "VLet": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, _$$1, _$$2, _$$3.h2), ( val$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, Prelude__$3A$3A_(null, _$$2, _$$1), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$2), _$$3.h3), ( body$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Let(_$$3.h0, _$$3.h1, val$27, body$27)))))); case "VPi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, _$$1, _$$2, _$$3.h4), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$3.h5, Lib_Types_VVar(Lib_Common_emptyFC, _$$2, Prelude_Lin(null))), ( tmapp ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, Prelude__$3A$3A_(null, _$$2, _$$1), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$2), tmapp), ( scope$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Pi(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, ty$27, scope$27)))))))); case "VLam": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$3.h4, Lib_Types_VVar(_$$3.h0, _$$2, Prelude_Lin(null))), ( tapp ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$0, Prelude__$3A$3A_(null, _$$2, _$$1), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$2), tapp), ( scope ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lam(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, scope)))))); case "VMeta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("rename Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$3.h1)))(" spine "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$3.h2)))(""))), ( _ ) => { const sc$$8 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$3.h1)(_$$0); switch (sc$$8.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$3.h1), ( meta$27 ) => { switch (meta$27.tag) { case "Solved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("rename: ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$3.h1)))(" is solved"))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(meta$27.h2, _$$3.h2), ( val$27 ) => (Lib_Elab_rename(_$$0, _$$1, _$$2, val$27))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("rename: ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$3.h1)))(" is unsolved"))), ( _1 ) => (Lib_Types_catchError(null, Lib_Elab_renameSpine(_$$0, _$$1, _$$2, Lib_Types_Meta(_$$3.h0, _$$3.h1), _$$3.h2), ( err ) => (Lib_Types_throwError(null, Lib_Common_Postpone(_$$3.h0, _$$3.h1, Lib_Types_errorMsg(err))))))); } }); case "True": return Lib_Types_error(null, _$$3.h0, "meta occurs check"); } }); case "VCase": return Lib_Types_error(null, _$$3.h0, "Case in solution"); case "VRef": return Lib_Elab_renameSpine(_$$0, _$$1, _$$2, Lib_Types_Ref(_$$3.h0, _$$3.h1), _$$3.h2); case "VVar": { const sc$$7 = Prelude_findIndex$27(null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$3.h1), _$$1); switch (sc$$7.tag) { case "Nothing": return Lib_Types_error(null, _$$3.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("scope/skolem thinger VVar ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$3.h1)))(" ren "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_Int))(_$$1)))("")); case "Just": return Lib_Elab_renameSpine(_$$0, _$$1, _$$2, Lib_Types_Bnd(_$$3.h0, sc$$7.h1), _$$3.h2); } break; } } };
const Lib_Elab_invert_go = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$3.tag) { case "_:<_": { const _sc$$0 = _$$3.h2; switch (_sc$$0.tag) { case "VVar": { const _sc$$1 = _sc$$0.h2; switch (_sc$$1.tag) { case "Lin": { const sc$$12 = Prelude_elem(null, Prelude_Prelude_Eq$20Prim_Int, _sc$$0.h1, _$$4); switch (sc$$12.tag) { case "False": return Lib_Elab_invert_go(_, _1, _2, _$$3.h1, Prelude__$3A$3A_(null, _sc$$0.h1, _$$4)); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_sc$$0.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_Int))(_$$4)))(""))), ( _3 ) => (Lib_Types_error(null, _sc$$0.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("non-linear pattern: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_1)))("")))); } break; } default: return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("non-variable in pattern ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3.h2)))("")); } break; } default: return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("non-variable in pattern ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3.h2)))("")); } break; } case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_reverse(null)(_$$4)); } };
const Lib_Elab_invert = ( _$$0, _$$1 ) => { const go = null; return Lib_Elab_invert_go(_$$0, _$$1, go, _$$1, Prelude_Nil(null)); };
const Lib_Types_Prelude_Show$20Lib_Types_BD$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "Defined": return "def"; case "Bound": return "bnd"; } };
const Lib_Types_Prelude_Show$20Lib_Types_BD = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_BD$2Cshow);
const Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "AutoSolve": return "Auto"; case "User": return "User"; case "Normal": return "Normal"; } };
const Lib_Types_Prelude_Show$20Lib_Types_MetaKind = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_MetaKind$2Cshow);
const Lib_Types_Prelude_Show$20Lib_Types_MetaEntry$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "OutOfScope": return "OutOfScope"; case "Solved": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Solved ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h2)))(""); case "Unsolved": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Unsolved ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_$$0.h0)))(" "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_MetaKind)(_$$0.h4)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$0.h3)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_BD))(Lib_Types__bds(_$$0.h2))))(" cs "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Prelude_length(null, _$$0.h5))))(""); } };
const Lib_Types_Prelude_Show$20Lib_Types_MetaEntry = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_MetaEntry$2Cshow);
const Prelude_Prelude_Eq$20Prelude_Nat$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "S": switch (_$$0.tag) { case "S": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prelude_Nat)(_$$0.h0)(_$$1.h0); default: return Prelude_False; } break; case "Z": switch (_$$0.tag) { case "Z": return Prelude_True; default: return Prelude_False; } break; } };
const Prelude_Prelude_Eq$20Prelude_Nat = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Eq$20Prelude_Nat$2C_$3D$3D_(eta, eta1))));
const Lib_Elab_solve = ( _$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$1), ( $$sc ) => { switch ($$sc.tag) { case "Unsolved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SOLVE ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_MetaKind)($$sc.h4)))(" lvl "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Prelude_length$27(null, _$$0))))(" sp "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$2)))(" is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _ ) => { const size = Prelude_length(null, Prelude_filter(null, ( x ) => (Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_BD)(x)(Lib_Types_Bound)), Lib_Types__bds($$sc.h2))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" size is "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(size)))(" sps "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Data_SnocList_snoclen(null, _$$2))))(""))), ( _1 ) => { const sc$$15 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prelude_Nat)(Data_SnocList_snoclen(null, _$$2))(size); switch (sc$$15.tag) { case "True": { const l = Prelude_length$27(null, _$$0); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("meta ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_MetaEntry)($$sc)))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_invert(l, _$$2), ( ren ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(l, _$$3), ( hack ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, Lib_Types_CBN, hack), ( t ) => (Lib_Types_catchError(null, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_rename(_$$1, ren, l, t), ( tm ) => { const tm1 = Lib_Elab_lams(Data_SnocList_snoclen(null, _$$2), Prelude_reverse(null)(Lib_Elab__boundNames($$sc.h2)), tm); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, tm1), ( soln ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_updateMeta(_$$1, ( $$case ) => { switch ($$case.tag) { case "OutOfScope": return Lib_Types_error$27(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)($$sc.h1)))(" out of scope")); case "Solved": return Lib_Types_error$27(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)($$sc.h1)))(" already solved! [solve2]")); case "Unsolved": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Solved($$case.h0, $$case.h1, soln)); } }), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_maybeCheck(Prelude_for_(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, $$sc.h5, ( $$case ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(soln, $$case.h2), ( val ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("discharge l=")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Prelude_length$27(null, $$case.h1))))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(val)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)($$case.h3)))(""))), ( _4 ) => (Lib_Elab_unify($$case.h1, Lib_Elab_UNormal, val, $$case.h3)))))))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit))))))))))); }), ( $$case ) => { switch ($$case.tag) { case "Postpone": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CONSTRAINT2 m")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)($$case.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$2)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(t)))(""))), ( _3 ) => (Lib_Elab_addConstraint(_$$0, _$$1, _$$2, t))); default: return Lib_Types_throwError(null, $$case); } }))))))))); break; } default: { const l = Prelude_length$27(null, _$$0); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" ("))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)($$sc.h1)))(") applied to "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Data_SnocList_snoclen(null, _$$2))))(" args instead of "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(size)))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CONSTRAINT m")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)($$sc.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_SnocList$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$2)))(" =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _3 ) => (Lib_Elab_addConstraint(_$$0, _$$1, _$$2, _$$3))))); break; } } }); }); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" already solved! [solve]")); } }));
const Prelude__$3E$3E_ = ( m$$0, a$$1, b$$2, _$$3, _$$4, _$$5 ) => (Prelude_bind(null, _$$3)(null)(null)(_$$4)(( _ ) => (_$$5)));
const Prelude_Prelude_Ord$20Prelude_Nat$2Ccompare = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "S": switch (_$$0.tag) { case "S": return Prelude_compare(null, Prelude_Prelude_Ord$20Prelude_Nat)(_$$0.h0)(_$$1.h0); case "Z": return Prelude_LT; } break; case "Z": switch (_$$0.tag) { case "Z": return Prelude_EQ; default: return Prelude_GT; } break; } };
const Prelude_Prelude_Ord$20Prelude_Nat = Prelude_MkOrd(null, ( eta ) => (( eta1 ) => (Prelude_Prelude_Ord$20Prelude_Nat$2Ccompare(eta, eta1))));
const Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$9, _$$10 ) => { switch (_$$10.tag) { case "VMeta": switch (_$$9.tag) { case "VMeta": { const sc$$17 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$9.h1)(_$$10.h1); switch (sc$$17.tag) { case "False": { const sc$$18 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prelude_Nat, Data_SnocList_snoclen(null, _$$9.h2), Data_SnocList_snoclen(null, _$$10.h2)); switch (sc$$18.tag) { case "False": return Prelude__$3E$3E_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solve(_, _$$9.h1, _$$9.h2, Lib_Types_VMeta(_$$10.h0, _$$10.h1, _$$10.h2)), Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_neutral(null, Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult))); case "True": return Prelude__$3E$3E_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solve(_, _$$10.h1, _$$10.h2, Lib_Types_VMeta(_$$9.h0, _$$9.h1, _$$9.h2)), Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_neutral(null, Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult))); } break; } case "True": return Lib_Elab_unifySpine(_, _1, Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$9.h1)(_$$10.h1), _$$9.h2, _$$10.h2); } break; } default: return Prelude__$3E$3E_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solve(_, _$$10.h1, _$$10.h2, _$$9), Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_neutral(null, Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult))); } break; default: switch (_$$9.tag) { case "VMeta": return Prelude__$3E$3E_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solve(_, _$$9.h1, _$$9.h2, _$$10), Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_neutral(null, Lib_Elab_Prelude_Monoid$20Lib_Elab_UnifyResult))); default: return Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam(_, _1, _2, _3, _4, _5, _6, _7, _$$9, _$$10); } break; } };
const Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta_unifyPattern = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$10, _$$11 ) => { switch (_$$11.tag) { case "VVar": switch (_$$10.tag) { case "VVar": { const sc$$18 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$10.h1)(_$$11.h1); switch (sc$$18.tag) { case "False": { const sc$$19 = Prelude__$2C_(null, null, _$$10.h2, _$$11.h2); const _sc$$0 = sc$$19.h2; switch (_sc$$0.tag) { case "Lin": { const _sc$$1 = sc$$19.h3; switch (_sc$$1.tag) { case "Lin": { const sc$$26 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _$$10.h1, _$$11.h1); switch (sc$$26.tag) { case "False": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Elab_MkResult(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$11.h1, _$$10), Prelude_Nil(null)))); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Elab_MkResult(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$10.h1, _$$11), Prelude_Nil(null)))); } break; } default: return Lib_Types_error(null, _$$10.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Failed to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$10)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$11)))("")); } break; } default: return Lib_Types_error(null, _$$10.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Failed to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$10)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$11)))("")); } break; } case "True": return Lib_Elab_unifySpine(_, _1, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$10.h1)(_$$11.h1), _$$10.h2, _$$11.h2); } break; } default: { const _sc$$0 = _$$11.h2; switch (_sc$$0.tag) { case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Elab_MkResult(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$11.h1, _$$10), Prelude_Nil(null)))); default: return Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta(_, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11); } break; } } break; default: switch (_$$10.tag) { case "VVar": { const _sc$$0 = _$$10.h2; switch (_sc$$0.tag) { case "Lin": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Elab_MkResult(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$10.h1, _$$11), Prelude_Nil(null)))); default: return Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta(_, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11); } break; } default: return Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta(_, _1, _2, _3, _4, _5, _6, _7, _8, _$$10, _$$11); } break; } };
const Lib_Elab_forceMeta = ( _$$0 ) => { switch (_$$0.tag) { case "VMeta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$0.h1), ( meta ) => { switch (meta.tag) { case "Solved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(meta.h2, _$$0.h2), Lib_Elab_forceMeta); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VMeta(_$$0.h0, _$$0.h1, _$$0.h2)); } }); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$0); } };
const Lib_Elab_unify = ( _$$0, _$$1, _$$2, _$$3 ) => { const unifyRest = null; const unifyRef = null; const unifyVar = null; const unifyLam = null; const unifyMeta = null; const unifyPattern = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Unify lvl ")(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Prelude_length(null, _$$0))))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$2)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  =?= ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_$$2), ( eta ) => (Lib_Eval_unlet(_$$0, eta))), ( t$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_$$3), ( eta ) => (Lib_Eval_unlet(_$$0, eta))), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("forced ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(t$27)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  =?= ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(u$27)))(""))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("env ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(_$$0)))(""))), ( _5 ) => { const l = Prelude_length$27(null, _$$0); switch (_$$1.tag) { case "UPattern": return Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta_unifyPattern(_$$0, _$$1, _$$2, _$$3, unifyRest, unifyRef, unifyVar, unifyLam, unifyMeta, unifyPattern, t$27, u$27); case "UNormal": return Lib_Elab_unify_unifyRest_unifyRef_unifyVar_unifyLam_unifyMeta(_$$0, _$$1, _$$2, _$$3, unifyRest, unifyRef, unifyVar, unifyLam, unifyMeta, t$27, u$27); } }))))))))))))))); };
const Lib_Elab_unifyCatch = ( _$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_catchError(null, Lib_Elab_unify(Lib_Types__env(_$$1), Lib_Elab_UNormal, _$$2, _$$3), ( err ) => { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$1)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("fail ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$2)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_$$1), _$$2), ( a ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_$$1), _$$3), ( b ) => { const msg = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unification failure: ")(Lib_Types_errorMsg(err)))("\n  failed to unify "))(Lib_Elab_rpprint(names, a)))("\n             with "))(Lib_Elab_rpprint(names, b)))("\n  "); return Lib_Types_throwError(null, Lib_Common_E(_$$0, msg)); }))))); }), ( res ) => { const _sc$$0 = res.h0; switch (_sc$$0.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("fail with constraints ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Elab__constraints(res))))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_$$1), _$$2), ( a ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_$$1), _$$3), ( b ) => { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$1)); const msg = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unification failure\n  failed to unify ")(Lib_Elab_rpprint(names, a)))("\n             with "))(Lib_Elab_rpprint(names, b)))(""); const msg1 = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(msg)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("\nconstraints ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Elab__constraints(res))))("")); return Lib_Types_throwError(null, Lib_Common_E(_$$0, msg1)); }))))); } }));
const Lib_Syntax_foo = ( _$$0 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Data_String_unwords(_$$0))(")")));
const Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "Auto": return "Auto"; case "Explicit": return "Explicit"; case "Implicit": return "Implicit"; } };
const Lib_Types_Prelude_Show$20Lib_Types_Icit = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_Icit$2Cshow);
const Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo$2Cshow = ( _$$0 ) => (Lib_Syntax_foo(Prelude__$3A$3A_(null, "BI", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3), Prelude_Nil(null)))))));
const Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo = Prelude_MkShow(null, Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo$2Cshow);
const Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt$2Cshow = ( _$$0 ) => (Lib_Syntax_foo(Prelude__$3A$3A_(null, "MkAlt", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h0), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude_Nil(null))))));
const Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt = Prelude_MkShow(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt$2Cshow);
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "RAs": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "RAs", Prelude__$3A$3A_(null, _$$0.h1, Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude_Nil(null))))); case "RWhere": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Where", Prelude__$3A$3A_(null, "FIXME", Prelude_Nil(null)))); case "RIf": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "If", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h3), Prelude_Nil(null)))))); case "RDo": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "DO", Prelude__$3A$3A_(null, "FIXME", Prelude_Nil(null)))); case "RHole": return "?"; case "RImplicit": return "_"; case "RCase": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Case", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_RCaseAlt))(_$$0.h2), Prelude_Nil(null))))); case "RLit": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "RLit", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$0.h1), Prelude_Nil(null)))); case "RAnn": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "RAnn", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude_Nil(null))))); case "RLet": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Let", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1), Prelude__$3A$3A_(null, " : ", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude__$3A$3A_(null, " = ", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h3), Prelude__$3A$3A_(null, " in ", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h4), Prelude_Nil(null)))))))))); case "RPi": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Pi", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h3), Prelude_Nil(null)))))); case "RU": return "U"; case "RApp": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "App", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h3), Prelude_Nil(null)))))); case "RLam": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Lam", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude_Nil(null))))); case "RVar": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "RVar", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1), Prelude_Nil(null)))); } };
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw = Prelude_MkShow(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw$2Cshow);
const Lib_Types_Normal = { tag: "Normal" };
const Lib_Elab_freshMeta_applyBDs = ( _, _1, _2, _3, _4, _$$5, _$$6, _$$7 ) => { switch (_$$7.tag) { case "_::_": { const _sc$$0 = _$$7.h1; switch (_sc$$0.tag) { case "Defined": return Lib_Elab_freshMeta_applyBDs(_, _1, _2, _3, _4, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$5), _$$6, _$$7.h2); case "Bound": return Lib_Types_App(Lib_Common_emptyFC, Lib_Elab_freshMeta_applyBDs(_, _1, _2, _3, _4, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$5), _$$6, _$$7.h2), Lib_Types_Bnd(Lib_Common_emptyFC, _$$5)); } break; } case "Nil": return _$$6; } };
const Lib_Elab_freshMeta = ( _$$0, _$$1, _$$2, _$$3 ) => { const applyBDs = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("fresh meta ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Lib_Types__next(mc))))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$2)))(" ("))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_MetaKind)(_$$3)))(")"))), ( _ ) => { const qn = Lib_Common_QN(Lib_Types__ns(top), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("$m")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Lib_Types__next(mc))))("")); const newmeta = Lib_Types_Unsolved(_$$1, qn, _$$0, _$$2, _$$3, Prelude_Nil(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_writeIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), Lib_Types_MC(Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, qn, newmeta, Lib_Types__metas(mc)), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(Lib_Types__next(mc)), Lib_Types__mcmode(mc))), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Elab_freshMeta_applyBDs(_$$0, _$$1, _$$2, _$$3, applyBDs, 0, Lib_Types_Meta(_$$1, qn), Lib_Types__bds(_$$0))))); }))))); };
const Lib_Types_AutoSolve = { tag: "AutoSolve" };
const Lib_Elab_insert = ( ctx$$0, _$$1, _$$2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_$$2), ( ty$27 ) => { switch (ty$27.tag) { case "VPi": { const _sc$$0 = ty$27.h2; switch (_sc$$0.tag) { case "Auto": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(ctx$$0, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$1), ty$27.h4, Lib_Types_AutoSolve), ( m ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("INSERT Auto ")(Lib_Elab_rpprint(Lib_Types_names(ctx$$0), m)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty$27.h4)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TM ")(Lib_Elab_rpprint(Lib_Types_names(ctx$$0), _$$1)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(ctx$$0), Lib_Types_CBN, m), ( mv ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(ty$27.h5, mv), ( bapp ) => (Lib_Elab_insert(ctx$$0, Lib_Types_App(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$1), _$$1, m), bapp))))))))))); case "Implicit": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(ctx$$0, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$1), ty$27.h4, Lib_Types_Normal), ( m ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("INSERT ")(Lib_Elab_rpprint(Lib_Types_names(ctx$$0), m)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty$27.h4)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TM ")(Lib_Elab_rpprint(Lib_Types_names(ctx$$0), _$$1)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(ctx$$0), Lib_Types_CBN, m), ( mv ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(ty$27.h5, mv), ( bapp ) => (Lib_Elab_insert(ctx$$0, Lib_Types_App(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$1), _$$1, m), bapp))))))))))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, _$$1, ty$27)); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, _$$1, ty$27)); } }));
const Lib_Types_Prelude_Show$20Lib_Types_Def$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "PrimFn": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("PrimFn ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h0)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(_$$0.h1)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_$$0.h2)))(""); case "PrimTCon": return "PrimTCon"; case "Fn": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Fn ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Tm)(_$$0.h0)))(""); case "DCon": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("DCon ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h0)))(" "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h1)))(""); case "TCon": return Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TCon ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_$$0.h1)))(""); case "Axiom": return "axiom"; } };
const Lib_Types_Prelude_Show$20Lib_Types_Def = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_Def$2Cshow);
const Lib_Elab_infer_go = ( _, _1, _2, _3, _4, _$$5, _$$6 ) => { switch (_$$6.tag) { case "_::_": { const _sc$$0 = _$$6.h1; const sc$$14 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h2)(_3); switch (sc$$14.tag) { case "False": return Lib_Elab_infer_go(_, _1, _2, _3, _4, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$5)(1), _$$6.h2); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Bnd(_2, _$$5), _sc$$0.h3)); } break; } case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$9 = Lib_TopContext_lookupRaw(_3, top); switch (sc$$9.tag) { case "Nothing": return Lib_Types_error(null, _2, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_3)))(" not in scope")); case "Just": { const _sc$$0 = sc$$9.h1; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("lookup ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" as "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Def)(_sc$$0.h3)))(""))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$0.h2), ( vty ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Ref(_2, _sc$$0.h1), vty)))))); break; } } }); } };
const Lib_Types_MkCtx = ( h0, h1, h2, h3, h4 ) => ({ tag: "MkCtx",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Types_extend = ( _$$0, _$$1, _$$2 ) => (Lib_Types_MkCtx(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$0.h0), Prelude__$3A$3A_(null, Lib_Types_VVar(Lib_Common_emptyFC, _$$0.h0, Prelude_Lin(null)), _$$0.h1), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1, _$$2), _$$0.h2), Prelude__$3A$3A_(null, Lib_Types_Bound, _$$0.h3), _$$0.h4));
const Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Auto": switch (_$$0.tag) { case "Auto": return Prelude_True; default: return Prelude_False; } break; case "Explicit": switch (_$$0.tag) { case "Explicit": return Prelude_True; default: return Prelude_False; } break; case "Implicit": switch (_$$0.tag) { case "Implicit": return Prelude_True; default: return Prelude_False; } break; } };
const Lib_Types_Prelude_Eq$20Lib_Types_Icit = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Lib_Types_Prelude_Eq$20Lib_Types_Icit$2C_$3D$3D_(eta, eta1))));
const Lib_Types_Implicit = { tag: "Implicit" };
const Lib_Types_Auto = { tag: "Auto" };
const Lib_Types_Icit = { tag: "Icit" };
const Prelude_the = ( a$$0, _$$1 ) => (_$$1);
const Lib_Types_Defined = { tag: "Defined" };
const Lib_Types_define = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Types_MkCtx(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$0.h0), Prelude__$3A$3A_(null, _$$2, _$$0.h1), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$1, _$$3), _$$0.h2), Prelude__$3A$3A_(null, Lib_Types_Defined, _$$0.h3), _$$0.h4));
const Lib_Types_LString = ( h0 ) => ({ tag: "LString",  h0: h0 });
const Lib_Elab_stringType = Lib_Common_QN(Prelude__$3A$3A_(null, "Prim", Prelude_Nil(null)), "String");
const Lib_Elab_primType = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$3 = Lib_TopContext_lookup(_$$1, top); switch (sc$$3.tag) { case "Just": { const _sc$$0 = sc$$3.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PrimTCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_VRef(_$$0, _sc$$0.h1, Prelude_Lin(null))); default: return Lib_Types_error(null, _$$0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Primitive type ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" not in scope")); } break; } default: return Lib_Types_error(null, _$$0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Primitive type ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$1)))(" not in scope")); } }));
const Lib_Types_LInt = ( h0 ) => ({ tag: "LInt",  h0: h0 });
const Lib_Elab_intType = Lib_Common_QN(Prelude__$3A$3A_(null, "Prim", Prelude_Nil(null)), "Int");
const Lib_Types_LChar = ( h0 ) => ({ tag: "LChar",  h0: h0 });
const Lib_Elab_charType = Lib_Common_QN(Prelude__$3A$3A_(null, "Prim", Prelude_Nil(null)), "Char");
const Lib_Elab_infer = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "RAs": return Lib_Types_error(null, _$$1.h0, "@ can only be used in patterns"); case "RImplicit": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, ty), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(_$$0, _$$1.h0, vty, Lib_Types_Normal), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, tm, vty)))))))); case "RLit": { const _sc$$0 = _$$1.h1; switch (_sc$$0.tag) { case "LChar": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_primType(_$$1.h0, Lib_Elab_charType), ( ty ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Lit(_$$1.h0, Lib_Types_LChar(_sc$$0.h0)), ty)))); case "LInt": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_primType(_$$1.h0, Lib_Elab_intType), ( ty ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Lit(_$$1.h0, Lib_Types_LInt(_sc$$0.h0)), ty)))); case "LString": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_primType(_$$1.h0, Lib_Elab_stringType), ( ty ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Lit(_$$1.h0, Lib_Types_LString(_sc$$0.h0)), ty)))); } break; } case "RAnn": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h2, Lib_Types_VU(_$$1.h0)), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, ty), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h1, vty), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, tm, vty)))))))); case "RLet": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h2, Lib_Types_VU(Lib_Common_emptyFC)), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, ty$27), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h3, vty), ( v$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, v$27), ( vv ) => { const ctx$27 = Lib_Types_define(_$$0, _$$1.h1, vv, vty); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(ctx$27, _$$1.h4), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Let(_$$1.h0, _$$1.h1, v$27, $$sc.h2), $$sc.h3)))); }))))))); case "RPi": { const _sc$$0 = _$$1.h1; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h2, Lib_Types_VU(_sc$$0.h0)), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, ty$27), ( vty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_extend(_$$0, _sc$$0.h1, vty$27), _$$1.h3, Lib_Types_VU(_sc$$0.h0)), ( ty2$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Pi(_sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, ty$27, ty2$27), Lib_Types_VU(_sc$$0.h0))))))))); break; } case "RU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_UU(_$$1.h0), Lib_Types_VU(_$$1.h0))); case "RApp": { const sc$$6 = Prelude_the(Lib_Types_Icit, _$$1.h3); switch (sc$$6.tag) { case "Auto": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(_$$0, _$$1.h1), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Auto, Prelude__$2C_(null, null, $$sc.h2, $$sc.h3))))), ( $$sc ) => { const _sc$$0 = $$sc.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_sc$$0.h3), ( tty$27 ) => { switch (tty$27.tag) { case "VPi": { const sc$$24 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(tty$27.h2)($$sc.h2); switch (sc$$24.tag) { case "False": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("IcitMismatch ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)($$sc.h2)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(tty$27.h2)))("")); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, tty$27.h4, tty$27.h5)); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify PI for ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(tty$27)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal), ( eta ) => (Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, eta))), ( a ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_MkClosure(Lib_Types__env(_$$0), eta)), Lib_Elab_freshMeta(Lib_Types_extend(_$$0, ":ins", a), _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal)), ( b ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(_$$1.h0, _$$0, tty$27, Lib_Types_VPi(_$$1.h0, ":ins", $$sc.h2, Lib_Types_Many, a, b)), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, a, b)))))))))); } }), ( $$sc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h2, $$sc1.h2), ( u ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, u), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_($$sc1.h3, u$27), ( bappu ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_App(_$$1.h0, _sc$$0.h2, u), bappu)))))))))); }); case "Explicit": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(_$$0, _$$1.h1), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_insert(_$$0, $$sc.h2, $$sc.h3), ( $$sc1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Explicit, Prelude__$2C_(null, null, $$sc1.h2, $$sc1.h3))))))), ( $$sc ) => { const _sc$$0 = $$sc.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_sc$$0.h3), ( tty$27 ) => { switch (tty$27.tag) { case "VPi": { const sc$$24 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(tty$27.h2)($$sc.h2); switch (sc$$24.tag) { case "False": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("IcitMismatch ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)($$sc.h2)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(tty$27.h2)))("")); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, tty$27.h4, tty$27.h5)); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify PI for ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(tty$27)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal), ( eta ) => (Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, eta))), ( a ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_MkClosure(Lib_Types__env(_$$0), eta)), Lib_Elab_freshMeta(Lib_Types_extend(_$$0, ":ins", a), _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal)), ( b ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(_$$1.h0, _$$0, tty$27, Lib_Types_VPi(_$$1.h0, ":ins", $$sc.h2, Lib_Types_Many, a, b)), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, a, b)))))))))); } }), ( $$sc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h2, $$sc1.h2), ( u ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, u), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_($$sc1.h3, u$27), ( bappu ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_App(_$$1.h0, _sc$$0.h2, u), bappu)))))))))); }); case "Implicit": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(_$$0, _$$1.h1), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Implicit, Prelude__$2C_(null, null, $$sc.h2, $$sc.h3))))), ( $$sc ) => { const _sc$$0 = $$sc.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_sc$$0.h3), ( tty$27 ) => { switch (tty$27.tag) { case "VPi": { const sc$$24 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(tty$27.h2)($$sc.h2); switch (sc$$24.tag) { case "False": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("IcitMismatch ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)($$sc.h2)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(tty$27.h2)))("")); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, tty$27.h4, tty$27.h5)); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify PI for ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(tty$27)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(_$$0, _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal), ( eta ) => (Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, eta))), ( a ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_MkClosure(Lib_Types__env(_$$0), eta)), Lib_Elab_freshMeta(Lib_Types_extend(_$$0, ":ins", a), _$$1.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal)), ( b ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(_$$1.h0, _$$0, tty$27, Lib_Types_VPi(_$$1.h0, ":ins", $$sc.h2, Lib_Types_Many, a, b)), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, a, b)))))))))); } }), ( $$sc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _$$1.h2, $$sc1.h2), ( u ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, u), ( u$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_($$sc1.h3, u$27), ( bappu ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_App(_$$1.h0, _sc$$0.h2, u), bappu)))))))))); }); } break; } case "RLam": { const _sc$$0 = _$$1.h1; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_freshMeta(_$$0, _sc$$0.h0, Lib_Types_VU(Lib_Common_emptyFC), Lib_Types_Normal), ( eta ) => (Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, eta))), ( a ) => { const ctx$27 = Lib_Types_extend(_$$0, _sc$$0.h1, a); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(ctx$27, _$$1.h2), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("make lam for ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_sc$$0.h1)))(" scope "))(Lib_Elab_rpprint(Lib_Types_names(_$$0), $$sc.h2)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)($$sc.h3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(Lib_Types__lvl(_$$0)), $$sc.h3), ( tyb ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Lib_Types_Lam(_sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, $$sc.h2), Lib_Types_VPi(_sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, a, Lib_Types_MkClosure(Lib_Types__env(_$$0), tyb)))))))))); }); break; } case "RVar": { const go = null; return Lib_Elab_infer_go(_$$0, _$$1, _$$1.h0, _$$1.h1, go, 0, Lib_Types__types(_$$0)); break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$1), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Implement infer ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$1)))("")); } };
const Lib_Eval_prvalCtx = ( ctx$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(ctx$$0), _$$1), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(ctx$$0)), tm))))));
const Lib_Types_logM = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3C$3D_(null, Prelude_Prelude_Ord$20Prim_Int, _$$0, Lib_Types__verbose(top)), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, _$$1, ( msg ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, msg))))))));
const Lib_Types_debugM = ( _$$0 ) => (Lib_Types_logM(2, _$$0));
const Lib_Elab_MkProb = ( h0, h1 ) => ({ tag: "MkProb",  h0: h0,  h1: h1 });
const Lib_Elab_showCtx_isVar = ( _, _1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "VVar": { const _sc$$0 = _$$3.h2; switch (_sc$$0.tag) { case "Lin": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$2)(_$$3.h1); default: return Prelude_False; } break; } default: return Prelude_False; } };
const Lib_Elab_showCtx_isVar_go = ( _, _1, _2, _$$3, _$$4, _$$5, _$$6 ) => { switch (_$$5.tag) { case "_::_": { const _sc$$0 = _$$5.h1; const _sc$$1 = _sc$$0.h3; const sc$$18 = Lib_Elab_showCtx_isVar(_, _1, _$$4, _sc$$0.h2); switch (sc$$18.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$0.h2), ( tm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$1.h3), ( tty ) => (Lib_Elab_showCtx_isVar_go(_, _1, _2, _$$3, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$4), _$$5.h2, Prelude__$3A$3A_(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(_sc$$1.h2))(" = "))(Lib_Elab_rpprint(_$$3, tm)))(" : "))(Lib_Elab_rpprint(_$$3, tty)))(""), _$$6)))))); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$1.h3), ( tty ) => (Lib_Elab_showCtx_isVar_go(_, _1, _2, _$$3, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$4), _$$5.h2, Prelude__$3A$3A_(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(_sc$$1.h2))(" : "))(Lib_Elab_rpprint(_$$3, tty)))(""), _$$6)))); } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$6); } };
const Lib_Elab_showCtx = ( _$$0 ) => { const isVar = null; const go = null; return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude_unlines, Prelude_reverse(null), eta)), Lib_Elab_showCtx_isVar_go(_$$0, isVar, go, Lib_Types_names(_$$0), 0, Prelude_reverse(null)(Prelude_zip(null, null, Lib_Types__env(_$$0), Lib_Types__types(_$$0))), Prelude_Nil(null))); };
const Lib_Types__ctxFC = ( _$$0 ) => (_$$0.h4);
const Lib_Types_CBV = { tag: "CBV" };
const Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "Nothing": return "Nothing"; case "Just": return "Just {show a}"; } };
const Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29 = ( a, _ ) => (Prelude_MkShow(null, ( eta ) => (Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29$2Cshow(null, _, eta))));
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "PatLit": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PatLit", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$0.h1), Prelude_Nil(null)))); case "PatWild": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PatWild", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h1), Prelude_Nil(null)))); case "PatCon": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PatCon", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern))(_$$0.h3), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_$$0.h4), Prelude_Nil(null))))))); case "PatVar": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PatVar", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h2), Prelude_Nil(null))))); } };
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern = Prelude_MkShow(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern$2Cshow);
const Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case "PatLit": return _$$0.h0; case "PatWild": return _$$0.h0; case "PatCon": return _$$0.h0; case "PatVar": return _$$0.h0; } };
const Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern = Lib_Common_MkHasFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern$2CgetFC);
const Lib_Elab_checkDone_rename = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _$$15 ) => { switch (_$$15.tag) { case "_::_": { const _sc$$0 = _$$15.h1; const sc$$23 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h2)(_9); switch (sc$$23.tag) { case "False": return Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h2, _sc$$0.h3), Lib_Elab_checkDone_rename(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _$$15.h2)); case "True": return Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _13, _sc$$0.h3), _$$15.h2); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Elab_checkDone = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PatWild": return Lib_Elab_checkDone(_$$0, _$$1.h2, _$$2, _$$3); case "PatVar": { const rename = null; const ctx = Lib_Types_MkCtx(Lib_Types__lvl(_$$0), Lib_Types__env(_$$0), Lib_Elab_checkDone_rename(_$$0, _$$1, _$$2, _$$3, _$$1.h0, _$$1.h1, _$$1.h2, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, _sc$$1.h0, _sc$$1.h1, _sc$$1.h2, rename, Lib_Types__types(_$$0)), Lib_Types__bds(_$$0), Lib_Types__ctxFC(_$$0)); return Lib_Elab_checkDone(ctx, _$$1.h2, _$$2, _$$3); break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_sc$$0.h3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("stray constraint ")(_sc$$0.h2))(" /? "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)(_sc$$0.h3)))("")); } break; } case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("DONE-> check body ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$2)))(" at "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debugM(Lib_Elab_showCtx(_$$0)), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Lib_Types__env(_$$0), ( val ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude_length$27(null, Lib_Types__env(_$$0)), val), ( ty ) => (Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBV, ty))))), ( env$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Lib_Types__types(_$$0), ( $$case ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude_length$27(null, env$27), $$case.h3), ( nty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(env$27, Lib_Types_CBV, nty), ( ty$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, $$case.h2, ty$27)))))))), ( types$27 ) => { const ctx = Lib_Types_MkCtx(Lib_Types__lvl(_$$0), env$27, types$27, Lib_Types__bds(_$$0), Lib_Types__ctxFC(_$$0)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => ("AFTER")), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debugM(Lib_Elab_showCtx(ctx)), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude_length$27(null, Lib_Types__env(ctx)), _$$3), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(ctx), Lib_Types_CBN, ty), ( ty1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("check at ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty1)))(""))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(ctx, _$$2, ty1), ( got ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("DONE<- got ")(Lib_Elab_rpprint(Lib_Types_names(ctx), got)))(""))), ( _5 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(got))))))))))))))); }))))))); } };
const Lib_Elab__ty = ( _$$0 ) => (_$$0.h1);
const Lib_Elab__clauses = ( _$$0 ) => (_$$0.h0);
const Lib_Syntax__cons = ( _$$0 ) => (_$$0.h1);
const Prelude_find = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": { const sc$$6 = _$$1(_$$2.h1); switch (sc$$6.tag) { case "False": return Prelude_find(null, _$$1, _$$2.h2); case "True": return Prelude_Just(null, _$$2.h1); } break; } case "Nil": return Prelude_Nothing(null); } };
const Lib_Elab_buildDefault_isDefault = ( _, _1, _2, _3, _4, _5, _$$6 ) => { const sc$$7 = Prelude_find(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_3), ( eta ) => (Prelude_fst(null, null, eta)), eta)), Lib_Syntax__cons(_$$6)); switch (sc$$7.tag) { case "Nothing": return Prelude_True; case "Just": { const _sc$$0 = sc$$7.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PatWild": return Prelude_True; case "PatVar": return Prelude_True; default: return Prelude_False; } break; } } };
const Lib_Elab_buildDefault = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { const isDefault = null; const defclauses = Prelude_filter(null, ( eta ) => (Lib_Elab_buildDefault_isDefault(_$$0, _$$1, _$$2, _$$3, _$$4, isDefault, eta)), Lib_Elab__clauses(_$$1)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, defclauses))(0), ( _ ) => (Lib_Types_error(null, _$$2, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("missing cases ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_$$4)))(" on "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$3)))("")))), ( _ ) => (Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Lib_Types_CaseDefault, Lib_Elab_buildTree(_$$0, Lib_Elab_MkProb(defclauses, Lib_Elab__ty(_$$1)))))); };
const Lib_Types_Prelude_Show$20Lib_Types_CaseAlt$2Cshow = Lib_Types_showCaseAlt;
const Lib_Types_Prelude_Show$20Lib_Types_CaseAlt = Prelude_MkShow(null, Lib_Types_Prelude_Show$20Lib_Types_CaseAlt$2Cshow);
const Lib_Elab_buildCase_constrainSpine_getName = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _$$15 ) => (_$$15.h0);
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow = ( _$$0 ) => (Prelude_show(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Common_Prelude_Show$20Lib_Common_FC, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)), Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern), Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw))))(Prelude__$2C_(null, null, _$$0.h0, Prelude__$2C_(null, null, _$$0.h1, Prelude__$2C_(null, null, _$$0.h2, _$$0.h3)))));
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause = Prelude_MkShow(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause$2Cshow);
const Lib_Syntax_MkClause = ( h0, h1, h2, h3 ) => ({ tag: "MkClause",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Syntax_PatVar = ( h0, h1, h2 ) => ({ tag: "PatVar",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Syntax_PatWild = ( h0, h1 ) => ({ tag: "PatWild",  h0: h0,  h1: h1 });
const Lib_Syntax_getIcit = ( _$$0 ) => { switch (_$$0.tag) { case "PatLit": return Lib_Types_Explicit; case "PatWild": return _$$0.h1; case "PatCon": return _$$0.h1; case "PatVar": return _$$0.h1; } };
const Lib_Elab_buildCase_constrainSpine_getName_makeConstr = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$16, _$$17, _$$18 ) => { switch (_$$18.tag) { case "_::_": switch (_$$17.tag) { case "_::_": { const _sc$$0 = _$$17.h1; const _sc$$1 = _sc$$0.h1; switch (_sc$$1.tag) { case "Explicit": { const sc$$28 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(Lib_Syntax_getIcit(_$$18.h1))(Lib_Types_Explicit); switch (sc$$28.tag) { case "False": return Lib_Types_error(null, Lib_Types__ctxFC(_), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("mismatch between Explicit and ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(Lib_Syntax_getIcit(_$$18.h1))))("")); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$16, _$$17.h2, _$$18.h2), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, _$$18.h1), rest)))); } break; } default: { const sc$$28 = Prelude__$2F$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit, Lib_Syntax_getIcit(_$$18.h1), _sc$$0.h1); switch (sc$$28.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$16, _$$17.h2, _$$18.h2), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, _$$18.h1), rest)))); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$16, _$$17.h2, Prelude__$3A$3A_(null, _$$18.h1, _$$18.h2)), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, Lib_Syntax_PatWild(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_$$18.h1), _sc$$0.h1)), rest)))); } break; } } break; } case "Nil": return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_$$18.h1), "too many patterns"); } break; case "Nil": switch (_$$17.tag) { case "_::_": { const _sc$$0 = _$$17.h1; const _sc$$1 = _sc$$0.h1; switch (_sc$$1.tag) { case "Auto": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$16, _$$17.h2, Prelude_Nil(null)), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, Lib_Syntax_PatWild(Lib_Common_emptyFC, Lib_Types_Auto)), rest)))); case "Explicit": return Lib_Types_error(null, _$$16, "not enough patterns"); case "Implicit": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _$$16, _$$17.h2, Prelude_Nil(null)), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, Lib_Syntax_PatWild(Lib_Common_emptyFC, Lib_Types_Implicit)), rest)))); } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nil(null)); } break; } };
const Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _$$17, _$$18, _$$19, _$$20 ) => { switch (_$$19.tag) { case "_::_": { const _sc$$0 = _$$19.h1; const sc$$28 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h2)(_2); switch (sc$$28.tag) { case "False": return Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _$$17, _$$18, _$$19.h2, Prelude__$3A$3A_(null, _$$19.h1, _$$20)); case "True": { const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PatLit": return Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Literal ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_sc$$1.h1)))(" in constructor split")); case "PatWild": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Prelude__$3A$3A_(null, _$$19.h1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$19.h2)(_$$20)))); case "PatCon": { const sc$$35 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_sc$$1.h2)(_7); switch (sc$$35.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$37 = Lib_TopContext_lookup(_sc$$1.h2, top); switch (sc$$37.tag) { case "Nothing": return Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal Error: DCon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$1.h2)))(" not found")); case "Just": { const _sc$$2 = sc$$37.h1; const _sc$$3 = _sc$$2.h3; switch (_sc$$3.tag) { case "DCon": { const sc$$46 = Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _sc$$3.h1, _$$17); switch (sc$$46.tag) { case "False": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); case "True": return Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Constructor is ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$3.h1)))(" expected "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$17)))("")); } break; } default: return Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal Error: ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$1.h2)))(" is not a DCon")); } break; } } }); case "True": { const _sc$$2 = _sc$$1.h4; switch (_sc$$2.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _sc$$1.h0, _$$18, _sc$$1.h3), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(rest)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$19.h2)(_$$20)))))); case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _sc$$1.h0, _$$18, _sc$$1.h3), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _2, Lib_Syntax_PatVar(_sc$$1.h0, _sc$$1.h1, _sc$$2.h1)), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(rest)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$19.h2)(_$$20))))))); } break; } } break; } case "PatVar": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Prelude__$3A$3A_(null, _$$19.h1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$19.h2)(_$$20)))); } break; } } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, _$$20)); } };
const Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint_rewriteClause = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _$$18, _$$19, _$$20 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _$$18, _$$19, _$$20.h1, Prelude_Nil(null)), ( $$sc ) => { switch ($$sc.tag) { case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Lib_Syntax_MkClause(_$$20.h0, $$sc.h1, _$$20.h2, _$$20.h3))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }));
const Lib_Elab_Prelude_Show$20Lib_Elab_Bind$2Cshow = ( _$$0 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$0.h0))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h1)))(""));
const Lib_Elab_Prelude_Show$20Lib_Elab_Bind = Prelude_MkShow(null, Lib_Elab_Prelude_Show$20Lib_Elab_Bind$2Cshow);
const Lib_Elab_updateContext_replace_replaceV = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, a$$11, _$$12, _$$13, _$$14 ) => { switch (_$$14.tag) { case "_::_": switch (_$$12.tag) { case "S": return Prelude__$3A$3A_(null, _$$14.h1, Lib_Elab_updateContext_replace_replaceV(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, null, _$$12.h0, _$$13, _$$14.h2)); case "Z": return Prelude__$3A$3A_(null, _$$13, _$$14.h2); } break; case "Nil": return Prelude_Nil(null); } };
const Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_:<_": return Prelude__$3A$3C_(null, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_SnocList)(null)(null)(_$$2)(_$$3.h1), _$$2(_$$3.h2)); case "Lin": return Prelude_Lin(null); } };
const Prelude_Prelude_Functor$20Prelude_SnocList = Prelude_MkFunctor(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Functor$20Prelude_SnocList$2Cmap(null, null, eta, eta1))))));
const Lib_Elab_substVal_go = ( _, _1, _2, _3, _$$4 ) => { switch (_$$4.tag) { case "VLet": return Lib_Types_VLet(_$$4.h0, _$$4.h1, Lib_Elab_substVal_go(_, _1, _2, _3, _$$4.h2), _$$4.h3); case "VPi": return Lib_Types_VPi(_$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, Lib_Elab_substVal_go(_, _1, _2, _3, _$$4.h4), _$$4.h5); case "VMeta": return Lib_Types_VMeta(_$$4.h0, _$$4.h1, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_SnocList)(null)(null)(( eta ) => (Lib_Elab_substVal_go(_, _1, _2, _3, eta)))(_$$4.h2)); case "VRef": return Lib_Types_VRef(_$$4.h0, _$$4.h1, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_SnocList)(null)(null)(( eta ) => (Lib_Elab_substVal_go(_, _1, _2, _3, eta)))(_$$4.h2)); case "VVar": { const sc$$8 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$4.h1)(_); switch (sc$$8.tag) { case "False": return Lib_Types_VVar(_$$4.h0, _$$4.h1, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_SnocList)(null)(null)(( eta ) => (Lib_Elab_substVal_go(_, _1, _2, _3, eta)))(_$$4.h2)); case "True": return _1; } break; } default: return _$$4; } };
const Lib_Elab_substVal = ( _$$0, _$$1, _$$2 ) => { const go = null; return Lib_Elab_substVal_go(_$$0, _$$1, _$$2, go, _$$2); };
const Lib_Elab_updateContext = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; const replace = null; const replaceV = null; const ix = Prelude_cast(null, null, Prelude_Prelude_Cast$20Prim_Int$20Prelude_Nat)(Lib_Common_lvl2ix(Prelude_length$27(null, Lib_Types__env(_$$0)), _sc$$0.h2)); const sc$$12 = Prelude_getAt(null, ix, Lib_Types__env(_$$0)); switch (sc$$12.tag) { case "Nothing": return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_sc$$0.h3), "INTERNAL ERROR: bad index in updateContext"); case "Just": { const _sc$$1 = sc$$12.h1; switch (_sc$$1.tag) { case "VVar": { const _sc$$2 = _sc$$1.h2; switch (_sc$$2.tag) { case "Lin": { const sc$$19 = Prelude__$2F$3D_(null, Prelude_Prelude_Eq$20Prim_Int, _sc$$1.h1, _sc$$0.h2); switch (sc$$19.tag) { case "False": { const ctx$27 = Lib_Types_MkCtx(Lib_Types__lvl(_$$0), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Elab_substVal(_sc$$0.h2, _sc$$0.h3, eta)))(Lib_Types__env(_$$0)), Lib_Types__types(_$$0), Lib_Elab_updateContext_replace_replaceV(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, replace, replaceV, null, ix, Lib_Types_Defined, Lib_Types__bds(_$$0)), Lib_Types__ctxFC(_$$0)); return Lib_Elab_updateContext(ctx$27, _$$1.h2); break; } case "True": return Lib_Elab_updateContext(_$$0, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$1.h1, _sc$$0.h3), _$$1.h2)); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_info(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_sc$$0.h3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("need to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$0.h3)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$12.h1)))(" or something")), ( _ ) => (Lib_Elab_updateContext(_$$0, _$$1.h2))); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_info(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_sc$$0.h3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("need to unify ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$0.h3)))(" and "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$12.h1)))(" or something")), ( _ ) => (Lib_Elab_updateContext(_$$0, _$$1.h2))); } break; } } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$0); } };
const Lib_Elab_UPattern = { tag: "UPattern" };
const Lib_Types_tryError = ( a$$0, _$$1 ) => (Lib_Types_catchError(null, Prelude_map(null, Lib_Types_Prelude_Functor$20Lib_Types_M)(null)(null)(( eta ) => (Prelude_Right(null, null, eta)))(_$$1), ( eta ) => (Prelude__$2218_(null, null, null, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null), ( eta ) => (Prelude_Left(null, null, eta)), eta))));
const Lib_Elab_buildCase_constrainSpine = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _$$14, _$$15 ) => { switch (_$$15.tag) { case "_::_": return Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$14, _$$15.h1), Lib_Elab_buildCase_constrainSpine(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$14), _$$15.h2)); case "Nil": return Prelude_Nil(null); } };
const Lib_Elab_lookupDef_go = ( _, _1, _2, _$$3, _$$4, _$$5 ) => { switch (_$$5.tag) { case "_::_": switch (_$$4.tag) { case "_::_": { const _sc$$0 = _$$4.h1; const sc$$16 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h2)(_1); switch (sc$$16.tag) { case "False": return Lib_Elab_lookupDef_go(_, _1, _2, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$3), _$$4.h2, _$$5.h2); case "True": return Prelude_Just(null, _$$5.h1); } break; } default: return Prelude_Nothing(null); } break; default: return Prelude_Nothing(null); } };
const Lib_Elab_lookupDef = ( _$$0, _$$1 ) => { const go = null; return Lib_Elab_lookupDef_go(_$$0, _$$1, go, 0, Lib_Types__types(_$$0), Lib_Types__env(_$$0)); };
const Lib_Elab_MkBind = ( h0, h1, h2 ) => ({ tag: "MkBind",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Elab_fresh = ( ctx$$0, _$$1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$1)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("$")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Prelude_length$27(null, Lib_Types__env(ctx$$0))))));
const Lib_Elab_extendPi = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$1.tag) { case "VPi": { const nm = Lib_Elab_fresh(_$$0, _$$1.h1); const ctx$27 = Lib_Types_extend(_$$0, nm, _$$1.h4); const v = Lib_Types_VVar(Lib_Common_emptyFC, Prelude_length$27(null, Lib_Types__env(_$$0)), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$1.h5, v), ( tyb ) => (Lib_Elab_extendPi(ctx$27, tyb, Prelude__$3A$3C_(null, _$$2, Lib_Elab_MkBind(nm, _$$1.h2, _$$1.h4)), Prelude__$3A$3C_(null, _$$3, Lib_Types_VVar(_$$1.h0, Prelude_length$27(null, Lib_Types__env(_$$0)), Prelude_Lin(null)))))); break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, _$$0, Prelude__$2C_(null, null, _$$1, Prelude__$2C_(null, null, Prelude__$3C$3E$3E_(null, _$$2, Prelude_Nil(null)), _$$3)))); } };
const Lib_Elab_buildCase = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { const _sc$$0 = _$$4.h3; const constrainSpine = null; const getName = null; const makeConstr = null; const rewriteConstraint = null; const rewriteClause = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CASE ")(_$$2))(" match "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" ty "))(Lib_Elab_rpprint(Lib_Types_names(_$$0), _sc$$0.h3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$0.h3), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_extendPi(_$$0, vty, Prelude_Lin(null), Prelude_Lin(null)), ( $$sc ) => { const _sc$$1 = $$sc.h3; const _sc$$2 = _sc$$1.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("unify dcon cod with scrut\n  ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$1.h2)))("\n  "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_catchError(null, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_Just(null, eta)), Lib_Elab_unify(Lib_Types__env($$sc.h2), Lib_Elab_UPattern, _sc$$1.h2, _$$3)), ( err ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SKIP ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" because unify error "))(Lib_Types_errorMsg(err)))(""))), ( _2 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))))), ( $$sc1 ) => { switch ($$sc1.tag) { case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("scrut ")(_$$2))(" constrained to "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Lib_Elab_lookupDef(_$$0, _$$2))))(""))), ( _2 ) => { switch (_$$3.tag) { case "VRef": { const sc$$44 = Lib_Elab_lookupDef(_$$0, _$$2); switch (sc$$44.tag) { case "Just": { const _sc$$3 = sc$$44.h1; switch (_sc$$3.tag) { case "VRef": { const sc$$50 = Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _sc$$3.h1, _$$4.h2); switch (sc$$50.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("case ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" dotted "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$44.h1)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$2F$3D_(null, Prelude_Prelude_Eq$20Prelude_Nat, Prelude_length(null, _sc$$2.h2), Data_SnocList_snoclen(null, _sc$$3.h2)), ( _4 ) => (Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Prelude_length(null, _sc$$2.h2))))(" vars /= "))(Prelude_show(null, Prelude_Prelude_Show$20Prelude_Nat)(Data_SnocList_snoclen(null, _sc$$3.h2))))("")))), ( _4 ) => { const lvl = Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(Prelude_length$27(null, Lib_Types__env($$sc.h2)))(Prelude_length$27(null, _sc$$2.h2)); const scons = Lib_Elab_buildCase_constrainSpine(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, lvl, Prelude__$3C$3E$3E_(null, _sc$$3.h2, Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_updateContext($$sc.h2, scons), ( ctx$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(dcon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" ty "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$1.h2)))(" scty "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(dcon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(") (vars "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Elab_Prelude_Show$20Lib_Elab_Bind))(_sc$$2.h2)))(") clauses were"))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Lib_Elab__clauses(_$$1), ( x ) => (Lib_Types_debug(( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("    ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause)(x)))(""))))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), eta)), Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, getName, makeConstr, rewriteConstraint, rewriteClause, _$$3.h1, _sc$$2.h2, eta)))(Lib_Elab__clauses(_$$1))), ( clauses ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => ("and now:")), ( _8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, clauses, ( x ) => (Lib_Types_debug(( _9 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("    ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause)(x)))(""))))), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, clauses))(0), ( _10 ) => (Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Missing case for ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" splitting "))(_$$2))("")))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(ctx$27, Lib_Elab_MkProb(clauses, Lib_Elab__ty(_$$1))), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Lib_Types_CaseCons(_$$4.h2, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Elab_buildCase_constrainSpine_getName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, getName, eta)))(_sc$$2.h2), tm))))))))))))))))))))); }))); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SKIP ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" because "))(_$$2))(" forced to "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$44.h1)))(""))), ( _3 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_tryError(null, Lib_Elab_unify(Lib_Types__env($$sc.h2), Lib_Elab_UPattern, _sc$$1.h2, _$$3)), ( $$sc2 ) => { switch ($$sc2.tag) { case "Right": { const sc$$52 = Prelude_findIndex$27(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$2), ( eta ) => (Prelude_fst(null, null, eta)), eta)), Lib_Types__types($$sc.h2)); switch (sc$$52.tag) { case "Nothing": return Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$2))(" not is scope?")); case "Just": { const lvl = Lib_Common_lvl2ix(Prelude_length$27(null, Lib_Types__env($$sc.h2)), sc$$52.h1); const scon = Prelude__$2C_(null, null, lvl, Lib_Types_VRef(Lib_Types__ctxFC(_$$0), _$$4.h2, _sc$$2.h3)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("scty ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("UNIFY results ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Elab__constraints($$sc2.h2))))(""))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("before types: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Types__types($$sc.h2))))(""))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("before env: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Lib_Types__env($$sc.h2))))(""))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SC CONSTRAINT: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val))(scon)))(""))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_updateContext($$sc.h2, Prelude__$3A$3A_(null, scon, Lib_Elab__constraints($$sc2.h2))), ( ctx$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("context types: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Types__types(ctx$27))))(""))), ( _8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _9 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("context env: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Lib_Types__env(ctx$27))))(""))), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _10 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(dcon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" ty "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$1.h2)))(" scty "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _11 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(dcon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(") (vars "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Elab_Prelude_Show$20Lib_Elab_Bind))(_sc$$2.h2)))(") clauses were"))), ( _11 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Lib_Elab__clauses(_$$1), ( x ) => (Lib_Types_debug(( _12 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("    ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause)(x)))(""))))), ( _12 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), eta)), Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, getName, makeConstr, rewriteConstraint, rewriteClause, _$$3.h1, _sc$$2.h2, eta)))(Lib_Elab__clauses(_$$1))), ( clauses ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _13 ) => ("and now:")), ( _13 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, clauses, ( x ) => (Lib_Types_debug(( _14 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("    ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause)(x)))(""))))), ( _14 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, clauses))(0), ( _15 ) => (Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Missing case for ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" splitting "))(_$$2))("")))), ( _15 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(ctx$27, Lib_Elab_MkProb(clauses, Lib_Elab__ty(_$$1))), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Lib_Types_CaseCons(_$$4.h2, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Elab_buildCase_constrainSpine_getName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, getName, eta)))(_sc$$2.h2), tm))))))))))))))))))))))))))))))))))); break; } } break; } case "Left": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SKIP ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" because unify error "))(Lib_Types_errorMsg($$sc2.h2)))(""))), ( _3 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); } }); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_tryError(null, Lib_Elab_unify(Lib_Types__env($$sc.h2), Lib_Elab_UPattern, _sc$$1.h2, _$$3)), ( $$sc2 ) => { switch ($$sc2.tag) { case "Right": { const sc$$50 = Prelude_findIndex$27(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$2), ( eta ) => (Prelude_fst(null, null, eta)), eta)), Lib_Types__types($$sc.h2)); switch (sc$$50.tag) { case "Nothing": return Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$2))(" not is scope?")); case "Just": { const lvl = Lib_Common_lvl2ix(Prelude_length$27(null, Lib_Types__env($$sc.h2)), sc$$50.h1); const scon = Prelude__$2C_(null, null, lvl, Lib_Types_VRef(Lib_Types__ctxFC(_$$0), _$$4.h2, _sc$$2.h3)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("scty ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("UNIFY results ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Elab__constraints($$sc2.h2))))(""))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("before types: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Types__types($$sc.h2))))(""))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("before env: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Lib_Types__env($$sc.h2))))(""))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SC CONSTRAINT: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Val))(scon)))(""))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_updateContext($$sc.h2, Prelude__$3A$3A_(null, scon, Lib_Elab__constraints($$sc2.h2))), ( ctx$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("context types: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Types_Prelude_Show$20Lib_Types_Val)))(Lib_Types__types(ctx$27))))(""))), ( _8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _9 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("context env: ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Lib_Types__env(ctx$27))))(""))), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _10 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(dcon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" ty "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$1.h2)))(" scty "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))(""))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _11 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(dcon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(") (vars "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Elab_Prelude_Show$20Lib_Elab_Bind))(_sc$$2.h2)))(") clauses were"))), ( _11 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Lib_Elab__clauses(_$$1), ( x ) => (Lib_Types_debug(( _12 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("    ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause)(x)))(""))))), ( _12 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), eta)), Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_buildCase_constrainSpine_getName_makeConstr_rewriteConstraint_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, getName, makeConstr, rewriteConstraint, rewriteClause, _$$3.h1, _sc$$2.h2, eta)))(Lib_Elab__clauses(_$$1))), ( clauses ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _13 ) => ("and now:")), ( _13 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, clauses, ( x ) => (Lib_Types_debug(( _14 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("    ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Clause)(x)))(""))))), ( _14 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, clauses))(0), ( _15 ) => (Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Missing case for ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" splitting "))(_$$2))("")))), ( _15 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(ctx$27, Lib_Elab_MkProb(clauses, Lib_Elab__ty(_$$1))), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, Lib_Types_CaseCons(_$$4.h2, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Elab_buildCase_constrainSpine_getName(_$$0, _$$1, _$$2, _$$3, _$$4, _$$4.h0, _$$4.h1, _$$4.h2, _$$4.h3, _sc$$0.h0, _sc$$0.h1, _sc$$0.h2, _sc$$0.h3, constrainSpine, getName, eta)))(_sc$$2.h2), tm))))))))))))))))))))))))))))))))))); break; } } break; } case "Left": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SKIP ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" because unify error "))(Lib_Types_errorMsg($$sc2.h2)))(""))), ( _3 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))); } }); } break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("case split on non-inductive ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$3)))("")); } }); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }))); }))))); };
const Lib_Elab_checkCase = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { const _sc$$0 = _$$4.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$0.h3), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_extendPi(_$$0, vty, Prelude_Lin(null), Prelude_Lin(null)), ( $$sc ) => { const _sc$$1 = $$sc.h3; const _sc$$2 = _sc$$1.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_catchError(null, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude_Just(null, eta)), Lib_Elab_unify(Lib_Types__env($$sc.h2), Lib_Elab_UPattern, _sc$$1.h2, _$$3)), ( err ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SKIP ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" because unify error "))(Lib_Types_errorMsg(err)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)))))), ( $$sc1 ) => { switch ($$sc1.tag) { case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_tryError(null, Lib_Elab_unify(Lib_Types__env($$sc.h2), Lib_Elab_UPattern, _sc$$1.h2, _$$3)), ( $$sc2 ) => { switch ($$sc2.tag) { case "Right": { const sc$$37 = Lib_Elab_lookupDef(_$$0, _$$2); switch (sc$$37.tag) { case "Just": { const _sc$$3 = sc$$37.h1; switch (_sc$$3.tag) { case "VRef": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_sc$$3.h1)(_$$4.h2)); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_True); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_True); } break; } case "Left": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SKIP ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$4.h2)))(" because unify error "))(Lib_Types_errorMsg($$sc2.h2)))(""))), ( _ ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False))); } }); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False); } }); }))); };
const Lib_Types_filterM = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, _$$1(_$$2.h1), ( check ) => { switch (check.tag) { case "False": return Lib_Types_filterM(null, _$$1, _$$2.h2); case "True": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude__$3A$3A_(null, _$$2.h1, eta)), Lib_Types_filterM(null, _$$1, _$$2.h2)); } }); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nil(null)); } };
const Prelude_partition_go = ( _, _1, _2, _3, _$$4, _$$5, _$$6 ) => { switch (_$$4.tag) { case "_::_": { const sc$$10 = _1(_$$4.h1); switch (sc$$10.tag) { case "False": return Prelude_partition_go(_, _1, _2, _3, _$$4.h2, _$$5, Prelude__$3A$3A_(null, _$$4.h1, _$$6)); case "True": return Prelude_partition_go(_, _1, _2, _3, _$$4.h2, Prelude__$3A$3A_(null, _$$4.h1, _$$5), _$$6); } break; } case "Nil": return Prelude__$2C_(null, null, _$$5, _$$6); } };
const Prelude_partition = ( a$$0, _$$1, _$$2 ) => { const go = null; return Prelude_partition_go(a$$0, _$$1, _$$2, go, _$$2, Prelude_Nil(null), Prelude_Nil(null)); };
const Lib_Elab_matchedConstructors = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; const sc$$9 = Prelude_find(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$0), ( eta ) => (Prelude_fst(null, null, eta)), eta)), _sc$$0.h1); switch (sc$$9.tag) { case "Just": { const _sc$$1 = sc$$9.h1; const _sc$$2 = _sc$$1.h3; switch (_sc$$2.tag) { case "PatCon": return Prelude__$3A$3A_(null, _sc$$2.h2, Lib_Elab_matchedConstructors(_$$0, _$$1.h2)); default: return Lib_Elab_matchedConstructors(_$$0, _$$1.h2); } break; } default: return Lib_Elab_matchedConstructors(_$$0, _$$1.h2); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Elab_vprint = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Prelude_length$27(null, Lib_Types__env(_$$0)), _$$1), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Prettier_render(90, Lib_Types_pprint(Lib_Types_names(_$$0), tm))))));
const Lib_Elab_getConstructors_lookupTCon_lookupDCon = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$10 = Lib_TopContext_lookup(_$$8, top); switch (sc$$10.tag) { case "Nothing": return Lib_Types_error(null, _3, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal Error: DCon ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$8)))(" not found")); case "Just": { const _sc$$0 = sc$$10.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "DCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, _sc$$0.h1, Prelude__$2C_(null, null, _sc$$1.h0, _sc$$0.h2))); default: return Lib_Types_error(null, _3, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal Error: ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$8)))(" is not a DCon")); } break; } } }));
const Lib_Elab_getConstructors_lookupTCon = ( _, _1, _2, _3, _4, _5, _6, _$$7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$9 = Lib_TopContext_lookup(_4, top); switch (sc$$9.tag) { case "Just": { const _sc$$0 = sc$$9.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "TCon": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_sc$$1.h1); default: return Lib_Types_error(null, _1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Not a type constructor ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_4)))("")); } break; } default: return Lib_Types_error(null, _1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Not a type constructor ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_4)))("")); } }));
const Lib_Elab_getConstructors = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "VRef": { const lookupTCon = null; const lookupDCon = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_getConstructors_lookupTCon(_$$0, _$$1, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, lookupTCon, _$$2.h1), ( $$sc ) => (Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_getConstructors_lookupTCon_lookupDCon(_$$0, _$$1, _$$2, _$$2.h0, _$$2.h1, _$$2.h2, lookupTCon, lookupDCon, eta)))($$sc))); break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_vprint(_$$0, _$$2), ( tms ) => (Lib_Types_error(null, _$$1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Can't split - not VRef: ")(tms))("")))); } };
const Lib_Elab_buildLitCases_isDefault = ( _, _1, _2, _3, _4, _5, _$$6 ) => { const sc$$7 = Prelude_find(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_3), ( eta ) => (Prelude_fst(null, null, eta)), eta)), Lib_Syntax__cons(_$$6)); switch (sc$$7.tag) { case "Nothing": return Prelude_True; case "Just": { const _sc$$0 = sc$$7.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PatWild": return Prelude_True; case "PatVar": return Prelude_True; default: return Prelude_False; } break; } } };
const Prelude_Prelude_Monad$20Prelude_Maybe$2Cpure = ( a$$0, _$$1 ) => (Prelude_Just(null, _$$1));
const Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "Nothing": return Prelude_Nothing(null); case "Just": return _$$3(_$$2.h1); } };
const Prelude_Prelude_Monad$20Prelude_Maybe = Prelude_MkMonad(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cbind(null, null, eta, eta1))))), ( a ) => (( eta ) => (Prelude_Prelude_Monad$20Prelude_Maybe$2Cpure(null, eta))));
const Lib_Types_Prelude_Eq$20Lib_Types_Literal$2C_$3D$3D_ = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "LChar": switch (_$$0.tag) { case "LChar": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Char)(_$$0.h0)(_$$1.h0); default: return Prelude_False; } break; case "LInt": switch (_$$0.tag) { case "LInt": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$0.h0)(_$$1.h0); default: return Prelude_False; } break; case "LString": switch (_$$0.tag) { case "LString": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$0.h0)(_$$1.h0); default: return Prelude_False; } break; } };
const Lib_Types_Prelude_Eq$20Lib_Types_Literal = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Lib_Types_Prelude_Eq$20Lib_Types_Literal$2C_$3D$3D_(eta, eta1))));
const Lib_Elab_buildLitCase_rewriteConstraint = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8 ) => { switch (_$$7.tag) { case "_::_": { const _sc$$0 = _$$7.h1; const sc$$16 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h2)(_3); switch (sc$$16.tag) { case "False": return Lib_Elab_buildLitCase_rewriteConstraint(_, _1, _2, _3, _4, _5, _6, _$$7.h2, Prelude__$3A$3A_(null, _$$7.h1, _$$8)); case "True": { const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PatLit": { const sc$$20 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Literal)(_sc$$1.h1)(_5); switch (sc$$20.tag) { case "False": return Prelude_Nothing(null); case "True": return Prelude_Just(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$7.h2)(_$$8)); } break; } case "PatWild": return Prelude_Just(null, Prelude__$3A$3A_(null, _$$7.h1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$7.h2)(_$$8))); case "PatCon": return Prelude_Nothing(null); case "PatVar": return Prelude_Just(null, Prelude__$3A$3A_(null, _$$7.h1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_$$7.h2)(_$$8))); } break; } } break; } case "Nil": return Prelude_Just(null, _$$8); } };
const Lib_Elab_buildLitCase_rewriteConstraint_rewriteClause = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8 ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_Maybe, Lib_Elab_buildLitCase_rewriteConstraint(_, _1, _2, _3, _4, _5, _6, _$$8.h1, Prelude_Nil(null)), ( cons ) => (Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_Maybe)(null)(Lib_Syntax_MkClause(_$$8.h0, cons, _$$8.h2, _$$8.h3)))));
const Lib_Elab_buildLitCase = ( _$$0, _$$1, _$$2, _$$3, _$$4, _$$5 ) => { const rewriteConstraint = null; const rewriteClause = null; const sc$$8 = Prelude_findIndex$27(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$3), ( eta ) => (Prelude_fst(null, null, eta)), eta)), Lib_Types__types(_$$0)); switch (sc$$8.tag) { case "Nothing": return Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$3))(" not is scope?")); case "Just": { const lvl = Lib_Common_lvl2ix(Prelude_length$27(null, Lib_Types__env(_$$0)), sc$$8.h1); const scon = Prelude__$2C_(null, null, lvl, Lib_Types_VLit(_$$2, _$$5)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_updateContext(_$$0, Prelude__$3A$3A_(null, scon, Prelude_Nil(null))), ( ctx$27 ) => { const clauses = Prelude_mapMaybe(null, null, ( eta ) => (Lib_Elab_buildLitCase_rewriteConstraint_rewriteClause(_$$0, _$$1, _$$2, _$$3, _$$4, _$$5, rewriteConstraint, rewriteClause, eta)), Lib_Elab__clauses(_$$1)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, clauses))(0), ( _ ) => (Lib_Types_error(null, Lib_Types__ctxFC(_$$0), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Missing case for ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Literal)(_$$5)))(" splitting "))(_$$3))("")))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(ctx$27, Lib_Elab_MkProb(clauses, Lib_Elab__ty(_$$1))), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_CaseLit(_$$5, tm)))))); }); break; } } };
const Lib_Elab_getLits = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; const sc$$9 = Prelude_find(null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$0), ( eta ) => (Prelude_fst(null, null, eta)), eta)), _sc$$0.h1); switch (sc$$9.tag) { case "Just": { const _sc$$1 = sc$$9.h1; const _sc$$2 = _sc$$1.h3; switch (_sc$$2.tag) { case "PatLit": return Prelude__$3A$3A_(null, _sc$$2.h1, Lib_Elab_getLits(_$$0, _$$1.h2)); default: return Lib_Elab_getLits(_$$0, _$$1.h2); } break; } default: return Lib_Elab_getLits(_$$0, _$$1.h2); } break; } case "Nil": return Prelude_Nil(null); } };
const Prelude_nub = ( a$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": { const sc$$6 = Prelude_elem(null, _$$1, _$$2.h1, _$$2.h2); switch (sc$$6.tag) { case "False": return Prelude__$3A$3A_(null, _$$2.h1, Prelude_nub(null, _$$1, _$$2.h2)); case "True": return Prelude_nub(null, _$$1, _$$2.h2); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Elab_buildLitCases = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { const isDefault = null; const lits = Prelude_nub(null, Lib_Types_Prelude_Eq$20Lib_Types_Literal, Lib_Elab_getLits(_$$3, Lib_Elab__clauses(_$$1))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_buildLitCase(_$$0, _$$1, _$$2, _$$3, _$$4, eta)))(lits), ( alts ) => { const defclauses = Prelude_filter(null, ( eta ) => (Lib_Elab_buildLitCases_isDefault(_$$0, _$$1, _$$2, _$$3, _$$4, isDefault, eta)), Lib_Elab__clauses(_$$1)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, defclauses))(0), ( _ ) => (Lib_Types_error(null, _$$2, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no default for literal slot on ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$3)))("")))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(_$$0, Lib_Elab_MkProb(defclauses, Lib_Elab__ty(_$$1))), ( tm ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(alts)(Prelude__$3A$3A_(null, Lib_Types_CaseDefault(tm), Prelude_Nil(null)))))))); }); };
const Lib_Elab_litTyName = ( _$$0 ) => { switch (_$$0.tag) { case "LChar": return Lib_Elab_charType; case "LInt": return Lib_Elab_intType; case "LString": return Lib_Elab_stringType; } };
const Lib_Elab_solveAutos_isAuto = ( _, _$$1 ) => { switch (_$$1.tag) { case "Unsolved": { const _sc$$0 = _$$1.h4; switch (_sc$$0.tag) { case "AutoSolve": return Prelude_True; default: return Prelude_False; } break; } default: return Prelude_False; } };
const Lib_Elab_solveAutos_isAuto_run = ( _, _1, _$$2 ) => { switch (_$$2.tag) { case "_::_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_trySolveAuto(_$$2.h1), ( res ) => { switch (res.tag) { case "False": return Lib_Elab_solveAutos_isAuto_run(_, _1, _$$2.h2); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_True); } }); case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_False); } };
const Lib_Elab_solveAutos = ((  ) => { const isAuto = null; const run = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solveAutos_isAuto_run(isAuto, run, Prelude_filter(null, ( eta ) => (Lib_Elab_solveAutos_isAuto(isAuto, eta)), Data_SortedMap_listValues(null, null, Lib_Types__metas(mc)))), ( res ) => { switch (res.tag) { case "False": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "True": return Lib_Elab_solveAutos; } }))))); })();
const Lib_Elab_lookupName_go = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "_::_": { const _sc$$0 = _$$4.h1; const sc$$12 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h2)(_1); switch (sc$$12.tag) { case "False": return Lib_Elab_lookupName_go(_, _1, _2, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$3), _$$4.h2); case "True": return Prelude_Just(null, Prelude__$2C_(null, null, Lib_Types_Bnd(Lib_Common_emptyFC, _$$3), _sc$$0.h3)); } break; } case "Nil": return Prelude_Nothing(null); } };
const Lib_Elab_lookupName = ( _$$0, _$$1 ) => { const go = null; return Lib_Elab_lookupName_go(_$$0, _$$1, go, 0, Lib_Types__types(_$$0)); };
const Lib_Elab_findSplit = ( _$$0 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "PatLit": return Prelude_Just(null, _$$0.h1); case "PatCon": return Prelude_Just(null, _$$0.h1); default: return Lib_Elab_findSplit(_$$0.h2); } break; } case "Nil": return Prelude_Nothing(null); } };
const Lib_Elab_introClause = ( _$$0, _$$1, _$$2 ) => { const _sc$$0 = _$$2.h2; switch (_sc$$0.tag) { case "_::_": { const sc$$10 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(_$$1)(Lib_Syntax_getIcit(_sc$$0.h1)); switch (sc$$10.tag) { case "False": { const sc$$11 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(_$$1)(Lib_Types_Implicit); switch (sc$$11.tag) { case "False": { const sc$$12 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(_$$1)(Lib_Types_Auto); switch (sc$$12.tag) { case "False": return Lib_Types_error(null, _$$2.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Explicit arg and ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(Lib_Syntax_getIcit(_sc$$0.h1))))(" pattern "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0)))("  "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)(_sc$$0.h1)))("")); case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(_$$2.h0, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$0, Lib_Syntax_PatWild(_$$2.h0, Lib_Types_Auto)), _$$2.h1), Prelude__$3A$3A_(null, _sc$$0.h1, _sc$$0.h2), _$$2.h3)); } break; } case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(_$$2.h0, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$0, Lib_Syntax_PatWild(_$$2.h0, Lib_Types_Implicit)), _$$2.h1), Prelude__$3A$3A_(null, _sc$$0.h1, _sc$$0.h2), _$$2.h3)); } break; } case "True": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(_$$2.h0, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$0, _sc$$0.h1), _$$2.h1), _sc$$0.h2, _$$2.h3)); } break; } case "Nil": switch (_$$1.tag) { case "Auto": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(_$$2.h0, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$0, Lib_Syntax_PatWild(_$$2.h0, Lib_Types_Auto)), _$$2.h1), Prelude_Nil(null), _$$2.h3)); case "Implicit": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(_$$2.h0, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$0, Lib_Syntax_PatWild(_$$2.h0, Lib_Types_Implicit)), _$$2.h1), Prelude_Nil(null), _$$2.h3)); default: return Lib_Types_error(null, _$$2.h0, "Clause size doesn't match"); } break; } };
const Lib_Elab_buildTree = ( _$$0, _$$1 ) => { const _sc$$0 = _$$1.h0; switch (_sc$$0.tag) { case "_::_": { const _sc$$1 = _sc$$0.h1; const _sc$$2 = _sc$$1.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _$$1.h1; switch (_sc$$3.tag) { case "VPi": { const l = Prelude_length$27(null, Lib_Types__env(_$$0)); const nm = Lib_Elab_fresh(_$$0, _sc$$3.h1); const ctx$27 = Lib_Types_extend(_$$0, nm, _sc$$3.h4); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_introClause(nm, _sc$$3.h2, eta)))(Lib_Elab__clauses(_$$1)), ( clauses ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_sc$$3.h5, Lib_Types_VVar(_sc$$1.h0, l, Prelude_Lin(null))), ( vb ) => (Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_Lam(_sc$$1.h0, nm, _sc$$3.h2, _sc$$3.h3, eta)), Lib_Elab_buildTree(ctx$27, Lib_Elab_MkProb(clauses, vb))))))); break; } default: return Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Extra pattern variables ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern))(_sc$$1.h2)))("")); } break; } case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("buildTree ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)))(_sc$$1.h1)))(" "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_sc$$1.h3)))(""))), ( _ ) => { const sc$$13 = Lib_Elab_findSplit(_sc$$1.h1); switch (sc$$13.tag) { case "Just": { const _sc$$3 = sc$$13.h1; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SPLIT on ")(_sc$$3.h2))(" because "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)(_sc$$3.h3)))(" "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_sc$$3.h3))))(""))), ( _1 ) => { const sc$$21 = Lib_Elab_lookupName(_$$0, _sc$$3.h2); switch (sc$$21.tag) { case "Just": { const _sc$$4 = sc$$21.h1; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_unlet(Lib_Types__env(_$$0), _sc$$4.h3), ( eta ) => (Lib_Eval_forceType(Lib_Types__env(_$$0), eta))), ( scty$27 ) => { switch (scty$27.tag) { case "VMeta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(scty$27.h1), ( meta ) => { switch (meta.tag) { case "OutOfScope": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(scty$27); case "Solved": return Lib_Eval_forceType(Lib_Types__env(_$$0), scty$27); case "Unsolved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solveAutos, ( _2 ) => (Lib_Eval_forceType(Lib_Types__env(_$$0), scty$27))))))); } }), ( scty$271 ) => { const _sc$$5 = _sc$$3.h3; switch (_sc$$5.tag) { case "PatLit": { const tyname = Lib_Elab_litTyName(_sc$$5.h1); switch (scty$271.tag) { case "VRef": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, scty$271.h1, tyname), ( _2 ) => (Lib_Types_error(null, _sc$$5.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$4.h3)))(" and got "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(tyname)))("")))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildLitCases(_$$0, _$$1, _sc$$5.h0, _sc$$3.h2, _sc$$4.h3), ( alts ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, alts)))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_error(null, _sc$$5.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$4.h3)))(" and got "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(tyname)))("")), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildLitCases(_$$0, _$$1, _sc$$5.h0, _sc$$3.h2, _sc$$4.h3), ( alts ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, alts)))))); } break; } case "PatCon": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("EXP ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$4.h3)))(" -> "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(scty$271)))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_getConstructors(_$$0, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_sc$$3.h3), scty$271), ( cons ) => { const matched = Lib_Elab_matchedConstructors(_sc$$3.h2, Lib_Elab__clauses(_$$1)); const sc$$39 = Prelude_partition(null, ( eta ) => (Prelude__$2218_(null, null, null, ( eta ) => (Prelude_flip(null, null, null, ( eta ) => (( eta1 ) => (Prelude_elem(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, eta, eta1))), matched, eta)), ( eta ) => (Prelude_fst(null, null, eta)), eta)), cons); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_filterM(null, ( eta ) => (Lib_Elab_checkCase(_$$0, _$$1, _sc$$3.h2, scty$271, eta)), sc$$39.h3), ( miss$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CONS ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(cons))))(" matched "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(matched)))(" miss "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm))))(sc$$39.h3)))(" miss' "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm))))(miss$27)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_buildCase(_$$0, _$$1, _sc$$3.h2, scty$271, eta)))(sc$$39.h2), ( alts ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("GOTALTS ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_CaseAlt)))(alts)))(""))), ( _4 ) => { const alts$27 = Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), alts); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, alts$27))(0), ( _5 ) => (Lib_Types_error(null, _sc$$5.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no alts for ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(scty$271)))("")))), ( _5 ) => { switch (miss$27.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), alts))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildDefault(_$$0, _$$1, _sc$$5.h0, _sc$$3.h2, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(miss$27)), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, Prelude_snoc(null, alts$27, $$sc))))); } }); }))))))); }))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_sc$$3.h3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal error - tried to split on ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)(_sc$$3.h3)))("")); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(scty$27), ( scty$271 ) => { const _sc$$5 = _sc$$3.h3; switch (_sc$$5.tag) { case "PatLit": { const tyname = Lib_Elab_litTyName(_sc$$5.h1); switch (scty$271.tag) { case "VRef": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, scty$271.h1, tyname), ( _2 ) => (Lib_Types_error(null, _sc$$5.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$4.h3)))(" and got "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(tyname)))("")))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildLitCases(_$$0, _$$1, _sc$$5.h0, _sc$$3.h2, _sc$$4.h3), ( alts ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, alts)))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_error(null, _sc$$5.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$4.h3)))(" and got "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(tyname)))("")), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildLitCases(_$$0, _$$1, _sc$$5.h0, _sc$$3.h2, _sc$$4.h3), ( alts ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, alts)))))); } break; } case "PatCon": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("EXP ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$4.h3)))(" -> "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(scty$271)))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_getConstructors(_$$0, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_sc$$3.h3), scty$271), ( cons ) => { const matched = Lib_Elab_matchedConstructors(_sc$$3.h2, Lib_Elab__clauses(_$$1)); const sc$$39 = Prelude_partition(null, ( eta ) => (Prelude__$2218_(null, null, null, ( eta ) => (Prelude_flip(null, null, null, ( eta ) => (( eta1 ) => (Prelude_elem(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, eta, eta1))), matched, eta)), ( eta ) => (Prelude_fst(null, null, eta)), eta)), cons); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_filterM(null, ( eta ) => (Lib_Elab_checkCase(_$$0, _$$1, _sc$$3.h2, scty$271, eta)), sc$$39.h3), ( miss$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("CONS ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(cons))))(" matched "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(matched)))(" miss "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm))))(sc$$39.h3)))(" miss' "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Common_Prelude_Show$20Lib_Common_QName, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_Int, Lib_Types_Prelude_Show$20Lib_Types_Tm))))(miss$27)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Elab_buildCase(_$$0, _$$1, _sc$$3.h2, scty$271, eta)))(sc$$39.h2), ( alts ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("GOTALTS ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_CaseAlt)))(alts)))(""))), ( _4 ) => { const alts$27 = Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), alts); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Prelude_length$27(null, alts$27))(0), ( _5 ) => (Lib_Types_error(null, _sc$$5.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no alts for ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(scty$271)))("")))), ( _5 ) => { switch (miss$27.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), alts))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildDefault(_$$0, _$$1, _sc$$5.h0, _sc$$3.h2, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(miss$27)), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Case(_sc$$5.h0, _sc$$4.h2, Prelude_snoc(null, alts$27, $$sc))))); } }); }))))))); }))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Pattern)(_sc$$3.h3), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal error - tried to split on ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)(_sc$$3.h3)))("")); } }); } }); break; } default: return Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Internal Error: can't find ")(_sc$$3.h2))(" in environment")); } }); break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("checkDone ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Prelude_Prelude_Show$20Prim_String, Lib_Syntax_Prelude_Show$20Lib_Syntax_Pattern)))(_sc$$1.h1)))(""))), ( _1 ) => (Lib_Elab_checkDone(_$$0, _sc$$1.h1, _sc$$1.h3, _$$1.h1))); } }); } break; } case "Nil": return Lib_Types_error(null, Lib_Common_emptyFC, "no clauses"); } };
const Lib_Types_withPos = ( _$$0, _$$1 ) => (Lib_Types_MkCtx(_$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, _$$1));
const Lib_Syntax_PatCon = ( h0, h1, h2, h3, h4 ) => ({ tag: "PatCon",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Syntax_PatLit = ( h0, h1 ) => ({ tag: "PatLit",  h0: h0,  h1: h1 });
const Lib_Elab_splitArgs = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "RApp": return Lib_Elab_splitArgs(_$$0.h1, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _$$0.h2, _$$0.h3), _$$1)); default: return Prelude__$2C_(null, null, _$$0, _$$1); } };
const Lib_Elab_mkPat = ( _$$0 ) => { const _sc$$0 = _$$0.h2; switch (_sc$$0.tag) { case "RAs": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_mkPat(Prelude__$2C_(null, null, _sc$$0.h2, _$$0.h3)), ( pat ) => { switch (pat.tag) { case "PatCon": { const _sc$$1 = pat.h4; switch (_sc$$1.tag) { case "Nothing": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_PatCon(pat.h0, pat.h1, pat.h2, pat.h3, Prelude_Just(null, _sc$$0.h1))); default: return Lib_Types_error(null, pat.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Double as pattern ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_sc$$0.h2)))("")); } break; } default: return Lib_Types_error(null, _sc$$0.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Can't put as on non-constructor ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_sc$$0.h2)))("")); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$6 = Lib_Elab_splitArgs(_$$0.h2, Prelude_Nil(null)); const _sc$$1 = sc$$6.h2; switch (_sc$$1.tag) { case "RImplicit": { const _sc$$2 = sc$$6.h3; switch (_sc$$2.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_PatWild(_sc$$1.h0, _$$0.h3)); default: return Lib_Types_error(null, _sc$$1.h0, "implicit pat can't be applied to arguments"); } break; } case "RLit": { const _sc$$2 = sc$$6.h3; switch (_sc$$2.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_PatLit(_sc$$1.h0, _sc$$1.h1)); default: return Lib_Types_error(null, _sc$$1.h0, "lit cannot be applied to arguments"); } break; } case "RVar": { const sc$$13 = Lib_TopContext_lookupRaw(_sc$$1.h1, top); switch (sc$$13.tag) { case "Just": { const _sc$$2 = sc$$13.h1; const _sc$$3 = _sc$$2.h3; switch (_sc$$3.tag) { case "DCon": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(Lib_Elab_mkPat)(sc$$6.h3), ( bpat ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_PatCon(_sc$$1.h0, _$$0.h3, _sc$$2.h1, bpat, Prelude_Nothing(null))))); default: { const _sc$$4 = sc$$6.h3; switch (_sc$$4.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_PatVar(_sc$$1.h0, _$$0.h3, _sc$$1.h1)); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$0.h2), "patvar applied to args"); } break; } } break; } default: { const _sc$$2 = sc$$6.h3; switch (_sc$$2.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_PatVar(_sc$$1.h0, _$$0.h3, _sc$$1.h1)); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$0.h2), "patvar applied to args"); } break; } } break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$6.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected pat var or constructor, got ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(sc$$6.h2)))("")); } }); } };
const Lib_Types_User = { tag: "User" };
const Lib_Types_BI = ( h0, h1, h2, h3 ) => ({ tag: "BI",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Syntax_RLam = ( h0, h1, h2 ) => ({ tag: "RLam",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Syntax_RApp = ( h0, h1, h2, h3 ) => ({ tag: "RApp",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Syntax_RImplicit = ( h0 ) => ({ tag: "RImplicit",  h0: h0 });
const Lib_Syntax_RLet = ( h0, h1, h2, h3, h4 ) => ({ tag: "RLet",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Syntax_MkAlt = ( h0, h1 ) => ({ tag: "MkAlt",  h0: h0,  h1: h1 });
const Lib_Syntax_RCase = ( h0, h1, h2 ) => ({ tag: "RCase",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Elab_undo = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; switch (_sc$$0.tag) { case "DoArrow": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1.tag) { case "RVar": { const _sc$$2 = _sc$$0.h3; switch (_sc$$2.tag) { case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$13 = Lib_TopContext_lookupRaw(_sc$$1.h1, top); switch (sc$$13.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_undo(_sc$$0.h0, _$$1.h2), ( xs$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, "_>>=_"), _sc$$0.h2, Lib_Types_Explicit), Lib_Syntax_RLam(_sc$$0.h0, Lib_Types_BI(_sc$$1.h0, _sc$$1.h1, Lib_Types_Explicit, Lib_Types_Many), xs$27), Lib_Types_Explicit)))); case "Just": { const nm = "$sc"; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_undo(_sc$$0.h0, _$$1.h2), ( xs$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RCase(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, nm), Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(_sc$$0.h1, xs$27), Prelude_Nil(null)))), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, "_>>=_"), _sc$$0.h2, Lib_Types_Explicit), Lib_Syntax_RLam(_sc$$0.h0, Lib_Types_BI(_sc$$0.h0, nm, Lib_Types_Explicit, Lib_Types_Many), rest), Lib_Types_Explicit)))))); break; } } }); default: { const nm = "$sc"; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_undo(_sc$$0.h0, _$$1.h2), ( xs$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RCase(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, nm), Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(_sc$$0.h1, xs$27), _sc$$0.h3))), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, "_>>=_"), _sc$$0.h2, Lib_Types_Explicit), Lib_Syntax_RLam(_sc$$0.h0, Lib_Types_BI(_sc$$0.h0, nm, Lib_Types_Explicit, Lib_Types_Many), rest), Lib_Types_Explicit)))))); break; } } break; } default: { const nm = "$sc"; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_undo(_sc$$0.h0, _$$1.h2), ( xs$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RCase(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, nm), Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(_sc$$0.h1, xs$27), _sc$$0.h3))), ( rest ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, "_>>=_"), _sc$$0.h2, Lib_Types_Explicit), Lib_Syntax_RLam(_sc$$0.h0, Lib_Types_BI(_sc$$0.h0, nm, Lib_Types_Explicit, Lib_Types_Many), rest), Lib_Types_Explicit)))))); break; } } break; } case "DoLet": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Syntax_RLet(_sc$$0.h0, _sc$$0.h1, Lib_Syntax_RImplicit(_sc$$0.h0), _sc$$0.h2, eta)), Lib_Elab_undo(_sc$$0.h0, _$$1.h2)); case "DoExpr": { const _sc$$1 = _$$1.h2; switch (_sc$$1.tag) { case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_sc$$0.h1); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_undo(_sc$$0.h0, _$$1.h2), ( xs$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RApp(_sc$$0.h0, Lib_Syntax_RVar(_sc$$0.h0, "_>>=_"), _sc$$0.h1, Lib_Types_Explicit), Lib_Syntax_RLam(_sc$$0.h0, Lib_Types_BI(_sc$$0.h0, "_", Lib_Types_Explicit, Lib_Types_Many), xs$27), Lib_Types_Explicit)))); } break; } } break; } case "Nil": return Lib_Types_error(null, _$$0, "do block must end in expression"); } };
const Lib_Syntax_Def = ( h0, h1, h2 ) => ({ tag: "Def",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Elab_collectDecl = ( _$$0 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; switch (_sc$$0.tag) { case "Def": { const _sc$$1 = _$$0.h2; switch (_sc$$1.tag) { case "_::_": { const _sc$$2 = _sc$$1.h1; switch (_sc$$2.tag) { case "Def": { const sc$$13 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$0.h1)(_sc$$2.h1); switch (sc$$13.tag) { case "False": return Prelude__$3A$3A_(null, Lib_Syntax_Def(_sc$$0.h0, _sc$$0.h1, _sc$$0.h2), Lib_Elab_collectDecl(_$$0.h2)); case "True": return Lib_Elab_collectDecl(Prelude__$3A$3A_(null, Lib_Syntax_Def(_sc$$0.h0, _sc$$0.h1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(_sc$$0.h2)(_sc$$2.h2)), _sc$$1.h2)); } break; } default: return Prelude__$3A$3A_(null, _$$0.h1, Lib_Elab_collectDecl(_$$0.h2)); } break; } default: return Prelude__$3A$3A_(null, _$$0.h1, Lib_Elab_collectDecl(_$$0.h2)); } break; } default: return Prelude__$3A$3A_(null, _$$0.h1, Lib_Elab_collectDecl(_$$0.h2)); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC = ( _$$0 ) => { switch (_$$0.tag) { case "Record": return _$$0.h0; case "Instance": return _$$0.h0; case "Class": return _$$0.h0; case "PMixFix": return _$$0.h0; case "PFunc": return _$$0.h0; case "PType": return _$$0.h0; case "ShortData": return _$$0.h0; case "Data": return _$$0.h0; case "DCheck": return _$$0.h0; case "Def": return _$$0.h0; case "TypeSig": return _$$0.h0; } };
const Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl = Lib_Common_MkHasFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl$2CgetFC);
const Lib_Elab_makeClause = ( _$$0 ) => { const sc$$5 = Lib_Elab_splitArgs(_$$0.h2, Prelude_Nil(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(Lib_Elab_mkPat)(sc$$5.h3), ( pats ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$0.h2), Prelude_Nil(null), pats, _$$0.h3)))); };
const Prelude_unless = ( f$$0, _$$1, _$$2, _$$3 ) => (Prelude_when(null, _$$1, Prelude_not(_$$2), _$$3));
const Lib_Elab_checkWhere = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; switch (_sc$$0.tag) { case "TypeSig": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1.tag) { case "_::_": { const _sc$$2 = _sc$$1.h2; switch (_sc$$2.tag) { case "Nil": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _sc$$0.h2, Lib_Types_VU(_sc$$0.h0)), ( funTy ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("where clause ")(_sc$$1.h1))(" : "))(Lib_Elab_rpprint(Lib_Types_names(_$$0), funTy)))(""))), ( _ ) => { const _sc$$3 = _$$1.h2; switch (_sc$$3.tag) { case "_::_": { const _sc$$4 = _sc$$3.h1; switch (_sc$$4.tag) { case "Def": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_unless(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$1.h1)(_sc$$4.h1), ( _1 ) => (Lib_Types_error(null, _sc$$4.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected def for ")(_sc$$1.h1))("")))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(Lib_Elab_makeClause)(_sc$$4.h2), ( clauses$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, funTy), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_sc$$1.h1))(" vty is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(vty)))(""))), ( _2 ) => { const ctx$27 = Lib_Types_extend(_$$0, _sc$$1.h1, vty); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(Lib_Types_withPos(ctx$27, _sc$$4.h0), Lib_Elab_MkProb(clauses$27, vty)), ( tm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(ctx$27), Lib_Types_CBN, tm), ( vtm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_checkWhere(ctx$27, _sc$$3.h2, _$$2, _$$3), ( ty$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_LetRec(_sc$$0.h0, _sc$$1.h1, funTy, tm, ty$27)))))))); }))))))))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(_sc$$3.h1), "expected function definition"); } break; } default: return Lib_Types_error(null, _sc$$0.h0, "expected function definition after this signature"); } }))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(_$$1.h1), "expected type signature"); } break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(_$$1.h1), "expected type signature"); } break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(_$$1.h1), "expected type signature"); } break; } default: return Lib_Elab_check(_$$0, _$$2, _$$3); } };
const Lib_Elab_check = ( _$$0, _$$1, _$$2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_forceType(Lib_Types__env(_$$0), _$$2), ( ty$27 ) => { const sc$$4 = Prelude__$2C_(null, null, _$$1, ty$27); const _sc$$0 = sc$$4.h2; switch (_sc$$0.tag) { case "RWhere": return Lib_Elab_checkWhere(_$$0, Lib_Elab_collectDecl(_sc$$0.h1), _sc$$0.h2, sc$$4.h3); case "RIf": { const tm$27 = Lib_Syntax_RCase(_sc$$0.h0, _sc$$0.h1, Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(Lib_Syntax_RVar(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_sc$$0.h2), "True"), _sc$$0.h2), Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(Lib_Syntax_RVar(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_sc$$0.h3), "False"), _sc$$0.h3), Prelude_Nil(null)))); return Lib_Elab_check(_$$0, tm$27, sc$$4.h3); break; } case "RDo": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_undo(_sc$$0.h0, _sc$$0.h1), ( stmts$27 ) => (Lib_Elab_check(_$$0, stmts$27, sc$$4.h3))); case "RHole": return Lib_Elab_freshMeta(_$$0, _sc$$0.h0, sc$$4.h3, Lib_Types_User); case "RImplicit": return Lib_Elab_freshMeta(_$$0, _sc$$0.h0, sc$$4.h3, Lib_Types_Normal); case "RCase": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(_$$0, _sc$$0.h1), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta($$sc.h3), ( scty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SCTM ")(Lib_Elab_rpprint(Lib_Types_names(_$$0), $$sc.h2)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("SCTY ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(scty)))(""))), ( _1 ) => { const scnm = Lib_Elab_fresh(_$$0, "sc"); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _sc$$0.h2, ( $$case ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_mkPat(Prelude__$2C_(null, null, $$case.h0, Lib_Types_Explicit)), ( pat$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_MkClause(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)($$case.h0), Prelude__$3A$3A_(null, Prelude__$2C_(null, null, scnm, pat$27), Prelude_Nil(null)), Prelude_Nil(null), $$case.h1)))))), ( clauses ) => { const ctx$27 = Lib_Types_withPos(Lib_Types_extend(_$$0, scnm, scty), Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$1)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(ctx$27, Lib_Elab_MkProb(clauses, sc$$4.h3)), ( tree ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Let(_sc$$0.h0, scnm, $$sc.h2, tree)))); }))); }))))))); case "RLet": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _sc$$0.h2, Lib_Types_VU(Lib_Common_emptyFC)), ( ty$271 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, ty$271), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, _sc$$0.h3, vty), ( v$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_$$0), Lib_Types_CBN, v$27), ( vv ) => { const ctx$27 = Lib_Types_define(_$$0, _sc$$0.h1, vv, vty); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(ctx$27, _sc$$0.h4, sc$$4.h3), ( sc$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Let(_sc$$0.h0, _sc$$0.h1, v$27, sc$27)))); }))))))); case "RLam": { const _sc$$1 = _sc$$0.h1; const _sc$$2 = sc$$4.h3; switch (_sc$$2.tag) { case "VPi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("icits ")(_sc$$1.h1))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_sc$$1.h2)))(" "))(_sc$$2.h1))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_sc$$2.h2)))(""))), ( _ ) => { const sc$$23 = Prelude__$3D$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit)(_sc$$1.h2)(_sc$$2.h2); switch (sc$$23.tag) { case "False": { const sc$$24 = Prelude__$2F$3D_(null, Lib_Types_Prelude_Eq$20Lib_Types_Icit, _sc$$2.h2, Lib_Types_Explicit); switch (sc$$24.tag) { case "False": return Lib_Types_error(null, _sc$$0.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Icity issue checking ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(sc$$4.h2)))(" at "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$4.h3)))("")); case "True": { const $var = Lib_Types_VVar(_sc$$0.h0, Prelude_length$27(null, Lib_Types__env(_$$0)), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_sc$$2.h5, $var), ( ty$271 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_extend(_$$0, _sc$$2.h1, _sc$$2.h4), sc$$4.h2, ty$271), ( sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lam(_sc$$0.h0, _sc$$2.h1, _sc$$1.h2, _sc$$2.h3, sc)))))); break; } } break; } case "True": { const $var = Lib_Types_VVar(_sc$$0.h0, Prelude_length$27(null, Lib_Types__env(_$$0)), Prelude_Lin(null)); const ctx$27 = Lib_Types_extend(_$$0, _sc$$1.h1, _sc$$2.h4); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_sc$$2.h5, $var), ( bapp ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(ctx$27, _sc$$0.h2, bapp), ( tm$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lam(_sc$$0.h0, _sc$$1.h1, _sc$$1.h2, _sc$$2.h3, tm$27)))))); break; } } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_prvalCtx(_$$0, sc$$4.h3), ( pty ) => (Lib_Types_error(null, _sc$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected pi type, got ")(pty))("")))); } break; } default: { const _sc$$1 = sc$$4.h3; switch (_sc$$1.tag) { case "VPi": { const _sc$$2 = _sc$$1.h2; switch (_sc$$2.tag) { case "Auto": { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$0)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("XXX edge case add auto lambda {")(_sc$$1.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$1.h4)))("} to "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(sc$$4.h2)))(" "))), ( _ ) => { const $var = Lib_Types_VVar(_sc$$1.h0, Prelude_length$27(null, Lib_Types__env(_$$0)), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_sc$$1.h5, $var), ( ty$271 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debugM(Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_prvalCtx(Lib_Types_extend(_$$0, _sc$$1.h1, _sc$$1.h4), ty$271), ( pty$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("XXX ty' is ")(pty$27))(""))))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_extend(_$$0, _sc$$1.h1, _sc$$1.h4), sc$$4.h2, ty$271), ( sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lam(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$4.h2), _sc$$1.h1, Lib_Types_Auto, _sc$$1.h3, sc)))))))); }); break; } case "Implicit": { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$0)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("XXX edge case add implicit lambda {")(_sc$$1.h1))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_sc$$1.h4)))("} to "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(sc$$4.h2)))(" "))), ( _ ) => { const $var = Lib_Types_VVar(_sc$$1.h0, Prelude_length$27(null, Lib_Types__env(_$$0)), Prelude_Lin(null)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_sc$$1.h5, $var), ( ty$271 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debugM(Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_prvalCtx(Lib_Types_extend(_$$0, _sc$$1.h1, _sc$$1.h4), ty$271), ( pty$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("XXX ty' is ")(pty$27))(""))))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_extend(_$$0, _sc$$1.h1, _sc$$1.h4), sc$$4.h2, ty$271), ( sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lam(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$4.h2), _sc$$1.h1, Lib_Types_Implicit, _sc$$1.h3, sc)))))))); }); break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(_$$0, sc$$4.h2), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_insert(_$$0, $$sc.h2, $$sc.h3), ( $$sc1 ) => { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$0)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("INFER ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(sc$$4.h2)))(" to ("))(Lib_Elab_rpprint(names, $$sc1.h2)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)($$sc1.h3)))(") expect "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$4.h3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$4.h2), _$$0, $$sc1.h3, sc$$4.h3), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)($$sc1.h2))))); }))); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_infer(_$$0, sc$$4.h2), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_insert(_$$0, $$sc.h2, $$sc.h3), ( $$sc1 ) => { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_$$0)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("INFER ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(sc$$4.h2)))(" to ("))(Lib_Elab_rpprint(names, $$sc1.h2)))(" : "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)($$sc1.h3)))(") expect "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(sc$$4.h3)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_unifyCatch(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$4.h2), _$$0, $$sc1.h3, sc$$4.h3), ( _1 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)($$sc1.h2))))); }))); } break; } } }));
const Lib_Util_MkBinder = ( h0, h1, h2, h3, h4 ) => ({ tag: "MkBinder",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Util_splitTele_go = ( _, _$$1, _$$2 ) => { switch (_$$2.tag) { case "Pi": return Lib_Util_splitTele_go(_, Prelude__$3A$3A_(null, Lib_Util_MkBinder(_$$2.h0, _$$2.h1, _$$2.h2, _$$2.h3, _$$2.h4), _$$1), _$$2.h5); default: return Prelude__$2C_(null, null, _$$2, Prelude_reverse(null)(_$$1)); } };
const Lib_Util_splitTele = ((  ) => { const go = null; return ( eta ) => (Lib_Util_splitTele_go(go, Prelude_Nil(null), eta)); })();
const Lib_Elab_findMatches = ( _$$0, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": { const _sc$$0 = _$$2.h1; const sc$$10 = Lib_Elab_isCandidate(_$$1, _sc$$0.h2); switch (sc$$10.tag) { case "False": return Lib_Elab_findMatches(_$$0, _$$1, _$$2.h2); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => { const fc = Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)(_$$1); return Lib_Types_catchError(null, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TRY ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" : "))(Lib_Elab_rpprint(Prelude_Nil(null), _sc$$0.h2)))(" for "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$1)))(""))), ( _ ) => { const _sc$$1 = _sc$$0.h1; const sc$$18 = Lib_Util_splitTele(_sc$$0.h2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_modifyIORef(null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), ( mc1 ) => (Lib_Types_MC(Lib_Types__metas(mc1), Lib_Types__next(mc1), Lib_Types_CheckFirst))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(_$$0, Lib_Syntax_RVar(fc, _sc$$1.h1), _$$1), ( tm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Found ")(Lib_Elab_rpprint(Prelude_Nil(null), tm)))(" for "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$1)))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_writeIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), mc), ( _3 ) => (Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude__$3A$3A_(null, _sc$$1.h1, eta)), Lib_Elab_findMatches(_$$0, _$$1, _$$2.h2)))))))))); }), ( err ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("No match ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$1)))(" "))(Lib_Elab_rpprint(Prelude_Nil(null), _sc$$0.h2)))(" "))(Lib_Common_showError("", err)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_writeIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top), mc), ( _1 ) => (Lib_Elab_findMatches(_$$0, _$$1, _$$2.h2))))))); }))); } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nil(null)); } };
const Lib_ProcessDecl_dumpEnv_isVar = ( _, _1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "VVar": { const _sc$$0 = _$$3.h2; switch (_sc$$0.tag) { case "Lin": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$2)(_$$3.h1); default: return Prelude_False; } break; } default: return Prelude_False; } };
const Lib_ProcessDecl_dumpEnv_isVar_go = ( _, _1, _2, _$$3, _$$4, _$$5, _$$6 ) => { switch (_$$5.tag) { case "_::_": { const _sc$$0 = _$$5.h1; const _sc$$1 = _sc$$0.h3; const sc$$18 = Lib_ProcessDecl_dumpEnv_isVar(_, _1, _$$4, _sc$$0.h2); switch (sc$$18.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$0.h2), ( v$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$1.h3), ( ty$27 ) => (Lib_ProcessDecl_dumpEnv_isVar_go(_, _1, _2, _$$3, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$4), _$$5.h2, Prelude__$3A$3A_(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(_sc$$1.h2))(" = "))(Lib_Prettier_render(90, Lib_Types_pprint(_$$3, v$27))))(" : "))(Lib_Prettier_render(90, Lib_Types_pprint(_$$3, ty$27))))(""), _$$6)))))); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_), _sc$$1.h3), ( ty$27 ) => (Lib_ProcessDecl_dumpEnv_isVar_go(_, _1, _2, _$$3, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$4), _$$5.h2, Prelude__$3A$3A_(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(_sc$$1.h2))(" : "))(Lib_Prettier_render(90, Lib_Types_pprint(_$$3, ty$27))))(""), _$$6)))); } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$6); } };
const Lib_ProcessDecl_dumpEnv = ( _$$0 ) => { const isVar = null; const go = null; return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Prelude__$2218_(null, null, null, Prelude_unlines, Prelude_reverse(null), eta)), Lib_ProcessDecl_dumpEnv_isVar_go(_$$0, isVar, go, Lib_Types_names(_$$0), 0, Prelude_reverse(null)(Prelude_zip(null, null, Lib_Types__env(_$$0), Lib_Types__types(_$$0))), Prelude_Nil(null))); };
const Lib_ProcessDecl_logMetas = ( _$$0 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; switch (_sc$$0.tag) { case "OutOfScope": return Lib_ProcessDecl_logMetas(_$$0.h2); case "Solved": return Lib_ProcessDecl_logMetas(_$$0.h2); case "Unsolved": { const _sc$$1 = _sc$$0.h4; switch (_sc$$1.tag) { case "User": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_sc$$0.h2), _sc$$0.h3), ( ty$27 ) => { const names = Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_fst(null, null, eta)))(Lib_Types__types(_sc$$0.h2)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_dumpEnv(_sc$$0.h2), ( env ) => { const msg = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(env))("\n  -----------\n  "))(Lib_Prettier_render(90, Lib_Types_pprint(names, ty$27))))(""); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_info(_sc$$0.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("User Hole\n")(msg))("")), ( _ ) => (Lib_ProcessDecl_logMetas(_$$0.h2))); }); }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_forceMeta(_sc$$0.h3), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_sc$$0.h2), ty$27), ( tm ) => { const msg = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Unsolved meta ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_MetaKind)(_sc$$0.h4)))(" type "))(Lib_Prettier_render(90, Lib_Types_pprint(Lib_Types_names(_sc$$0.h2), tm))))(" "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Prelude_length$27(null, _sc$$0.h5))))(" constraints"); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _sc$$0.h5, ( $$case ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  * (m")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" ("))(Data_String_unwords(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(Prelude__$3C$3E$3E_(null, $$case.h2, Prelude_Nil(null))))))(") =?= "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)($$case.h3)))("")))), ( msgs ) => { const _sc$$2 = _sc$$0.h4; switch (_sc$$2.tag) { case "AutoSolve": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_quote(Lib_Types__lvl(_sc$$0.h2), _sc$$0.h3), ( x ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Lib_Types__env(_sc$$0.h2), Lib_Types_CBN, x), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("AUTO ---> ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(ty)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_findMatches(_sc$$0.h2, ty, Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Prelude_snd(null, null, eta)))(Data_SortedMap_toList(null, null, Lib_Types__defs(top)))), ( matches ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$3A$3A_(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(Prelude_length$27(null, matches))))(" Solutions: "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(matches)))(""), Prelude_Nil(null))))))))))))), ( sols ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_info(_sc$$0.h0, Prelude_unlines(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(Prelude__$3A$3A_(null, msg, Prelude_Nil(null)))(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(msgs)(sols)))), ( _ ) => (Lib_ProcessDecl_logMetas(_$$0.h2))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nil(null)), ( sols ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_info(_sc$$0.h0, Prelude_unlines(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(Prelude__$3A$3A_(null, msg, Prelude_Nil(null)))(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20$28Prelude_List$20BND$3A0$29(null))(msgs)(sols)))), ( _ ) => (Lib_ProcessDecl_logMetas(_$$0.h2))))); } }); }))); } break; } } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } };
const Lib_Types__ops = ( _$$0 ) => (_$$0.h7);
const Lib_Types_MkTop = ( h0, h1, h2, h3, h4, h5, h6, h7 ) => ({ tag: "MkTop",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5,  h6: h6,  h7: h7 });
const Lib_Types_putTop = ( _$$0 ) => (Lib_Types_MkM(null, ( _ ) => (Prelude_pure(null, Prelude_Prelude_Monad$20Prelude_IO)(null)(Prelude_Right(null, null, Prelude__$2C_(null, null, _$$0, Prelude_MkUnit))))));
const Lib_Types_modifyTop = ( _$$0 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( tc ) => (Lib_Types_putTop(_$$0(tc)))));
const Lib_Types_CheckAll = { tag: "CheckAll" };
const Serialize_dumpObject = (_,fn,a) => (w) => {
  let fs = require('fs')
  try {
    let {EncFile} = require('./serializer')
    let enc = EncFile.encode(a)
    fs.writeFileSync(fn, enc)
  } catch (e) {}
  return Prelude_MkIORes(null, Prelude_MkUnit, w)
}
const Lib_Types__ctxOps = ( _$$0 ) => (_$$0.h2);
const Serialize_dumpModule = ( _$$0, _$$1, _$$2 ) => { const fn = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("build/")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0)))(".newtmod"); const defs = Data_SortedMap_listValues(null, null, Lib_Types__modDefs(_$$2)); const ops = Data_SortedMap_toList(null, null, Lib_Types__ctxOps(_$$2)); const mctx = Data_SortedMap_toList(null, null, Lib_Types__metas(Lib_Types__modMetaCtx(_$$2))); return Prelude_liftIO(null, Lib_Types_Prelude_HasIO$20Lib_Types_M)(null)(Serialize_dumpObject(null, fn, Prelude__$2C_(null, null, _$$1, Prelude__$2C_(null, null, defs, Prelude__$2C_(null, null, ops, mctx))))); };
const Lib_Types_MkModCtx = ( h0, h1, h2 ) => ({ tag: "MkModCtx",  h0: h0,  h1: h1,  h2: h2 });
const Lib_TopContext_addError = ( _$$0 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Data_IORef_modifyIORef(null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__errors(top), ( eta ) => (Prelude__$3A$3A_(null, _$$0, eta))))));
const Lib_Types_Axiom = { tag: "Axiom" };
const Lib_Types_MkEntry = ( h0, h1, h2, h3 ) => ({ tag: "MkEntry",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_TopContext_setDef = ( _$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$5 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__defs(top)); switch (sc$$5.tag) { case "Nothing": return Lib_Types_modifyTop(( $$case ) => { const defs = Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types_MkEntry(_$$1, _$$0, _$$2, _$$3), Lib_Types__defs(top)); return Lib_Types_MkTop($$case.h0, $$case.h1, $$case.h2, defs, $$case.h4, $$case.h5, $$case.h6, $$case.h7); }); case "Just": { const _sc$$0 = sc$$5.h1; return Lib_Types_error(null, _$$1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0)))(" is already defined at "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_sc$$0.h0)))("")); break; } } }));
const Lib_Eval_appSpine = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "_::_": return Lib_Eval_appSpine(Lib_Types_App(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$0), _$$0, _$$1.h1), _$$1.h2); case "Nil": return _$$0; } };
const Lib_Eval_tweakFC = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Erased": return Lib_Types_Erased(_$$0); case "Lit": return Lib_Types_Lit(_$$0, _$$1.h1); case "LetRec": return Lib_Types_LetRec(_$$0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4); case "Let": return Lib_Types_Let(_$$0, _$$1.h1, _$$1.h2, _$$1.h3); case "Case": return Lib_Types_Case(_$$0, _$$1.h1, _$$1.h2); case "Pi": return Lib_Types_Pi(_$$0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4, _$$1.h5); case "UU": return Lib_Types_UU(_$$0); case "App": return Lib_Types_App(_$$0, _$$1.h1, _$$1.h2); case "Lam": return Lib_Types_Lam(_$$0, _$$1.h1, _$$1.h2, _$$1.h3, _$$1.h4); case "Meta": return Lib_Types_Meta(_$$0, _$$1.h1); case "Ref": return Lib_Types_Ref(_$$0, _$$1.h1); case "Bnd": return Lib_Types_Bnd(_$$0, _$$1.h1); } };
const Lib_Eval_zonkApp = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { switch (_$$3.tag) { case "App": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h2), ( u$27 ) => (Lib_Eval_zonkApp(_$$0, _$$1, _$$2, _$$3.h1, Prelude__$3A$3A_(null, u$27, _$$4)))); case "Meta": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_lookupMeta(_$$3.h1), ( meta ) => { switch (meta.tag) { case "Solved": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Eval_eval(_$$2, Lib_Types_CBN, eta)))(_$$4), ( sp$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("zonk ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$3.h1)))(" -> "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(meta.h2)))(" spine "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(sp$27)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_vappSpine(meta.h2, Prelude__$3C$3E$3C_(null, Prelude_Lin(null), sp$27)), ( foo ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("-> result is ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(foo)))(""))), ( _1 ) => (Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Eval_tweakFC(_$$3.h0, eta)), Lib_Eval_quote(_$$1, foo)))))))))); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Eval_appSpine(_$$3, _$$4)); } }); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3), ( t$27 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Eval_appSpine(t$27, _$$4)))); } };
const Lib_Eval_zonkBind = ( _$$0, _$$1, _$$2, _$$3 ) => (Lib_Eval_zonk(_$$0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$1), Prelude__$3A$3A_(null, Lib_Types_VVar(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$3), _$$1, Prelude_Lin(null)), _$$2), _$$3));
const Lib_Eval_zonkAlt_go = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10, _$$11 ) => { switch (_$$10.tag) { case "_::_": return Lib_Eval_zonkAlt_go(_, _1, _2, _3, _4, _5, _6, _7, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$8), Prelude__$3A$3A_(null, Lib_Types_VVar(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(_$$11), _$$8, Prelude_Lin(null)), _$$9), _$$10.h2, _$$11); case "Nil": return Lib_Eval_zonk(_, _$$8, _$$9, _6); } };
const Lib_Eval_zonkAlt = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "CaseLit": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_CaseLit(_$$3.h0, eta)), Lib_Eval_zonkBind(_$$0, _$$1, _$$2, _$$3.h1)); case "CaseCons": { const go = null; return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_CaseCons(_$$3.h0, _$$3.h1, eta)), Lib_Eval_zonkAlt_go(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, _$$3.h2, go, _$$1, _$$2, _$$3.h1, _$$3.h2)); break; } case "CaseDefault": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, Lib_Types_CaseDefault, Lib_Eval_zonkBind(_$$0, _$$1, _$$2, _$$3.h0)); } };
const Lib_Eval_zonk = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "Erased": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Erased(_$$3.h0)); case "Lit": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Lit(_$$3.h0, _$$3.h1)); case "LetRec": return Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( 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, _$$2, _$$3.h3)))(Lib_Eval_zonkBind(_$$0, _$$1, _$$2, _$$3.h4)); case "Let": return Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (( eta1 ) => (Lib_Types_Let(_$$3.h0, _$$3.h1, eta, eta1))), Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h2)))(Lib_Eval_zonkBind(_$$0, _$$1, _$$2, _$$3.h3)); case "Case": return Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (( eta1 ) => (Lib_Types_Case(_$$3.h0, eta, eta1))), Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h1)))(Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Eval_zonkAlt(_$$0, _$$1, _$$2, eta)))(_$$3.h2)); case "Pi": return Prelude__$3C$2A$3E_(null, Lib_Types_Prelude_Applicative$20Lib_Types_M)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( 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, _$$2, _$$3.h5)); case "UU": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_UU(_$$3.h0)); case "App": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_zonk(_$$0, _$$1, _$$2, _$$3.h2), ( u$27 ) => (Lib_Eval_zonkApp(_$$0, _$$1, _$$2, _$$3.h1, Prelude__$3A$3A_(null, u$27, Prelude_Nil(null))))); case "Lam": return Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Types_Lam(_$$3.h0, _$$3.h1, _$$3.h2, _$$3.h3, eta)), Lib_Eval_zonk(_$$0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(_$$1), Prelude__$3A$3A_(null, Lib_Types_VVar(_$$3.h0, _$$1, Prelude_Lin(null)), _$$2), _$$3.h4)); case "Meta": return Lib_Eval_zonkApp(_$$0, _$$1, _$$2, _$$3, Prelude_Nil(null)); case "Ref": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Ref(_$$3.h0, _$$3.h1)); case "Bnd": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types_Bnd(_$$3.h0, _$$3.h1)); } };
const Lib_Types_mkCtx = ( _$$0 ) => (Lib_Types_MkCtx(0, Prelude_Nil(null), Prelude_Nil(null), Prelude_Nil(null), _$$0));
const Lib_Types__fc = ( _$$0 ) => (_$$0.h0);
const Lib_TopContext_updateDef = ( _$$0, _$$1, _$$2, _$$3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const sc$$5 = Data_SortedMap_lookupMap$27(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types__defs(top)); switch (sc$$5.tag) { case "Nothing": return Lib_Types_error(null, _$$1, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_$$0)))(" not declared")); case "Just": { const _sc$$0 = sc$$5.h1; return Lib_Types_modifyTop(( $$case ) => { const defs = Data_SortedMap_updateMap(null, null, Lib_Common_Prelude_Ord$20Lib_Common_QName, _$$0, Lib_Types_MkEntry(_sc$$0.h0, _$$0, _$$2, _$$3), $$case.h3); return Lib_Types_MkTop($$case.h0, $$case.h1, $$case.h2, defs, $$case.h4, $$case.h5, $$case.h6, $$case.h7); }); break; } } }));
const Lib_Eval_nfv = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, Lib_Types_CBV, _$$1), ( eta ) => (Lib_Eval_quote(Prelude_length$27(null, _$$0), eta))));
const Lib_Eval_nf = ( _$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(_$$0, Lib_Types_CBN, _$$1), ( eta ) => (Lib_Eval_quote(Prelude_length$27(null, _$$0), eta))));
const Lib_Types_TCon = ( h0, h1 ) => ({ tag: "TCon",  h0: h0,  h1: h1 });
const Lib_Util_piArity = ( _$$0 ) => { switch (_$$0.tag) { case "Pi": return Prelude_S(Lib_Util_piArity(_$$0.h5)); default: return Prelude_Z; } };
const Lib_Elab_getArity = ( _$$0 ) => { switch (_$$0.tag) { case "Pi": return Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(1)(Lib_Elab_getArity(_$$0.h5)); default: return 0; } };
const Lib_Types_DCon = ( h0, h1 ) => ({ tag: "DCon",  h0: h0,  h1: h1 });
const Lib_ProcessDecl_processDecl_binderName = ( _, _1, _2, _3, _4, _5, _6, _$$7 ) => (_$$7.h1);
const Lib_Syntax_wrap = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "Auto": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("{{"))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$1)(Lib_Prettier_text("}}"))); case "Explicit": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$1)(Lib_Prettier_text(")"))); case "Implicit": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("{"))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$1)(Lib_Prettier_text("}"))); } };
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par = ( _, _1, _$$2, _$$3, _$$4 ) => { const sc$$5 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _$$3, _$$2); switch (sc$$5.tag) { case "False": return _$$4; case "True": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(_$$4)(Lib_Prettier_text(")"))); } };
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Types_Literal$2Cpretty = ( _$$0 ) => { switch (_$$0.tag) { case "LChar": return Lib_Prettier_text(Prelude_show(null, Prelude_Prelude_Show$20Prim_Char)(_$$0.h0)); case "LInt": return Lib_Prettier_text(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h0)); case "LString": return Lib_Prettier_text(_$$0.h0); } };
const Lib_Prettier_MkPretty = ( h0, h1 ) => ({ tag: "MkPretty",  h0: h0,  h1: h1 });
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Types_Literal = Lib_Prettier_MkPretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Types_Literal$2Cpretty);
const Lib_Prettier_pretty = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "RAs": return Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text(_$$4.h1))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("@("))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h2))(Lib_Prettier_text(")")))); case "RWhere": return Lib_Prettier_text("TODO pretty where"); case "RIf": return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 0, Lib_Prettier__$3C$2B$2F$3E_(Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("if"))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h1)), Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("then"))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h2))), Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("else"))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h3)))); case "RDo": return Lib_Prettier_text("TODO - RDo"); case "RHole": return Lib_Prettier_text("?"); case "RImplicit": return Lib_Prettier_text("_"); case "RCase": return Lib_Prettier_text("TODO - RCase"); case "RLit": return Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Types_Literal)(_$$4.h1); case "RAnn": return Lib_Prettier_text("TODO - RAnn"); case "RLet": return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 0, Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("let"))(Lib_Prettier_text(_$$4.h1)))(Lib_Prettier_text(":")))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h3)))(Lib_Prettier_text("=")))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h2)), Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("in"))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h4)))); case "RPi": { const _sc$$0 = _$$4.h1; const _sc$$1 = _sc$$0.h1; switch (_sc$$1) { case "_": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "Explicit": { const _sc$$3 = _sc$$0.h3; switch (_sc$$3.tag) { case "Many": return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 1, Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h2))(Lib_Prettier_text("->")), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h3))); default: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 1, Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_wrap(_sc$$0.h2, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_sc$$0.h3))(_sc$$0.h1)))(Lib_Prettier_text(":")))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h2))))(Lib_Prettier_text("->")), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 1, _$$4.h3))); } break; } default: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 1, Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_wrap(_sc$$0.h2, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_sc$$0.h3))(_sc$$0.h1)))(Lib_Prettier_text(":")))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h2))))(Lib_Prettier_text("->")), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 1, _$$4.h3))); } break; } default: return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 1, Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_wrap(_sc$$0.h2, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_sc$$0.h3))(_sc$$0.h1)))(Lib_Prettier_text(":")))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, _$$3, _$$4.h2))))(Lib_Prettier_text("->")), Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 1, _$$4.h3))); } break; } case "RU": return Lib_Prettier_text("U"); case "RApp": { const _sc$$0 = _$$4.h3; switch (_sc$$0.tag) { case "Auto": return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 2, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 2, _$$4.h1))(Lib_Prettier_text("{{")))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h2))(Lib_Prettier_text("}}")))); case "Explicit": return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 2, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 2, _$$4.h1))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 3, _$$4.h2))); case "Implicit": return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 2, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 2, _$$4.h1))(Lib_Prettier_text("{")))(Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h2))(Lib_Prettier_text("}")))); } break; } case "RLam": { const _sc$$0 = _$$4.h1; return Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par(_, _1, _$$3, 0, Prelude__$2B$2B_(null, Lib_Prettier_Prelude_Concat$20Lib_Prettier_Doc)(Lib_Prettier_text("\\"))(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Syntax_wrap(_sc$$0.h2, Lib_Prettier_text(_sc$$0.h1)))(Lib_Prettier_text("=>")))(Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(_, _1, _2, 0, _$$4.h2)))); break; } case "RVar": return Lib_Prettier_text(_$$4.h1); } };
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty = ((  ) => { const bindDoc = null; const par = null; const asDoc = null; return ( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty_bindDoc_par_asDoc(bindDoc, par, asDoc, 0, eta)); })();
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw = Lib_Prettier_MkPretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw$2Cpretty);
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty_prettyPair = ( _, _1, _2, _3, _4, _$$5 ) => (Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$5.h2))(Lib_Prettier_text("=")))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$5.h3)));
const Lib_Syntax_pipeSep = ( eta ) => (Lib_Prettier_folddoc(( a ) => (( b ) => (Lib_Prettier__$3C$2B$2F$3E_(a, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("|"))(b)))), eta));
const Lib_Prettier_empty = Lib_Prettier_Empty;
const Prelude_maybe = ( a$$0, b$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "Nothing": return _$$2; case "Just": return _$$3(_$$4.h1); } };
const Lib_Common_Prelude_Show$20Lib_Common_Fixity$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "Infix": return "infix"; case "InfixR": return "infixr"; case "InfixL": return "infixl"; } };
const Lib_Common_Prelude_Show$20Lib_Common_Fixity = Prelude_MkShow(null, Lib_Common_Prelude_Show$20Lib_Common_Fixity$2Cshow);
const Lib_Syntax_prettyBind = ( _$$0 ) => { const _sc$$0 = _$$0.h2; return Lib_Syntax_wrap(_sc$$0.h2, Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_sc$$0.h3))(_sc$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h3))); };
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty = ( _$$0 ) => { switch (_$$0.tag) { case "Record": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("record"))(Lib_Prettier_text(_$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_spread(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Syntax_prettyBind)(_$$0.h2))))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2F$3E_(Lib_Prettier_text("where"), Lib_Prettier_stack(Prelude__$3A$3A_(null, Prelude_maybe(null, null, Lib_Prettier_empty, ( nm$27 ) => (Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("constructor"))(Lib_Prettier_text(nm$27))), _$$0.h3), Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl))(_$$0.h4)))))); case "Instance": return Lib_Prettier_text("TODO pretty Instance"); case "Class": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("class"))(Lib_Prettier_text(_$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_spread(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Syntax_prettyBind)(_$$0.h2))))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2F$3E_(Lib_Prettier_text("where"), Lib_Prettier_stack(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl))(_$$0.h3))))); case "PMixFix": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_Fixity)(_$$0.h3)))(Lib_Prettier_text(Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h2))))(Lib_Prettier_spread(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_text)(_$$0.h1))); case "PFunc": { const _sc$$0 = _$$0.h2; switch (_sc$$0.tag) { case "Nil": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("pfunc"))(Lib_Prettier_text(_$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h3))(Lib_Prettier_text(":=")), Lib_Prettier_text(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h4))))); default: return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("pfunc"))(Lib_Prettier_text(_$$0.h1)))(Lib_Prettier_text("uses")))(Lib_Prettier_spread(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_text)(_$$0.h2))))(Lib_Prettier_text(":")))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2B$2F$3E_(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h3))(Lib_Prettier_text(":=")), Lib_Prettier_text(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h4))))); } break; } case "PType": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("ptype"))(Lib_Prettier_text(_$$0.h1)))(Prelude_maybe(null, null, Lib_Prettier_empty, ( ty ) => (Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text(":"))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(ty))), _$$0.h2)); case "ShortData": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("data"))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h1)))(Lib_Prettier_text("=")))(Lib_Syntax_pipeSep(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw))(_$$0.h2))); case "Data": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("data"))(Lib_Prettier_text(_$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h2)))(Lib_Prettier_nest(2)(Lib_Prettier__$3C$2F$3E_(Lib_Prettier_text("where"), Lib_Prettier_stack(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl))(_$$0.h3))))); case "DCheck": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_text("#check"))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h2)); case "Def": { const prettyPair = null; return Lib_Prettier_stack(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty_prettyPair(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, prettyPair, eta)))(_$$0.h2)); break; } case "TypeSig": return Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Prelude__$3C$2B$3E_(null, Lib_Prettier_Prelude_Semigroup$20Lib_Prettier_Doc)(Lib_Prettier_spread(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Prettier_text)(_$$0.h1)))(Lib_Prettier_text(":")))(Lib_Prettier_nest(2)(Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$0.h2))); } };
const Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl = Lib_Prettier_MkPretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl$2Cpretty);
const Lib_Syntax_Data = ( h0, h1, h2, h3 ) => ({ tag: "Data",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Syntax_TypeSig = ( h0, h1, h2 ) => ({ tag: "TypeSig",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Syntax_RU = ( h0 ) => ({ tag: "RU",  h0: h0 });
const Lib_Types_Zero = { tag: "Zero" };
const Lib_Syntax_RPi = ( h0, h1, h2, h3 ) => ({ tag: "RPi",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_ProcessDecl_processDecl_mkPi_getArgs_mkDecl_mkPi = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _$$14, _$$15 ) => (Lib_Syntax_RPi(_$$14.h2, Lib_Types_BI(_$$14.h2, _$$14.h3, Lib_Types_Implicit, Lib_Types_Zero), Lib_Syntax_RU(_$$14.h2), _$$15));
const Prelude_foldr = ( a$$0, b$$1, _$$2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "_::_": return _$$2(_$$4.h1)(Prelude_foldr(null, null, _$$2, _$$3, _$$4.h2)); case "Nil": return _$$3; } };
const Lib_ProcessDecl_processDecl_mkPi_getArgs_mkDecl = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10 ) => { switch (_$$10.tag) { case "RApp": return Lib_ProcessDecl_processDecl_mkPi_getArgs_mkDecl(_, _1, _2, _3, _4, _5, _6, _7, _$$8, Prelude__$3A$3A_(null, _$$10.h2, _$$9), _$$10.h1); case "RVar": { const mkPi = null; const base = Prelude_foldr(null, null, ( ty ) => (( acc ) => (Lib_Syntax_RPi(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(ty), Lib_Types_BI(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(ty), "_", Lib_Types_Explicit, Lib_Types_Many), ty, acc))), _3, _$$9); const ty = Prelude_foldr(null, null, ( eta ) => (( eta1 ) => (Lib_ProcessDecl_processDecl_mkPi_getArgs_mkDecl_mkPi(_, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10, _$$10.h0, _$$10.h1, mkPi, eta, eta1))), base, _$$8); return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Syntax_TypeSig(_$$10.h0, Prelude__$3A$3A_(null, _$$10.h1, Prelude_Nil(null)), ty)); break; } default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$10), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected contructor application, got: ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$10)))("")); } };
const Lib_ProcessDecl_processDecl_mkPi = ( _, _1, _2, _3, _4, _5, _$$6, _$$7 ) => (Lib_Syntax_RPi(_$$6.h2, Lib_Types_BI(_$$6.h2, _$$6.h3, Lib_Types_Explicit, Lib_Types_Zero), Lib_Syntax_RU(_$$6.h2), _$$7));
const Lib_ProcessDecl_processDecl_mkPi_getArgs = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8 ) => { switch (_$$7.tag) { case "RApp": { const _sc$$0 = _$$7.h2; switch (_sc$$0.tag) { case "RVar": return Lib_ProcessDecl_processDecl_mkPi_getArgs(_, _1, _2, _3, _4, _5, _6, _$$7.h1, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, _sc$$0.h1), _$$8)); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$7), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected contructor application, got: ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$7)))("")); } break; } case "RVar": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, _$$7.h1, _$$8)); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$7), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected contructor application, got: ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$7)))("")); } };
const Lib_Types_PrimTCon = ( h0 ) => ({ tag: "PrimTCon",  h0: h0 });
const Lib_Types_PrimFn = ( h0, h1, h2 ) => ({ tag: "PrimFn",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Types__name = ( _$$0 ) => (_$$0.h1);
const Lib_ProcessDecl_processDecl_makeLHS = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8 ) => { switch (_$$8.tag) { case "_::_": { const _sc$$0 = _$$8.h1; const _sc$$1 = _sc$$0.h2; return Lib_Syntax_RApp(_sc$$1.h0, Lib_ProcessDecl_processDecl_makeLHS(_, _1, _2, _3, _4, _5, _6, _$$7, _$$8.h2), Lib_Syntax_RVar(_sc$$1.h0, _sc$$1.h1), Lib_Types_Implicit); break; } case "Nil": return _$$7; } };
const Lib_ProcessDecl_processDecl_makeLHS_mkAutoApp = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9 ) => { const _sc$$0 = _$$9.h3; return Lib_Syntax_RApp(_$$9.h2, _$$8, Lib_Syntax_RVar(_$$9.h2, _sc$$0.h2), Lib_Types_Explicit); };
const Lib_ProcessDecl_impTele_foo = ( _, _1, _$$2 ) => { const _sc$$0 = _$$2.h2; return Prelude__$2C_(null, null, Lib_Types_BI(_sc$$0.h0, _sc$$0.h1, Lib_Types_Implicit, Lib_Types_Zero), _$$2.h3); };
const Lib_ProcessDecl_impTele = ( _$$0 ) => { const foo = null; return Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_ProcessDecl_impTele_foo(_$$0, foo, eta)))(_$$0); };
const Lib_Types_Lib_Common_HasFC$20Lib_Types_BindInfo$2CgetFC = ( _$$0 ) => (_$$0.h0);
const Lib_Types_Lib_Common_HasFC$20Lib_Types_BindInfo = Lib_Common_MkHasFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_BindInfo$2CgetFC);
const Lib_ProcessDecl_teleToPi = ( _$$0, _$$1 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; return Lib_Syntax_RPi(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_BindInfo)(_sc$$0.h2), _sc$$0.h2, _sc$$0.h3, Lib_ProcessDecl_teleToPi(_$$0.h2, _$$1)); break; } case "Nil": return _$$1; } };
const Lib_ProcessDecl_processDecl_makeLHS_mkAutoApp_mkPi = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$9, _$$10 ) => { const _sc$$0 = _$$9.h3; return Lib_Syntax_RPi(_$$9.h2, Lib_Types_BI(_$$9.h2, _sc$$0.h2, Lib_Types_Explicit, Lib_Types_Many), _sc$$0.h3, _$$10); };
const Lib_ProcessDecl_processDecl_makeLHS_mkAutoApp_mkPi_mkApp = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$10, _$$11 ) => { const _sc$$0 = _$$11.h2; return Lib_Syntax_RApp(_sc$$0.h0, _$$10, Lib_Syntax_RVar(_sc$$0.h0, _sc$$0.h1), _sc$$0.h2); };
const Lib_ProcessDecl_getSigs = ( _$$0 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; switch (_sc$$0.tag) { case "TypeSig": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1.tag) { case "_::_": return Prelude__$3A$3A_(null, Prelude__$2C_(null, null, _sc$$0.h0, Prelude__$2C_(null, null, _sc$$1.h1, _sc$$0.h2)), Lib_ProcessDecl_getSigs(_$$0.h2)); case "Nil": return Lib_ProcessDecl_getSigs(_$$0.h2); } break; } default: return Lib_ProcessDecl_getSigs(_$$0.h2); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "Record": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Record", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Syntax_Prelude_Show$20Lib_Types_BindInfo, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)))(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_$$0.h3), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl))(_$$0.h4), Prelude_Nil(null))))))); case "Instance": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Instance", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_Maybe)(null)(null)(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl)))(_$$0.h2)), Prelude_Nil(null))))); case "Class": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Class", Prelude__$3A$3A_(null, _$$0.h1, Prelude__$3A$3A_(null, "...", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl))(_$$0.h3)), Prelude_Nil(null)))))); case "PMixFix": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PMixFix", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_Int)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_Fixity)(_$$0.h3), Prelude_Nil(null)))))); case "PFunc": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PFunc", Prelude__$3A$3A_(null, _$$0.h1, Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h3), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h4), Prelude_Nil(null))))))); case "PType": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "PType", Prelude__$3A$3A_(null, _$$0.h1, Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_Maybe$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw))(_$$0.h2), Prelude_Nil(null))))); case "ShortData": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "ShortData", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw))(_$$0.h2), Prelude_Nil(null))))); case "Data": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Data", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl))(_$$0.h3), Prelude_Nil(null)))))); case "DCheck": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "DCheck", Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude_Nil(null))))); case "Def": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "Def", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20$28Prelude__$D7_$20BND$3A3$20BND$3A2$29(null, null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)))(_$$0.h2), Prelude_Nil(null))))); case "TypeSig": return Lib_Syntax_foo(Prelude__$3A$3A_(null, "TypeSig", Prelude__$3A$3A_(null, Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(_$$0.h1), Prelude__$3A$3A_(null, Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$0.h2), Prelude_Nil(null))))); } };
const Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl = Prelude_MkShow(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl$2Cshow);
const Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10 ) => { switch (_$$9.tag) { case "_::_": { const _sc$$0 = _$$9.h1; const _sc$$1 = _sc$$0.h2; switch (_sc$$1.tag) { case "Explicit": return Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS(_, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9.h2, Lib_Syntax_RApp(_sc$$0.h0, _$$10, Lib_Syntax_RVar(_sc$$0.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$8))(","))(_sc$$0.h1))("")), Lib_Types_Explicit)); default: return Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS(_, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9.h2, _$$10); } break; } case "Nil": return _$$10; } };
const Lib_Syntax_Decl = { tag: "Decl" };
const Lib_Util_Binder = { tag: "Binder" };
const Lib_ProcessDecl_processDecl_getFields = ( _, _1, _2, _3, _4, _5, _$$6, _$$7, _$$8 ) => { switch (_$$6.tag) { case "VPi": { const _sc$$0 = _$$6.h2; switch (_sc$$0.tag) { case "Explicit": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3C$$$3E_(null, Lib_Types_Prelude_Functor$20Lib_Types_M, null, null, ( eta ) => (Lib_Util_MkBinder(_$$6.h0, _$$6.h1, Lib_Types_Explicit, _$$6.h3, eta)), Lib_Eval_quote(Prelude_length$27(null, _$$7), _$$6.h4)), ( bnd ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$6.h5, Lib_Types_VVar(_$$6.h0, Prelude_length$27(null, _$$7), Prelude_Lin(null))), ( appsc ) => (Lib_ProcessDecl_processDecl_getFields(_, _1, _2, _3, _4, _5, appsc, _$$7, Prelude__$3A$3A_(null, bnd, _$$8)))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$6.h5, Lib_Types_VVar(_$$6.h0, Prelude_length$27(null, _$$7), Prelude_Lin(null))), ( appsc ) => (Lib_ProcessDecl_processDecl_getFields(_, _1, _2, _3, _4, _5, appsc, _$$7, _$$8))); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_reverse(null)(_$$8)); } };
const Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS_apply = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$9, _$$10 ) => { switch (_$$10.tag) { case "_::_": switch (_$$9.tag) { case "VPi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval__$$$$_(_$$9.h5, _$$10.h1), ( bx ) => (Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS_apply(_, _1, _2, _3, _4, _5, _6, _7, _8, bx, _$$10.h2))); default: return Lib_Types_error(null, _2, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected pi type ")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(_$$9)))("")); } break; case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(_$$9); } };
const Lib_Util_Prelude_Show$20Lib_Util_Binder$2Cshow = ( _$$0 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("(")(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Quant)(_$$0.h3)))(""))(_$$0.h1))(" "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Icit)(_$$0.h2)))(" : ... :: Nil)"));
const Lib_Util_Prelude_Show$20Lib_Util_Binder = Prelude_MkShow(null, Lib_Util_Prelude_Show$20Lib_Util_Binder$2Cshow);
const Lib_ProcessDecl_processDecl_getFields_tenv = ( _, _1, _2, _3, _4, _5, _6, _$$7 ) => { switch (_$$7.tag) { case "S": return Prelude__$3A$3A_(null, Lib_Types_VVar(Lib_Common_emptyFC, Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(_$$7.h0), Prelude_Lin(null)), Lib_ProcessDecl_processDecl_getFields_tenv(_, _1, _2, _3, _4, _5, _6, _$$7.h0)); case "Z": return Prelude_Nil(null); } };
const Prelude__$D7_ = ( h0, h1 ) => ({ tag: "_×_",  h0: h0,  h1: h1 });
const Lib_ProcessDecl_processDecl = ( _$$0, _$$1 ) => { switch (_$$1.tag) { case "Record": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => ("Record")), ( _1 ) => { const fields = Lib_ProcessDecl_getSigs(_$$1.h4); const dcName = Prelude_fromMaybe(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Mk")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$1.h1)))(""), _$$1.h3); const tcType = Lib_ProcessDecl_teleToPi(_$$1.h2, Lib_Syntax_RU(_$$1.h0)); const tail = Prelude_foldl(null, null, ( acc ) => (( bi ) => { const sc$$14 = Prelude_the(Prelude__$D7_(null, null), bi); const _sc$$0 = sc$$14.h2; return Lib_Syntax_RApp(_sc$$0.h0, acc, Lib_Syntax_RVar(_sc$$0.h0, _sc$$0.h1), _sc$$0.h2); }), Lib_Syntax_RVar(_$$1.h0, _$$1.h1), _$$1.h2); const dcType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$1.h2), Prelude_foldr(null, null, ( x ) => (( acc ) => { const sc$$15 = Prelude_the(Prelude__$D7_(null, null), x); const _sc$$0 = sc$$15.h3; return Lib_Syntax_RPi(sc$$15.h2, Lib_Types_BI(sc$$15.h2, _sc$$0.h2, Lib_Types_Explicit, Lib_Types_Many), _sc$$0.h3, acc); }), tail, fields)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("tcon type ")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(tcType))))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dcon type ")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(dcType))))(""))), ( _3 ) => { const decl = Lib_Syntax_Data(_$$1.h0, _$$1.h1, tcType, Prelude__$3A$3A_(null, Lib_Syntax_TypeSig(_$$1.h0, Prelude__$3A$3A_(null, dcName, Prelude_Nil(null)), dcType), Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _4 ) => ("Decl:")), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _5 ) => (Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(_$$0, decl), ( _6 ) => (Prelude_ignore(null, null, Lib_Types_Prelude_Functor$20Lib_Types_M)(Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, fields, ( $$case ) => { const _sc$$0 = $$case.h3; const funType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$1.h2), Lib_Syntax_RPi($$case.h2, Lib_Types_BI($$case.h2, "_", Lib_Types_Explicit, Lib_Types_Many), tail, _sc$$0.h3)); const autoPat = Prelude_foldl(null, null, ( acc ) => (( x ) => { const sc$$33 = Prelude_the(Prelude__$D7_(null, null), x); const _sc$$1 = sc$$33.h3; return Lib_Syntax_RApp(sc$$33.h2, acc, Lib_Syntax_RVar(sc$$33.h2, _sc$$1.h2), Lib_Types_Explicit); }), Lib_Syntax_RVar(_$$1.h0, dcName), fields); const pname = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(".")(_sc$$0.h2); const lhs = Prelude_foldl(null, null, ( acc ) => (( x ) => { const sc$$35 = Prelude_the(Prelude__$D7_(null, null), x); const _sc$$1 = sc$$35.h2; return Lib_Syntax_RApp(_sc$$1.h0, acc, Lib_Syntax_RVar(_sc$$1.h0, _sc$$1.h1), Lib_Types_Implicit); }), Lib_Syntax_RVar($$case.h2, pname), _$$1.h2); const lhs1 = Lib_Syntax_RApp(_$$1.h0, lhs, autoPat, Lib_Types_Explicit); const pdecl = Lib_Syntax_Def($$case.h2, pname, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, lhs1, Lib_Syntax_RVar($$case.h2, _sc$$0.h2)), Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(pname))(" : "))(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(funType))))(""))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _8 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(pdecl))))(""))), ( _8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(_$$0, Lib_Syntax_TypeSig($$case.h2, Prelude__$3A$3A_(null, pname, Prelude_Nil(null)), funType)), ( _9 ) => (Lib_ProcessDecl_processDecl(_$$0, pdecl))))))); })))))))); }))); }))); case "Instance": { const getFields = null; const tenv = null; const mkRHS = null; const apply = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Instance ")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(_$$1.h1))))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const tyFC = Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$1.h1); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), _$$1.h1, Lib_Types_VU(_$$1.h0)), ( vty ) => { const sc$$14 = Lib_Util_splitTele(vty); const env = Lib_ProcessDecl_processDecl_getFields_tenv(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, tenv, Prelude_length(null, sc$$14.h3)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("codomain ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), sc$$14.h2))))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("tele is ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Util_Prelude_Show$20Lib_Util_Binder))(sc$$14.h3)))(""))), ( _3 ) => { const instname = Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), sc$$14.h2)); const sigDecl = Lib_Syntax_TypeSig(_$$1.h0, Prelude__$3A$3A_(null, instname, Prelude_Nil(null)), _$$1.h1); const sc$$24 = Lib_TopContext_lookupRaw(instname, top); switch (sc$$24.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(_$$0, sigDecl), ( _4 ) => { const sc$$25 = Prelude__$3C$$$3E_(null, Prelude_Prelude_Functor$20Prelude_Maybe, null, null, Lib_Elab_collectDecl, _$$1.h2); switch (sc$$25.tag) { case "Just": { const sc$$28 = Lib_Util_funArgs(sc$$14.h2); const _sc$$0 = sc$$28.h2; switch (_sc$$0.tag) { case "Ref": { const sc$$35 = Lib_TopContext_lookup(_sc$$0.h1, top); switch (sc$$35.tag) { case "Just": { const _sc$$1 = sc$$35.h1; const _sc$$2 = _sc$$1.h3; switch (_sc$$2.tag) { case "TCon": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3.tag) { case "_::_": { const _sc$$4 = _sc$$3.h2; switch (_sc$$4.tag) { case "Nil": { const sc$$49 = Lib_TopContext_lookup(_sc$$3.h1, top); switch (sc$$49.tag) { case "Just": { const _sc$$5 = sc$$49.h1; const _sc$$6 = _sc$$5.h3; switch (_sc$$6.tag) { case "DCon": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$5.h2), ( $$sc ) => { switch ($$sc.tag) { case "VPi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dcty ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), _sc$$5.h2))))(""))), ( _5 ) => { const sc$$67 = Lib_Util_funArgs(sc$$14.h2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("traverse ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Types_showTm)(sc$$67.h3))))(""))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Eval_eval(env, Lib_Types_CBN, eta)))(sc$$67.h3), ( args$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("args' is ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(args$27)))(""))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS_apply(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, tenv, mkRHS, apply, $$sc, args$27), ( appty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl_getFields(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, appty, env, Prelude_Nil(null)), ( conTele ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, conTele, ( $$case ) => { const _sc$$7 = $$case.h2; switch (_sc$$7.tag) { case "Explicit": { const ty$27 = Prelude_foldr(null, null, ( x ) => (( acc ) => { const sc$$86 = Prelude_the(Lib_Util_Binder, x); return Lib_Types_Pi(sc$$86.h0, sc$$86.h1, sc$$86.h2, sc$$86.h3, sc$$86.h4, acc); }), $$case.h4, sc$$14.h3); const nm$27 = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(instname))(","))($$case.h1))(""); const sc$$86 = Prelude_find(null, ( x ) => { const sc$$87 = Prelude_the(Lib_Syntax_Decl, x); switch (sc$$87.tag) { case "Def": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(sc$$87.h1)($$case.h1); default: return Prelude_False; } }, sc$$25.h1); switch (sc$$86.tag) { case "Just": { const _sc$$8 = sc$$86.h1; switch (_sc$$8.tag) { case "Def": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_TopContext_setDef(Lib_Common_QN(_$$0, nm$27), _sc$$8.h0, ty$27, Lib_Types_Axiom), ( _8 ) => { const decl = Lib_Syntax_Def(_sc$$8.h0, nm$27, _sc$$8.h2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _9 ) => ("***")), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _10 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("«")(nm$27))("» : "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), ty$27))))(""))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _11 ) => (Lib_Prettier_render(80, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _11 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, decl)))))))); }); default: return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no definition for ")($$case.h1))("")); } break; } default: return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no definition for ")($$case.h1))("")); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }), ( defs ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), defs), ( decl ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => (Lib_Prettier_render(80, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _8 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))), ( _8 ) => { const _sc$$7 = _sc$$3.h1; const decl = Lib_Syntax_Def(_$$1.h0, instname, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Lib_Syntax_RVar(_$$1.h0, instname), Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, tenv, mkRHS, instname, conTele, Lib_Syntax_RVar(_$$1.h0, _sc$$7.h1))), Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _9 ) => ("SIGDECL")), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _10 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(sigDecl))))(""))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _11 ) => (Lib_Prettier_render(80, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _11 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))))); }))))))))))))); }); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)($$sc), "dcty not Pi"); } }); default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("can't find constructor ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$3.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("can't find constructor ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$3.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" has multiple constructors "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_sc$$2.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" has multiple constructors "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_sc$$2.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" is not a type constructor")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" is not a type constructor")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), sc$$14.h2))))(" doesn't appear to be a TCon application")); } break; } default: return Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Forward declaration ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl)(sigDecl)))(""))); } }); case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit), ( _4 ) => { const sc$$25 = Prelude__$3C$$$3E_(null, Prelude_Prelude_Functor$20Prelude_Maybe, null, null, Lib_Elab_collectDecl, _$$1.h2); switch (sc$$25.tag) { case "Just": { const sc$$28 = Lib_Util_funArgs(sc$$14.h2); const _sc$$0 = sc$$28.h2; switch (_sc$$0.tag) { case "Ref": { const sc$$35 = Lib_TopContext_lookup(_sc$$0.h1, top); switch (sc$$35.tag) { case "Just": { const _sc$$1 = sc$$35.h1; const _sc$$2 = _sc$$1.h3; switch (_sc$$2.tag) { case "TCon": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3.tag) { case "_::_": { const _sc$$4 = _sc$$3.h2; switch (_sc$$4.tag) { case "Nil": { const sc$$49 = Lib_TopContext_lookup(_sc$$3.h1, top); switch (sc$$49.tag) { case "Just": { const _sc$$5 = sc$$49.h1; const _sc$$6 = _sc$$5.h3; switch (_sc$$6.tag) { case "DCon": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$5.h2), ( $$sc ) => { switch ($$sc.tag) { case "VPi": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dcty ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), _sc$$5.h2))))(""))), ( _5 ) => { const sc$$67 = Lib_Util_funArgs(sc$$14.h2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("traverse ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(Lib_Types_showTm)(sc$$67.h3))))(""))), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_Eval_eval(env, Lib_Types_CBN, eta)))(sc$$67.h3), ( args$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("args' is ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Types_Prelude_Show$20Lib_Types_Val))(args$27)))(""))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS_apply(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, tenv, mkRHS, apply, $$sc, args$27), ( appty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl_getFields(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, appty, env, Prelude_Nil(null)), ( conTele ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, conTele, ( $$case ) => { const _sc$$7 = $$case.h2; switch (_sc$$7.tag) { case "Explicit": { const ty$27 = Prelude_foldr(null, null, ( x ) => (( acc ) => { const sc$$86 = Prelude_the(Lib_Util_Binder, x); return Lib_Types_Pi(sc$$86.h0, sc$$86.h1, sc$$86.h2, sc$$86.h3, sc$$86.h4, acc); }), $$case.h4, sc$$14.h3); const nm$27 = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(instname))(","))($$case.h1))(""); const sc$$86 = Prelude_find(null, ( x ) => { const sc$$87 = Prelude_the(Lib_Syntax_Decl, x); switch (sc$$87.tag) { case "Def": return Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(sc$$87.h1)($$case.h1); default: return Prelude_False; } }, sc$$25.h1); switch (sc$$86.tag) { case "Just": { const _sc$$8 = sc$$86.h1; switch (_sc$$8.tag) { case "Def": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_TopContext_setDef(Lib_Common_QN(_$$0, nm$27), _sc$$8.h0, ty$27, Lib_Types_Axiom), ( _8 ) => { const decl = Lib_Syntax_Def(_sc$$8.h0, nm$27, _sc$$8.h2); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _9 ) => ("***")), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _10 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("«")(nm$27))("» : "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), ty$27))))(""))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _11 ) => (Lib_Prettier_render(80, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _11 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Just(null, decl)))))))); }); default: return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no definition for ")($$case.h1))("")); } break; } default: return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("no definition for ")($$case.h1))("")); } break; } default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_Nothing(null)); } }), ( defs ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, Prelude_mapMaybe(null, null, ( eta ) => (Prelude_id(null, eta)), defs), ( decl ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _8 ) => (Lib_Prettier_render(80, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _8 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))), ( _8 ) => { const _sc$$7 = _sc$$3.h1; const decl = Lib_Syntax_Def(_$$1.h0, instname, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Lib_Syntax_RVar(_$$1.h0, instname), Lib_ProcessDecl_processDecl_getFields_tenv_mkRHS(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, getFields, tenv, mkRHS, instname, conTele, Lib_Syntax_RVar(_$$1.h0, _sc$$7.h1))), Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _9 ) => ("SIGDECL")), ( _9 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _10 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(sigDecl))))(""))), ( _10 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _11 ) => (Lib_Prettier_render(80, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _11 ) => (Lib_ProcessDecl_processDecl(_$$0, decl))))))); }))))))))))))); }); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Val)($$sc), "dcty not Pi"); } }); default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("can't find constructor ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$3.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("can't find constructor ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$3.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" has multiple constructors "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_sc$$2.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" has multiple constructors "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(_sc$$2.h1)))("")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" is not a type constructor")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_QName)(_sc$$0.h1)))(" is not a type constructor")); } break; } default: return Lib_Types_error(null, tyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), sc$$14.h2))))(" doesn't appear to be a TCon application")); } break; } default: return Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Forward declaration ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Decl)(sigDecl)))(""))); } }); } }))); }); }))))); break; } case "Class": { const makeLHS = null; const mkAutoApp = null; const mkPi = null; const mkApp = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Class ")(_$$1.h1))(""))), ( _1 ) => { const fields = Lib_ProcessDecl_getSigs(_$$1.h3); const dcName = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Mk")(_$$1.h1))(""); const tcType = Lib_ProcessDecl_teleToPi(_$$1.h2, Lib_Syntax_RU(_$$1.h0)); const tail = Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_ProcessDecl_processDecl_makeLHS_mkAutoApp_mkPi_mkApp(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, makeLHS, mkAutoApp, mkPi, mkApp, eta, eta1))), Lib_Syntax_RVar(_$$1.h0, _$$1.h1), _$$1.h2); const dcType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$1.h2), Prelude_foldr(null, null, ( eta ) => (( eta1 ) => (Lib_ProcessDecl_processDecl_makeLHS_mkAutoApp_mkPi(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, makeLHS, mkAutoApp, mkPi, eta, eta1))), tail, fields)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("tcon type ")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(tcType))))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dcon type ")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(dcType))))(""))), ( _3 ) => { const decl = Lib_Syntax_Data(_$$1.h0, _$$1.h1, tcType, Prelude__$3A$3A_(null, Lib_Syntax_TypeSig(_$$1.h0, Prelude__$3A$3A_(null, dcName, Prelude_Nil(null)), dcType), Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _4 ) => ("Decl:")), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _5 ) => (Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl)))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(_$$0, decl), ( _6 ) => (Prelude_ignore(null, null, Lib_Types_Prelude_Functor$20Lib_Types_M)(Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, fields, ( $$case ) => { const _sc$$0 = $$case.h3; const funType = Lib_ProcessDecl_teleToPi(Lib_ProcessDecl_impTele(_$$1.h2), Lib_Syntax_RPi($$case.h2, Lib_Types_BI($$case.h2, "_", Lib_Types_Auto, Lib_Types_Many), tail, _sc$$0.h3)); const autoPat = Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_ProcessDecl_processDecl_makeLHS_mkAutoApp(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, makeLHS, mkAutoApp, eta, eta1))), Lib_Syntax_RVar(_$$1.h0, dcName), fields); const lhs = Lib_ProcessDecl_processDecl_makeLHS(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, makeLHS, Lib_Syntax_RVar($$case.h2, _sc$$0.h2), _$$1.h2); const lhs1 = Lib_Syntax_RApp(_$$1.h0, lhs, autoPat, Lib_Types_Auto); const decl1 = Lib_Syntax_Def($$case.h2, _sc$$0.h2, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, lhs1, Lib_Syntax_RVar($$case.h2, _sc$$0.h2)), Prelude_Nil(null))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _7 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_sc$$0.h2))(" : "))(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Raw)(funType))))(""))), ( _7 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _8 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(decl1))))(""))), ( _8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(_$$0, Lib_Syntax_TypeSig($$case.h2, Prelude__$3A$3A_(null, _sc$$0.h2, Prelude_Nil(null)), funType)), ( _9 ) => (Lib_ProcessDecl_processDecl(_$$0, decl1))))))); })))))))); }))); }))); break; } case "PMixFix": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "PFunc": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), _$$1.h3, Lib_Types_VU(_$$1.h0)), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_nf(Prelude_Nil(null), ty), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("pfunc ")(_$$1.h1))(" : "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), ty$27))))(" = "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$1.h4)))(""))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h2, ( name ) => { const sc$$12 = Lib_TopContext_lookupRaw(name, top); switch (sc$$12.tag) { case "Nothing": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(name))(" not in scope")); case "Just": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Lib_Types__name(sc$$12.h1)); } }), ( used$27 ) => { const arity = Lib_Util_piArity(ty$27); return Lib_TopContext_setDef(Lib_Common_QN(_$$0, _$$1.h1), _$$1.h0, ty$27, Lib_Types_PrimFn(_$$1.h4, arity, used$27)); }))))))))); case "PType": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), Prelude_maybe(null, null, Lib_Syntax_RU(_$$1.h0), ( eta ) => (Prelude_id(null, eta)), _$$1.h2), Lib_Types_VU(_$$1.h0)), ( ty$27 ) => { const arity = Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(Lib_Util_piArity(ty$27)); return Lib_TopContext_setDef(Lib_Common_QN(_$$0, _$$1.h1), _$$1.h0, ty$27, Lib_Types_PrimTCon(arity)); }))); case "ShortData": { const mkPi = null; const getArgs = null; const mkDecl = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl_mkPi_getArgs(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, mkPi, getArgs, _$$1.h1, Prelude_Nil(null)), ( $$sc ) => { const ty = Prelude_foldr(null, null, ( eta ) => (( eta1 ) => (Lib_ProcessDecl_processDecl_mkPi(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, mkPi, eta, eta1))), Lib_Syntax_RU(_$$1.h0), $$sc.h3); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Lib_ProcessDecl_processDecl_mkPi_getArgs_mkDecl(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, mkPi, getArgs, mkDecl, $$sc.h3, Prelude_Nil(null), eta)))(_$$1.h2), ( cons ) => { const dataDecl = Lib_Syntax_Data(_$$1.h0, $$sc.h2, ty, cons); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("SHORTDATA")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Lib_Prettier_render(90, Lib_Prettier_pretty(null, Lib_Syntax_Lib_Prettier_Pretty$20Lib_Syntax_Decl)(dataDecl))))(""))), ( _1 ) => (Lib_ProcessDecl_processDecl(_$$0, dataDecl))))); }); }); break; } case "Data": { const binderName = null; const checkDeclType = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Data ")(_$$1.h1))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), _$$1.h2, Lib_Types_VU(_$$1.h0)), ( tyty ) => { const sc$$13 = Lib_TopContext_lookupRaw(_$$1.h1, top); switch (sc$$13.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_TopContext_setDef(Lib_Common_QN(_$$0, _$$1.h1), _$$1.h0, tyty, Lib_Types_Axiom), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h3, ( x ) => { switch (x.tag) { case "TypeSig": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("check dcon ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(x.h1)))(" "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(x.h2)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(x.h0), x.h2, Lib_Types_VU(x.h0)), ( dty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dty ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(x.h1)))(" is "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), dty))))(""))), ( _4 ) => { const sc$$22 = Lib_Util_splitTele(dty); const tnames = Prelude_reverse(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_ProcessDecl_processDecl_binderName(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, binderName, eta)))(sc$$22.h3)); const sc$$28 = Lib_Util_funArgs(sc$$22.h2); const _sc$$0 = sc$$28.h2; switch (_sc$$0.tag) { case "Ref": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _sc$$0.h1, Lib_Common_QN(_$$0, _$$1.h1)), ( _5 ) => (Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(sc$$22.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Constructor codomain is ")(Lib_Prettier_render(90, Lib_Types_pprint(tnames, sc$$22.h2))))(" rather than "))(_$$1.h1))("")))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, x.h1, ( nm$27 ) => (Lib_TopContext_setDef(Lib_Common_QN(_$$0, nm$27), x.h0, dty, Lib_Types_DCon(Lib_Elab_getArity(dty), _sc$$0.h1)))), ( _6 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Common_QN(_$$0, eta)))(x.h1)))))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(sc$$28.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$1.h1))(" got "))(Lib_Prettier_render(90, Lib_Types_pprint(tnames, sc$$28.h2))))("")); } }))))); default: return Lib_Types_throwError(null, Lib_Common_E(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(x), "expected constructor declaration")); } }), ( cnames ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("setDef ")(_$$1.h1))("  TCon "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, cnames))))(""))), ( _3 ) => { const arity = Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(Lib_Util_piArity(tyty)); return Lib_TopContext_updateDef(Lib_Common_QN(_$$0, _$$1.h1), _$$1.h0, tyty, Lib_Types_TCon(arity, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, cnames))); }))))); case "Just": { const _sc$$0 = sc$$13.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Axiom": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, tyty), ( tyty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$0.h2), ( type$27 ) => (Lib_Elab_unifyCatch(_$$1.h0, Lib_Types_mkCtx(_$$1.h0), tyty$27, type$27))))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h3, ( x ) => { switch (x.tag) { case "TypeSig": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("check dcon ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(x.h1)))(" "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(x.h2)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(x.h0), x.h2, Lib_Types_VU(x.h0)), ( dty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dty ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(x.h1)))(" is "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), dty))))(""))), ( _4 ) => { const sc$$22 = Lib_Util_splitTele(dty); const tnames = Prelude_reverse(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_ProcessDecl_processDecl_binderName(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, binderName, eta)))(sc$$22.h3)); const sc$$28 = Lib_Util_funArgs(sc$$22.h2); const _sc$$0 = sc$$28.h2; switch (_sc$$0.tag) { case "Ref": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _sc$$0.h1, Lib_Common_QN(_$$0, _$$1.h1)), ( _5 ) => (Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(sc$$22.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Constructor codomain is ")(Lib_Prettier_render(90, Lib_Types_pprint(tnames, sc$$22.h2))))(" rather than "))(_$$1.h1))("")))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, x.h1, ( nm$27 ) => (Lib_TopContext_setDef(Lib_Common_QN(_$$0, nm$27), x.h0, dty, Lib_Types_DCon(Lib_Elab_getArity(dty), _sc$$0.h1)))), ( _6 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Common_QN(_$$0, eta)))(x.h1)))))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(sc$$28.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$1.h1))(" got "))(Lib_Prettier_render(90, Lib_Types_pprint(tnames, sc$$28.h2))))("")); } }))))); default: return Lib_Types_throwError(null, Lib_Common_E(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(x), "expected constructor declaration")); } }), ( cnames ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("setDef ")(_$$1.h1))("  TCon "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, cnames))))(""))), ( _3 ) => { const arity = Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(Lib_Util_piArity(tyty)); return Lib_TopContext_updateDef(Lib_Common_QN(_$$0, _$$1.h1), _$$1.h0, tyty, Lib_Types_TCon(arity, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, cnames))); }))))); default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$1.h1)))(" already declared")), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h3, ( x ) => { switch (x.tag) { case "TypeSig": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("check dcon ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(x.h1)))(" "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(x.h2)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(x.h0), x.h2, Lib_Types_VU(x.h0)), ( dty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _4 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("dty ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(x.h1)))(" is "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), dty))))(""))), ( _4 ) => { const sc$$22 = Lib_Util_splitTele(dty); const tnames = Prelude_reverse(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_ProcessDecl_processDecl_binderName(_$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, _$$1.h3, binderName, eta)))(sc$$22.h3)); const sc$$28 = Lib_Util_funArgs(sc$$22.h2); const _sc$$0 = sc$$28.h2; switch (_sc$$0.tag) { case "Ref": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$2F$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName, _sc$$0.h1, Lib_Common_QN(_$$0, _$$1.h1)), ( _5 ) => (Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(sc$$22.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Constructor codomain is ")(Lib_Prettier_render(90, Lib_Types_pprint(tnames, sc$$22.h2))))(" rather than "))(_$$1.h1))("")))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, x.h1, ( nm$27 ) => (Lib_TopContext_setDef(Lib_Common_QN(_$$0, nm$27), x.h0, dty, Lib_Types_DCon(Lib_Elab_getArity(dty), _sc$$0.h1)))), ( _6 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Common_QN(_$$0, eta)))(x.h1)))))); default: return Lib_Types_error(null, Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_Tm)(sc$$28.h2), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$1.h1))(" got "))(Lib_Prettier_render(90, Lib_Types_pprint(tnames, sc$$28.h2))))("")); } }))))); default: return Lib_Types_throwError(null, Lib_Common_E(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Decl)(x), "expected constructor declaration")); } }), ( cnames ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("setDef ")(_$$1.h1))("  TCon "))(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Lib_Common_Prelude_Show$20Lib_Common_QName))(Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, cnames))))(""))), ( _3 ) => { const arity = Prelude_cast(null, null, Prelude_Prelude_Cast$20Prelude_Nat$20Prim_Int)(Lib_Util_piArity(tyty)); return Lib_TopContext_updateDef(Lib_Common_QN(_$$0, _$$1.h1), _$$1.h0, tyty, Lib_Types_TCon(arity, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, cnames))); }))))); } break; } } }))))))))); break; } case "DCheck": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("----- DCheck")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_info(_$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("check ")(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$1.h1)))(" at "))(Prelude_show(null, Lib_Syntax_Prelude_Show$20Lib_Syntax_Raw)(_$$1.h2)))("")), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), _$$1.h2, Lib_Types_VU(_$$1.h0)), ( ty$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  got type ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), ty$27))))("")), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, ty$27), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), _$$1.h1, vty), ( res ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  got ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), res))))("")), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_nf(Prelude_Nil(null), res), ( norm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  NF ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), norm))))("")), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_nfv(Prelude_Nil(null), res), ( norm1 ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("  NFV ")(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), norm1))))("")))))))))))))))))))))))); case "Def": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Def ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$1.h1)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => { const sc$$9 = Lib_TopContext_lookupRaw(_$$1.h1, top); switch (sc$$9.tag) { case "Nothing": return Lib_Types_throwError(null, Lib_Common_E(_$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("No declaration for ")(_$$1.h1))(""))); case "Just": { const _sc$$0 = sc$$9.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Axiom": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("check ")(_$$1.h1))(" at "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), _sc$$0.h2))))(""))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_eval(Prelude_Nil(null), Lib_Types_CBN, _sc$$0.h2), ( vty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$1.h1))(" vty is "))(Prelude_show(null, Lib_Types_Prelude_Show$20Lib_Types_Val)(vty)))(""))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(Lib_Elab_makeClause)(_$$1.h2), ( clauses$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_buildTree(Lib_Types_mkCtx(_sc$$0.h0), Lib_Elab_MkProb(clauses$27, vty)), ( tm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_solveAutos, ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_zonk(top, 0, Prelude_Nil(null), tm), ( tm$27 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _5 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("NF\n")(Lib_Prettier_render(80, Lib_Types_pprint(Prelude_Nil(null), tm$27))))(""))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_debug(( _6 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Add def ")(_$$1.h1))(" "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), tm$27))))(" : "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), _sc$$0.h2))))(""))), ( _6 ) => (Lib_TopContext_updateDef(Lib_Common_QN(_$$0, _$$1.h1), _sc$$0.h0, _sc$$0.h2, Lib_Types_Fn(tm$27)))))))))))))))))))))); default: return Lib_Types_throwError(null, Lib_Common_E(_$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$1.h1))(" already defined at "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(Lib_Types__fc(sc$$9.h1))))(""))); } break; } } }))))))); case "TypeSig": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _ ) => ("-----")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top)), ( mc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h1, ( nm ) => { const sc$$9 = Lib_TopContext_lookupRaw(nm, top); switch (sc$$9.tag) { case "Nothing": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "Just": return Lib_Types_error(null, _$$1.h0, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(nm)))(" is already defined at "))(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(Lib_Types__fc(sc$$9.h1))))("")); } }), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Elab_check(Lib_Types_mkCtx(_$$1.h0), _$$1.h2, Lib_Types_VU(_$$1.h0)), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Eval_zonk(top, 0, Prelude_Nil(null), ty), ( ty1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _2 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TypeSig ")(Data_String_unwords(_$$1.h1)))(" : "))(Lib_Prettier_render(90, Lib_Types_pprint(Prelude_Nil(null), ty1))))(""))), ( _2 ) => (Prelude_ignore(null, null, Lib_Types_Prelude_Functor$20Lib_Types_M)(Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _$$1.h1, ( nm ) => (Lib_TopContext_setDef(Lib_Common_QN(_$$0, nm), _$$1.h0, ty1, Lib_Types_Axiom)))))))))))))))))); } };
const Main_processModule_tryProcessDecl = ( _, _1, _2, _3, _4, _5, _6, _$$7, _$$8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_tryError(null, Lib_ProcessDecl_processDecl(_$$7, _$$8)), ( $$sc ) => { switch ($$sc.tag) { case "Left": return Lib_TopContext_addError($$sc.h2); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); } }));
const Lib_Token__bounds = ( ty$$0, _$$1 ) => (_$$1.h2);
const Lib_Token_Prelude_Eq$20Lib_Token_Bounds$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude__$26$26_(Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$0.h0)(_$$1.h0), Prelude__$26$26_(Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$0.h1)(_$$1.h1), Prelude__$26$26_(Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$0.h2)(_$$1.h2), Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(_$$0.h3)(_$$1.h3)))));
const Lib_Token_Prelude_Eq$20Lib_Token_Bounds = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Lib_Token_Prelude_Eq$20Lib_Token_Bounds$2C_$3D$3D_(eta, eta1))));
const Lib_Token__startCol = ( _$$0 ) => (_$$0.h1);
const Main_parseDecls_recover = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8 ) => { switch (_$$8.tag) { case "_::_": { const sc$$12 = Prelude__$26$26_(Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(Lib_Token__startCol(Lib_Token__bounds(null, _$$8.h1)))(0), Prelude__$2F$3D_(null, Lib_Token_Prelude_Eq$20Lib_Token_Bounds, Lib_Token__bounds(null, _$$8.h1), Lib_Token__bounds(null, _5))); switch (sc$$12.tag) { case "False": return Main_parseDecls_recover(_, _1, _2, _3, _4, _5, _6, _7, _$$8.h2); case "True": return Prelude__$3A$3A_(null, _$$8.h1, _$$8.h2); } break; } case "Nil": return Prelude_Nil(null); } };
const Lib_Syntax_Record = ( h0, h1, h2, h3, h4 ) => ({ tag: "Record",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Parser_Impl_OK = ( h0, h1, h2, h3, h4 ) => ({ tag: "OK",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Parser_Impl_Fail = ( h0, h1, h2, h3, h4, h5 ) => ({ tag: "Fail",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4,  h5: h5 });
const Lib_Parser_Impl_P = ( h0, h1 ) => ({ tag: "P",  h0: h0,  h1: h1 });
const Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_ = ( a$$0, b$$1, _$$2, _$$3 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => { const sc$$12 = _$$2.h1(toks)(com)(ops)(col); switch (sc$$12.tag) { case "Fail": return Lib_Parser_Impl_Fail(null, sc$$12.h1, sc$$12.h2, sc$$12.h3, sc$$12.h4, sc$$12.h5); case "OK": { const sc$$18 = _$$3.h1(sc$$12.h2)(sc$$12.h3)(sc$$12.h4)(col); switch (sc$$18.tag) { case "Fail": return Lib_Parser_Impl_Fail(null, sc$$18.h1, sc$$18.h2, sc$$18.h3, sc$$18.h4, sc$$18.h5); case "OK": return Lib_Parser_Impl_OK(null, sc$$12.h1(sc$$18.h1), sc$$18.h2, sc$$18.h3, sc$$18.h4); } break; } } })))));
const Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn = ( a$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_OK(null, _$$1, toks, com, ops)))))));
const Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser = Prelude_MkApplicative(null, ( a ) => (( eta ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2Creturn(null, eta))), ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser$2C_$3C$2A$3E_(null, null, eta, eta1))))));
const Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cpure = ( a ) => (Prelude_return(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null));
const Lib_Parser_Impl_runP = ( a$$0, _$$1 ) => (_$$1.h1);
const Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind = ( a$$0, b$$1, _$$2, _$$3 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => { const sc$$10 = _$$2.h1(toks)(com)(ops)(col); switch (sc$$10.tag) { case "Fail": return Lib_Parser_Impl_Fail(null, sc$$10.h1, sc$$10.h2, sc$$10.h3, sc$$10.h4, sc$$10.h5); case "OK": return Lib_Parser_Impl_runP(null, _$$3(sc$$10.h1))(sc$$10.h2)(sc$$10.h3)(sc$$10.h4)(col); } })))));
const Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser = Prelude_MkMonad(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cbind(null, null, eta, eta1))))), ( a ) => (Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser$2Cpure(null)));
const Lib_Token_Number = { tag: "Number" };
const Lib_Token__val = ( ty$$0, _$$1 ) => (_$$1.h1);
const Lib_Token__kind = ( _$$0 ) => (_$$0.h0);
const Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow = ( _$$0 ) => { switch (_$$0.tag) { case "EndInterp": return "EndInterp"; case "StartInterp": return "StartInterp"; case "EndQuote": return "EndQuote"; case "StartQuote": return "StartQuote"; case "EOI": return "EOI"; case "RBrace": return "RBrace"; case "Semi": return "Semi"; case "LBrace": return "LBrace"; case "Projection": return "Projection"; case "Pragma": return "Pragma"; case "Comment": return "Comment"; case "Space": return "Space"; case "Symbol": return "Symbol"; case "JSLit": return "JSLit"; case "StringKind": return "String"; case "Character": return "Character"; case "Number": return "Number"; case "MixFix": return "MixFix"; case "Keyword": return "Keyword"; case "UIdent": return "UIdent"; case "Ident": return "Ident"; } };
const Lib_Token_Prelude_Show$20Lib_Token_Kind = Prelude_MkShow(null, Lib_Token_Prelude_Show$20Lib_Token_Kind$2Cshow);
const Lib_Token_Prelude_Eq$20Lib_Token_Kind$2C_$3D$3D_ = ( _$$0, _$$1 ) => (Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(Prelude_show(null, Lib_Token_Prelude_Show$20Lib_Token_Kind)(_$$0))(Prelude_show(null, Lib_Token_Prelude_Show$20Lib_Token_Kind)(_$$1)));
const Lib_Token_Prelude_Eq$20Lib_Token_Kind = Prelude_MkEq(null, ( eta ) => (( eta1 ) => (Lib_Token_Prelude_Eq$20Lib_Token_Kind$2C_$3D$3D_(eta, eta1))));
const Lib_Token_Symbol = { tag: "Symbol" };
const Lib_Token_Keyword = { tag: "Keyword" };
const Lib_Token__text = ( _$$0 ) => (_$$0.h1);
const Lib_Parser_Impl_perror = ( _$$0, _$$1, _$$2 ) => { switch (_$$1.tag) { case "_::_": { const _sc$$0 = _$$1.h1; const _sc$$1 = _sc$$0.h2; return Lib_Common_E(Lib_Common_MkFC(_$$0, Prelude__$2C_(null, null, _sc$$1.h0, _sc$$1.h1)), _$$2); break; } case "Nil": return Lib_Common_E(Lib_Common_MkFC(_$$0, Prelude__$2C_(null, null, 0, 0)), _$$2); } };
const Lib_Token_value = ( _$$0 ) => { const _sc$$0 = _$$0.h1; return _sc$$0.h1; };
const Lib_Parser_Impl_satisfy = ( _$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => { switch (toks.tag) { case "_::_": { const sc$$10 = _$$0(toks.h1); switch (sc$$10.tag) { case "False": return Lib_Parser_Impl_Fail(null, Prelude_False, Lib_Parser_Impl_perror(Lib_Common__file(col), toks, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$1))(" at "))(Prelude_show(null, Lib_Token_Prelude_Show$20Lib_Token_Kind)(Lib_Token__kind(Lib_Token__val(null, toks.h1)))))(":"))(Lib_Token_value(toks.h1)))("")), toks, com, ops); case "True": return Lib_Parser_Impl_OK(null, Lib_Token_value(toks.h1), toks.h2, Prelude_True, ops); } break; } case "Nil": return Lib_Parser_Impl_Fail(null, Prelude_False, Lib_Parser_Impl_perror(Lib_Common__file(col), toks, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(_$$1))(" at EOF")), toks, com, ops); } })))));
const Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Result$2Cmap = ( a$$0, b$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "Fail": return Lib_Parser_Impl_Fail(null, _$$3.h1, _$$3.h2, _$$3.h3, _$$3.h4, _$$3.h5); case "OK": return Lib_Parser_Impl_OK(null, _$$2(_$$3.h1), _$$3.h2, _$$3.h3, _$$3.h4); } };
const Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Result = Prelude_MkFunctor(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Result$2Cmap(null, null, eta, eta1))))));
const Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap = ( a$$0, b$$1, _$$2, _$$3 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => (Prelude_map(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Result)(null)(null)(_$$2)(_$$3.h1(toks)(com)(ops)(col))))))));
const Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser = Prelude_MkFunctor(null, ( a ) => (( b ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser$2Cmap(null, null, eta, eta1))))));
const Lib_Parser_Impl_keyword$27 = ( _$$0 ) => (Prelude_ignore(null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser)(Lib_Parser_Impl_satisfy(( t ) => (Prelude__$26$26_(Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(Lib_Token__text(Lib_Token__val(null, t)))(_$$0), Prelude__$7C$7C_(Prelude__$3D$3D_(null, Lib_Token_Prelude_Eq$20Lib_Token_Kind)(Lib_Token__kind(Lib_Token__val(null, t)))(Lib_Token_Keyword), Prelude__$7C$7C_(Prelude__$3D$3D_(null, Lib_Token_Prelude_Eq$20Lib_Token_Kind)(Lib_Token__kind(Lib_Token__val(null, t)))(Lib_Token_Symbol), Prelude__$3D$3D_(null, Lib_Token_Prelude_Eq$20Lib_Token_Kind)(Lib_Token__kind(Lib_Token__val(null, t)))(Lib_Token_Number))))), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected ")(_$$0))(""))));
const Lib_Token_getStart = ( _$$0 ) => { const _sc$$0 = _$$0.h2; return Prelude__$2C_(null, null, _sc$$0.h0, _sc$$0.h1); };
const Lib_Parser_Impl_indented = ( a$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( indent ) => { switch (toks.tag) { case "_::_": { const sc$$12 = Lib_Token_getStart(toks.h1); const sc$$17 = Prelude__$7C$7C_(Prelude__$3E_(null, Prelude_Prelude_Ord$20Prim_Int, sc$$12.h3, Lib_Common_fcCol(indent)), Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(sc$$12.h2)(Lib_Common_fcLine(indent))); switch (sc$$17.tag) { case "False": return Lib_Parser_Impl_Fail(null, Prelude_False, Lib_Parser_Impl_perror(Lib_Common__file(indent), toks, "unexpected outdent"), toks, com, ops); case "True": return _$$1.h1(toks)(com)(ops)(indent); } break; } case "Nil": return _$$1.h1(toks)(com)(ops)(indent); } })))));
const Lib_Parser_Impl_keyword = ( _$$0 ) => (Lib_Parser_Impl_indented(null, Lib_Parser_Impl_keyword$27(_$$0)));
const Lib_Parser_Impl_symbol = Lib_Parser_Impl_keyword;
const Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_ = ( a$$0, _$$1, _$$2 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => { const sc$$11 = _$$1.h1(toks)(Prelude_False)(ops)(col); switch (sc$$11.tag) { case "Fail": { const _sc$$0 = sc$$11.h1; switch (_sc$$0.tag) { case "True": return Lib_Parser_Impl_Fail(null, Prelude_True, sc$$11.h2, sc$$11.h3, sc$$11.h4, sc$$11.h5); default: { const _sc$$1 = sc$$11.h4; switch (_sc$$1.tag) { case "False": return _$$2.h1(toks)(com)(sc$$11.h5)(col); case "True": return Lib_Parser_Impl_Fail(null, sc$$11.h1, sc$$11.h2, sc$$11.h3, Prelude_True, sc$$11.h5); } break; } } break; } case "OK": return Lib_Parser_Impl_OK(null, sc$$11.h1, sc$$11.h2, com, sc$$11.h4); } })))));
const Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser = Prelude_MkAlternative(null, ( a ) => (( eta ) => (( eta1 ) => (Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser$2C_$3C$7C$3E_(null, eta, eta1)))));
const Lib_Parser_arrow = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_Impl_symbol("->"))(Lib_Parser_Impl_symbol("→"));
const Prelude__$2A$3E_ = ( f$$0, a$$1, b$$2, _$$3, _$$4, _$$5, _$$6 ) => (Prelude__$3C$2A$3E_(null, _$$4)(null)(null)(Prelude_map(null, _$$3)(null)(null)(( eta ) => (Prelude_const(null, null, ( eta ) => (Prelude_id(null, eta)), eta)))(_$$5))(_$$6));
const Lib_Parser_optional = ( a$$0, _$$1 ) => (Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (Prelude_Just(null, eta)), _$$1))(Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_Nothing(null))));
const Lib_Parser_term_apply = ( _, _$$1, _$$2 ) => { switch (_$$2.tag) { case "_::_": { const _sc$$0 = _$$2.h1; return Lib_Syntax_RApp(_sc$$0.h2, _$$1, Lib_Parser_term_apply(_, _sc$$0.h3, _$$2.h2), Lib_Types_Explicit); break; } case "Nil": return _$$1; } };
const Lib_Parser_Impl_fail = ( a$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_Fail(null, Prelude_False, Lib_Parser_Impl_perror(Lib_Common__file(col), toks, _$$1), toks, com, ops)))))));
const Lib_Parser_pratt_projectHead_runProject_runRule = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10, _$$11, _$$12, _$$13 ) => { switch (_$$11.tag) { case "_::_": { const _sc$$0 = _$$11.h1; switch (_sc$$0) { case "": { const _sc$$1 = _$$11.h2; switch (_sc$$1.tag) { case "Nil": { let pr; switch (_$$9.tag) { case "InfixR": { pr = _$$8; break; } default: { pr = Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$8)(1); break; } } switch (_$$13.tag) { case "_::_": { const _sc$$2 = _$$13.h1; const _sc$$3 = _sc$$2.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_pratt(_, pr, _$$10, _sc$$3.h3, _$$13.h2), ( $$sc ) => (Lib_Parser_pratt(_, _1, _$$10, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$12), _$$12, $$sc.h2, Lib_Types_Explicit), $$sc.h3))); break; } default: return Lib_Parser_Impl_fail(null, "trailing operator"); } break; } default: switch (_$$13.tag) { case "_::_": { const _sc$$2 = _$$13.h1; const _sc$$3 = _sc$$2.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_pratt(_, 0, _$$11.h1, _sc$$3.h3, _$$13.h2), ( $$sc ) => { const _sc$$4 = $$sc.h3; switch (_sc$$4.tag) { case "_::_": { const _sc$$5 = _sc$$4.h1; const _sc$$6 = _sc$$5.h3; const _sc$$7 = _sc$$6.h3; switch (_sc$$7.tag) { case "RVar": { const sc$$49 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$7.h1)(_$$11.h1); switch (sc$$49.tag) { case "False": return Lib_Parser_Impl_fail(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$11.h1))("")); case "True": return Lib_Parser_pratt_projectHead_runProject_runRule(_, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10, _$$11.h2, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$12), _$$12, $$sc.h2, Lib_Types_Explicit), _sc$$4.h2); } break; } default: return Lib_Parser_Impl_fail(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$11.h1))("")); } break; } default: return Lib_Parser_Impl_fail(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$11.h1))("")); } }); break; } case "Nil": return Lib_Parser_Impl_fail(null, "short"); } break; } break; } default: switch (_$$13.tag) { case "_::_": { const _sc$$1 = _$$13.h1; const _sc$$2 = _sc$$1.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_pratt(_, 0, _$$11.h1, _sc$$2.h3, _$$13.h2), ( $$sc ) => { const _sc$$3 = $$sc.h3; switch (_sc$$3.tag) { case "_::_": { const _sc$$4 = _sc$$3.h1; const _sc$$5 = _sc$$4.h3; const _sc$$6 = _sc$$5.h3; switch (_sc$$6.tag) { case "RVar": { const sc$$49 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$6.h1)(_$$11.h1); switch (sc$$49.tag) { case "False": return Lib_Parser_Impl_fail(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$11.h1))("")); case "True": return Lib_Parser_pratt_projectHead_runProject_runRule(_, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9, _$$10, _$$11.h2, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$12), _$$12, $$sc.h2, Lib_Types_Explicit), _sc$$3.h2); } break; } default: return Lib_Parser_Impl_fail(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$11.h1))("")); } break; } default: return Lib_Parser_Impl_fail(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("expected ")(_$$11.h1))("")); } }); break; } case "Nil": return Lib_Parser_Impl_fail(null, "short"); } break; } break; } case "Nil": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, _$$12, _$$13)); } };
const Prelude_isPrefixOf = (pfx, s) => s.startsWith(pfx) ? Prelude_True : Prelude_False
const Lib_Parser_pratt_projectHead_runProject = ( _, _1, _2, _3, _4, _5, _6, _$$7 ) => { switch (_$$7.tag) { case "_::_": { const _sc$$0 = _$$7.h1; const _sc$$1 = _sc$$0.h2; switch (_sc$$1.tag) { case "Explicit": { const _sc$$2 = _sc$$0.h3; const _sc$$3 = _$$7.h2; switch (_sc$$3.tag) { case "_::_": { const _sc$$4 = _sc$$3.h1; const _sc$$5 = _sc$$4.h2; switch (_sc$$5.tag) { case "Explicit": { const _sc$$6 = _sc$$4.h3; const _sc$$7 = _sc$$6.h3; switch (_sc$$7.tag) { case "RVar": { const sc$$32 = Prelude_isPrefixOf(".", _sc$$7.h1); switch (sc$$32.tag) { case "False": return Prelude__$3A$3A_(null, _$$7.h1, Prelude__$3A$3A_(null, _sc$$3.h1, _sc$$3.h2)); case "True": return Lib_Parser_pratt_projectHead_runProject(_, _1, _2, _3, _4, _5, _6, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Lib_Types_Explicit, Prelude__$2C_(null, null, _sc$$2.h2, Lib_Syntax_RApp(_sc$$7.h0, Lib_Syntax_RVar(_sc$$7.h0, _sc$$7.h1), _sc$$2.h3, Lib_Types_Explicit))), _sc$$3.h2)); } break; } default: return _$$7; } break; } default: return _$$7; } break; } default: return _$$7; } break; } default: return _$$7; } break; } default: return _$$7; } };
const Lib_Parser_pratt_projectHead = ( _, _1, _2, _3, _4, _5, _$$6, _$$7 ) => { switch (_$$7.tag) { case "_::_": { const _sc$$0 = _$$7.h1; const _sc$$1 = _sc$$0.h2; switch (_sc$$1.tag) { case "Explicit": { const _sc$$2 = _sc$$0.h3; const _sc$$3 = _sc$$2.h3; switch (_sc$$3.tag) { case "RVar": { const sc$$21 = Prelude_isPrefixOf(".", _sc$$3.h1); switch (sc$$21.tag) { case "False": return Prelude__$2C_(null, null, _$$6, _$$7); case "True": return Lib_Parser_pratt_projectHead(_, _1, _2, _3, _4, _5, Lib_Syntax_RApp(_sc$$3.h0, Lib_Syntax_RVar(_sc$$3.h0, _sc$$3.h1), _$$6, Lib_Types_Explicit), _$$7.h2); } break; } default: return Prelude__$2C_(null, null, _$$6, _$$7); } break; } default: return Prelude__$2C_(null, null, _$$6, _$$7); } break; } default: return Prelude__$2C_(null, null, _$$6, _$$7); } };
const Lib_Parser_pratt_projectHead_runProject_runRule_runPrefix = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$9, _$$10, _$$11 ) => { switch (_$$10.tag) { case "RVar": { const sc$$14 = Data_SortedMap_lookupMap$27(null, null, Prelude_Prelude_Ord$20Prim_String, _$$10.h1, _); switch (sc$$14.tag) { case "Just": { const _sc$$0 = sc$$14.h1; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "True": return Lib_Parser_pratt_projectHead_runProject_runRule(_, _1, _2, _3, _4, _5, _6, _7, _sc$$0.h1, _sc$$0.h2, _$$9, _sc$$0.h4, Lib_Syntax_RVar(_$$10.h0, _sc$$0.h0), _$$11); default: return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, _3, _$$11)); } break; } default: return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, _3, _$$11)); } break; } default: return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, _$$10, _$$11)); } };
const Lib_Parser_pratt = ( _$$0, _$$1, _$$2, _$$3, _$$4 ) => { const projectHead = null; const runProject = null; const runRule = null; const runPrefix = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_pratt_projectHead_runProject_runRule_runPrefix(_$$0, _$$1, _$$2, _$$3, _$$4, projectHead, runProject, runRule, runPrefix, _$$2, _$$3, _$$4), ( $$sc ) => { const sc$$15 = Lib_Parser_pratt_projectHead(_$$0, _$$1, _$$2, _$$3, _$$4, projectHead, $$sc.h2, $$sc.h3); const spine = Lib_Parser_pratt_projectHead_runProject(_$$0, _$$1, _$$2, _$$3, _$$4, projectHead, runProject, sc$$15.h3); switch (spine.tag) { case "_::_": { const _sc$$0 = spine.h1; const _sc$$1 = _sc$$0.h2; switch (_sc$$1.tag) { case "Explicit": { const _sc$$2 = _sc$$0.h3; const _sc$$3 = _sc$$2.h3; switch (_sc$$3.tag) { case "RVar": { const sc$$35 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_sc$$3.h1)(_$$2); switch (sc$$35.tag) { case "False": { const sc$$36 = Data_SortedMap_lookupMap$27(null, null, Prelude_Prelude_Ord$20Prim_String, _sc$$3.h1, _$$0); switch (sc$$36.tag) { case "Nothing": { const sc$$38 = Prelude_isPrefixOf(".", _sc$$3.h1); switch (sc$$38.tag) { case "False": return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$15.h2), sc$$15.h2, _sc$$2.h3, Lib_Types_Explicit), spine.h2); case "True": return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_sc$$2.h3), _sc$$2.h3, sc$$15.h2, Lib_Types_Explicit), spine.h2); } break; } case "Just": { const _sc$$4 = sc$$36.h1; const _sc$$5 = _sc$$4.h3; switch (_sc$$5.tag) { case "False": { const sc$$44 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _sc$$4.h1, _$$1); switch (sc$$44.tag) { case "False": return Lib_Parser_pratt_projectHead_runProject_runRule(_$$0, _$$1, _$$2, _$$3, _$$4, projectHead, runProject, runRule, _sc$$4.h1, _sc$$4.h2, _$$2, _sc$$4.h4, Lib_Syntax_RApp(_sc$$2.h2, Lib_Syntax_RVar(_sc$$2.h2, _sc$$4.h0), sc$$15.h2, Lib_Types_Explicit), spine.h2); case "True": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, sc$$15.h2, spine)); } break; } default: return Lib_Parser_Impl_fail(null, "expected operator"); } break; } } break; } case "True": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, sc$$15.h2, spine)); } break; } default: return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$15.h2), sc$$15.h2, _sc$$2.h3, _sc$$0.h2), spine.h2); } break; } default: { const _sc$$2 = _sc$$0.h3; return Lib_Parser_pratt(_$$0, _$$1, _$$2, Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(sc$$15.h2), sc$$15.h2, _sc$$2.h3, _sc$$0.h2), spine.h2); break; } } break; } case "Nil": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, sc$$15.h2, Prelude_Nil(null))); } }); };
const Lib_Parser_dbraces = ( a$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("{{"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, _$$1, ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("}}"), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(t))))))));
const Lib_Parser_braces = ( a$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("{"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, _$$1, ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("}"), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(t))))))));
const Lib_Parser_parenWrap = ( a$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("("), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, _$$1, ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(")"), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(t))))))));
const Lib_Parser_Impl_getPos = Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( indent ) => { switch (toks.tag) { case "_::_": return Lib_Parser_Impl_OK(null, Lib_Common_MkFC(Lib_Common__file(indent), Lib_Token_getStart(toks.h1)), toks, com, ops); case "Nil": return Lib_Parser_Impl_OK(null, Lib_Common_emptyFC, toks, com, ops); } }))));
const Lib_Syntax_RHole = ( h0 ) => ({ tag: "RHole",  h0: h0 });
const Prelude__$3C$2A_ = ( f$$0, a$$1, b$$2, _$$3, _$$4, _$$5 ) => (Prelude__$3C$2A$3E_(null, _$$3)(null)(null)(Prelude__$3C$2A$3E_(null, _$$3)(null)(null)(Prelude_return(null, _$$3)(null)(( eta ) => (( eta1 ) => (Prelude_const(null, null, eta, eta1)))))(_$$4))(_$$5));
const Prelude_strIndex = (s, ix) => s[ix]
const Lib_Syntax_RLit = ( h0, h1 ) => ({ tag: "RLit",  h0: h0,  h1: h1 });
const Lib_Token_Character = { tag: "Character" };
const Lib_Parser_Impl_token$27 = ( _$$0 ) => (Lib_Parser_Impl_satisfy(( t ) => (Prelude__$3D$3D_(null, Lib_Token_Prelude_Eq$20Lib_Token_Kind)(Lib_Token__kind(Lib_Token__val(null, t)))(_$$0)), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Expected a ")(Prelude_show(null, Lib_Token_Prelude_Show$20Lib_Token_Kind)(_$$0)))(" token")));
const Lib_Parser_Impl_token = ( eta ) => (Prelude__$2218_(null, null, null, ( eta ) => (Lib_Parser_Impl_indented(null, eta)), Lib_Parser_Impl_token$27, eta));
const Lib_Parser_charLit = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_Character), ( v ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RLit(fc, Lib_Types_LChar(Prelude_strIndex(v, 0))))))));
const Lib_Token_StringKind = { tag: "StringKind" };
const Lib_Parser_stringLit = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_StringKind), ( t ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RLit(fc, Lib_Types_LString(t)))))));
const Lib_Parser_interpString_append = ( _, _$$1, _$$2 ) => { const fc = Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$1); return Lib_Syntax_RApp(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(_$$1), Lib_Syntax_RApp(fc, Lib_Syntax_RVar(fc, "_++_"), _$$1, Lib_Types_Explicit), _$$2, Lib_Types_Explicit); };
const Lib_Token_EndQuote = { tag: "EndQuote" };
const Lib_Token_EndInterp = { tag: "EndInterp" };
const Lib_Token_StartInterp = { tag: "StartInterp" };
const Lib_Parser_interp = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_StartInterp), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( tm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_EndInterp), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(tm)))))));
const Lib_Parser_Impl_some = ( a$$0, _$$1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, _$$1, ( x ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, _$$1), ( xs ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$3A$3A_(null, x, xs)))))));
const Lib_Parser_Impl_many = ( a$$0, _$$1 ) => (Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_Impl_some(null, _$$1))(Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_Nil(null))));
const Lib_Token_StartQuote = { tag: "StartQuote" };
const Lib_Parser_interpString = ((  ) => { const append = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude_ignore(null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser)(Lib_Parser_Impl_token(Lib_Token_StartQuote)), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( part ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_stringLit)(Lib_Parser_interp)), ( parts ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude_ignore(null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser)(Lib_Parser_Impl_token(Lib_Token_EndQuote)), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_Parser_interpString_append(append, eta, eta1))), part, parts)))))))))); })();
const Prelude_stringToInt = (s) => {
  let rval = Number(s)
  if (isNaN(rval)) throw new Error(s + " is NaN")
  return rval
}
const Lib_Parser_intLit = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_Number), ( t ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RLit(fc, Lib_Types_LInt(Prelude_stringToInt(t))))))));
const Lib_Parser_lit = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_intLit)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_interpString)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_stringLit)(Lib_Parser_charLit)));
const Lib_Token_Projection = { tag: "Projection" };
const Lib_Token_UIdent = { tag: "UIdent" };
const Lib_Parser_uident = Lib_Parser_Impl_token(Lib_Token_UIdent);
const Lib_Syntax_RAs = ( h0, h1, h2 ) => ({ tag: "RAs",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Token_MixFix = { tag: "MixFix" };
const Lib_Token_Ident = { tag: "Ident" };
const Lib_Parser_ident = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_Impl_token(Lib_Token_Ident))(Lib_Parser_Impl_token(Lib_Token_MixFix));
const Lib_Parser_asAtom = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_ident, ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("@"), Lib_Parser_parenWrap(null, Lib_Parser_typeExpr))), ( asPat ) => { switch (asPat.tag) { case "Nothing": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RVar(fc, nm)); case "Just": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RAs(fc, nm, asPat.h1)); } })))));
const Lib_Parser_atom = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_MkUnit), ( _ ) => (Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, Lib_Syntax_RU, Lib_Parser_Impl_getPos), Lib_Parser_Impl_keyword("U")))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_asAtom)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Lib_Syntax_RVar(eta, eta1))), Lib_Parser_Impl_getPos))(Lib_Parser_uident))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Lib_Syntax_RVar(eta, eta1))), Lib_Parser_Impl_getPos))(Lib_Parser_Impl_token(Lib_Token_Projection)))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_lit)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, Lib_Syntax_RImplicit, Lib_Parser_Impl_getPos), Lib_Parser_Impl_keyword("_")))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, Lib_Syntax_RHole, Lib_Parser_Impl_getPos), Lib_Parser_Impl_keyword("?")))(Lib_Parser_parenWrap(null, Lib_Parser_typeExpr))))))))));
const Lib_Parser_pArg = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( x ) => (Prelude__$2C_(null, null, Lib_Types_Explicit, Prelude__$2C_(null, null, fc, x))), Lib_Parser_atom))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( x ) => (Prelude__$2C_(null, null, Lib_Types_Implicit, Prelude__$2C_(null, null, fc, x))), Lib_Parser_braces(null, Lib_Parser_typeExpr)))(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( x ) => (Prelude__$2C_(null, null, Lib_Types_Auto, Prelude__$2C_(null, null, fc, x))), Lib_Parser_dbraces(null, Lib_Parser_typeExpr))))));
const Lib_Parser_Impl_getOps = Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => (Lib_Parser_Impl_OK(null, ops, toks, com, ops))))));
const Lib_Parser_parseOp = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getOps, ( ops ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_atom, ( hd ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Lib_Parser_pArg), ( rest ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_pratt(ops, 0, "", hd, rest), ( $$sc ) => { const _sc$$0 = $$sc.h3; switch (_sc$$0.tag) { case "Nil": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)($$sc.h2); default: return Lib_Parser_Impl_fail(null, "extra stuff"); } })))))))));
const Lib_Syntax_RIf = ( h0, h1, h2, h3 ) => ({ tag: "RIf",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Parser_parseIfThen = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("if"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( a ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("then"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( b ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("else"), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( c ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RIf(fc, a, b, c))))))))))))))));
const Lib_Syntax_DoExpr = ( h0, h1 ) => ({ tag: "DoExpr",  h0: h0,  h1: h1 });
const Lib_Syntax_DoArrow = ( h0, h1, h2, h3 ) => ({ tag: "DoArrow",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Parser_caseAlt = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_MkUnit), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( pat ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("=>"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( t ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_MkAlt(pat, t))))))))));
const Lib_Parser_Impl_sameLevel = ( a$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( indent ) => { switch (toks.tag) { case "_::_": { const sc$$12 = Lib_Token_getStart(toks.h1); const _sc$$0 = indent.h1; const sc$$24 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Int)(sc$$12.h3)(_sc$$0.h3); switch (sc$$24.tag) { case "False": { const sc$$25 = Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, _sc$$0.h3, sc$$12.h3); switch (sc$$25.tag) { case "False": return Lib_Parser_Impl_Fail(null, Prelude_False, Lib_Parser_Impl_perror(indent.h0, toks, "unexpected indent"), toks, com, ops); case "True": return Lib_Parser_Impl_Fail(null, Prelude_False, Lib_Parser_Impl_perror(indent.h0, toks, "unexpected indent"), toks, com, ops); } break; } case "True": return _$$1.h1(toks)(com)(ops)(Lib_Common_MkFC(indent.h0, Prelude__$2C_(null, null, sc$$12.h2, _sc$$0.h3))); } break; } case "Nil": return _$$1.h1(toks)(com)(ops)(indent); } })))));
const Lib_Parser_Impl_manySame = ( a$$0, _$$1 ) => (Lib_Parser_Impl_many(null, Lib_Parser_Impl_sameLevel(null, _$$1)));
const Lib_Parser_Impl_startBlock = ( a$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( indent ) => { switch (toks.tag) { case "_::_": { const sc$$12 = Lib_Token_getStart(toks.h1); const _sc$$0 = indent.h1; return _$$1.h1(toks)(com)(ops)(Lib_Common_MkFC(indent.h0, Prelude__$2C_(null, null, sc$$12.h2, Prelude_ite(null, Prelude__$3C$3D_(null, Prelude_Prelude_Ord$20Prim_Int, sc$$12.h3, _sc$$0.h3), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$0.h3)(1), sc$$12.h3)))); break; } case "Nil": return _$$1.h1(toks)(com)(ops)(indent); } })))));
const Lib_Parser_doArrow = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( left ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Lib_Parser_Impl_keyword("<-")), ( $$sc ) => { switch ($$sc.tag) { case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( right ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("|"), Lib_Parser_caseAlt))), ( alts ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_DoArrow(fc, left, right, alts)))))); default: return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_DoExpr(fc, left)); } })))));
const Lib_Syntax_DoLet = ( h0, h1, h2 ) => ({ tag: "DoLet",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Parser_doLet = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("let"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_ident, ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("="), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( tm ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_DoLet(fc, nm, tm))))))))))));
const Lib_Parser_Impl_someSame = ( a$$0, _$$1 ) => (Lib_Parser_Impl_some(null, Lib_Parser_Impl_sameLevel(null, _$$1)));
const Lib_Syntax_RDo = ( h0, h1 ) => ({ tag: "RDo",  h0: h0,  h1: h1 });
const Lib_Parser_Impl_try = ( a$$0, _$$1 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => { const sc$$8 = _$$1.h1(toks)(com)(ops)(col); switch (sc$$8.tag) { case "Fail": return Lib_Parser_Impl_Fail(null, sc$$8.h1, sc$$8.h2, sc$$8.h3, Prelude_False, sc$$8.h5); default: return sc$$8; } })))));
const Lib_Parser_doCaseLet = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_try(null, Prelude__$3E$3E_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("let"), Lib_Parser_Impl_symbol("("))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( pat ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(")"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("="), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("|"), Lib_Parser_caseAlt))), ( alts ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( bodyFC ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Lib_Syntax_RDo(eta, eta1))), Lib_Parser_Impl_getPos))(Lib_Parser_Impl_someSame(null, Lib_Parser_doStmt)), ( body ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_DoExpr(fc, Lib_Syntax_RCase(fc, sc, Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(pat, body), alts))))))))))))))))))))));
const Lib_Parser_doStmt = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_doCaseLet)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_doLet)(Lib_Parser_doArrow));
const Lib_Parser_doExpr = Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Lib_Syntax_RDo(eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_keyword("do")))(Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_someSame(null, Lib_Parser_doStmt)));
const Lib_Parser_lamExpr_mkLam = ( _, _$$1, _$$2 ) => { const _sc$$0 = _$$1.h3; const _sc$$1 = _sc$$0.h3; return Lib_Syntax_RLam(_$$1.h2, Lib_Types_BI(_$$1.h2, _sc$$1.h2, _sc$$0.h2, Lib_Types_Many), _$$2); };
const Lib_Parser_pLamArg_impArg_autoArg_expArg = ( _, _1, _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_parenWrap(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Lib_Parser_uident)), ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$3E$3E_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(":"), Lib_Parser_typeExpr)), ( ty ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, Lib_Types_Explicit, Prelude__$2C_(null, null, nm, ty))))))));
const Lib_Parser_pLamArg_impArg_autoArg = ( _, _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_dbraces(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Lib_Parser_uident)), ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$3E$3E_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(":"), Lib_Parser_typeExpr)), ( ty ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, Lib_Types_Auto, Prelude__$2C_(null, null, nm, ty))))))));
const Lib_Parser_pLamArg_impArg = ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_braces(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Lib_Parser_uident)), ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$3E$3E_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(":"), Lib_Parser_typeExpr)), ( ty ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, Lib_Types_Implicit, Prelude__$2C_(null, null, nm, ty))))))));
const Lib_Parser_pLamArg = ((  ) => { const impArg = null; const autoArg = null; const expArg = null; return Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_pLamArg_impArg(impArg))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_pLamArg_impArg_autoArg(impArg, autoArg))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_pLamArg_impArg_autoArg_expArg(impArg, autoArg, expArg))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( x ) => (Prelude__$2C_(null, null, Lib_Types_Explicit, Prelude__$2C_(null, null, x, Prelude_Nothing(null)))), Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Lib_Parser_uident)))(Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("_"), Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, Lib_Types_Explicit, Prelude__$2C_(null, null, "_", Prelude_Nothing(null))))))))); })();
const Lib_Parser_addPos = ( a$$0, _$$1 ) => (Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Prelude__$2C_(null, null, eta, eta1))), Lib_Parser_Impl_getPos))(_$$1));
const Lib_Parser_lamExpr = ((  ) => { const mkLam = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( pos ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_Impl_keyword("\\"))(Lib_Parser_Impl_keyword("λ")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Lib_Parser_addPos(null, Lib_Parser_pLamArg)), ( args ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("=>"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( scope ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_foldr(null, null, ( eta ) => (( eta1 ) => (Lib_Parser_lamExpr_mkLam(mkLam, eta, eta1))), scope, args)))))))))))); })();
const Lib_Parser_caseLamExpr = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_try(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_Impl_keyword("\\"))(Lib_Parser_Impl_keyword("λ")), Lib_Parser_Impl_keyword("case"))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_someSame(null, Lib_Parser_caseAlt)), ( alts ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RLam(fc, Lib_Types_BI(fc, "$case", Lib_Types_Explicit, Lib_Types_Many), Lib_Syntax_RCase(fc, Lib_Syntax_RVar(fc, "$case"), alts)))))))));
const Lib_Parser_letExpr_mkLet = ( _, _$$1, _$$2 ) => { const _sc$$0 = _$$2.h3; const _sc$$1 = _sc$$0.h3; return Lib_Syntax_RLet(_sc$$0.h2, _$$2.h2, Prelude_fromMaybe(null, Lib_Syntax_RImplicit(_sc$$0.h2), _sc$$1.h2), _sc$$1.h3, _$$1); };
const Lib_Parser_letExpr_mkLet_letAssign = ( _, _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_ident, ( name ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword(":"), Lib_Parser_typeExpr)), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("="), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( t ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, name, Prelude__$2C_(null, null, fc, Prelude__$2C_(null, null, ty, t)))))))))))))));
const Lib_Parser_letExpr = ((  ) => { const mkLet = null; const letAssign = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("let"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_someSame(null, Lib_Parser_letExpr_mkLet_letAssign(mkLet, letAssign))), ( alts ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword$27("in"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( scope ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_foldl(null, null, ( eta ) => (( eta1 ) => (Lib_Parser_letExpr_mkLet(mkLet, eta, eta1))), scope, Prelude_reverse(null)(alts))))))))))); })();
const Lib_Parser_caseLet = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_try(null, Prelude__$3E$3E_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("let"), Lib_Parser_Impl_symbol("("))), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( pat ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(")"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("="), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("|"), Lib_Parser_caseAlt))), ( alts ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("in"), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( body ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RCase(fc, sc, Prelude__$3A$3A_(null, Lib_Syntax_MkAlt(pat, body), alts)))))))))))))))))))));
const Lib_Parser_caseExpr = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("case"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("of"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_someSame(null, Lib_Parser_caseAlt)), ( alts ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RCase(fc, sc, alts))))))))))));
const Lib_Parser_term$27 = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_caseExpr)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_caseLet)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_letExpr)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_caseLamExpr)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_lamExpr)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_doExpr)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseIfThen)(Lib_Parser_parseOp)))))));
const Lib_Parser_term = ((  ) => { const apply = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term$27, ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Prelude__$2C_(null, null, eta, eta1))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_keyword("$")))(Lib_Parser_term$27)), ( rest ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_term_apply(apply, t, rest)))))); })();
const Lib_Parser_forAll_mkPi = ( _, _$$1, _$$2 ) => (Lib_Syntax_RPi(_$$1.h2, Lib_Types_BI(_$$1.h2, _$$1.h3, Lib_Types_Implicit, Lib_Types_Zero), Lib_Syntax_RImplicit(_$$1.h2), _$$2));
const Lib_Parser_varname = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_uident)(Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("_"), Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)("_"))));
const Lib_Parser_forAll = ((  ) => { const mkPi = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_Impl_keyword("forall"))(Lib_Parser_Impl_keyword("∀")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Lib_Parser_addPos(null, Lib_Parser_varname)), ( all ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("."), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( scope ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_foldr(null, null, ( eta ) => (( eta1 ) => (Lib_Parser_forAll_mkPi(mkPi, eta, eta1))), scope, all)))))))))); })();
const Lib_Parser_binders_mkBind = ( _, _$$1, _$$2 ) => (Lib_Syntax_RPi(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Types_BindInfo)(_$$1.h2), _$$1.h2, _$$1.h3, _$$2));
const Lib_Parser_ebind_makeBind = ( _, _$$1, _$$2, _$$3 ) => (Prelude__$2C_(null, null, Lib_Types_BI(_$$3.h2, _$$3.h3, Lib_Types_Explicit, _$$1), _$$2));
const Prelude__$3C$$_ = ( f$$0, a$$1, b$$2, _$$3, _$$4, _$$5 ) => (Prelude__$3C$$$3E_(null, _$$3, null, null, ( eta ) => (Prelude_const(null, null, _$$4, eta)), _$$5));
const Lib_Parser_quantity = Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (Prelude_fromMaybe(null, Lib_Types_Many, eta)), Lib_Parser_optional(null, Prelude__$3C$$_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Types_Zero, Lib_Parser_Impl_keyword("0"))));
const Lib_Parser_ebind = ((  ) => { const makeBind = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("("), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_quantity, ( quant ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_try(null, Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Lib_Parser_addPos(null, Lib_Parser_varname)), Lib_Parser_Impl_symbol(":"))), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(")"), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Parser_ebind_makeBind(makeBind, quant, ty, eta)))($$sc)))))))))))); })();
const Lib_Parser_ibind_makeBind = ( _, _$$1, _$$2, _$$3 ) => (Prelude__$2C_(null, null, Lib_Types_BI(_$$3.h2, _$$3.h3, Lib_Types_Implicit, _$$1), Prelude_fromMaybe(null, Lib_Syntax_RImplicit(_$$3.h2), _$$2)));
const Lib_Parser_ibind = ((  ) => { const makeBind = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("{"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_quantity, ( quant ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Lib_Parser_addPos(null, Lib_Parser_varname)), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol(":"), Lib_Parser_typeExpr)), ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("}"), ( _1 ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Parser_ibind_makeBind(makeBind, quant, ty, eta)))($$sc)))))))))))); })();
const Lib_Parser_abind = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("{{"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Lib_Parser_Impl_try(null, Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_addPos(null, Lib_Parser_varname), Lib_Parser_Impl_symbol(":")))), ( name ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_symbol("}}"), ( _1 ) => { switch (name.tag) { case "Nothing": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Lib_Types_BI(Lib_Common_getFC(null, Lib_Syntax_Lib_Common_HasFC$20Lib_Syntax_Raw)(ty), "_", Lib_Types_Auto, Lib_Types_Many), ty), Prelude_Nil(null))); case "Just": { const _sc$$0 = name.h1; return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$3A$3A_(null, Prelude__$2C_(null, null, Lib_Types_BI(_sc$$0.h2, _sc$$0.h3, Lib_Types_Auto, Lib_Types_Many), ty), Prelude_Nil(null))); break; } } })))))));
const Lib_Parser_binders = ((  ) => { const mkBind = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_abind)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ibind)(Lib_Parser_ebind))), ( binds ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_arrow, ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( scope ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_foldr(null, null, ( eta ) => (( eta1 ) => (Lib_Parser_binders_mkBind(mkBind, eta, eta1))), scope, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, binds))))))))); })();
const Lib_Parser_typeExpr = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_binders)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_forAll)(Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_term, ( exp ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$2A$3E_(null, null, null, 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 ) => { switch (scope.tag) { case "Nothing": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(exp); case "Just": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_RPi(fc, Lib_Types_BI(fc, "_", Lib_Types_Explicit, Lib_Types_Many), exp, scope.h1)); } })))))));
const Lib_Parser_parseSig = Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (( eta2 ) => (Lib_Syntax_TypeSig(eta, eta1, eta2)))), Lib_Parser_Impl_getPos))(Lib_Parser_Impl_try(null, Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_uident)(Lib_Parser_Impl_token(Lib_Token_Projection)))), Lib_Parser_Impl_keyword(":")))))(Lib_Parser_typeExpr);
const Lib_Parser_nakedBind_makeBind = ( _, _$$1 ) => (Prelude__$2C_(null, null, Lib_Types_BI(_$$1.h2, _$$1.h3, Lib_Types_Explicit, Lib_Types_Many), Lib_Syntax_RImplicit(_$$1.h2)));
const Lib_Parser_nakedBind = ((  ) => { const makeBind = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Lib_Parser_addPos(null, Lib_Parser_varname)), ( $$sc ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude_map(null, Prelude_Prelude_Functor$20Prelude_List)(null)(null)(( eta ) => (Lib_Parser_nakedBind_makeBind(makeBind, eta)))($$sc)))); })();
const Lib_Parser_parseRecord = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("record"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_uident, ( name ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ebind)(Lib_Parser_nakedBind)), ( teles ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("where"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("constructor"), Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_uident)(Lib_Parser_Impl_token(Lib_Token_MixFix)))), ( cname ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Lib_Parser_parseSig)), ( decls ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_Record(fc, name, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, teles), cname, decls))))))))))))))));
const Lib_Syntax_Instance = ( h0, h1, h2 ) => ({ tag: "Instance",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Syntax_RWhere = ( h0, h1, h2 ) => ({ tag: "RWhere",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Parser_getName = ( _$$0 ) => { switch (_$$0.tag) { case "RApp": return Lib_Parser_getName(_$$0.h1); case "RVar": return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(_$$0.h1); default: return Lib_Parser_Impl_fail(null, "bad LHS"); } };
const Lib_Parser_parseDef = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( t ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_getName(t), ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("="), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( body ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( wfc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("where"), ( _1 ) => (Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseSig)(Lib_Parser_parseDef)))))), ( w ) => { const body1 = Prelude_maybe(null, null, body, ( decls ) => (Lib_Syntax_RWhere(wfc, decls, body)), w); return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_Def(fc, nm, Prelude__$3A$3A_(null, Prelude__$2C_(null, null, t, body1), Prelude_Nil(null)))); })))))))))))));
const Lib_Parser_parseInstance = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("instance"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Lib_Parser_Impl_keyword("where")), ( $$sc ) => { switch ($$sc.tag) { case "Just": return Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Lib_Parser_parseDef)), ( decls ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_Instance(fc, ty, Prelude_Just(null, decls))))); default: return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_Instance(fc, ty, Prelude_Nothing(null))); } })))))));
const Lib_Syntax_Class = ( h0, h1, h2, h3 ) => ({ tag: "Class",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Parser_parseClass = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("class"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_uident, ( name ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ebind)(Lib_Parser_nakedBind)), ( teles ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("where"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Lib_Parser_parseSig)), ( decls ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_Class(fc, name, Prelude_join(null, null, Prelude_Prelude_Monad$20Prelude_List, teles), decls))))))))))))));
const Lib_Syntax_ShortData = ( h0, h1, h2 ) => ({ tag: "ShortData",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Parser_Impl_sepBy = ( s$$0, a$$1, _$$2, _$$3 ) => (Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (Prelude__$3A$3A_(null, eta, eta1))), _$$3))(Lib_Parser_Impl_many(null, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, _$$2, _$$3))));
const Lib_Parser_parseShortData = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("data"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( lhs ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("="), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_sepBy(null, null, Lib_Parser_Impl_keyword("|"), Lib_Parser_typeExpr), ( sigs ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_ShortData(fc, lhs, sigs))))))))))));
const Lib_Parser_parseData = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_try(null, Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$2A$3E_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("data"), Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_uident)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Lib_Parser_Impl_token(Lib_Token_MixFix)))), Lib_Parser_Impl_keyword(":"))), ( name ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("where"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_startBlock(null, Lib_Parser_Impl_manySame(null, Lib_Parser_parseSig)), ( decls ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_Data(fc, name, ty, decls))))))))))));
const Lib_Syntax_DCheck = ( h0, h1, h2 ) => ({ tag: "DCheck",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Parser_parseNorm = Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$2A$3E_(null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser)(null)(null)(Prelude__$3C$2A_(null, null, null, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, Prelude__$3C$$$3E_(null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, null, null, ( eta ) => (( eta1 ) => (( eta2 ) => (Lib_Syntax_DCheck(eta, eta1, eta2)))), Lib_Parser_Impl_getPos), Lib_Parser_Impl_keyword("#check")))(Lib_Parser_typeExpr), Lib_Parser_Impl_keyword(":")))(Lib_Parser_typeExpr);
const Lib_Syntax_PFunc = ( h0, h1, h2, h3, h4 ) => ({ tag: "PFunc",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Lib_Token_JSLit = { tag: "JSLit" };
const Lib_Parser_parsePFunc = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("pfunc"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_ident, ( nm ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$3E$3E_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("uses"), Lib_Parser_parenWrap(null, Lib_Parser_Impl_many(null, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_uident)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_ident)(Lib_Parser_Impl_token(Lib_Token_MixFix))))))), ( used ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword(":"), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_typeExpr, ( ty ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword(":="), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_JSLit), ( src ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_PFunc(fc, nm, Prelude_fromMaybe(null, Prelude_Nil(null), used), ty, src))))))))))))))))));
const Lib_Syntax_PType = ( h0, h1, h2 ) => ({ tag: "PType",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Parser_parsePType = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("ptype"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_uident, ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_optional(null, Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword(":"), ( _1 ) => (Lib_Parser_typeExpr))), ( ty ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_PType(fc, $$sc, ty))))))))));
const Data_String_Prelude_Cast$20Prim_String$20Prim_Int$2Ccast = Prelude_stringToInt;
const Data_String_Prelude_Cast$20Prim_String$20Prim_Int = Prelude_MkCast(null, null, Data_String_Prelude_Cast$20Prim_String$20Prim_Int$2Ccast);
const Lib_Syntax_PMixFix = ( h0, h1, h2, h3 ) => ({ tag: "PMixFix",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Common_MkOp = ( h0, h1, h2, h3, h4 ) => ({ tag: "MkOp",  h0: h0,  h1: h1,  h2: h2,  h3: h3,  h4: h4 });
const Prelude_split = (s, by) => {
  let parts = s.split(by)
  let rval = Prelude_Nil(null)
  parts.reverse()
  parts.forEach(p => { rval = Prelude__$3A$3A_(null, p, rval) })
  return rval
}
const Lib_Parser_Impl_addOp = ( _$$0, _$$1, _$$2 ) => (Lib_Parser_Impl_P(null, ( toks ) => (( com ) => (( ops ) => (( col ) => { const parts = Prelude_split(_$$0, "_"); switch (parts.tag) { case "_::_": { const _sc$$0 = parts.h1; switch (_sc$$0) { case "": { const _sc$$1 = parts.h2; switch (_sc$$1.tag) { case "_::_": return Lib_Parser_Impl_OK(null, Prelude_MkUnit, toks, com, Data_SortedMap_updateMap(null, null, Prelude_Prelude_Ord$20Prim_String, _sc$$1.h1, Lib_Common_MkOp(_$$0, _$$1, _$$2, Prelude_False, _sc$$1.h2), ops)); default: return Lib_Parser_Impl_OK(null, Prelude_MkUnit, toks, com, Data_SortedMap_updateMap(null, null, Prelude_Prelude_Ord$20Prim_String, parts.h1, Lib_Common_MkOp(_$$0, _$$1, _$$2, Prelude_True, parts.h2), ops)); } break; } default: return Lib_Parser_Impl_OK(null, Prelude_MkUnit, toks, com, Data_SortedMap_updateMap(null, null, Prelude_Prelude_Ord$20Prim_String, parts.h1, Lib_Common_MkOp(_$$0, _$$1, _$$2, Prelude_True, parts.h2), ops)); } break; } case "Nil": return Lib_Parser_Impl_Fail(null, Prelude_True, Lib_Parser_Impl_perror(Lib_Common__file(col), toks, "Internal error parsing mixfix"), toks, com, ops); } })))));
const Lib_Common_Infix = { tag: "Infix" };
const Lib_Common_InfixR = { tag: "InfixR" };
const Lib_Common_InfixL = { tag: "InfixL" };
const Lib_Parser_parseMixfix = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$$_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Common_InfixL, Lib_Parser_Impl_keyword("infixl")))(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Prelude__$3C$$_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Common_InfixR, Lib_Parser_Impl_keyword("infixr")))(Prelude__$3C$$_(null, null, null, Lib_Parser_Impl_Prelude_Functor$20Lib_Parser_Impl_Parser, Lib_Common_Infix, Lib_Parser_Impl_keyword("infix")))), ( fix ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_token(Lib_Token_Number), ( prec ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_some(null, Lib_Parser_Impl_token(Lib_Token_MixFix)), ( ops ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Parser_Impl_Prelude_Applicative$20Lib_Parser_Impl_Parser, null, null, ops, ( op ) => (Lib_Parser_Impl_addOp(op, Prelude_cast(null, null, Data_String_Prelude_Cast$20Prim_String$20Prim_Int)(prec), fix))), ( _ ) => (Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_PMixFix(fc, ops, Prelude_cast(null, null, Data_String_Prelude_Cast$20Prim_String$20Prim_Int)(prec), fix))))))))))));
const Lib_Parser_parseDecl = Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseMixfix)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parsePType)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parsePFunc)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseNorm)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseData)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseShortData)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseSig)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseDef)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseClass)(Prelude__$3C$7C$3E_(null, Lib_Parser_Impl_Prelude_Alternative$20Lib_Parser_Impl_Parser)(null)(Lib_Parser_parseInstance)(Lib_Parser_parseRecord))))))))));
const Lib_Parser_Impl_partialParse = ( a$$0, _$$1, _$$2, _$$3, _$$4 ) => { const sc$$5 = Lib_Parser_Impl_runP(null, _$$2)(_$$4)(Prelude_False)(_$$3)(Lib_Common_MkFC(_$$1, Prelude__$2C_(null, null, 0, 0))); switch (sc$$5.tag) { case "Fail": return Prelude_Left(null, null, Prelude__$2C_(null, null, sc$$5.h2, sc$$5.h3)); case "OK": return Prelude_Right(null, null, Prelude__$2C_(null, null, sc$$5.h1, Prelude__$2C_(null, null, sc$$5.h4, sc$$5.h2))); } };
const Main_parseDecls = ( _$$0, _$$1, _$$2, _$$3 ) => { switch (_$$2.tag) { case "_::_": { const recover = null; const sc$$8 = Lib_Parser_Impl_partialParse(null, _$$0, Lib_Parser_Impl_sameLevel(null, Lib_Parser_parseDecl), _$$1, _$$2); switch (sc$$8.tag) { case "Right": { const _sc$$0 = sc$$8.h2; const _sc$$1 = _sc$$0.h3; return Main_parseDecls(_$$0, _sc$$1.h2, _sc$$1.h3, Prelude__$3A$3C_(null, _$$3, _sc$$0.h2)); break; } case "Left": { const _sc$$0 = sc$$8.h2; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Common_showError("", _sc$$0.h2)), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_TopContext_addError(_sc$$0.h2), ( _1 ) => (Main_parseDecls(_$$0, _$$1, Main_parseDecls_recover(_$$0, _$$1, _$$2, _$$3, _$$2.h0, _$$2.h1, _$$2.h2, recover, _sc$$0.h3), _$$3))))); break; } } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Prelude__$3C$3E$3E_(null, _$$3, Prelude_Nil(null)), _$$1)); } };
const Main_primNS = Prelude__$3A$3A_(null, "Prim", Prelude_Nil(null));
const Data_List1__$3A$3A$3A_ = ( h0, h1, h2 ) => ({ tag: "_:::_",  h0: h0,  h1: h1,  h2: h2 });
const Data_List1_split1 = ( _$$0, _$$1 ) => { const sc$$2 = Prelude_split(_$$0, _$$1); switch (sc$$2.tag) { case "_::_": return Data_List1__$3A$3A$3A_(null, sc$$2.h1, sc$$2.h2); case "Nil": return Data_List1__$3A$3A$3A_(null, _$$0, Prelude_Nil(null)); } };
const Data_List1_unsnoc_go = ( _, _1, _2, _3, _4, _5, _$$6, _$$7 ) => { switch (_$$7.tag) { case "_::_": { const sc$$11 = Data_List1_unsnoc_go(_, _1, _2, _3, _4, _5, _$$7.h1, _$$7.h2); return Prelude__$2C_(null, null, Prelude__$3A$3A_(null, _$$6, sc$$11.h2), sc$$11.h3); break; } case "Nil": return Prelude__$2C_(null, null, Prelude_Nil(null), _$$6); } };
const Data_List1_unsnoc = ( a$$0, _$$1 ) => { const go = null; return Data_List1_unsnoc_go(a$$0, _$$1, _$$1.h0, _$$1.h1, _$$1.h2, go, _$$1.h1, _$$1.h2); };
const Lib_Syntax_MkImport = ( h0, h1 ) => ({ tag: "MkImport",  h0: h0,  h1: h1 });
const Lib_Parser_parseImport = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_keyword("import"), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_uident, ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Lib_Parser_Impl_token(Lib_Token_Projection)), ( rest ) => { const name = Prelude_joinBy("", Prelude__$3A$3A_(null, $$sc, rest)); return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Lib_Syntax_MkImport(fc, name)); })))))));
const Lib_Parser_parseImports = Lib_Parser_Impl_manySame(null, Lib_Parser_parseImport);
const Lib_Parser_parseModHeader = Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_sameLevel(null, Lib_Parser_Impl_keyword("module")), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_getPos, ( fc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_uident, ( name ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser, Lib_Parser_Impl_many(null, Lib_Parser_Impl_token(Lib_Token_Projection)), ( rest ) => { const name1 = Prelude_joinBy("", Prelude__$3A$3A_(null, name, rest)); return Prelude_pure(null, Lib_Parser_Impl_Prelude_Monad$20Lib_Parser_Impl_Parser)(null)(Prelude__$2C_(null, null, fc, name1)); })))))));
const Lib_Tokenizer_TS = ( h0, h1, h2, h3 ) => ({ tag: "TS",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Token_MkBounds = ( h0, h1, h2, h3 ) => ({ tag: "MkBounds",  h0: h0,  h1: h1,  h2: h2,  h3: h3 });
const Lib_Token_Tok = ( h0, h1 ) => ({ tag: "Tok",  h0: h0,  h1: h1 });
const Lib_Token_MkBounded = ( h0, h1, h2 ) => ({ tag: "MkBounded",  h0: h0,  h1: h1,  h2: h2 });
const Lib_Tokenizer_keywords = Prelude__$3A$3A_(null, "let", Prelude__$3A$3A_(null, "in", Prelude__$3A$3A_(null, "where", Prelude__$3A$3A_(null, "case", Prelude__$3A$3A_(null, "of", Prelude__$3A$3A_(null, "data", Prelude__$3A$3A_(null, "U", Prelude__$3A$3A_(null, "do", Prelude__$3A$3A_(null, "ptype", Prelude__$3A$3A_(null, "pfunc", Prelude__$3A$3A_(null, "module", Prelude__$3A$3A_(null, "infixl", Prelude__$3A$3A_(null, "infixr", Prelude__$3A$3A_(null, "infix", Prelude__$3A$3A_(null, "∀", Prelude__$3A$3A_(null, "forall", Prelude__$3A$3A_(null, "import", Prelude__$3A$3A_(null, "uses", Prelude__$3A$3A_(null, "class", Prelude__$3A$3A_(null, "instance", Prelude__$3A$3A_(null, "record", Prelude__$3A$3A_(null, "constructor", Prelude__$3A$3A_(null, "if", Prelude__$3A$3A_(null, "then", Prelude__$3A$3A_(null, "else", Prelude__$3A$3A_(null, "$", Prelude__$3A$3A_(null, "λ", Prelude__$3A$3A_(null, "?", Prelude__$3A$3A_(null, "@", Prelude__$3A$3A_(null, ".", Prelude__$3A$3A_(null, "->", Prelude__$3A$3A_(null, "→", Prelude__$3A$3A_(null, ":", Prelude__$3A$3A_(null, "=>", Prelude__$3A$3A_(null, ":=", Prelude__$3A$3A_(null, "=", Prelude__$3A$3A_(null, "<-", Prelude__$3A$3A_(null, "\\", Prelude__$3A$3A_(null, "_", Prelude__$3A$3A_(null, "|", Prelude_Nil(null)))))))))))))))))))))))))))))))))))))))));
const Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _$$9, _$$10, _$$11, _$$12, _$$13 ) => { let kind; const sc$$14 = Prelude__$26$26_(_$$9, Prelude_elem(null, Prelude_Prelude_Eq$20Prim_String, _$$13, Lib_Tokenizer_keywords)); switch (sc$$14.tag) { case "False": { kind = _$$12; break; } case "True": { kind = Lib_Token_Keyword; break; } } return Lib_Token_MkBounded(null, Lib_Token_Tok(kind, _$$13), Lib_Token_MkBounds(_1, _2, _$$10, _$$11)); };
const Lib_Tokenizer_standalone = Prelude_unpack("()\\{}[],.@");
const Prelude_isSpace = ( _$$0 ) => { switch (_$$0) { case " ": return Prelude_True; case "\n": return Prelude_True; default: return Prelude_False; } };
const Lib_Tokenizer_rawTokenise_isIdent = ( _, _1, _2, _3, _4, _5, _$$6 ) => (Prelude_not(Prelude__$7C$7C_(Prelude_isSpace(_$$6), Prelude_elem(null, Prelude_Prelude_Eq$20Prim_Char, _$$6, Lib_Tokenizer_standalone))));
const Data_SnocList_snocelem = ( a$$0, _$$1, _$$2, _$$3 ) => { switch (_$$3.tag) { case "_:<_": { const sc$$7 = Prelude__$3D$3D_(null, _$$1)(_$$2)(_$$3.h2); switch (sc$$7.tag) { case "False": return Data_SnocList_snocelem(null, _$$1, _$$2, _$$3.h1); case "True": return Prelude_True; } break; } case "Lin": return Prelude_False; } };
const Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _$$12, _$$13, _$$14, _$$15 ) => { const _sc$$0 = _$$12.h3; switch (_sc$$0.tag) { case "_::_": { const sc$$23 = _$$14(_sc$$0.h1); switch (sc$$23.tag) { case "False": { let kind; const sc$$24 = Data_SnocList_snocelem(null, Prelude_Prelude_Eq$20Prim_Char, "_", _$$15); switch (sc$$24.tag) { case "False": { kind = _$$13; break; } case "True": { kind = Lib_Token_MixFix; break; } } return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$12.h0, _$$12.h1, Prelude__$3A$3C_(null, _$$12.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_, _1, _2, _3, _4, _5, _6, _7, _8, Prelude_True, _$$12.h0, Prelude__$2D_(null, Prelude_Prelude_Sub$20Prim_Int)(_$$12.h1)(1), kind, Prelude_pack(Prelude__$3C$3E$3E_(null, _$$15, Prelude_Nil(null))))), Prelude__$3A$3A_(null, _sc$$0.h1, _sc$$0.h2))); break; } case "True": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, Lib_Tokenizer_TS(_$$12.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$12.h1)(1), _$$12.h2, _sc$$0.h2), _$$13, _$$14, Prelude__$3A$3C_(null, _$$15, _sc$$0.h1)); } break; } case "Nil": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$12.h0, _$$12.h1, Prelude__$3A$3C_(null, _$$12.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_, _1, _2, _3, _4, _5, _6, _7, _8, Prelude_True, _$$12.h0, _$$12.h1, _$$13, Prelude_pack(Prelude__$3C$3E$3E_(null, _$$15, Prelude_Nil(null))))), Prelude_Nil(null))); } };
const Prelude_isUpper = ( _$$0 ) => { const o = Prelude_ord(_$$0); return Prelude__$26$26_(Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, 64, o), Prelude__$3C_(null, Prelude_Prelude_Ord$20Prim_Int, o, 91)); };
const Prelude_isDigit = ( _$$0 ) => { switch (_$$0) { case "0": return Prelude_True; case "1": return Prelude_True; case "2": return Prelude_True; case "3": return Prelude_True; case "4": return Prelude_True; case "5": return Prelude_True; case "6": return Prelude_True; case "7": return Prelude_True; case "8": return Prelude_True; case "9": return Prelude_True; default: return Prelude_False; } };
const Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _$$13, _$$14 ) => { const sc$$15 = Prelude_elem(null, Prelude_Prelude_Eq$20Prim_Char, _$$13, Lib_Tokenizer_standalone); switch (sc$$15.tag) { case "False": { let kind; const sc$$16 = Prelude_isDigit(_$$13); switch (sc$$16.tag) { case "False": { const sc$$17 = Prelude_isUpper(_$$13); switch (sc$$17.tag) { case "False": { kind = Lib_Token_Ident; break; } case "True": { kind = Lib_Token_UIdent; break; } } break; } case "True": { kind = Lib_Token_Number; break; } } return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, Lib_Tokenizer_TS(_1, _2, _3, Prelude__$3A$3A_(null, _$$13, _$$14)), kind, ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(_, _1, _2, _3, _4, _5, eta)), Prelude_Lin(null)); break; } case "True": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_1, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_2)(1), Prelude__$3A$3C_(null, _3, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_, _1, _2, _3, _4, _5, _6, _7, _8, Prelude_True, _1, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_2)(1), Lib_Token_Symbol, Prelude_pack(Prelude__$3A$3A_(null, _$$13, Prelude_Nil(null))))), _$$14)); } };
const Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _$$10 ) => { const _sc$$0 = _$$10.h3; switch (_sc$$0.tag) { case "_::_": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1) { case "\n": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$10.h0)(1), 0, _$$10.h2, _sc$$0.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, Lib_Tokenizer_TS(_$$10.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$10.h1)(1), _$$10.h2, _sc$$0.h2)); } break; } case "Nil": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$10.h0, _$$10.h1, _$$10.h2, Prelude_Nil(null))); } };
const Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick = ( _, _1, _2, _3, _4, _5, _6, _7, _$$8, _$$9 ) => { const _sc$$0 = _$$8.h3; switch (_sc$$0.tag) { case "_::_": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1) { case "`": { const tok = Lib_Token_MkBounded(null, Lib_Token_Tok(Lib_Token_JSLit, Prelude_pack(Prelude__$3C$3E$3E_(null, _$$9, Prelude_Nil(null)))), Lib_Token_MkBounds(_1, _2, _$$8.h0, _$$8.h1)); return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$8.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$8.h1)(1), Prelude__$3A$3C_(null, _$$8.h2, tok), _sc$$0.h2)); break; } case "\n": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick(_, _1, _2, _3, _4, _5, _6, _7, Lib_Tokenizer_TS(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$8.h0)(1), 0, _$$8.h2, _sc$$0.h2), Prelude__$3A$3C_(null, _$$9, "\n")); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick(_, _1, _2, _3, _4, _5, _6, _7, Lib_Tokenizer_TS(_$$8.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$8.h1)(1), _$$8.h2, _sc$$0.h2), Prelude__$3A$3C_(null, _$$9, _sc$$0.h1)); } break; } case "Nil": return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _$$8.h0, _$$8.h1)), "EOF in backtick string")); } };
const Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment = ( _, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _$$11 ) => { const _sc$$0 = _$$11.h3; switch (_sc$$0.tag) { case "_::_": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1) { case "-": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case "/": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$11.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$11.h1)(2), _$$11.h2, _sc$$2.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Lib_Tokenizer_TS(_$$11.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$11.h1)(1), _$$11.h2, _sc$$0.h2)); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Lib_Tokenizer_TS(_$$11.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$11.h1)(1), _$$11.h2, _sc$$0.h2)); } break; } case "\n": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Lib_Tokenizer_TS(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$11.h0)(1), 0, _$$11.h2, _sc$$0.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Lib_Tokenizer_TS(_$$11.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$11.h1)(1), _$$11.h2, _sc$$0.h2)); } break; } case "Nil": return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _$$11.h0, _$$11.h1)), "EOF in block comment")); } };
const Lib_Token_Pragma = { tag: "Pragma" };
const Lib_Tokenizer_singleton = ( _$$0 ) => (Prelude_pack(Prelude__$3A$3A_(null, _$$0, Prelude_Nil(null))));
const Lib_Tokenizer_quoteTokenise_stok = ( _, _1, _2, _3, _4, _5, _6, _7, _8 ) => (Lib_Token_MkBounded(null, Lib_Token_Tok(Lib_Token_StringKind, Prelude_pack(Prelude__$3C$3E$3E_(null, _3, Prelude_Nil(null)))), Lib_Token_MkBounds(_1, _2, _4, _5)));
const Lib_Tokenizer_quoteTokenise = ( _$$0, _$$1, _$$2, _$$3 ) => { const stok = null; const _sc$$0 = _$$0.h3; switch (_sc$$0.tag) { case "_::_": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1) { case "\"": return Prelude_Right(null, null, Lib_Tokenizer_TS(_$$0.h0, _$$0.h1, Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_quoteTokenise_stok(_$$0, _$$1, _$$2, _$$3, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, stok)), _$$0.h3)); case "\n": return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _$$0.h0, _$$0.h1)), "Newline in string")); case "\\": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case "{": { const tok = Lib_Token_MkBounded(null, Lib_Token_Tok(Lib_Token_StartInterp, "\\{"), Lib_Token_MkBounds(_$$0.h0, _$$0.h1, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2))); const sc$$17 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_quoteTokenise_stok(_$$0, _$$1, _$$2, _$$3, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, stok)), tok), _sc$$2.h2)); switch (sc$$17.tag) { case "Right": { const _sc$$4 = sc$$17.h2; const _sc$$5 = _sc$$4.h3; switch (_sc$$5.tag) { case "_::_": { const _sc$$6 = _sc$$5.h1; switch (_sc$$6) { case "}": { const tok1 = Lib_Token_MkBounded(null, Lib_Token_Tok(Lib_Token_EndInterp, "}"), Lib_Token_MkBounds(_sc$$4.h0, _sc$$4.h1, _sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(1))); return Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(_sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(1), Prelude__$3A$3C_(null, _sc$$4.h2, tok1), _sc$$5.h2), _sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(1), Prelude_Lin(null)); break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '{'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '{'")); } break; } case "Left": return Prelude_Left(null, null, sc$$17.h2); } break; } case "n": return Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), _$$0.h2, _sc$$2.h2), _$$1, _$$2, Prelude__$3A$3C_(null, _$$3, "\n")); default: return Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), _$$0.h2, _sc$$2.h2), _$$1, _$$2, Prelude__$3A$3C_(null, _$$3, _sc$$2.h1)); } break; } default: return Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, _sc$$0.h2), _$$1, _$$2, Prelude__$3A$3C_(null, _$$3, _sc$$0.h1)); } break; } default: return Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, _sc$$0.h2), _$$1, _$$2, Prelude__$3A$3C_(null, _$$3, _sc$$0.h1)); } break; } case "Nil": return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _$$0.h0, _$$0.h1)), "Expected '\"' at EOF")); } };
const Lib_Tokenizer_rawTokenise = ( _$$0 ) => { const isIdent = null; const isUIdent = null; const doBacktick = null; const mktok = null; const lineComment = null; const blockComment = null; const doRest = null; const doChar = null; const _sc$$0 = _$$0.h3; switch (_sc$$0.tag) { case "_::_": { const _sc$$1 = _sc$$0.h1; switch (_sc$$1) { case " ": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, _sc$$0.h2)); case "\n": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h0)(1), 0, _$$0.h2, _sc$$0.h2)); case "\"": { const tok = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Lib_Token_StartQuote, "\""); const sc$$18 = Lib_Tokenizer_quoteTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Prelude__$3A$3C_(null, _$$0.h2, tok), _sc$$0.h2), _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Prelude_Lin(null)); switch (sc$$18.tag) { case "Right": { const _sc$$2 = sc$$18.h2; const _sc$$3 = _sc$$2.h3; switch (_sc$$3.tag) { case "_::_": { const _sc$$4 = _sc$$3.h1; switch (_sc$$4) { case "\"": { const tok1 = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _sc$$2.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$2.h1)(1), Lib_Token_EndQuote, "\""); return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_sc$$2.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$2.h1)(1), Prelude__$3A$3C_(null, _sc$$2.h2, tok1), _sc$$3.h2)); break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$2.h0, _sc$$2.h1)), "Expected '\"'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$2.h0, _sc$$2.h1)), "Expected '\"'")); } break; } case "Left": return Prelude_Left(null, null, sc$$18.h2); } break; } case "}": return Prelude_Right(null, null, _$$0); case "{": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case "{": { const tok = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), Lib_Token_Keyword, "{{"); const sc$$21 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), Prelude__$3A$3C_(null, _$$0.h2, tok), _sc$$2.h2)); switch (sc$$21.tag) { case "Right": { const _sc$$4 = sc$$21.h2; const _sc$$5 = _sc$$4.h3; switch (_sc$$5.tag) { case "_::_": { const _sc$$6 = _sc$$5.h1; switch (_sc$$6) { case "}": { const _sc$$7 = _sc$$5.h2; switch (_sc$$7.tag) { case "_::_": { const _sc$$8 = _sc$$7.h1; switch (_sc$$8) { case "}": { const tok1 = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(2), Lib_Token_Keyword, "}}"); return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(2), Prelude__$3A$3C_(null, _sc$$4.h2, tok1), _sc$$7.h2)); break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '}}'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '}}'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '}}'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '}}'")); } break; } case "Left": return Prelude_Left(null, null, sc$$21.h2); } break; } default: { const tok = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Lib_Token_Symbol, "{"); const sc$$21 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Prelude__$3A$3C_(null, _$$0.h2, tok), _sc$$0.h2)); switch (sc$$21.tag) { case "Right": { const _sc$$4 = sc$$21.h2; const _sc$$5 = _sc$$4.h3; switch (_sc$$5.tag) { case "_::_": { const _sc$$6 = _sc$$5.h1; switch (_sc$$6) { case "}": { const tok1 = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(1), Lib_Token_Symbol, "}"); return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_sc$$4.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$4.h1)(1), Prelude__$3A$3C_(null, _sc$$4.h2, tok1), _sc$$5.h2)); break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '}'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$4.h0, _sc$$4.h1)), "Expected '}'")); } break; } case "Left": return Prelude_Left(null, null, sc$$21.h2); } break; } } break; } default: { const tok = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Lib_Token_Symbol, "{"); const sc$$18 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Prelude__$3A$3C_(null, _$$0.h2, tok), _sc$$0.h2)); switch (sc$$18.tag) { case "Right": { const _sc$$3 = sc$$18.h2; const _sc$$4 = _sc$$3.h3; switch (_sc$$4.tag) { case "_::_": { const _sc$$5 = _sc$$4.h1; switch (_sc$$5) { case "}": { const tok1 = Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _sc$$3.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$3.h1)(1), Lib_Token_Symbol, "}"); return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_sc$$3.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_sc$$3.h1)(1), Prelude__$3A$3C_(null, _sc$$3.h2, tok1), _sc$$4.h2)); break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$3.h0, _sc$$3.h1)), "Expected '}'")); } break; } default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC("", Prelude__$2C_(null, null, _sc$$3.h0, _sc$$3.h1)), "Expected '}'")); } break; } case "Left": return Prelude_Left(null, null, sc$$18.h2); } break; } } break; } case ",": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), Lib_Token_Ident, ",")), _sc$$0.h2)); case "_": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case ",": { const _sc$$4 = _sc$$2.h2; switch (_sc$$4.tag) { case "_::_": { const _sc$$5 = _sc$$4.h1; switch (_sc$$5) { case "_": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Lib_Token_MixFix, "_,_")), _sc$$4.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } case ".": { const _sc$$4 = _sc$$2.h2; switch (_sc$$4.tag) { case "_::_": { const _sc$$5 = _sc$$4.h1; switch (_sc$$5) { case "_": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Lib_Token_MixFix, "_._")), _sc$$4.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } case "'": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case "\\": { const _sc$$4 = _sc$$2.h2; switch (_sc$$4.tag) { case "_::_": { const _sc$$5 = _sc$$4.h2; switch (_sc$$5.tag) { case "_::_": { const _sc$$6 = _sc$$5.h1; switch (_sc$$6) { case "'": { const ch = Prelude_ite(null, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_Char)(_sc$$4.h1)("n"), "\n", _sc$$4.h1); return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(4), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(4), Lib_Token_Character, Lib_Tokenizer_singleton(ch))), _sc$$5.h2)); break; } default: { const _sc$$7 = _sc$$4.h1; switch (_sc$$7) { case "'": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Lib_Token_Character, Lib_Tokenizer_singleton(_sc$$2.h1))), _sc$$4.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } } break; } default: { const _sc$$6 = _sc$$4.h1; switch (_sc$$6) { case "'": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Lib_Token_Character, Lib_Tokenizer_singleton(_sc$$2.h1))), _sc$$4.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: { const _sc$$4 = _sc$$2.h2; switch (_sc$$4.tag) { case "_::_": { const _sc$$5 = _sc$$4.h1; switch (_sc$$5) { case "'": return Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Prelude__$3A$3C_(null, _$$0.h2, Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, Prelude_False, _$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(3), Lib_Token_Character, Lib_Tokenizer_singleton(_sc$$2.h1))), _sc$$4.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } case "#": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, _sc$$0.h2), Lib_Token_Pragma, ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, eta)), Prelude__$3A$3C_(null, Prelude_Lin(null), "#")); case "/": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case "-": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), _$$0.h2, _sc$$2.h2)); default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } case "`": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, _sc$$0.h2), Prelude_Lin(null)); case ".": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, _sc$$0.h2), Lib_Token_Projection, ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, eta)), Prelude__$3A$3C_(null, Prelude_Lin(null), ".")); case "-": { const _sc$$2 = _sc$$0.h2; switch (_sc$$2.tag) { case "_::_": { const _sc$$3 = _sc$$2.h1; switch (_sc$$3) { case "-": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), _$$0.h2, _sc$$2.h2)); default: { const sc$$20 = Prelude_isDigit(_sc$$2.h1); switch (sc$$20.tag) { case "False": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(1), _$$0.h2, Prelude__$3A$3A_(null, _sc$$2.h1, _sc$$2.h2)), Lib_Token_Ident, ( eta ) => (Lib_Tokenizer_rawTokenise_isIdent(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, eta)), Prelude__$3A$3C_(null, Prelude_Lin(null), "-")); case "True": return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, Lib_Tokenizer_TS(_$$0.h0, Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(_$$0.h1)(2), _$$0.h2, _sc$$2.h2), Lib_Token_Number, Prelude_isDigit, Prelude__$3A$3C_(null, Prelude__$3A$3C_(null, Prelude_Lin(null), "-"), _sc$$2.h1)); } break; } } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } default: return Lib_Tokenizer_rawTokenise_isIdent_isUIdent_doBacktick_mktok_lineComment_blockComment_doRest_doChar(_$$0, _$$0.h0, _$$0.h1, _$$0.h2, _$$0.h3, isIdent, isUIdent, doBacktick, mktok, lineComment, blockComment, doRest, doChar, _sc$$0.h1, _sc$$0.h2); } break; } case "Nil": return Prelude_Right(null, null, _$$0); } };
const Lib_Tokenizer_tokenise = ( _$$0, _$$1 ) => { const sc$$2 = Lib_Tokenizer_rawTokenise(Lib_Tokenizer_TS(0, 0, Prelude_Lin(null), Prelude_unpack(_$$1))); switch (sc$$2.tag) { case "Right": { const _sc$$0 = sc$$2.h2; const _sc$$1 = _sc$$0.h3; switch (_sc$$1.tag) { case "Nil": return Prelude_Right(null, null, Prelude__$3C$3E$3E_(null, _sc$$0.h2, Prelude_Nil(null))); default: return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC(_$$0, Prelude__$2C_(null, null, _sc$$0.h0, _sc$$0.h1)), "Extra toks")); } break; } case "Left": { const _sc$$0 = sc$$2.h2; switch (_sc$$0.tag) { case "E": { const _sc$$1 = _sc$$0.h0; return Prelude_Left(null, null, Lib_Common_E(Lib_Common_MkFC(_$$0, _sc$$1.h1), _sc$$0.h1)); break; } default: return Prelude_Left(null, null, sc$$2.h2); } break; } } };
const Node_readFile = (fn) => (w) => {
  let fs = require('fs')
  let result
  try {
    let content = fs.readFileSync(fn, 'utf8')
    result = Prelude_Right(null, null, content)
  } catch (e) {
    let err = ""+e
    result = Prelude_Left(null, null, e)
  }
  return Prelude_MkIORes(null, result, w)
}
const Lib_Types_emptyModCtx = Lib_Types_MkModCtx(Data_SortedMap_EmptyMap(null, null), Lib_Types_MC(Data_SortedMap_EmptyMap(null, null), 0, Lib_Types_NoCheck), Data_SortedMap_EmptyMap(null, null));
const Main_processModule = ( _$$0, _$$1, _$$2, _$$3 ) => { const tryProcessDecl = null; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const modns = Prelude_snoc(null, _$$3.h0, _$$3.h1); const name = Prelude_joinBy(".", modns); const sc$$10 = Data_SortedMap_lookupMap(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), modns, Lib_Types__modules(top)); switch (sc$$10.tag) { case "Nothing": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_modifyTop(( top1 ) => (Lib_Types_MkTop(Data_SortedMap_updateMap(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), modns, Lib_Types_emptyModCtx, Lib_Types__modules(top1)), Lib_Types__imported(top1), Lib_Types__ns(top1), Lib_Types__defs(top1), Lib_Types__metaCtx(top1), Lib_Types__verbose(top1), Lib_Types__errors(top1), Lib_Types__ops(top1)))), ( _ ) => { const fn = Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude_joinBy("/", Prelude__$3A$3A_(null, _$$1, _$$3.h0)))(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("/")(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(_$$3.h1)(".newt"))); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_liftIO(null, Lib_Types_Prelude_HasIO$20Lib_Types_M)(null)(Node_readFile(fn)), ( $$sc ) => { switch ($$sc.tag) { case "Right": { const sc$$19 = Lib_Tokenizer_tokenise(fn, $$sc.h2); switch (sc$$19.tag) { case "Right": { const sc$$23 = Lib_Parser_Impl_partialParse(null, fn, Lib_Parser_parseModHeader, Lib_Types__ops(top), sc$$19.h2); switch (sc$$23.tag) { case "Right": { const _sc$$0 = sc$$23.h2; const _sc$$1 = _sc$$0.h2; const _sc$$2 = _sc$$0.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("scan imports for module ")(_sc$$1.h3))(""))), ( _1 ) => { const ns = Prelude_split(_sc$$1.h3, "."); const sc$$41 = Data_List1_unsnoc(null, Data_List1_split1(_sc$$1.h3, ".")); const sc$$46 = Prelude__$3D$3D_(null, Lib_Common_Prelude_Eq$20Lib_Common_QName)(_$$3)(Lib_Common_QN(sc$$41.h2, sc$$41.h3)); switch (sc$$46.tag) { case "True": { const sc$$47 = Lib_Parser_Impl_partialParse(null, fn, Lib_Parser_parseImports, _sc$$2.h2, _sc$$2.h3); switch (sc$$47.tag) { case "Right": { const _sc$$3 = sc$$47.h2; const _sc$$4 = _sc$$3.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, _sc$$3.h2, ( $$case ) => { const sc$$63 = Data_List1_unsnoc(null, Data_List1_split1($$case.h1, ".")); const qname = Lib_Common_QN(sc$$63.h2, sc$$63.h3); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_elem(null, Prelude_Prelude_Eq$20Prim_String, $$case.h1, _$$2), ( _2 ) => (Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("import loop ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(name)))(" -> "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)($$case.h1)))("")))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_processModule($$case.h0, _$$1, Prelude__$3A$3A_(null, name, _$$2), qname), ( _3 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_split($$case.h1, ".")))))); }), ( imported ) => { const imported1 = Prelude_snoc(null, imported, Main_primNS); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("module ")(_sc$$1.h3))("")), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _3 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("MODNS ")(Prelude_show(null, Prelude_Prelude_Show$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Show$20Prim_String))(modns)))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_parseDecls(fn, Lib_Types__ops(top1), _sc$$4.h3, Prelude_Lin(null)), ( $$sc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_newIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types_MC(Data_SortedMap_EmptyMap(null, null), 0, Lib_Types_CheckAll)), ( freshMC ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_modifyTop(( top3 ) => (Lib_Types_MkTop(Lib_Types__modules(top3), imported1, modns, Data_SortedMap_EmptyMap(null, null), freshMC, Lib_Types__verbose(top3), Lib_Types__errors(top3), $$sc1.h3))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _5 ) => ("process Decls")), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(( eta ) => (Main_processModule_tryProcessDecl(_$$0, _$$1, _$$2, _$$3, _$$3.h0, _$$3.h1, tryProcessDecl, ns, eta)))(Lib_Elab_collectDecl($$sc1.h2)), ( _6 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_readIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types__metaCtx(top3)), ( mc ) => { const mod = Lib_Types_MkModCtx(Lib_Types__defs(top3), mc, Lib_Types__ops(top3)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Serialize_dumpModule(_$$3, $$sc.h2, mod), ( _7 ) => { const modules = Data_SortedMap_updateMap(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), modns, mod, Lib_Types__modules(top3)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Data_IORef_newIORef(null, null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Types_MC(Data_SortedMap_EmptyMap(null, null), 0, Lib_Types_CheckAll)), ( freshMC1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_modifyTop(( top4 ) => (Lib_Types_MkTop(modules, Lib_Types__imported(top4), Lib_Types__ns(top4), Lib_Types__defs(top4), Lib_Types__metaCtx(top4), Lib_Types__verbose(top4), Lib_Types__errors(top4), Lib_Types__ops(top4)))), ( _8 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_liftIO(null, Lib_Types_Prelude_HasIO$20Lib_Types_M)(null)(Data_IORef_readIORef(null, null, Prelude_Prelude_HasIO$20Prelude_IO, Lib_Types__errors(top3))), ( $$sc2 ) => { switch ($$sc2.tag) { case "Nil": { const sc$$85 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Eq$20Prim_String))(_$$2)(Prelude_Nil(null)); switch (sc$$85.tag) { case "False": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit), ( _9 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)($$sc.h2))); case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_logMetas(Prelude_reverse(null)(Data_SortedMap_listValues(null, null, Lib_Types__metas(mc)))), ( _9 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)($$sc.h2))); } break; } default: return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_for_(null, null, Prelude_Prelude_Traversable$20Prelude_List, Lib_Types_Prelude_Applicative$20Lib_Types_M, null, null, $$sc2, ( err ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Lib_Common_showError($$sc.h2, err)))), ( _9 ) => (Node_exitFailure(null, "Compile failed"))); } }))))); }); }))))))))))))))))))))); }); break; } case "Left": { const _sc$$3 = sc$$47.h2; return Node_exitFailure(null, Lib_Common_showError($$sc.h2, _sc$$3.h2)); break; } } break; } default: return Node_exitFailure(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ERROR at ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_sc$$1.h2)))(": module name "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_sc$$1.h3)))(" doesn't match file name "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(fn)))("")); } }); break; } case "Left": { const _sc$$0 = sc$$23.h2; return Node_exitFailure(null, Lib_Common_showError($$sc.h2, _sc$$0.h2)); break; } } break; } case "Left": return Node_exitFailure(null, Lib_Common_showError($$sc.h2, sc$$19.h2)); } break; } case "Left": return Node_exitFailure(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ERROR at ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(_$$0)))(": error reading "))(fn))(": "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)($$sc.h2)))("")); } }); }); default: return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(""); } }); };
const Lib_Util_getBaseDir_baseDir = ( _, _1, _2, _$$3, _$$4 ) => { switch (_$$4.tag) { case "_:<_": switch (_$$3.tag) { case "_:<_": { const sc$$11 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(_$$3.h2)(_$$4.h2); switch (sc$$11.tag) { case "False": return Prelude_Left(null, null, "module path doesn't match directory"); case "True": return Lib_Util_getBaseDir_baseDir(_, _1, _2, _$$3.h1, _$$4.h1); } break; } case "Lin": return Prelude_Left(null, null, "module path doesn't match directory"); } break; case "Lin": return Prelude_Right(null, null, Prelude_joinBy("/", Prelude__$3C$3E$3E_(null, _$$3, Prelude_Nil(null)))); } };
const Prelude_Prelude_Bifunctor$20Prelude__$D7_$2Cbimap = ( a$$0, b$$1, c$$2, d$$3, _$$4, _$$5, _$$6 ) => (Prelude__$2C_(null, null, _$$4(_$$6.h2), _$$5(_$$6.h3)));
const Prelude_MkBifunctor = ( h0, h1 ) => ({ tag: "MkBifunctor",  h0: h0,  h1: h1 });
const Prelude_Prelude_Bifunctor$20Prelude__$D7_ = Prelude_MkBifunctor(null, ( a ) => (( b ) => (( c ) => (( d ) => (( eta ) => (( eta1 ) => (( eta2 ) => (Prelude_Prelude_Bifunctor$20Prelude__$D7_$2Cbimap(null, null, null, null, eta, eta1, eta2)))))))));
const Prelude_bimap = ( f$$0, _$$1 ) => (( a ) => (( b ) => (( c ) => (( d ) => (_$$1.h1(null)(null)(null)(null))))));
const Prelude_mapFst = ( a$$0, b$$1, c$$2, f$$3, _$$4, _$$5, _$$6 ) => (Prelude_bimap(null, _$$4)(null)(null)(null)(null)(_$$5)(( eta ) => (Prelude_id(null, eta)))(_$$6));
const Data_List1_splitFileName = ( _$$0 ) => { const sc$$1 = Data_List1_split1(_$$0, "."); const _sc$$0 = sc$$1.h2; switch (_sc$$0.tag) { case "Nil": return Prelude__$2C_(null, null, sc$$1.h1, ""); default: return Prelude_mapFst(null, null, null, null, Prelude_Prelude_Bifunctor$20Prelude__$D7_, ( eta ) => (Prelude_joinBy(".", eta)), Data_List1_unsnoc(null, sc$$1)); } };
const Lib_Util_getBaseDir = ( _$$0, _$$1 ) => { const baseDir = null; const sc$$3 = Data_List1_unsnoc(null, Data_List1_split1(_$$1, ".")); const parts = Data_List1_split1(_$$0, "/"); const sc$$9 = Data_List1_unsnoc(null, parts); const sc$$14 = Data_List1_splitFileName(sc$$9.h3); const parts1 = Data_List1_split1(_$$0, "/"); const sc$$20 = Data_List1_unsnoc(null, parts1); const sc$$25 = Data_List1_unsnoc(null, Data_List1_split1(_$$1, ".")); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_unless(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(sc$$25.h3)(sc$$14.h2), ( _ ) => (Lib_Types_error(null, Lib_Common_MkFC(_$$0, Prelude__$2C_(null, null, 0, 0)), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("module name ")(sc$$25.h3))(" doesn't match "))(sc$$14.h2))("")))), ( _ ) => { const sc$$31 = Lib_Util_getBaseDir_baseDir(_$$0, _$$1, baseDir, Prelude__$3C$3E$3C_(null, Prelude_Lin(null), sc$$20.h2), Prelude__$3C$3E$3C_(null, Prelude_Lin(null), sc$$25.h2)); switch (sc$$31.tag) { case "Right": { let base; const sc$$35 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20Prim_String)(sc$$31.h2)(""); switch (sc$$35.tag) { case "False": { base = sc$$31.h2; break; } case "True": { base = "."; break; } } return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, base, Lib_Common_QN(sc$$25.h2, sc$$25.h3))); break; } case "Left": return Lib_Types_error(null, Lib_Common_MkFC(_$$0, Prelude__$2C_(null, null, 0, 0)), sc$$31.h2); } }); };
const Main_processFile = ( _$$0 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("*** Process ")(_$$0))("")), ( _ ) => { const parts = Data_List1_split1(_$$0, "/"); const sc$$3 = Data_List1_unsnoc(null, parts); let dir; const sc$$8 = Prelude__$3D$3D_(null, Prelude_Prelude_Eq$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Eq$20Prim_String))(sc$$3.h2)(Prelude_Nil(null)); switch (sc$$8.tag) { case "False": { dir = Prelude_joinBy("/", sc$$3.h2); break; } case "True": { dir = "."; break; } } const sc$$9 = Data_List1_splitFileName(sc$$3.h3); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_log(1, ( _1 ) => (Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(dir)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(sc$$9.h2)))(" "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(sc$$9.h3)))(""))), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_liftIO(null, Lib_Types_Prelude_HasIO$20Lib_Types_M)(null)(Node_readFile(_$$0)), ( $$sc ) => { switch ($$sc.tag) { case "Right": { const sc$$20 = Lib_Tokenizer_tokenise(_$$0, $$sc.h2); switch (sc$$20.tag) { case "Right": { const sc$$24 = Lib_Parser_Impl_partialParse(null, _$$0, Lib_Parser_parseModHeader, Data_SortedMap_EmptyMap(null, null), sc$$20.h2); switch (sc$$24.tag) { case "Right": { const _sc$$0 = sc$$24.h2; const _sc$$1 = _sc$$0.h2; const _sc$$2 = _sc$$0.h3; return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Util_getBaseDir(_$$0, _sc$$1.h3), ( $$sc1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(Main_primNS, Lib_Syntax_PType(Lib_Common_emptyFC, "Int", Prelude_Nothing(null))), ( _2 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(Main_primNS, Lib_Syntax_PType(Lib_Common_emptyFC, "String", Prelude_Nothing(null))), ( _3 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_ProcessDecl_processDecl(Main_primNS, Lib_Syntax_PType(Lib_Common_emptyFC, "Char", Prelude_Nothing(null))), ( _4 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top ) => { const modules = Data_SortedMap_updateMap(null, null, Prelude_Prelude_Ord$20$28Prelude_List$20BND$3A1$29(null, Prelude_Prelude_Ord$20Prim_String), Main_primNS, Lib_Types_MkModCtx(Lib_Types__defs(top), Lib_Types_MC(Data_SortedMap_EmptyMap(null, null), 0, Lib_Types_CheckAll), Lib_Types__ops(top)), Lib_Types__modules(top)); return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_modifyTop(( top1 ) => (Lib_Types_MkTop(modules, Prelude__$3A$3A_(null, Main_primNS, Prelude_Nil(null)), Prelude_Nil(null), Data_SortedMap_EmptyMap(null, null), Lib_Types__metaCtx(top1), Lib_Types__verbose(top1), Lib_Types__errors(top1), Lib_Types__ops(top1)))), ( _5 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_processModule(Lib_Common_emptyFC, $$sc1.h2, Prelude_Nil(null), $$sc1.h3), ( src ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_getTop, ( top1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_showErrors(_$$0, src), ( _6 ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit))))))))); }))))))))); break; } case "Left": { const _sc$$0 = sc$$24.h2; return Lib_Types_throwError(null, _sc$$0.h2); break; } } break; } case "Left": return Lib_Types_throwError(null, sc$$20.h2); } break; } case "Left": return Lib_Types_error(null, Lib_Common_MkFC(_$$0, Prelude__$2C_(null, null, 0, 0)), Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("error reading ")(_$$0))(": "))(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)($$sc.h2)))("")); } }))); }));
const Prelude_isSuffixOf = (pfx, s) => s.endsWith(pfx) ? Prelude_True : Prelude_False
const Main_cmdLine = ( _$$0 ) => { switch (_$$0.tag) { case "_::_": { const _sc$$0 = _$$0.h1; switch (_sc$$0) { case "--top": return Main_cmdLine(_$$0.h2); case "-v": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Lib_Types_modifyTop(( top ) => (Lib_Types_MkTop(Lib_Types__modules(top), Lib_Types__imported(top), Lib_Types__ns(top), Lib_Types__defs(top), Lib_Types__metaCtx(top), Prelude__$2B_(null, Prelude_Prelude_Add$20Prim_Int)(Lib_Types__verbose(top))(1), Lib_Types__errors(top), Lib_Types__ops(top)))), ( _ ) => (Main_cmdLine(_$$0.h2))); case "-o": { const _sc$$1 = _$$0.h2; switch (_sc$$1.tag) { case "_::_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_cmdLine(_sc$$1.h2), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Prelude__$3C$7C$3E_(null, Prelude_Prelude_Alternative$20Prelude_Maybe)(null)($$sc.h2)(Prelude_Just(null, _sc$$1.h1)), $$sc.h3)))); default: { const sc$$4 = Prelude_isSuffixOf(".newt", _$$0.h1); switch (sc$$4.tag) { case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_cmdLine(_$$0.h2), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, $$sc.h2, Prelude__$3A$3A_(null, _$$0.h1, $$sc.h3))))); default: return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Bad argument ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1)))("")); } break; } } break; } default: { const sc$$4 = Prelude_isSuffixOf(".newt", _$$0.h1); switch (sc$$4.tag) { case "True": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_cmdLine(_$$0.h2), ( $$sc ) => (Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, $$sc.h2, Prelude__$3A$3A_(null, _$$0.h1, $$sc.h3))))); default: return Lib_Types_error(null, Lib_Common_emptyFC, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("Bad argument ")(Prelude_show(null, Prelude_Prelude_Show$20Prim_String)(_$$0.h1)))("")); } break; } } break; } case "Nil": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude__$2C_(null, null, Prelude_Nothing(null), Prelude_Nil(null))); } };
const Node_getArgs = Prelude_arrayToList(null, process.argv.slice(1))
const Main_main$27 = ((  ) => { const sc$$0 = Node_getArgs; switch (sc$$0.tag) { case "_::_": return Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_cmdLine(sc$$0.h2), ( $$sc ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_traverse(null, Prelude_Prelude_Traversable$20Prelude_List)(null)(null)(null)(Lib_Types_Prelude_Applicative$20Lib_Types_M)(Main_processFile)($$sc.h3), ( _ ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Prelude_when(null, Lib_Types_Prelude_Applicative$20Lib_Types_M, Prelude_elem(null, Prelude_Prelude_Eq$20Prim_String, "--top", sc$$0.h2), ( _1 ) => (Prelude__$3E$3E$3D_(null, null, null, Lib_Types_Prelude_Monad$20Lib_Types_M, Main_jsonTopContext, ( json ) => (Prelude_putStrLn(null, Lib_Types_Prelude_HasIO$20Lib_Types_M, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("TOP:")(Lib_Common_renderJson(json)))("")))))), ( _1 ) => { const _sc$$0 = $$sc.h2; switch (_sc$$0.tag) { case "Nothing": return Prelude_pure(null, Lib_Types_Prelude_Monad$20Lib_Types_M)(null)(Prelude_MkUnit); case "Just": return Main_writeSource(_sc$$0.h1); } }))))); default: return Lib_Types_error(null, Lib_Common_emptyFC, "error reading args"); } })();
const Prelude_List = ( h0 ) => ({ tag: "List",  h0: h0 });
const Lib_TopContext_emptyTop = ( io, _, _1 ) => (Prelude__$3E$3E$3D_(null, null, null, _, Data_IORef_newIORef(null, null, _1, Lib_Types_MC(Data_SortedMap_EmptyMap(null, null), 0, Lib_Types_CheckAll)), ( mcctx ) => (Prelude__$3E$3E$3D_(null, null, null, _, Data_IORef_newIORef(null, null, _1, Prelude_the(Prelude_List(null), Prelude_Nil(null))), ( errs ) => (Prelude_pure(null, _)(null)(Lib_Types_MkTop(Data_SortedMap_EmptyMap(null, null), Prelude_Nil(null), Prelude_Nil(null), Data_SortedMap_EmptyMap(null, null), mcctx, 0, errs, Data_SortedMap_EmptyMap(null, null))))))));
const Main_main = Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, Lib_TopContext_emptyTop(null, Prelude_Prelude_Monad$20Prelude_IO, Prelude_Prelude_HasIO$20Prelude_IO), ( ctx ) => (Prelude__$3E$3E$3D_(null, null, null, Prelude_Prelude_Monad$20Prelude_IO, Lib_Types__runM(null, Main_main$27)(ctx), ( $$sc ) => { switch ($$sc.tag) { case "Right": return Prelude_putStrLn(null, Prelude_Prelude_HasIO$20Prelude_IO, "done"); case "Left": return Node_exitFailure(null, Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)(Prelude__$2B$2B_(null, Prelude_Prelude_Concat$20Prim_String)("ERROR at ")(Prelude_show(null, Lib_Common_Prelude_Show$20Lib_Common_FC)(Lib_Common_getFC(null, Lib_Types_Lib_Common_HasFC$20Lib_Common_Error)($$sc.h2))))(": "))(Lib_Types_errorMsg($$sc.h2)))("")); } })));
Main_main();