mirror of
https://github.com/correl/elm.git
synced 2024-12-23 03:00:08 +00:00
3254 lines
No EOL
69 KiB
HTML
3254 lines
No EOL
69 KiB
HTML
<!DOCTYPE HTML>
|
|
<html><head><meta charset="UTF-8"><title>AllYourBase</title><style>html,head,body { padding:0; margin:0; }
|
|
body { font-family: calibri, helvetica, arial, sans-serif; }</style><script type="text/javascript">
|
|
(function() {
|
|
'use strict';
|
|
|
|
function F2(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return fun(a,b); }; }
|
|
wrapper.arity = 2;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F3(fun)
|
|
{
|
|
function wrapper(a) {
|
|
return function(b) { return function(c) { return fun(a, b, c); }; };
|
|
}
|
|
wrapper.arity = 3;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F4(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return function(c) {
|
|
return function(d) { return fun(a, b, c, d); }; }; };
|
|
}
|
|
wrapper.arity = 4;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F5(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return function(c) {
|
|
return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; };
|
|
}
|
|
wrapper.arity = 5;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F6(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return function(c) {
|
|
return function(d) { return function(e) { return function(f) {
|
|
return fun(a, b, c, d, e, f); }; }; }; }; };
|
|
}
|
|
wrapper.arity = 6;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F7(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return function(c) {
|
|
return function(d) { return function(e) { return function(f) {
|
|
return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; };
|
|
}
|
|
wrapper.arity = 7;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F8(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return function(c) {
|
|
return function(d) { return function(e) { return function(f) {
|
|
return function(g) { return function(h) {
|
|
return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; };
|
|
}
|
|
wrapper.arity = 8;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function F9(fun)
|
|
{
|
|
function wrapper(a) { return function(b) { return function(c) {
|
|
return function(d) { return function(e) { return function(f) {
|
|
return function(g) { return function(h) { return function(i) {
|
|
return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; };
|
|
}
|
|
wrapper.arity = 9;
|
|
wrapper.func = fun;
|
|
return wrapper;
|
|
}
|
|
|
|
function A2(fun, a, b)
|
|
{
|
|
return fun.arity === 2
|
|
? fun.func(a, b)
|
|
: fun(a)(b);
|
|
}
|
|
function A3(fun, a, b, c)
|
|
{
|
|
return fun.arity === 3
|
|
? fun.func(a, b, c)
|
|
: fun(a)(b)(c);
|
|
}
|
|
function A4(fun, a, b, c, d)
|
|
{
|
|
return fun.arity === 4
|
|
? fun.func(a, b, c, d)
|
|
: fun(a)(b)(c)(d);
|
|
}
|
|
function A5(fun, a, b, c, d, e)
|
|
{
|
|
return fun.arity === 5
|
|
? fun.func(a, b, c, d, e)
|
|
: fun(a)(b)(c)(d)(e);
|
|
}
|
|
function A6(fun, a, b, c, d, e, f)
|
|
{
|
|
return fun.arity === 6
|
|
? fun.func(a, b, c, d, e, f)
|
|
: fun(a)(b)(c)(d)(e)(f);
|
|
}
|
|
function A7(fun, a, b, c, d, e, f, g)
|
|
{
|
|
return fun.arity === 7
|
|
? fun.func(a, b, c, d, e, f, g)
|
|
: fun(a)(b)(c)(d)(e)(f)(g);
|
|
}
|
|
function A8(fun, a, b, c, d, e, f, g, h)
|
|
{
|
|
return fun.arity === 8
|
|
? fun.func(a, b, c, d, e, f, g, h)
|
|
: fun(a)(b)(c)(d)(e)(f)(g)(h);
|
|
}
|
|
function A9(fun, a, b, c, d, e, f, g, h, i)
|
|
{
|
|
return fun.arity === 9
|
|
? fun.func(a, b, c, d, e, f, g, h, i)
|
|
: fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
|
|
}
|
|
//import Native.Utils //
|
|
|
|
var _elm_lang$core$Native_Basics = function() {
|
|
|
|
function div(a, b)
|
|
{
|
|
return (a / b) | 0;
|
|
}
|
|
function rem(a, b)
|
|
{
|
|
return a % b;
|
|
}
|
|
function mod(a, b)
|
|
{
|
|
if (b === 0)
|
|
{
|
|
throw new Error('Cannot perform mod 0. Division by zero error.');
|
|
}
|
|
var r = a % b;
|
|
var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r + b) : -mod(-a, -b));
|
|
|
|
return m === b ? 0 : m;
|
|
}
|
|
function logBase(base, n)
|
|
{
|
|
return Math.log(n) / Math.log(base);
|
|
}
|
|
function negate(n)
|
|
{
|
|
return -n;
|
|
}
|
|
function abs(n)
|
|
{
|
|
return n < 0 ? -n : n;
|
|
}
|
|
|
|
function min(a, b)
|
|
{
|
|
return _elm_lang$core$Native_Utils.cmp(a, b) < 0 ? a : b;
|
|
}
|
|
function max(a, b)
|
|
{
|
|
return _elm_lang$core$Native_Utils.cmp(a, b) > 0 ? a : b;
|
|
}
|
|
function clamp(lo, hi, n)
|
|
{
|
|
return _elm_lang$core$Native_Utils.cmp(n, lo) < 0
|
|
? lo
|
|
: _elm_lang$core$Native_Utils.cmp(n, hi) > 0
|
|
? hi
|
|
: n;
|
|
}
|
|
|
|
var ord = ['LT', 'EQ', 'GT'];
|
|
|
|
function compare(x, y)
|
|
{
|
|
return { ctor: ord[_elm_lang$core$Native_Utils.cmp(x, y) + 1] };
|
|
}
|
|
|
|
function xor(a, b)
|
|
{
|
|
return a !== b;
|
|
}
|
|
function not(b)
|
|
{
|
|
return !b;
|
|
}
|
|
function isInfinite(n)
|
|
{
|
|
return n === Infinity || n === -Infinity;
|
|
}
|
|
|
|
function truncate(n)
|
|
{
|
|
return n | 0;
|
|
}
|
|
|
|
function degrees(d)
|
|
{
|
|
return d * Math.PI / 180;
|
|
}
|
|
function turns(t)
|
|
{
|
|
return 2 * Math.PI * t;
|
|
}
|
|
function fromPolar(point)
|
|
{
|
|
var r = point._0;
|
|
var t = point._1;
|
|
return _elm_lang$core$Native_Utils.Tuple2(r * Math.cos(t), r * Math.sin(t));
|
|
}
|
|
function toPolar(point)
|
|
{
|
|
var x = point._0;
|
|
var y = point._1;
|
|
return _elm_lang$core$Native_Utils.Tuple2(Math.sqrt(x * x + y * y), Math.atan2(y, x));
|
|
}
|
|
|
|
return {
|
|
div: F2(div),
|
|
rem: F2(rem),
|
|
mod: F2(mod),
|
|
|
|
pi: Math.PI,
|
|
e: Math.E,
|
|
cos: Math.cos,
|
|
sin: Math.sin,
|
|
tan: Math.tan,
|
|
acos: Math.acos,
|
|
asin: Math.asin,
|
|
atan: Math.atan,
|
|
atan2: F2(Math.atan2),
|
|
|
|
degrees: degrees,
|
|
turns: turns,
|
|
fromPolar: fromPolar,
|
|
toPolar: toPolar,
|
|
|
|
sqrt: Math.sqrt,
|
|
logBase: F2(logBase),
|
|
negate: negate,
|
|
abs: abs,
|
|
min: F2(min),
|
|
max: F2(max),
|
|
clamp: F3(clamp),
|
|
compare: F2(compare),
|
|
|
|
xor: F2(xor),
|
|
not: not,
|
|
|
|
truncate: truncate,
|
|
ceiling: Math.ceil,
|
|
floor: Math.floor,
|
|
round: Math.round,
|
|
toFloat: function(x) { return x; },
|
|
isNaN: isNaN,
|
|
isInfinite: isInfinite
|
|
};
|
|
|
|
}();//import //
|
|
|
|
var _elm_lang$core$Native_Utils = function() {
|
|
|
|
// COMPARISONS
|
|
|
|
function eq(x, y)
|
|
{
|
|
var stack = [];
|
|
var isEqual = eqHelp(x, y, 0, stack);
|
|
var pair;
|
|
while (isEqual && (pair = stack.pop()))
|
|
{
|
|
isEqual = eqHelp(pair.x, pair.y, 0, stack);
|
|
}
|
|
return isEqual;
|
|
}
|
|
|
|
|
|
function eqHelp(x, y, depth, stack)
|
|
{
|
|
if (depth > 100)
|
|
{
|
|
stack.push({ x: x, y: y });
|
|
return true;
|
|
}
|
|
|
|
if (x === y)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (typeof x !== 'object')
|
|
{
|
|
if (typeof x === 'function')
|
|
{
|
|
throw new Error(
|
|
'Trying to use `(==)` on functions. There is no way to know if functions are "the same" in the Elm sense.'
|
|
+ ' Read more about this at http://package.elm-lang.org/packages/elm-lang/core/latest/Basics#=='
|
|
+ ' which describes why it is this way and what the better version will look like.'
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if (x === null || y === null)
|
|
{
|
|
return false
|
|
}
|
|
|
|
if (x instanceof Date)
|
|
{
|
|
return x.getTime() === y.getTime();
|
|
}
|
|
|
|
if (!('ctor' in x))
|
|
{
|
|
for (var key in x)
|
|
{
|
|
if (!eqHelp(x[key], y[key], depth + 1, stack))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// convert Dicts and Sets to lists
|
|
if (x.ctor === 'RBNode_elm_builtin' || x.ctor === 'RBEmpty_elm_builtin')
|
|
{
|
|
x = _elm_lang$core$Dict$toList(x);
|
|
y = _elm_lang$core$Dict$toList(y);
|
|
}
|
|
if (x.ctor === 'Set_elm_builtin')
|
|
{
|
|
x = _elm_lang$core$Set$toList(x);
|
|
y = _elm_lang$core$Set$toList(y);
|
|
}
|
|
|
|
// check if lists are equal without recursion
|
|
if (x.ctor === '::')
|
|
{
|
|
var a = x;
|
|
var b = y;
|
|
while (a.ctor === '::' && b.ctor === '::')
|
|
{
|
|
if (!eqHelp(a._0, b._0, depth + 1, stack))
|
|
{
|
|
return false;
|
|
}
|
|
a = a._1;
|
|
b = b._1;
|
|
}
|
|
return a.ctor === b.ctor;
|
|
}
|
|
|
|
// check if Arrays are equal
|
|
if (x.ctor === '_Array')
|
|
{
|
|
var xs = _elm_lang$core$Native_Array.toJSArray(x);
|
|
var ys = _elm_lang$core$Native_Array.toJSArray(y);
|
|
if (xs.length !== ys.length)
|
|
{
|
|
return false;
|
|
}
|
|
for (var i = 0; i < xs.length; i++)
|
|
{
|
|
if (!eqHelp(xs[i], ys[i], depth + 1, stack))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if (!eqHelp(x.ctor, y.ctor, depth + 1, stack))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
for (var key in x)
|
|
{
|
|
if (!eqHelp(x[key], y[key], depth + 1, stack))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Code in Generate/JavaScript.hs, Basics.js, and List.js depends on
|
|
// the particular integer values assigned to LT, EQ, and GT.
|
|
|
|
var LT = -1, EQ = 0, GT = 1;
|
|
|
|
function cmp(x, y)
|
|
{
|
|
if (typeof x !== 'object')
|
|
{
|
|
return x === y ? EQ : x < y ? LT : GT;
|
|
}
|
|
|
|
if (x instanceof String)
|
|
{
|
|
var a = x.valueOf();
|
|
var b = y.valueOf();
|
|
return a === b ? EQ : a < b ? LT : GT;
|
|
}
|
|
|
|
if (x.ctor === '::' || x.ctor === '[]')
|
|
{
|
|
while (x.ctor === '::' && y.ctor === '::')
|
|
{
|
|
var ord = cmp(x._0, y._0);
|
|
if (ord !== EQ)
|
|
{
|
|
return ord;
|
|
}
|
|
x = x._1;
|
|
y = y._1;
|
|
}
|
|
return x.ctor === y.ctor ? EQ : x.ctor === '[]' ? LT : GT;
|
|
}
|
|
|
|
if (x.ctor.slice(0, 6) === '_Tuple')
|
|
{
|
|
var ord;
|
|
var n = x.ctor.slice(6) - 0;
|
|
var err = 'cannot compare tuples with more than 6 elements.';
|
|
if (n === 0) return EQ;
|
|
if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
|
|
if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
|
|
if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
|
|
if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
|
|
if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
|
|
if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
|
|
if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
|
|
return EQ;
|
|
}
|
|
|
|
throw new Error(
|
|
'Comparison error: comparison is only defined on ints, '
|
|
+ 'floats, times, chars, strings, lists of comparable values, '
|
|
+ 'and tuples of comparable values.'
|
|
);
|
|
}
|
|
|
|
|
|
// COMMON VALUES
|
|
|
|
var Tuple0 = {
|
|
ctor: '_Tuple0'
|
|
};
|
|
|
|
function Tuple2(x, y)
|
|
{
|
|
return {
|
|
ctor: '_Tuple2',
|
|
_0: x,
|
|
_1: y
|
|
};
|
|
}
|
|
|
|
function chr(c)
|
|
{
|
|
return new String(c);
|
|
}
|
|
|
|
|
|
// GUID
|
|
|
|
var count = 0;
|
|
function guid(_)
|
|
{
|
|
return count++;
|
|
}
|
|
|
|
|
|
// RECORDS
|
|
|
|
function update(oldRecord, updatedFields)
|
|
{
|
|
var newRecord = {};
|
|
|
|
for (var key in oldRecord)
|
|
{
|
|
newRecord[key] = oldRecord[key];
|
|
}
|
|
|
|
for (var key in updatedFields)
|
|
{
|
|
newRecord[key] = updatedFields[key];
|
|
}
|
|
|
|
return newRecord;
|
|
}
|
|
|
|
|
|
//// LIST STUFF ////
|
|
|
|
var Nil = { ctor: '[]' };
|
|
|
|
function Cons(hd, tl)
|
|
{
|
|
return {
|
|
ctor: '::',
|
|
_0: hd,
|
|
_1: tl
|
|
};
|
|
}
|
|
|
|
function append(xs, ys)
|
|
{
|
|
// append Strings
|
|
if (typeof xs === 'string')
|
|
{
|
|
return xs + ys;
|
|
}
|
|
|
|
// append Lists
|
|
if (xs.ctor === '[]')
|
|
{
|
|
return ys;
|
|
}
|
|
var root = Cons(xs._0, Nil);
|
|
var curr = root;
|
|
xs = xs._1;
|
|
while (xs.ctor !== '[]')
|
|
{
|
|
curr._1 = Cons(xs._0, Nil);
|
|
xs = xs._1;
|
|
curr = curr._1;
|
|
}
|
|
curr._1 = ys;
|
|
return root;
|
|
}
|
|
|
|
|
|
// CRASHES
|
|
|
|
function crash(moduleName, region)
|
|
{
|
|
return function(message) {
|
|
throw new Error(
|
|
'Ran into a `Debug.crash` in module `' + moduleName + '` ' + regionToString(region) + '\n'
|
|
+ 'The message provided by the code author is:\n\n '
|
|
+ message
|
|
);
|
|
};
|
|
}
|
|
|
|
function crashCase(moduleName, region, value)
|
|
{
|
|
return function(message) {
|
|
throw new Error(
|
|
'Ran into a `Debug.crash` in module `' + moduleName + '`\n\n'
|
|
+ 'This was caused by the `case` expression ' + regionToString(region) + '.\n'
|
|
+ 'One of the branches ended with a crash and the following value got through:\n\n ' + toString(value) + '\n\n'
|
|
+ 'The message provided by the code author is:\n\n '
|
|
+ message
|
|
);
|
|
};
|
|
}
|
|
|
|
function regionToString(region)
|
|
{
|
|
if (region.start.line == region.end.line)
|
|
{
|
|
return 'on line ' + region.start.line;
|
|
}
|
|
return 'between lines ' + region.start.line + ' and ' + region.end.line;
|
|
}
|
|
|
|
|
|
// TO STRING
|
|
|
|
function toString(v)
|
|
{
|
|
var type = typeof v;
|
|
if (type === 'function')
|
|
{
|
|
return '<function>';
|
|
}
|
|
|
|
if (type === 'boolean')
|
|
{
|
|
return v ? 'True' : 'False';
|
|
}
|
|
|
|
if (type === 'number')
|
|
{
|
|
return v + '';
|
|
}
|
|
|
|
if (v instanceof String)
|
|
{
|
|
return '\'' + addSlashes(v, true) + '\'';
|
|
}
|
|
|
|
if (type === 'string')
|
|
{
|
|
return '"' + addSlashes(v, false) + '"';
|
|
}
|
|
|
|
if (v === null)
|
|
{
|
|
return 'null';
|
|
}
|
|
|
|
if (type === 'object' && 'ctor' in v)
|
|
{
|
|
var ctorStarter = v.ctor.substring(0, 5);
|
|
|
|
if (ctorStarter === '_Tupl')
|
|
{
|
|
var output = [];
|
|
for (var k in v)
|
|
{
|
|
if (k === 'ctor') continue;
|
|
output.push(toString(v[k]));
|
|
}
|
|
return '(' + output.join(',') + ')';
|
|
}
|
|
|
|
if (ctorStarter === '_Task')
|
|
{
|
|
return '<task>'
|
|
}
|
|
|
|
if (v.ctor === '_Array')
|
|
{
|
|
var list = _elm_lang$core$Array$toList(v);
|
|
return 'Array.fromList ' + toString(list);
|
|
}
|
|
|
|
if (v.ctor === '<decoder>')
|
|
{
|
|
return '<decoder>';
|
|
}
|
|
|
|
if (v.ctor === '_Process')
|
|
{
|
|
return '<process:' + v.id + '>';
|
|
}
|
|
|
|
if (v.ctor === '::')
|
|
{
|
|
var output = '[' + toString(v._0);
|
|
v = v._1;
|
|
while (v.ctor === '::')
|
|
{
|
|
output += ',' + toString(v._0);
|
|
v = v._1;
|
|
}
|
|
return output + ']';
|
|
}
|
|
|
|
if (v.ctor === '[]')
|
|
{
|
|
return '[]';
|
|
}
|
|
|
|
if (v.ctor === 'Set_elm_builtin')
|
|
{
|
|
return 'Set.fromList ' + toString(_elm_lang$core$Set$toList(v));
|
|
}
|
|
|
|
if (v.ctor === 'RBNode_elm_builtin' || v.ctor === 'RBEmpty_elm_builtin')
|
|
{
|
|
return 'Dict.fromList ' + toString(_elm_lang$core$Dict$toList(v));
|
|
}
|
|
|
|
var output = '';
|
|
for (var i in v)
|
|
{
|
|
if (i === 'ctor') continue;
|
|
var str = toString(v[i]);
|
|
var c0 = str[0];
|
|
var parenless = c0 === '{' || c0 === '(' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0;
|
|
output += ' ' + (parenless ? str : '(' + str + ')');
|
|
}
|
|
return v.ctor + output;
|
|
}
|
|
|
|
if (type === 'object')
|
|
{
|
|
if (v instanceof Date)
|
|
{
|
|
return '<' + v.toString() + '>';
|
|
}
|
|
|
|
if (v.elm_web_socket)
|
|
{
|
|
return '<websocket>';
|
|
}
|
|
|
|
var output = [];
|
|
for (var k in v)
|
|
{
|
|
output.push(k + ' = ' + toString(v[k]));
|
|
}
|
|
if (output.length === 0)
|
|
{
|
|
return '{}';
|
|
}
|
|
return '{ ' + output.join(', ') + ' }';
|
|
}
|
|
|
|
return '<internal structure>';
|
|
}
|
|
|
|
function addSlashes(str, isChar)
|
|
{
|
|
var s = str.replace(/\\/g, '\\\\')
|
|
.replace(/\n/g, '\\n')
|
|
.replace(/\t/g, '\\t')
|
|
.replace(/\r/g, '\\r')
|
|
.replace(/\v/g, '\\v')
|
|
.replace(/\0/g, '\\0');
|
|
if (isChar)
|
|
{
|
|
return s.replace(/\'/g, '\\\'');
|
|
}
|
|
else
|
|
{
|
|
return s.replace(/\"/g, '\\"');
|
|
}
|
|
}
|
|
|
|
|
|
return {
|
|
eq: eq,
|
|
cmp: cmp,
|
|
Tuple0: Tuple0,
|
|
Tuple2: Tuple2,
|
|
chr: chr,
|
|
update: update,
|
|
guid: guid,
|
|
|
|
append: F2(append),
|
|
|
|
crash: crash,
|
|
crashCase: crashCase,
|
|
|
|
toString: toString
|
|
};
|
|
|
|
}();var _elm_lang$core$Basics$never = function (_p0) {
|
|
never:
|
|
while (true) {
|
|
var _p1 = _p0;
|
|
var _v1 = _p1._0;
|
|
_p0 = _v1;
|
|
continue never;
|
|
}
|
|
};
|
|
var _elm_lang$core$Basics$uncurry = F2(
|
|
function (f, _p2) {
|
|
var _p3 = _p2;
|
|
return A2(f, _p3._0, _p3._1);
|
|
});
|
|
var _elm_lang$core$Basics$curry = F3(
|
|
function (f, a, b) {
|
|
return f(
|
|
{ctor: '_Tuple2', _0: a, _1: b});
|
|
});
|
|
var _elm_lang$core$Basics$flip = F3(
|
|
function (f, b, a) {
|
|
return A2(f, a, b);
|
|
});
|
|
var _elm_lang$core$Basics$always = F2(
|
|
function (a, _p4) {
|
|
return a;
|
|
});
|
|
var _elm_lang$core$Basics$identity = function (x) {
|
|
return x;
|
|
};
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['<|'] = F2(
|
|
function (f, x) {
|
|
return f(x);
|
|
});
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['|>'] = F2(
|
|
function (x, f) {
|
|
return f(x);
|
|
});
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['>>'] = F3(
|
|
function (f, g, x) {
|
|
return g(
|
|
f(x));
|
|
});
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['<<'] = F3(
|
|
function (g, f, x) {
|
|
return g(
|
|
f(x));
|
|
});
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['++'] = _elm_lang$core$Native_Utils.append;
|
|
var _elm_lang$core$Basics$toString = _elm_lang$core$Native_Utils.toString;
|
|
var _elm_lang$core$Basics$isInfinite = _elm_lang$core$Native_Basics.isInfinite;
|
|
var _elm_lang$core$Basics$isNaN = _elm_lang$core$Native_Basics.isNaN;
|
|
var _elm_lang$core$Basics$toFloat = _elm_lang$core$Native_Basics.toFloat;
|
|
var _elm_lang$core$Basics$ceiling = _elm_lang$core$Native_Basics.ceiling;
|
|
var _elm_lang$core$Basics$floor = _elm_lang$core$Native_Basics.floor;
|
|
var _elm_lang$core$Basics$truncate = _elm_lang$core$Native_Basics.truncate;
|
|
var _elm_lang$core$Basics$round = _elm_lang$core$Native_Basics.round;
|
|
var _elm_lang$core$Basics$not = _elm_lang$core$Native_Basics.not;
|
|
var _elm_lang$core$Basics$xor = _elm_lang$core$Native_Basics.xor;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['||'] = _elm_lang$core$Native_Basics.or;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['&&'] = _elm_lang$core$Native_Basics.and;
|
|
var _elm_lang$core$Basics$max = _elm_lang$core$Native_Basics.max;
|
|
var _elm_lang$core$Basics$min = _elm_lang$core$Native_Basics.min;
|
|
var _elm_lang$core$Basics$compare = _elm_lang$core$Native_Basics.compare;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['>='] = _elm_lang$core$Native_Basics.ge;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['<='] = _elm_lang$core$Native_Basics.le;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['>'] = _elm_lang$core$Native_Basics.gt;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['<'] = _elm_lang$core$Native_Basics.lt;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['/='] = _elm_lang$core$Native_Basics.neq;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['=='] = _elm_lang$core$Native_Basics.eq;
|
|
var _elm_lang$core$Basics$e = _elm_lang$core$Native_Basics.e;
|
|
var _elm_lang$core$Basics$pi = _elm_lang$core$Native_Basics.pi;
|
|
var _elm_lang$core$Basics$clamp = _elm_lang$core$Native_Basics.clamp;
|
|
var _elm_lang$core$Basics$logBase = _elm_lang$core$Native_Basics.logBase;
|
|
var _elm_lang$core$Basics$abs = _elm_lang$core$Native_Basics.abs;
|
|
var _elm_lang$core$Basics$negate = _elm_lang$core$Native_Basics.negate;
|
|
var _elm_lang$core$Basics$sqrt = _elm_lang$core$Native_Basics.sqrt;
|
|
var _elm_lang$core$Basics$atan2 = _elm_lang$core$Native_Basics.atan2;
|
|
var _elm_lang$core$Basics$atan = _elm_lang$core$Native_Basics.atan;
|
|
var _elm_lang$core$Basics$asin = _elm_lang$core$Native_Basics.asin;
|
|
var _elm_lang$core$Basics$acos = _elm_lang$core$Native_Basics.acos;
|
|
var _elm_lang$core$Basics$tan = _elm_lang$core$Native_Basics.tan;
|
|
var _elm_lang$core$Basics$sin = _elm_lang$core$Native_Basics.sin;
|
|
var _elm_lang$core$Basics$cos = _elm_lang$core$Native_Basics.cos;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['^'] = _elm_lang$core$Native_Basics.exp;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['%'] = _elm_lang$core$Native_Basics.mod;
|
|
var _elm_lang$core$Basics$rem = _elm_lang$core$Native_Basics.rem;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['//'] = _elm_lang$core$Native_Basics.div;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['/'] = _elm_lang$core$Native_Basics.floatDiv;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['*'] = _elm_lang$core$Native_Basics.mul;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['-'] = _elm_lang$core$Native_Basics.sub;
|
|
var _elm_lang$core$Basics_ops = _elm_lang$core$Basics_ops || {};
|
|
_elm_lang$core$Basics_ops['+'] = _elm_lang$core$Native_Basics.add;
|
|
var _elm_lang$core$Basics$toPolar = _elm_lang$core$Native_Basics.toPolar;
|
|
var _elm_lang$core$Basics$fromPolar = _elm_lang$core$Native_Basics.fromPolar;
|
|
var _elm_lang$core$Basics$turns = _elm_lang$core$Native_Basics.turns;
|
|
var _elm_lang$core$Basics$degrees = _elm_lang$core$Native_Basics.degrees;
|
|
var _elm_lang$core$Basics$radians = function (t) {
|
|
return t;
|
|
};
|
|
var _elm_lang$core$Basics$GT = {ctor: 'GT'};
|
|
var _elm_lang$core$Basics$EQ = {ctor: 'EQ'};
|
|
var _elm_lang$core$Basics$LT = {ctor: 'LT'};
|
|
var _elm_lang$core$Basics$JustOneMore = function (a) {
|
|
return {ctor: 'JustOneMore', _0: a};
|
|
};
|
|
var _elm_lang$core$Maybe$withDefault = F2(
|
|
function ($default, maybe) {
|
|
var _p0 = maybe;
|
|
if (_p0.ctor === 'Just') {
|
|
return _p0._0;
|
|
} else {
|
|
return $default;
|
|
}
|
|
});
|
|
var _elm_lang$core$Maybe$Nothing = {ctor: 'Nothing'};
|
|
var _elm_lang$core$Maybe$andThen = F2(
|
|
function (callback, maybeValue) {
|
|
var _p1 = maybeValue;
|
|
if (_p1.ctor === 'Just') {
|
|
return callback(_p1._0);
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
var _elm_lang$core$Maybe$Just = function (a) {
|
|
return {ctor: 'Just', _0: a};
|
|
};
|
|
var _elm_lang$core$Maybe$map = F2(
|
|
function (f, maybe) {
|
|
var _p2 = maybe;
|
|
if (_p2.ctor === 'Just') {
|
|
return _elm_lang$core$Maybe$Just(
|
|
f(_p2._0));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
var _elm_lang$core$Maybe$map2 = F3(
|
|
function (func, ma, mb) {
|
|
var _p3 = {ctor: '_Tuple2', _0: ma, _1: mb};
|
|
if (((_p3.ctor === '_Tuple2') && (_p3._0.ctor === 'Just')) && (_p3._1.ctor === 'Just')) {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A2(func, _p3._0._0, _p3._1._0));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
var _elm_lang$core$Maybe$map3 = F4(
|
|
function (func, ma, mb, mc) {
|
|
var _p4 = {ctor: '_Tuple3', _0: ma, _1: mb, _2: mc};
|
|
if ((((_p4.ctor === '_Tuple3') && (_p4._0.ctor === 'Just')) && (_p4._1.ctor === 'Just')) && (_p4._2.ctor === 'Just')) {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A3(func, _p4._0._0, _p4._1._0, _p4._2._0));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
var _elm_lang$core$Maybe$map4 = F5(
|
|
function (func, ma, mb, mc, md) {
|
|
var _p5 = {ctor: '_Tuple4', _0: ma, _1: mb, _2: mc, _3: md};
|
|
if (((((_p5.ctor === '_Tuple4') && (_p5._0.ctor === 'Just')) && (_p5._1.ctor === 'Just')) && (_p5._2.ctor === 'Just')) && (_p5._3.ctor === 'Just')) {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A4(func, _p5._0._0, _p5._1._0, _p5._2._0, _p5._3._0));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
var _elm_lang$core$Maybe$map5 = F6(
|
|
function (func, ma, mb, mc, md, me) {
|
|
var _p6 = {ctor: '_Tuple5', _0: ma, _1: mb, _2: mc, _3: md, _4: me};
|
|
if ((((((_p6.ctor === '_Tuple5') && (_p6._0.ctor === 'Just')) && (_p6._1.ctor === 'Just')) && (_p6._2.ctor === 'Just')) && (_p6._3.ctor === 'Just')) && (_p6._4.ctor === 'Just')) {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A5(func, _p6._0._0, _p6._1._0, _p6._2._0, _p6._3._0, _p6._4._0));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
//import Native.Utils //
|
|
|
|
var _elm_lang$core$Native_List = function() {
|
|
|
|
var Nil = { ctor: '[]' };
|
|
|
|
function Cons(hd, tl)
|
|
{
|
|
return { ctor: '::', _0: hd, _1: tl };
|
|
}
|
|
|
|
function fromArray(arr)
|
|
{
|
|
var out = Nil;
|
|
for (var i = arr.length; i--; )
|
|
{
|
|
out = Cons(arr[i], out);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function toArray(xs)
|
|
{
|
|
var out = [];
|
|
while (xs.ctor !== '[]')
|
|
{
|
|
out.push(xs._0);
|
|
xs = xs._1;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function foldr(f, b, xs)
|
|
{
|
|
var arr = toArray(xs);
|
|
var acc = b;
|
|
for (var i = arr.length; i--; )
|
|
{
|
|
acc = A2(f, arr[i], acc);
|
|
}
|
|
return acc;
|
|
}
|
|
|
|
function map2(f, xs, ys)
|
|
{
|
|
var arr = [];
|
|
while (xs.ctor !== '[]' && ys.ctor !== '[]')
|
|
{
|
|
arr.push(A2(f, xs._0, ys._0));
|
|
xs = xs._1;
|
|
ys = ys._1;
|
|
}
|
|
return fromArray(arr);
|
|
}
|
|
|
|
function map3(f, xs, ys, zs)
|
|
{
|
|
var arr = [];
|
|
while (xs.ctor !== '[]' && ys.ctor !== '[]' && zs.ctor !== '[]')
|
|
{
|
|
arr.push(A3(f, xs._0, ys._0, zs._0));
|
|
xs = xs._1;
|
|
ys = ys._1;
|
|
zs = zs._1;
|
|
}
|
|
return fromArray(arr);
|
|
}
|
|
|
|
function map4(f, ws, xs, ys, zs)
|
|
{
|
|
var arr = [];
|
|
while ( ws.ctor !== '[]'
|
|
&& xs.ctor !== '[]'
|
|
&& ys.ctor !== '[]'
|
|
&& zs.ctor !== '[]')
|
|
{
|
|
arr.push(A4(f, ws._0, xs._0, ys._0, zs._0));
|
|
ws = ws._1;
|
|
xs = xs._1;
|
|
ys = ys._1;
|
|
zs = zs._1;
|
|
}
|
|
return fromArray(arr);
|
|
}
|
|
|
|
function map5(f, vs, ws, xs, ys, zs)
|
|
{
|
|
var arr = [];
|
|
while ( vs.ctor !== '[]'
|
|
&& ws.ctor !== '[]'
|
|
&& xs.ctor !== '[]'
|
|
&& ys.ctor !== '[]'
|
|
&& zs.ctor !== '[]')
|
|
{
|
|
arr.push(A5(f, vs._0, ws._0, xs._0, ys._0, zs._0));
|
|
vs = vs._1;
|
|
ws = ws._1;
|
|
xs = xs._1;
|
|
ys = ys._1;
|
|
zs = zs._1;
|
|
}
|
|
return fromArray(arr);
|
|
}
|
|
|
|
function sortBy(f, xs)
|
|
{
|
|
return fromArray(toArray(xs).sort(function(a, b) {
|
|
return _elm_lang$core$Native_Utils.cmp(f(a), f(b));
|
|
}));
|
|
}
|
|
|
|
function sortWith(f, xs)
|
|
{
|
|
return fromArray(toArray(xs).sort(function(a, b) {
|
|
var ord = f(a)(b).ctor;
|
|
return ord === 'EQ' ? 0 : ord === 'LT' ? -1 : 1;
|
|
}));
|
|
}
|
|
|
|
return {
|
|
Nil: Nil,
|
|
Cons: Cons,
|
|
cons: F2(Cons),
|
|
toArray: toArray,
|
|
fromArray: fromArray,
|
|
|
|
foldr: F3(foldr),
|
|
|
|
map2: F3(map2),
|
|
map3: F4(map3),
|
|
map4: F5(map4),
|
|
map5: F6(map5),
|
|
sortBy: F2(sortBy),
|
|
sortWith: F2(sortWith)
|
|
};
|
|
|
|
}();var _elm_lang$core$List$sortWith = _elm_lang$core$Native_List.sortWith;
|
|
var _elm_lang$core$List$sortBy = _elm_lang$core$Native_List.sortBy;
|
|
var _elm_lang$core$List$sort = function (xs) {
|
|
return A2(_elm_lang$core$List$sortBy, _elm_lang$core$Basics$identity, xs);
|
|
};
|
|
var _elm_lang$core$List$singleton = function (value) {
|
|
return {
|
|
ctor: '::',
|
|
_0: value,
|
|
_1: {ctor: '[]'}
|
|
};
|
|
};
|
|
var _elm_lang$core$List$drop = F2(
|
|
function (n, list) {
|
|
drop:
|
|
while (true) {
|
|
if (_elm_lang$core$Native_Utils.cmp(n, 0) < 1) {
|
|
return list;
|
|
} else {
|
|
var _p0 = list;
|
|
if (_p0.ctor === '[]') {
|
|
return list;
|
|
} else {
|
|
var _v1 = n - 1,
|
|
_v2 = _p0._1;
|
|
n = _v1;
|
|
list = _v2;
|
|
continue drop;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
var _elm_lang$core$List$map5 = _elm_lang$core$Native_List.map5;
|
|
var _elm_lang$core$List$map4 = _elm_lang$core$Native_List.map4;
|
|
var _elm_lang$core$List$map3 = _elm_lang$core$Native_List.map3;
|
|
var _elm_lang$core$List$map2 = _elm_lang$core$Native_List.map2;
|
|
var _elm_lang$core$List$any = F2(
|
|
function (isOkay, list) {
|
|
any:
|
|
while (true) {
|
|
var _p1 = list;
|
|
if (_p1.ctor === '[]') {
|
|
return false;
|
|
} else {
|
|
if (isOkay(_p1._0)) {
|
|
return true;
|
|
} else {
|
|
var _v4 = isOkay,
|
|
_v5 = _p1._1;
|
|
isOkay = _v4;
|
|
list = _v5;
|
|
continue any;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
var _elm_lang$core$List$all = F2(
|
|
function (isOkay, list) {
|
|
return !A2(
|
|
_elm_lang$core$List$any,
|
|
function (_p2) {
|
|
return !isOkay(_p2);
|
|
},
|
|
list);
|
|
});
|
|
var _elm_lang$core$List$foldr = _elm_lang$core$Native_List.foldr;
|
|
var _elm_lang$core$List$foldl = F3(
|
|
function (func, acc, list) {
|
|
foldl:
|
|
while (true) {
|
|
var _p3 = list;
|
|
if (_p3.ctor === '[]') {
|
|
return acc;
|
|
} else {
|
|
var _v7 = func,
|
|
_v8 = A2(func, _p3._0, acc),
|
|
_v9 = _p3._1;
|
|
func = _v7;
|
|
acc = _v8;
|
|
list = _v9;
|
|
continue foldl;
|
|
}
|
|
}
|
|
});
|
|
var _elm_lang$core$List$length = function (xs) {
|
|
return A3(
|
|
_elm_lang$core$List$foldl,
|
|
F2(
|
|
function (_p4, i) {
|
|
return i + 1;
|
|
}),
|
|
0,
|
|
xs);
|
|
};
|
|
var _elm_lang$core$List$sum = function (numbers) {
|
|
return A3(
|
|
_elm_lang$core$List$foldl,
|
|
F2(
|
|
function (x, y) {
|
|
return x + y;
|
|
}),
|
|
0,
|
|
numbers);
|
|
};
|
|
var _elm_lang$core$List$product = function (numbers) {
|
|
return A3(
|
|
_elm_lang$core$List$foldl,
|
|
F2(
|
|
function (x, y) {
|
|
return x * y;
|
|
}),
|
|
1,
|
|
numbers);
|
|
};
|
|
var _elm_lang$core$List$maximum = function (list) {
|
|
var _p5 = list;
|
|
if (_p5.ctor === '::') {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A3(_elm_lang$core$List$foldl, _elm_lang$core$Basics$max, _p5._0, _p5._1));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
};
|
|
var _elm_lang$core$List$minimum = function (list) {
|
|
var _p6 = list;
|
|
if (_p6.ctor === '::') {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A3(_elm_lang$core$List$foldl, _elm_lang$core$Basics$min, _p6._0, _p6._1));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
};
|
|
var _elm_lang$core$List$member = F2(
|
|
function (x, xs) {
|
|
return A2(
|
|
_elm_lang$core$List$any,
|
|
function (a) {
|
|
return _elm_lang$core$Native_Utils.eq(a, x);
|
|
},
|
|
xs);
|
|
});
|
|
var _elm_lang$core$List$isEmpty = function (xs) {
|
|
var _p7 = xs;
|
|
if (_p7.ctor === '[]') {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
var _elm_lang$core$List$tail = function (list) {
|
|
var _p8 = list;
|
|
if (_p8.ctor === '::') {
|
|
return _elm_lang$core$Maybe$Just(_p8._1);
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
};
|
|
var _elm_lang$core$List$head = function (list) {
|
|
var _p9 = list;
|
|
if (_p9.ctor === '::') {
|
|
return _elm_lang$core$Maybe$Just(_p9._0);
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
};
|
|
var _elm_lang$core$List_ops = _elm_lang$core$List_ops || {};
|
|
_elm_lang$core$List_ops['::'] = _elm_lang$core$Native_List.cons;
|
|
var _elm_lang$core$List$map = F2(
|
|
function (f, xs) {
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
F2(
|
|
function (x, acc) {
|
|
return {
|
|
ctor: '::',
|
|
_0: f(x),
|
|
_1: acc
|
|
};
|
|
}),
|
|
{ctor: '[]'},
|
|
xs);
|
|
});
|
|
var _elm_lang$core$List$filter = F2(
|
|
function (pred, xs) {
|
|
var conditionalCons = F2(
|
|
function (front, back) {
|
|
return pred(front) ? {ctor: '::', _0: front, _1: back} : back;
|
|
});
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
conditionalCons,
|
|
{ctor: '[]'},
|
|
xs);
|
|
});
|
|
var _elm_lang$core$List$maybeCons = F3(
|
|
function (f, mx, xs) {
|
|
var _p10 = f(mx);
|
|
if (_p10.ctor === 'Just') {
|
|
return {ctor: '::', _0: _p10._0, _1: xs};
|
|
} else {
|
|
return xs;
|
|
}
|
|
});
|
|
var _elm_lang$core$List$filterMap = F2(
|
|
function (f, xs) {
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
_elm_lang$core$List$maybeCons(f),
|
|
{ctor: '[]'},
|
|
xs);
|
|
});
|
|
var _elm_lang$core$List$reverse = function (list) {
|
|
return A3(
|
|
_elm_lang$core$List$foldl,
|
|
F2(
|
|
function (x, y) {
|
|
return {ctor: '::', _0: x, _1: y};
|
|
}),
|
|
{ctor: '[]'},
|
|
list);
|
|
};
|
|
var _elm_lang$core$List$scanl = F3(
|
|
function (f, b, xs) {
|
|
var scan1 = F2(
|
|
function (x, accAcc) {
|
|
var _p11 = accAcc;
|
|
if (_p11.ctor === '::') {
|
|
return {
|
|
ctor: '::',
|
|
_0: A2(f, x, _p11._0),
|
|
_1: accAcc
|
|
};
|
|
} else {
|
|
return {ctor: '[]'};
|
|
}
|
|
});
|
|
return _elm_lang$core$List$reverse(
|
|
A3(
|
|
_elm_lang$core$List$foldl,
|
|
scan1,
|
|
{
|
|
ctor: '::',
|
|
_0: b,
|
|
_1: {ctor: '[]'}
|
|
},
|
|
xs));
|
|
});
|
|
var _elm_lang$core$List$append = F2(
|
|
function (xs, ys) {
|
|
var _p12 = ys;
|
|
if (_p12.ctor === '[]') {
|
|
return xs;
|
|
} else {
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
F2(
|
|
function (x, y) {
|
|
return {ctor: '::', _0: x, _1: y};
|
|
}),
|
|
ys,
|
|
xs);
|
|
}
|
|
});
|
|
var _elm_lang$core$List$concat = function (lists) {
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
_elm_lang$core$List$append,
|
|
{ctor: '[]'},
|
|
lists);
|
|
};
|
|
var _elm_lang$core$List$concatMap = F2(
|
|
function (f, list) {
|
|
return _elm_lang$core$List$concat(
|
|
A2(_elm_lang$core$List$map, f, list));
|
|
});
|
|
var _elm_lang$core$List$partition = F2(
|
|
function (pred, list) {
|
|
var step = F2(
|
|
function (x, _p13) {
|
|
var _p14 = _p13;
|
|
var _p16 = _p14._0;
|
|
var _p15 = _p14._1;
|
|
return pred(x) ? {
|
|
ctor: '_Tuple2',
|
|
_0: {ctor: '::', _0: x, _1: _p16},
|
|
_1: _p15
|
|
} : {
|
|
ctor: '_Tuple2',
|
|
_0: _p16,
|
|
_1: {ctor: '::', _0: x, _1: _p15}
|
|
};
|
|
});
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
step,
|
|
{
|
|
ctor: '_Tuple2',
|
|
_0: {ctor: '[]'},
|
|
_1: {ctor: '[]'}
|
|
},
|
|
list);
|
|
});
|
|
var _elm_lang$core$List$unzip = function (pairs) {
|
|
var step = F2(
|
|
function (_p18, _p17) {
|
|
var _p19 = _p18;
|
|
var _p20 = _p17;
|
|
return {
|
|
ctor: '_Tuple2',
|
|
_0: {ctor: '::', _0: _p19._0, _1: _p20._0},
|
|
_1: {ctor: '::', _0: _p19._1, _1: _p20._1}
|
|
};
|
|
});
|
|
return A3(
|
|
_elm_lang$core$List$foldr,
|
|
step,
|
|
{
|
|
ctor: '_Tuple2',
|
|
_0: {ctor: '[]'},
|
|
_1: {ctor: '[]'}
|
|
},
|
|
pairs);
|
|
};
|
|
var _elm_lang$core$List$intersperse = F2(
|
|
function (sep, xs) {
|
|
var _p21 = xs;
|
|
if (_p21.ctor === '[]') {
|
|
return {ctor: '[]'};
|
|
} else {
|
|
var step = F2(
|
|
function (x, rest) {
|
|
return {
|
|
ctor: '::',
|
|
_0: sep,
|
|
_1: {ctor: '::', _0: x, _1: rest}
|
|
};
|
|
});
|
|
var spersed = A3(
|
|
_elm_lang$core$List$foldr,
|
|
step,
|
|
{ctor: '[]'},
|
|
_p21._1);
|
|
return {ctor: '::', _0: _p21._0, _1: spersed};
|
|
}
|
|
});
|
|
var _elm_lang$core$List$takeReverse = F3(
|
|
function (n, list, taken) {
|
|
takeReverse:
|
|
while (true) {
|
|
if (_elm_lang$core$Native_Utils.cmp(n, 0) < 1) {
|
|
return taken;
|
|
} else {
|
|
var _p22 = list;
|
|
if (_p22.ctor === '[]') {
|
|
return taken;
|
|
} else {
|
|
var _v23 = n - 1,
|
|
_v24 = _p22._1,
|
|
_v25 = {ctor: '::', _0: _p22._0, _1: taken};
|
|
n = _v23;
|
|
list = _v24;
|
|
taken = _v25;
|
|
continue takeReverse;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
var _elm_lang$core$List$takeTailRec = F2(
|
|
function (n, list) {
|
|
return _elm_lang$core$List$reverse(
|
|
A3(
|
|
_elm_lang$core$List$takeReverse,
|
|
n,
|
|
list,
|
|
{ctor: '[]'}));
|
|
});
|
|
var _elm_lang$core$List$takeFast = F3(
|
|
function (ctr, n, list) {
|
|
if (_elm_lang$core$Native_Utils.cmp(n, 0) < 1) {
|
|
return {ctor: '[]'};
|
|
} else {
|
|
var _p23 = {ctor: '_Tuple2', _0: n, _1: list};
|
|
_v26_5:
|
|
do {
|
|
_v26_1:
|
|
do {
|
|
if (_p23.ctor === '_Tuple2') {
|
|
if (_p23._1.ctor === '[]') {
|
|
return list;
|
|
} else {
|
|
if (_p23._1._1.ctor === '::') {
|
|
switch (_p23._0) {
|
|
case 1:
|
|
break _v26_1;
|
|
case 2:
|
|
return {
|
|
ctor: '::',
|
|
_0: _p23._1._0,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p23._1._1._0,
|
|
_1: {ctor: '[]'}
|
|
}
|
|
};
|
|
case 3:
|
|
if (_p23._1._1._1.ctor === '::') {
|
|
return {
|
|
ctor: '::',
|
|
_0: _p23._1._0,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p23._1._1._0,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p23._1._1._1._0,
|
|
_1: {ctor: '[]'}
|
|
}
|
|
}
|
|
};
|
|
} else {
|
|
break _v26_5;
|
|
}
|
|
default:
|
|
if ((_p23._1._1._1.ctor === '::') && (_p23._1._1._1._1.ctor === '::')) {
|
|
var _p28 = _p23._1._1._1._0;
|
|
var _p27 = _p23._1._1._0;
|
|
var _p26 = _p23._1._0;
|
|
var _p25 = _p23._1._1._1._1._0;
|
|
var _p24 = _p23._1._1._1._1._1;
|
|
return (_elm_lang$core$Native_Utils.cmp(ctr, 1000) > 0) ? {
|
|
ctor: '::',
|
|
_0: _p26,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p27,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p28,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p25,
|
|
_1: A2(_elm_lang$core$List$takeTailRec, n - 4, _p24)
|
|
}
|
|
}
|
|
}
|
|
} : {
|
|
ctor: '::',
|
|
_0: _p26,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p27,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p28,
|
|
_1: {
|
|
ctor: '::',
|
|
_0: _p25,
|
|
_1: A3(_elm_lang$core$List$takeFast, ctr + 1, n - 4, _p24)
|
|
}
|
|
}
|
|
}
|
|
};
|
|
} else {
|
|
break _v26_5;
|
|
}
|
|
}
|
|
} else {
|
|
if (_p23._0 === 1) {
|
|
break _v26_1;
|
|
} else {
|
|
break _v26_5;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
break _v26_5;
|
|
}
|
|
} while(false);
|
|
return {
|
|
ctor: '::',
|
|
_0: _p23._1._0,
|
|
_1: {ctor: '[]'}
|
|
};
|
|
} while(false);
|
|
return list;
|
|
}
|
|
});
|
|
var _elm_lang$core$List$take = F2(
|
|
function (n, list) {
|
|
return A3(_elm_lang$core$List$takeFast, 0, n, list);
|
|
});
|
|
var _elm_lang$core$List$repeatHelp = F3(
|
|
function (result, n, value) {
|
|
repeatHelp:
|
|
while (true) {
|
|
if (_elm_lang$core$Native_Utils.cmp(n, 0) < 1) {
|
|
return result;
|
|
} else {
|
|
var _v27 = {ctor: '::', _0: value, _1: result},
|
|
_v28 = n - 1,
|
|
_v29 = value;
|
|
result = _v27;
|
|
n = _v28;
|
|
value = _v29;
|
|
continue repeatHelp;
|
|
}
|
|
}
|
|
});
|
|
var _elm_lang$core$List$repeat = F2(
|
|
function (n, value) {
|
|
return A3(
|
|
_elm_lang$core$List$repeatHelp,
|
|
{ctor: '[]'},
|
|
n,
|
|
value);
|
|
});
|
|
var _elm_lang$core$List$rangeHelp = F3(
|
|
function (lo, hi, list) {
|
|
rangeHelp:
|
|
while (true) {
|
|
if (_elm_lang$core$Native_Utils.cmp(lo, hi) < 1) {
|
|
var _v30 = lo,
|
|
_v31 = hi - 1,
|
|
_v32 = {ctor: '::', _0: hi, _1: list};
|
|
lo = _v30;
|
|
hi = _v31;
|
|
list = _v32;
|
|
continue rangeHelp;
|
|
} else {
|
|
return list;
|
|
}
|
|
}
|
|
});
|
|
var _elm_lang$core$List$range = F2(
|
|
function (lo, hi) {
|
|
return A3(
|
|
_elm_lang$core$List$rangeHelp,
|
|
lo,
|
|
hi,
|
|
{ctor: '[]'});
|
|
});
|
|
var _elm_lang$core$List$indexedMap = F2(
|
|
function (f, xs) {
|
|
return A3(
|
|
_elm_lang$core$List$map2,
|
|
f,
|
|
A2(
|
|
_elm_lang$core$List$range,
|
|
0,
|
|
_elm_lang$core$List$length(xs) - 1),
|
|
xs);
|
|
});
|
|
//import Native.Utils //
|
|
|
|
var _elm_lang$core$Native_Char = function() {
|
|
|
|
return {
|
|
fromCode: function(c) { return _elm_lang$core$Native_Utils.chr(String.fromCharCode(c)); },
|
|
toCode: function(c) { return c.charCodeAt(0); },
|
|
toUpper: function(c) { return _elm_lang$core$Native_Utils.chr(c.toUpperCase()); },
|
|
toLower: function(c) { return _elm_lang$core$Native_Utils.chr(c.toLowerCase()); },
|
|
toLocaleUpper: function(c) { return _elm_lang$core$Native_Utils.chr(c.toLocaleUpperCase()); },
|
|
toLocaleLower: function(c) { return _elm_lang$core$Native_Utils.chr(c.toLocaleLowerCase()); }
|
|
};
|
|
|
|
}();var _elm_lang$core$Char$fromCode = _elm_lang$core$Native_Char.fromCode;
|
|
var _elm_lang$core$Char$toCode = _elm_lang$core$Native_Char.toCode;
|
|
var _elm_lang$core$Char$toLocaleLower = _elm_lang$core$Native_Char.toLocaleLower;
|
|
var _elm_lang$core$Char$toLocaleUpper = _elm_lang$core$Native_Char.toLocaleUpper;
|
|
var _elm_lang$core$Char$toLower = _elm_lang$core$Native_Char.toLower;
|
|
var _elm_lang$core$Char$toUpper = _elm_lang$core$Native_Char.toUpper;
|
|
var _elm_lang$core$Char$isBetween = F3(
|
|
function (low, high, $char) {
|
|
var code = _elm_lang$core$Char$toCode($char);
|
|
return (_elm_lang$core$Native_Utils.cmp(
|
|
code,
|
|
_elm_lang$core$Char$toCode(low)) > -1) && (_elm_lang$core$Native_Utils.cmp(
|
|
code,
|
|
_elm_lang$core$Char$toCode(high)) < 1);
|
|
});
|
|
var _elm_lang$core$Char$isUpper = A2(
|
|
_elm_lang$core$Char$isBetween,
|
|
_elm_lang$core$Native_Utils.chr('A'),
|
|
_elm_lang$core$Native_Utils.chr('Z'));
|
|
var _elm_lang$core$Char$isLower = A2(
|
|
_elm_lang$core$Char$isBetween,
|
|
_elm_lang$core$Native_Utils.chr('a'),
|
|
_elm_lang$core$Native_Utils.chr('z'));
|
|
var _elm_lang$core$Char$isDigit = A2(
|
|
_elm_lang$core$Char$isBetween,
|
|
_elm_lang$core$Native_Utils.chr('0'),
|
|
_elm_lang$core$Native_Utils.chr('9'));
|
|
var _elm_lang$core$Char$isOctDigit = A2(
|
|
_elm_lang$core$Char$isBetween,
|
|
_elm_lang$core$Native_Utils.chr('0'),
|
|
_elm_lang$core$Native_Utils.chr('7'));
|
|
var _elm_lang$core$Char$isHexDigit = function ($char) {
|
|
return _elm_lang$core$Char$isDigit($char) || (A3(
|
|
_elm_lang$core$Char$isBetween,
|
|
_elm_lang$core$Native_Utils.chr('a'),
|
|
_elm_lang$core$Native_Utils.chr('f'),
|
|
$char) || A3(
|
|
_elm_lang$core$Char$isBetween,
|
|
_elm_lang$core$Native_Utils.chr('A'),
|
|
_elm_lang$core$Native_Utils.chr('F'),
|
|
$char));
|
|
};
|
|
//import Native.Utils //
|
|
|
|
var _elm_lang$core$Native_Scheduler = function() {
|
|
|
|
var MAX_STEPS = 10000;
|
|
|
|
|
|
// TASKS
|
|
|
|
function succeed(value)
|
|
{
|
|
return {
|
|
ctor: '_Task_succeed',
|
|
value: value
|
|
};
|
|
}
|
|
|
|
function fail(error)
|
|
{
|
|
return {
|
|
ctor: '_Task_fail',
|
|
value: error
|
|
};
|
|
}
|
|
|
|
function nativeBinding(callback)
|
|
{
|
|
return {
|
|
ctor: '_Task_nativeBinding',
|
|
callback: callback,
|
|
cancel: null
|
|
};
|
|
}
|
|
|
|
function andThen(callback, task)
|
|
{
|
|
return {
|
|
ctor: '_Task_andThen',
|
|
callback: callback,
|
|
task: task
|
|
};
|
|
}
|
|
|
|
function onError(callback, task)
|
|
{
|
|
return {
|
|
ctor: '_Task_onError',
|
|
callback: callback,
|
|
task: task
|
|
};
|
|
}
|
|
|
|
function receive(callback)
|
|
{
|
|
return {
|
|
ctor: '_Task_receive',
|
|
callback: callback
|
|
};
|
|
}
|
|
|
|
|
|
// PROCESSES
|
|
|
|
function rawSpawn(task)
|
|
{
|
|
var process = {
|
|
ctor: '_Process',
|
|
id: _elm_lang$core$Native_Utils.guid(),
|
|
root: task,
|
|
stack: null,
|
|
mailbox: []
|
|
};
|
|
|
|
enqueue(process);
|
|
|
|
return process;
|
|
}
|
|
|
|
function spawn(task)
|
|
{
|
|
return nativeBinding(function(callback) {
|
|
var process = rawSpawn(task);
|
|
callback(succeed(process));
|
|
});
|
|
}
|
|
|
|
function rawSend(process, msg)
|
|
{
|
|
process.mailbox.push(msg);
|
|
enqueue(process);
|
|
}
|
|
|
|
function send(process, msg)
|
|
{
|
|
return nativeBinding(function(callback) {
|
|
rawSend(process, msg);
|
|
callback(succeed(_elm_lang$core$Native_Utils.Tuple0));
|
|
});
|
|
}
|
|
|
|
function kill(process)
|
|
{
|
|
return nativeBinding(function(callback) {
|
|
var root = process.root;
|
|
if (root.ctor === '_Task_nativeBinding' && root.cancel)
|
|
{
|
|
root.cancel();
|
|
}
|
|
|
|
process.root = null;
|
|
|
|
callback(succeed(_elm_lang$core$Native_Utils.Tuple0));
|
|
});
|
|
}
|
|
|
|
function sleep(time)
|
|
{
|
|
return nativeBinding(function(callback) {
|
|
var id = setTimeout(function() {
|
|
callback(succeed(_elm_lang$core$Native_Utils.Tuple0));
|
|
}, time);
|
|
|
|
return function() { clearTimeout(id); };
|
|
});
|
|
}
|
|
|
|
|
|
// STEP PROCESSES
|
|
|
|
function step(numSteps, process)
|
|
{
|
|
while (numSteps < MAX_STEPS)
|
|
{
|
|
var ctor = process.root.ctor;
|
|
|
|
if (ctor === '_Task_succeed')
|
|
{
|
|
while (process.stack && process.stack.ctor === '_Task_onError')
|
|
{
|
|
process.stack = process.stack.rest;
|
|
}
|
|
if (process.stack === null)
|
|
{
|
|
break;
|
|
}
|
|
process.root = process.stack.callback(process.root.value);
|
|
process.stack = process.stack.rest;
|
|
++numSteps;
|
|
continue;
|
|
}
|
|
|
|
if (ctor === '_Task_fail')
|
|
{
|
|
while (process.stack && process.stack.ctor === '_Task_andThen')
|
|
{
|
|
process.stack = process.stack.rest;
|
|
}
|
|
if (process.stack === null)
|
|
{
|
|
break;
|
|
}
|
|
process.root = process.stack.callback(process.root.value);
|
|
process.stack = process.stack.rest;
|
|
++numSteps;
|
|
continue;
|
|
}
|
|
|
|
if (ctor === '_Task_andThen')
|
|
{
|
|
process.stack = {
|
|
ctor: '_Task_andThen',
|
|
callback: process.root.callback,
|
|
rest: process.stack
|
|
};
|
|
process.root = process.root.task;
|
|
++numSteps;
|
|
continue;
|
|
}
|
|
|
|
if (ctor === '_Task_onError')
|
|
{
|
|
process.stack = {
|
|
ctor: '_Task_onError',
|
|
callback: process.root.callback,
|
|
rest: process.stack
|
|
};
|
|
process.root = process.root.task;
|
|
++numSteps;
|
|
continue;
|
|
}
|
|
|
|
if (ctor === '_Task_nativeBinding')
|
|
{
|
|
process.root.cancel = process.root.callback(function(newRoot) {
|
|
process.root = newRoot;
|
|
enqueue(process);
|
|
});
|
|
|
|
break;
|
|
}
|
|
|
|
if (ctor === '_Task_receive')
|
|
{
|
|
var mailbox = process.mailbox;
|
|
if (mailbox.length === 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
process.root = process.root.callback(mailbox.shift());
|
|
++numSteps;
|
|
continue;
|
|
}
|
|
|
|
throw new Error(ctor);
|
|
}
|
|
|
|
if (numSteps < MAX_STEPS)
|
|
{
|
|
return numSteps + 1;
|
|
}
|
|
enqueue(process);
|
|
|
|
return numSteps;
|
|
}
|
|
|
|
|
|
// WORK QUEUE
|
|
|
|
var working = false;
|
|
var workQueue = [];
|
|
|
|
function enqueue(process)
|
|
{
|
|
workQueue.push(process);
|
|
|
|
if (!working)
|
|
{
|
|
setTimeout(work, 0);
|
|
working = true;
|
|
}
|
|
}
|
|
|
|
function work()
|
|
{
|
|
var numSteps = 0;
|
|
var process;
|
|
while (numSteps < MAX_STEPS && (process = workQueue.shift()))
|
|
{
|
|
if (process.root)
|
|
{
|
|
numSteps = step(numSteps, process);
|
|
}
|
|
}
|
|
if (!process)
|
|
{
|
|
working = false;
|
|
return;
|
|
}
|
|
setTimeout(work, 0);
|
|
}
|
|
|
|
|
|
return {
|
|
succeed: succeed,
|
|
fail: fail,
|
|
nativeBinding: nativeBinding,
|
|
andThen: F2(andThen),
|
|
onError: F2(onError),
|
|
receive: receive,
|
|
|
|
spawn: spawn,
|
|
kill: kill,
|
|
sleep: sleep,
|
|
send: F2(send),
|
|
|
|
rawSpawn: rawSpawn,
|
|
rawSend: rawSend
|
|
};
|
|
|
|
}();//import //
|
|
|
|
var _elm_lang$core$Native_Platform = function() {
|
|
|
|
|
|
// PROGRAMS
|
|
|
|
function program(impl)
|
|
{
|
|
return function(flagDecoder)
|
|
{
|
|
return function(object, moduleName)
|
|
{
|
|
object['worker'] = function worker(flags)
|
|
{
|
|
if (typeof flags !== 'undefined')
|
|
{
|
|
throw new Error(
|
|
'The `' + moduleName + '` module does not need flags.\n'
|
|
+ 'Call ' + moduleName + '.worker() with no arguments and you should be all set!'
|
|
);
|
|
}
|
|
|
|
return initialize(
|
|
impl.init,
|
|
impl.update,
|
|
impl.subscriptions,
|
|
renderer
|
|
);
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
function programWithFlags(impl)
|
|
{
|
|
return function(flagDecoder)
|
|
{
|
|
return function(object, moduleName)
|
|
{
|
|
object['worker'] = function worker(flags)
|
|
{
|
|
if (typeof flagDecoder === 'undefined')
|
|
{
|
|
throw new Error(
|
|
'Are you trying to sneak a Never value into Elm? Trickster!\n'
|
|
+ 'It looks like ' + moduleName + '.main is defined with `programWithFlags` but has type `Program Never`.\n'
|
|
+ 'Use `program` instead if you do not want flags.'
|
|
);
|
|
}
|
|
|
|
var result = A2(_elm_lang$core$Native_Json.run, flagDecoder, flags);
|
|
if (result.ctor === 'Err')
|
|
{
|
|
throw new Error(
|
|
moduleName + '.worker(...) was called with an unexpected argument.\n'
|
|
+ 'I tried to convert it to an Elm value, but ran into this problem:\n\n'
|
|
+ result._0
|
|
);
|
|
}
|
|
|
|
return initialize(
|
|
impl.init(result._0),
|
|
impl.update,
|
|
impl.subscriptions,
|
|
renderer
|
|
);
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
function renderer(enqueue, _)
|
|
{
|
|
return function(_) {};
|
|
}
|
|
|
|
|
|
// HTML TO PROGRAM
|
|
|
|
function htmlToProgram(vnode)
|
|
{
|
|
var emptyBag = batch(_elm_lang$core$Native_List.Nil);
|
|
var noChange = _elm_lang$core$Native_Utils.Tuple2(
|
|
_elm_lang$core$Native_Utils.Tuple0,
|
|
emptyBag
|
|
);
|
|
|
|
return _elm_lang$virtual_dom$VirtualDom$program({
|
|
init: noChange,
|
|
view: function(model) { return main; },
|
|
update: F2(function(msg, model) { return noChange; }),
|
|
subscriptions: function (model) { return emptyBag; }
|
|
});
|
|
}
|
|
|
|
|
|
// INITIALIZE A PROGRAM
|
|
|
|
function initialize(init, update, subscriptions, renderer)
|
|
{
|
|
// ambient state
|
|
var managers = {};
|
|
var updateView;
|
|
|
|
// init and update state in main process
|
|
var initApp = _elm_lang$core$Native_Scheduler.nativeBinding(function(callback) {
|
|
var model = init._0;
|
|
updateView = renderer(enqueue, model);
|
|
var cmds = init._1;
|
|
var subs = subscriptions(model);
|
|
dispatchEffects(managers, cmds, subs);
|
|
callback(_elm_lang$core$Native_Scheduler.succeed(model));
|
|
});
|
|
|
|
function onMessage(msg, model)
|
|
{
|
|
return _elm_lang$core$Native_Scheduler.nativeBinding(function(callback) {
|
|
var results = A2(update, msg, model);
|
|
model = results._0;
|
|
updateView(model);
|
|
var cmds = results._1;
|
|
var subs = subscriptions(model);
|
|
dispatchEffects(managers, cmds, subs);
|
|
callback(_elm_lang$core$Native_Scheduler.succeed(model));
|
|
});
|
|
}
|
|
|
|
var mainProcess = spawnLoop(initApp, onMessage);
|
|
|
|
function enqueue(msg)
|
|
{
|
|
_elm_lang$core$Native_Scheduler.rawSend(mainProcess, msg);
|
|
}
|
|
|
|
var ports = setupEffects(managers, enqueue);
|
|
|
|
return ports ? { ports: ports } : {};
|
|
}
|
|
|
|
|
|
// EFFECT MANAGERS
|
|
|
|
var effectManagers = {};
|
|
|
|
function setupEffects(managers, callback)
|
|
{
|
|
var ports;
|
|
|
|
// setup all necessary effect managers
|
|
for (var key in effectManagers)
|
|
{
|
|
var manager = effectManagers[key];
|
|
|
|
if (manager.isForeign)
|
|
{
|
|
ports = ports || {};
|
|
ports[key] = manager.tag === 'cmd'
|
|
? setupOutgoingPort(key)
|
|
: setupIncomingPort(key, callback);
|
|
}
|
|
|
|
managers[key] = makeManager(manager, callback);
|
|
}
|
|
|
|
return ports;
|
|
}
|
|
|
|
function makeManager(info, callback)
|
|
{
|
|
var router = {
|
|
main: callback,
|
|
self: undefined
|
|
};
|
|
|
|
var tag = info.tag;
|
|
var onEffects = info.onEffects;
|
|
var onSelfMsg = info.onSelfMsg;
|
|
|
|
function onMessage(msg, state)
|
|
{
|
|
if (msg.ctor === 'self')
|
|
{
|
|
return A3(onSelfMsg, router, msg._0, state);
|
|
}
|
|
|
|
var fx = msg._0;
|
|
switch (tag)
|
|
{
|
|
case 'cmd':
|
|
return A3(onEffects, router, fx.cmds, state);
|
|
|
|
case 'sub':
|
|
return A3(onEffects, router, fx.subs, state);
|
|
|
|
case 'fx':
|
|
return A4(onEffects, router, fx.cmds, fx.subs, state);
|
|
}
|
|
}
|
|
|
|
var process = spawnLoop(info.init, onMessage);
|
|
router.self = process;
|
|
return process;
|
|
}
|
|
|
|
function sendToApp(router, msg)
|
|
{
|
|
return _elm_lang$core$Native_Scheduler.nativeBinding(function(callback)
|
|
{
|
|
router.main(msg);
|
|
callback(_elm_lang$core$Native_Scheduler.succeed(_elm_lang$core$Native_Utils.Tuple0));
|
|
});
|
|
}
|
|
|
|
function sendToSelf(router, msg)
|
|
{
|
|
return A2(_elm_lang$core$Native_Scheduler.send, router.self, {
|
|
ctor: 'self',
|
|
_0: msg
|
|
});
|
|
}
|
|
|
|
|
|
// HELPER for STATEFUL LOOPS
|
|
|
|
function spawnLoop(init, onMessage)
|
|
{
|
|
var andThen = _elm_lang$core$Native_Scheduler.andThen;
|
|
|
|
function loop(state)
|
|
{
|
|
var handleMsg = _elm_lang$core$Native_Scheduler.receive(function(msg) {
|
|
return onMessage(msg, state);
|
|
});
|
|
return A2(andThen, loop, handleMsg);
|
|
}
|
|
|
|
var task = A2(andThen, loop, init);
|
|
|
|
return _elm_lang$core$Native_Scheduler.rawSpawn(task);
|
|
}
|
|
|
|
|
|
// BAGS
|
|
|
|
function leaf(home)
|
|
{
|
|
return function(value)
|
|
{
|
|
return {
|
|
type: 'leaf',
|
|
home: home,
|
|
value: value
|
|
};
|
|
};
|
|
}
|
|
|
|
function batch(list)
|
|
{
|
|
return {
|
|
type: 'node',
|
|
branches: list
|
|
};
|
|
}
|
|
|
|
function map(tagger, bag)
|
|
{
|
|
return {
|
|
type: 'map',
|
|
tagger: tagger,
|
|
tree: bag
|
|
}
|
|
}
|
|
|
|
|
|
// PIPE BAGS INTO EFFECT MANAGERS
|
|
|
|
function dispatchEffects(managers, cmdBag, subBag)
|
|
{
|
|
var effectsDict = {};
|
|
gatherEffects(true, cmdBag, effectsDict, null);
|
|
gatherEffects(false, subBag, effectsDict, null);
|
|
|
|
for (var home in managers)
|
|
{
|
|
var fx = home in effectsDict
|
|
? effectsDict[home]
|
|
: {
|
|
cmds: _elm_lang$core$Native_List.Nil,
|
|
subs: _elm_lang$core$Native_List.Nil
|
|
};
|
|
|
|
_elm_lang$core$Native_Scheduler.rawSend(managers[home], { ctor: 'fx', _0: fx });
|
|
}
|
|
}
|
|
|
|
function gatherEffects(isCmd, bag, effectsDict, taggers)
|
|
{
|
|
switch (bag.type)
|
|
{
|
|
case 'leaf':
|
|
var home = bag.home;
|
|
var effect = toEffect(isCmd, home, taggers, bag.value);
|
|
effectsDict[home] = insert(isCmd, effect, effectsDict[home]);
|
|
return;
|
|
|
|
case 'node':
|
|
var list = bag.branches;
|
|
while (list.ctor !== '[]')
|
|
{
|
|
gatherEffects(isCmd, list._0, effectsDict, taggers);
|
|
list = list._1;
|
|
}
|
|
return;
|
|
|
|
case 'map':
|
|
gatherEffects(isCmd, bag.tree, effectsDict, {
|
|
tagger: bag.tagger,
|
|
rest: taggers
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
|
|
function toEffect(isCmd, home, taggers, value)
|
|
{
|
|
function applyTaggers(x)
|
|
{
|
|
var temp = taggers;
|
|
while (temp)
|
|
{
|
|
x = temp.tagger(x);
|
|
temp = temp.rest;
|
|
}
|
|
return x;
|
|
}
|
|
|
|
var map = isCmd
|
|
? effectManagers[home].cmdMap
|
|
: effectManagers[home].subMap;
|
|
|
|
return A2(map, applyTaggers, value)
|
|
}
|
|
|
|
function insert(isCmd, newEffect, effects)
|
|
{
|
|
effects = effects || {
|
|
cmds: _elm_lang$core$Native_List.Nil,
|
|
subs: _elm_lang$core$Native_List.Nil
|
|
};
|
|
if (isCmd)
|
|
{
|
|
effects.cmds = _elm_lang$core$Native_List.Cons(newEffect, effects.cmds);
|
|
return effects;
|
|
}
|
|
effects.subs = _elm_lang$core$Native_List.Cons(newEffect, effects.subs);
|
|
return effects;
|
|
}
|
|
|
|
|
|
// PORTS
|
|
|
|
function checkPortName(name)
|
|
{
|
|
if (name in effectManagers)
|
|
{
|
|
throw new Error('There can only be one port named `' + name + '`, but your program has multiple.');
|
|
}
|
|
}
|
|
|
|
|
|
// OUTGOING PORTS
|
|
|
|
function outgoingPort(name, converter)
|
|
{
|
|
checkPortName(name);
|
|
effectManagers[name] = {
|
|
tag: 'cmd',
|
|
cmdMap: outgoingPortMap,
|
|
converter: converter,
|
|
isForeign: true
|
|
};
|
|
return leaf(name);
|
|
}
|
|
|
|
var outgoingPortMap = F2(function cmdMap(tagger, value) {
|
|
return value;
|
|
});
|
|
|
|
function setupOutgoingPort(name)
|
|
{
|
|
var subs = [];
|
|
var converter = effectManagers[name].converter;
|
|
|
|
// CREATE MANAGER
|
|
|
|
var init = _elm_lang$core$Native_Scheduler.succeed(null);
|
|
|
|
function onEffects(router, cmdList, state)
|
|
{
|
|
while (cmdList.ctor !== '[]')
|
|
{
|
|
// grab a separate reference to subs in case unsubscribe is called
|
|
var currentSubs = subs;
|
|
var value = converter(cmdList._0);
|
|
for (var i = 0; i < currentSubs.length; i++)
|
|
{
|
|
currentSubs[i](value);
|
|
}
|
|
cmdList = cmdList._1;
|
|
}
|
|
return init;
|
|
}
|
|
|
|
effectManagers[name].init = init;
|
|
effectManagers[name].onEffects = F3(onEffects);
|
|
|
|
// PUBLIC API
|
|
|
|
function subscribe(callback)
|
|
{
|
|
subs.push(callback);
|
|
}
|
|
|
|
function unsubscribe(callback)
|
|
{
|
|
// copy subs into a new array in case unsubscribe is called within a
|
|
// subscribed callback
|
|
subs = subs.slice();
|
|
var index = subs.indexOf(callback);
|
|
if (index >= 0)
|
|
{
|
|
subs.splice(index, 1);
|
|
}
|
|
}
|
|
|
|
return {
|
|
subscribe: subscribe,
|
|
unsubscribe: unsubscribe
|
|
};
|
|
}
|
|
|
|
|
|
// INCOMING PORTS
|
|
|
|
function incomingPort(name, converter)
|
|
{
|
|
checkPortName(name);
|
|
effectManagers[name] = {
|
|
tag: 'sub',
|
|
subMap: incomingPortMap,
|
|
converter: converter,
|
|
isForeign: true
|
|
};
|
|
return leaf(name);
|
|
}
|
|
|
|
var incomingPortMap = F2(function subMap(tagger, finalTagger)
|
|
{
|
|
return function(value)
|
|
{
|
|
return tagger(finalTagger(value));
|
|
};
|
|
});
|
|
|
|
function setupIncomingPort(name, callback)
|
|
{
|
|
var sentBeforeInit = [];
|
|
var subs = _elm_lang$core$Native_List.Nil;
|
|
var converter = effectManagers[name].converter;
|
|
var currentOnEffects = preInitOnEffects;
|
|
var currentSend = preInitSend;
|
|
|
|
// CREATE MANAGER
|
|
|
|
var init = _elm_lang$core$Native_Scheduler.succeed(null);
|
|
|
|
function preInitOnEffects(router, subList, state)
|
|
{
|
|
var postInitResult = postInitOnEffects(router, subList, state);
|
|
|
|
for(var i = 0; i < sentBeforeInit.length; i++)
|
|
{
|
|
postInitSend(sentBeforeInit[i]);
|
|
}
|
|
|
|
sentBeforeInit = null; // to release objects held in queue
|
|
currentSend = postInitSend;
|
|
currentOnEffects = postInitOnEffects;
|
|
return postInitResult;
|
|
}
|
|
|
|
function postInitOnEffects(router, subList, state)
|
|
{
|
|
subs = subList;
|
|
return init;
|
|
}
|
|
|
|
function onEffects(router, subList, state)
|
|
{
|
|
return currentOnEffects(router, subList, state);
|
|
}
|
|
|
|
effectManagers[name].init = init;
|
|
effectManagers[name].onEffects = F3(onEffects);
|
|
|
|
// PUBLIC API
|
|
|
|
function preInitSend(value)
|
|
{
|
|
sentBeforeInit.push(value);
|
|
}
|
|
|
|
function postInitSend(value)
|
|
{
|
|
var temp = subs;
|
|
while (temp.ctor !== '[]')
|
|
{
|
|
callback(temp._0(value));
|
|
temp = temp._1;
|
|
}
|
|
}
|
|
|
|
function send(incomingValue)
|
|
{
|
|
var result = A2(_elm_lang$core$Json_Decode$decodeValue, converter, incomingValue);
|
|
if (result.ctor === 'Err')
|
|
{
|
|
throw new Error('Trying to send an unexpected type of value through port `' + name + '`:\n' + result._0);
|
|
}
|
|
|
|
currentSend(result._0);
|
|
}
|
|
|
|
return { send: send };
|
|
}
|
|
|
|
return {
|
|
// routers
|
|
sendToApp: F2(sendToApp),
|
|
sendToSelf: F2(sendToSelf),
|
|
|
|
// global setup
|
|
effectManagers: effectManagers,
|
|
outgoingPort: outgoingPort,
|
|
incomingPort: incomingPort,
|
|
|
|
htmlToProgram: htmlToProgram,
|
|
program: program,
|
|
programWithFlags: programWithFlags,
|
|
initialize: initialize,
|
|
|
|
// effect bags
|
|
leaf: leaf,
|
|
batch: batch,
|
|
map: F2(map)
|
|
};
|
|
|
|
}();
|
|
var _elm_lang$core$Platform_Cmd$batch = _elm_lang$core$Native_Platform.batch;
|
|
var _elm_lang$core$Platform_Cmd$none = _elm_lang$core$Platform_Cmd$batch(
|
|
{ctor: '[]'});
|
|
var _elm_lang$core$Platform_Cmd_ops = _elm_lang$core$Platform_Cmd_ops || {};
|
|
_elm_lang$core$Platform_Cmd_ops['!'] = F2(
|
|
function (model, commands) {
|
|
return {
|
|
ctor: '_Tuple2',
|
|
_0: model,
|
|
_1: _elm_lang$core$Platform_Cmd$batch(commands)
|
|
};
|
|
});
|
|
var _elm_lang$core$Platform_Cmd$map = _elm_lang$core$Native_Platform.map;
|
|
var _elm_lang$core$Platform_Cmd$Cmd = {ctor: 'Cmd'};
|
|
var _elm_lang$core$Platform_Sub$batch = _elm_lang$core$Native_Platform.batch;
|
|
var _elm_lang$core$Platform_Sub$none = _elm_lang$core$Platform_Sub$batch(
|
|
{ctor: '[]'});
|
|
var _elm_lang$core$Platform_Sub$map = _elm_lang$core$Native_Platform.map;
|
|
var _elm_lang$core$Platform_Sub$Sub = {ctor: 'Sub'};
|
|
var _elm_lang$core$Platform$hack = _elm_lang$core$Native_Scheduler.succeed;
|
|
var _elm_lang$core$Platform$sendToSelf = _elm_lang$core$Native_Platform.sendToSelf;
|
|
var _elm_lang$core$Platform$sendToApp = _elm_lang$core$Native_Platform.sendToApp;
|
|
var _elm_lang$core$Platform$programWithFlags = _elm_lang$core$Native_Platform.programWithFlags;
|
|
var _elm_lang$core$Platform$program = _elm_lang$core$Native_Platform.program;
|
|
var _elm_lang$core$Platform$Program = {ctor: 'Program'};
|
|
var _elm_lang$core$Platform$Task = {ctor: 'Task'};
|
|
var _elm_lang$core$Platform$ProcessId = {ctor: 'ProcessId'};
|
|
var _elm_lang$core$Platform$Router = {ctor: 'Router'};
|
|
var _elm_lang$core$Result$toMaybe = function (result) {
|
|
var _p0 = result;
|
|
if (_p0.ctor === 'Ok') {
|
|
return _elm_lang$core$Maybe$Just(_p0._0);
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
};
|
|
var _elm_lang$core$Result$withDefault = F2(
|
|
function (def, result) {
|
|
var _p1 = result;
|
|
if (_p1.ctor === 'Ok') {
|
|
return _p1._0;
|
|
} else {
|
|
return def;
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$Err = function (a) {
|
|
return {ctor: 'Err', _0: a};
|
|
};
|
|
var _elm_lang$core$Result$andThen = F2(
|
|
function (callback, result) {
|
|
var _p2 = result;
|
|
if (_p2.ctor === 'Ok') {
|
|
return callback(_p2._0);
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p2._0);
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$Ok = function (a) {
|
|
return {ctor: 'Ok', _0: a};
|
|
};
|
|
var _elm_lang$core$Result$map = F2(
|
|
function (func, ra) {
|
|
var _p3 = ra;
|
|
if (_p3.ctor === 'Ok') {
|
|
return _elm_lang$core$Result$Ok(
|
|
func(_p3._0));
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p3._0);
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$map2 = F3(
|
|
function (func, ra, rb) {
|
|
var _p4 = {ctor: '_Tuple2', _0: ra, _1: rb};
|
|
if (_p4._0.ctor === 'Ok') {
|
|
if (_p4._1.ctor === 'Ok') {
|
|
return _elm_lang$core$Result$Ok(
|
|
A2(func, _p4._0._0, _p4._1._0));
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p4._1._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p4._0._0);
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$map3 = F4(
|
|
function (func, ra, rb, rc) {
|
|
var _p5 = {ctor: '_Tuple3', _0: ra, _1: rb, _2: rc};
|
|
if (_p5._0.ctor === 'Ok') {
|
|
if (_p5._1.ctor === 'Ok') {
|
|
if (_p5._2.ctor === 'Ok') {
|
|
return _elm_lang$core$Result$Ok(
|
|
A3(func, _p5._0._0, _p5._1._0, _p5._2._0));
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p5._2._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p5._1._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p5._0._0);
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$map4 = F5(
|
|
function (func, ra, rb, rc, rd) {
|
|
var _p6 = {ctor: '_Tuple4', _0: ra, _1: rb, _2: rc, _3: rd};
|
|
if (_p6._0.ctor === 'Ok') {
|
|
if (_p6._1.ctor === 'Ok') {
|
|
if (_p6._2.ctor === 'Ok') {
|
|
if (_p6._3.ctor === 'Ok') {
|
|
return _elm_lang$core$Result$Ok(
|
|
A4(func, _p6._0._0, _p6._1._0, _p6._2._0, _p6._3._0));
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p6._3._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p6._2._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p6._1._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p6._0._0);
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$map5 = F6(
|
|
function (func, ra, rb, rc, rd, re) {
|
|
var _p7 = {ctor: '_Tuple5', _0: ra, _1: rb, _2: rc, _3: rd, _4: re};
|
|
if (_p7._0.ctor === 'Ok') {
|
|
if (_p7._1.ctor === 'Ok') {
|
|
if (_p7._2.ctor === 'Ok') {
|
|
if (_p7._3.ctor === 'Ok') {
|
|
if (_p7._4.ctor === 'Ok') {
|
|
return _elm_lang$core$Result$Ok(
|
|
A5(func, _p7._0._0, _p7._1._0, _p7._2._0, _p7._3._0, _p7._4._0));
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p7._4._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p7._3._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p7._2._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p7._1._0);
|
|
}
|
|
} else {
|
|
return _elm_lang$core$Result$Err(_p7._0._0);
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$mapError = F2(
|
|
function (f, result) {
|
|
var _p8 = result;
|
|
if (_p8.ctor === 'Ok') {
|
|
return _elm_lang$core$Result$Ok(_p8._0);
|
|
} else {
|
|
return _elm_lang$core$Result$Err(
|
|
f(_p8._0));
|
|
}
|
|
});
|
|
var _elm_lang$core$Result$fromMaybe = F2(
|
|
function (err, maybe) {
|
|
var _p9 = maybe;
|
|
if (_p9.ctor === 'Just') {
|
|
return _elm_lang$core$Result$Ok(_p9._0);
|
|
} else {
|
|
return _elm_lang$core$Result$Err(err);
|
|
}
|
|
});
|
|
//import Native.Utils //
|
|
|
|
var _elm_lang$core$Native_Debug = function() {
|
|
|
|
function log(tag, value)
|
|
{
|
|
var msg = tag + ': ' + _elm_lang$core$Native_Utils.toString(value);
|
|
var process = process || {};
|
|
if (process.stdout)
|
|
{
|
|
process.stdout.write(msg);
|
|
}
|
|
else
|
|
{
|
|
console.log(msg);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
function crash(message)
|
|
{
|
|
throw new Error(message);
|
|
}
|
|
|
|
return {
|
|
crash: crash,
|
|
log: F2(log)
|
|
};
|
|
|
|
}();//import Maybe, Native.List, Native.Utils, Result //
|
|
|
|
var _elm_lang$core$Native_String = function() {
|
|
|
|
function isEmpty(str)
|
|
{
|
|
return str.length === 0;
|
|
}
|
|
function cons(chr, str)
|
|
{
|
|
return chr + str;
|
|
}
|
|
function uncons(str)
|
|
{
|
|
var hd = str[0];
|
|
if (hd)
|
|
{
|
|
return _elm_lang$core$Maybe$Just(_elm_lang$core$Native_Utils.Tuple2(_elm_lang$core$Native_Utils.chr(hd), str.slice(1)));
|
|
}
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
function append(a, b)
|
|
{
|
|
return a + b;
|
|
}
|
|
function concat(strs)
|
|
{
|
|
return _elm_lang$core$Native_List.toArray(strs).join('');
|
|
}
|
|
function length(str)
|
|
{
|
|
return str.length;
|
|
}
|
|
function map(f, str)
|
|
{
|
|
var out = str.split('');
|
|
for (var i = out.length; i--; )
|
|
{
|
|
out[i] = f(_elm_lang$core$Native_Utils.chr(out[i]));
|
|
}
|
|
return out.join('');
|
|
}
|
|
function filter(pred, str)
|
|
{
|
|
return str.split('').map(_elm_lang$core$Native_Utils.chr).filter(pred).join('');
|
|
}
|
|
function reverse(str)
|
|
{
|
|
return str.split('').reverse().join('');
|
|
}
|
|
function foldl(f, b, str)
|
|
{
|
|
var len = str.length;
|
|
for (var i = 0; i < len; ++i)
|
|
{
|
|
b = A2(f, _elm_lang$core$Native_Utils.chr(str[i]), b);
|
|
}
|
|
return b;
|
|
}
|
|
function foldr(f, b, str)
|
|
{
|
|
for (var i = str.length; i--; )
|
|
{
|
|
b = A2(f, _elm_lang$core$Native_Utils.chr(str[i]), b);
|
|
}
|
|
return b;
|
|
}
|
|
function split(sep, str)
|
|
{
|
|
return _elm_lang$core$Native_List.fromArray(str.split(sep));
|
|
}
|
|
function join(sep, strs)
|
|
{
|
|
return _elm_lang$core$Native_List.toArray(strs).join(sep);
|
|
}
|
|
function repeat(n, str)
|
|
{
|
|
var result = '';
|
|
while (n > 0)
|
|
{
|
|
if (n & 1)
|
|
{
|
|
result += str;
|
|
}
|
|
n >>= 1, str += str;
|
|
}
|
|
return result;
|
|
}
|
|
function slice(start, end, str)
|
|
{
|
|
return str.slice(start, end);
|
|
}
|
|
function left(n, str)
|
|
{
|
|
return n < 1 ? '' : str.slice(0, n);
|
|
}
|
|
function right(n, str)
|
|
{
|
|
return n < 1 ? '' : str.slice(-n);
|
|
}
|
|
function dropLeft(n, str)
|
|
{
|
|
return n < 1 ? str : str.slice(n);
|
|
}
|
|
function dropRight(n, str)
|
|
{
|
|
return n < 1 ? str : str.slice(0, -n);
|
|
}
|
|
function pad(n, chr, str)
|
|
{
|
|
var half = (n - str.length) / 2;
|
|
return repeat(Math.ceil(half), chr) + str + repeat(half | 0, chr);
|
|
}
|
|
function padRight(n, chr, str)
|
|
{
|
|
return str + repeat(n - str.length, chr);
|
|
}
|
|
function padLeft(n, chr, str)
|
|
{
|
|
return repeat(n - str.length, chr) + str;
|
|
}
|
|
|
|
function trim(str)
|
|
{
|
|
return str.trim();
|
|
}
|
|
function trimLeft(str)
|
|
{
|
|
return str.replace(/^\s+/, '');
|
|
}
|
|
function trimRight(str)
|
|
{
|
|
return str.replace(/\s+$/, '');
|
|
}
|
|
|
|
function words(str)
|
|
{
|
|
return _elm_lang$core$Native_List.fromArray(str.trim().split(/\s+/g));
|
|
}
|
|
function lines(str)
|
|
{
|
|
return _elm_lang$core$Native_List.fromArray(str.split(/\r\n|\r|\n/g));
|
|
}
|
|
|
|
function toUpper(str)
|
|
{
|
|
return str.toUpperCase();
|
|
}
|
|
function toLower(str)
|
|
{
|
|
return str.toLowerCase();
|
|
}
|
|
|
|
function any(pred, str)
|
|
{
|
|
for (var i = str.length; i--; )
|
|
{
|
|
if (pred(_elm_lang$core$Native_Utils.chr(str[i])))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function all(pred, str)
|
|
{
|
|
for (var i = str.length; i--; )
|
|
{
|
|
if (!pred(_elm_lang$core$Native_Utils.chr(str[i])))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function contains(sub, str)
|
|
{
|
|
return str.indexOf(sub) > -1;
|
|
}
|
|
function startsWith(sub, str)
|
|
{
|
|
return str.indexOf(sub) === 0;
|
|
}
|
|
function endsWith(sub, str)
|
|
{
|
|
return str.length >= sub.length &&
|
|
str.lastIndexOf(sub) === str.length - sub.length;
|
|
}
|
|
function indexes(sub, str)
|
|
{
|
|
var subLen = sub.length;
|
|
|
|
if (subLen < 1)
|
|
{
|
|
return _elm_lang$core$Native_List.Nil;
|
|
}
|
|
|
|
var i = 0;
|
|
var is = [];
|
|
|
|
while ((i = str.indexOf(sub, i)) > -1)
|
|
{
|
|
is.push(i);
|
|
i = i + subLen;
|
|
}
|
|
|
|
return _elm_lang$core$Native_List.fromArray(is);
|
|
}
|
|
|
|
|
|
function toInt(s)
|
|
{
|
|
var len = s.length;
|
|
|
|
// if empty
|
|
if (len === 0)
|
|
{
|
|
return intErr(s);
|
|
}
|
|
|
|
// if hex
|
|
var c = s[0];
|
|
if (c === '0' && s[1] === 'x')
|
|
{
|
|
for (var i = 2; i < len; ++i)
|
|
{
|
|
var c = s[i];
|
|
if (('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f'))
|
|
{
|
|
continue;
|
|
}
|
|
return intErr(s);
|
|
}
|
|
return _elm_lang$core$Result$Ok(parseInt(s, 16));
|
|
}
|
|
|
|
// is decimal
|
|
if (c > '9' || (c < '0' && c !== '-' && c !== '+'))
|
|
{
|
|
return intErr(s);
|
|
}
|
|
for (var i = 1; i < len; ++i)
|
|
{
|
|
var c = s[i];
|
|
if (c < '0' || '9' < c)
|
|
{
|
|
return intErr(s);
|
|
}
|
|
}
|
|
|
|
return _elm_lang$core$Result$Ok(parseInt(s, 10));
|
|
}
|
|
|
|
function intErr(s)
|
|
{
|
|
return _elm_lang$core$Result$Err("could not convert string '" + s + "' to an Int");
|
|
}
|
|
|
|
|
|
function toFloat(s)
|
|
{
|
|
// check if it is a hex, octal, or binary number
|
|
if (s.length === 0 || /[\sxbo]/.test(s))
|
|
{
|
|
return floatErr(s);
|
|
}
|
|
var n = +s;
|
|
// faster isNaN check
|
|
return n === n ? _elm_lang$core$Result$Ok(n) : floatErr(s);
|
|
}
|
|
|
|
function floatErr(s)
|
|
{
|
|
return _elm_lang$core$Result$Err("could not convert string '" + s + "' to a Float");
|
|
}
|
|
|
|
|
|
function toList(str)
|
|
{
|
|
return _elm_lang$core$Native_List.fromArray(str.split('').map(_elm_lang$core$Native_Utils.chr));
|
|
}
|
|
function fromList(chars)
|
|
{
|
|
return _elm_lang$core$Native_List.toArray(chars).join('');
|
|
}
|
|
|
|
return {
|
|
isEmpty: isEmpty,
|
|
cons: F2(cons),
|
|
uncons: uncons,
|
|
append: F2(append),
|
|
concat: concat,
|
|
length: length,
|
|
map: F2(map),
|
|
filter: F2(filter),
|
|
reverse: reverse,
|
|
foldl: F3(foldl),
|
|
foldr: F3(foldr),
|
|
|
|
split: F2(split),
|
|
join: F2(join),
|
|
repeat: F2(repeat),
|
|
|
|
slice: F3(slice),
|
|
left: F2(left),
|
|
right: F2(right),
|
|
dropLeft: F2(dropLeft),
|
|
dropRight: F2(dropRight),
|
|
|
|
pad: F3(pad),
|
|
padLeft: F3(padLeft),
|
|
padRight: F3(padRight),
|
|
|
|
trim: trim,
|
|
trimLeft: trimLeft,
|
|
trimRight: trimRight,
|
|
|
|
words: words,
|
|
lines: lines,
|
|
|
|
toUpper: toUpper,
|
|
toLower: toLower,
|
|
|
|
any: F2(any),
|
|
all: F2(all),
|
|
|
|
contains: F2(contains),
|
|
startsWith: F2(startsWith),
|
|
endsWith: F2(endsWith),
|
|
indexes: F2(indexes),
|
|
|
|
toInt: toInt,
|
|
toFloat: toFloat,
|
|
toList: toList,
|
|
fromList: fromList
|
|
};
|
|
|
|
}();
|
|
var _elm_lang$core$String$fromList = _elm_lang$core$Native_String.fromList;
|
|
var _elm_lang$core$String$toList = _elm_lang$core$Native_String.toList;
|
|
var _elm_lang$core$String$toFloat = _elm_lang$core$Native_String.toFloat;
|
|
var _elm_lang$core$String$toInt = _elm_lang$core$Native_String.toInt;
|
|
var _elm_lang$core$String$indices = _elm_lang$core$Native_String.indexes;
|
|
var _elm_lang$core$String$indexes = _elm_lang$core$Native_String.indexes;
|
|
var _elm_lang$core$String$endsWith = _elm_lang$core$Native_String.endsWith;
|
|
var _elm_lang$core$String$startsWith = _elm_lang$core$Native_String.startsWith;
|
|
var _elm_lang$core$String$contains = _elm_lang$core$Native_String.contains;
|
|
var _elm_lang$core$String$all = _elm_lang$core$Native_String.all;
|
|
var _elm_lang$core$String$any = _elm_lang$core$Native_String.any;
|
|
var _elm_lang$core$String$toLower = _elm_lang$core$Native_String.toLower;
|
|
var _elm_lang$core$String$toUpper = _elm_lang$core$Native_String.toUpper;
|
|
var _elm_lang$core$String$lines = _elm_lang$core$Native_String.lines;
|
|
var _elm_lang$core$String$words = _elm_lang$core$Native_String.words;
|
|
var _elm_lang$core$String$trimRight = _elm_lang$core$Native_String.trimRight;
|
|
var _elm_lang$core$String$trimLeft = _elm_lang$core$Native_String.trimLeft;
|
|
var _elm_lang$core$String$trim = _elm_lang$core$Native_String.trim;
|
|
var _elm_lang$core$String$padRight = _elm_lang$core$Native_String.padRight;
|
|
var _elm_lang$core$String$padLeft = _elm_lang$core$Native_String.padLeft;
|
|
var _elm_lang$core$String$pad = _elm_lang$core$Native_String.pad;
|
|
var _elm_lang$core$String$dropRight = _elm_lang$core$Native_String.dropRight;
|
|
var _elm_lang$core$String$dropLeft = _elm_lang$core$Native_String.dropLeft;
|
|
var _elm_lang$core$String$right = _elm_lang$core$Native_String.right;
|
|
var _elm_lang$core$String$left = _elm_lang$core$Native_String.left;
|
|
var _elm_lang$core$String$slice = _elm_lang$core$Native_String.slice;
|
|
var _elm_lang$core$String$repeat = _elm_lang$core$Native_String.repeat;
|
|
var _elm_lang$core$String$join = _elm_lang$core$Native_String.join;
|
|
var _elm_lang$core$String$split = _elm_lang$core$Native_String.split;
|
|
var _elm_lang$core$String$foldr = _elm_lang$core$Native_String.foldr;
|
|
var _elm_lang$core$String$foldl = _elm_lang$core$Native_String.foldl;
|
|
var _elm_lang$core$String$reverse = _elm_lang$core$Native_String.reverse;
|
|
var _elm_lang$core$String$filter = _elm_lang$core$Native_String.filter;
|
|
var _elm_lang$core$String$map = _elm_lang$core$Native_String.map;
|
|
var _elm_lang$core$String$length = _elm_lang$core$Native_String.length;
|
|
var _elm_lang$core$String$concat = _elm_lang$core$Native_String.concat;
|
|
var _elm_lang$core$String$append = _elm_lang$core$Native_String.append;
|
|
var _elm_lang$core$String$uncons = _elm_lang$core$Native_String.uncons;
|
|
var _elm_lang$core$String$cons = _elm_lang$core$Native_String.cons;
|
|
var _elm_lang$core$String$fromChar = function ($char) {
|
|
return A2(_elm_lang$core$String$cons, $char, '');
|
|
};
|
|
var _elm_lang$core$String$isEmpty = _elm_lang$core$Native_String.isEmpty;
|
|
var _elm_lang$core$Debug$crash = _elm_lang$core$Native_Debug.crash;
|
|
var _elm_lang$core$Debug$log = _elm_lang$core$Native_Debug.log;
|
|
var _elm_lang$core$Tuple$mapSecond = F2(
|
|
function (func, _p0) {
|
|
var _p1 = _p0;
|
|
return {
|
|
ctor: '_Tuple2',
|
|
_0: _p1._0,
|
|
_1: func(_p1._1)
|
|
};
|
|
});
|
|
var _elm_lang$core$Tuple$mapFirst = F2(
|
|
function (func, _p2) {
|
|
var _p3 = _p2;
|
|
return {
|
|
ctor: '_Tuple2',
|
|
_0: func(_p3._0),
|
|
_1: _p3._1
|
|
};
|
|
});
|
|
var _elm_lang$core$Tuple$second = function (_p4) {
|
|
var _p5 = _p4;
|
|
return _p5._1;
|
|
};
|
|
var _elm_lang$core$Tuple$first = function (_p6) {
|
|
var _p7 = _p6;
|
|
return _p7._0;
|
|
};
|
|
var _user$project$AllYourBase$toBase = function (base) {
|
|
var unfold = F2(
|
|
function (f, b) {
|
|
var _p0 = f(b);
|
|
if (_p0.ctor === 'Just') {
|
|
return {
|
|
ctor: '::',
|
|
_0: _p0._0._0,
|
|
_1: A2(unfold, f, _p0._0._1)
|
|
};
|
|
} else {
|
|
return {ctor: '[]'};
|
|
}
|
|
});
|
|
var swap = function (_p1) {
|
|
var _p2 = _p1;
|
|
return {ctor: '_Tuple2', _0: _p2._1, _1: _p2._0};
|
|
};
|
|
var divMod = F2(
|
|
function (a, b) {
|
|
return {
|
|
ctor: '_Tuple2',
|
|
_0: (a / b) | 0,
|
|
_1: A2(_elm_lang$core$Basics_ops['%'], a, b)
|
|
};
|
|
});
|
|
var f = function (x) {
|
|
var _p3 = x;
|
|
if (_p3 === 0) {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
} else {
|
|
return _elm_lang$core$Maybe$Just(
|
|
swap(
|
|
A2(divMod, x, base)));
|
|
}
|
|
};
|
|
return function (_p4) {
|
|
return _elm_lang$core$List$reverse(
|
|
A2(unfold, f, _p4));
|
|
};
|
|
};
|
|
var _user$project$AllYourBase$fromBase = function (base) {
|
|
var f = F2(
|
|
function (x, m) {
|
|
var _p5 = m;
|
|
if (_p5.ctor === 'Nothing') {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
} else {
|
|
return ((_elm_lang$core$Native_Utils.cmp(x, 0) > -1) && (_elm_lang$core$Native_Utils.cmp(x, base) < 0)) ? _elm_lang$core$Maybe$Just((_p5._0 * base) + x) : _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
return A2(
|
|
_elm_lang$core$List$foldl,
|
|
f,
|
|
_elm_lang$core$Maybe$Just(0));
|
|
};
|
|
var _user$project$AllYourBase$rebase = F3(
|
|
function (inBase, digits, outBase) {
|
|
var _p6 = A2(_user$project$AllYourBase$fromBase, inBase, digits);
|
|
if (_p6.ctor === 'Just') {
|
|
return _elm_lang$core$Maybe$Just(
|
|
A2(_user$project$AllYourBase$toBase, outBase, _p6._0));
|
|
} else {
|
|
return _elm_lang$core$Maybe$Nothing;
|
|
}
|
|
});
|
|
var Elm = {};
|
|
Elm['AllYourBase'] = Elm['AllYourBase'] || {};
|
|
if (typeof _user$project$AllYourBase$main !== 'undefined') {
|
|
_user$project$AllYourBase$main(Elm['AllYourBase'], 'AllYourBase', undefined);
|
|
}
|
|
|
|
if (typeof define === "function" && define['amd'])
|
|
{
|
|
define([], function() { return Elm; });
|
|
return;
|
|
}
|
|
|
|
if (typeof module === "object")
|
|
{
|
|
module['exports'] = Elm;
|
|
return;
|
|
}
|
|
|
|
var globalElm = this['Elm'];
|
|
if (typeof globalElm === "undefined")
|
|
{
|
|
this['Elm'] = Elm;
|
|
return;
|
|
}
|
|
|
|
for (var publicModule in Elm)
|
|
{
|
|
if (publicModule in globalElm)
|
|
{
|
|
throw new Error('There are two Elm modules called `' + publicModule + '` on this page! Rename one of them.');
|
|
}
|
|
globalElm[publicModule] = Elm[publicModule];
|
|
}
|
|
|
|
}).call(this);
|
|
</script></head><body><script type="text/javascript">Elm.AllYourBase.fullscreen()</script></body></html> |