// This object will hold all exports.
var Haste = {};
/* Thunk
Creates a thunk representing the given closure.
If the non-updatable flag is undefined, the thunk is updatable.
*/
function T(f, nu) {
this.f = f;
if(nu === undefined) {
this.x = __updatable;
}
}
/* Hint to optimizer that an imported symbol is strict. */
function __strict(x) {return x}
// A tailcall.
function F(f) {
this.f = f;
}
// A partially applied function. Invariant: members are never thunks.
function PAP(f, args) {
this.f = f;
this.args = args;
this.arity = f.length - args.length;
}
// Special object used for blackholing.
var __blackhole = {};
// Used to indicate that an object is updatable.
var __updatable = {};
/* Generic apply.
Applies a function *or* a partial application object to a list of arguments.
See https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution/FunctionCalls
for more information.
*/
function A(f, args) {
while(true) {
f = E(f);
if(f instanceof F) {
f = E(B(f));
}
if(f instanceof PAP) {
// f is a partial application
if(args.length == f.arity) {
// Saturated application
return f.f.apply(null, f.args.concat(args));
} else if(args.length < f.arity) {
// Application is still unsaturated
return new PAP(f.f, f.args.concat(args));
} else {
// Application is oversaturated;
var f2 = f.f.apply(null, f.args.concat(args.slice(0, f.arity)));
args = args.slice(f.arity);
f = B(f2);
}
} else if(f instanceof Function) {
if(args.length == f.length) {
return f.apply(null, args);
} else if(args.length < f.length) {
return new PAP(f, args);
} else {
var f2 = f.apply(null, args.slice(0, f.length));
args = args.slice(f.length);
f = B(f2);
}
} else {
return f;
}
}
}
/* Eval
Evaluate the given thunk t into head normal form.
If the "thunk" we get isn't actually a thunk, just return it.
*/
function E(t) {
if(t instanceof T) {
if(t.f !== __blackhole) {
if(t.x === __updatable) {
var f = t.f;
t.f = __blackhole;
t.x = f();
} else {
return t.f();
}
}
return t.x;
} else {
return t;
}
}
/* Bounce
Bounce on a trampoline for as long as we get a function back.
*/
function B(f) {
while(f instanceof F) {
var fun = f.f;
f.f = __blackhole;
f = fun();
}
return f;
}
// Export Haste, A, B and E. Haste because we need to preserve exports, A, B
// and E because they're handy for Haste.Foreign.
if(!window) {
var window = {};
}
window['Haste'] = Haste;
window['A'] = A;
window['E'] = E;
window['B'] = B;
/* Throw an error.
We need to be able to use throw as an exception so we wrap it in a function.
*/
function die(err) {
throw E(err);
}
function quot(a, b) {
return (a-a%b)/b;
}
function quotRemI(a, b) {
return [0, (a-a%b)/b, a%b];
}
// 32 bit integer multiplication, with correct overflow behavior
// note that |0 or >>>0 needs to be applied to the result, for int and word
// respectively.
if(Math.imul) {
var imul = Math.imul;
} else {
var imul = function(a, b) {
// ignore high a * high a as the result will always be truncated
var lows = (a & 0xffff) * (b & 0xffff); // low a * low b
var aB = (a & 0xffff) * (b & 0xffff0000); // low a * high b
var bA = (a & 0xffff0000) * (b & 0xffff); // low b * high a
return lows + aB + bA; // sum will not exceed 52 bits, so it's safe
}
}
function addC(a, b) {
var x = a+b;
return [0, x & 0xffffffff, x > 0x7fffffff];
}
function subC(a, b) {
var x = a-b;
return [0, x & 0xffffffff, x < -2147483648];
}
function sinh (arg) {
return (Math.exp(arg) - Math.exp(-arg)) / 2;
}
function tanh (arg) {
return (Math.exp(arg) - Math.exp(-arg)) / (Math.exp(arg) + Math.exp(-arg));
}
function cosh (arg) {
return (Math.exp(arg) + Math.exp(-arg)) / 2;
}
function isFloatFinite(x) {
return isFinite(x);
}
function isDoubleFinite(x) {
return isFinite(x);
}
function err(str) {
die(toJSStr(str));
}
/* unpackCString#
NOTE: update constructor tags if the code generator starts munging them.
*/
function unCStr(str) {return unAppCStr(str, [0]);}
function unFoldrCStr(str, f, z) {
var acc = z;
for(var i = str.length-1; i >= 0; --i) {
acc = B(A(f, [str.charCodeAt(i), acc]));
}
return acc;
}
function unAppCStr(str, chrs) {
var i = arguments[2] ? arguments[2] : 0;
if(i >= str.length) {
return E(chrs);
} else {
return [1,str.charCodeAt(i),new T(function() {
return unAppCStr(str,chrs,i+1);
})];
}
}
function charCodeAt(str, i) {return str.charCodeAt(i);}
function fromJSStr(str) {
return unCStr(E(str));
}
function toJSStr(hsstr) {
var s = '';
for(var str = E(hsstr); str[0] == 1; str = E(str[2])) {
s += String.fromCharCode(E(str[1]));
}
return s;
}
// newMutVar
function nMV(val) {
return ({x: val});
}
// readMutVar
function rMV(mv) {
return mv.x;
}
// writeMutVar
function wMV(mv, val) {
mv.x = val;
}
// atomicModifyMutVar
function mMV(mv, f) {
var x = B(A(f, [mv.x]));
mv.x = x[1];
return x[2];
}
function localeEncoding() {
var le = newByteArr(5);
le['v']['i8'][0] = 'U'.charCodeAt(0);
le['v']['i8'][1] = 'T'.charCodeAt(0);
le['v']['i8'][2] = 'F'.charCodeAt(0);
le['v']['i8'][3] = '-'.charCodeAt(0);
le['v']['i8'][4] = '8'.charCodeAt(0);
return le;
}
var isDoubleNaN = isNaN;
var isFloatNaN = isNaN;
function isDoubleInfinite(d) {
return (d === Infinity);
}
var isFloatInfinite = isDoubleInfinite;
function isDoubleNegativeZero(x) {
return (x===0 && (1/x)===-Infinity);
}
var isFloatNegativeZero = isDoubleNegativeZero;
function strEq(a, b) {
return a == b;
}
function strOrd(a, b) {
if(a < b) {
return 0;
} else if(a == b) {
return 1;
}
return 2;
}
function jsCatch(act, handler) {
try {
return B(A(act,[0]));
} catch(e) {
return B(A(handler,[e, 0]));
}
}
/* Haste represents constructors internally using 1 for the first constructor,
2 for the second, etc.
However, dataToTag should use 0, 1, 2, etc. Also, booleans might be unboxed.
*/
function dataToTag(x) {
if(x instanceof Array) {
return x[0];
} else {
return x;
}
}
function __word_encodeDouble(d, e) {
return d * Math.pow(2,e);
}
var __word_encodeFloat = __word_encodeDouble;
var jsRound = Math.round, rintDouble = jsRound, rintFloat = jsRound;
var jsTrunc = Math.trunc ? Math.trunc : function(x) {
return x < 0 ? Math.ceil(x) : Math.floor(x);
};
function jsRoundW(n) {
return Math.abs(jsTrunc(n));
}
var realWorld = undefined;
if(typeof _ == 'undefined') {
var _ = undefined;
}
function popCnt64(i) {
return popCnt(I_getBits(i,0)) + popCnt(I_getBits(i,1));
}
function popCnt(i) {
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}