Created
August 12, 2017 18:03
-
-
Save sudhirvkumar/2f356f32b6d5b100c2f064cf1c7be0d0 to your computer and use it in GitHub Desktop.
tryHalogen bytton generated code
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var console = { | |
| log: function(s) { | |
| var text = document.createTextNode(s); | |
| var div = document.createElement("div"); | |
| div.appendChild(text); | |
| var cons = document.getElementById("console"); | |
| cons && cons.appendChild(div); | |
| } | |
| }; | |
| window.onerror = function(e) { | |
| console.log(e); | |
| return true; | |
| }; | |
| // Generated by psc-bundle 0.11.6 | |
| var PS = {}; | |
| (function(exports) { | |
| "use strict"; | |
| exports.arrayMap = function (f) { | |
| return function (arr) { | |
| var l = arr.length; | |
| var result = new Array(l); | |
| for (var i = 0; i < l; i++) { | |
| result[i] = f(arr[i]); | |
| } | |
| return result; | |
| }; | |
| }; | |
| })(PS["Data.Functor"] = PS["Data.Functor"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // | A `Semigroupoid` is similar to a [`Category`](#category) but does not | |
| // | require an identity element `id`, just composable morphisms. | |
| // | | |
| // | `Semigroupoid`s must satisfy the following law: | |
| // | | |
| // | - Associativity: `p <<< (q <<< r) = (p <<< q) <<< r` | |
| // | | |
| // | One example of a `Semigroupoid` is the function type constructor `(->)`, | |
| // | with `(<<<)` defined as function composition. | |
| var Semigroupoid = function (compose) { | |
| this.compose = compose; | |
| }; | |
| var semigroupoidFn = new Semigroupoid(function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return f(g(x)); | |
| }; | |
| }; | |
| }); | |
| var compose = function (dict) { | |
| return dict.compose; | |
| }; | |
| // | Forwards composition, or `compose` with its arguments reversed. | |
| var composeFlipped = function (dictSemigroupoid) { | |
| return function (f) { | |
| return function (g) { | |
| return compose(dictSemigroupoid)(g)(f); | |
| }; | |
| }; | |
| }; | |
| exports["Semigroupoid"] = Semigroupoid; | |
| exports["compose"] = compose; | |
| exports["composeFlipped"] = composeFlipped; | |
| exports["semigroupoidFn"] = semigroupoidFn; | |
| })(PS["Control.Semigroupoid"] = PS["Control.Semigroupoid"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| // | `Category`s consist of objects and composable morphisms between them, and | |
| // | as such are [`Semigroupoids`](#semigroupoid), but unlike `semigroupoids` | |
| // | must have an identity element. | |
| // | | |
| // | Instances must satisfy the following law in addition to the | |
| // | `Semigroupoid` law: | |
| // | | |
| // | - Identity: `id <<< p = p <<< id = p` | |
| var Category = function (Semigroupoid0, id) { | |
| this.Semigroupoid0 = Semigroupoid0; | |
| this.id = id; | |
| }; | |
| var id = function (dict) { | |
| return dict.id; | |
| }; | |
| var categoryFn = new Category(function () { | |
| return Control_Semigroupoid.semigroupoidFn; | |
| }, function (x) { | |
| return x; | |
| }); | |
| exports["Category"] = Category; | |
| exports["id"] = id; | |
| exports["categoryFn"] = categoryFn; | |
| })(PS["Control.Category"] = PS["Control.Category"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| // | The `on` function is used to change the domain of a binary operator. | |
| // | | |
| // | For example, we can create a function which compares two records based on the values of their `x` properties: | |
| // | | |
| // | ```purescript | |
| // | compareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering | |
| // | compareX = compare `on` _.x | |
| // | ``` | |
| var on = function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return function (y) { | |
| return f(g(x))(g(y)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Flips the order of the arguments to a function of two arguments. | |
| // | | |
| // | ```purescript | |
| // | flip const 1 2 = const 2 1 = 2 | |
| // | ``` | |
| var flip = function (f) { | |
| return function (b) { | |
| return function (a) { | |
| return f(a)(b); | |
| }; | |
| }; | |
| }; | |
| // | Returns its first argument and ignores its second. | |
| // | | |
| // | ```purescript | |
| // | const 1 "hello" = 1 | |
| // | ``` | |
| var $$const = function (a) { | |
| return function (v) { | |
| return a; | |
| }; | |
| }; | |
| // | Applies an argument to a function. This is primarily used as the `(#)` | |
| // | operator, which allows parentheses to be ommitted in some cases, or as a | |
| // | natural way to apply a value to a chain of composed functions. | |
| var applyFlipped = function (x) { | |
| return function (f) { | |
| return f(x); | |
| }; | |
| }; | |
| // | Applies a function to an argument. This is primarily used as the operator | |
| // | `($)` which allows parentheses to be omitted in some cases, or as a | |
| // | natural way to apply a chain of composed functions to a value. | |
| var apply = function (f) { | |
| return function (x) { | |
| return f(x); | |
| }; | |
| }; | |
| exports["apply"] = apply; | |
| exports["applyFlipped"] = applyFlipped; | |
| exports["const"] = $$const; | |
| exports["flip"] = flip; | |
| exports["on"] = on; | |
| })(PS["Data.Function"] = PS["Data.Function"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.unit = {}; | |
| })(PS["Data.Unit"] = PS["Data.Unit"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.showIntImpl = function (n) { | |
| return n.toString(); | |
| }; | |
| exports.showNumberImpl = function (n) { | |
| var str = n.toString(); | |
| return isNaN(str + ".0") ? str : str + ".0"; | |
| }; | |
| exports.showCharImpl = function (c) { | |
| var code = c.charCodeAt(0); | |
| if (code < 0x20 || code === 0x7F) { | |
| switch (c) { | |
| case "\x07": return "'\\a'"; | |
| case "\b": return "'\\b'"; | |
| case "\f": return "'\\f'"; | |
| case "\n": return "'\\n'"; | |
| case "\r": return "'\\r'"; | |
| case "\t": return "'\\t'"; | |
| case "\v": return "'\\v'"; | |
| } | |
| return "'\\" + code.toString(10) + "'"; | |
| } | |
| return c === "'" || c === "\\" ? "'\\" + c + "'" : "'" + c + "'"; | |
| }; | |
| exports.showStringImpl = function (s) { | |
| var l = s.length; | |
| return "\"" + s.replace( | |
| /[\0-\x1F\x7F"\\]/g, // eslint-disable-line no-control-regex | |
| function (c, i) { | |
| switch (c) { | |
| case "\"": | |
| case "\\": | |
| return "\\" + c; | |
| case "\x07": return "\\a"; | |
| case "\b": return "\\b"; | |
| case "\f": return "\\f"; | |
| case "\n": return "\\n"; | |
| case "\r": return "\\r"; | |
| case "\t": return "\\t"; | |
| case "\v": return "\\v"; | |
| } | |
| var k = i + 1; | |
| var empty = k < l && s[k] >= "0" && s[k] <= "9" ? "\\&" : ""; | |
| return "\\" + c.charCodeAt(0).toString(10) + empty; | |
| } | |
| ) + "\""; | |
| }; | |
| exports.showArrayImpl = function (f) { | |
| return function (xs) { | |
| var ss = []; | |
| for (var i = 0, l = xs.length; i < l; i++) { | |
| ss[i] = f(xs[i]); | |
| } | |
| return "[" + ss.join(",") + "]"; | |
| }; | |
| }; | |
| })(PS["Data.Show"] = PS["Data.Show"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Show"]; | |
| // | The `Show` type class represents those types which can be converted into | |
| // | a human-readable `String` representation. | |
| // | | |
| // | While not required, it is recommended that for any expression `x`, the | |
| // | string `show x` be executable PureScript code which evaluates to the same | |
| // | value as the expression `x`. | |
| var Show = function (show) { | |
| this.show = show; | |
| }; | |
| var showString = new Show($foreign.showStringImpl); | |
| var showNumber = new Show($foreign.showNumberImpl); | |
| var showInt = new Show($foreign.showIntImpl); | |
| var showChar = new Show($foreign.showCharImpl); | |
| var showBoolean = new Show(function (v) { | |
| if (v) { | |
| return "true"; | |
| }; | |
| if (!v) { | |
| return "false"; | |
| }; | |
| throw new Error("Failed pattern match at Data.Show line 12, column 1 - line 12, column 37: " + [ v.constructor.name ]); | |
| }); | |
| var show = function (dict) { | |
| return dict.show; | |
| }; | |
| var showArray = function (dictShow) { | |
| return new Show($foreign.showArrayImpl(show(dictShow))); | |
| }; | |
| exports["Show"] = Show; | |
| exports["show"] = show; | |
| exports["showBoolean"] = showBoolean; | |
| exports["showInt"] = showInt; | |
| exports["showNumber"] = showNumber; | |
| exports["showChar"] = showChar; | |
| exports["showString"] = showString; | |
| exports["showArray"] = showArray; | |
| })(PS["Data.Show"] = PS["Data.Show"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Unit"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var showUnit = new Data_Show.Show(function (v) { | |
| return "unit"; | |
| }); | |
| exports["showUnit"] = showUnit; | |
| exports["unit"] = $foreign.unit; | |
| })(PS["Data.Unit"] = PS["Data.Unit"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Functor"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | A `Functor` is a type constructor which supports a mapping operation | |
| // | `map`. | |
| // | | |
| // | `map` can be used to turn functions `a -> b` into functions | |
| // | `f a -> f b` whose argument and return types use the type constructor `f` | |
| // | to represent some computational context. | |
| // | | |
| // | Instances must satisfy the following laws: | |
| // | | |
| // | - Identity: `map id = id` | |
| // | - Composition: `map (f <<< g) = map f <<< map g` | |
| var Functor = function (map) { | |
| this.map = map; | |
| }; | |
| var map = function (dict) { | |
| return dict.map; | |
| }; | |
| // | `mapFlipped` is `map` with its arguments reversed. For example: | |
| // | | |
| // | ```purescript | |
| // | [1, 2, 3] <#> \n -> n * n | |
| // | ``` | |
| var mapFlipped = function (dictFunctor) { | |
| return function (fa) { | |
| return function (f) { | |
| return map(dictFunctor)(f)(fa); | |
| }; | |
| }; | |
| }; | |
| // | The `void` function is used to ignore the type wrapped by a | |
| // | [`Functor`](#functor), replacing it with `Unit` and keeping only the type | |
| // | information provided by the type constructor itself. | |
| // | | |
| // | `void` is often useful when using `do` notation to change the return type | |
| // | of a monadic computation: | |
| // | | |
| // | ```purescript | |
| // | main = forE 1 10 \n -> void do | |
| // | print n | |
| // | print (n * n) | |
| // | ``` | |
| var $$void = function (dictFunctor) { | |
| return map(dictFunctor)(Data_Function["const"](Data_Unit.unit)); | |
| }; | |
| // | A version of `voidRight` with its arguments flipped. | |
| var voidLeft = function (dictFunctor) { | |
| return function (f) { | |
| return function (x) { | |
| return map(dictFunctor)(Data_Function["const"](x))(f); | |
| }; | |
| }; | |
| }; | |
| // | Ignore the return value of a computation, using the specified return value | |
| // | instead. | |
| var voidRight = function (dictFunctor) { | |
| return function (x) { | |
| return map(dictFunctor)(Data_Function["const"](x)); | |
| }; | |
| }; | |
| var functorFn = new Functor(Control_Semigroupoid.compose(Control_Semigroupoid.semigroupoidFn)); | |
| var functorArray = new Functor($foreign.arrayMap); | |
| // | Apply a value in a computational context to a value in no context. | |
| // | | |
| // | Generalizes `flip`. | |
| // | | |
| // | ```purescript | |
| // | longEnough :: String -> Bool | |
| // | hasSymbol :: String -> Bool | |
| // | hasDigit :: String -> Bool | |
| // | password :: String | |
| // | | |
| // | validate :: String -> List Bool | |
| // | validate = flap [longEnough, hasSymbol, hasDigit] | |
| // | ``` | |
| // | | |
| // | ```purescript | |
| // | flap (-) 3 4 == 1 | |
| // | threeve <$> Just 1 <@> 'a' <*> Just true == Just (threeve 1 'a' true) | |
| // | ``` | |
| var flap = function (dictFunctor) { | |
| return function (ff) { | |
| return function (x) { | |
| return map(dictFunctor)(function (f) { | |
| return f(x); | |
| })(ff); | |
| }; | |
| }; | |
| }; | |
| exports["Functor"] = Functor; | |
| exports["flap"] = flap; | |
| exports["map"] = map; | |
| exports["mapFlipped"] = mapFlipped; | |
| exports["void"] = $$void; | |
| exports["voidLeft"] = voidLeft; | |
| exports["voidRight"] = voidRight; | |
| exports["functorFn"] = functorFn; | |
| exports["functorArray"] = functorArray; | |
| })(PS["Data.Functor"] = PS["Data.Functor"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.concatString = function (s1) { | |
| return function (s2) { | |
| return s1 + s2; | |
| }; | |
| }; | |
| exports.concatArray = function (xs) { | |
| return function (ys) { | |
| if (xs.length === 0) return ys; | |
| if (ys.length === 0) return xs; | |
| return xs.concat(ys); | |
| }; | |
| }; | |
| })(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Show = PS["Data.Show"]; | |
| // | An uninhabited data type. | |
| // | | |
| // | `Void` is useful to eliminate the possibility of a value being created. | |
| // | For example, a value of type `Either Void Boolean` can never have | |
| // | a Left value created in PureScript. | |
| var Void = function (x) { | |
| return x; | |
| }; | |
| var absurd = function (a) { | |
| var spin = function ($copy_v) { | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| $copy_v = v; | |
| return; | |
| }; | |
| while (!false) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| return spin(a); | |
| }; | |
| var showVoid = new Data_Show.Show(absurd); | |
| exports["absurd"] = absurd; | |
| exports["showVoid"] = showVoid; | |
| })(PS["Data.Void"] = PS["Data.Void"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Semigroup"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Data_Void = PS["Data.Void"]; | |
| // | The `Semigroup` type class identifies an associative operation on a type. | |
| // | | |
| // | Instances are required to satisfy the following law: | |
| // | | |
| // | - Associativity: `(x <> y) <> z = x <> (y <> z)` | |
| // | | |
| // | One example of a `Semigroup` is `String`, with `(<>)` defined as string | |
| // | concatenation. | |
| var Semigroup = function (append) { | |
| this.append = append; | |
| }; | |
| var semigroupVoid = new Semigroup(function (v) { | |
| return Data_Void.absurd; | |
| }); | |
| var semigroupUnit = new Semigroup(function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }); | |
| var semigroupString = new Semigroup($foreign.concatString); | |
| var semigroupArray = new Semigroup($foreign.concatArray); | |
| var append = function (dict) { | |
| return dict.append; | |
| }; | |
| var semigroupFn = function (dictSemigroup) { | |
| return new Semigroup(function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return append(dictSemigroup)(f(x))(g(x)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| exports["Semigroup"] = Semigroup; | |
| exports["append"] = append; | |
| exports["semigroupString"] = semigroupString; | |
| exports["semigroupUnit"] = semigroupUnit; | |
| exports["semigroupVoid"] = semigroupVoid; | |
| exports["semigroupFn"] = semigroupFn; | |
| exports["semigroupArray"] = semigroupArray; | |
| })(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| // | The `Alt` type class identifies an associative operation on a type | |
| // | constructor. It is similar to `Semigroup`, except that it applies to | |
| // | types of kind `* -> *`, like `Array` or `List`, rather than concrete types | |
| // | `String` or `Number`. | |
| // | | |
| // | `Alt` instances are required to satisfy the following laws: | |
| // | | |
| // | - Associativity: `(x <|> y) <|> z == x <|> (y <|> z)` | |
| // | - Distributivity: `f <$> (x <|> y) == (f <$> x) <|> (f <$> y)` | |
| // | | |
| // | For example, the `Array` (`[]`) type is an instance of `Alt`, where | |
| // | `(<|>)` is defined to be concatenation. | |
| var Alt = function (Functor0, alt) { | |
| this.Functor0 = Functor0; | |
| this.alt = alt; | |
| }; | |
| var altArray = new Alt(function () { | |
| return Data_Functor.functorArray; | |
| }, Data_Semigroup.append(Data_Semigroup.semigroupArray)); | |
| var alt = function (dict) { | |
| return dict.alt; | |
| }; | |
| exports["Alt"] = Alt; | |
| exports["alt"] = alt; | |
| exports["altArray"] = altArray; | |
| })(PS["Control.Alt"] = PS["Control.Alt"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.arrayApply = function (fs) { | |
| return function (xs) { | |
| var result = []; | |
| var n = 0; | |
| for (var i = 0, l = fs.length; i < l; i++) { | |
| for (var j = 0, k = xs.length; j < k; j++) { | |
| result[n++] = fs[i](xs[j]); | |
| } | |
| } | |
| return result; | |
| }; | |
| }; | |
| })(PS["Control.Apply"] = PS["Control.Apply"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| // | The `Apply` class provides the `(<*>)` which is used to apply a function | |
| // | to an argument under a type constructor. | |
| // | | |
| // | `Apply` can be used to lift functions of two or more arguments to work on | |
| // | values wrapped with the type constructor `f`. It might also be understood | |
| // | in terms of the `lift2` function: | |
| // | | |
| // | ```purescript | |
| // | lift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c | |
| // | lift2 f a b = f <$> a <*> b | |
| // | ``` | |
| // | | |
| // | `(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts | |
| // | the function application operator `($)` to arguments wrapped with the | |
| // | type constructor `f`. | |
| // | | |
| // | Instances must satisfy the following law in addition to the `Functor` | |
| // | laws: | |
| // | | |
| // | - Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)` | |
| // | | |
| // | Formally, `Apply` represents a strong lax semi-monoidal endofunctor. | |
| var Apply = function (Functor0, apply) { | |
| this.Functor0 = Functor0; | |
| this.apply = apply; | |
| }; | |
| var applyFn = new Apply(function () { | |
| return Data_Functor.functorFn; | |
| }, function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return f(x)(g(x)); | |
| }; | |
| }; | |
| }); | |
| var applyArray = new Apply(function () { | |
| return Data_Functor.functorArray; | |
| }, $foreign.arrayApply); | |
| var apply = function (dict) { | |
| return dict.apply; | |
| }; | |
| // | Combine two effectful actions, keeping only the result of the first. | |
| var applyFirst = function (dictApply) { | |
| return function (a) { | |
| return function (b) { | |
| return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"])(a))(b); | |
| }; | |
| }; | |
| }; | |
| // | Combine two effectful actions, keeping only the result of the second. | |
| var applySecond = function (dictApply) { | |
| return function (a) { | |
| return function (b) { | |
| return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"](Control_Category.id(Control_Category.categoryFn)))(a))(b); | |
| }; | |
| }; | |
| }; | |
| // | Lift a function of two arguments to a function which accepts and returns | |
| // | values wrapped with the type constructor `f`. | |
| var lift2 = function (dictApply) { | |
| return function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Lift a function of three arguments to a function which accepts and returns | |
| // | values wrapped with the type constructor `f`. | |
| var lift3 = function (dictApply) { | |
| return function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return apply(dictApply)(apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b))(c); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Lift a function of four arguments to a function which accepts and returns | |
| // | values wrapped with the type constructor `f`. | |
| var lift4 = function (dictApply) { | |
| return function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return apply(dictApply)(apply(dictApply)(apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b))(c))(d); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Lift a function of five arguments to a function which accepts and returns | |
| // | values wrapped with the type constructor `f`. | |
| var lift5 = function (dictApply) { | |
| return function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return function (e) { | |
| return apply(dictApply)(apply(dictApply)(apply(dictApply)(apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b))(c))(d))(e); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Apply"] = Apply; | |
| exports["apply"] = apply; | |
| exports["applyFirst"] = applyFirst; | |
| exports["applySecond"] = applySecond; | |
| exports["lift2"] = lift2; | |
| exports["lift3"] = lift3; | |
| exports["lift4"] = lift4; | |
| exports["lift5"] = lift5; | |
| exports["applyFn"] = applyFn; | |
| exports["applyArray"] = applyArray; | |
| })(PS["Control.Apply"] = PS["Control.Apply"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Applicative` type class extends the [`Apply`](#apply) type class | |
| // | with a `pure` function, which can be used to create values of type `f a` | |
| // | from values of type `a`. | |
| // | | |
| // | Where [`Apply`](#apply) provides the ability to lift functions of two or | |
| // | more arguments to functions whose arguments are wrapped using `f`, and | |
| // | [`Functor`](#functor) provides the ability to lift functions of one | |
| // | argument, `pure` can be seen as the function which lifts functions of | |
| // | _zero_ arguments. That is, `Applicative` functors support a lifting | |
| // | operation for any number of function arguments. | |
| // | | |
| // | Instances must satisfy the following laws in addition to the `Apply` | |
| // | laws: | |
| // | | |
| // | - Identity: `(pure id) <*> v = v` | |
| // | - Composition: `pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)` | |
| // | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)` | |
| // | - Interchange: `u <*> (pure y) = (pure (_ $ y)) <*> u` | |
| var Applicative = function (Apply0, pure) { | |
| this.Apply0 = Apply0; | |
| this.pure = pure; | |
| }; | |
| var pure = function (dict) { | |
| return dict.pure; | |
| }; | |
| // | Perform a applicative action unless a condition is true. | |
| var unless = function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| if (!v) { | |
| return v1; | |
| }; | |
| if (v) { | |
| return pure(dictApplicative)(Data_Unit.unit); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative line 62, column 1 - line 62, column 65: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Perform a applicative action when a condition is true. | |
| var when = function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| if (v) { | |
| return v1; | |
| }; | |
| if (!v) { | |
| return pure(dictApplicative)(Data_Unit.unit); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative line 57, column 1 - line 57, column 63: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | `liftA1` provides a default implementation of `(<$>)` for any | |
| // | [`Applicative`](#applicative) functor, without using `(<$>)` as provided | |
| // | by the [`Functor`](#functor)-[`Applicative`](#applicative) superclass | |
| // | relationship. | |
| // | | |
| // | `liftA1` can therefore be used to write [`Functor`](#functor) instances | |
| // | as follows: | |
| // | | |
| // | ```purescript | |
| // | instance functorF :: Functor F where | |
| // | map = liftA1 | |
| // | ``` | |
| var liftA1 = function (dictApplicative) { | |
| return function (f) { | |
| return function (a) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a); | |
| }; | |
| }; | |
| }; | |
| var applicativeFn = new Applicative(function () { | |
| return Control_Apply.applyFn; | |
| }, function (x) { | |
| return function (v) { | |
| return x; | |
| }; | |
| }); | |
| var applicativeArray = new Applicative(function () { | |
| return Control_Apply.applyArray; | |
| }, function (x) { | |
| return [ x ]; | |
| }); | |
| exports["Applicative"] = Applicative; | |
| exports["liftA1"] = liftA1; | |
| exports["pure"] = pure; | |
| exports["unless"] = unless; | |
| exports["when"] = when; | |
| exports["applicativeFn"] = applicativeFn; | |
| exports["applicativeArray"] = applicativeArray; | |
| })(PS["Control.Applicative"] = PS["Control.Applicative"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| // | The `Plus` type class extends the `Alt` type class with a value that | |
| // | should be the left and right identity for `(<|>)`. | |
| // | | |
| // | It is similar to `Monoid`, except that it applies to types of | |
| // | kind `* -> *`, like `Array` or `List`, rather than concrete types like | |
| // | `String` or `Number`. | |
| // | | |
| // | `Plus` instances should satisfy the following laws: | |
| // | | |
| // | - Left identity: `empty <|> x == x` | |
| // | - Right identity: `x <|> empty == x` | |
| // | - Annihilation: `f <$> empty == empty` | |
| var Plus = function (Alt0, empty) { | |
| this.Alt0 = Alt0; | |
| this.empty = empty; | |
| }; | |
| var plusArray = new Plus(function () { | |
| return Control_Alt.altArray; | |
| }, [ ]); | |
| var empty = function (dict) { | |
| return dict.empty; | |
| }; | |
| exports["Plus"] = Plus; | |
| exports["empty"] = empty; | |
| exports["plusArray"] = plusArray; | |
| })(PS["Control.Plus"] = PS["Control.Plus"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| // | The `Alternative` type class has no members of its own; it just specifies | |
| // | that the type constructor has both `Applicative` and `Plus` instances. | |
| // | | |
| // | Types which have `Alternative` instances should also satisfy the following | |
| // | laws: | |
| // | | |
| // | - Distributivity: `(f <|> g) <*> x == (f <*> x) <|> (g <*> x)` | |
| // | - Annihilation: `empty <*> f = empty` | |
| var Alternative = function (Applicative0, Plus1) { | |
| this.Applicative0 = Applicative0; | |
| this.Plus1 = Plus1; | |
| }; | |
| var alternativeArray = new Alternative(function () { | |
| return Control_Applicative.applicativeArray; | |
| }, function () { | |
| return Control_Plus.plusArray; | |
| }); | |
| exports["Alternative"] = Alternative; | |
| exports["alternativeArray"] = alternativeArray; | |
| })(PS["Control.Alternative"] = PS["Control.Alternative"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.arrayBind = function (arr) { | |
| return function (f) { | |
| var result = []; | |
| for (var i = 0, l = arr.length; i < l; i++) { | |
| Array.prototype.push.apply(result, f(arr[i])); | |
| } | |
| return result; | |
| }; | |
| }; | |
| })(PS["Control.Bind"] = PS["Control.Bind"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Bind"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Bind` type class extends the [`Apply`](#apply) type class with a | |
| // | "bind" operation `(>>=)` which composes computations in sequence, using | |
| // | the return value of one computation to determine the next computation. | |
| // | | |
| // | The `>>=` operator can also be expressed using `do` notation, as follows: | |
| // | | |
| // | ```purescript | |
| // | x >>= f = do y <- x | |
| // | f y | |
| // | ``` | |
| // | | |
| // | where the function argument of `f` is given the name `y`. | |
| // | | |
| // | Instances must satisfy the following law in addition to the `Apply` | |
| // | laws: | |
| // | | |
| // | - Associativity: `(x >>= f) >>= g = x >>= (\k -> f k >>= g)` | |
| // | | |
| // | Associativity tells us that we can regroup operations which use `do` | |
| // | notation so that we can unambiguously write, for example: | |
| // | | |
| // | ```purescript | |
| // | do x <- m1 | |
| // | y <- m2 x | |
| // | m3 x y | |
| // | ``` | |
| var Bind = function (Apply0, bind) { | |
| this.Apply0 = Apply0; | |
| this.bind = bind; | |
| }; | |
| // | A class for types whose values can safely be discarded | |
| // | in a `do` notation block. | |
| // | | |
| // | An example is the `Unit` type, since there is only one | |
| // | possible value which can be returned. | |
| var Discard = function (discard) { | |
| this.discard = discard; | |
| }; | |
| var discard = function (dict) { | |
| return dict.discard; | |
| }; | |
| var bindFn = new Bind(function () { | |
| return Control_Apply.applyFn; | |
| }, function (m) { | |
| return function (f) { | |
| return function (x) { | |
| return f(m(x))(x); | |
| }; | |
| }; | |
| }); | |
| var bindArray = new Bind(function () { | |
| return Control_Apply.applyArray; | |
| }, $foreign.arrayBind); | |
| var bind = function (dict) { | |
| return dict.bind; | |
| }; | |
| // | `bindFlipped` is `bind` with its arguments reversed. For example: | |
| // | | |
| // | ```purescript | |
| // | print =<< random | |
| // | ``` | |
| var bindFlipped = function (dictBind) { | |
| return Data_Function.flip(bind(dictBind)); | |
| }; | |
| // | Backwards Kleisli composition. | |
| var composeKleisliFlipped = function (dictBind) { | |
| return function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return bindFlipped(dictBind)(f)(g(a)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Forwards Kleisli composition. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | import Data.Array (head, tail) | |
| // | | |
| // | third = tail >=> tail >=> head | |
| // | ``` | |
| var composeKleisli = function (dictBind) { | |
| return function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return bind(dictBind)(f(a))(g); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var discardUnit = new Discard(function (dictBind) { | |
| return bind(dictBind); | |
| }); | |
| // | Execute a monadic action if a condition holds. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | main = ifM ((< 0.5) <$> random) | |
| // | (trace "Heads") | |
| // | (trace "Tails") | |
| // | ``` | |
| var ifM = function (dictBind) { | |
| return function (cond) { | |
| return function (t) { | |
| return function (f) { | |
| return bind(dictBind)(cond)(function (cond$prime) { | |
| if (cond$prime) { | |
| return t; | |
| }; | |
| return f; | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Collapse two applications of a monadic type constructor into one. | |
| var join = function (dictBind) { | |
| return function (m) { | |
| return bind(dictBind)(m)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| exports["Bind"] = Bind; | |
| exports["Discard"] = Discard; | |
| exports["bind"] = bind; | |
| exports["bindFlipped"] = bindFlipped; | |
| exports["composeKleisli"] = composeKleisli; | |
| exports["composeKleisliFlipped"] = composeKleisliFlipped; | |
| exports["discard"] = discard; | |
| exports["ifM"] = ifM; | |
| exports["join"] = join; | |
| exports["bindFn"] = bindFn; | |
| exports["bindArray"] = bindArray; | |
| exports["discardUnit"] = discardUnit; | |
| })(PS["Control.Bind"] = PS["Control.Bind"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.boolConj = function (b1) { | |
| return function (b2) { | |
| return b1 && b2; | |
| }; | |
| }; | |
| exports.boolDisj = function (b1) { | |
| return function (b2) { | |
| return b1 || b2; | |
| }; | |
| }; | |
| exports.boolNot = function (b) { | |
| return !b; | |
| }; | |
| })(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.HeytingAlgebra"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `HeytingAlgebra` type class represents types that are bounded lattices with | |
| // | an implication operator such that the following laws hold: | |
| // | | |
| // | - Associativity: | |
| // | - `a || (b || c) = (a || b) || c` | |
| // | - `a && (b && c) = (a && b) && c` | |
| // | - Commutativity: | |
| // | - `a || b = b || a` | |
| // | - `a && b = b && a` | |
| // | - Absorption: | |
| // | - `a || (a && b) = a` | |
| // | - `a && (a || b) = a` | |
| // | - Idempotent: | |
| // | - `a || a = a` | |
| // | - `a && a = a` | |
| // | - Identity: | |
| // | - `a || ff = a` | |
| // | - `a && tt = a` | |
| // | - Implication: | |
| // | - ``a `implies` a = tt`` | |
| // | - ``a && (a `implies` b) = a && b`` | |
| // | - ``b && (a `implies` b) = b`` | |
| // | - ``a `implies` (b && c) = (a `implies` b) && (a `implies` c)`` | |
| // | - Complemented: | |
| // | - ``not a = a `implies` ff`` | |
| var HeytingAlgebra = function (conj, disj, ff, implies, not, tt) { | |
| this.conj = conj; | |
| this.disj = disj; | |
| this.ff = ff; | |
| this.implies = implies; | |
| this.not = not; | |
| this.tt = tt; | |
| }; | |
| var tt = function (dict) { | |
| return dict.tt; | |
| }; | |
| var not = function (dict) { | |
| return dict.not; | |
| }; | |
| var implies = function (dict) { | |
| return dict.implies; | |
| }; | |
| var heytingAlgebraUnit = new HeytingAlgebra(function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }, Data_Unit.unit, function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }, function (v) { | |
| return Data_Unit.unit; | |
| }, Data_Unit.unit); | |
| var ff = function (dict) { | |
| return dict.ff; | |
| }; | |
| var disj = function (dict) { | |
| return dict.disj; | |
| }; | |
| var heytingAlgebraBoolean = new HeytingAlgebra($foreign.boolConj, $foreign.boolDisj, false, function (a) { | |
| return function (b) { | |
| return disj(heytingAlgebraBoolean)(not(heytingAlgebraBoolean)(a))(b); | |
| }; | |
| }, $foreign.boolNot, true); | |
| var conj = function (dict) { | |
| return dict.conj; | |
| }; | |
| var heytingAlgebraFunction = function (dictHeytingAlgebra) { | |
| return new HeytingAlgebra(function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return conj(dictHeytingAlgebra)(f(a))(g(a)); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return disj(dictHeytingAlgebra)(f(a))(g(a)); | |
| }; | |
| }; | |
| }, function (v) { | |
| return ff(dictHeytingAlgebra); | |
| }, function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return implies(dictHeytingAlgebra)(f(a))(g(a)); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (a) { | |
| return not(dictHeytingAlgebra)(f(a)); | |
| }; | |
| }, function (v) { | |
| return tt(dictHeytingAlgebra); | |
| }); | |
| }; | |
| exports["HeytingAlgebra"] = HeytingAlgebra; | |
| exports["conj"] = conj; | |
| exports["disj"] = disj; | |
| exports["ff"] = ff; | |
| exports["implies"] = implies; | |
| exports["not"] = not; | |
| exports["tt"] = tt; | |
| exports["heytingAlgebraBoolean"] = heytingAlgebraBoolean; | |
| exports["heytingAlgebraUnit"] = heytingAlgebraUnit; | |
| exports["heytingAlgebraFunction"] = heytingAlgebraFunction; | |
| })(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `BooleanAlgebra` type class represents types that behave like boolean | |
| // | values. | |
| // | | |
| // | Instances should satisfy the following laws in addition to the | |
| // | `HeytingAlgebra` law: | |
| // | | |
| // | - Excluded middle: | |
| // | - `a || not a = tt` | |
| var BooleanAlgebra = function (HeytingAlgebra0) { | |
| this.HeytingAlgebra0 = HeytingAlgebra0; | |
| }; | |
| var booleanAlgebraUnit = new BooleanAlgebra(function () { | |
| return Data_HeytingAlgebra.heytingAlgebraUnit; | |
| }); | |
| var booleanAlgebraFn = function (dictBooleanAlgebra) { | |
| return new BooleanAlgebra(function () { | |
| return Data_HeytingAlgebra.heytingAlgebraFunction(dictBooleanAlgebra.HeytingAlgebra0()); | |
| }); | |
| }; | |
| var booleanAlgebraBoolean = new BooleanAlgebra(function () { | |
| return Data_HeytingAlgebra.heytingAlgebraBoolean; | |
| }); | |
| exports["BooleanAlgebra"] = BooleanAlgebra; | |
| exports["booleanAlgebraBoolean"] = booleanAlgebraBoolean; | |
| exports["booleanAlgebraUnit"] = booleanAlgebraUnit; | |
| exports["booleanAlgebraFn"] = booleanAlgebraFn; | |
| })(PS["Data.BooleanAlgebra"] = PS["Data.BooleanAlgebra"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.topInt = 2147483647; | |
| exports.bottomInt = -2147483648; | |
| exports.topChar = String.fromCharCode(65535); | |
| exports.bottomChar = String.fromCharCode(0); | |
| })(PS["Data.Bounded"] = PS["Data.Bounded"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.ordArrayImpl = function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| var i = 0; | |
| var xlen = xs.length; | |
| var ylen = ys.length; | |
| while (i < xlen && i < ylen) { | |
| var x = xs[i]; | |
| var y = ys[i]; | |
| var o = f(x)(y); | |
| if (o !== 0) { | |
| return o; | |
| } | |
| i++; | |
| } | |
| if (xlen === ylen) { | |
| return 0; | |
| } else if (xlen > ylen) { | |
| return -1; | |
| } else { | |
| return 1; | |
| } | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Ord"] = PS["Data.Ord"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.refEq = function (r1) { | |
| return function (r2) { | |
| return r1 === r2; | |
| }; | |
| }; | |
| exports.refIneq = function (r1) { | |
| return function (r2) { | |
| return r1 !== r2; | |
| }; | |
| }; | |
| exports.eqArrayImpl = function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| if (xs.length !== ys.length) return false; | |
| for (var i = 0; i < xs.length; i++) { | |
| if (!f(xs[i])(ys[i])) return false; | |
| } | |
| return true; | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Eq"] = PS["Data.Eq"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Eq"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Data_Void = PS["Data.Void"]; | |
| // | The `Eq` type class represents types which support decidable equality. | |
| // | | |
| // | `Eq` instances should satisfy the following laws: | |
| // | | |
| // | - Reflexivity: `x == x = true` | |
| // | - Symmetry: `x == y = y == x` | |
| // | - Transitivity: if `x == y` and `y == z` then `x == z` | |
| // | | |
| // | **Note:** The `Number` type is not an entirely law abiding member of this | |
| // | class due to the presence of `NaN`, since `NaN /= NaN`. Additionally, | |
| // | computing with `Number` can result in a loss of precision, so sometimes | |
| // | values that should be equivalent are not. | |
| var Eq = function (eq) { | |
| this.eq = eq; | |
| }; | |
| // | The `Eq1` type class represents type constructors with decidable equality. | |
| var Eq1 = function (eq1) { | |
| this.eq1 = eq1; | |
| }; | |
| var eqVoid = new Eq(function (v) { | |
| return function (v1) { | |
| return true; | |
| }; | |
| }); | |
| var eqUnit = new Eq(function (v) { | |
| return function (v1) { | |
| return true; | |
| }; | |
| }); | |
| var eqString = new Eq($foreign.refEq); | |
| var eqNumber = new Eq($foreign.refEq); | |
| var eqInt = new Eq($foreign.refEq); | |
| var eqChar = new Eq($foreign.refEq); | |
| var eqBoolean = new Eq($foreign.refEq); | |
| var eq1 = function (dict) { | |
| return dict.eq1; | |
| }; | |
| var eq = function (dict) { | |
| return dict.eq; | |
| }; | |
| var eqArray = function (dictEq) { | |
| return new Eq($foreign.eqArrayImpl(eq(dictEq))); | |
| }; | |
| var eq1Array = new Eq1(function (dictEq) { | |
| return eq(eqArray(dictEq)); | |
| }); | |
| // | `notEq` tests whether one value is _not equal_ to another. Shorthand for | |
| // | `not (eq x y)`. | |
| var notEq = function (dictEq) { | |
| return function (x) { | |
| return function (y) { | |
| return eq(eqBoolean)(eq(dictEq)(x)(y))(false); | |
| }; | |
| }; | |
| }; | |
| var notEq1 = function (dictEq1) { | |
| return function (dictEq) { | |
| return function (x) { | |
| return function (y) { | |
| return eq(eqBoolean)(eq1(dictEq1)(dictEq)(x)(y))(false); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Eq"] = Eq; | |
| exports["Eq1"] = Eq1; | |
| exports["eq"] = eq; | |
| exports["eq1"] = eq1; | |
| exports["notEq"] = notEq; | |
| exports["notEq1"] = notEq1; | |
| exports["eqBoolean"] = eqBoolean; | |
| exports["eqInt"] = eqInt; | |
| exports["eqNumber"] = eqNumber; | |
| exports["eqChar"] = eqChar; | |
| exports["eqString"] = eqString; | |
| exports["eqUnit"] = eqUnit; | |
| exports["eqVoid"] = eqVoid; | |
| exports["eqArray"] = eqArray; | |
| exports["eq1Array"] = eq1Array; | |
| })(PS["Data.Eq"] = PS["Data.Eq"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.unsafeCompareImpl = function (lt) { | |
| return function (eq) { | |
| return function (gt) { | |
| return function (x) { | |
| return function (y) { | |
| return x < y ? lt : x === y ? eq : gt; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Ord.Unsafe"] = PS["Data.Ord.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| // | The `Ordering` data type represents the three possible outcomes of | |
| // | comparing two values: | |
| // | | |
| // | `LT` - The first value is _less than_ the second. | |
| // | `GT` - The first value is _greater than_ the second. | |
| // | `EQ` - The first value is _equal to_ the second. | |
| var LT = (function () { | |
| function LT() { | |
| }; | |
| LT.value = new LT(); | |
| return LT; | |
| })(); | |
| // | The `Ordering` data type represents the three possible outcomes of | |
| // | comparing two values: | |
| // | | |
| // | `LT` - The first value is _less than_ the second. | |
| // | `GT` - The first value is _greater than_ the second. | |
| // | `EQ` - The first value is _equal to_ the second. | |
| var GT = (function () { | |
| function GT() { | |
| }; | |
| GT.value = new GT(); | |
| return GT; | |
| })(); | |
| // | The `Ordering` data type represents the three possible outcomes of | |
| // | comparing two values: | |
| // | | |
| // | `LT` - The first value is _less than_ the second. | |
| // | `GT` - The first value is _greater than_ the second. | |
| // | `EQ` - The first value is _equal to_ the second. | |
| var EQ = (function () { | |
| function EQ() { | |
| }; | |
| EQ.value = new EQ(); | |
| return EQ; | |
| })(); | |
| var showOrdering = new Data_Show.Show(function (v) { | |
| if (v instanceof LT) { | |
| return "LT"; | |
| }; | |
| if (v instanceof GT) { | |
| return "GT"; | |
| }; | |
| if (v instanceof EQ) { | |
| return "EQ"; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ordering line 26, column 1 - line 26, column 39: " + [ v.constructor.name ]); | |
| }); | |
| var semigroupOrdering = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| if (v instanceof LT) { | |
| return LT.value; | |
| }; | |
| if (v instanceof GT) { | |
| return GT.value; | |
| }; | |
| if (v instanceof EQ) { | |
| return v1; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ordering line 21, column 1 - line 21, column 49: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| // | Reverses an `Ordering` value, flipping greater than for less than while | |
| // | preserving equality. | |
| var invert = function (v) { | |
| if (v instanceof GT) { | |
| return LT.value; | |
| }; | |
| if (v instanceof EQ) { | |
| return EQ.value; | |
| }; | |
| if (v instanceof LT) { | |
| return GT.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ordering line 33, column 1 - line 33, column 31: " + [ v.constructor.name ]); | |
| }; | |
| var eqOrdering = new Data_Eq.Eq(function (v) { | |
| return function (v1) { | |
| if (v instanceof LT && v1 instanceof LT) { | |
| return true; | |
| }; | |
| if (v instanceof GT && v1 instanceof GT) { | |
| return true; | |
| }; | |
| if (v instanceof EQ && v1 instanceof EQ) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| }); | |
| exports["LT"] = LT; | |
| exports["GT"] = GT; | |
| exports["EQ"] = EQ; | |
| exports["invert"] = invert; | |
| exports["eqOrdering"] = eqOrdering; | |
| exports["semigroupOrdering"] = semigroupOrdering; | |
| exports["showOrdering"] = showOrdering; | |
| })(PS["Data.Ordering"] = PS["Data.Ordering"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Ord.Unsafe"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var unsafeCompare = $foreign.unsafeCompareImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value); | |
| exports["unsafeCompare"] = unsafeCompare; | |
| })(PS["Data.Ord.Unsafe"] = PS["Data.Ord.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.intSub = function (x) { | |
| return function (y) { | |
| /* jshint bitwise: false */ | |
| return x - y | 0; | |
| }; | |
| }; | |
| exports.numSub = function (n1) { | |
| return function (n2) { | |
| return n1 - n2; | |
| }; | |
| }; | |
| })(PS["Data.Ring"] = PS["Data.Ring"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.intAdd = function (x) { | |
| return function (y) { | |
| /* jshint bitwise: false */ | |
| return x + y | 0; | |
| }; | |
| }; | |
| exports.intMul = function (x) { | |
| return function (y) { | |
| /* jshint bitwise: false */ | |
| return x * y | 0; | |
| }; | |
| }; | |
| exports.numAdd = function (n1) { | |
| return function (n2) { | |
| return n1 + n2; | |
| }; | |
| }; | |
| exports.numMul = function (n1) { | |
| return function (n2) { | |
| return n1 * n2; | |
| }; | |
| }; | |
| })(PS["Data.Semiring"] = PS["Data.Semiring"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Semiring"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Semiring` class is for types that support an addition and | |
| // | multiplication operation. | |
| // | | |
| // | Instances must satisfy the following laws: | |
| // | | |
| // | - Commutative monoid under addition: | |
| // | - Associativity: `(a + b) + c = a + (b + c)` | |
| // | - Identity: `zero + a = a + zero = a` | |
| // | - Commutative: `a + b = b + a` | |
| // | - Monoid under multiplication: | |
| // | - Associativity: `(a * b) * c = a * (b * c)` | |
| // | - Identity: `one * a = a * one = a` | |
| // | - Multiplication distributes over addition: | |
| // | - Left distributivity: `a * (b + c) = (a * b) + (a * c)` | |
| // | - Right distributivity: `(a + b) * c = (a * c) + (b * c)` | |
| // | - Annihilation: `zero * a = a * zero = zero` | |
| // | | |
| // | **Note:** The `Number` and `Int` types are not fully law abiding | |
| // | members of this class hierarchy due to the potential for arithmetic | |
| // | overflows, and in the case of `Number`, the presence of `NaN` and | |
| // | `Infinity` values. The behaviour is unspecified in these cases. | |
| var Semiring = function (add, mul, one, zero) { | |
| this.add = add; | |
| this.mul = mul; | |
| this.one = one; | |
| this.zero = zero; | |
| }; | |
| var zero = function (dict) { | |
| return dict.zero; | |
| }; | |
| var semiringUnit = new Semiring(function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }, Data_Unit.unit, Data_Unit.unit); | |
| var semiringNumber = new Semiring($foreign.numAdd, $foreign.numMul, 1.0, 0.0); | |
| var semiringInt = new Semiring($foreign.intAdd, $foreign.intMul, 1, 0); | |
| var one = function (dict) { | |
| return dict.one; | |
| }; | |
| var mul = function (dict) { | |
| return dict.mul; | |
| }; | |
| var add = function (dict) { | |
| return dict.add; | |
| }; | |
| var semiringFn = function (dictSemiring) { | |
| return new Semiring(function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return add(dictSemiring)(f(x))(g(x)); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return mul(dictSemiring)(f(x))(g(x)); | |
| }; | |
| }; | |
| }, function (v) { | |
| return one(dictSemiring); | |
| }, function (v) { | |
| return zero(dictSemiring); | |
| }); | |
| }; | |
| exports["Semiring"] = Semiring; | |
| exports["add"] = add; | |
| exports["mul"] = mul; | |
| exports["one"] = one; | |
| exports["zero"] = zero; | |
| exports["semiringInt"] = semiringInt; | |
| exports["semiringNumber"] = semiringNumber; | |
| exports["semiringFn"] = semiringFn; | |
| exports["semiringUnit"] = semiringUnit; | |
| })(PS["Data.Semiring"] = PS["Data.Semiring"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Ring"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Ring` class is for types that support addition, multiplication, | |
| // | and subtraction operations. | |
| // | | |
| // | Instances must satisfy the following law in addition to the `Semiring` | |
| // | laws: | |
| // | | |
| // | - Additive inverse: `a - a = (zero - a) + a = zero` | |
| var Ring = function (Semiring0, sub) { | |
| this.Semiring0 = Semiring0; | |
| this.sub = sub; | |
| }; | |
| var sub = function (dict) { | |
| return dict.sub; | |
| }; | |
| var ringUnit = new Ring(function () { | |
| return Data_Semiring.semiringUnit; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_Unit.unit; | |
| }; | |
| }); | |
| var ringNumber = new Ring(function () { | |
| return Data_Semiring.semiringNumber; | |
| }, $foreign.numSub); | |
| var ringInt = new Ring(function () { | |
| return Data_Semiring.semiringInt; | |
| }, $foreign.intSub); | |
| var ringFn = function (dictRing) { | |
| return new Ring(function () { | |
| return Data_Semiring.semiringFn(dictRing.Semiring0()); | |
| }, function (f) { | |
| return function (g) { | |
| return function (x) { | |
| return sub(dictRing)(f(x))(g(x)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | `negate x` can be used as a shorthand for `zero - x`. | |
| var negate = function (dictRing) { | |
| return function (a) { | |
| return sub(dictRing)(Data_Semiring.zero(dictRing.Semiring0()))(a); | |
| }; | |
| }; | |
| exports["Ring"] = Ring; | |
| exports["negate"] = negate; | |
| exports["sub"] = sub; | |
| exports["ringInt"] = ringInt; | |
| exports["ringNumber"] = ringNumber; | |
| exports["ringUnit"] = ringUnit; | |
| exports["ringFn"] = ringFn; | |
| })(PS["Data.Ring"] = PS["Data.Ring"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Ord"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Ord_Unsafe = PS["Data.Ord.Unsafe"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Data_Void = PS["Data.Void"]; | |
| // | The `Ord` type class represents types which support comparisons with a | |
| // | _total order_. | |
| // | | |
| // | `Ord` instances should satisfy the laws of total orderings: | |
| // | | |
| // | - Reflexivity: `a <= a` | |
| // | - Antisymmetry: if `a <= b` and `b <= a` then `a = b` | |
| // | - Transitivity: if `a <= b` and `b <= c` then `a <= c` | |
| var Ord = function (Eq0, compare) { | |
| this.Eq0 = Eq0; | |
| this.compare = compare; | |
| }; | |
| // | The `Ord1` type class represents totally ordered type constructors. | |
| var Ord1 = function (Eq10, compare1) { | |
| this.Eq10 = Eq10; | |
| this.compare1 = compare1; | |
| }; | |
| var ordVoid = new Ord(function () { | |
| return Data_Eq.eqVoid; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| }); | |
| var ordUnit = new Ord(function () { | |
| return Data_Eq.eqUnit; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| }); | |
| var ordString = new Ord(function () { | |
| return Data_Eq.eqString; | |
| }, Data_Ord_Unsafe.unsafeCompare); | |
| var ordOrdering = new Ord(function () { | |
| return Data_Ordering.eqOrdering; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Ordering.LT && v1 instanceof Data_Ordering.LT) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| if (v instanceof Data_Ordering.EQ && v1 instanceof Data_Ordering.EQ) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| if (v instanceof Data_Ordering.GT && v1 instanceof Data_Ordering.GT) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| if (v instanceof Data_Ordering.LT) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v instanceof Data_Ordering.EQ && v1 instanceof Data_Ordering.LT) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof Data_Ordering.EQ && v1 instanceof Data_Ordering.GT) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ord line 68, column 1 - line 68, column 37: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var ordNumber = new Ord(function () { | |
| return Data_Eq.eqNumber; | |
| }, Data_Ord_Unsafe.unsafeCompare); | |
| var ordInt = new Ord(function () { | |
| return Data_Eq.eqInt; | |
| }, Data_Ord_Unsafe.unsafeCompare); | |
| var ordChar = new Ord(function () { | |
| return Data_Eq.eqChar; | |
| }, Data_Ord_Unsafe.unsafeCompare); | |
| var ordBoolean = new Ord(function () { | |
| return Data_Eq.eqBoolean; | |
| }, Data_Ord_Unsafe.unsafeCompare); | |
| var compare1 = function (dict) { | |
| return dict.compare1; | |
| }; | |
| var compare = function (dict) { | |
| return dict.compare; | |
| }; | |
| // | Compares two values by mapping them to a type with an `Ord` instance. | |
| var comparing = function (dictOrd) { | |
| return function (f) { | |
| return Data_Function.on(compare(dictOrd))(f); | |
| }; | |
| }; | |
| // | Test whether one value is _strictly greater than_ another. | |
| var greaterThan = function (dictOrd) { | |
| return function (a1) { | |
| return function (a2) { | |
| var v = compare(dictOrd)(a1)(a2); | |
| if (v instanceof Data_Ordering.GT) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| }; | |
| }; | |
| // | Test whether one value is _non-strictly greater than_ another. | |
| var greaterThanOrEq = function (dictOrd) { | |
| return function (a1) { | |
| return function (a2) { | |
| var v = compare(dictOrd)(a1)(a2); | |
| if (v instanceof Data_Ordering.LT) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| }; | |
| }; | |
| // | The sign function; always evaluates to either `one` or `negate one`. For | |
| // | any `x`, we should have `signum x * abs x == x`. | |
| var signum = function (dictOrd) { | |
| return function (dictRing) { | |
| return function (x) { | |
| var $33 = greaterThanOrEq(dictOrd)(x)(Data_Semiring.zero(dictRing.Semiring0())); | |
| if ($33) { | |
| return Data_Semiring.one(dictRing.Semiring0()); | |
| }; | |
| return Data_Ring.negate(dictRing)(Data_Semiring.one(dictRing.Semiring0())); | |
| }; | |
| }; | |
| }; | |
| // | Test whether one value is _strictly less than_ another. | |
| var lessThan = function (dictOrd) { | |
| return function (a1) { | |
| return function (a2) { | |
| var v = compare(dictOrd)(a1)(a2); | |
| if (v instanceof Data_Ordering.LT) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| }; | |
| }; | |
| // | Test whether one value is _non-strictly less than_ another. | |
| var lessThanOrEq = function (dictOrd) { | |
| return function (a1) { | |
| return function (a2) { | |
| var v = compare(dictOrd)(a1)(a2); | |
| if (v instanceof Data_Ordering.GT) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| }; | |
| }; | |
| // | Take the maximum of two values. If they are considered equal, the first | |
| // | argument is chosen. | |
| var max = function (dictOrd) { | |
| return function (x) { | |
| return function (y) { | |
| var v = compare(dictOrd)(x)(y); | |
| if (v instanceof Data_Ordering.LT) { | |
| return y; | |
| }; | |
| if (v instanceof Data_Ordering.EQ) { | |
| return x; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return x; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ord line 123, column 3 - line 126, column 12: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Take the minimum of two values. If they are considered equal, the first | |
| // | argument is chosen. | |
| var min = function (dictOrd) { | |
| return function (x) { | |
| return function (y) { | |
| var v = compare(dictOrd)(x)(y); | |
| if (v instanceof Data_Ordering.LT) { | |
| return x; | |
| }; | |
| if (v instanceof Data_Ordering.EQ) { | |
| return x; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return y; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ord line 114, column 3 - line 117, column 12: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| var ordArray = function (dictOrd) { | |
| return new Ord(function () { | |
| return Data_Eq.eqArray(dictOrd.Eq0()); | |
| }, (function () { | |
| var toDelta = function (x) { | |
| return function (y) { | |
| var v = compare(dictOrd)(x)(y); | |
| if (v instanceof Data_Ordering.EQ) { | |
| return 0; | |
| }; | |
| if (v instanceof Data_Ordering.LT) { | |
| return 1; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return -1 | 0; | |
| }; | |
| throw new Error("Failed pattern match at Data.Ord line 61, column 7 - line 66, column 1: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| return function (xs) { | |
| return function (ys) { | |
| return compare(ordInt)(0)($foreign.ordArrayImpl(toDelta)(xs)(ys)); | |
| }; | |
| }; | |
| })()); | |
| }; | |
| var ord1Array = new Ord1(function () { | |
| return Data_Eq.eq1Array; | |
| }, function (dictOrd) { | |
| return compare(ordArray(dictOrd)); | |
| }); | |
| // | Clamp a value between a minimum and a maximum. For example: | |
| // | | |
| // | ``` purescript | |
| // | let f = clamp 0 10 | |
| // | f (-5) == 0 | |
| // | f 5 == 5 | |
| // | f 15 == 10 | |
| // | ``` | |
| var clamp = function (dictOrd) { | |
| return function (low) { | |
| return function (hi) { | |
| return function (x) { | |
| return min(dictOrd)(hi)(max(dictOrd)(low)(x)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Test whether a value is between a minimum and a maximum (inclusive). | |
| // | For example: | |
| // | | |
| // | ``` purescript | |
| // | let f = between 0 10 | |
| // | f 0 == true | |
| // | f (-5) == false | |
| // | f 5 == true | |
| // | f 10 == true | |
| // | f 15 == false | |
| // | ``` | |
| var between = function (dictOrd) { | |
| return function (low) { | |
| return function (hi) { | |
| return function (x) { | |
| if (lessThan(dictOrd)(x)(low)) { | |
| return false; | |
| }; | |
| if (greaterThan(dictOrd)(x)(hi)) { | |
| return false; | |
| }; | |
| return true; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | The absolute value function. `abs x` is defined as `if x >= zero then x | |
| // | else negate x`. | |
| var abs = function (dictOrd) { | |
| return function (dictRing) { | |
| return function (x) { | |
| var $42 = greaterThanOrEq(dictOrd)(x)(Data_Semiring.zero(dictRing.Semiring0())); | |
| if ($42) { | |
| return x; | |
| }; | |
| return Data_Ring.negate(dictRing)(x); | |
| }; | |
| }; | |
| }; | |
| exports["Ord"] = Ord; | |
| exports["Ord1"] = Ord1; | |
| exports["abs"] = abs; | |
| exports["between"] = between; | |
| exports["clamp"] = clamp; | |
| exports["compare"] = compare; | |
| exports["compare1"] = compare1; | |
| exports["comparing"] = comparing; | |
| exports["greaterThan"] = greaterThan; | |
| exports["greaterThanOrEq"] = greaterThanOrEq; | |
| exports["lessThan"] = lessThan; | |
| exports["lessThanOrEq"] = lessThanOrEq; | |
| exports["max"] = max; | |
| exports["min"] = min; | |
| exports["signum"] = signum; | |
| exports["ordBoolean"] = ordBoolean; | |
| exports["ordInt"] = ordInt; | |
| exports["ordNumber"] = ordNumber; | |
| exports["ordString"] = ordString; | |
| exports["ordChar"] = ordChar; | |
| exports["ordUnit"] = ordUnit; | |
| exports["ordVoid"] = ordVoid; | |
| exports["ordArray"] = ordArray; | |
| exports["ordOrdering"] = ordOrdering; | |
| exports["ord1Array"] = ord1Array; | |
| })(PS["Data.Ord"] = PS["Data.Ord"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Bounded"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Bounded` type class represents totally ordered types that have an | |
| // | upper and lower boundary. | |
| // | | |
| // | Instances should satisfy the following law in addition to the `Ord` laws: | |
| // | | |
| // | - Bounded: `bottom <= a <= top` | |
| var Bounded = function (Ord0, bottom, top) { | |
| this.Ord0 = Ord0; | |
| this.bottom = bottom; | |
| this.top = top; | |
| }; | |
| var top = function (dict) { | |
| return dict.top; | |
| }; | |
| var boundedUnit = new Bounded(function () { | |
| return Data_Ord.ordUnit; | |
| }, Data_Unit.unit, Data_Unit.unit); | |
| var boundedOrdering = new Bounded(function () { | |
| return Data_Ord.ordOrdering; | |
| }, Data_Ordering.LT.value, Data_Ordering.GT.value); | |
| var boundedInt = new Bounded(function () { | |
| return Data_Ord.ordInt; | |
| }, $foreign.bottomInt, $foreign.topInt); | |
| // | Characters fall within the Unicode range. | |
| var boundedChar = new Bounded(function () { | |
| return Data_Ord.ordChar; | |
| }, $foreign.bottomChar, $foreign.topChar); | |
| var boundedBoolean = new Bounded(function () { | |
| return Data_Ord.ordBoolean; | |
| }, false, true); | |
| var bottom = function (dict) { | |
| return dict.bottom; | |
| }; | |
| exports["Bounded"] = Bounded; | |
| exports["bottom"] = bottom; | |
| exports["top"] = top; | |
| exports["boundedBoolean"] = boundedBoolean; | |
| exports["boundedInt"] = boundedInt; | |
| exports["boundedChar"] = boundedChar; | |
| exports["boundedOrdering"] = boundedOrdering; | |
| exports["boundedUnit"] = boundedUnit; | |
| })(PS["Data.Bounded"] = PS["Data.Bounded"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `CommutativeRing` class is for rings where multiplication is | |
| // | commutative. | |
| // | | |
| // | Instances must satisfy the following law in addition to the `Ring` | |
| // | laws: | |
| // | | |
| // | - Commutative multiplication: `a * b = b * a` | |
| var CommutativeRing = function (Ring0) { | |
| this.Ring0 = Ring0; | |
| }; | |
| var commutativeRingUnit = new CommutativeRing(function () { | |
| return Data_Ring.ringUnit; | |
| }); | |
| var commutativeRingNumber = new CommutativeRing(function () { | |
| return Data_Ring.ringNumber; | |
| }); | |
| var commutativeRingInt = new CommutativeRing(function () { | |
| return Data_Ring.ringInt; | |
| }); | |
| var commutativeRingFn = function (dictCommutativeRing) { | |
| return new CommutativeRing(function () { | |
| return Data_Ring.ringFn(dictCommutativeRing.Ring0()); | |
| }); | |
| }; | |
| exports["CommutativeRing"] = CommutativeRing; | |
| exports["commutativeRingInt"] = commutativeRingInt; | |
| exports["commutativeRingNumber"] = commutativeRingNumber; | |
| exports["commutativeRingUnit"] = commutativeRingUnit; | |
| exports["commutativeRingFn"] = commutativeRingFn; | |
| })(PS["Data.CommutativeRing"] = PS["Data.CommutativeRing"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.intDegree = function (x) { | |
| return Math.min(Math.abs(x), 2147483647); | |
| }; | |
| exports.intDiv = function (x) { | |
| return function (y) { | |
| /* jshint bitwise: false */ | |
| return x / y | 0; | |
| }; | |
| }; | |
| exports.intMod = function (x) { | |
| return function (y) { | |
| return x % y; | |
| }; | |
| }; | |
| exports.numDiv = function (n1) { | |
| return function (n2) { | |
| return n1 / n2; | |
| }; | |
| }; | |
| })(PS["Data.EuclideanRing"] = PS["Data.EuclideanRing"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.EuclideanRing"]; | |
| var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| // | The `EuclideanRing` class is for commutative rings that support division. | |
| // | The mathematical structure this class is based on is sometimes also called | |
| // | a *Euclidean domain*. | |
| // | | |
| // | Instances must satisfy the following laws in addition to the `Ring` | |
| // | laws: | |
| // | | |
| // | - Integral domain: `one /= zero`, and if `a` and `b` are both nonzero then | |
| // | so is their product `a * b` | |
| // | - Euclidean function `degree`: | |
| // | - Nonnegativity: For all nonzero `a`, `degree a >= 0` | |
| // | - Quotient/remainder: For all `a` and `b`, where `b` is nonzero, | |
| // | let `q = a / b` and ``r = a `mod` b``; then `a = q*b + r`, and also | |
| // | either `r = zero` or `degree r < degree b` | |
| // | - Submultiplicative euclidean function: | |
| // | - For all nonzero `a` and `b`, `degree a <= degree (a * b)` | |
| // | | |
| // | The behaviour of division by `zero` is unconstrained by these laws, | |
| // | meaning that individual instances are free to choose how to behave in this | |
| // | case. Similarly, there are no restrictions on what the result of | |
| // | `degree zero` is; it doesn't make sense to ask for `degree zero` in the | |
| // | same way that it doesn't make sense to divide by `zero`, so again, | |
| // | individual instances may choose how to handle this case. | |
| // | | |
| // | For any `EuclideanRing` which is also a `Field`, one valid choice | |
| // | for `degree` is simply `const 1`. In fact, unless there's a specific | |
| // | reason not to, `Field` types should normally use this definition of | |
| // | `degree`. | |
| var EuclideanRing = function (CommutativeRing0, degree, div, mod) { | |
| this.CommutativeRing0 = CommutativeRing0; | |
| this.degree = degree; | |
| this.div = div; | |
| this.mod = mod; | |
| }; | |
| var mod = function (dict) { | |
| return dict.mod; | |
| }; | |
| // | The *greatest common divisor* of two values. | |
| var gcd = function ($copy_dictEq) { | |
| return function ($copy_dictEuclideanRing) { | |
| return function ($copy_a) { | |
| return function ($copy_b) { | |
| var $tco_var_dictEq = $copy_dictEq; | |
| var $tco_var_dictEuclideanRing = $copy_dictEuclideanRing; | |
| var $tco_var_a = $copy_a; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(dictEq, dictEuclideanRing, a, b) { | |
| var $7 = Data_Eq.eq(dictEq)(b)(Data_Semiring.zero(((dictEuclideanRing.CommutativeRing0()).Ring0()).Semiring0())); | |
| if ($7) { | |
| $tco_done = true; | |
| return a; | |
| }; | |
| $tco_var_dictEq = dictEq; | |
| $tco_var_dictEuclideanRing = dictEuclideanRing; | |
| $tco_var_a = b; | |
| $copy_b = mod(dictEuclideanRing)(a)(b); | |
| return; | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_dictEq, $tco_var_dictEuclideanRing, $tco_var_a, $copy_b); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var euclideanRingNumber = new EuclideanRing(function () { | |
| return Data_CommutativeRing.commutativeRingNumber; | |
| }, function (v) { | |
| return 1; | |
| }, $foreign.numDiv, function (v) { | |
| return function (v1) { | |
| return 0.0; | |
| }; | |
| }); | |
| var euclideanRingInt = new EuclideanRing(function () { | |
| return Data_CommutativeRing.commutativeRingInt; | |
| }, $foreign.intDegree, $foreign.intDiv, $foreign.intMod); | |
| var div = function (dict) { | |
| return dict.div; | |
| }; | |
| // | The *least common multiple* of two values. | |
| var lcm = function (dictEq) { | |
| return function (dictEuclideanRing) { | |
| return function (a) { | |
| return function (b) { | |
| var $8 = Data_Eq.eq(dictEq)(a)(Data_Semiring.zero(((dictEuclideanRing.CommutativeRing0()).Ring0()).Semiring0())) || Data_Eq.eq(dictEq)(b)(Data_Semiring.zero(((dictEuclideanRing.CommutativeRing0()).Ring0()).Semiring0())); | |
| if ($8) { | |
| return Data_Semiring.zero(((dictEuclideanRing.CommutativeRing0()).Ring0()).Semiring0()); | |
| }; | |
| return div(dictEuclideanRing)(Data_Semiring.mul(((dictEuclideanRing.CommutativeRing0()).Ring0()).Semiring0())(a)(b))(gcd(dictEq)(dictEuclideanRing)(a)(b)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var degree = function (dict) { | |
| return dict.degree; | |
| }; | |
| exports["EuclideanRing"] = EuclideanRing; | |
| exports["degree"] = degree; | |
| exports["div"] = div; | |
| exports["gcd"] = gcd; | |
| exports["lcm"] = lcm; | |
| exports["mod"] = mod; | |
| exports["euclideanRingInt"] = euclideanRingInt; | |
| exports["euclideanRingNumber"] = euclideanRingNumber; | |
| })(PS["Data.EuclideanRing"] = PS["Data.EuclideanRing"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| // | The `DivisionRing` class is for non-zero rings in which every non-zero | |
| // | element has a multiplicative inverse. Division rings are sometimes also | |
| // | called *skew fields*. | |
| // | | |
| // | Instances must satisfy the following laws in addition to the `Ring` laws: | |
| // | | |
| // | - Non-zero ring: `one /= zero` | |
| // | - Non-zero multiplicative inverse: `recip a * a = a * recip a = one` for | |
| // | all non-zero `a` | |
| // | | |
| // | The result of `recip zero` is left undefined; individual instances may | |
| // | choose how to handle this case. | |
| // | | |
| // | If a type has both `DivisionRing` and `CommutativeRing` instances, then | |
| // | it is a field and should have a `Field` instance. | |
| var DivisionRing = function (Ring0, recip) { | |
| this.Ring0 = Ring0; | |
| this.recip = recip; | |
| }; | |
| var recip = function (dict) { | |
| return dict.recip; | |
| }; | |
| // | Right division, defined as `rightDiv a b = a * recip b`. Left and right | |
| // | division are distinct in this module because a `DivisionRing` is not | |
| // | necessarily commutative. | |
| // | | |
| // | If the type `a` is also a `EuclideanRing`, then this function is | |
| // | equivalent to `div` from the `EuclideanRing` class. When working | |
| // | abstractly, `div` should generally be preferred, unless you know that you | |
| // | need your code to work with noncommutative rings. | |
| var rightDiv = function (dictDivisionRing) { | |
| return function (a) { | |
| return function (b) { | |
| return Data_Semiring.mul((dictDivisionRing.Ring0()).Semiring0())(a)(recip(dictDivisionRing)(b)); | |
| }; | |
| }; | |
| }; | |
| // | Left division, defined as `leftDiv a b = recip b * a`. Left and right | |
| // | division are distinct in this module because a `DivisionRing` is not | |
| // | necessarily commutative. | |
| // | | |
| // | If the type `a` is also a `EuclideanRing`, then this function is | |
| // | equivalent to `div` from the `EuclideanRing` class. When working | |
| // | abstractly, `div` should generally be preferred, unless you know that you | |
| // | need your code to work with noncommutative rings. | |
| var leftDiv = function (dictDivisionRing) { | |
| return function (a) { | |
| return function (b) { | |
| return Data_Semiring.mul((dictDivisionRing.Ring0()).Semiring0())(recip(dictDivisionRing)(b))(a); | |
| }; | |
| }; | |
| }; | |
| var divisionringNumber = new DivisionRing(function () { | |
| return Data_Ring.ringNumber; | |
| }, function (x) { | |
| return 1.0 / x; | |
| }); | |
| exports["DivisionRing"] = DivisionRing; | |
| exports["leftDiv"] = leftDiv; | |
| exports["recip"] = recip; | |
| exports["rightDiv"] = rightDiv; | |
| exports["divisionringNumber"] = divisionringNumber; | |
| })(PS["Data.DivisionRing"] = PS["Data.DivisionRing"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_DivisionRing = PS["Data.DivisionRing"]; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| // | The `Field` class is for types that are (commutative) fields. | |
| // | | |
| // | Instances must satisfy the following law in addition to the | |
| // | `EuclideanRing` laws: | |
| // | | |
| // | - Non-zero multiplicative inverse: ``a `mod` b = zero`` for all `a` and `b` | |
| // | | |
| // | If a type has a `Field` instance, it should also have a `DivisionRing` | |
| // | instance. In a future release, `DivisionRing` may become a superclass of | |
| // | `Field`. | |
| var Field = function (EuclideanRing0) { | |
| this.EuclideanRing0 = EuclideanRing0; | |
| }; | |
| var fieldNumber = new Field(function () { | |
| return Data_EuclideanRing.euclideanRingNumber; | |
| }); | |
| exports["Field"] = Field; | |
| exports["fieldNumber"] = fieldNumber; | |
| })(PS["Data.Field"] = PS["Data.Field"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.foldrArray = function (f) { | |
| return function (init) { | |
| return function (xs) { | |
| var acc = init; | |
| var len = xs.length; | |
| for (var i = len - 1; i >= 0; i--) { | |
| acc = f(xs[i])(acc); | |
| } | |
| return acc; | |
| }; | |
| }; | |
| }; | |
| exports.foldlArray = function (f) { | |
| return function (init) { | |
| return function (xs) { | |
| var acc = init; | |
| var len = xs.length; | |
| for (var i = 0; i < len; i++) { | |
| acc = f(acc)(xs[i]); | |
| } | |
| return acc; | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Foldable"] = PS["Data.Foldable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.arrayExtend = function(f) { | |
| return function(xs) { | |
| return xs.map(function (_, i, xs) { | |
| return f(xs.slice(i)); | |
| }); | |
| }; | |
| }; | |
| })(PS["Control.Extend"] = PS["Control.Extend"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Extend"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| // | The `Extend` class defines the extension operator `(<<=)` | |
| // | which extends a local context-dependent computation to | |
| // | a global computation. | |
| // | | |
| // | `Extend` is the dual of `Bind`, and `(<<=)` is the dual of | |
| // | `(>>=)`. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - Associativity: `extend f <<< extend g = extend (f <<< extend g)` | |
| var Extend = function (Functor0, extend) { | |
| this.Functor0 = Functor0; | |
| this.extend = extend; | |
| }; | |
| var extendFn = function (dictSemigroup) { | |
| return new Extend(function () { | |
| return Data_Functor.functorFn; | |
| }, function (f) { | |
| return function (g) { | |
| return function (w) { | |
| return f(function (w$prime) { | |
| return g(Data_Semigroup.append(dictSemigroup)(w)(w$prime)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var extendArray = new Extend(function () { | |
| return Data_Functor.functorArray; | |
| }, $foreign.arrayExtend); | |
| var extend = function (dict) { | |
| return dict.extend; | |
| }; | |
| // | A version of `extend` with its arguments flipped. | |
| var extendFlipped = function (dictExtend) { | |
| return function (w) { | |
| return function (f) { | |
| return extend(dictExtend)(f)(w); | |
| }; | |
| }; | |
| }; | |
| // | Duplicate a comonadic context. | |
| // | | |
| // | `duplicate` is dual to `Control.Bind.join`. | |
| var duplicate = function (dictExtend) { | |
| return extend(dictExtend)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| // | Backwards co-Kleisli composition. | |
| var composeCoKleisliFlipped = function (dictExtend) { | |
| return function (f) { | |
| return function (g) { | |
| return function (w) { | |
| return f(extend(dictExtend)(g)(w)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Forwards co-Kleisli composition. | |
| var composeCoKleisli = function (dictExtend) { | |
| return function (f) { | |
| return function (g) { | |
| return function (w) { | |
| return g(extend(dictExtend)(f)(w)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Extend"] = Extend; | |
| exports["composeCoKleisli"] = composeCoKleisli; | |
| exports["composeCoKleisliFlipped"] = composeCoKleisliFlipped; | |
| exports["duplicate"] = duplicate; | |
| exports["extend"] = extend; | |
| exports["extendFlipped"] = extendFlipped; | |
| exports["extendFn"] = extendFn; | |
| exports["extendArray"] = extendArray; | |
| })(PS["Control.Extend"] = PS["Control.Extend"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Monad` type class combines the operations of the `Bind` and | |
| // | `Applicative` type classes. Therefore, `Monad` instances represent type | |
| // | constructors which support sequential composition, and also lifting of | |
| // | functions of arbitrary arity. | |
| // | | |
| // | Instances must satisfy the following laws in addition to the | |
| // | `Applicative` and `Bind` laws: | |
| // | | |
| // | - Left Identity: `pure x >>= f = f x` | |
| // | - Right Identity: `x >>= pure = x` | |
| var Monad = function (Applicative0, Bind1) { | |
| this.Applicative0 = Applicative0; | |
| this.Bind1 = Bind1; | |
| }; | |
| // | Perform a monadic action when a condition is true, where the conditional | |
| // | value is also in a monadic context. | |
| var whenM = function (dictMonad) { | |
| return function (mb) { | |
| return function (m) { | |
| return Control_Bind.bind(dictMonad.Bind1())(mb)(function (v) { | |
| return Control_Applicative.when(dictMonad.Applicative0())(v)(m); | |
| }); | |
| }; | |
| }; | |
| }; | |
| // | Perform a monadic action unless a condition is true, where the conditional | |
| // | value is also in a monadic context. | |
| var unlessM = function (dictMonad) { | |
| return function (mb) { | |
| return function (m) { | |
| return Control_Bind.bind(dictMonad.Bind1())(mb)(function (v) { | |
| return Control_Applicative.unless(dictMonad.Applicative0())(v)(m); | |
| }); | |
| }; | |
| }; | |
| }; | |
| var monadFn = new Monad(function () { | |
| return Control_Applicative.applicativeFn; | |
| }, function () { | |
| return Control_Bind.bindFn; | |
| }); | |
| var monadArray = new Monad(function () { | |
| return Control_Applicative.applicativeArray; | |
| }, function () { | |
| return Control_Bind.bindArray; | |
| }); | |
| // | `liftM1` provides a default implementation of `(<$>)` for any | |
| // | [`Monad`](#monad), without using `(<$>)` as provided by the | |
| // | [`Functor`](#functor)-[`Monad`](#monad) superclass relationship. | |
| // | | |
| // | `liftM1` can therefore be used to write [`Functor`](#functor) instances | |
| // | as follows: | |
| // | | |
| // | ```purescript | |
| // | instance functorF :: Functor F where | |
| // | map = liftM1 | |
| // | ``` | |
| var liftM1 = function (dictMonad) { | |
| return function (f) { | |
| return function (a) { | |
| return Control_Bind.bind(dictMonad.Bind1())(a)(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(f(v)); | |
| }); | |
| }; | |
| }; | |
| }; | |
| // | `ap` provides a default implementation of `(<*>)` for any | |
| // | [`Monad`](#monad), without using `(<*>)` as provided by the | |
| // | [`Apply`](#apply)-[`Monad`](#monad) superclass relationship. | |
| // | | |
| // | `ap` can therefore be used to write [`Apply`](#apply) instances as | |
| // | follows: | |
| // | | |
| // | ```purescript | |
| // | instance applyF :: Apply F where | |
| // | apply = ap | |
| // | ``` | |
| var ap = function (dictMonad) { | |
| return function (f) { | |
| return function (a) { | |
| return Control_Bind.bind(dictMonad.Bind1())(f)(function (v) { | |
| return Control_Bind.bind(dictMonad.Bind1())(a)(function (v1) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(v(v1)); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }; | |
| exports["Monad"] = Monad; | |
| exports["ap"] = ap; | |
| exports["liftM1"] = liftM1; | |
| exports["unlessM"] = unlessM; | |
| exports["whenM"] = whenM; | |
| exports["monadFn"] = monadFn; | |
| exports["monadArray"] = monadArray; | |
| })(PS["Control.Monad"] = PS["Control.Monad"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `MonadZero` type class has no members of its own; it just specifies | |
| // | that the type has both `Monad` and `Alternative` instances. | |
| // | | |
| // | Types which have `MonadZero` instances should also satisfy the following | |
| // | laws: | |
| // | | |
| // | - Annihilation: `empty >>= f = empty` | |
| var MonadZero = function (Alternative1, Monad0) { | |
| this.Alternative1 = Alternative1; | |
| this.Monad0 = Monad0; | |
| }; | |
| var monadZeroArray = new MonadZero(function () { | |
| return Control_Alternative.alternativeArray; | |
| }, function () { | |
| return Control_Monad.monadArray; | |
| }); | |
| // | Fail using `Plus` if a condition does not hold, or | |
| // | succeed using `Monad` if it does. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | import Prelude | |
| // | import Control.Monad (bind) | |
| // | import Control.MonadZero (guard) | |
| // | import Data.Array ((..)) | |
| // | | |
| // | factors :: Int -> Array Int | |
| // | factors n = do | |
| // | a <- 1..n | |
| // | b <- a..n | |
| // | guard $ a * b == n | |
| // | pure [a, b] | |
| // | ``` | |
| var guard = function (dictMonadZero) { | |
| return function (v) { | |
| if (v) { | |
| return Control_Applicative.pure((dictMonadZero.Alternative1()).Applicative0())(Data_Unit.unit); | |
| }; | |
| if (!v) { | |
| return Control_Plus.empty((dictMonadZero.Alternative1()).Plus1()); | |
| }; | |
| throw new Error("Failed pattern match at Control.MonadZero line 54, column 1 - line 54, column 52: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| exports["MonadZero"] = MonadZero; | |
| exports["guard"] = guard; | |
| exports["monadZeroArray"] = monadZeroArray; | |
| })(PS["Control.MonadZero"] = PS["Control.MonadZero"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Functor = PS["Data.Functor"]; | |
| // | A type of functor that can be used to adapt the type of a wrapped function | |
| // | where the parameterised type occurs in both the positive and negative | |
| // | position, for example, `F (a -> a)`. | |
| // | | |
| // | An `Invariant` instance should satisfy the following laws: | |
| // | | |
| // | - Identity: `imap id id = id` | |
| // | - Composition: `imap g1 g2 <<< imap f1 f2 = imap (g1 <<< f1) (f2 <<< g2)` | |
| // | | |
| var Invariant = function (imap) { | |
| this.imap = imap; | |
| }; | |
| // | As all `Functor`s are also trivially `Invariant`, this function can be | |
| // | used as the `imap` implementation for any types that has an existing | |
| // | `Functor` instance. | |
| var imapF = function (dictFunctor) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(f); | |
| }; | |
| }; | |
| }; | |
| var invariantArray = new Invariant(imapF(Data_Functor.functorArray)); | |
| var invariantFn = new Invariant(imapF(Data_Functor.functorFn)); | |
| var imap = function (dict) { | |
| return dict.imap; | |
| }; | |
| exports["Invariant"] = Invariant; | |
| exports["imap"] = imap; | |
| exports["imapF"] = imapF; | |
| exports["invariantFn"] = invariantFn; | |
| exports["invariantArray"] = invariantArray; | |
| })(PS["Data.Functor.Invariant"] = PS["Data.Functor.Invariant"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // | An alias for `true`, which can be useful in guard clauses: | |
| // | | |
| // | ```purescript | |
| // | max x y | x >= y = x | |
| // | | otherwise = y | |
| // | ``` | |
| var otherwise = true; | |
| exports["otherwise"] = otherwise; | |
| })(PS["Data.Boolean"] = PS["Data.Boolean"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Boolean = PS["Data.Boolean"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A `Monoid` is a `Semigroup` with a value `mempty`, which is both a | |
| // | left and right unit for the associative operation `<>`: | |
| // | | |
| // | ```text | |
| // | forall x. mempty <> x = x <> mempty = x | |
| // | ``` | |
| // | | |
| // | `Monoid`s are commonly used as the result of fold operations, where | |
| // | `<>` is used to combine individual results, and `mempty` gives the result | |
| // | of folding an empty collection of elements. | |
| var Monoid = function (Semigroup0, mempty) { | |
| this.Semigroup0 = Semigroup0; | |
| this.mempty = mempty; | |
| }; | |
| var monoidUnit = new Monoid(function () { | |
| return Data_Semigroup.semigroupUnit; | |
| }, Data_Unit.unit); | |
| var monoidString = new Monoid(function () { | |
| return Data_Semigroup.semigroupString; | |
| }, ""); | |
| var monoidArray = new Monoid(function () { | |
| return Data_Semigroup.semigroupArray; | |
| }, [ ]); | |
| var mempty = function (dict) { | |
| return dict.mempty; | |
| }; | |
| var monoidFn = function (dictMonoid) { | |
| return new Monoid(function () { | |
| return Data_Semigroup.semigroupFn(dictMonoid.Semigroup0()); | |
| }, Data_Function["const"](mempty(dictMonoid))); | |
| }; | |
| // | Append a value to itself a certain number of times. For the | |
| // | `Multiplicative` type, and for a non-negative power, this is the same as | |
| // | normal number exponentiation. | |
| // | | |
| // | If the second argument is negative this function will return `mempty` | |
| // | (*unlike* normal number exponentiation). The `Monoid` constraint alone | |
| // | is not enough to write a `power` function with the property that `power x | |
| // | n` cancels with `power x (-n)`, i.e. `power x n <> power x (-n) = mempty`. | |
| // | For that, we would additionally need the ability to invert elements, i.e. | |
| // | a Group. | |
| var power = function (dictMonoid) { | |
| return function (x) { | |
| var go = function (p) { | |
| if (p <= 0) { | |
| return mempty(dictMonoid); | |
| }; | |
| if (p === 1) { | |
| return x; | |
| }; | |
| if (p % 2 === 0) { | |
| var x$prime = go(p / 2 | 0); | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(x$prime)(x$prime); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| var x$prime = go(p / 2 | 0); | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(x$prime)(Data_Semigroup.append(dictMonoid.Semigroup0())(x$prime)(x)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Monoid line 48, column 3 - line 48, column 17: " + [ p.constructor.name ]); | |
| }; | |
| return go; | |
| }; | |
| }; | |
| exports["Monoid"] = Monoid; | |
| exports["mempty"] = mempty; | |
| exports["power"] = power; | |
| exports["monoidUnit"] = monoidUnit; | |
| exports["monoidFn"] = monoidFn; | |
| exports["monoidString"] = monoidString; | |
| exports["monoidArray"] = monoidArray; | |
| })(PS["Data.Monoid"] = PS["Data.Monoid"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `Maybe` type is used to represent optional values and can be seen as | |
| // | something like a type-safe `null`, where `Nothing` is `null` and `Just x` | |
| // | is the non-null value `x`. | |
| var Nothing = (function () { | |
| function Nothing() { | |
| }; | |
| Nothing.value = new Nothing(); | |
| return Nothing; | |
| })(); | |
| // | The `Maybe` type is used to represent optional values and can be seen as | |
| // | something like a type-safe `null`, where `Nothing` is `null` and `Just x` | |
| // | is the non-null value `x`. | |
| var Just = (function () { | |
| function Just(value0) { | |
| this.value0 = value0; | |
| }; | |
| Just.create = function (value0) { | |
| return new Just(value0); | |
| }; | |
| return Just; | |
| })(); | |
| // | The `Show` instance allows `Maybe` values to be rendered as a string with | |
| // | `show` whenever there is an `Show` instance for the type the `Maybe` | |
| // | contains. | |
| var showMaybe = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| if (v instanceof Just) { | |
| return "(Just " + (Data_Show.show(dictShow)(v.value0) + ")"); | |
| }; | |
| if (v instanceof Nothing) { | |
| return "Nothing"; | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 207, column 1 - line 207, column 47: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| // | The `Semigroup` instance enables use of the operator `<>` on `Maybe` values | |
| // | whenever there is a `Semigroup` instance for the type the `Maybe` contains. | |
| // | The exact behaviour of `<>` depends on the "inner" `Semigroup` instance, | |
| // | but generally captures the notion of appending or combining things. | |
| // | | |
| // | ``` purescript | |
| // | Just x <> Just y = Just (x <> y) | |
| // | Just x <> Nothing = Just x | |
| // | Nothing <> Just y = Just y | |
| // | Nothing <> Nothing = Nothing | |
| // | ``` | |
| var semigroupMaybe = function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| if (v instanceof Nothing) { | |
| return v1; | |
| }; | |
| if (v1 instanceof Nothing) { | |
| return v; | |
| }; | |
| if (v instanceof Just && v1 instanceof Just) { | |
| return new Just(Data_Semigroup.append(dictSemigroup)(v.value0)(v1.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 176, column 1 - line 176, column 62: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| }; | |
| var monoidMaybe = function (dictSemigroup) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupMaybe(dictSemigroup); | |
| }, Nothing.value); | |
| }; | |
| // | Similar to `maybe` but for use in cases where the default value may be | |
| // | expensive to compute. As PureScript is not lazy, the standard `maybe` has | |
| // | to evaluate the default value before returning the result, whereas here | |
| // | the value is only computed when the `Maybe` is known to be `Nothing`. | |
| // | | |
| // | ``` purescript | |
| // | maybe' (\_ -> x) f Nothing == x | |
| // | maybe' (\_ -> x) f (Just y) == f y | |
| // | ``` | |
| var maybe$prime = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Nothing) { | |
| return v(Data_Unit.unit); | |
| }; | |
| if (v2 instanceof Just) { | |
| return v1(v2.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 232, column 1 - line 232, column 62: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Takes a default value, a function, and a `Maybe` value. If the `Maybe` | |
| // | value is `Nothing` the default value is returned, otherwise the function | |
| // | is applied to the value inside the `Just` and the result is returned. | |
| // | | |
| // | ``` purescript | |
| // | maybe x f Nothing == x | |
| // | maybe x f (Just y) == f y | |
| // | ``` | |
| var maybe = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Nothing) { | |
| return v; | |
| }; | |
| if (v2 instanceof Just) { | |
| return v1(v2.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 219, column 1 - line 219, column 51: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Returns `true` when the `Maybe` value is `Nothing`. | |
| var isNothing = maybe(true)(Data_Function["const"](false)); | |
| // | Returns `true` when the `Maybe` value was constructed with `Just`. | |
| var isJust = maybe(false)(Data_Function["const"](true)); | |
| // | The `Functor` instance allows functions to transform the contents of a | |
| // | `Just` with the `<$>` operator: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Just x == Just (f x) | |
| // | ``` | |
| // | | |
| // | `Nothing` values are left untouched: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Nothing == Nothing | |
| // | ``` | |
| var functorMaybe = new Data_Functor.Functor(function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Just) { | |
| return new Just(v(v1.value0)); | |
| }; | |
| return Nothing.value; | |
| }; | |
| }); | |
| var invariantMaybe = new Data_Functor_Invariant.Invariant(Data_Functor_Invariant.imapF(functorMaybe)); | |
| // | Similar to `fromMaybe` but for use in cases where the default value may be | |
| // | expensive to compute. As PureScript is not lazy, the standard `fromMaybe` | |
| // | has to evaluate the default value before returning the result, whereas here | |
| // | the value is only computed when the `Maybe` is known to be `Nothing`. | |
| // | | |
| // | ``` purescript | |
| // | fromMaybe' (\_ -> x) Nothing == x | |
| // | fromMaybe' (\_ -> x) (Just y) == y | |
| // | ``` | |
| var fromMaybe$prime = function (a) { | |
| return maybe$prime(a)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| // | Takes a default value, and a `Maybe` value. If the `Maybe` value is | |
| // | `Nothing` the default value is returned, otherwise the value inside the | |
| // | `Just` is returned. | |
| // | | |
| // | ``` purescript | |
| // | fromMaybe x Nothing == x | |
| // | fromMaybe x (Just y) == y | |
| // | ``` | |
| var fromMaybe = function (a) { | |
| return maybe(a)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| // | A partial function that extracts the value from the `Just` data | |
| // | constructor. Passing `Nothing` to `fromJust` will throw an error at | |
| // | runtime. | |
| var fromJust = function (dictPartial) { | |
| return function (v) { | |
| var __unused = function (dictPartial1) { | |
| return function ($dollar34) { | |
| return $dollar34; | |
| }; | |
| }; | |
| return __unused(dictPartial)((function () { | |
| if (v instanceof Just) { | |
| return v.value0; | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 270, column 1 - line 270, column 46: " + [ v.constructor.name ]); | |
| })()); | |
| }; | |
| }; | |
| // | The `Extend` instance allows sequencing of `Maybe` values and functions | |
| // | that accept a `Maybe a` and return a non-`Maybe` result using the | |
| // | `<<=` operator. | |
| // | | |
| // | ``` purescript | |
| // | f <<= Nothing = Nothing | |
| // | f <<= Just x = Just (f x) | |
| // | ``` | |
| var extendMaybe = new Control_Extend.Extend(function () { | |
| return functorMaybe; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Nothing) { | |
| return Nothing.value; | |
| }; | |
| return new Just(v(v1)); | |
| }; | |
| }); | |
| var eqMaybe = function (dictEq) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| if (x instanceof Nothing && y instanceof Nothing) { | |
| return true; | |
| }; | |
| if (x instanceof Just && y instanceof Just) { | |
| return Data_Eq.eq(dictEq)(x.value0)(y.value0); | |
| }; | |
| return false; | |
| }; | |
| }); | |
| }; | |
| var ordMaybe = function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqMaybe(dictOrd.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| if (x instanceof Nothing && y instanceof Nothing) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| if (x instanceof Nothing) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (y instanceof Nothing) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (x instanceof Just && y instanceof Just) { | |
| return Data_Ord.compare(dictOrd)(x.value0)(y.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 196, column 8 - line 196, column 51: " + [ x.constructor.name, y.constructor.name ]); | |
| }; | |
| }); | |
| }; | |
| var eq1Maybe = new Data_Eq.Eq1(function (dictEq) { | |
| return Data_Eq.eq(eqMaybe(dictEq)); | |
| }); | |
| var ord1Maybe = new Data_Ord.Ord1(function () { | |
| return eq1Maybe; | |
| }, function (dictOrd) { | |
| return Data_Ord.compare(ordMaybe(dictOrd)); | |
| }); | |
| var boundedMaybe = function (dictBounded) { | |
| return new Data_Bounded.Bounded(function () { | |
| return ordMaybe(dictBounded.Ord0()); | |
| }, Nothing.value, new Just(Data_Bounded.top(dictBounded))); | |
| }; | |
| // | The `Apply` instance allows functions contained within a `Just` to | |
| // | transform a value contained within a `Just` using the `apply` operator: | |
| // | | |
| // | ``` purescript | |
| // | Just f <*> Just x == Just (f x) | |
| // | ``` | |
| // | | |
| // | `Nothing` values are left untouched: | |
| // | | |
| // | ``` purescript | |
| // | Just f <*> Nothing == Nothing | |
| // | Nothing <*> Just x == Nothing | |
| // | ``` | |
| // | | |
| // | Combining `Functor`'s `<$>` with `Apply`'s `<*>` can be used transform a | |
| // | pure function to take `Maybe`-typed arguments so `f :: a -> b -> c` | |
| // | becomes `f :: Maybe a -> Maybe b -> Maybe c`: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Just x <*> Just y == Just (f x y) | |
| // | ``` | |
| // | | |
| // | The `Nothing`-preserving behaviour of both operators means the result of | |
| // | an expression like the above but where any one of the values is `Nothing` | |
| // | means the whole result becomes `Nothing` also: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Nothing <*> Just y == Nothing | |
| // | f <$> Just x <*> Nothing == Nothing | |
| // | f <$> Nothing <*> Nothing == Nothing | |
| // | ``` | |
| var applyMaybe = new Control_Apply.Apply(function () { | |
| return functorMaybe; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Just) { | |
| return Data_Functor.map(functorMaybe)(v.value0)(v1); | |
| }; | |
| if (v instanceof Nothing) { | |
| return Nothing.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 68, column 1 - line 68, column 35: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| // | The `Bind` instance allows sequencing of `Maybe` values and functions that | |
| // | return a `Maybe` by using the `>>=` operator: | |
| // | | |
| // | ``` purescript | |
| // | Just x >>= f = f x | |
| // | Nothing >>= f = Nothing | |
| // | ``` | |
| var bindMaybe = new Control_Bind.Bind(function () { | |
| return applyMaybe; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Just) { | |
| return v1(v.value0); | |
| }; | |
| if (v instanceof Nothing) { | |
| return Nothing.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe line 127, column 1 - line 127, column 33: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| // | The `Applicative` instance enables lifting of values into `Maybe` with the | |
| // | `pure` or `return` function (`return` is an alias for `pure`): | |
| // | | |
| // | ``` purescript | |
| // | pure x :: Maybe _ == Just x | |
| // | return x :: Maybe _ == Just x | |
| // | ``` | |
| // | | |
| // | Combining `Functor`'s `<$>` with `Apply`'s `<*>` and `Applicative`'s | |
| // | `pure` can be used to pass a mixture of `Maybe` and non-`Maybe` typed | |
| // | values to a function that does not usually expect them, by using `pure` | |
| // | for any value that is not already `Maybe` typed: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Just x <*> pure y == Just (f x y) | |
| // | ``` | |
| // | | |
| // | Even though `pure = Just` it is recommended to use `pure` in situations | |
| // | like this as it allows the choice of `Applicative` to be changed later | |
| // | without having to go through and replace `Just` with a new constructor. | |
| var applicativeMaybe = new Control_Applicative.Applicative(function () { | |
| return applyMaybe; | |
| }, Just.create); | |
| // | The `Monad` instance guarantees that there are both `Applicative` and | |
| // | `Bind` instances for `Maybe`. This also enables the `do` syntactic sugar: | |
| // | | |
| // | ``` purescript | |
| // | do | |
| // | x' <- x | |
| // | y' <- y | |
| // | pure (f x' y') | |
| // | ``` | |
| // | | |
| // | Which is equivalent to: | |
| // | | |
| // | ``` purescript | |
| // | x >>= (\x' -> y >>= (\y' -> pure (f x' y'))) | |
| // | ``` | |
| var monadMaybe = new Control_Monad.Monad(function () { | |
| return applicativeMaybe; | |
| }, function () { | |
| return bindMaybe; | |
| }); | |
| // | The `Alt` instance allows for a choice to be made between two `Maybe` | |
| // | values with the `<|>` operator, where the first `Just` encountered | |
| // | is taken. | |
| // | | |
| // | ``` purescript | |
| // | Just x <|> Just y == Just x | |
| // | Nothing <|> Just y == Just y | |
| // | Nothing <|> Nothing == Nothing | |
| // | ``` | |
| var altMaybe = new Control_Alt.Alt(function () { | |
| return functorMaybe; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Nothing) { | |
| return v1; | |
| }; | |
| return v; | |
| }; | |
| }); | |
| // | The `Plus` instance provides a default `Maybe` value: | |
| // | | |
| // | ``` purescript | |
| // | empty :: Maybe _ == Nothing | |
| // | ``` | |
| var plusMaybe = new Control_Plus.Plus(function () { | |
| return altMaybe; | |
| }, Nothing.value); | |
| // | The `Alternative` instance guarantees that there are both `Applicative` and | |
| // | `Plus` instances for `Maybe`. | |
| var alternativeMaybe = new Control_Alternative.Alternative(function () { | |
| return applicativeMaybe; | |
| }, function () { | |
| return plusMaybe; | |
| }); | |
| var monadZeroMaybe = new Control_MonadZero.MonadZero(function () { | |
| return alternativeMaybe; | |
| }, function () { | |
| return monadMaybe; | |
| }); | |
| exports["Nothing"] = Nothing; | |
| exports["Just"] = Just; | |
| exports["fromJust"] = fromJust; | |
| exports["fromMaybe"] = fromMaybe; | |
| exports["fromMaybe'"] = fromMaybe$prime; | |
| exports["isJust"] = isJust; | |
| exports["isNothing"] = isNothing; | |
| exports["maybe"] = maybe; | |
| exports["maybe'"] = maybe$prime; | |
| exports["functorMaybe"] = functorMaybe; | |
| exports["applyMaybe"] = applyMaybe; | |
| exports["applicativeMaybe"] = applicativeMaybe; | |
| exports["altMaybe"] = altMaybe; | |
| exports["plusMaybe"] = plusMaybe; | |
| exports["alternativeMaybe"] = alternativeMaybe; | |
| exports["bindMaybe"] = bindMaybe; | |
| exports["monadMaybe"] = monadMaybe; | |
| exports["monadZeroMaybe"] = monadZeroMaybe; | |
| exports["extendMaybe"] = extendMaybe; | |
| exports["invariantMaybe"] = invariantMaybe; | |
| exports["semigroupMaybe"] = semigroupMaybe; | |
| exports["monoidMaybe"] = monoidMaybe; | |
| exports["eqMaybe"] = eqMaybe; | |
| exports["eq1Maybe"] = eq1Maybe; | |
| exports["ordMaybe"] = ordMaybe; | |
| exports["ord1Maybe"] = ord1Maybe; | |
| exports["boundedMaybe"] = boundedMaybe; | |
| exports["showMaybe"] = showMaybe; | |
| })(PS["Data.Maybe"] = PS["Data.Maybe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A type class for `newtype`s to enable convenient wrapping and unwrapping, | |
| // | and the use of the other functions in this module. | |
| // | | |
| // | The compiler can derive instances of `Newtype` automatically: | |
| // | | |
| // | ``` purescript | |
| // | newtype EmailAddress = EmailAddress String | |
| // | | |
| // | derive instance newtypeEmailAddress :: Newtype EmailAddress _ | |
| // | ``` | |
| // | | |
| // | Note that deriving for `Newtype` instances requires that the type be | |
| // | defined as `newtype` rather than `data` declaration (even if the `data` | |
| // | structurally fits the rules of a `newtype`), and the use of a wildcard for | |
| // | the wrapped type. | |
| // | | |
| // | Instances must obey the following laws: | |
| // | ``` purescript | |
| // | unwrap <<< wrap = id | |
| // | wrap <<< unwrap = id | |
| // | ``` | |
| var Newtype = function (unwrap, wrap) { | |
| this.unwrap = unwrap; | |
| this.wrap = wrap; | |
| }; | |
| var wrap = function (dict) { | |
| return dict.wrap; | |
| }; | |
| var unwrap = function (dict) { | |
| return dict.unwrap; | |
| }; | |
| // | Much like `under2`, but where the lifted binary function operates on | |
| // | values in a `Functor`. | |
| var underF2 = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($50) { | |
| return function ($51) { | |
| return Data_Functor.map(dictFunctor1)(unwrap(dictNewtype1))(Data_Function.on(f)(Data_Functor.map(dictFunctor)(wrap(dictNewtype)))($50)($51)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Much like `under`, but where the lifted function operates on values in a | |
| // | `Functor`: | |
| // | | |
| // | ``` purescript | |
| // | newtype EmailAddress = EmailAddress String | |
| // | derive instance newtypeEmailAddress :: Newtype EmailAddress _ | |
| // | | |
| // | isValid :: EmailAddress -> Boolean | |
| // | isValid x = false -- imagine a slightly less strict predicate here | |
| // | | |
| // | findValidEmailString :: Array String -> Maybe String | |
| // | findValidEmailString = underF EmailAddress (Foldable.find isValid) | |
| // | ``` | |
| // | | |
| // | The above example also demonstrates that the functor type is polymorphic | |
| // | here too, the input is an `Array` but the result is a `Maybe`. | |
| var underF = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($52) { | |
| return Data_Functor.map(dictFunctor1)(unwrap(dictNewtype1))(f(Data_Functor.map(dictFunctor)(wrap(dictNewtype))($52))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | The opposite of `over2`: lowers a binary function that operates on `Newtype`d | |
| // | values to operate on the wrapped value instead. | |
| var under2 = function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($53) { | |
| return function ($54) { | |
| return unwrap(dictNewtype1)(Data_Function.on(f)(wrap(dictNewtype))($53)($54)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | The opposite of `over`: lowers a function that operates on `Newtype`d | |
| // | values to operate on the wrapped value instead. | |
| // | | |
| // | ``` purescript | |
| // | newtype Degrees = Degrees Number | |
| // | derive instance newtypeDegrees :: Newtype Degrees _ | |
| // | | |
| // | newtype NormalDegrees = NormalDegrees Number | |
| // | derive instance newtypeNormalDegrees :: Newtype NormalDegrees _ | |
| // | | |
| // | normaliseDegrees :: Degrees -> NormalDegrees | |
| // | normaliseDegrees (Degrees deg) = NormalDegrees (deg % 360.0) | |
| // | | |
| // | asNormalDegrees :: Number -> Number | |
| // | asNormalDegrees = under Degrees normaliseDegrees | |
| // | ``` | |
| // | | |
| // | As with `over` the `Newtype` is polymorphic, as illustrated in the example | |
| // | above - both `Degrees` and `NormalDegrees` are instances of `Newtype`, | |
| // | so even though `normaliseDegrees` changes the result type we can still put | |
| // | a `Number` in and get a `Number` out via `under`. | |
| var under = function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($55) { | |
| return unwrap(dictNewtype1)(f(wrap(dictNewtype)($55))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Given a constructor for a `Newtype`, this returns the appropriate `unwrap` | |
| // | function. | |
| var un = function (dictNewtype) { | |
| return function (v) { | |
| return unwrap(dictNewtype); | |
| }; | |
| }; | |
| // | Similar to the function from the `Traversable` class, but operating within | |
| // | a newtype instead. | |
| var traverse = function (dictFunctor) { | |
| return function (dictNewtype) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($56) { | |
| return Data_Functor.map(dictFunctor)(wrap(dictNewtype))(f(unwrap(dictNewtype)($56))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Much like `over2`, but where the lifted binary function operates on | |
| // | values in a `Functor`. | |
| var overF2 = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($57) { | |
| return function ($58) { | |
| return Data_Functor.map(dictFunctor1)(wrap(dictNewtype1))(Data_Function.on(f)(Data_Functor.map(dictFunctor)(unwrap(dictNewtype)))($57)($58)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Much like `over`, but where the lifted function operates on values in a | |
| // | `Functor`: | |
| // | | |
| // | ``` purescript | |
| // | findLabel :: String -> Array Label -> Maybe Label | |
| // | findLabel s = overF Label (Foldable.find (_ == s)) | |
| // | ``` | |
| // | | |
| // | The above example also demonstrates that the functor type is polymorphic | |
| // | here too, the input is an `Array` but the result is a `Maybe`. | |
| var overF = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($59) { | |
| return Data_Functor.map(dictFunctor1)(wrap(dictNewtype1))(f(Data_Functor.map(dictFunctor)(unwrap(dictNewtype))($59))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Lifts a binary function to operate over newtypes. | |
| // | | |
| // | ``` purescript | |
| // | newtype Meter = Meter Int | |
| // | derive newtype instance newtypeMeter :: Newtype Meter _ | |
| // | newtype SquareMeter = SquareMeter Int | |
| // | derive newtype instance newtypeSquareMeter :: Newtype SquareMeter _ | |
| // | | |
| // | area :: Meter -> Meter -> SquareMeter | |
| // | area = over2 Meter (*) | |
| // | ``` | |
| // | | |
| // | The above example also demonstrates that the return type is polymorphic | |
| // | here too. | |
| var over2 = function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($60) { | |
| return function ($61) { | |
| return wrap(dictNewtype1)(Data_Function.on(f)(unwrap(dictNewtype))($60)($61)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Lifts a function operate over newtypes. This can be used to lift a | |
| // | function to manipulate the contents of a single newtype, somewhat like | |
| // | `map` does for a `Functor`: | |
| // | | |
| // | ``` purescript | |
| // | newtype Label = Label String | |
| // | derive instance newtypeLabel :: Newtype Label _ | |
| // | | |
| // | toUpperLabel :: Label -> Label | |
| // | toUpperLabel = over Label String.toUpper | |
| // | ``` | |
| // | | |
| // | But the result newtype is polymorphic, meaning the result can be returned | |
| // | as an alternative newtype: | |
| // | | |
| // | ``` purescript | |
| // | newtype UppercaseLabel = UppercaseLabel String | |
| // | derive instance newtypeUppercaseLabel :: Newtype UppercaseLabel _ | |
| // | | |
| // | toUpperLabel' :: Label -> UppercaseLabel | |
| // | toUpperLabel' = over Label String.toUpper | |
| // | ``` | |
| var over = function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($62) { | |
| return wrap(dictNewtype1)(f(unwrap(dictNewtype)($62))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Deprecated previous name of `un`. | |
| var op = function (dictNewtype) { | |
| return un(dictNewtype); | |
| }; | |
| // | Similar to the function from the `Distributive` class, but operating within | |
| // | a newtype instead. | |
| var collect = function (dictFunctor) { | |
| return function (dictNewtype) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($63) { | |
| return wrap(dictNewtype)(f(Data_Functor.map(dictFunctor)(unwrap(dictNewtype))($63))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Similar to `ala` but useful for cases where you want to use an additional | |
| // | projection with the higher order function: | |
| // | | |
| // | ``` purescript | |
| // | alaF Additive foldMap String.length ["hello", "world"] -- 10 | |
| // | alaF Multiplicative foldMap Math.abs [1.0, -2.0, 3.0, -4.0] -- 24.0 | |
| // | ``` | |
| // | | |
| // | The type admits other possibilities due to the polymorphic `Functor` | |
| // | constraints, but the case described above works because ((->) a) is a | |
| // | `Functor`. | |
| var alaF = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return function ($64) { | |
| return Data_Functor.map(dictFunctor1)(unwrap(dictNewtype1))(f(Data_Functor.map(dictFunctor)(wrap(dictNewtype))($64))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | This combinator is for when you have a higher order function that you want | |
| // | to use in the context of some newtype - `foldMap` being a common example: | |
| // | | |
| // | ``` purescript | |
| // | ala Additive foldMap [1,2,3,4] -- 10 | |
| // | ala Multiplicative foldMap [1,2,3,4] -- 24 | |
| // | ala Conj foldMap [true, false] -- false | |
| // | ala Disj foldMap [true, false] -- true | |
| // | ``` | |
| var ala = function (dictFunctor) { | |
| return function (dictNewtype) { | |
| return function (dictNewtype1) { | |
| return function (v) { | |
| return function (f) { | |
| return Data_Functor.map(dictFunctor)(unwrap(dictNewtype))(f(wrap(dictNewtype1))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Newtype"] = Newtype; | |
| exports["ala"] = ala; | |
| exports["alaF"] = alaF; | |
| exports["collect"] = collect; | |
| exports["op"] = op; | |
| exports["over"] = over; | |
| exports["over2"] = over2; | |
| exports["overF"] = overF; | |
| exports["overF2"] = overF2; | |
| exports["traverse"] = traverse; | |
| exports["un"] = un; | |
| exports["under"] = under; | |
| exports["under2"] = under2; | |
| exports["underF"] = underF; | |
| exports["underF2"] = underF2; | |
| exports["unwrap"] = unwrap; | |
| exports["wrap"] = wrap; | |
| })(PS["Data.Newtype"] = PS["Data.Newtype"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid returning the first (left-most) non-`Nothing` value. | |
| // | | |
| // | ``` purescript | |
| // | First (Just x) <> First (Just y) == First (Just x) | |
| // | First Nothing <> First (Just y) == First (Just y) | |
| // | First Nothing <> Nothing == First Nothing | |
| // | mempty :: First _ == First Nothing | |
| // | ``` | |
| var First = function (x) { | |
| return x; | |
| }; | |
| var showFirst = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "First (" + (Data_Show.show(Data_Maybe.showMaybe(dictShow))(v) + ")"); | |
| }); | |
| }; | |
| var semigroupFirst = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Maybe.Just) { | |
| return v; | |
| }; | |
| return v1; | |
| }; | |
| }); | |
| var ordFirst = function (dictOrd) { | |
| return Data_Maybe.ordMaybe(dictOrd); | |
| }; | |
| var ord1First = Data_Maybe.ord1Maybe; | |
| var newtypeFirst = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, First); | |
| var monoidFirst = new Data_Monoid.Monoid(function () { | |
| return semigroupFirst; | |
| }, Data_Maybe.Nothing.value); | |
| var monadFirst = Data_Maybe.monadMaybe; | |
| var invariantFirst = Data_Maybe.invariantMaybe; | |
| var functorFirst = Data_Maybe.functorMaybe; | |
| var extendFirst = Data_Maybe.extendMaybe; | |
| var eqFirst = function (dictEq) { | |
| return Data_Maybe.eqMaybe(dictEq); | |
| }; | |
| var eq1First = Data_Maybe.eq1Maybe; | |
| var boundedFirst = function (dictBounded) { | |
| return Data_Maybe.boundedMaybe(dictBounded); | |
| }; | |
| var bindFirst = Data_Maybe.bindMaybe; | |
| var applyFirst = Data_Maybe.applyMaybe; | |
| var applicativeFirst = Data_Maybe.applicativeMaybe; | |
| exports["First"] = First; | |
| exports["newtypeFirst"] = newtypeFirst; | |
| exports["eqFirst"] = eqFirst; | |
| exports["eq1First"] = eq1First; | |
| exports["ordFirst"] = ordFirst; | |
| exports["ord1First"] = ord1First; | |
| exports["boundedFirst"] = boundedFirst; | |
| exports["functorFirst"] = functorFirst; | |
| exports["invariantFirst"] = invariantFirst; | |
| exports["applyFirst"] = applyFirst; | |
| exports["applicativeFirst"] = applicativeFirst; | |
| exports["bindFirst"] = bindFirst; | |
| exports["monadFirst"] = monadFirst; | |
| exports["extendFirst"] = extendFirst; | |
| exports["showFirst"] = showFirst; | |
| exports["semigroupFirst"] = semigroupFirst; | |
| exports["monoidFirst"] = monoidFirst; | |
| })(PS["Data.Maybe.First"] = PS["Data.Maybe.First"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid returning the last (right-most) non-`Nothing` value. | |
| // | | |
| // | ``` purescript | |
| // | Last (Just x) <> Last (Just y) == Last (Just y) | |
| // | Last (Just x) <> Nothing == Last (Just x) | |
| // | Last Nothing <> Nothing == Last Nothing | |
| // | mempty :: Last _ == Last Nothing | |
| // | ``` | |
| var Last = function (x) { | |
| return x; | |
| }; | |
| var showLast = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Last " + (Data_Show.show(Data_Maybe.showMaybe(dictShow))(v) + ")"); | |
| }); | |
| }; | |
| var semigroupLast = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_Maybe.Just) { | |
| return v1; | |
| }; | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return v; | |
| }; | |
| throw new Error("Failed pattern match at Data.Maybe.Last line 53, column 1 - line 53, column 45: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var ordLast = function (dictOrd) { | |
| return Data_Maybe.ordMaybe(dictOrd); | |
| }; | |
| var ord1Last = Data_Maybe.ord1Maybe; | |
| var newtypeLast = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Last); | |
| var monoidLast = new Data_Monoid.Monoid(function () { | |
| return semigroupLast; | |
| }, Data_Maybe.Nothing.value); | |
| var monadLast = Data_Maybe.monadMaybe; | |
| var invariantLast = Data_Maybe.invariantMaybe; | |
| var functorLast = Data_Maybe.functorMaybe; | |
| var extendLast = Data_Maybe.extendMaybe; | |
| var eqLast = function (dictEq) { | |
| return Data_Maybe.eqMaybe(dictEq); | |
| }; | |
| var eq1Last = Data_Maybe.eq1Maybe; | |
| var boundedLast = function (dictBounded) { | |
| return Data_Maybe.boundedMaybe(dictBounded); | |
| }; | |
| var bindLast = Data_Maybe.bindMaybe; | |
| var applyLast = Data_Maybe.applyMaybe; | |
| var applicativeLast = Data_Maybe.applicativeMaybe; | |
| exports["Last"] = Last; | |
| exports["newtypeLast"] = newtypeLast; | |
| exports["eqLast"] = eqLast; | |
| exports["eq1Last"] = eq1Last; | |
| exports["ordLast"] = ordLast; | |
| exports["ord1Last"] = ord1Last; | |
| exports["boundedLast"] = boundedLast; | |
| exports["functorLast"] = functorLast; | |
| exports["invariantLast"] = invariantLast; | |
| exports["applyLast"] = applyLast; | |
| exports["applicativeLast"] = applicativeLast; | |
| exports["bindLast"] = bindLast; | |
| exports["monadLast"] = monadLast; | |
| exports["extendLast"] = extendLast; | |
| exports["showLast"] = showLast; | |
| exports["semigroupLast"] = semigroupLast; | |
| exports["monoidLast"] = monoidLast; | |
| })(PS["Data.Maybe.Last"] = PS["Data.Maybe.Last"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| // | `Comonad` extends the `Extend` class with the `extract` function | |
| // | which extracts a value, discarding the comonadic context. | |
| // | | |
| // | `Comonad` is the dual of `Monad`, and `extract` is the dual of `pure`. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - Left Identity: `extract <<= xs = xs` | |
| // | - Right Identity: `extract (f <<= xs) = f xs` | |
| var Comonad = function (Extend0, extract) { | |
| this.Extend0 = Extend0; | |
| this.extract = extract; | |
| }; | |
| var extract = function (dict) { | |
| return dict.extract; | |
| }; | |
| exports["Comonad"] = Comonad; | |
| exports["extract"] = extract; | |
| })(PS["Control.Comonad"] = PS["Control.Comonad"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid and semigroup for semirings under addition. | |
| // | | |
| // | ``` purescript | |
| // | Additive x <> Additive y == Additive (x + y) | |
| // | mempty :: Additive _ == Additive zero | |
| // | ``` | |
| var Additive = function (x) { | |
| return x; | |
| }; | |
| var showAdditive = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Additive " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semigroupAdditive = function (dictSemiring) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Data_Semiring.add(dictSemiring)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var ordAdditive = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeAdditive = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Additive); | |
| var monoidAdditive = function (dictSemiring) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupAdditive(dictSemiring); | |
| }, Data_Semiring.zero(dictSemiring)); | |
| }; | |
| var invariantAdditive = new Data_Functor_Invariant.Invariant(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return f(v1); | |
| }; | |
| }; | |
| }); | |
| var functorAdditive = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }); | |
| var extendAdditive = new Control_Extend.Extend(function () { | |
| return functorAdditive; | |
| }, function (f) { | |
| return function (x) { | |
| return f(x); | |
| }; | |
| }); | |
| var eqAdditive = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var comonadAdditive = new Control_Comonad.Comonad(function () { | |
| return extendAdditive; | |
| }, Data_Newtype.unwrap(newtypeAdditive)); | |
| var boundedAdditive = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var applyAdditive = new Control_Apply.Apply(function () { | |
| return functorAdditive; | |
| }, function (v) { | |
| return function (v1) { | |
| return v(v1); | |
| }; | |
| }); | |
| var bindAdditive = new Control_Bind.Bind(function () { | |
| return applyAdditive; | |
| }, function (v) { | |
| return function (f) { | |
| return f(v); | |
| }; | |
| }); | |
| var applicativeAdditive = new Control_Applicative.Applicative(function () { | |
| return applyAdditive; | |
| }, Additive); | |
| var monadAdditive = new Control_Monad.Monad(function () { | |
| return applicativeAdditive; | |
| }, function () { | |
| return bindAdditive; | |
| }); | |
| exports["Additive"] = Additive; | |
| exports["newtypeAdditive"] = newtypeAdditive; | |
| exports["eqAdditive"] = eqAdditive; | |
| exports["ordAdditive"] = ordAdditive; | |
| exports["boundedAdditive"] = boundedAdditive; | |
| exports["functorAdditive"] = functorAdditive; | |
| exports["invariantAdditive"] = invariantAdditive; | |
| exports["applyAdditive"] = applyAdditive; | |
| exports["applicativeAdditive"] = applicativeAdditive; | |
| exports["bindAdditive"] = bindAdditive; | |
| exports["monadAdditive"] = monadAdditive; | |
| exports["extendAdditive"] = extendAdditive; | |
| exports["comonadAdditive"] = comonadAdditive; | |
| exports["showAdditive"] = showAdditive; | |
| exports["semigroupAdditive"] = semigroupAdditive; | |
| exports["monoidAdditive"] = monoidAdditive; | |
| })(PS["Data.Monoid.Additive"] = PS["Data.Monoid.Additive"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid under conjuntion. | |
| // | | |
| // | ``` purescript | |
| // | Conj x <> Conj y == Conj (x && y) | |
| // | mempty :: Conj _ == Conj top | |
| // | ``` | |
| var Conj = function (x) { | |
| return x; | |
| }; | |
| var showConj = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Conj " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semiringConj = function (dictHeytingAlgebra) { | |
| return new Data_Semiring.Semiring(function (v) { | |
| return function (v1) { | |
| return Data_HeytingAlgebra.conj(dictHeytingAlgebra)(v)(v1); | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_HeytingAlgebra.disj(dictHeytingAlgebra)(v)(v1); | |
| }; | |
| }, Data_HeytingAlgebra.ff(dictHeytingAlgebra), Data_HeytingAlgebra.tt(dictHeytingAlgebra)); | |
| }; | |
| var semigroupConj = function (dictHeytingAlgebra) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Data_HeytingAlgebra.conj(dictHeytingAlgebra)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var ordConj = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeConj = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Conj); | |
| var monoidConj = function (dictHeytingAlgebra) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupConj(dictHeytingAlgebra); | |
| }, Data_HeytingAlgebra.tt(dictHeytingAlgebra)); | |
| }; | |
| var invariantConj = new Data_Functor_Invariant.Invariant(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return f(v1); | |
| }; | |
| }; | |
| }); | |
| var functorConj = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }); | |
| var extendConj = new Control_Extend.Extend(function () { | |
| return functorConj; | |
| }, function (f) { | |
| return function (x) { | |
| return f(x); | |
| }; | |
| }); | |
| var eqConj = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var comonadConj = new Control_Comonad.Comonad(function () { | |
| return extendConj; | |
| }, Data_Newtype.unwrap(newtypeConj)); | |
| var boundedConj = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var applyConj = new Control_Apply.Apply(function () { | |
| return functorConj; | |
| }, function (v) { | |
| return function (v1) { | |
| return v(v1); | |
| }; | |
| }); | |
| var bindConj = new Control_Bind.Bind(function () { | |
| return applyConj; | |
| }, function (v) { | |
| return function (f) { | |
| return f(v); | |
| }; | |
| }); | |
| var applicativeConj = new Control_Applicative.Applicative(function () { | |
| return applyConj; | |
| }, Conj); | |
| var monadConj = new Control_Monad.Monad(function () { | |
| return applicativeConj; | |
| }, function () { | |
| return bindConj; | |
| }); | |
| exports["Conj"] = Conj; | |
| exports["newtypeConj"] = newtypeConj; | |
| exports["eqConj"] = eqConj; | |
| exports["ordConj"] = ordConj; | |
| exports["boundedConj"] = boundedConj; | |
| exports["functorConj"] = functorConj; | |
| exports["invariantConj"] = invariantConj; | |
| exports["applyConj"] = applyConj; | |
| exports["applicativeConj"] = applicativeConj; | |
| exports["bindConj"] = bindConj; | |
| exports["monadConj"] = monadConj; | |
| exports["extendConj"] = extendConj; | |
| exports["comonadConj"] = comonadConj; | |
| exports["showConj"] = showConj; | |
| exports["semigroupConj"] = semigroupConj; | |
| exports["monoidConj"] = monoidConj; | |
| exports["semiringConj"] = semiringConj; | |
| })(PS["Data.Monoid.Conj"] = PS["Data.Monoid.Conj"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid under disjuntion. | |
| // | | |
| // | ``` purescript | |
| // | Disj x <> Disj y == Disj (x || y) | |
| // | mempty :: Disj _ == Disj bottom | |
| // | ``` | |
| var Disj = function (x) { | |
| return x; | |
| }; | |
| var showDisj = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Disj " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semiringDisj = function (dictHeytingAlgebra) { | |
| return new Data_Semiring.Semiring(function (v) { | |
| return function (v1) { | |
| return Data_HeytingAlgebra.disj(dictHeytingAlgebra)(v)(v1); | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_HeytingAlgebra.conj(dictHeytingAlgebra)(v)(v1); | |
| }; | |
| }, Data_HeytingAlgebra.tt(dictHeytingAlgebra), Data_HeytingAlgebra.ff(dictHeytingAlgebra)); | |
| }; | |
| var semigroupDisj = function (dictHeytingAlgebra) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Data_HeytingAlgebra.disj(dictHeytingAlgebra)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var ordDisj = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeDisj = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Disj); | |
| var monoidDisj = function (dictHeytingAlgebra) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupDisj(dictHeytingAlgebra); | |
| }, Data_HeytingAlgebra.ff(dictHeytingAlgebra)); | |
| }; | |
| var invariantDisj = new Data_Functor_Invariant.Invariant(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return f(v1); | |
| }; | |
| }; | |
| }); | |
| var functorDisj = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }); | |
| var extendDisj = new Control_Extend.Extend(function () { | |
| return functorDisj; | |
| }, function (f) { | |
| return function (x) { | |
| return f(x); | |
| }; | |
| }); | |
| var eqDisj = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var comonadDisj = new Control_Comonad.Comonad(function () { | |
| return extendDisj; | |
| }, Data_Newtype.unwrap(newtypeDisj)); | |
| var boundedDisj = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var applyDisj = new Control_Apply.Apply(function () { | |
| return functorDisj; | |
| }, function (v) { | |
| return function (v1) { | |
| return v(v1); | |
| }; | |
| }); | |
| var bindDisj = new Control_Bind.Bind(function () { | |
| return applyDisj; | |
| }, function (v) { | |
| return function (f) { | |
| return f(v); | |
| }; | |
| }); | |
| var applicativeDisj = new Control_Applicative.Applicative(function () { | |
| return applyDisj; | |
| }, Disj); | |
| var monadDisj = new Control_Monad.Monad(function () { | |
| return applicativeDisj; | |
| }, function () { | |
| return bindDisj; | |
| }); | |
| exports["Disj"] = Disj; | |
| exports["newtypeDisj"] = newtypeDisj; | |
| exports["eqDisj"] = eqDisj; | |
| exports["ordDisj"] = ordDisj; | |
| exports["boundedDisj"] = boundedDisj; | |
| exports["functorDisj"] = functorDisj; | |
| exports["invariantDisj"] = invariantDisj; | |
| exports["applyDisj"] = applyDisj; | |
| exports["applicativeDisj"] = applicativeDisj; | |
| exports["bindDisj"] = bindDisj; | |
| exports["monadDisj"] = monadDisj; | |
| exports["extendDisj"] = extendDisj; | |
| exports["comonadDisj"] = comonadDisj; | |
| exports["showDisj"] = showDisj; | |
| exports["semigroupDisj"] = semigroupDisj; | |
| exports["monoidDisj"] = monoidDisj; | |
| exports["semiringDisj"] = semiringDisj; | |
| })(PS["Data.Monoid.Disj"] = PS["Data.Monoid.Disj"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The dual of a monoid. | |
| // | | |
| // | ``` purescript | |
| // | Dual x <> Dual y == Dual (y <> x) | |
| // | mempty :: Dual _ == Dual mempty | |
| // | ``` | |
| var Dual = function (x) { | |
| return x; | |
| }; | |
| var showDual = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Dual " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semigroupDual = function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Data_Semigroup.append(dictSemigroup)(v1)(v); | |
| }; | |
| }); | |
| }; | |
| var ordDual = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeDual = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Dual); | |
| var monoidDual = function (dictMonoid) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupDual(dictMonoid.Semigroup0()); | |
| }, Data_Monoid.mempty(dictMonoid)); | |
| }; | |
| var invariantDual = new Data_Functor_Invariant.Invariant(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return f(v1); | |
| }; | |
| }; | |
| }); | |
| var functorDual = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }); | |
| var extendDual = new Control_Extend.Extend(function () { | |
| return functorDual; | |
| }, function (f) { | |
| return function (x) { | |
| return f(x); | |
| }; | |
| }); | |
| var eqDual = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var comonadDual = new Control_Comonad.Comonad(function () { | |
| return extendDual; | |
| }, Data_Newtype.unwrap(newtypeDual)); | |
| var boundedDual = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var applyDual = new Control_Apply.Apply(function () { | |
| return functorDual; | |
| }, function (v) { | |
| return function (v1) { | |
| return v(v1); | |
| }; | |
| }); | |
| var bindDual = new Control_Bind.Bind(function () { | |
| return applyDual; | |
| }, function (v) { | |
| return function (f) { | |
| return f(v); | |
| }; | |
| }); | |
| var applicativeDual = new Control_Applicative.Applicative(function () { | |
| return applyDual; | |
| }, Dual); | |
| var monadDual = new Control_Monad.Monad(function () { | |
| return applicativeDual; | |
| }, function () { | |
| return bindDual; | |
| }); | |
| exports["Dual"] = Dual; | |
| exports["newtypeDual"] = newtypeDual; | |
| exports["eqDual"] = eqDual; | |
| exports["ordDual"] = ordDual; | |
| exports["boundedDual"] = boundedDual; | |
| exports["functorDual"] = functorDual; | |
| exports["invariantDual"] = invariantDual; | |
| exports["applyDual"] = applyDual; | |
| exports["applicativeDual"] = applicativeDual; | |
| exports["bindDual"] = bindDual; | |
| exports["monadDual"] = monadDual; | |
| exports["extendDual"] = extendDual; | |
| exports["comonadDual"] = comonadDual; | |
| exports["showDual"] = showDual; | |
| exports["semigroupDual"] = semigroupDual; | |
| exports["monoidDual"] = monoidDual; | |
| })(PS["Data.Monoid.Dual"] = PS["Data.Monoid.Dual"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid of endomorphisms under composition. | |
| // | | |
| // | Composes of functions of type `a -> a`: | |
| // | ``` purescript | |
| // | Endo f <> Endo g == Endo (f <<< g) | |
| // | mempty :: Endo _ == Endo id | |
| // | ``` | |
| var Endo = function (x) { | |
| return x; | |
| }; | |
| var semigroupEndo = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return function ($11) { | |
| return v(v1($11)); | |
| }; | |
| }; | |
| }); | |
| var newtypeEndo = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Endo); | |
| var monoidEndo = new Data_Monoid.Monoid(function () { | |
| return semigroupEndo; | |
| }, Control_Category.id(Control_Category.categoryFn)); | |
| var invariantEndo = new Data_Functor_Invariant.Invariant(function (ab) { | |
| return function (ba) { | |
| return function (v) { | |
| return function ($12) { | |
| return ab(v(ba($12))); | |
| }; | |
| }; | |
| }; | |
| }); | |
| exports["Endo"] = Endo; | |
| exports["newtypeEndo"] = newtypeEndo; | |
| exports["invariantEndo"] = invariantEndo; | |
| exports["semigroupEndo"] = semigroupEndo; | |
| exports["monoidEndo"] = monoidEndo; | |
| })(PS["Data.Monoid.Endo"] = PS["Data.Monoid.Endo"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Monoid and semigroup for semirings under multiplication. | |
| // | | |
| // | ``` purescript | |
| // | Multiplicative x <> Multiplicative y == Multiplicative (x * y) | |
| // | mempty :: Multiplicative _ == Multiplicative one | |
| // | ``` | |
| var Multiplicative = function (x) { | |
| return x; | |
| }; | |
| var showMultiplicative = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Multiplicative " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semigroupMultiplicative = function (dictSemiring) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Data_Semiring.mul(dictSemiring)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var ordMultiplicative = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeMultiplicative = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Multiplicative); | |
| var monoidMultiplicative = function (dictSemiring) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupMultiplicative(dictSemiring); | |
| }, Data_Semiring.one(dictSemiring)); | |
| }; | |
| var invariantMultiplicative = new Data_Functor_Invariant.Invariant(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return f(v1); | |
| }; | |
| }; | |
| }); | |
| var functorMultiplicative = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }); | |
| var extendMultiplicative = new Control_Extend.Extend(function () { | |
| return functorMultiplicative; | |
| }, function (f) { | |
| return function (x) { | |
| return f(x); | |
| }; | |
| }); | |
| var eqMultiplicative = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var comonadMultiplicative = new Control_Comonad.Comonad(function () { | |
| return extendMultiplicative; | |
| }, Data_Newtype.unwrap(newtypeMultiplicative)); | |
| var boundedMultiplicative = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var applyMultiplicative = new Control_Apply.Apply(function () { | |
| return functorMultiplicative; | |
| }, function (v) { | |
| return function (v1) { | |
| return v(v1); | |
| }; | |
| }); | |
| var bindMultiplicative = new Control_Bind.Bind(function () { | |
| return applyMultiplicative; | |
| }, function (v) { | |
| return function (f) { | |
| return f(v); | |
| }; | |
| }); | |
| var applicativeMultiplicative = new Control_Applicative.Applicative(function () { | |
| return applyMultiplicative; | |
| }, Multiplicative); | |
| var monadMultiplicative = new Control_Monad.Monad(function () { | |
| return applicativeMultiplicative; | |
| }, function () { | |
| return bindMultiplicative; | |
| }); | |
| exports["Multiplicative"] = Multiplicative; | |
| exports["newtypeMultiplicative"] = newtypeMultiplicative; | |
| exports["eqMultiplicative"] = eqMultiplicative; | |
| exports["ordMultiplicative"] = ordMultiplicative; | |
| exports["boundedMultiplicative"] = boundedMultiplicative; | |
| exports["functorMultiplicative"] = functorMultiplicative; | |
| exports["invariantMultiplicative"] = invariantMultiplicative; | |
| exports["applyMultiplicative"] = applyMultiplicative; | |
| exports["applicativeMultiplicative"] = applicativeMultiplicative; | |
| exports["bindMultiplicative"] = bindMultiplicative; | |
| exports["monadMultiplicative"] = monadMultiplicative; | |
| exports["extendMultiplicative"] = extendMultiplicative; | |
| exports["comonadMultiplicative"] = comonadMultiplicative; | |
| exports["showMultiplicative"] = showMultiplicative; | |
| exports["semigroupMultiplicative"] = semigroupMultiplicative; | |
| exports["monoidMultiplicative"] = monoidMultiplicative; | |
| })(PS["Data.Monoid.Multiplicative"] = PS["Data.Monoid.Multiplicative"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Foldable"]; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Maybe_First = PS["Data.Maybe.First"]; | |
| var Data_Maybe_Last = PS["Data.Maybe.Last"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Monoid_Additive = PS["Data.Monoid.Additive"]; | |
| var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; | |
| var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; | |
| var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; | |
| var Data_Monoid_Endo = PS["Data.Monoid.Endo"]; | |
| var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | `Foldable` represents data structures which can be _folded_. | |
| // | | |
| // | - `foldr` folds a structure from the right | |
| // | - `foldl` folds a structure from the left | |
| // | - `foldMap` folds a structure by accumulating values in a `Monoid` | |
| // | | |
| // | Default implementations are provided by the following functions: | |
| // | | |
| // | - `foldrDefault` | |
| // | - `foldlDefault` | |
| // | - `foldMapDefaultR` | |
| // | - `foldMapDefaultL` | |
| // | | |
| // | Note: some combinations of the default implementations are unsafe to | |
| // | use together - causing a non-terminating mutually recursive cycle. | |
| // | These combinations are documented per function. | |
| var Foldable = function (foldMap, foldl, foldr) { | |
| this.foldMap = foldMap; | |
| this.foldl = foldl; | |
| this.foldr = foldr; | |
| }; | |
| var foldr = function (dict) { | |
| return dict.foldr; | |
| }; | |
| // | Test whether the structure is empty. | |
| // | Optimized for structures that are similar to cons-lists, because there | |
| // | is no general way to do better. | |
| var $$null = function (dictFoldable) { | |
| return foldr(dictFoldable)(function (v) { | |
| return function (v1) { | |
| return false; | |
| }; | |
| })(true); | |
| }; | |
| // | Combines a collection of elements using the `Alt` operation. | |
| var oneOf = function (dictFoldable) { | |
| return function (dictPlus) { | |
| return foldr(dictFoldable)(Control_Alt.alt(dictPlus.Alt0()))(Control_Plus.empty(dictPlus)); | |
| }; | |
| }; | |
| // | Traverse a data structure, performing some effects encoded by an | |
| // | `Applicative` functor at each value, ignoring the final result. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | traverse_ print [1, 2, 3] | |
| // | ``` | |
| var traverse_ = function (dictApplicative) { | |
| return function (dictFoldable) { | |
| return function (f) { | |
| return foldr(dictFoldable)(function ($181) { | |
| return Control_Apply.applySecond(dictApplicative.Apply0())(f($181)); | |
| })(Control_Applicative.pure(dictApplicative)(Data_Unit.unit)); | |
| }; | |
| }; | |
| }; | |
| // | A version of `traverse_` with its arguments flipped. | |
| // | | |
| // | This can be useful when running an action written using do notation | |
| // | for every element in a data structure: | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | for_ [1, 2, 3] \n -> do | |
| // | print n | |
| // | trace "squared is" | |
| // | print (n * n) | |
| // | ``` | |
| var for_ = function (dictApplicative) { | |
| return function (dictFoldable) { | |
| return Data_Function.flip(traverse_(dictApplicative)(dictFoldable)); | |
| }; | |
| }; | |
| // | Perform all of the effects in some data structure in the order | |
| // | given by the `Foldable` instance, ignoring the final result. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | sequence_ [ trace "Hello, ", trace " world!" ] | |
| // | ``` | |
| var sequence_ = function (dictApplicative) { | |
| return function (dictFoldable) { | |
| return traverse_(dictApplicative)(dictFoldable)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var foldl = function (dict) { | |
| return dict.foldl; | |
| }; | |
| // | Fold a data structure, accumulating values in some `Monoid`, | |
| // | combining adjacent elements using the specified separator. | |
| var intercalate = function (dictFoldable) { | |
| return function (dictMonoid) { | |
| return function (sep) { | |
| return function (xs) { | |
| var go = function (v) { | |
| return function (x) { | |
| if (v.init) { | |
| return { | |
| init: false, | |
| acc: x | |
| }; | |
| }; | |
| return { | |
| init: false, | |
| acc: Data_Semigroup.append(dictMonoid.Semigroup0())(v.acc)(Data_Semigroup.append(dictMonoid.Semigroup0())(sep)(x)) | |
| }; | |
| }; | |
| }; | |
| return (foldl(dictFoldable)(go)({ | |
| init: true, | |
| acc: Data_Monoid.mempty(dictMonoid) | |
| })(xs)).acc; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Returns the size/length of a finite structure. | |
| // | Optimized for structures that are similar to cons-lists, because there | |
| // | is no general way to do better. | |
| var length = function (dictFoldable) { | |
| return function (dictSemiring) { | |
| return foldl(dictFoldable)(function (c) { | |
| return function (v) { | |
| return Data_Semiring.add(dictSemiring)(Data_Semiring.one(dictSemiring))(c); | |
| }; | |
| })(Data_Semiring.zero(dictSemiring)); | |
| }; | |
| }; | |
| // | Find the largest element of a structure, according to a given comparison | |
| // | function. The comparison function should represent a total ordering (see | |
| // | the `Ord` type class laws); if it does not, the behaviour is undefined. | |
| var maximumBy = function (dictFoldable) { | |
| return function (cmp) { | |
| var max$prime = function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return new Data_Maybe.Just(v1); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return new Data_Maybe.Just((function () { | |
| var $104 = Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(v.value0)(v1))(Data_Ordering.GT.value); | |
| if ($104) { | |
| return v.value0; | |
| }; | |
| return v1; | |
| })()); | |
| }; | |
| throw new Error("Failed pattern match at Data.Foldable line 347, column 3 - line 347, column 27: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| return foldl(dictFoldable)(max$prime)(Data_Maybe.Nothing.value); | |
| }; | |
| }; | |
| // | Find the largest element of a structure, according to its `Ord` instance. | |
| var maximum = function (dictOrd) { | |
| return function (dictFoldable) { | |
| return maximumBy(dictFoldable)(Data_Ord.compare(dictOrd)); | |
| }; | |
| }; | |
| // | Find the smallest element of a structure, according to a given comparison | |
| // | function. The comparison function should represent a total ordering (see | |
| // | the `Ord` type class laws); if it does not, the behaviour is undefined. | |
| var minimumBy = function (dictFoldable) { | |
| return function (cmp) { | |
| var min$prime = function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return new Data_Maybe.Just(v1); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return new Data_Maybe.Just((function () { | |
| var $108 = Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(v.value0)(v1))(Data_Ordering.LT.value); | |
| if ($108) { | |
| return v.value0; | |
| }; | |
| return v1; | |
| })()); | |
| }; | |
| throw new Error("Failed pattern match at Data.Foldable line 360, column 3 - line 360, column 27: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| return foldl(dictFoldable)(min$prime)(Data_Maybe.Nothing.value); | |
| }; | |
| }; | |
| // | Find the smallest element of a structure, according to its `Ord` instance. | |
| var minimum = function (dictOrd) { | |
| return function (dictFoldable) { | |
| return minimumBy(dictFoldable)(Data_Ord.compare(dictOrd)); | |
| }; | |
| }; | |
| // | Find the product of the numeric values in a data structure. | |
| var product = function (dictFoldable) { | |
| return function (dictSemiring) { | |
| return foldl(dictFoldable)(Data_Semiring.mul(dictSemiring))(Data_Semiring.one(dictSemiring)); | |
| }; | |
| }; | |
| // | Find the sum of the numeric values in a data structure. | |
| var sum = function (dictFoldable) { | |
| return function (dictSemiring) { | |
| return foldl(dictFoldable)(Data_Semiring.add(dictSemiring))(Data_Semiring.zero(dictSemiring)); | |
| }; | |
| }; | |
| var foldableMultiplicative = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v)(z); | |
| }; | |
| }; | |
| }); | |
| var foldableMaybe = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Data_Monoid.mempty(dictMonoid); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return f(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ f.constructor.name, v.constructor.name ]); | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (z) { | |
| return function (v1) { | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return z; | |
| }; | |
| if (v1 instanceof Data_Maybe.Just) { | |
| return v(z)(v1.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (z) { | |
| return function (v1) { | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return z; | |
| }; | |
| if (v1 instanceof Data_Maybe.Just) { | |
| return v(v1.value0)(z); | |
| }; | |
| throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| var foldableDual = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v)(z); | |
| }; | |
| }; | |
| }); | |
| var foldableDisj = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v)(z); | |
| }; | |
| }; | |
| }); | |
| var foldableConj = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v)(z); | |
| }; | |
| }; | |
| }); | |
| var foldableAdditive = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v)(z); | |
| }; | |
| }; | |
| }); | |
| // | A default implementation of `foldMap` using `foldr`. | |
| // | | |
| // | Note: when defining a `Foldable` instance, this function is unsafe to use | |
| // | in combination with `foldrDefault`. | |
| var foldMapDefaultR = function (dictFoldable) { | |
| return function (dictMonoid) { | |
| return function (f) { | |
| return foldr(dictFoldable)(function (x) { | |
| return function (acc) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(f(x))(acc); | |
| }; | |
| })(Data_Monoid.mempty(dictMonoid)); | |
| }; | |
| }; | |
| }; | |
| var foldableArray = new Foldable(function (dictMonoid) { | |
| return foldMapDefaultR(foldableArray)(dictMonoid); | |
| }, $foreign.foldlArray, $foreign.foldrArray); | |
| // | A default implementation of `foldMap` using `foldl`. | |
| // | | |
| // | Note: when defining a `Foldable` instance, this function is unsafe to use | |
| // | in combination with `foldlDefault`. | |
| var foldMapDefaultL = function (dictFoldable) { | |
| return function (dictMonoid) { | |
| return function (f) { | |
| return foldl(dictFoldable)(function (acc) { | |
| return function (x) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f(x)); | |
| }; | |
| })(Data_Monoid.mempty(dictMonoid)); | |
| }; | |
| }; | |
| }; | |
| var foldMap = function (dict) { | |
| return dict.foldMap; | |
| }; | |
| var foldableFirst = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return foldMap(foldableMaybe)(dictMonoid)(f)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return foldl(foldableMaybe)(f)(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return foldr(foldableMaybe)(f)(z)(v); | |
| }; | |
| }; | |
| }); | |
| var foldableLast = new Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return foldMap(foldableMaybe)(dictMonoid)(f)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return foldl(foldableMaybe)(f)(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return foldr(foldableMaybe)(f)(z)(v); | |
| }; | |
| }; | |
| }); | |
| // | A default implementation of `foldl` using `foldMap`. | |
| // | | |
| // | Note: when defining a `Foldable` instance, this function is unsafe to use | |
| // | in combination with `foldMapDefaultL`. | |
| var foldlDefault = function (dictFoldable) { | |
| return function (c) { | |
| return function (u) { | |
| return function (xs) { | |
| return Data_Newtype.unwrap(Data_Monoid_Endo.newtypeEndo)(Data_Newtype.unwrap(Data_Monoid_Dual.newtypeDual)(foldMap(dictFoldable)(Data_Monoid_Dual.monoidDual(Data_Monoid_Endo.monoidEndo))(function ($182) { | |
| return Data_Monoid_Dual.Dual(Data_Monoid_Endo.Endo(Data_Function.flip(c)($182))); | |
| })(xs)))(u); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | A default implementation of `foldr` using `foldMap`. | |
| // | | |
| // | Note: when defining a `Foldable` instance, this function is unsafe to use | |
| // | in combination with `foldMapDefaultR`. | |
| var foldrDefault = function (dictFoldable) { | |
| return function (c) { | |
| return function (u) { | |
| return function (xs) { | |
| return Data_Newtype.unwrap(Data_Monoid_Endo.newtypeEndo)(foldMap(dictFoldable)(Data_Monoid_Endo.monoidEndo)(function ($183) { | |
| return Data_Monoid_Endo.Endo(c($183)); | |
| })(xs))(u); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | `foldMap` but with each element surrounded by some fixed value. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | > surroundMap "*" show [] | |
| // | = "*" | |
| // | | |
| // | > surroundMap "*" show [1] | |
| // | = "*1*" | |
| // | | |
| // | > surroundMap "*" show [1, 2] | |
| // | = "*1*2*" | |
| // | | |
| // | > surroundMap "*" show [1, 2, 3] | |
| // | = "*1*2*3*" | |
| // | ``` | |
| var surroundMap = function (dictFoldable) { | |
| return function (dictSemigroup) { | |
| return function (d) { | |
| return function (t) { | |
| return function (f) { | |
| var joined = function (a) { | |
| return function (m) { | |
| return Data_Semigroup.append(dictSemigroup)(d)(Data_Semigroup.append(dictSemigroup)(t(a))(m)); | |
| }; | |
| }; | |
| return Data_Newtype.unwrap(Data_Monoid_Endo.newtypeEndo)(foldMap(dictFoldable)(Data_Monoid_Endo.monoidEndo)(joined)(f))(d); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | `fold` but with each element surrounded by some fixed value. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | > surround "*" [] | |
| // | = "*" | |
| // | | |
| // | > surround "*" ["1"] | |
| // | = "*1*" | |
| // | | |
| // | > surround "*" ["1", "2"] | |
| // | = "*1*2*" | |
| // | | |
| // | > surround "*" ["1", "2", "3"] | |
| // | = "*1*2*3*" | |
| // | ``` | |
| var surround = function (dictFoldable) { | |
| return function (dictSemigroup) { | |
| return function (d) { | |
| return surroundMap(dictFoldable)(dictSemigroup)(d)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| }; | |
| // | Similar to 'foldl', but the result is encapsulated in a monad. | |
| // | | |
| // | Note: this function is not generally stack-safe, e.g., for monads which | |
| // | build up thunks a la `Eff`. | |
| var foldM = function (dictFoldable) { | |
| return function (dictMonad) { | |
| return function (f) { | |
| return function (a0) { | |
| return foldl(dictFoldable)(function (ma) { | |
| return function (b) { | |
| return Control_Bind.bind(dictMonad.Bind1())(ma)(Data_Function.flip(f)(b)); | |
| }; | |
| })(Control_Applicative.pure(dictMonad.Applicative0())(a0)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Fold a data structure, accumulating values in some `Monoid`. | |
| var fold = function (dictFoldable) { | |
| return function (dictMonoid) { | |
| return foldMap(dictFoldable)(dictMonoid)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | Try to find an element in a data structure which satisfies a predicate mapping. | |
| var findMap = function (dictFoldable) { | |
| return function (p) { | |
| var go = function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return p(v1); | |
| }; | |
| return v; | |
| }; | |
| }; | |
| return foldl(dictFoldable)(go)(Data_Maybe.Nothing.value); | |
| }; | |
| }; | |
| // | Try to find an element in a data structure which satisfies a predicate. | |
| var find = function (dictFoldable) { | |
| return function (p) { | |
| var go = function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Maybe.Nothing && p(v1)) { | |
| return new Data_Maybe.Just(v1); | |
| }; | |
| return v; | |
| }; | |
| }; | |
| return foldl(dictFoldable)(go)(Data_Maybe.Nothing.value); | |
| }; | |
| }; | |
| // | `any f` is the same as `or <<< map f`; map a function over the structure, | |
| // | and then get the disjunction of the results. | |
| var any = function (dictFoldable) { | |
| return function (dictHeytingAlgebra) { | |
| return Data_Newtype.alaF(Data_Functor.functorFn)(Data_Functor.functorFn)(Data_Monoid_Disj.newtypeDisj)(Data_Monoid_Disj.newtypeDisj)(Data_Monoid_Disj.Disj)(foldMap(dictFoldable)(Data_Monoid_Disj.monoidDisj(dictHeytingAlgebra))); | |
| }; | |
| }; | |
| // | Test whether a value is an element of a data structure. | |
| var elem = function (dictFoldable) { | |
| return function (dictEq) { | |
| return function ($184) { | |
| return any(dictFoldable)(Data_HeytingAlgebra.heytingAlgebraBoolean)(Data_Eq.eq(dictEq)($184)); | |
| }; | |
| }; | |
| }; | |
| // | Test whether a value is not an element of a data structure. | |
| var notElem = function (dictFoldable) { | |
| return function (dictEq) { | |
| return function (x) { | |
| return function ($185) { | |
| return !elem(dictFoldable)(dictEq)(x)($185); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | The disjunction of all the values in a data structure. When specialized | |
| // | to `Boolean`, this function will test whether any of the values in a data | |
| // | structure is `true`. | |
| var or = function (dictFoldable) { | |
| return function (dictHeytingAlgebra) { | |
| return any(dictFoldable)(dictHeytingAlgebra)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | `all f` is the same as `and <<< map f`; map a function over the structure, | |
| // | and then get the conjunction of the results. | |
| var all = function (dictFoldable) { | |
| return function (dictHeytingAlgebra) { | |
| return Data_Newtype.alaF(Data_Functor.functorFn)(Data_Functor.functorFn)(Data_Monoid_Conj.newtypeConj)(Data_Monoid_Conj.newtypeConj)(Data_Monoid_Conj.Conj)(foldMap(dictFoldable)(Data_Monoid_Conj.monoidConj(dictHeytingAlgebra))); | |
| }; | |
| }; | |
| // | The conjunction of all the values in a data structure. When specialized | |
| // | to `Boolean`, this function will test whether all of the values in a data | |
| // | structure are `true`. | |
| var and = function (dictFoldable) { | |
| return function (dictHeytingAlgebra) { | |
| return all(dictFoldable)(dictHeytingAlgebra)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| exports["Foldable"] = Foldable; | |
| exports["all"] = all; | |
| exports["and"] = and; | |
| exports["any"] = any; | |
| exports["elem"] = elem; | |
| exports["find"] = find; | |
| exports["findMap"] = findMap; | |
| exports["fold"] = fold; | |
| exports["foldM"] = foldM; | |
| exports["foldMap"] = foldMap; | |
| exports["foldMapDefaultL"] = foldMapDefaultL; | |
| exports["foldMapDefaultR"] = foldMapDefaultR; | |
| exports["foldl"] = foldl; | |
| exports["foldlDefault"] = foldlDefault; | |
| exports["foldr"] = foldr; | |
| exports["foldrDefault"] = foldrDefault; | |
| exports["for_"] = for_; | |
| exports["intercalate"] = intercalate; | |
| exports["length"] = length; | |
| exports["maximum"] = maximum; | |
| exports["maximumBy"] = maximumBy; | |
| exports["minimum"] = minimum; | |
| exports["minimumBy"] = minimumBy; | |
| exports["notElem"] = notElem; | |
| exports["null"] = $$null; | |
| exports["oneOf"] = oneOf; | |
| exports["or"] = or; | |
| exports["product"] = product; | |
| exports["sequence_"] = sequence_; | |
| exports["sum"] = sum; | |
| exports["surround"] = surround; | |
| exports["surroundMap"] = surroundMap; | |
| exports["traverse_"] = traverse_; | |
| exports["foldableArray"] = foldableArray; | |
| exports["foldableMaybe"] = foldableMaybe; | |
| exports["foldableFirst"] = foldableFirst; | |
| exports["foldableLast"] = foldableLast; | |
| exports["foldableAdditive"] = foldableAdditive; | |
| exports["foldableDual"] = foldableDual; | |
| exports["foldableDisj"] = foldableDisj; | |
| exports["foldableConj"] = foldableConj; | |
| exports["foldableMultiplicative"] = foldableMultiplicative; | |
| })(PS["Data.Foldable"] = PS["Data.Foldable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Void = PS["Data.Void"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A `Contravariant` functor can be seen as a way of changing the input type | |
| // | of a consumer of input, in contrast to the standard covariant `Functor` | |
| // | that can be seen as a way of changing the output type of a producer of | |
| // | output. | |
| // | | |
| // | `Contravariant` instances should satisfy the following laws: | |
| // | | |
| // | - Identity `(>$<) id = id` | |
| // | - Composition `(f >$<) <<< (g >$<) = (>$<) (g <<< f)` | |
| var Contravariant = function (cmap) { | |
| this.cmap = cmap; | |
| }; | |
| var cmap = function (dict) { | |
| return dict.cmap; | |
| }; | |
| // | `cmapFlipped` is `cmap` with its arguments reversed. | |
| var cmapFlipped = function (dictContravariant) { | |
| return function (x) { | |
| return function (f) { | |
| return cmap(dictContravariant)(f)(x); | |
| }; | |
| }; | |
| }; | |
| var coerce = function (dictContravariant) { | |
| return function (dictFunctor) { | |
| return function (a) { | |
| return Data_Functor.map(dictFunctor)(Data_Void.absurd)(cmap(dictContravariant)(Data_Void.absurd)(a)); | |
| }; | |
| }; | |
| }; | |
| exports["Contravariant"] = Contravariant; | |
| exports["cmap"] = cmap; | |
| exports["cmapFlipped"] = cmapFlipped; | |
| exports["coerce"] = coerce; | |
| })(PS["Data.Functor.Contravariant"] = PS["Data.Functor.Contravariant"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // jshint maxparams: 3 | |
| exports.traverseArrayImpl = function () { | |
| function Cont(fn) { | |
| this.fn = fn; | |
| } | |
| var emptyList = {}; | |
| var ConsCell = function (head, tail) { | |
| this.head = head; | |
| this.tail = tail; | |
| }; | |
| function consList(x) { | |
| return function (xs) { | |
| return new ConsCell(x, xs); | |
| }; | |
| } | |
| function listToArray(list) { | |
| var arr = []; | |
| var xs = list; | |
| while (xs !== emptyList) { | |
| arr.push(xs.head); | |
| xs = xs.tail; | |
| } | |
| return arr; | |
| } | |
| return function (apply) { | |
| return function (map) { | |
| return function (pure) { | |
| return function (f) { | |
| var buildFrom = function (x, ys) { | |
| return apply(map(consList)(f(x)))(ys); | |
| }; | |
| var go = function (acc, currentLen, xs) { | |
| if (currentLen === 0) { | |
| return acc; | |
| } else { | |
| var last = xs[currentLen - 1]; | |
| return new Cont(function () { | |
| return go(buildFrom(last, acc), currentLen - 1, xs); | |
| }); | |
| } | |
| }; | |
| return function (array) { | |
| var result = go(pure(emptyList), array.length, array); | |
| while (result instanceof Cont) { | |
| result = result.fn(); | |
| } | |
| return map(listToArray)(result); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }(); | |
| })(PS["Data.Traversable"] = PS["Data.Traversable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Traversable"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Maybe_First = PS["Data.Maybe.First"]; | |
| var Data_Maybe_Last = PS["Data.Maybe.Last"]; | |
| var Data_Monoid_Additive = PS["Data.Monoid.Additive"]; | |
| var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; | |
| var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; | |
| var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; | |
| var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; | |
| var Prelude = PS["Prelude"]; | |
| var StateL = function (x) { | |
| return x; | |
| }; | |
| var StateR = function (x) { | |
| return x; | |
| }; | |
| // | `Traversable` represents data structures which can be _traversed_, | |
| // | accumulating results and effects in some `Applicative` functor. | |
| // | | |
| // | - `traverse` runs an action for every element in a data structure, | |
| // | and accumulates the results. | |
| // | - `sequence` runs the actions _contained_ in a data structure, | |
| // | and accumulates the results. | |
| // | | |
| // | The `traverse` and `sequence` functions should be compatible in the | |
| // | following sense: | |
| // | | |
| // | - `traverse f xs = sequence (f <$> xs)` | |
| // | - `sequence = traverse id` | |
| // | | |
| // | `Traversable` instances should also be compatible with the corresponding | |
| // | `Foldable` instances, in the following sense: | |
| // | | |
| // | - `foldMap f = runConst <<< traverse (Const <<< f)` | |
| // | | |
| // | Default implementations are provided by the following functions: | |
| // | | |
| // | - `traverseDefault` | |
| // | - `sequenceDefault` | |
| var Traversable = function (Foldable1, Functor0, sequence, traverse) { | |
| this.Foldable1 = Foldable1; | |
| this.Functor0 = Functor0; | |
| this.sequence = sequence; | |
| this.traverse = traverse; | |
| }; | |
| var traverse = function (dict) { | |
| return dict.traverse; | |
| }; | |
| var traversableMultiplicative = new Traversable(function () { | |
| return Data_Foldable.foldableMultiplicative; | |
| }, function () { | |
| return Data_Monoid_Multiplicative.functorMultiplicative; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Multiplicative.Multiplicative)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Multiplicative.Multiplicative)(f(v)); | |
| }; | |
| }; | |
| }); | |
| var traversableMaybe = new Traversable(function () { | |
| return Data_Foldable.foldableMaybe; | |
| }, function () { | |
| return Data_Maybe.functorMaybe; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictApplicative)(Data_Maybe.Nothing.value); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Maybe.Just.create)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Traversable line 84, column 1 - line 84, column 47: " + [ v.constructor.name ]); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictApplicative)(Data_Maybe.Nothing.value); | |
| }; | |
| if (v1 instanceof Data_Maybe.Just) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Maybe.Just.create)(v(v1.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Traversable line 84, column 1 - line 84, column 47: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| var traversableDual = new Traversable(function () { | |
| return Data_Foldable.foldableDual; | |
| }, function () { | |
| return Data_Monoid_Dual.functorDual; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Dual.Dual)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Dual.Dual)(f(v)); | |
| }; | |
| }; | |
| }); | |
| var traversableDisj = new Traversable(function () { | |
| return Data_Foldable.foldableDisj; | |
| }, function () { | |
| return Data_Monoid_Disj.functorDisj; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Disj.Disj)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Disj.Disj)(f(v)); | |
| }; | |
| }; | |
| }); | |
| var traversableConj = new Traversable(function () { | |
| return Data_Foldable.foldableConj; | |
| }, function () { | |
| return Data_Monoid_Conj.functorConj; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Conj.Conj)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Conj.Conj)(f(v)); | |
| }; | |
| }; | |
| }); | |
| var traversableAdditive = new Traversable(function () { | |
| return Data_Foldable.foldableAdditive; | |
| }, function () { | |
| return Data_Monoid_Additive.functorAdditive; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Additive.Additive)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Monoid_Additive.Additive)(f(v)); | |
| }; | |
| }; | |
| }); | |
| var stateR = function (v) { | |
| return v; | |
| }; | |
| var stateL = function (v) { | |
| return v; | |
| }; | |
| // | A default implementation of `sequence` using `traverse`. | |
| var sequenceDefault = function (dictTraversable) { | |
| return function (dictApplicative) { | |
| return traverse(dictTraversable)(dictApplicative)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var traversableArray = new Traversable(function () { | |
| return Data_Foldable.foldableArray; | |
| }, function () { | |
| return Data_Functor.functorArray; | |
| }, function (dictApplicative) { | |
| return sequenceDefault(traversableArray)(dictApplicative); | |
| }, function (dictApplicative) { | |
| return $foreign.traverseArrayImpl(Control_Apply.apply(dictApplicative.Apply0()))(Data_Functor.map((dictApplicative.Apply0()).Functor0()))(Control_Applicative.pure(dictApplicative)); | |
| }); | |
| var sequence = function (dict) { | |
| return dict.sequence; | |
| }; | |
| var traversableFirst = new Traversable(function () { | |
| return Data_Foldable.foldableFirst; | |
| }, function () { | |
| return Data_Maybe_First.functorFirst; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Maybe_First.First)(sequence(traversableMaybe)(dictApplicative)(v)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Maybe_First.First)(traverse(traversableMaybe)(dictApplicative)(f)(v)); | |
| }; | |
| }; | |
| }); | |
| var traversableLast = new Traversable(function () { | |
| return Data_Foldable.foldableLast; | |
| }, function () { | |
| return Data_Maybe_Last.functorLast; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Maybe_Last.Last)(sequence(traversableMaybe)(dictApplicative)(v)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Maybe_Last.Last)(traverse(traversableMaybe)(dictApplicative)(f)(v)); | |
| }; | |
| }; | |
| }); | |
| // | A default implementation of `traverse` using `sequence` and `map`. | |
| var traverseDefault = function (dictTraversable) { | |
| return function (dictApplicative) { | |
| return function (f) { | |
| return function (ta) { | |
| return sequence(dictTraversable)(dictApplicative)(Data_Functor.map(dictTraversable.Functor0())(f)(ta)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var functorStateR = new Data_Functor.Functor(function (f) { | |
| return function (k) { | |
| return function (s) { | |
| var v = stateR(k)(s); | |
| return { | |
| accum: v.accum, | |
| value: f(v.value) | |
| }; | |
| }; | |
| }; | |
| }); | |
| var functorStateL = new Data_Functor.Functor(function (f) { | |
| return function (k) { | |
| return function (s) { | |
| var v = stateL(k)(s); | |
| return { | |
| accum: v.accum, | |
| value: f(v.value) | |
| }; | |
| }; | |
| }; | |
| }); | |
| // | A version of `traverse` with its arguments flipped. | |
| // | | |
| // | | |
| // | This can be useful when running an action written using do notation | |
| // | for every element in a data structure: | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | for [1, 2, 3] \n -> do | |
| // | print n | |
| // | return (n * n) | |
| // | ``` | |
| var $$for = function (dictApplicative) { | |
| return function (dictTraversable) { | |
| return function (x) { | |
| return function (f) { | |
| return traverse(dictTraversable)(dictApplicative)(f)(x); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var applyStateR = new Control_Apply.Apply(function () { | |
| return functorStateR; | |
| }, function (f) { | |
| return function (x) { | |
| return function (s) { | |
| var v = stateR(x)(s); | |
| var v1 = stateR(f)(v.accum); | |
| return { | |
| accum: v1.accum, | |
| value: v1.value(v.value) | |
| }; | |
| }; | |
| }; | |
| }); | |
| var applyStateL = new Control_Apply.Apply(function () { | |
| return functorStateL; | |
| }, function (f) { | |
| return function (x) { | |
| return function (s) { | |
| var v = stateL(f)(s); | |
| var v1 = stateL(x)(v.accum); | |
| return { | |
| accum: v1.accum, | |
| value: v.value(v1.value) | |
| }; | |
| }; | |
| }; | |
| }); | |
| var applicativeStateR = new Control_Applicative.Applicative(function () { | |
| return applyStateR; | |
| }, function (a) { | |
| return function (s) { | |
| return { | |
| accum: s, | |
| value: a | |
| }; | |
| }; | |
| }); | |
| // | Fold a data structure from the right, keeping all intermediate results | |
| // | instead of only the final result. | |
| // | | |
| // | Unlike `scanr`, `mapAccumR` allows the type of accumulator to differ | |
| // | from the element type of the final data structure. | |
| var mapAccumR = function (dictTraversable) { | |
| return function (f) { | |
| return function (s0) { | |
| return function (xs) { | |
| return stateR(traverse(dictTraversable)(applicativeStateR)(function (a) { | |
| return function (s) { | |
| return f(s)(a); | |
| }; | |
| })(xs))(s0); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Fold a data structure from the right, keeping all intermediate results | |
| // | instead of only the final result. Note that the initial value does not | |
| // | appear in the result (unlike Haskell's `Prelude.scanr`). | |
| // | | |
| // | ```purescript | |
| // | scanr (+) 0 [1,2,3] = [1,3,6] | |
| // | scanr (flip (-)) 10 [1,2,3] = [4,5,7] | |
| // | ``` | |
| var scanr = function (dictTraversable) { | |
| return function (f) { | |
| return function (b0) { | |
| return function (xs) { | |
| return (mapAccumR(dictTraversable)(function (b) { | |
| return function (a) { | |
| var b$prime = f(a)(b); | |
| return { | |
| accum: b$prime, | |
| value: b$prime | |
| }; | |
| }; | |
| })(b0)(xs)).value; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var applicativeStateL = new Control_Applicative.Applicative(function () { | |
| return applyStateL; | |
| }, function (a) { | |
| return function (s) { | |
| return { | |
| accum: s, | |
| value: a | |
| }; | |
| }; | |
| }); | |
| // | Fold a data structure from the left, keeping all intermediate results | |
| // | instead of only the final result. | |
| // | | |
| // | Unlike `scanl`, `mapAccumL` allows the type of accumulator to differ | |
| // | from the element type of the final data structure. | |
| var mapAccumL = function (dictTraversable) { | |
| return function (f) { | |
| return function (s0) { | |
| return function (xs) { | |
| return stateL(traverse(dictTraversable)(applicativeStateL)(function (a) { | |
| return function (s) { | |
| return f(s)(a); | |
| }; | |
| })(xs))(s0); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Fold a data structure from the left, keeping all intermediate results | |
| // | instead of only the final result. Note that the initial value does not | |
| // | appear in the result (unlike Haskell's `Prelude.scanl`). | |
| // | | |
| // | ```purescript | |
| // | scanl (+) 0 [1,2,3] = [1,3,6] | |
| // | scanl (-) 10 [1,2,3] = [9,7,4] | |
| // | ``` | |
| var scanl = function (dictTraversable) { | |
| return function (f) { | |
| return function (b0) { | |
| return function (xs) { | |
| return (mapAccumL(dictTraversable)(function (b) { | |
| return function (a) { | |
| var b$prime = f(b)(a); | |
| return { | |
| accum: b$prime, | |
| value: b$prime | |
| }; | |
| }; | |
| })(b0)(xs)).value; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Traversable"] = Traversable; | |
| exports["for"] = $$for; | |
| exports["mapAccumL"] = mapAccumL; | |
| exports["mapAccumR"] = mapAccumR; | |
| exports["scanl"] = scanl; | |
| exports["scanr"] = scanr; | |
| exports["sequence"] = sequence; | |
| exports["sequenceDefault"] = sequenceDefault; | |
| exports["traverse"] = traverse; | |
| exports["traverseDefault"] = traverseDefault; | |
| exports["traversableArray"] = traversableArray; | |
| exports["traversableMaybe"] = traversableMaybe; | |
| exports["traversableFirst"] = traversableFirst; | |
| exports["traversableLast"] = traversableLast; | |
| exports["traversableAdditive"] = traversableAdditive; | |
| exports["traversableDual"] = traversableDual; | |
| exports["traversableConj"] = traversableConj; | |
| exports["traversableDisj"] = traversableDisj; | |
| exports["traversableMultiplicative"] = traversableMultiplicative; | |
| })(PS["Data.Traversable"] = PS["Data.Traversable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Field = PS["Data.Field"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Contravariant = PS["Data.Functor.Contravariant"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `Const` type constructor, which wraps its first type argument | |
| // | and ignores its second. That is, `Const a b` is isomorphic to `a` | |
| // | for any `b`. | |
| // | | |
| // | `Const` has some useful instances. For example, the `Applicative` | |
| // | instance allows us to collect results using a `Monoid` while | |
| // | ignoring return values. | |
| var Const = function (x) { | |
| return x; | |
| }; | |
| var showConst = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Const " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semiringConst = function (dictSemiring) { | |
| return dictSemiring; | |
| }; | |
| var semigroupoidConst = new Control_Semigroupoid.Semigroupoid(function (v) { | |
| return function (v1) { | |
| return v1; | |
| }; | |
| }); | |
| var semigroupConst = function (dictSemigroup) { | |
| return dictSemigroup; | |
| }; | |
| var ringConst = function (dictRing) { | |
| return dictRing; | |
| }; | |
| var ordConst = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeConst = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Const); | |
| var monoidConst = function (dictMonoid) { | |
| return dictMonoid; | |
| }; | |
| var heytingAlgebraConst = function (dictHeytingAlgebra) { | |
| return dictHeytingAlgebra; | |
| }; | |
| var functorConst = new Data_Functor.Functor(function (v) { | |
| return function (v1) { | |
| return v1; | |
| }; | |
| }); | |
| var invariantConst = new Data_Functor_Invariant.Invariant(Data_Functor_Invariant.imapF(functorConst)); | |
| var foldableConst = new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Monoid.mempty(dictMonoid); | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (z) { | |
| return function (v1) { | |
| return z; | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (z) { | |
| return function (v1) { | |
| return z; | |
| }; | |
| }; | |
| }); | |
| var traversableConst = new Data_Traversable.Traversable(function () { | |
| return foldableConst; | |
| }, function () { | |
| return functorConst; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Control_Applicative.pure(dictApplicative)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| return Control_Applicative.pure(dictApplicative)(v1); | |
| }; | |
| }; | |
| }); | |
| var fieldConst = function (dictField) { | |
| return dictField; | |
| }; | |
| var euclideanRingConst = function (dictEuclideanRing) { | |
| return dictEuclideanRing; | |
| }; | |
| var eqConst = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var contravariantConst = new Data_Functor_Contravariant.Contravariant(function (v) { | |
| return function (v1) { | |
| return v1; | |
| }; | |
| }); | |
| var commutativeRingConst = function (dictCommutativeRing) { | |
| return dictCommutativeRing; | |
| }; | |
| var boundedConst = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var booleanAlgebraConst = function (dictBooleanAlgebra) { | |
| return dictBooleanAlgebra; | |
| }; | |
| var applyConst = function (dictSemigroup) { | |
| return new Control_Apply.Apply(function () { | |
| return functorConst; | |
| }, function (v) { | |
| return function (v1) { | |
| return Data_Semigroup.append(dictSemigroup)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var bindConst = function (dictSemigroup) { | |
| return new Control_Bind.Bind(function () { | |
| return applyConst(dictSemigroup); | |
| }, function (v) { | |
| return function (v1) { | |
| return v; | |
| }; | |
| }); | |
| }; | |
| var applicativeConst = function (dictMonoid) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyConst(dictMonoid.Semigroup0()); | |
| }, function (v) { | |
| return Data_Monoid.mempty(dictMonoid); | |
| }); | |
| }; | |
| exports["Const"] = Const; | |
| exports["newtypeConst"] = newtypeConst; | |
| exports["eqConst"] = eqConst; | |
| exports["ordConst"] = ordConst; | |
| exports["boundedConst"] = boundedConst; | |
| exports["showConst"] = showConst; | |
| exports["semigroupoidConst"] = semigroupoidConst; | |
| exports["semigroupConst"] = semigroupConst; | |
| exports["monoidConst"] = monoidConst; | |
| exports["semiringConst"] = semiringConst; | |
| exports["ringConst"] = ringConst; | |
| exports["euclideanRingConst"] = euclideanRingConst; | |
| exports["commutativeRingConst"] = commutativeRingConst; | |
| exports["fieldConst"] = fieldConst; | |
| exports["heytingAlgebraConst"] = heytingAlgebraConst; | |
| exports["booleanAlgebraConst"] = booleanAlgebraConst; | |
| exports["functorConst"] = functorConst; | |
| exports["invariantConst"] = invariantConst; | |
| exports["contravariantConst"] = contravariantConst; | |
| exports["applyConst"] = applyConst; | |
| exports["bindConst"] = bindConst; | |
| exports["applicativeConst"] = applicativeConst; | |
| exports["foldableConst"] = foldableConst; | |
| exports["traversableConst"] = traversableConst; | |
| })(PS["Data.Const"] = PS["Data.Const"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // module Unsafe.Coerce | |
| exports.unsafeCoerce = function (x) { | |
| return x; | |
| }; | |
| })(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Unsafe.Coerce"]; | |
| exports["unsafeCoerce"] = $foreign.unsafeCoerce; | |
| })(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| // | The `runExists` function is used to eliminate a value of type `Exists f`. The rank 2 type ensures | |
| // | that the existentially-quantified type does not escape its scope. Since the function is required | |
| // | to work for _any_ type `a`, it will work for the existentially-quantified type. | |
| // | | |
| // | For example, we can write a function to obtain the head of a stream by using `runExists` as follows: | |
| // | | |
| // | ```purescript | |
| // | head :: forall a. Stream a -> a | |
| // | head = runExists head' | |
| // | where | |
| // | head' :: forall s. StreamF a s -> a | |
| // | head' (StreamF s f) = snd (f s) | |
| // | ``` | |
| var runExists = Unsafe_Coerce.unsafeCoerce; | |
| // | The `mkExists` function is used to introduce a value of type `Exists f`, by providing a value of | |
| // | type `f a`, for some type `a` which will be hidden in the existentially-quantified type. | |
| // | | |
| // | For example, to create a value of type `Stream Number`, we might use `mkExists` as follows: | |
| // | | |
| // | ```purescript | |
| // | nats :: Stream Number | |
| // | nats = mkExists $ StreamF 0 (\n -> Tuple (n + 1) n) | |
| // | ``` | |
| var mkExists = Unsafe_Coerce.unsafeCoerce; | |
| exports["mkExists"] = mkExists; | |
| exports["runExists"] = runExists; | |
| })(PS["Data.Exists"] = PS["Data.Exists"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Const = PS["Data.Const"]; | |
| var Data_Exists = PS["Data.Exists"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| var ApF = (function () { | |
| function ApF(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| ApF.create = function (value0) { | |
| return function (value1) { | |
| return new ApF(value0, value1); | |
| }; | |
| }; | |
| return ApF; | |
| })(); | |
| // | The free applicative functor for a type constructor `f`. | |
| var Pure = (function () { | |
| function Pure(value0) { | |
| this.value0 = value0; | |
| }; | |
| Pure.create = function (value0) { | |
| return new Pure(value0); | |
| }; | |
| return Pure; | |
| })(); | |
| // | The free applicative functor for a type constructor `f`. | |
| var Ap = (function () { | |
| function Ap(value0) { | |
| this.value0 = value0; | |
| }; | |
| Ap.create = function (value0) { | |
| return new Ap(value0); | |
| }; | |
| return Ap; | |
| })(); | |
| // | Run a free applicative functor using the applicative instance for | |
| // | the type constructor `f`. | |
| var retractFreeAp = function (dictApplicative) { | |
| return function (v) { | |
| if (v instanceof Pure) { | |
| return Control_Applicative.pure(dictApplicative)(v.value0); | |
| }; | |
| if (v instanceof Ap) { | |
| return Data_Exists.runExists(function (v1) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(retractFreeAp(dictApplicative)(v1.value1(Data_Unit.unit)))(v1.value0(Data_Unit.unit)); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative.Free line 32, column 1 - line 32, column 64: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| // | Run a free applicative functor with a natural transformation from | |
| // | the type constructor `f` to the applicative functor `g`. | |
| var foldFreeAp = function (dictApplicative) { | |
| return function (k) { | |
| return function (v) { | |
| if (v instanceof Pure) { | |
| return Control_Applicative.pure(dictApplicative)(v.value0); | |
| }; | |
| if (v instanceof Ap) { | |
| return Data_Exists.runExists(function (v1) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Function.flip(Control_Category.id(Control_Category.categoryFn)))(k(v1.value0(Data_Unit.unit))))(foldFreeAp(dictApplicative)(k)(v1.value1(Data_Unit.unit))); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative.Free line 38, column 1 - line 38, column 75: " + [ k.constructor.name, v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| var ap = function (v) { | |
| return function (k) { | |
| return new Ap(Data_Exists.mkExists(new ApF(v, k))); | |
| }; | |
| }; | |
| var functorFreeAp = new Data_Functor.Functor(function (k) { | |
| return function (v) { | |
| if (v instanceof Pure) { | |
| return new Pure(k(v.value0)); | |
| }; | |
| if (v instanceof Ap) { | |
| return Data_Exists.runExists(function (v1) { | |
| return ap(v1.value0)(function (v3) { | |
| return Data_Functor.map(functorFreeAp)(Control_Semigroupoid.compose(Control_Semigroupoid.semigroupoidFn)(k))(v1.value1(Data_Unit.unit)); | |
| }); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative.Free line 52, column 1 - line 52, column 45: " + [ k.constructor.name, v.constructor.name ]); | |
| }; | |
| }); | |
| var applyFreeAp = new Control_Apply.Apply(function () { | |
| return functorFreeAp; | |
| }, function (v) { | |
| return function (f) { | |
| if (v instanceof Pure) { | |
| return Data_Functor.map(functorFreeAp)(v.value0)(f); | |
| }; | |
| if (v instanceof Ap) { | |
| return Data_Exists.runExists(function (v1) { | |
| return ap(v1.value0)(function (v3) { | |
| return Control_Apply.apply(applyFreeAp)(Data_Functor.map(functorFreeAp)(Data_Function.flip)(v1.value1(Data_Unit.unit)))(f); | |
| }); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative.Free line 56, column 1 - line 56, column 41: " + [ v.constructor.name, f.constructor.name ]); | |
| }; | |
| }); | |
| var applicativeFreeAp = new Control_Applicative.Applicative(function () { | |
| return applyFreeAp; | |
| }, Pure.create); | |
| // | Natural transformation from `FreeAp f a` to `FreeAp g a` given a | |
| // | natural transformation from `f` to `g`. | |
| var hoistFreeAp = function (k) { | |
| return function (v) { | |
| if (v instanceof Pure) { | |
| return new Pure(v.value0); | |
| }; | |
| if (v instanceof Ap) { | |
| return Data_Exists.runExists(function (v1) { | |
| return ap(function (v3) { | |
| return k(v1.value0(Data_Unit.unit)); | |
| })(function (v3) { | |
| return hoistFreeAp(k)(v1.value1(Data_Unit.unit)); | |
| }); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Applicative.Free line 44, column 1 - line 44, column 66: " + [ k.constructor.name, v.constructor.name ]); | |
| }; | |
| }; | |
| // | Lift a value described by the type constructor `f` into | |
| // | the free applicative functor. | |
| var liftFreeAp = function (a) { | |
| return ap(function (v) { | |
| return a; | |
| })(function (v) { | |
| return new Pure(Control_Category.id(Control_Category.categoryFn)); | |
| }); | |
| }; | |
| // | Perform monoidal analysis over the free applicative functor `f`. | |
| var analyzeFreeAp = function (dictMonoid) { | |
| return function (k) { | |
| return function ($53) { | |
| return Data_Newtype.unwrap(Data_Const.newtypeConst)(foldFreeAp(Data_Const.applicativeConst(dictMonoid))(function ($54) { | |
| return Data_Const.Const(k($54)); | |
| })($53)); | |
| }; | |
| }; | |
| }; | |
| exports["analyzeFreeAp"] = analyzeFreeAp; | |
| exports["foldFreeAp"] = foldFreeAp; | |
| exports["hoistFreeAp"] = hoistFreeAp; | |
| exports["liftFreeAp"] = liftFreeAp; | |
| exports["retractFreeAp"] = retractFreeAp; | |
| exports["functorFreeAp"] = functorFreeAp; | |
| exports["applyFreeAp"] = applyFreeAp; | |
| exports["applicativeFreeAp"] = applicativeFreeAp; | |
| })(PS["Control.Applicative.Free"] = PS["Control.Applicative.Free"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| // | A `Bifunctor` is a `Functor` from the pair category `(Type, Type)` to `Type`. | |
| // | | |
| // | A type constructor with two type arguments can be made into a `Bifunctor` if | |
| // | both of its type arguments are covariant. | |
| // | | |
| // | The `bimap` function maps a pair of functions over the two type arguments | |
| // | of the bifunctor. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - Identity: `bimap id id == id` | |
| // | - Composition: `bimap f1 g1 <<< bimap f2 g2 == bimap (f1 <<< f2) (g1 <<< g2)` | |
| // | | |
| var Bifunctor = function (bimap) { | |
| this.bimap = bimap; | |
| }; | |
| var bimap = function (dict) { | |
| return dict.bimap; | |
| }; | |
| // | Map a function over the first type argument of a `Bifunctor`. | |
| var lmap = function (dictBifunctor) { | |
| return function (f) { | |
| return bimap(dictBifunctor)(f)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | Map a function over the second type arguments of a `Bifunctor`. | |
| var rmap = function (dictBifunctor) { | |
| return bimap(dictBifunctor)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| exports["Bifunctor"] = Bifunctor; | |
| exports["bimap"] = bimap; | |
| exports["lmap"] = lmap; | |
| exports["rmap"] = rmap; | |
| })(PS["Data.Bifunctor"] = PS["Data.Bifunctor"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Function = PS["Data.Function"]; | |
| // | `Biapply` captures type constructors of two arguments which support lifting of | |
| // | functions of one or more arguments, in the sense of `Apply`. | |
| var Biapply = function (Bifunctor0, biapply) { | |
| this.Bifunctor0 = Bifunctor0; | |
| this.biapply = biapply; | |
| }; | |
| var biapply = function (dict) { | |
| return dict.biapply; | |
| }; | |
| // | Keep the results of the second computation. | |
| var biapplyFirst = function (dictBiapply) { | |
| return function (a) { | |
| return function (b) { | |
| return biapply(dictBiapply)(Control_Category.id(Control_Category.categoryFn)(Data_Bifunctor.bimap(dictBiapply.Bifunctor0())(Data_Function["const"](Control_Category.id(Control_Category.categoryFn)))(Data_Function["const"](Control_Category.id(Control_Category.categoryFn))))(a))(b); | |
| }; | |
| }; | |
| }; | |
| // | Keep the results of the first computation. | |
| var biapplySecond = function (dictBiapply) { | |
| return function (a) { | |
| return function (b) { | |
| return biapply(dictBiapply)(Control_Category.id(Control_Category.categoryFn)(Data_Bifunctor.bimap(dictBiapply.Bifunctor0())(Data_Function["const"])(Data_Function["const"]))(a))(b); | |
| }; | |
| }; | |
| }; | |
| // | Lift a function of two arguments. | |
| var bilift2 = function (dictBiapply) { | |
| return function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return function (b) { | |
| return biapply(dictBiapply)(Control_Category.id(Control_Category.categoryFn)(Data_Bifunctor.bimap(dictBiapply.Bifunctor0())(f)(g))(a))(b); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Lift a function of three arguments. | |
| var bilift3 = function (dictBiapply) { | |
| return function (f) { | |
| return function (g) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return biapply(dictBiapply)(biapply(dictBiapply)(Control_Category.id(Control_Category.categoryFn)(Data_Bifunctor.bimap(dictBiapply.Bifunctor0())(f)(g))(a))(b))(c); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Biapply"] = Biapply; | |
| exports["biapply"] = biapply; | |
| exports["biapplyFirst"] = biapplyFirst; | |
| exports["biapplySecond"] = biapplySecond; | |
| exports["bilift2"] = bilift2; | |
| exports["bilift3"] = bilift3; | |
| })(PS["Control.Biapply"] = PS["Control.Biapply"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| // | `Biapplicative` captures type constructors of two arguments which support lifting of | |
| // | functions of zero or more arguments, in the sense of `Applicative`. | |
| var Biapplicative = function (Biapply0, bipure) { | |
| this.Biapply0 = Biapply0; | |
| this.bipure = bipure; | |
| }; | |
| var bipure = function (dict) { | |
| return dict.bipure; | |
| }; | |
| exports["Biapplicative"] = Biapplicative; | |
| exports["bipure"] = bipure; | |
| })(PS["Control.Biapplicative"] = PS["Control.Biapplicative"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.pureE = function (a) { | |
| return function () { | |
| return a; | |
| }; | |
| }; | |
| exports.bindE = function (a) { | |
| return function (f) { | |
| return function () { | |
| return f(a())(); | |
| }; | |
| }; | |
| }; | |
| exports.runPure = function (f) { | |
| return f(); | |
| }; | |
| exports.untilE = function (f) { | |
| return function () { | |
| while (!f()); | |
| return {}; | |
| }; | |
| }; | |
| exports.whileE = function (f) { | |
| return function (a) { | |
| return function () { | |
| while (f()) { | |
| a(); | |
| } | |
| return {}; | |
| }; | |
| }; | |
| }; | |
| exports.forE = function (lo) { | |
| return function (hi) { | |
| return function (f) { | |
| return function () { | |
| for (var i = lo; i < hi; i++) { | |
| f(i)(); | |
| } | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.foreachE = function (as) { | |
| return function (f) { | |
| return function () { | |
| for (var i = 0, l = as.length; i < l; i++) { | |
| f(as[i])(); | |
| } | |
| }; | |
| }; | |
| }; | |
| })(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Eff"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var monadEff = new Control_Monad.Monad(function () { | |
| return applicativeEff; | |
| }, function () { | |
| return bindEff; | |
| }); | |
| var bindEff = new Control_Bind.Bind(function () { | |
| return applyEff; | |
| }, $foreign.bindE); | |
| var applyEff = new Control_Apply.Apply(function () { | |
| return functorEff; | |
| }, Control_Monad.ap(monadEff)); | |
| var applicativeEff = new Control_Applicative.Applicative(function () { | |
| return applyEff; | |
| }, $foreign.pureE); | |
| var functorEff = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEff)); | |
| exports["functorEff"] = functorEff; | |
| exports["applyEff"] = applyEff; | |
| exports["applicativeEff"] = applicativeEff; | |
| exports["bindEff"] = bindEff; | |
| exports["monadEff"] = monadEff; | |
| exports["forE"] = $foreign.forE; | |
| exports["foreachE"] = $foreign.foreachE; | |
| exports["runPure"] = $foreign.runPure; | |
| exports["untilE"] = $foreign.untilE; | |
| exports["whileE"] = $foreign.whileE; | |
| })(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.unsafeCoerceEff = function (f) { | |
| return f; | |
| }; | |
| })(PS["Control.Monad.Eff.Unsafe"] = PS["Control.Monad.Eff.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Eff.Unsafe"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| // | Run an effectful computation. | |
| // | | |
| // | *Note*: use of this function can result in arbitrary side-effects. | |
| var unsafePerformEff = function ($0) { | |
| return Control_Monad_Eff.runPure($foreign.unsafeCoerceEff($0)); | |
| }; | |
| exports["unsafePerformEff"] = unsafePerformEff; | |
| exports["unsafeCoerceEff"] = $foreign.unsafeCoerceEff; | |
| })(PS["Control.Monad.Eff.Unsafe"] = PS["Control.Monad.Eff.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.newSTRef = function (val) { | |
| return function () { | |
| return { value: val }; | |
| }; | |
| }; | |
| exports.readSTRef = function (ref) { | |
| return function () { | |
| return ref.value; | |
| }; | |
| }; | |
| exports.modifySTRef = function (ref) { | |
| return function (f) { | |
| return function () { | |
| return ref.value = f(ref.value); // eslint-disable-line no-return-assign | |
| }; | |
| }; | |
| }; | |
| exports.writeSTRef = function (ref) { | |
| return function (a) { | |
| return function () { | |
| return ref.value = a; // eslint-disable-line no-return-assign | |
| }; | |
| }; | |
| }; | |
| exports.runST = function (f) { | |
| return f; | |
| }; | |
| })(PS["Control.Monad.ST"] = PS["Control.Monad.ST"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.ST"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| // | A convenience function which combines `runST` with `runPure`, which can be | |
| // | used when the only required effect is `ST`. | |
| // | | |
| // | Note: since this function has a rank-2 type, it may cause problems to apply | |
| // | this function using the `$` operator. The recommended approach is to use | |
| // | parentheses instead. | |
| var pureST = function (st) { | |
| return Control_Monad_Eff.runPure($foreign.runST(st)); | |
| }; | |
| exports["pureST"] = pureST; | |
| exports["modifySTRef"] = $foreign.modifySTRef; | |
| exports["newSTRef"] = $foreign.newSTRef; | |
| exports["readSTRef"] = $foreign.readSTRef; | |
| exports["runST"] = $foreign.runST; | |
| exports["writeSTRef"] = $foreign.writeSTRef; | |
| })(PS["Control.Monad.ST"] = PS["Control.Monad.ST"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Biapplicative = PS["Control.Biapplicative"]; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Make a `Functor` over the first argument of a `Bifunctor` | |
| var Clown = function (x) { | |
| return x; | |
| }; | |
| var showClown = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Clown " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var ordClown = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeClown = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Clown); | |
| var functorClown = new Data_Functor.Functor(function (v) { | |
| return function (v1) { | |
| return v1; | |
| }; | |
| }); | |
| var eqClown = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var bifunctorClown = function (dictFunctor) { | |
| return new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Functor.map(dictFunctor)(f)(v1); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var biapplyClown = function (dictApply) { | |
| return new Control_Biapply.Biapply(function () { | |
| return bifunctorClown(dictApply.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Apply.apply(dictApply)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var biapplicativeClown = function (dictApplicative) { | |
| return new Control_Biapplicative.Biapplicative(function () { | |
| return biapplyClown(dictApplicative.Apply0()); | |
| }, function (a) { | |
| return function (v) { | |
| return Control_Applicative.pure(dictApplicative)(a); | |
| }; | |
| }); | |
| }; | |
| exports["Clown"] = Clown; | |
| exports["newtypeClown"] = newtypeClown; | |
| exports["eqClown"] = eqClown; | |
| exports["ordClown"] = ordClown; | |
| exports["showClown"] = showClown; | |
| exports["functorClown"] = functorClown; | |
| exports["bifunctorClown"] = bifunctorClown; | |
| exports["biapplyClown"] = biapplyClown; | |
| exports["biapplicativeClown"] = biapplicativeClown; | |
| })(PS["Data.Bifunctor.Clown"] = PS["Data.Bifunctor.Clown"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Biapplicative = PS["Control.Biapplicative"]; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Flips the order of the type arguments of a `Bifunctor`. | |
| var Flip = function (x) { | |
| return x; | |
| }; | |
| var showFlip = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Flip " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var ordFlip = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeFlip = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Flip); | |
| var functorFlip = function (dictBifunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return Data_Bifunctor.lmap(dictBifunctor)(f)(v); | |
| }; | |
| }); | |
| }; | |
| var eqFlip = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var bifunctorFlip = function (dictBifunctor) { | |
| return new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return Data_Bifunctor.bimap(dictBifunctor)(g)(f)(v); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var biapplyFlip = function (dictBiapply) { | |
| return new Control_Biapply.Biapply(function () { | |
| return bifunctorFlip(dictBiapply.Bifunctor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Biapply.biapply(dictBiapply)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var biapplicativeFlip = function (dictBiapplicative) { | |
| return new Control_Biapplicative.Biapplicative(function () { | |
| return biapplyFlip(dictBiapplicative.Biapply0()); | |
| }, function (a) { | |
| return function (b) { | |
| return Control_Biapplicative.bipure(dictBiapplicative)(b)(a); | |
| }; | |
| }); | |
| }; | |
| exports["Flip"] = Flip; | |
| exports["newtypeFlip"] = newtypeFlip; | |
| exports["eqFlip"] = eqFlip; | |
| exports["ordFlip"] = ordFlip; | |
| exports["showFlip"] = showFlip; | |
| exports["functorFlip"] = functorFlip; | |
| exports["bifunctorFlip"] = bifunctorFlip; | |
| exports["biapplyFlip"] = biapplyFlip; | |
| exports["biapplicativeFlip"] = biapplicativeFlip; | |
| })(PS["Data.Bifunctor.Flip"] = PS["Data.Bifunctor.Flip"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Biapplicative = PS["Control.Biapplicative"]; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Make a `Functor` over the second argument of a `Bifunctor` | |
| var Joker = function (x) { | |
| return x; | |
| }; | |
| var showJoker = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Joker " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var ordJoker = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeJoker = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Joker); | |
| var functorJoker = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (g) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(g)(v); | |
| }; | |
| }); | |
| }; | |
| var eqJoker = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var bifunctorJoker = function (dictFunctor) { | |
| return new Data_Bifunctor.Bifunctor(function (v) { | |
| return function (g) { | |
| return function (v1) { | |
| return Data_Functor.map(dictFunctor)(g)(v1); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var biapplyJoker = function (dictApply) { | |
| return new Control_Biapply.Biapply(function () { | |
| return bifunctorJoker(dictApply.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Apply.apply(dictApply)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var biapplicativeJoker = function (dictApplicative) { | |
| return new Control_Biapplicative.Biapplicative(function () { | |
| return biapplyJoker(dictApplicative.Apply0()); | |
| }, function (v) { | |
| return function (b) { | |
| return Control_Applicative.pure(dictApplicative)(b); | |
| }; | |
| }); | |
| }; | |
| exports["Joker"] = Joker; | |
| exports["newtypeJoker"] = newtypeJoker; | |
| exports["eqJoker"] = eqJoker; | |
| exports["ordJoker"] = ordJoker; | |
| exports["showJoker"] = showJoker; | |
| exports["functorJoker"] = functorJoker; | |
| exports["bifunctorJoker"] = bifunctorJoker; | |
| exports["biapplyJoker"] = biapplyJoker; | |
| exports["biapplicativeJoker"] = biapplicativeJoker; | |
| })(PS["Data.Bifunctor.Joker"] = PS["Data.Bifunctor.Joker"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Biapplicative = PS["Control.Biapplicative"]; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The product of two `Bifunctor`s. | |
| var Product = (function () { | |
| function Product(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Product.create = function (value0) { | |
| return function (value1) { | |
| return new Product(value0, value1); | |
| }; | |
| }; | |
| return Product; | |
| })(); | |
| var showProduct = function (dictShow) { | |
| return function (dictShow1) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Product " + (Data_Show.show(dictShow)(v.value0) + (" " + (Data_Show.show(dictShow1)(v.value1) + ")"))); | |
| }); | |
| }; | |
| }; | |
| var eqProduct = function (dictEq) { | |
| return function (dictEq1) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(dictEq)(x.value0)(y.value0) && Data_Eq.eq(dictEq1)(x.value1)(y.value1); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var ordProduct = function (dictOrd) { | |
| return function (dictOrd1) { | |
| return new Data_Ord.Ord(function () { | |
| return eqProduct(dictOrd.Eq0())(dictOrd1.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| var v = Data_Ord.compare(dictOrd)(x.value0)(y.value0); | |
| if (v instanceof Data_Ordering.LT) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| return Data_Ord.compare(dictOrd1)(x.value1)(y.value1); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bifunctorProduct = function (dictBifunctor) { | |
| return function (dictBifunctor1) { | |
| return new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return new Product(Data_Bifunctor.bimap(dictBifunctor)(f)(g)(v.value0), Data_Bifunctor.bimap(dictBifunctor1)(f)(g)(v.value1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var biapplyProduct = function (dictBiapply) { | |
| return function (dictBiapply1) { | |
| return new Control_Biapply.Biapply(function () { | |
| return bifunctorProduct(dictBiapply.Bifunctor0())(dictBiapply1.Bifunctor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return new Product(Control_Biapply.biapply(dictBiapply)(v.value0)(v1.value0), Control_Biapply.biapply(dictBiapply1)(v.value1)(v1.value1)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var biapplicativeProduct = function (dictBiapplicative) { | |
| return function (dictBiapplicative1) { | |
| return new Control_Biapplicative.Biapplicative(function () { | |
| return biapplyProduct(dictBiapplicative.Biapply0())(dictBiapplicative1.Biapply0()); | |
| }, function (a) { | |
| return function (b) { | |
| return new Product(Control_Biapplicative.bipure(dictBiapplicative)(a)(b), Control_Biapplicative.bipure(dictBiapplicative1)(a)(b)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| exports["Product"] = Product; | |
| exports["eqProduct"] = eqProduct; | |
| exports["ordProduct"] = ordProduct; | |
| exports["showProduct"] = showProduct; | |
| exports["bifunctorProduct"] = bifunctorProduct; | |
| exports["biapplyProduct"] = biapplyProduct; | |
| exports["biapplicativeProduct"] = biapplicativeProduct; | |
| })(PS["Data.Bifunctor.Product"] = PS["Data.Bifunctor.Product"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Biapplicative = PS["Control.Biapplicative"]; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Provides a `Functor` over the second argument of a `Bifunctor`. | |
| var Wrap = function (x) { | |
| return x; | |
| }; | |
| var showWrap = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Wrap " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var ordWrap = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeWrap = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Wrap); | |
| var functorWrap = function (dictBifunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return Data_Bifunctor.rmap(dictBifunctor)(f)(v); | |
| }; | |
| }); | |
| }; | |
| var eqWrap = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var bifunctorWrap = function (dictBifunctor) { | |
| return new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return Data_Bifunctor.bimap(dictBifunctor)(f)(g)(v); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var biapplyWrap = function (dictBiapply) { | |
| return new Control_Biapply.Biapply(function () { | |
| return bifunctorWrap(dictBiapply.Bifunctor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Biapply.biapply(dictBiapply)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var biapplicativeWrap = function (dictBiapplicative) { | |
| return new Control_Biapplicative.Biapplicative(function () { | |
| return biapplyWrap(dictBiapplicative.Biapply0()); | |
| }, function (a) { | |
| return function (b) { | |
| return Control_Biapplicative.bipure(dictBiapplicative)(a)(b); | |
| }; | |
| }); | |
| }; | |
| exports["Wrap"] = Wrap; | |
| exports["newtypeWrap"] = newtypeWrap; | |
| exports["eqWrap"] = eqWrap; | |
| exports["ordWrap"] = ordWrap; | |
| exports["showWrap"] = showWrap; | |
| exports["functorWrap"] = functorWrap; | |
| exports["bifunctorWrap"] = bifunctorWrap; | |
| exports["biapplyWrap"] = biapplyWrap; | |
| exports["biapplicativeWrap"] = biapplicativeWrap; | |
| })(PS["Data.Bifunctor.Wrap"] = PS["Data.Bifunctor.Wrap"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Bifunctor_Clown = PS["Data.Bifunctor.Clown"]; | |
| var Data_Bifunctor_Flip = PS["Data.Bifunctor.Flip"]; | |
| var Data_Bifunctor_Joker = PS["Data.Bifunctor.Joker"]; | |
| var Data_Bifunctor_Product = PS["Data.Bifunctor.Product"]; | |
| var Data_Bifunctor_Wrap = PS["Data.Bifunctor.Wrap"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; | |
| var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; | |
| var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; | |
| var Data_Monoid_Endo = PS["Data.Monoid.Endo"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | `Bifoldable` represents data structures with two type arguments which can be | |
| // | folded. | |
| // | | |
| // | A fold for such a structure requires two step functions, one for each type | |
| // | argument. Type class instances should choose the appropriate step function based | |
| // | on the type of the element encountered at each point of the fold. | |
| // | | |
| // | Default implementations are provided by the following functions: | |
| // | | |
| // | - `bifoldrDefault` | |
| // | - `bifoldlDefault` | |
| // | - `bifoldMapDefaultR` | |
| // | - `bifoldMapDefaultL` | |
| // | | |
| // | Note: some combinations of the default implementations are unsafe to | |
| // | use together - causing a non-terminating mutually recursive cycle. | |
| // | These combinations are documented per function. | |
| var Bifoldable = function (bifoldMap, bifoldl, bifoldr) { | |
| this.bifoldMap = bifoldMap; | |
| this.bifoldl = bifoldl; | |
| this.bifoldr = bifoldr; | |
| }; | |
| var bifoldr = function (dict) { | |
| return dict.bifoldr; | |
| }; | |
| // | Traverse a data structure, accumulating effects using an `Applicative` functor, | |
| // | ignoring the final result. | |
| var bitraverse_ = function (dictBifoldable) { | |
| return function (dictApplicative) { | |
| return function (f) { | |
| return function (g) { | |
| return bifoldr(dictBifoldable)(function ($97) { | |
| return Control_Apply.applySecond(dictApplicative.Apply0())(f($97)); | |
| })(function ($98) { | |
| return Control_Apply.applySecond(dictApplicative.Apply0())(g($98)); | |
| })(Control_Applicative.pure(dictApplicative)(Data_Unit.unit)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | A version of `bitraverse_` with the data structure as the first argument. | |
| var bifor_ = function (dictBifoldable) { | |
| return function (dictApplicative) { | |
| return function (t) { | |
| return function (f) { | |
| return function (g) { | |
| return bitraverse_(dictBifoldable)(dictApplicative)(f)(g)(t); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Collapse a data structure, collecting effects using an `Applicative` functor, | |
| // | ignoring the final result. | |
| var bisequence_ = function (dictBifoldable) { | |
| return function (dictApplicative) { | |
| return bitraverse_(dictBifoldable)(dictApplicative)(Control_Category.id(Control_Category.categoryFn))(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var bifoldl = function (dict) { | |
| return dict.bifoldl; | |
| }; | |
| var bifoldableJoker = function (dictFoldable) { | |
| return new Bifoldable(function (dictMonoid) { | |
| return function (v) { | |
| return function (r) { | |
| return function (v1) { | |
| return Data_Foldable.foldMap(dictFoldable)(dictMonoid)(r)(v1); | |
| }; | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (r) { | |
| return function (u) { | |
| return function (v1) { | |
| return Data_Foldable.foldl(dictFoldable)(r)(u)(v1); | |
| }; | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (r) { | |
| return function (u) { | |
| return function (v1) { | |
| return Data_Foldable.foldr(dictFoldable)(r)(u)(v1); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| var bifoldableClown = function (dictFoldable) { | |
| return new Bifoldable(function (dictMonoid) { | |
| return function (l) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Foldable.foldMap(dictFoldable)(dictMonoid)(l)(v1); | |
| }; | |
| }; | |
| }; | |
| }, function (l) { | |
| return function (v) { | |
| return function (u) { | |
| return function (v1) { | |
| return Data_Foldable.foldl(dictFoldable)(l)(u)(v1); | |
| }; | |
| }; | |
| }; | |
| }, function (l) { | |
| return function (v) { | |
| return function (u) { | |
| return function (v1) { | |
| return Data_Foldable.foldr(dictFoldable)(l)(u)(v1); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | A default implementation of `bifoldMap` using `bifoldr`. | |
| // | | |
| // | Note: when defining a `Bifoldable` instance, this function is unsafe to | |
| // | use in combination with `bifoldrDefault`. | |
| var bifoldMapDefaultR = function (dictBifoldable) { | |
| return function (dictMonoid) { | |
| return function (f) { | |
| return function (g) { | |
| return bifoldr(dictBifoldable)(function ($99) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(f($99)); | |
| })(function ($100) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(g($100)); | |
| })(Data_Monoid.mempty(dictMonoid)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | A default implementation of `bifoldMap` using `bifoldl`. | |
| // | | |
| // | Note: when defining a `Bifoldable` instance, this function is unsafe to | |
| // | use in combination with `bifoldlDefault`. | |
| var bifoldMapDefaultL = function (dictBifoldable) { | |
| return function (dictMonoid) { | |
| return function (f) { | |
| return function (g) { | |
| return bifoldl(dictBifoldable)(function (m) { | |
| return function (a) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(m)(f(a)); | |
| }; | |
| })(function (m) { | |
| return function (b) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(m)(g(b)); | |
| }; | |
| })(Data_Monoid.mempty(dictMonoid)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var bifoldMap = function (dict) { | |
| return dict.bifoldMap; | |
| }; | |
| var bifoldableFlip = function (dictBifoldable) { | |
| return new Bifoldable(function (dictMonoid) { | |
| return function (r) { | |
| return function (l) { | |
| return function (v) { | |
| return bifoldMap(dictBifoldable)(dictMonoid)(l)(r)(v); | |
| }; | |
| }; | |
| }; | |
| }, function (r) { | |
| return function (l) { | |
| return function (u) { | |
| return function (v) { | |
| return bifoldl(dictBifoldable)(l)(r)(u)(v); | |
| }; | |
| }; | |
| }; | |
| }, function (r) { | |
| return function (l) { | |
| return function (u) { | |
| return function (v) { | |
| return bifoldr(dictBifoldable)(l)(r)(u)(v); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| var bifoldableWrap = function (dictBifoldable) { | |
| return new Bifoldable(function (dictMonoid) { | |
| return function (l) { | |
| return function (r) { | |
| return function (v) { | |
| return bifoldMap(dictBifoldable)(dictMonoid)(l)(r)(v); | |
| }; | |
| }; | |
| }; | |
| }, function (l) { | |
| return function (r) { | |
| return function (u) { | |
| return function (v) { | |
| return bifoldl(dictBifoldable)(l)(r)(u)(v); | |
| }; | |
| }; | |
| }; | |
| }, function (l) { | |
| return function (r) { | |
| return function (u) { | |
| return function (v) { | |
| return bifoldr(dictBifoldable)(l)(r)(u)(v); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | A default implementation of `bifoldl` using `bifoldMap`. | |
| // | | |
| // | Note: when defining a `Bifoldable` instance, this function is unsafe to | |
| // | use in combination with `bifoldMapDefaultL`. | |
| var bifoldlDefault = function (dictBifoldable) { | |
| return function (f) { | |
| return function (g) { | |
| return function (z) { | |
| return function (p) { | |
| return Data_Newtype.unwrap(Data_Monoid_Endo.newtypeEndo)(Data_Newtype.unwrap(Data_Monoid_Dual.newtypeDual)(bifoldMap(dictBifoldable)(Data_Monoid_Dual.monoidDual(Data_Monoid_Endo.monoidEndo))(function ($101) { | |
| return Data_Monoid_Dual.Dual(Data_Monoid_Endo.Endo(Data_Function.flip(f)($101))); | |
| })(function ($102) { | |
| return Data_Monoid_Dual.Dual(Data_Monoid_Endo.Endo(Data_Function.flip(g)($102))); | |
| })(p)))(z); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | A default implementation of `bifoldr` using `bifoldMap`. | |
| // | | |
| // | Note: when defining a `Bifoldable` instance, this function is unsafe to | |
| // | use in combination with `bifoldMapDefaultR`. | |
| var bifoldrDefault = function (dictBifoldable) { | |
| return function (f) { | |
| return function (g) { | |
| return function (z) { | |
| return function (p) { | |
| return Data_Newtype.unwrap(Data_Monoid_Endo.newtypeEndo)(bifoldMap(dictBifoldable)(Data_Monoid_Endo.monoidEndo)(function ($103) { | |
| return Data_Monoid_Endo.Endo(f($103)); | |
| })(function ($104) { | |
| return Data_Monoid_Endo.Endo(g($104)); | |
| })(p))(z); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var bifoldableProduct = function (dictBifoldable) { | |
| return function (dictBifoldable1) { | |
| return new Bifoldable(function (dictMonoid) { | |
| return function (l) { | |
| return function (r) { | |
| return function (v) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(bifoldMap(dictBifoldable)(dictMonoid)(l)(r)(v.value0))(bifoldMap(dictBifoldable1)(dictMonoid)(l)(r)(v.value1)); | |
| }; | |
| }; | |
| }; | |
| }, function (l) { | |
| return function (r) { | |
| return function (u) { | |
| return function (m) { | |
| return bifoldlDefault(bifoldableProduct(dictBifoldable)(dictBifoldable1))(l)(r)(u)(m); | |
| }; | |
| }; | |
| }; | |
| }, function (l) { | |
| return function (r) { | |
| return function (u) { | |
| return function (m) { | |
| return bifoldrDefault(bifoldableProduct(dictBifoldable)(dictBifoldable1))(l)(r)(u)(m); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Fold a data structure, accumulating values in a monoidal type. | |
| var bifold = function (dictBifoldable) { | |
| return function (dictMonoid) { | |
| return bifoldMap(dictBifoldable)(dictMonoid)(Control_Category.id(Control_Category.categoryFn))(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | Test whether a predicate holds at any position in a data structure. | |
| var biany = function (dictBifoldable) { | |
| return function (dictBooleanAlgebra) { | |
| return function (p) { | |
| return function (q) { | |
| return function ($105) { | |
| return Data_Newtype.unwrap(Data_Monoid_Disj.newtypeDisj)(bifoldMap(dictBifoldable)(Data_Monoid_Disj.monoidDisj(dictBooleanAlgebra.HeytingAlgebra0()))(function ($106) { | |
| return Data_Monoid_Disj.Disj(p($106)); | |
| })(function ($107) { | |
| return Data_Monoid_Disj.Disj(q($107)); | |
| })($105)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Test whether a predicate holds at all positions in a data structure. | |
| var biall = function (dictBifoldable) { | |
| return function (dictBooleanAlgebra) { | |
| return function (p) { | |
| return function (q) { | |
| return function ($108) { | |
| return Data_Newtype.unwrap(Data_Monoid_Conj.newtypeConj)(bifoldMap(dictBifoldable)(Data_Monoid_Conj.monoidConj(dictBooleanAlgebra.HeytingAlgebra0()))(function ($109) { | |
| return Data_Monoid_Conj.Conj(p($109)); | |
| })(function ($110) { | |
| return Data_Monoid_Conj.Conj(q($110)); | |
| })($108)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Bifoldable"] = Bifoldable; | |
| exports["biall"] = biall; | |
| exports["biany"] = biany; | |
| exports["bifold"] = bifold; | |
| exports["bifoldMap"] = bifoldMap; | |
| exports["bifoldMapDefaultL"] = bifoldMapDefaultL; | |
| exports["bifoldMapDefaultR"] = bifoldMapDefaultR; | |
| exports["bifoldl"] = bifoldl; | |
| exports["bifoldlDefault"] = bifoldlDefault; | |
| exports["bifoldr"] = bifoldr; | |
| exports["bifoldrDefault"] = bifoldrDefault; | |
| exports["bifor_"] = bifor_; | |
| exports["bisequence_"] = bisequence_; | |
| exports["bitraverse_"] = bitraverse_; | |
| exports["bifoldableClown"] = bifoldableClown; | |
| exports["bifoldableJoker"] = bifoldableJoker; | |
| exports["bifoldableFlip"] = bifoldableFlip; | |
| exports["bifoldableProduct"] = bifoldableProduct; | |
| exports["bifoldableWrap"] = bifoldableWrap; | |
| })(PS["Data.Bifoldable"] = PS["Data.Bifoldable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Bifoldable = PS["Data.Bifoldable"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Bifunctor_Clown = PS["Data.Bifunctor.Clown"]; | |
| var Data_Bifunctor_Flip = PS["Data.Bifunctor.Flip"]; | |
| var Data_Bifunctor_Joker = PS["Data.Bifunctor.Joker"]; | |
| var Data_Bifunctor_Product = PS["Data.Bifunctor.Product"]; | |
| var Data_Bifunctor_Wrap = PS["Data.Bifunctor.Wrap"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | `Bitraversable` represents data structures with two type arguments which can be | |
| // | traversed. | |
| // | | |
| // | A traversal for such a structure requires two functions, one for each type | |
| // | argument. Type class instances should choose the appropriate function based | |
| // | on the type of the element encountered at each point of the traversal. | |
| // | | |
| // | Default implementations are provided by the following functions: | |
| // | | |
| // | - `bitraverseDefault` | |
| // | - `bisequenceDefault` | |
| var Bitraversable = function (Bifoldable1, Bifunctor0, bisequence, bitraverse) { | |
| this.Bifoldable1 = Bifoldable1; | |
| this.Bifunctor0 = Bifunctor0; | |
| this.bisequence = bisequence; | |
| this.bitraverse = bitraverse; | |
| }; | |
| var bitraverse = function (dict) { | |
| return dict.bitraverse; | |
| }; | |
| var lfor = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return function (t) { | |
| return function (f) { | |
| return bitraverse(dictBitraversable)(dictApplicative)(f)(Control_Applicative.pure(dictApplicative))(t); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var ltraverse = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return function (f) { | |
| return bitraverse(dictBitraversable)(dictApplicative)(f)(Control_Applicative.pure(dictApplicative)); | |
| }; | |
| }; | |
| }; | |
| var rfor = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return function (t) { | |
| return function (f) { | |
| return bitraverse(dictBitraversable)(dictApplicative)(Control_Applicative.pure(dictApplicative))(f)(t); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var rtraverse = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return bitraverse(dictBitraversable)(dictApplicative)(Control_Applicative.pure(dictApplicative)); | |
| }; | |
| }; | |
| var bitraversableJoker = function (dictTraversable) { | |
| return new Bitraversable(function () { | |
| return Data_Bifoldable.bifoldableJoker(dictTraversable.Foldable1()); | |
| }, function () { | |
| return Data_Bifunctor_Joker.bifunctorJoker(dictTraversable.Functor0()); | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Joker.Joker)(Data_Traversable.sequence(dictTraversable)(dictApplicative)(v)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return function (r) { | |
| return function (v1) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Joker.Joker)(Data_Traversable.traverse(dictTraversable)(dictApplicative)(r)(v1)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| var bitraversableClown = function (dictTraversable) { | |
| return new Bitraversable(function () { | |
| return Data_Bifoldable.bifoldableClown(dictTraversable.Foldable1()); | |
| }, function () { | |
| return Data_Bifunctor_Clown.bifunctorClown(dictTraversable.Functor0()); | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Clown.Clown)(Data_Traversable.sequence(dictTraversable)(dictApplicative)(v)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (l) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Clown.Clown)(Data_Traversable.traverse(dictTraversable)(dictApplicative)(l)(v1)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | A default implementation of `bisequence` using `bitraverse`. | |
| var bisequenceDefault = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return bitraverse(dictBitraversable)(dictApplicative)(Control_Category.id(Control_Category.categoryFn))(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var bisequence = function (dict) { | |
| return dict.bisequence; | |
| }; | |
| var bitraversableFlip = function (dictBitraversable) { | |
| return new Bitraversable(function () { | |
| return Data_Bifoldable.bifoldableFlip(dictBitraversable.Bifoldable1()); | |
| }, function () { | |
| return Data_Bifunctor_Flip.bifunctorFlip(dictBitraversable.Bifunctor0()); | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Flip.Flip)(bisequence(dictBitraversable)(dictApplicative)(v)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (r) { | |
| return function (l) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Flip.Flip)(bitraverse(dictBitraversable)(dictApplicative)(l)(r)(v)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| var bitraversableProduct = function (dictBitraversable) { | |
| return function (dictBitraversable1) { | |
| return new Bitraversable(function () { | |
| return Data_Bifoldable.bifoldableProduct(dictBitraversable.Bifoldable1())(dictBitraversable1.Bifoldable1()); | |
| }, function () { | |
| return Data_Bifunctor_Product.bifunctorProduct(dictBitraversable.Bifunctor0())(dictBitraversable1.Bifunctor0()); | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Product.Product.create)(bisequence(dictBitraversable)(dictApplicative)(v.value0)))(bisequence(dictBitraversable1)(dictApplicative)(v.value1)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (l) { | |
| return function (r) { | |
| return function (v) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Product.Product.create)(bitraverse(dictBitraversable)(dictApplicative)(l)(r)(v.value0)))(bitraverse(dictBitraversable1)(dictApplicative)(l)(r)(v.value1)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bitraversableWrap = function (dictBitraversable) { | |
| return new Bitraversable(function () { | |
| return Data_Bifoldable.bifoldableWrap(dictBitraversable.Bifoldable1()); | |
| }, function () { | |
| return Data_Bifunctor_Wrap.bifunctorWrap(dictBitraversable.Bifunctor0()); | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Wrap.Wrap)(bisequence(dictBitraversable)(dictApplicative)(v)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (l) { | |
| return function (r) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Bifunctor_Wrap.Wrap)(bitraverse(dictBitraversable)(dictApplicative)(l)(r)(v)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | A default implementation of `bitraverse` using `bisequence` and `bimap`. | |
| var bitraverseDefault = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return function (f) { | |
| return function (g) { | |
| return function (t) { | |
| return bisequence(dictBitraversable)(dictApplicative)(Data_Bifunctor.bimap(dictBitraversable.Bifunctor0())(f)(g)(t)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Traverse a data structure, accumulating effects and results using an `Applicative` functor. | |
| var bifor = function (dictBitraversable) { | |
| return function (dictApplicative) { | |
| return function (t) { | |
| return function (f) { | |
| return function (g) { | |
| return bitraverse(dictBitraversable)(dictApplicative)(f)(g)(t); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Bitraversable"] = Bitraversable; | |
| exports["bifor"] = bifor; | |
| exports["bisequence"] = bisequence; | |
| exports["bisequenceDefault"] = bisequenceDefault; | |
| exports["bitraverse"] = bitraverse; | |
| exports["bitraverseDefault"] = bitraverseDefault; | |
| exports["lfor"] = lfor; | |
| exports["ltraverse"] = ltraverse; | |
| exports["rfor"] = rfor; | |
| exports["rtraverse"] = rtraverse; | |
| exports["bitraversableClown"] = bitraversableClown; | |
| exports["bitraversableJoker"] = bitraversableJoker; | |
| exports["bitraversableFlip"] = bitraversableFlip; | |
| exports["bitraversableProduct"] = bitraversableProduct; | |
| exports["bitraversableWrap"] = bitraversableWrap; | |
| })(PS["Data.Bitraversable"] = PS["Data.Bitraversable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_Bifoldable = PS["Data.Bifoldable"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Bitraversable = PS["Data.Bitraversable"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `Either` type is used to represent a choice between two types of value. | |
| // | | |
| // | A common use case for `Either` is error handling, where `Left` is used to | |
| // | carry an error value and `Right` is used to carry a success value. | |
| var Left = (function () { | |
| function Left(value0) { | |
| this.value0 = value0; | |
| }; | |
| Left.create = function (value0) { | |
| return new Left(value0); | |
| }; | |
| return Left; | |
| })(); | |
| // | The `Either` type is used to represent a choice between two types of value. | |
| // | | |
| // | A common use case for `Either` is error handling, where `Left` is used to | |
| // | carry an error value and `Right` is used to carry a success value. | |
| var Right = (function () { | |
| function Right(value0) { | |
| this.value0 = value0; | |
| }; | |
| Right.create = function (value0) { | |
| return new Right(value0); | |
| }; | |
| return Right; | |
| })(); | |
| // | The `Show` instance allows `Either` values to be rendered as a string with | |
| // | `show` whenever there is an `Show` instance for both type the `Either` can | |
| // | contain. | |
| var showEither = function (dictShow) { | |
| return function (dictShow1) { | |
| return new Data_Show.Show(function (v) { | |
| if (v instanceof Left) { | |
| return "(Left " + (Data_Show.show(dictShow)(v.value0) + ")"); | |
| }; | |
| if (v instanceof Right) { | |
| return "(Right " + (Data_Show.show(dictShow1)(v.value0) + ")"); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 160, column 1 - line 160, column 61: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| }; | |
| // | Takes a default and a `Maybe` value, if the value is a `Just`, turn it into | |
| // | a `Right`, if the value is a `Nothing` use the provided default as a `Left` | |
| // | | |
| // | ```purescript | |
| // | note "default" Nothing = Left "default" | |
| // | note "default" (Just 1) = Right 1 | |
| // | ``` | |
| var note = function (a) { | |
| return Data_Maybe.maybe(new Left(a))(Right.create); | |
| }; | |
| // | The `Functor` instance allows functions to transform the contents of a | |
| // | `Right` with the `<$>` operator: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Right x == Right (f x) | |
| // | ``` | |
| // | | |
| // | `Left` values are untouched: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Left y == Left y | |
| // | ``` | |
| var functorEither = new Data_Functor.Functor(function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Left) { | |
| return new Left(v1.value0); | |
| }; | |
| if (v1 instanceof Right) { | |
| return new Right(v(v1.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 36, column 1 - line 36, column 45: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var invariantEither = new Data_Functor_Invariant.Invariant(Data_Functor_Invariant.imapF(functorEither)); | |
| // | A partial function that extracts the value from the `Right` data constructor. | |
| // | Passing a `Left` to `fromRight` will throw an error at runtime. | |
| var fromRight = function (dictPartial) { | |
| return function (v) { | |
| var __unused = function (dictPartial1) { | |
| return function ($dollar62) { | |
| return $dollar62; | |
| }; | |
| }; | |
| return __unused(dictPartial)((function () { | |
| if (v instanceof Right) { | |
| return v.value0; | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 252, column 1 - line 252, column 52: " + [ v.constructor.name ]); | |
| })()); | |
| }; | |
| }; | |
| // | A partial function that extracts the value from the `Left` data constructor. | |
| // | Passing a `Right` to `fromLeft` will throw an error at runtime. | |
| var fromLeft = function (dictPartial) { | |
| return function (v) { | |
| var __unused = function (dictPartial1) { | |
| return function ($dollar66) { | |
| return $dollar66; | |
| }; | |
| }; | |
| return __unused(dictPartial)((function () { | |
| if (v instanceof Left) { | |
| return v.value0; | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 247, column 1 - line 247, column 51: " + [ v.constructor.name ]); | |
| })()); | |
| }; | |
| }; | |
| var foldableEither = new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| if (v instanceof Left) { | |
| return Data_Monoid.mempty(dictMonoid); | |
| }; | |
| if (v instanceof Right) { | |
| return f(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ f.constructor.name, v.constructor.name ]); | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (z) { | |
| return function (v1) { | |
| if (v1 instanceof Left) { | |
| return z; | |
| }; | |
| if (v1 instanceof Right) { | |
| return v(z)(v1.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (z) { | |
| return function (v1) { | |
| if (v1 instanceof Left) { | |
| return z; | |
| }; | |
| if (v1 instanceof Right) { | |
| return v(v1.value0)(z); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| var traversableEither = new Data_Traversable.Traversable(function () { | |
| return foldableEither; | |
| }, function () { | |
| return functorEither; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| if (v instanceof Left) { | |
| return Control_Applicative.pure(dictApplicative)(new Left(v.value0)); | |
| }; | |
| if (v instanceof Right) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Right.create)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 200, column 1 - line 200, column 53: " + [ v.constructor.name ]); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Left) { | |
| return Control_Applicative.pure(dictApplicative)(new Left(v1.value0)); | |
| }; | |
| if (v1 instanceof Right) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Right.create)(v(v1.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 200, column 1 - line 200, column 53: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| // | The `Extend` instance allows sequencing of `Either` values and functions | |
| // | that accept an `Either` and return a non-`Either` result using the | |
| // | `<<=` operator. | |
| // | | |
| // | ``` purescript | |
| // | f <<= Left x = Left x | |
| // | f <<= Right x = Right (f (Right x)) | |
| // | ``` | |
| var extendEither = new Control_Extend.Extend(function () { | |
| return functorEither; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Left) { | |
| return new Left(v1.value0); | |
| }; | |
| return new Right(v(v1)); | |
| }; | |
| }); | |
| var eqEither = function (dictEq) { | |
| return function (dictEq1) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| if (x instanceof Left && y instanceof Left) { | |
| return Data_Eq.eq(dictEq)(x.value0)(y.value0); | |
| }; | |
| if (x instanceof Right && y instanceof Right) { | |
| return Data_Eq.eq(dictEq1)(x.value0)(y.value0); | |
| }; | |
| return false; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var ordEither = function (dictOrd) { | |
| return function (dictOrd1) { | |
| return new Data_Ord.Ord(function () { | |
| return eqEither(dictOrd.Eq0())(dictOrd1.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| if (x instanceof Left && y instanceof Left) { | |
| return Data_Ord.compare(dictOrd)(x.value0)(y.value0); | |
| }; | |
| if (x instanceof Left) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (y instanceof Left) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (x instanceof Right && y instanceof Right) { | |
| return Data_Ord.compare(dictOrd1)(x.value0)(y.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 176, column 8 - line 176, column 64: " + [ x.constructor.name, y.constructor.name ]); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var eq1Either = function (dictEq) { | |
| return new Data_Eq.Eq1(function (dictEq1) { | |
| return Data_Eq.eq(eqEither(dictEq)(dictEq1)); | |
| }); | |
| }; | |
| var ord1Either = function (dictOrd) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1Either(dictOrd.Eq0()); | |
| }, function (dictOrd1) { | |
| return Data_Ord.compare(ordEither(dictOrd)(dictOrd1)); | |
| }); | |
| }; | |
| // | Takes two functions and an `Either` value, if the value is a `Left` the | |
| // | inner value is applied to the first function, if the value is a `Right` | |
| // | the inner value is applied to the second function. | |
| // | | |
| // | ``` purescript | |
| // | either f g (Left x) == f x | |
| // | either f g (Right y) == g y | |
| // | ``` | |
| var either = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Left) { | |
| return v(v2.value0); | |
| }; | |
| if (v2 instanceof Right) { | |
| return v1(v2.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 229, column 1 - line 229, column 64: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Turns an `Either` into a `Maybe`, by throwing eventual `Left` values away and converting | |
| // | them into `Nothing`. `Right` values get turned into `Just`s. | |
| // | | |
| // | ```purescript | |
| // | hush (Left "ParseError") = Nothing | |
| // | hush (Right 42) = Just 42 | |
| // | ``` | |
| var hush = either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create); | |
| // | Returns `true` when the `Either` value was constructed with `Left`. | |
| var isLeft = either(Data_Function["const"](true))(Data_Function["const"](false)); | |
| // | Returns `true` when the `Either` value was constructed with `Right`. | |
| var isRight = either(Data_Function["const"](false))(Data_Function["const"](true)); | |
| // | Combine two alternatives. | |
| var choose = function (dictAlt) { | |
| return function (a) { | |
| return function (b) { | |
| return Control_Alt.alt(dictAlt)(Data_Functor.map(dictAlt.Functor0())(Left.create)(a))(Data_Functor.map(dictAlt.Functor0())(Right.create)(b)); | |
| }; | |
| }; | |
| }; | |
| var boundedEither = function (dictBounded) { | |
| return function (dictBounded1) { | |
| return new Data_Bounded.Bounded(function () { | |
| return ordEither(dictBounded.Ord0())(dictBounded1.Ord0()); | |
| }, new Left(Data_Bounded.bottom(dictBounded)), new Right(Data_Bounded.top(dictBounded1))); | |
| }; | |
| }; | |
| var bifunctorEither = new Data_Bifunctor.Bifunctor(function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Left) { | |
| return new Left(v(v2.value0)); | |
| }; | |
| if (v2 instanceof Right) { | |
| return new Right(v1(v2.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 43, column 1 - line 43, column 45: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| var bifoldableEither = new Data_Bifoldable.Bifoldable(function (dictMonoid) { | |
| return function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Left) { | |
| return v(v2.value0); | |
| }; | |
| if (v2 instanceof Right) { | |
| return v1(v2.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 192, column 1 - line 192, column 47: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return function (z) { | |
| return function (v2) { | |
| if (v2 instanceof Left) { | |
| return v(z)(v2.value0); | |
| }; | |
| if (v2 instanceof Right) { | |
| return v1(z)(v2.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 192, column 1 - line 192, column 47: " + [ v.constructor.name, v1.constructor.name, z.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return function (z) { | |
| return function (v2) { | |
| if (v2 instanceof Left) { | |
| return v(v2.value0)(z); | |
| }; | |
| if (v2 instanceof Right) { | |
| return v1(v2.value0)(z); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 192, column 1 - line 192, column 47: " + [ v.constructor.name, v1.constructor.name, z.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }); | |
| var bitraversableEither = new Data_Bitraversable.Bitraversable(function () { | |
| return bifoldableEither; | |
| }, function () { | |
| return bifunctorEither; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| if (v instanceof Left) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Left.create)(v.value0); | |
| }; | |
| if (v instanceof Right) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Right.create)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 206, column 1 - line 206, column 53: " + [ v.constructor.name ]); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Left) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Left.create)(v(v2.value0)); | |
| }; | |
| if (v2 instanceof Right) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Right.create)(v1(v2.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 206, column 1 - line 206, column 53: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }); | |
| // | The `Apply` instance allows functions contained within a `Right` to | |
| // | transform a value contained within a `Right` using the `(<*>)` operator: | |
| // | | |
| // | ``` purescript | |
| // | Right f <*> Right x == Right (f x) | |
| // | ``` | |
| // | | |
| // | `Left` values are left untouched: | |
| // | | |
| // | ``` purescript | |
| // | Left f <*> Right x == Left x | |
| // | Right f <*> Left y == Left y | |
| // | ``` | |
| // | | |
| // | Combining `Functor`'s `<$>` with `Apply`'s `<*>` can be used to transform a | |
| // | pure function to take `Either`-typed arguments so `f :: a -> b -> c` | |
| // | becomes `f :: Either l a -> Either l b -> Either l c`: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Right x <*> Right y == Right (f x y) | |
| // | ``` | |
| // | | |
| // | The `Left`-preserving behaviour of both operators means the result of | |
| // | an expression like the above but where any one of the values is `Left` | |
| // | means the whole result becomes `Left` also, taking the first `Left` value | |
| // | found: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Left x <*> Right y == Left x | |
| // | f <$> Right x <*> Left y == Left y | |
| // | f <$> Left x <*> Left y == Left x | |
| // | ``` | |
| var applyEither = new Control_Apply.Apply(function () { | |
| return functorEither; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Left) { | |
| return new Left(v.value0); | |
| }; | |
| if (v instanceof Right) { | |
| return Data_Functor.map(functorEither)(v.value0)(v1); | |
| }; | |
| throw new Error("Failed pattern match at Data.Either line 79, column 1 - line 79, column 41: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| // | The `Bind` instance allows sequencing of `Either` values and functions that | |
| // | return an `Either` by using the `>>=` operator: | |
| // | | |
| // | ``` purescript | |
| // | Left x >>= f = Left x | |
| // | Right x >>= f = f x | |
| // | ``` | |
| var bindEither = new Control_Bind.Bind(function () { | |
| return applyEither; | |
| }, either(function (e) { | |
| return function (v) { | |
| return new Left(e); | |
| }; | |
| })(function (a) { | |
| return function (f) { | |
| return f(a); | |
| }; | |
| })); | |
| var semigroupEither = function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(function (x) { | |
| return function (y) { | |
| return Control_Apply.apply(applyEither)(Data_Functor.map(functorEither)(Data_Semigroup.append(dictSemigroup))(x))(y); | |
| }; | |
| }); | |
| }; | |
| var semiringEither = function (dictSemiring) { | |
| return new Data_Semiring.Semiring(function (x) { | |
| return function (y) { | |
| return Control_Apply.apply(applyEither)(Data_Functor.map(functorEither)(Data_Semiring.add(dictSemiring))(x))(y); | |
| }; | |
| }, function (x) { | |
| return function (y) { | |
| return Control_Apply.apply(applyEither)(Data_Functor.map(functorEither)(Data_Semiring.mul(dictSemiring))(x))(y); | |
| }; | |
| }, new Right(Data_Semiring.one(dictSemiring)), new Right(Data_Semiring.zero(dictSemiring))); | |
| }; | |
| // | The `Applicative` instance enables lifting of values into `Either` with the | |
| // | `pure` function: | |
| // | | |
| // | ``` purescript | |
| // | pure x :: Either _ _ == Right x | |
| // | ``` | |
| // | | |
| // | Combining `Functor`'s `<$>` with `Apply`'s `<*>` and `Applicative`'s | |
| // | `pure` can be used to pass a mixture of `Either` and non-`Either` typed | |
| // | values to a function that does not usually expect them, by using `pure` | |
| // | for any value that is not already `Either` typed: | |
| // | | |
| // | ``` purescript | |
| // | f <$> Right x <*> pure y == Right (f x y) | |
| // | ``` | |
| // | | |
| // | Even though `pure = Right` it is recommended to use `pure` in situations | |
| // | like this as it allows the choice of `Applicative` to be changed later | |
| // | without having to go through and replace `Right` with a new constructor. | |
| var applicativeEither = new Control_Applicative.Applicative(function () { | |
| return applyEither; | |
| }, Right.create); | |
| // | The `Monad` instance guarantees that there are both `Applicative` and | |
| // | `Bind` instances for `Either`. This also enables the `do` syntactic sugar: | |
| // | | |
| // | ``` purescript | |
| // | do | |
| // | x' <- x | |
| // | y' <- y | |
| // | pure (f x' y') | |
| // | ``` | |
| // | | |
| // | Which is equivalent to: | |
| // | | |
| // | ``` purescript | |
| // | x >>= (\x' -> y >>= (\y' -> pure (f x' y'))) | |
| // | ``` | |
| var monadEither = new Control_Monad.Monad(function () { | |
| return applicativeEither; | |
| }, function () { | |
| return bindEither; | |
| }); | |
| // | The `Alt` instance allows for a choice to be made between two `Either` | |
| // | values with the `<|>` operator, where the first `Right` encountered | |
| // | is taken. | |
| // | | |
| // | ``` purescript | |
| // | Right x <|> Right y == Right x | |
| // | Left x <|> Right y == Right y | |
| // | Left x <|> Left y == Left y | |
| // | ``` | |
| var altEither = new Control_Alt.Alt(function () { | |
| return functorEither; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Left) { | |
| return v1; | |
| }; | |
| return v; | |
| }; | |
| }); | |
| exports["Left"] = Left; | |
| exports["Right"] = Right; | |
| exports["choose"] = choose; | |
| exports["either"] = either; | |
| exports["fromLeft"] = fromLeft; | |
| exports["fromRight"] = fromRight; | |
| exports["hush"] = hush; | |
| exports["isLeft"] = isLeft; | |
| exports["isRight"] = isRight; | |
| exports["note"] = note; | |
| exports["functorEither"] = functorEither; | |
| exports["invariantEither"] = invariantEither; | |
| exports["bifunctorEither"] = bifunctorEither; | |
| exports["applyEither"] = applyEither; | |
| exports["applicativeEither"] = applicativeEither; | |
| exports["altEither"] = altEither; | |
| exports["bindEither"] = bindEither; | |
| exports["monadEither"] = monadEither; | |
| exports["extendEither"] = extendEither; | |
| exports["showEither"] = showEither; | |
| exports["eqEither"] = eqEither; | |
| exports["eq1Either"] = eq1Either; | |
| exports["ordEither"] = ordEither; | |
| exports["ord1Either"] = ord1Either; | |
| exports["boundedEither"] = boundedEither; | |
| exports["foldableEither"] = foldableEither; | |
| exports["bifoldableEither"] = bifoldableEither; | |
| exports["traversableEither"] = traversableEither; | |
| exports["bitraversableEither"] = bitraversableEither; | |
| exports["semiringEither"] = semiringEither; | |
| exports["semigroupEither"] = semigroupEither; | |
| })(PS["Data.Either"] = PS["Data.Either"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | The `Lazy` class represents types which allow evaluation of values | |
| // | to be _deferred_. | |
| // | | |
| // | Usually, this means that a type contains a function arrow which can | |
| // | be used to delay evaluation. | |
| var Lazy = function (defer) { | |
| this.defer = defer; | |
| }; | |
| var lazyUnit = new Lazy(function (v) { | |
| return Data_Unit.unit; | |
| }); | |
| var lazyFn = new Lazy(function (f) { | |
| return function (x) { | |
| return f(Data_Unit.unit)(x); | |
| }; | |
| }); | |
| var defer = function (dict) { | |
| return dict.defer; | |
| }; | |
| // | `fix` defines a value as the fixed point of a function. | |
| // | | |
| // | The `Lazy` instance allows us to generate the result lazily. | |
| var fix = function (dictLazy) { | |
| return function (f) { | |
| return defer(dictLazy)(function (v) { | |
| return f(fix(dictLazy)(f)); | |
| }); | |
| }; | |
| }; | |
| exports["Lazy"] = Lazy; | |
| exports["defer"] = defer; | |
| exports["fix"] = fix; | |
| exports["lazyFn"] = lazyFn; | |
| exports["lazyUnit"] = lazyUnit; | |
| })(PS["Control.Lazy"] = PS["Control.Lazy"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Field = PS["Data.Field"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| var Identity = function (x) { | |
| return x; | |
| }; | |
| var showIdentity = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Identity " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var semiringIdentity = function (dictSemiring) { | |
| return dictSemiring; | |
| }; | |
| var semigroupIdenity = function (dictSemigroup) { | |
| return dictSemigroup; | |
| }; | |
| var ringIdentity = function (dictRing) { | |
| return dictRing; | |
| }; | |
| var ordIdentity = function (dictOrd) { | |
| return dictOrd; | |
| }; | |
| var newtypeIdentity = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Identity); | |
| var monoidIdentity = function (dictMonoid) { | |
| return dictMonoid; | |
| }; | |
| var lazyIdentity = function (dictLazy) { | |
| return dictLazy; | |
| }; | |
| var heytingAlgebraIdentity = function (dictHeytingAlgebra) { | |
| return dictHeytingAlgebra; | |
| }; | |
| var functorIdentity = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }); | |
| var invariantIdentity = new Data_Functor_Invariant.Invariant(Data_Functor_Invariant.imapF(functorIdentity)); | |
| var foldableIdentity = new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v)(z); | |
| }; | |
| }; | |
| }); | |
| var traversableIdentity = new Data_Traversable.Traversable(function () { | |
| return foldableIdentity; | |
| }, function () { | |
| return functorIdentity; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Identity)(v); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Identity)(f(v)); | |
| }; | |
| }; | |
| }); | |
| var fieldIdentity = function (dictField) { | |
| return dictField; | |
| }; | |
| var extendIdentity = new Control_Extend.Extend(function () { | |
| return functorIdentity; | |
| }, function (f) { | |
| return function (m) { | |
| return f(m); | |
| }; | |
| }); | |
| var euclideanRingIdentity = function (dictEuclideanRing) { | |
| return dictEuclideanRing; | |
| }; | |
| var eqIdentity = function (dictEq) { | |
| return dictEq; | |
| }; | |
| var eq1Identity = new Data_Eq.Eq1(function (dictEq) { | |
| return Data_Eq.eq(eqIdentity(dictEq)); | |
| }); | |
| var ord1Identity = new Data_Ord.Ord1(function () { | |
| return eq1Identity; | |
| }, function (dictOrd) { | |
| return Data_Ord.compare(ordIdentity(dictOrd)); | |
| }); | |
| var comonadIdentity = new Control_Comonad.Comonad(function () { | |
| return extendIdentity; | |
| }, function (v) { | |
| return v; | |
| }); | |
| var commutativeRingIdentity = function (dictCommutativeRing) { | |
| return dictCommutativeRing; | |
| }; | |
| var boundedIdentity = function (dictBounded) { | |
| return dictBounded; | |
| }; | |
| var booleanAlgebraIdentity = function (dictBooleanAlgebra) { | |
| return dictBooleanAlgebra; | |
| }; | |
| var applyIdentity = new Control_Apply.Apply(function () { | |
| return functorIdentity; | |
| }, function (v) { | |
| return function (v1) { | |
| return v(v1); | |
| }; | |
| }); | |
| var bindIdentity = new Control_Bind.Bind(function () { | |
| return applyIdentity; | |
| }, function (v) { | |
| return function (f) { | |
| return f(v); | |
| }; | |
| }); | |
| var applicativeIdentity = new Control_Applicative.Applicative(function () { | |
| return applyIdentity; | |
| }, Identity); | |
| var monadIdentity = new Control_Monad.Monad(function () { | |
| return applicativeIdentity; | |
| }, function () { | |
| return bindIdentity; | |
| }); | |
| var altIdentity = new Control_Alt.Alt(function () { | |
| return functorIdentity; | |
| }, function (x) { | |
| return function (v) { | |
| return x; | |
| }; | |
| }); | |
| exports["Identity"] = Identity; | |
| exports["newtypeIdentity"] = newtypeIdentity; | |
| exports["eqIdentity"] = eqIdentity; | |
| exports["ordIdentity"] = ordIdentity; | |
| exports["boundedIdentity"] = boundedIdentity; | |
| exports["heytingAlgebraIdentity"] = heytingAlgebraIdentity; | |
| exports["booleanAlgebraIdentity"] = booleanAlgebraIdentity; | |
| exports["semigroupIdenity"] = semigroupIdenity; | |
| exports["monoidIdentity"] = monoidIdentity; | |
| exports["semiringIdentity"] = semiringIdentity; | |
| exports["euclideanRingIdentity"] = euclideanRingIdentity; | |
| exports["ringIdentity"] = ringIdentity; | |
| exports["commutativeRingIdentity"] = commutativeRingIdentity; | |
| exports["fieldIdentity"] = fieldIdentity; | |
| exports["lazyIdentity"] = lazyIdentity; | |
| exports["showIdentity"] = showIdentity; | |
| exports["eq1Identity"] = eq1Identity; | |
| exports["ord1Identity"] = ord1Identity; | |
| exports["functorIdentity"] = functorIdentity; | |
| exports["invariantIdentity"] = invariantIdentity; | |
| exports["altIdentity"] = altIdentity; | |
| exports["applyIdentity"] = applyIdentity; | |
| exports["applicativeIdentity"] = applicativeIdentity; | |
| exports["bindIdentity"] = bindIdentity; | |
| exports["monadIdentity"] = monadIdentity; | |
| exports["extendIdentity"] = extendIdentity; | |
| exports["comonadIdentity"] = comonadIdentity; | |
| exports["foldableIdentity"] = foldableIdentity; | |
| exports["traversableIdentity"] = traversableIdentity; | |
| })(PS["Data.Identity"] = PS["Data.Identity"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // module Partial.Unsafe | |
| exports.unsafePartial = function (f) { | |
| return f(); | |
| }; | |
| })(PS["Partial.Unsafe"] = PS["Partial.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // module Partial | |
| exports.crashWith = function () { | |
| return function (msg) { | |
| throw new Error(msg); | |
| }; | |
| }; | |
| })(PS["Partial"] = PS["Partial"] || {}); | |
| (function(exports) { | |
| // | Some partial helper functions. | |
| "use strict"; | |
| var $foreign = PS["Partial"]; | |
| // | A partial function which crashes on any input with a default message. | |
| var crash = function (dictPartial) { | |
| return $foreign.crashWith(dictPartial)("Partial.crash: partial function"); | |
| }; | |
| exports["crash"] = crash; | |
| exports["crashWith"] = $foreign.crashWith; | |
| })(PS["Partial"] = PS["Partial"] || {}); | |
| (function(exports) { | |
| // | Utilities for working with partial functions. | |
| "use strict"; | |
| var $foreign = PS["Partial.Unsafe"]; | |
| var Partial = PS["Partial"]; | |
| // | *deprecated:* use `unsafePartial` instead. | |
| var unsafePartialBecause = function (v) { | |
| return function (x) { | |
| return $foreign.unsafePartial(function (dictPartial) { | |
| return x(dictPartial); | |
| }); | |
| }; | |
| }; | |
| // | A function which crashes with the specified error message. | |
| var unsafeCrashWith = function (msg) { | |
| return $foreign.unsafePartial(function (dictPartial) { | |
| return Partial.crashWith(dictPartial)(msg); | |
| }); | |
| }; | |
| exports["unsafeCrashWith"] = unsafeCrashWith; | |
| exports["unsafePartialBecause"] = unsafePartialBecause; | |
| exports["unsafePartial"] = $foreign.unsafePartial; | |
| })(PS["Partial.Unsafe"] = PS["Partial.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; | |
| var Control_Monad_ST = PS["Control.Monad.ST"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Partial_Unsafe = PS["Partial.Unsafe"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The result of a computation: either `Loop` containing the updated | |
| // | accumulator, or `Done` containing the final result of the computation. | |
| var Loop = (function () { | |
| function Loop(value0) { | |
| this.value0 = value0; | |
| }; | |
| Loop.create = function (value0) { | |
| return new Loop(value0); | |
| }; | |
| return Loop; | |
| })(); | |
| // | The result of a computation: either `Loop` containing the updated | |
| // | accumulator, or `Done` containing the final result of the computation. | |
| var Done = (function () { | |
| function Done(value0) { | |
| this.value0 = value0; | |
| }; | |
| Done.create = function (value0) { | |
| return new Done(value0); | |
| }; | |
| return Done; | |
| })(); | |
| // | This type class captures those monads which support tail recursion in | |
| // | constant stack space. | |
| // | | |
| // | The `tailRecM` function takes a step function, and applies that step | |
| // | function recursively until a pure value of type `b` is found. | |
| // | | |
| // | Instances are provided for standard monad transformers. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | loopWriter :: Number -> WriterT Sum (Eff (trace :: Trace)) Unit | |
| // | loopWriter n = tailRecM go n | |
| // | where | |
| // | go 0 = do | |
| // | lift $ trace "Done!" | |
| // | pure (Done unit) | |
| // | go n = do | |
| // | tell $ Sum n | |
| // | pure (Loop (n - 1)) | |
| // | ``` | |
| var MonadRec = function (Monad0, tailRecM) { | |
| this.Monad0 = Monad0; | |
| this.tailRecM = tailRecM; | |
| }; | |
| var tailRecM = function (dict) { | |
| return dict.tailRecM; | |
| }; | |
| // | Create a tail-recursive function of two arguments which uses constant stack space. | |
| var tailRecM2 = function (dictMonadRec) { | |
| return function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return tailRecM(dictMonadRec)(function (o) { | |
| return f(o.a)(o.b); | |
| })({ | |
| a: a, | |
| b: b | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Create a tail-recursive function of three arguments which uses constant stack space. | |
| var tailRecM3 = function (dictMonadRec) { | |
| return function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return tailRecM(dictMonadRec)(function (o) { | |
| return f(o.a)(o.b)(o.c); | |
| })({ | |
| a: a, | |
| b: b, | |
| c: c | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var tailRecEff = function (f) { | |
| return function (a) { | |
| var fromDone = function (v) { | |
| var __unused = function (dictPartial1) { | |
| return function ($dollar16) { | |
| return $dollar16; | |
| }; | |
| }; | |
| return __unused()((function () { | |
| if (v instanceof Done) { | |
| return v.value0; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 141, column 28 - line 141, column 42: " + [ v.constructor.name ]); | |
| })()); | |
| }; | |
| var f$prime = function ($52) { | |
| return Control_Monad_Eff_Unsafe.unsafeCoerceEff(f($52)); | |
| }; | |
| return function __do() { | |
| var v = Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Control_Monad_ST.newSTRef)(f$prime(a))(); | |
| (function () { | |
| while (!(function __do() { | |
| var v1 = v.value; | |
| if (v1 instanceof Loop) { | |
| var v2 = f$prime(v1.value0)(); | |
| var v3 = v.value = v2; | |
| return false; | |
| }; | |
| if (v1 instanceof Done) { | |
| return true; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 130, column 5 - line 135, column 26: " + [ v1.constructor.name ]); | |
| })()) { | |
| }; | |
| return {}; | |
| })(); | |
| return Data_Functor.map(Control_Monad_Eff.functorEff)(fromDone)(Control_Monad_ST.readSTRef(v))(); | |
| }; | |
| }; | |
| }; | |
| // | Create a pure tail-recursive function of one argument | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | pow :: Number -> Number -> Number | |
| // | pow n p = tailRec go { accum: 1, power: p } | |
| // | where | |
| // | go :: _ -> Step _ Number | |
| // | go { accum: acc, power: 0 } = Done acc | |
| // | go { accum: acc, power: p } = Loop { accum: acc * n, power: p - 1 } | |
| // | ``` | |
| var tailRec = function (f) { | |
| var go = function ($copy_v) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| if (v instanceof Loop) { | |
| $copy_v = f(v.value0); | |
| return; | |
| }; | |
| if (v instanceof Done) { | |
| $tco_done = true; | |
| return v.value0; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 96, column 3 - line 96, column 25: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| return function ($53) { | |
| return go(f($53)); | |
| }; | |
| }; | |
| var monadRecMaybe = new MonadRec(function () { | |
| return Data_Maybe.monadMaybe; | |
| }, function (f) { | |
| return function (a0) { | |
| var g = function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return new Done(Data_Maybe.Nothing.value); | |
| }; | |
| if (v instanceof Data_Maybe.Just && v.value0 instanceof Loop) { | |
| return new Loop(f(v.value0.value0)); | |
| }; | |
| if (v instanceof Data_Maybe.Just && v.value0 instanceof Done) { | |
| return new Done(new Data_Maybe.Just(v.value0.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 120, column 7 - line 120, column 31: " + [ v.constructor.name ]); | |
| }; | |
| return tailRec(g)(f(a0)); | |
| }; | |
| }); | |
| var monadRecIdentity = new MonadRec(function () { | |
| return Data_Identity.monadIdentity; | |
| }, function (f) { | |
| var runIdentity = function (v) { | |
| return v; | |
| }; | |
| return function ($54) { | |
| return Data_Identity.Identity(tailRec(function ($55) { | |
| return runIdentity(f($55)); | |
| })($54)); | |
| }; | |
| }); | |
| var monadRecFunction = new MonadRec(function () { | |
| return Control_Monad.monadFn; | |
| }, function (f) { | |
| return function (a0) { | |
| return function (e) { | |
| return tailRec(function (a) { | |
| return f(a)(e); | |
| })(a0); | |
| }; | |
| }; | |
| }); | |
| var monadRecEither = new MonadRec(function () { | |
| return Data_Either.monadEither; | |
| }, function (f) { | |
| return function (a0) { | |
| var g = function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return new Done(new Data_Either.Left(v.value0)); | |
| }; | |
| if (v instanceof Data_Either.Right && v.value0 instanceof Loop) { | |
| return new Loop(f(v.value0.value0)); | |
| }; | |
| if (v instanceof Data_Either.Right && v.value0 instanceof Done) { | |
| return new Done(new Data_Either.Right(v.value0.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 112, column 7 - line 112, column 33: " + [ v.constructor.name ]); | |
| }; | |
| return tailRec(g)(f(a0)); | |
| }; | |
| }); | |
| var monadRecEff = new MonadRec(function () { | |
| return Control_Monad_Eff.monadEff; | |
| }, tailRecEff); | |
| var functorStep = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| if (v instanceof Loop) { | |
| return new Loop(v.value0); | |
| }; | |
| if (v instanceof Done) { | |
| return new Done(f(v.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 28, column 1 - line 28, column 41: " + [ f.constructor.name, v.constructor.name ]); | |
| }; | |
| }); | |
| // | `forever` runs an action indefinitely, using the `MonadRec` instance to | |
| // | ensure constant stack usage. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | main = forever $ trace "Hello, World!" | |
| // | ``` | |
| var forever = function (dictMonadRec) { | |
| return function (ma) { | |
| return tailRecM(dictMonadRec)(function (u) { | |
| return Data_Functor.voidRight((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(new Loop(u))(ma); | |
| })(Data_Unit.unit); | |
| }; | |
| }; | |
| var bifunctorStep = new Data_Bifunctor.Bifunctor(function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Loop) { | |
| return new Loop(v(v2.value0)); | |
| }; | |
| if (v2 instanceof Done) { | |
| return new Done(v1(v2.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Rec.Class line 32, column 1 - line 32, column 41: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| exports["Loop"] = Loop; | |
| exports["Done"] = Done; | |
| exports["MonadRec"] = MonadRec; | |
| exports["forever"] = forever; | |
| exports["tailRec"] = tailRec; | |
| exports["tailRecM"] = tailRecM; | |
| exports["tailRecM2"] = tailRecM2; | |
| exports["tailRecM3"] = tailRecM3; | |
| exports["functorStep"] = functorStep; | |
| exports["bifunctorStep"] = bifunctorStep; | |
| exports["monadRecIdentity"] = monadRecIdentity; | |
| exports["monadRecEff"] = monadRecEff; | |
| exports["monadRecFunction"] = monadRecFunction; | |
| exports["monadRecEither"] = monadRecEither; | |
| exports["monadRecMaybe"] = monadRecMaybe; | |
| })(PS["Control.Monad.Rec.Class"] = PS["Control.Monad.Rec.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MonadTrans` type class of _monad transformers_. | |
| "use strict"; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MonadTrans` type class represents _monad transformers_. | |
| // | | |
| // | A monad transformer is a type constructor of kind `(* -> *) -> * -> *`, which | |
| // | takes a `Monad` as its first argument, and returns another `Monad`. | |
| // | | |
| // | This allows us to add additional effects to an existing monad. By iterating this | |
| // | process, we create monad transformer _stacks_, which contain all of the effects | |
| // | required for a particular computation. | |
| // | | |
| // | The laws state that `lift` is a `Monad` morphism. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - `lift (pure a) = pure a` | |
| // | - `lift (do { x <- m ; y }) = do { x <- lift m ; lift y }` | |
| var MonadTrans = function (lift) { | |
| this.lift = lift; | |
| }; | |
| var lift = function (dict) { | |
| return dict.lift; | |
| }; | |
| exports["MonadTrans"] = MonadTrans; | |
| exports["lift"] = lift; | |
| })(PS["Control.Monad.Trans.Class"] = PS["Control.Monad.Trans.Class"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| // | The `MonadPlus` type class has no members of its own but extends | |
| // | `MonadZero` with an additional law: | |
| // | | |
| // | - Distributivity: `(x <|> y) >>= f == (x >>= f) <|> (y >>= f)` | |
| var MonadPlus = function (MonadZero0) { | |
| this.MonadZero0 = MonadZero0; | |
| }; | |
| var monadPlusArray = new MonadPlus(function () { | |
| return Control_MonadZero.monadZeroArray; | |
| }); | |
| exports["MonadPlus"] = MonadPlus; | |
| exports["monadPlusArray"] = monadPlusArray; | |
| })(PS["Control.MonadPlus"] = PS["Control.MonadPlus"] || {}); | |
| (function(exports) { | |
| // | This module defines a generic non-empty data structure, which adds an | |
| // | additional element to any container type. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A non-empty container of elements of type a. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | nonEmptyList :: NonEmpty List Int | |
| // | nonEmptyList = 0 :| empty | |
| // | ``` | |
| var NonEmpty = (function () { | |
| function NonEmpty(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| NonEmpty.create = function (value0) { | |
| return function (value1) { | |
| return new NonEmpty(value0, value1); | |
| }; | |
| }; | |
| return NonEmpty; | |
| })(); | |
| // | Get everything but the 'first' element of a non-empty container. | |
| var tail = function (v) { | |
| return v.value1; | |
| }; | |
| // | Create a non-empty structure with a single value. | |
| var singleton = function (dictPlus) { | |
| return function (a) { | |
| return new NonEmpty(a, Control_Plus.empty(dictPlus)); | |
| }; | |
| }; | |
| var showNonEmpty = function (dictShow) { | |
| return function (dictShow1) { | |
| return new Data_Show.Show(function (v) { | |
| return "(NonEmpty " + (Data_Show.show(dictShow)(v.value0) + (" " + (Data_Show.show(dictShow1)(v.value1) + ")"))); | |
| }); | |
| }; | |
| }; | |
| var oneOf = function (dictAlternative) { | |
| return function (v) { | |
| return Control_Alt.alt((dictAlternative.Plus1()).Alt0())(Control_Applicative.pure(dictAlternative.Applicative0())(v.value0))(v.value1); | |
| }; | |
| }; | |
| // | Get the 'first' element of a non-empty container. | |
| var head = function (v) { | |
| return v.value0; | |
| }; | |
| var functorNonEmpty = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return new NonEmpty(f(v.value0), Data_Functor.map(dictFunctor)(f)(v.value1)); | |
| }; | |
| }); | |
| }; | |
| var fromNonEmpty = function (f) { | |
| return function (v) { | |
| return f(v.value0)(v.value1); | |
| }; | |
| }; | |
| // | Fold a non-empty structure, collecting results using a binary operation. | |
| var foldl1 = function (dictFoldable) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Foldable.foldl(dictFoldable)(f)(v.value0)(v.value1); | |
| }; | |
| }; | |
| }; | |
| var foldableNonEmpty = function (dictFoldable) { | |
| return new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(f(v.value0))(Data_Foldable.foldMap(dictFoldable)(dictMonoid)(f)(v.value1)); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (b) { | |
| return function (v) { | |
| return Data_Foldable.foldl(dictFoldable)(f)(f(b)(v.value0))(v.value1); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (b) { | |
| return function (v) { | |
| return f(v.value0)(Data_Foldable.foldr(dictFoldable)(f)(b)(v.value1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var traversableNonEmpty = function (dictTraversable) { | |
| return new Data_Traversable.Traversable(function () { | |
| return foldableNonEmpty(dictTraversable.Foldable1()); | |
| }, function () { | |
| return functorNonEmpty(dictTraversable.Functor0()); | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(NonEmpty.create)(v.value0))(Data_Traversable.sequence(dictTraversable)(dictApplicative)(v.value1)); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(NonEmpty.create)(f(v.value0)))(Data_Traversable.traverse(dictTraversable)(dictApplicative)(f)(v.value1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | Fold a non-empty structure, collecting results in a `Semigroup`. | |
| var foldMap1 = function (dictSemigroup) { | |
| return function (dictFoldable) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Foldable.foldl(dictFoldable)(function (s) { | |
| return function (a1) { | |
| return Data_Semigroup.append(dictSemigroup)(s)(f(a1)); | |
| }; | |
| })(f(v.value0))(v.value1); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Fold a non-empty structure. | |
| var fold1 = function (dictSemigroup) { | |
| return function (dictFoldable) { | |
| return foldMap1(dictSemigroup)(dictFoldable)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var eq1NonEmpty = function (dictEq1) { | |
| return new Data_Eq.Eq1(function (dictEq) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Eq.eq(dictEq)(v.value0)(v1.value0) && Data_Eq.eq1(dictEq1)(dictEq)(v.value1)(v1.value1); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var eqNonEmpty = function (dictEq1) { | |
| return function (dictEq) { | |
| return new Data_Eq.Eq(Data_Eq.eq1(eq1NonEmpty(dictEq1))(dictEq)); | |
| }; | |
| }; | |
| var ord1NonEmpty = function (dictOrd1) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1NonEmpty(dictOrd1.Eq10()); | |
| }, function (dictOrd) { | |
| return function (v) { | |
| return function (v1) { | |
| var v2 = Data_Ord.compare(dictOrd)(v.value0)(v1.value0); | |
| if (v2 instanceof Data_Ordering.EQ) { | |
| return Data_Ord.compare1(dictOrd1)(dictOrd)(v.value1)(v1.value1); | |
| }; | |
| return v2; | |
| }; | |
| }; | |
| }); | |
| }; | |
| var ordNonEmpty = function (dictOrd1) { | |
| return function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqNonEmpty(dictOrd1.Eq10())(dictOrd.Eq0()); | |
| }, Data_Ord.compare1(ord1NonEmpty(dictOrd1))(dictOrd)); | |
| }; | |
| }; | |
| exports["NonEmpty"] = NonEmpty; | |
| exports["fold1"] = fold1; | |
| exports["foldMap1"] = foldMap1; | |
| exports["foldl1"] = foldl1; | |
| exports["fromNonEmpty"] = fromNonEmpty; | |
| exports["head"] = head; | |
| exports["oneOf"] = oneOf; | |
| exports["singleton"] = singleton; | |
| exports["tail"] = tail; | |
| exports["showNonEmpty"] = showNonEmpty; | |
| exports["eqNonEmpty"] = eqNonEmpty; | |
| exports["eq1NonEmpty"] = eq1NonEmpty; | |
| exports["ordNonEmpty"] = ordNonEmpty; | |
| exports["ord1NonEmpty"] = ord1NonEmpty; | |
| exports["functorNonEmpty"] = functorNonEmpty; | |
| exports["foldableNonEmpty"] = foldableNonEmpty; | |
| exports["traversableNonEmpty"] = traversableNonEmpty; | |
| })(PS["Data.NonEmpty"] = PS["Data.NonEmpty"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; | |
| var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| var Act = function (x) { | |
| return x; | |
| }; | |
| // | `Foldable1` represents data structures with a minimum of one element that can be _folded_. | |
| // | | |
| // | - `fold1` folds a structure using a `Semigroup` instance | |
| // | - `foldMap1` folds a structure by accumulating values in a `Semigroup` | |
| // | | |
| // | Default implementations are provided by the following functions: | |
| // | | |
| // | - `fold1Default` | |
| // | - `foldMap1Default` | |
| // | | |
| // | Note: some combinations of the default implementations are unsafe to | |
| // | use together - causing a non-terminating mutually recursive cycle. | |
| // | These combinations are documented per function. | |
| var Foldable1 = function (Foldable0, fold1, foldMap1) { | |
| this.Foldable0 = Foldable0; | |
| this.fold1 = fold1; | |
| this.foldMap1 = foldMap1; | |
| }; | |
| var semigroupAct = function (dictApply) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Control_Apply.applySecond(dictApply)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var getAct = function (v) { | |
| return v; | |
| }; | |
| var foldMap1 = function (dict) { | |
| return dict.foldMap1; | |
| }; | |
| // | Traverse a data structure, performing some effects encoded by an | |
| // | `Apply` instance at each value, ignoring the final result. | |
| var traverse1_ = function (dictFoldable1) { | |
| return function (dictApply) { | |
| return function (f) { | |
| return function (t) { | |
| return Data_Functor.voidRight(dictApply.Functor0())(Data_Unit.unit)(getAct(foldMap1(dictFoldable1)(semigroupAct(dictApply))(function ($28) { | |
| return Act(f($28)); | |
| })(t))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | A version of `traverse1_` with its arguments flipped. | |
| // | | |
| // | This can be useful when running an action written using do notation | |
| // | for every element in a data structure: | |
| var for1_ = function (dictFoldable1) { | |
| return function (dictApply) { | |
| return Data_Function.flip(traverse1_(dictFoldable1)(dictApply)); | |
| }; | |
| }; | |
| // | Perform all of the effects in some data structure in the order | |
| // | given by the `Foldable1` instance, ignoring the final result. | |
| var sequence1_ = function (dictFoldable1) { | |
| return function (dictApply) { | |
| return traverse1_(dictFoldable1)(dictApply)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | A default implementation of `fold1` using `foldMap1`. | |
| var fold1Default = function (dictFoldable1) { | |
| return function (dictSemigroup) { | |
| return foldMap1(dictFoldable1)(dictSemigroup)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var foldableDual = new Foldable1(function () { | |
| return Data_Foldable.foldableDual; | |
| }, function (dictSemigroup) { | |
| return fold1Default(foldableDual)(dictSemigroup); | |
| }, function (dictSemigroup) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }); | |
| var foldableMultiplicative = new Foldable1(function () { | |
| return Data_Foldable.foldableMultiplicative; | |
| }, function (dictSemigroup) { | |
| return fold1Default(foldableMultiplicative)(dictSemigroup); | |
| }, function (dictSemigroup) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| }); | |
| var fold1 = function (dict) { | |
| return dict.fold1; | |
| }; | |
| // | A default implementation of `foldMap1` using `fold1`. | |
| var foldMap1Default = function (dictFoldable1) { | |
| return function (dictFunctor) { | |
| return function (dictSemigroup) { | |
| return function (f) { | |
| return function ($29) { | |
| return fold1(dictFoldable1)(dictSemigroup)(Data_Functor.map(dictFunctor)(f)($29)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Foldable1"] = Foldable1; | |
| exports["fold1"] = fold1; | |
| exports["fold1Default"] = fold1Default; | |
| exports["foldMap1"] = foldMap1; | |
| exports["foldMap1Default"] = foldMap1Default; | |
| exports["for1_"] = for1_; | |
| exports["sequence1_"] = sequence1_; | |
| exports["traverse1_"] = traverse1_; | |
| exports["foldableDual"] = foldableDual; | |
| exports["foldableMultiplicative"] = foldableMultiplicative; | |
| })(PS["Data.Semigroup.Foldable"] = PS["Data.Semigroup.Foldable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Semigroup_Foldable = PS["Data.Semigroup.Foldable"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | `Traversable1` represents data structures with a minimum of one element that can be _traversed_, | |
| // | accumulating results and effects in some `Applicative` functor. | |
| // | | |
| // | - `traverse1` runs an action for every element in a data structure, | |
| // | and accumulates the results. | |
| // | - `sequence1` runs the actions _contained_ in a data structure, | |
| // | and accumulates the results. | |
| // | | |
| // | The `traverse1` and `sequence1` functions should be compatible in the | |
| // | following sense: | |
| // | | |
| // | - `traverse1 f xs = sequence1 (f <$> xs)` | |
| // | - `sequence1 = traverse1 id` | |
| // | | |
| // | `Traversable1` instances should also be compatible with the corresponding | |
| // | `Foldable1` instances, in the following sense: | |
| // | | |
| // | - `foldMap1 f = runConst <<< traverse1 (Const <<< f)` | |
| // | | |
| // | Default implementations are provided by the following functions: | |
| // | | |
| // | - `traverse1Default` | |
| // | - `sequence1Default` | |
| var Traversable1 = function (Foldable10, Traversable1, sequence1, traverse1) { | |
| this.Foldable10 = Foldable10; | |
| this.Traversable1 = Traversable1; | |
| this.sequence1 = sequence1; | |
| this.traverse1 = traverse1; | |
| }; | |
| var traverse1 = function (dict) { | |
| return dict.traverse1; | |
| }; | |
| // | A default implementation of `sequence1` using `traverse1`. | |
| var sequence1Default = function (dictTraversable1) { | |
| return function (dictApply) { | |
| return traverse1(dictTraversable1)(dictApply)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var sequence1 = function (dict) { | |
| return dict.sequence1; | |
| }; | |
| // | A default implementation of `traverse1` using `sequence1`. | |
| var traverse1Default = function (dictTraversable1) { | |
| return function (dictApply) { | |
| return function (f) { | |
| return function (ta) { | |
| return sequence1(dictTraversable1)(dictApply)(Data_Functor.map((dictTraversable1.Traversable1()).Functor0())(f)(ta)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["Traversable1"] = Traversable1; | |
| exports["sequence1"] = sequence1; | |
| exports["sequence1Default"] = sequence1Default; | |
| exports["traverse1"] = traverse1; | |
| exports["traverse1Default"] = traverse1Default; | |
| })(PS["Data.Semigroup.Traversable"] = PS["Data.Semigroup.Traversable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Categorical dual of `Traversable`: | |
| // | | |
| // | - `distribute` is the dual of `sequence` - it zips an arbitrary collection | |
| // | of containers. | |
| // | - `collect` is the dual of `traverse` - it traverses an arbitrary | |
| // | collection of values. | |
| var Distributive = function (Functor0, collect, distribute) { | |
| this.Functor0 = Functor0; | |
| this.collect = collect; | |
| this.distribute = distribute; | |
| }; | |
| var distributiveIdentity = new Distributive(function () { | |
| return Data_Identity.functorIdentity; | |
| }, function (dictFunctor) { | |
| return function (f) { | |
| return function ($11) { | |
| return Data_Identity.Identity(Data_Functor.map(dictFunctor)(function ($12) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(f($12)); | |
| })($11)); | |
| }; | |
| }; | |
| }, function (dictFunctor) { | |
| return function ($13) { | |
| return Data_Identity.Identity(Data_Functor.map(dictFunctor)(Data_Newtype.unwrap(Data_Identity.newtypeIdentity))($13)); | |
| }; | |
| }); | |
| var distribute = function (dict) { | |
| return dict.distribute; | |
| }; | |
| var distributiveFunction = new Distributive(function () { | |
| return Data_Functor.functorFn; | |
| }, function (dictFunctor) { | |
| return function (f) { | |
| return function ($14) { | |
| return distribute(distributiveFunction)(dictFunctor)(Data_Functor.map(dictFunctor)(f)($14)); | |
| }; | |
| }; | |
| }, function (dictFunctor) { | |
| return function (a) { | |
| return function (e) { | |
| return Data_Functor.map(dictFunctor)(function (v) { | |
| return v(e); | |
| })(a); | |
| }; | |
| }; | |
| }); | |
| // | Zip an arbitrary collection of containers and summarize the results | |
| var cotraverse = function (dictDistributive) { | |
| return function (dictFunctor) { | |
| return function (f) { | |
| return function ($15) { | |
| return Data_Functor.map(dictDistributive.Functor0())(f)(distribute(dictDistributive)(dictFunctor)($15)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | A default implementation of `collect`, based on `distribute`. | |
| var collectDefault = function (dictDistributive) { | |
| return function (dictFunctor) { | |
| return function (f) { | |
| return function ($16) { | |
| return distribute(dictDistributive)(dictFunctor)(Data_Functor.map(dictFunctor)(f)($16)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var collect = function (dict) { | |
| return dict.collect; | |
| }; | |
| // | A default implementation of `distribute`, based on `collect`. | |
| var distributeDefault = function (dictDistributive) { | |
| return function (dictFunctor) { | |
| return collect(dictDistributive)(dictFunctor)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| exports["Distributive"] = Distributive; | |
| exports["collect"] = collect; | |
| exports["collectDefault"] = collectDefault; | |
| exports["cotraverse"] = cotraverse; | |
| exports["distribute"] = distribute; | |
| exports["distributeDefault"] = distributeDefault; | |
| exports["distributiveIdentity"] = distributiveIdentity; | |
| exports["distributiveFunction"] = distributiveFunction; | |
| })(PS["Data.Distributive"] = PS["Data.Distributive"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // | This type class asserts that types `a` and `b` | |
| // | are equal. | |
| // | | |
| // | The functional dependencies and the single | |
| // | instance below will force the two type arguments | |
| // | to unify when either one is known. | |
| // | | |
| // | Note: any instance will necessarily overlap with | |
| // | `refl` below, so instances of this class should | |
| // | not be defined in libraries. | |
| var TypeEquals = function (from, to) { | |
| this.from = from; | |
| this.to = to; | |
| }; | |
| var to = function (dict) { | |
| return dict.to; | |
| }; | |
| var refl = new TypeEquals(function (a) { | |
| return a; | |
| }, function (a) { | |
| return a; | |
| }); | |
| var from = function (dict) { | |
| return dict.from; | |
| }; | |
| exports["TypeEquals"] = TypeEquals; | |
| exports["from"] = from; | |
| exports["to"] = to; | |
| exports["refl"] = refl; | |
| })(PS["Type.Equality"] = PS["Type.Equality"] || {}); | |
| (function(exports) { | |
| // | A data type and functions for working with ordered pairs. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Biapplicative = PS["Control.Biapplicative"]; | |
| var Control_Biapply = PS["Control.Biapply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Bifoldable = PS["Data.Bifoldable"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Bitraversable = PS["Data.Bitraversable"]; | |
| var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_Distributive = PS["Data.Distributive"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Maybe_First = PS["Data.Maybe.First"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| var Type_Equality = PS["Type.Equality"]; | |
| // | A simple product type for wrapping a pair of component values. | |
| var Tuple = (function () { | |
| function Tuple(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Tuple.create = function (value0) { | |
| return function (value1) { | |
| return new Tuple(value0, value1); | |
| }; | |
| }; | |
| return Tuple; | |
| })(); | |
| // | Turn a function of two arguments into a function that expects a tuple. | |
| var uncurry = function (f) { | |
| return function (v) { | |
| return f(v.value0)(v.value1); | |
| }; | |
| }; | |
| // | Exchange the first and second components of a tuple. | |
| var swap = function (v) { | |
| return new Tuple(v.value1, v.value0); | |
| }; | |
| // | Returns the second component of a tuple. | |
| var snd = function (v) { | |
| return v.value1; | |
| }; | |
| // | Allows `Tuple`s to be rendered as a string with `show` whenever there are | |
| // | `Show` instances for both component types. | |
| var showTuple = function (dictShow) { | |
| return function (dictShow1) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Tuple " + (Data_Show.show(dictShow)(v.value0) + (" " + (Data_Show.show(dictShow1)(v.value1) + ")"))); | |
| }); | |
| }; | |
| }; | |
| var semiringTuple = function (dictSemiring) { | |
| return function (dictSemiring1) { | |
| return new Data_Semiring.Semiring(function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_Semiring.add(dictSemiring)(v.value0)(v1.value0), Data_Semiring.add(dictSemiring1)(v.value1)(v1.value1)); | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_Semiring.mul(dictSemiring)(v.value0)(v1.value0), Data_Semiring.mul(dictSemiring1)(v.value1)(v1.value1)); | |
| }; | |
| }, new Tuple(Data_Semiring.one(dictSemiring), Data_Semiring.one(dictSemiring1)), new Tuple(Data_Semiring.zero(dictSemiring), Data_Semiring.zero(dictSemiring1))); | |
| }; | |
| }; | |
| var semigroupoidTuple = new Control_Semigroupoid.Semigroupoid(function (v) { | |
| return function (v1) { | |
| return new Tuple(v1.value0, v.value1); | |
| }; | |
| }); | |
| // | The `Semigroup` instance enables use of the associative operator `<>` on | |
| // | `Tuple`s whenever there are `Semigroup` instances for the component | |
| // | types. The `<>` operator is applied pairwise, so: | |
| // | ```purescript | |
| // | (Tuple a1 b1) <> (Tuple a2 b2) = Tuple (a1 <> a2) (b1 <> b2) | |
| // | ``` | |
| var semigroupTuple = function (dictSemigroup) { | |
| return function (dictSemigroup1) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_Semigroup.append(dictSemigroup)(v.value0)(v1.value0), Data_Semigroup.append(dictSemigroup1)(v.value1)(v1.value1)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var ringTuple = function (dictRing) { | |
| return function (dictRing1) { | |
| return new Data_Ring.Ring(function () { | |
| return semiringTuple(dictRing.Semiring0())(dictRing1.Semiring0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_Ring.sub(dictRing)(v.value0)(v1.value0), Data_Ring.sub(dictRing1)(v.value1)(v1.value1)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monoidTuple = function (dictMonoid) { | |
| return function (dictMonoid1) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupTuple(dictMonoid.Semigroup0())(dictMonoid1.Semigroup0()); | |
| }, new Tuple(Data_Monoid.mempty(dictMonoid), Data_Monoid.mempty(dictMonoid1))); | |
| }; | |
| }; | |
| // | Lookup a value in a data structure of `Tuple`s, generalizing association lists. | |
| var lookup = function (dictFoldable) { | |
| return function (dictEq) { | |
| return function (a) { | |
| return function ($264) { | |
| return Data_Newtype.unwrap(Data_Maybe_First.newtypeFirst)(Data_Foldable.foldMap(dictFoldable)(Data_Maybe_First.monoidFirst)(function (v) { | |
| var $146 = Data_Eq.eq(dictEq)(a)(v.value0); | |
| if ($146) { | |
| return new Data_Maybe.Just(v.value1); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| })($264)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var heytingAlgebraTuple = function (dictHeytingAlgebra) { | |
| return function (dictHeytingAlgebra1) { | |
| return new Data_HeytingAlgebra.HeytingAlgebra(function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_HeytingAlgebra.conj(dictHeytingAlgebra)(v.value0)(v1.value0), Data_HeytingAlgebra.conj(dictHeytingAlgebra1)(v.value1)(v1.value1)); | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_HeytingAlgebra.disj(dictHeytingAlgebra)(v.value0)(v1.value0), Data_HeytingAlgebra.disj(dictHeytingAlgebra1)(v.value1)(v1.value1)); | |
| }; | |
| }, new Tuple(Data_HeytingAlgebra.ff(dictHeytingAlgebra), Data_HeytingAlgebra.ff(dictHeytingAlgebra1)), function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_HeytingAlgebra.implies(dictHeytingAlgebra)(v.value0)(v1.value0), Data_HeytingAlgebra.implies(dictHeytingAlgebra1)(v.value1)(v1.value1)); | |
| }; | |
| }, function (v) { | |
| return new Tuple(Data_HeytingAlgebra.not(dictHeytingAlgebra)(v.value0), Data_HeytingAlgebra.not(dictHeytingAlgebra1)(v.value1)); | |
| }, new Tuple(Data_HeytingAlgebra.tt(dictHeytingAlgebra), Data_HeytingAlgebra.tt(dictHeytingAlgebra1))); | |
| }; | |
| }; | |
| // | The `Functor` instance allows functions to transform the contents of a | |
| // | `Tuple` with the `<$>` operator, applying the function to the second | |
| // | component, so: | |
| // | ```purescript | |
| // | f <$> (Tuple x y) = Tuple x (f y) | |
| // | ```` | |
| var functorTuple = new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return new Tuple(v.value0, f(v.value1)); | |
| }; | |
| }); | |
| var invariantTuple = new Data_Functor_Invariant.Invariant(Data_Functor_Invariant.imapF(functorTuple)); | |
| // | Returns the first component of a tuple. | |
| var fst = function (v) { | |
| return v.value0; | |
| }; | |
| var lazyTuple = function (dictLazy) { | |
| return function (dictLazy1) { | |
| return new Control_Lazy.Lazy(function (f) { | |
| return new Tuple(Control_Lazy.defer(dictLazy)(function (v) { | |
| return fst(f(Data_Unit.unit)); | |
| }), Control_Lazy.defer(dictLazy1)(function (v) { | |
| return snd(f(Data_Unit.unit)); | |
| })); | |
| }); | |
| }; | |
| }; | |
| var foldableTuple = new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return f(v.value1); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(z)(v.value1); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v.value1)(z); | |
| }; | |
| }; | |
| }); | |
| var traversableTuple = new Data_Traversable.Traversable(function () { | |
| return foldableTuple; | |
| }, function () { | |
| return functorTuple; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Tuple.create(v.value0))(v.value1); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Tuple.create(v.value0))(f(v.value1)); | |
| }; | |
| }; | |
| }); | |
| var extendTuple = new Control_Extend.Extend(function () { | |
| return functorTuple; | |
| }, function (f) { | |
| return function (v) { | |
| return new Tuple(v.value0, f(v)); | |
| }; | |
| }); | |
| var eqTuple = function (dictEq) { | |
| return function (dictEq1) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(dictEq)(x.value0)(y.value0) && Data_Eq.eq(dictEq1)(x.value1)(y.value1); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var ordTuple = function (dictOrd) { | |
| return function (dictOrd1) { | |
| return new Data_Ord.Ord(function () { | |
| return eqTuple(dictOrd.Eq0())(dictOrd1.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| var v = Data_Ord.compare(dictOrd)(x.value0)(y.value0); | |
| if (v instanceof Data_Ordering.LT) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| return Data_Ord.compare(dictOrd1)(x.value1)(y.value1); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var eq1Tuple = function (dictEq) { | |
| return new Data_Eq.Eq1(function (dictEq1) { | |
| return Data_Eq.eq(eqTuple(dictEq)(dictEq1)); | |
| }); | |
| }; | |
| var ord1Tuple = function (dictOrd) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1Tuple(dictOrd.Eq0()); | |
| }, function (dictOrd1) { | |
| return Data_Ord.compare(ordTuple(dictOrd)(dictOrd1)); | |
| }); | |
| }; | |
| var distributiveTuple = function (dictTypeEquals) { | |
| return new Data_Distributive.Distributive(function () { | |
| return functorTuple; | |
| }, function (dictFunctor) { | |
| return Data_Distributive.collectDefault(distributiveTuple(dictTypeEquals))(dictFunctor); | |
| }, function (dictFunctor) { | |
| return function ($265) { | |
| return Tuple.create(Type_Equality.from(dictTypeEquals)(Data_Unit.unit))(Data_Functor.map(dictFunctor)(snd)($265)); | |
| }; | |
| }); | |
| }; | |
| // | Turn a function that expects a tuple into a function of two arguments. | |
| var curry = function (f) { | |
| return function (a) { | |
| return function (b) { | |
| return f(new Tuple(a, b)); | |
| }; | |
| }; | |
| }; | |
| var comonadTuple = new Control_Comonad.Comonad(function () { | |
| return extendTuple; | |
| }, snd); | |
| var commutativeRingTuple = function (dictCommutativeRing) { | |
| return function (dictCommutativeRing1) { | |
| return new Data_CommutativeRing.CommutativeRing(function () { | |
| return ringTuple(dictCommutativeRing.Ring0())(dictCommutativeRing1.Ring0()); | |
| }); | |
| }; | |
| }; | |
| var boundedTuple = function (dictBounded) { | |
| return function (dictBounded1) { | |
| return new Data_Bounded.Bounded(function () { | |
| return ordTuple(dictBounded.Ord0())(dictBounded1.Ord0()); | |
| }, new Tuple(Data_Bounded.bottom(dictBounded), Data_Bounded.bottom(dictBounded1)), new Tuple(Data_Bounded.top(dictBounded), Data_Bounded.top(dictBounded1))); | |
| }; | |
| }; | |
| var booleanAlgebraTuple = function (dictBooleanAlgebra) { | |
| return function (dictBooleanAlgebra1) { | |
| return new Data_BooleanAlgebra.BooleanAlgebra(function () { | |
| return heytingAlgebraTuple(dictBooleanAlgebra.HeytingAlgebra0())(dictBooleanAlgebra1.HeytingAlgebra0()); | |
| }); | |
| }; | |
| }; | |
| var bifunctorTuple = new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return new Tuple(f(v.value0), g(v.value1)); | |
| }; | |
| }; | |
| }); | |
| var bifoldableTuple = new Data_Bifoldable.Bifoldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(f(v.value0))(g(v.value1)); | |
| }; | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (g) { | |
| return function (z) { | |
| return function (v) { | |
| return g(f(z)(v.value0))(v.value1); | |
| }; | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (g) { | |
| return function (z) { | |
| return function (v) { | |
| return f(v.value0)(g(v.value1)(z)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| var bitraversableTuple = new Data_Bitraversable.Bitraversable(function () { | |
| return bifoldableTuple; | |
| }, function () { | |
| return bifunctorTuple; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Tuple.create)(v.value0))(v.value1); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Tuple.create)(f(v.value0)))(g(v.value1)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| var biapplyTuple = new Control_Biapply.Biapply(function () { | |
| return bifunctorTuple; | |
| }, function (v) { | |
| return function (v1) { | |
| return new Tuple(v.value0(v1.value0), v.value1(v1.value1)); | |
| }; | |
| }); | |
| var biapplicativeTuple = new Control_Biapplicative.Biapplicative(function () { | |
| return biapplyTuple; | |
| }, Tuple.create); | |
| // | The `Functor` instance allows functions to transform the contents of a | |
| // | `Tuple` with the `<*>` operator whenever there is a `Semigroup` instance | |
| // | for the `fst` component, so: | |
| // | ```purescript | |
| // | (Tuple a1 f) <*> (Tuple a2 x) == Tuple (a1 <> a2) (f x) | |
| // | ``` | |
| var applyTuple = function (dictSemigroup) { | |
| return new Control_Apply.Apply(function () { | |
| return functorTuple; | |
| }, function (v) { | |
| return function (v1) { | |
| return new Tuple(Data_Semigroup.append(dictSemigroup)(v.value0)(v1.value0), v.value1(v1.value1)); | |
| }; | |
| }); | |
| }; | |
| var bindTuple = function (dictSemigroup) { | |
| return new Control_Bind.Bind(function () { | |
| return applyTuple(dictSemigroup); | |
| }, function (v) { | |
| return function (f) { | |
| var v1 = f(v.value1); | |
| return new Tuple(Data_Semigroup.append(dictSemigroup)(v.value0)(v1.value0), v1.value1); | |
| }; | |
| }); | |
| }; | |
| var applicativeTuple = function (dictMonoid) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyTuple(dictMonoid.Semigroup0()); | |
| }, Tuple.create(Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| var monadTuple = function (dictMonoid) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeTuple(dictMonoid); | |
| }, function () { | |
| return bindTuple(dictMonoid.Semigroup0()); | |
| }); | |
| }; | |
| exports["Tuple"] = Tuple; | |
| exports["curry"] = curry; | |
| exports["fst"] = fst; | |
| exports["lookup"] = lookup; | |
| exports["snd"] = snd; | |
| exports["swap"] = swap; | |
| exports["uncurry"] = uncurry; | |
| exports["showTuple"] = showTuple; | |
| exports["eqTuple"] = eqTuple; | |
| exports["eq1Tuple"] = eq1Tuple; | |
| exports["ordTuple"] = ordTuple; | |
| exports["ord1Tuple"] = ord1Tuple; | |
| exports["boundedTuple"] = boundedTuple; | |
| exports["semigroupoidTuple"] = semigroupoidTuple; | |
| exports["semigroupTuple"] = semigroupTuple; | |
| exports["monoidTuple"] = monoidTuple; | |
| exports["semiringTuple"] = semiringTuple; | |
| exports["ringTuple"] = ringTuple; | |
| exports["commutativeRingTuple"] = commutativeRingTuple; | |
| exports["heytingAlgebraTuple"] = heytingAlgebraTuple; | |
| exports["booleanAlgebraTuple"] = booleanAlgebraTuple; | |
| exports["functorTuple"] = functorTuple; | |
| exports["invariantTuple"] = invariantTuple; | |
| exports["bifunctorTuple"] = bifunctorTuple; | |
| exports["applyTuple"] = applyTuple; | |
| exports["biapplyTuple"] = biapplyTuple; | |
| exports["applicativeTuple"] = applicativeTuple; | |
| exports["biapplicativeTuple"] = biapplicativeTuple; | |
| exports["bindTuple"] = bindTuple; | |
| exports["monadTuple"] = monadTuple; | |
| exports["extendTuple"] = extendTuple; | |
| exports["comonadTuple"] = comonadTuple; | |
| exports["lazyTuple"] = lazyTuple; | |
| exports["foldableTuple"] = foldableTuple; | |
| exports["bifoldableTuple"] = bifoldableTuple; | |
| exports["traversableTuple"] = traversableTuple; | |
| exports["bitraversableTuple"] = bitraversableTuple; | |
| exports["distributiveTuple"] = distributiveTuple; | |
| })(PS["Data.Tuple"] = PS["Data.Tuple"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.unfoldrArrayImpl = function (isNothing) { | |
| return function (fromJust) { | |
| return function (fst) { | |
| return function (snd) { | |
| return function (f) { | |
| return function (b) { | |
| var result = []; | |
| var value = b; | |
| while (true) { // eslint-disable-line no-constant-condition | |
| var maybe = f(value); | |
| if (isNothing(maybe)) return result; | |
| var tuple = fromJust(maybe); | |
| result.push(fst(tuple)); | |
| value = snd(tuple); | |
| } | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Unfoldable"] = PS["Data.Unfoldable"] || {}); | |
| (function(exports) { | |
| // | This module provides a type class for _unfoldable functors_, i.e. | |
| // | functors which support an `unfoldr` operation. | |
| // | | |
| // | This allows us to unify various operations on arrays, lists, | |
| // | sequences, etc. | |
| "use strict"; | |
| var $foreign = PS["Data.Unfoldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Partial_Unsafe = PS["Partial.Unsafe"]; | |
| var Prelude = PS["Prelude"]; | |
| // | This class identifies data structures which can be _unfolded_, | |
| // | generalizing `unfoldr` on arrays. | |
| // | | |
| // | The generating function `f` in `unfoldr f` in understood as follows: | |
| // | | |
| // | - If `f b` is `Nothing`, then `unfoldr f b` should be empty. | |
| // | - If `f b` is `Just (Tuple a b1)`, then `unfoldr f b` should consist of `a` | |
| // | appended to the result of `unfoldr f b1`. | |
| var Unfoldable = function (unfoldr) { | |
| this.unfoldr = unfoldr; | |
| }; | |
| var unfoldr = function (dict) { | |
| return dict.unfoldr; | |
| }; | |
| var unfoldableArray = new Unfoldable($foreign.unfoldrArrayImpl(Data_Maybe.isNothing)(Data_Maybe.fromJust())(Data_Tuple.fst)(Data_Tuple.snd)); | |
| // | Replicate a value some natural number of times. | |
| // | For example: | |
| // | | |
| // | ~~~ purescript | |
| // | replicate 2 "foo" == ["foo", "foo"] :: Array String | |
| // | ~~~ | |
| var replicate = function (dictUnfoldable) { | |
| return function (n) { | |
| return function (v) { | |
| var step = function (i) { | |
| var $8 = i <= 0; | |
| if ($8) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| return new Data_Maybe.Just(new Data_Tuple.Tuple(v, i - 1 | 0)); | |
| }; | |
| return unfoldr(dictUnfoldable)(step)(n); | |
| }; | |
| }; | |
| }; | |
| // | Perform an Applicative action `n` times, and accumulate all the results. | |
| var replicateA = function (dictApplicative) { | |
| return function (dictUnfoldable) { | |
| return function (dictTraversable) { | |
| return function (n) { | |
| return function (m) { | |
| return Data_Traversable.sequence(dictTraversable)(dictApplicative)(replicate(dictUnfoldable)(n)(m)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Contain a single value. | |
| // | For example: | |
| // | | |
| // | ~~~ purescript | |
| // | singleton "foo" == ["foo"] :: Array String | |
| // | ~~~ | |
| var singleton = function (dictUnfoldable) { | |
| return replicate(dictUnfoldable)(1); | |
| }; | |
| // | The container with no elements - unfolded with zero iterations. | |
| // | For example: | |
| // | | |
| // | ~~~ purescript | |
| // | none == [] :: forall a. Array a | |
| // | ~~~ | |
| var none = function (dictUnfoldable) { | |
| return unfoldr(dictUnfoldable)(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Unit.unit); | |
| }; | |
| // | Convert a Maybe to any Unfoldable like lists and arrays. | |
| var fromMaybe = function (dictUnfoldable) { | |
| return unfoldr(dictUnfoldable)(function (b) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(Data_Function.flip(Data_Tuple.Tuple.create)(Data_Maybe.Nothing.value))(b); | |
| }); | |
| }; | |
| exports["Unfoldable"] = Unfoldable; | |
| exports["fromMaybe"] = fromMaybe; | |
| exports["none"] = none; | |
| exports["replicate"] = replicate; | |
| exports["replicateA"] = replicateA; | |
| exports["singleton"] = singleton; | |
| exports["unfoldr"] = unfoldr; | |
| exports["unfoldableArray"] = unfoldableArray; | |
| })(PS["Data.Unfoldable"] = PS["Data.Unfoldable"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_NonEmpty = PS["Data.NonEmpty"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semigroup_Foldable = PS["Data.Semigroup.Foldable"]; | |
| var Data_Semigroup_Traversable = PS["Data.Semigroup.Traversable"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unfoldable = PS["Data.Unfoldable"]; | |
| var Prelude = PS["Prelude"]; | |
| var Nil = (function () { | |
| function Nil() { | |
| }; | |
| Nil.value = new Nil(); | |
| return Nil; | |
| })(); | |
| var Cons = (function () { | |
| function Cons(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Cons.create = function (value0) { | |
| return function (value1) { | |
| return new Cons(value0, value1); | |
| }; | |
| }; | |
| return Cons; | |
| })(); | |
| var NonEmptyList = function (x) { | |
| return x; | |
| }; | |
| var toList = function (v) { | |
| return new Cons(v.value0, v.value1); | |
| }; | |
| var newtypeNonEmptyList = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, NonEmptyList); | |
| var nelCons = function (a) { | |
| return function (v) { | |
| return new Data_NonEmpty.NonEmpty(a, new Cons(v.value0, v.value1)); | |
| }; | |
| }; | |
| var foldableList = new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return Data_Foldable.foldl(foldableList)(function (acc) { | |
| return function ($143) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f($143)); | |
| }; | |
| })(Data_Monoid.mempty(dictMonoid)); | |
| }; | |
| }, function (f) { | |
| var go = function ($copy_b) { | |
| return function ($copy_v) { | |
| var $tco_var_b = $copy_b; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(b, v) { | |
| if (v instanceof Nil) { | |
| $tco_done = true; | |
| return b; | |
| }; | |
| if (v instanceof Cons) { | |
| $tco_var_b = f(b)(v.value0); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 78, column 12 - line 80, column 30: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_b, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go; | |
| }, function (f) { | |
| return function (b) { | |
| var rev = function ($copy_acc) { | |
| return function ($copy_v) { | |
| var $tco_var_acc = $copy_acc; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(acc, v) { | |
| if (v instanceof Nil) { | |
| $tco_done = true; | |
| return acc; | |
| }; | |
| if (v instanceof Cons) { | |
| $tco_var_acc = new Cons(v.value0, acc); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 73, column 15 - line 75, column 33: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_acc, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return function ($144) { | |
| return Data_Foldable.foldl(foldableList)(Data_Function.flip(f))(b)(rev(Nil.value)($144)); | |
| }; | |
| }; | |
| }); | |
| var foldableNonEmptyList = Data_NonEmpty.foldableNonEmpty(foldableList); | |
| var functorList = new Data_Functor.Functor(function (f) { | |
| return Data_Foldable.foldr(foldableList)(function (x) { | |
| return function (acc) { | |
| return new Cons(f(x), acc); | |
| }; | |
| })(Nil.value); | |
| }); | |
| var functorNonEmptyList = Data_NonEmpty.functorNonEmpty(functorList); | |
| var semigroupList = new Data_Semigroup.Semigroup(function (xs) { | |
| return function (ys) { | |
| return Data_Foldable.foldr(foldableList)(Cons.create)(ys)(xs); | |
| }; | |
| }); | |
| var monoidList = new Data_Monoid.Monoid(function () { | |
| return semigroupList; | |
| }, Nil.value); | |
| var semigroupNonEmptyList = new Data_Semigroup.Semigroup(function (v) { | |
| return function (as$prime) { | |
| return new Data_NonEmpty.NonEmpty(v.value0, Data_Semigroup.append(semigroupList)(v.value1)(toList(as$prime))); | |
| }; | |
| }); | |
| var showList = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| if (v instanceof Nil) { | |
| return "Nil"; | |
| }; | |
| return "(" + (Data_Foldable.intercalate(foldableList)(Data_Monoid.monoidString)(" : ")(Data_Functor.map(functorList)(Data_Show.show(dictShow))(v)) + " : Nil)"); | |
| }); | |
| }; | |
| var showNonEmptyList = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(NonEmptyList " + (Data_Show.show(Data_NonEmpty.showNonEmpty(dictShow)(showList(dictShow)))(v) + ")"); | |
| }); | |
| }; | |
| var traversableList = new Data_Traversable.Traversable(function () { | |
| return foldableList; | |
| }, function () { | |
| return functorList; | |
| }, function (dictApplicative) { | |
| return Data_Traversable.traverse(traversableList)(dictApplicative)(Control_Category.id(Control_Category.categoryFn)); | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function ($145) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Foldable.foldl(foldableList)(Data_Function.flip(Cons.create))(Nil.value))(Data_Foldable.foldl(foldableList)(function (acc) { | |
| return function ($146) { | |
| return Control_Apply.lift2(dictApplicative.Apply0())(Data_Function.flip(Cons.create))(acc)(f($146)); | |
| }; | |
| })(Control_Applicative.pure(dictApplicative)(Nil.value))($145)); | |
| }; | |
| }; | |
| }); | |
| var traversableNonEmptyList = Data_NonEmpty.traversableNonEmpty(traversableList); | |
| var unfoldableList = new Data_Unfoldable.Unfoldable(function (f) { | |
| return function (b) { | |
| var go = function ($copy_source) { | |
| return function ($copy_memo) { | |
| var $tco_var_source = $copy_source; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(source, memo) { | |
| var v = f(source); | |
| if (v instanceof Data_Maybe.Nothing) { | |
| $tco_done = true; | |
| return Data_Foldable.foldl(foldableList)(Data_Function.flip(Cons.create))(Nil.value)(memo); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| $tco_var_source = v.value0.value1; | |
| $copy_memo = new Cons(v.value0.value0, memo); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 86, column 22 - line 88, column 52: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_source, $copy_memo); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(b)(Nil.value); | |
| }; | |
| }); | |
| var foldable1NonEmptyList = new Data_Semigroup_Foldable.Foldable1(function () { | |
| return foldableNonEmptyList; | |
| }, function (dictSemigroup) { | |
| return function (v) { | |
| return Data_Foldable.foldl(foldableList)(Data_Semigroup.append(dictSemigroup))(v.value0)(v.value1); | |
| }; | |
| }, function (dictSemigroup) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Foldable.foldl(foldableList)(function (acc) { | |
| return function ($147) { | |
| return Data_Semigroup.append(dictSemigroup)(acc)(f($147)); | |
| }; | |
| })(f(v.value0))(v.value1); | |
| }; | |
| }; | |
| }); | |
| var extendNonEmptyList = new Control_Extend.Extend(function () { | |
| return functorNonEmptyList; | |
| }, function (f) { | |
| return function (v) { | |
| var go = function (a) { | |
| return function (v1) { | |
| return { | |
| val: new Cons(f(new Data_NonEmpty.NonEmpty(a, v1.acc)), v1.val), | |
| acc: new Cons(a, v1.acc) | |
| }; | |
| }; | |
| }; | |
| return new Data_NonEmpty.NonEmpty(f(v), (Data_Foldable.foldr(foldableList)(go)({ | |
| val: Nil.value, | |
| acc: Nil.value | |
| })(v.value1)).val); | |
| }; | |
| }); | |
| var extendList = new Control_Extend.Extend(function () { | |
| return functorList; | |
| }, function (f) { | |
| return function (v) { | |
| if (v instanceof Nil) { | |
| return Nil.value; | |
| }; | |
| if (v instanceof Cons) { | |
| var go = function (a$prime) { | |
| return function (v1) { | |
| var acc$prime = new Cons(a$prime, v1.acc); | |
| return { | |
| val: new Cons(f(acc$prime), v1.val), | |
| acc: acc$prime | |
| }; | |
| }; | |
| }; | |
| return new Cons(f(v), (Data_Foldable.foldr(foldableList)(go)({ | |
| val: Nil.value, | |
| acc: Nil.value | |
| })(v.value1)).val); | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 119, column 1 - line 119, column 35: " + [ f.constructor.name, v.constructor.name ]); | |
| }; | |
| }); | |
| var eq1List = new Data_Eq.Eq1(function (dictEq) { | |
| return function (xs) { | |
| return function (ys) { | |
| var go = function ($copy_v) { | |
| return function ($copy_v1) { | |
| return function ($copy_v2) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_var_v1 = $copy_v1; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1, v2) { | |
| if (!v2) { | |
| $tco_done = true; | |
| return false; | |
| }; | |
| if (v instanceof Nil && v1 instanceof Nil) { | |
| $tco_done = true; | |
| return v2; | |
| }; | |
| if (v instanceof Cons && v1 instanceof Cons) { | |
| $tco_var_v = v.value1; | |
| $tco_var_v1 = v1.value1; | |
| $copy_v2 = v2 && Data_Eq.eq(dictEq)(v1.value0)(v.value0); | |
| return; | |
| }; | |
| $tco_done = true; | |
| return false; | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $tco_var_v1, $copy_v2); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| return go(xs)(ys)(true); | |
| }; | |
| }; | |
| }); | |
| var eqList = function (dictEq) { | |
| return new Data_Eq.Eq(Data_Eq.eq1(eq1List)(dictEq)); | |
| }; | |
| var eqNonEmptyList = function (dictEq) { | |
| return Data_NonEmpty.eqNonEmpty(eq1List)(dictEq); | |
| }; | |
| var ord1List = new Data_Ord.Ord1(function () { | |
| return eq1List; | |
| }, function (dictOrd) { | |
| return function (xs) { | |
| return function (ys) { | |
| var go = function ($copy_v) { | |
| return function ($copy_v1) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1) { | |
| if (v instanceof Nil && v1 instanceof Nil) { | |
| $tco_done = true; | |
| return Data_Ordering.EQ.value; | |
| }; | |
| if (v instanceof Nil) { | |
| $tco_done = true; | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof Nil) { | |
| $tco_done = true; | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof Cons && v1 instanceof Cons) { | |
| var v2 = Data_Ord.compare(dictOrd)(v.value0)(v1.value0); | |
| if (v2 instanceof Data_Ordering.EQ) { | |
| $tco_var_v = v.value1; | |
| $copy_v1 = v1.value1; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return v2; | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 53, column 5 - line 53, column 20: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $copy_v1); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(xs)(ys); | |
| }; | |
| }; | |
| }); | |
| var ordList = function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqList(dictOrd.Eq0()); | |
| }, Data_Ord.compare1(ord1List)(dictOrd)); | |
| }; | |
| var ordNonEmptyList = function (dictOrd) { | |
| return Data_NonEmpty.ordNonEmpty(ord1List)(dictOrd); | |
| }; | |
| var comonadNonEmptyList = new Control_Comonad.Comonad(function () { | |
| return extendNonEmptyList; | |
| }, function (v) { | |
| return v.value0; | |
| }); | |
| var applyList = new Control_Apply.Apply(function () { | |
| return functorList; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Nil) { | |
| return Nil.value; | |
| }; | |
| if (v instanceof Cons) { | |
| return Data_Semigroup.append(semigroupList)(Data_Functor.map(functorList)(v.value0)(v1))(Control_Apply.apply(applyList)(v.value1)(v1)); | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 94, column 1 - line 94, column 33: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var applyNonEmptyList = new Control_Apply.Apply(function () { | |
| return functorNonEmptyList; | |
| }, function (v) { | |
| return function (v1) { | |
| return new Data_NonEmpty.NonEmpty(v.value0(v1.value0), Data_Semigroup.append(semigroupList)(Control_Apply.apply(applyList)(v.value1)(new Cons(v1.value0, Nil.value)))(Control_Apply.apply(applyList)(new Cons(v.value0, v.value1))(v1.value1))); | |
| }; | |
| }); | |
| var bindList = new Control_Bind.Bind(function () { | |
| return applyList; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Nil) { | |
| return Nil.value; | |
| }; | |
| if (v instanceof Cons) { | |
| return Data_Semigroup.append(semigroupList)(v1(v.value0))(Control_Bind.bind(bindList)(v.value1)(v1)); | |
| }; | |
| throw new Error("Failed pattern match at Data.List.Types line 101, column 1 - line 101, column 31: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var bindNonEmptyList = new Control_Bind.Bind(function () { | |
| return applyNonEmptyList; | |
| }, function (v) { | |
| return function (f) { | |
| var v1 = f(v.value0); | |
| return new Data_NonEmpty.NonEmpty(v1.value0, Data_Semigroup.append(semigroupList)(v1.value1)(Control_Bind.bind(bindList)(v.value1)(function ($148) { | |
| return toList(f($148)); | |
| }))); | |
| }; | |
| }); | |
| var applicativeList = new Control_Applicative.Applicative(function () { | |
| return applyList; | |
| }, function (a) { | |
| return new Cons(a, Nil.value); | |
| }); | |
| var monadList = new Control_Monad.Monad(function () { | |
| return applicativeList; | |
| }, function () { | |
| return bindList; | |
| }); | |
| var altNonEmptyList = new Control_Alt.Alt(function () { | |
| return functorNonEmptyList; | |
| }, Data_Semigroup.append(semigroupNonEmptyList)); | |
| var altList = new Control_Alt.Alt(function () { | |
| return functorList; | |
| }, Data_Semigroup.append(semigroupList)); | |
| var plusList = new Control_Plus.Plus(function () { | |
| return altList; | |
| }, Nil.value); | |
| var alternativeList = new Control_Alternative.Alternative(function () { | |
| return applicativeList; | |
| }, function () { | |
| return plusList; | |
| }); | |
| var monadZeroList = new Control_MonadZero.MonadZero(function () { | |
| return alternativeList; | |
| }, function () { | |
| return monadList; | |
| }); | |
| var monadPlusList = new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroList; | |
| }); | |
| var applicativeNonEmptyList = new Control_Applicative.Applicative(function () { | |
| return applyNonEmptyList; | |
| }, function ($149) { | |
| return NonEmptyList(Data_NonEmpty.singleton(plusList)($149)); | |
| }); | |
| var monadNonEmptyList = new Control_Monad.Monad(function () { | |
| return applicativeNonEmptyList; | |
| }, function () { | |
| return bindNonEmptyList; | |
| }); | |
| var traversable1NonEmptyList = new Data_Semigroup_Traversable.Traversable1(function () { | |
| return foldable1NonEmptyList; | |
| }, function () { | |
| return traversableNonEmptyList; | |
| }, function (dictApply) { | |
| return Data_Semigroup_Traversable.traverse1(traversable1NonEmptyList)(dictApply)(Control_Category.id(Control_Category.categoryFn)); | |
| }, function (dictApply) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.mapFlipped(dictApply.Functor0())(Data_Foldable.foldl(foldableList)(function (acc) { | |
| return function ($150) { | |
| return Control_Apply.lift2(dictApply)(Data_Function.flip(nelCons))(acc)(f($150)); | |
| }; | |
| })(Data_Functor.map(dictApply.Functor0())(Control_Applicative.pure(applicativeNonEmptyList))(f(v.value0)))(v.value1))(function (v1) { | |
| return Data_Foldable.foldl(foldableList)(Data_Function.flip(nelCons))(Control_Applicative.pure(applicativeNonEmptyList)(v1.value0))(v1.value1); | |
| }); | |
| }; | |
| }; | |
| }); | |
| exports["Nil"] = Nil; | |
| exports["Cons"] = Cons; | |
| exports["NonEmptyList"] = NonEmptyList; | |
| exports["nelCons"] = nelCons; | |
| exports["toList"] = toList; | |
| exports["showList"] = showList; | |
| exports["eqList"] = eqList; | |
| exports["eq1List"] = eq1List; | |
| exports["ordList"] = ordList; | |
| exports["ord1List"] = ord1List; | |
| exports["semigroupList"] = semigroupList; | |
| exports["monoidList"] = monoidList; | |
| exports["functorList"] = functorList; | |
| exports["foldableList"] = foldableList; | |
| exports["unfoldableList"] = unfoldableList; | |
| exports["traversableList"] = traversableList; | |
| exports["applyList"] = applyList; | |
| exports["applicativeList"] = applicativeList; | |
| exports["bindList"] = bindList; | |
| exports["monadList"] = monadList; | |
| exports["altList"] = altList; | |
| exports["plusList"] = plusList; | |
| exports["alternativeList"] = alternativeList; | |
| exports["monadZeroList"] = monadZeroList; | |
| exports["monadPlusList"] = monadPlusList; | |
| exports["extendList"] = extendList; | |
| exports["newtypeNonEmptyList"] = newtypeNonEmptyList; | |
| exports["eqNonEmptyList"] = eqNonEmptyList; | |
| exports["ordNonEmptyList"] = ordNonEmptyList; | |
| exports["showNonEmptyList"] = showNonEmptyList; | |
| exports["functorNonEmptyList"] = functorNonEmptyList; | |
| exports["applyNonEmptyList"] = applyNonEmptyList; | |
| exports["applicativeNonEmptyList"] = applicativeNonEmptyList; | |
| exports["bindNonEmptyList"] = bindNonEmptyList; | |
| exports["monadNonEmptyList"] = monadNonEmptyList; | |
| exports["altNonEmptyList"] = altNonEmptyList; | |
| exports["extendNonEmptyList"] = extendNonEmptyList; | |
| exports["comonadNonEmptyList"] = comonadNonEmptyList; | |
| exports["semigroupNonEmptyList"] = semigroupNonEmptyList; | |
| exports["foldableNonEmptyList"] = foldableNonEmptyList; | |
| exports["traversableNonEmptyList"] = traversableNonEmptyList; | |
| exports["foldable1NonEmptyList"] = foldable1NonEmptyList; | |
| exports["traversable1NonEmptyList"] = traversable1NonEmptyList; | |
| })(PS["Data.List.Types"] = PS["Data.List.Types"] || {}); | |
| (function(exports) { | |
| // | This module defines a type of _strict_ linked lists, and associated helper | |
| // | functions and type class instances. | |
| // | | |
| // | _Note_: Depending on your use-case, you may prefer to use | |
| // | `Data.Sequence` instead, which might give better performance for certain | |
| // | use cases. This module is an improvement over `Data.Array` when working with | |
| // | immutable lists of data in a purely-functional setting, but does not have | |
| // | good random-access performance. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Boolean = PS["Data.Boolean"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_List_Types = PS["Data.List.Types"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_NonEmpty = PS["Data.NonEmpty"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unfoldable = PS["Data.Unfoldable"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| //------------------------------------------------------------------------------ | |
| // Sublists -------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | A newtype used in cases where there is a list to be matched. | |
| var Pattern = function (x) { | |
| return x; | |
| }; | |
| // | Update the element at the specified index, returning a new | |
| // | list or `Nothing` if the index is out-of-bounds. | |
| // | | |
| // | Running time: `O(n)` | |
| var updateAt = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v === 0 && v2 instanceof Data_List_Types.Cons) { | |
| return new Data_Maybe.Just(new Data_List_Types.Cons(v1, v2.value1)); | |
| }; | |
| if (v2 instanceof Data_List_Types.Cons) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (v3) { | |
| return new Data_List_Types.Cons(v2.value0, v3); | |
| })(updateAt(v - 1 | 0)(v1)(v2.value1)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| }; | |
| // | Transforms a list of pairs into a list of first components and a list of | |
| // | second components. | |
| var unzip = Data_Foldable.foldr(Data_List_Types.foldableList)(function (v) { | |
| return function (v1) { | |
| return new Data_Tuple.Tuple(new Data_List_Types.Cons(v.value0, v1.value0), new Data_List_Types.Cons(v.value1, v1.value1)); | |
| }; | |
| })(new Data_Tuple.Tuple(Data_List_Types.Nil.value, Data_List_Types.Nil.value)); | |
| // | Break a list into its first element, and the remaining elements, | |
| // | or `Nothing` if the list is empty. | |
| // | | |
| // | Running time: `O(1)` | |
| var uncons = function (v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| return new Data_Maybe.Just({ | |
| head: v.value0, | |
| tail: v.value1 | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 256, column 1 - line 256, column 66: " + [ v.constructor.name ]); | |
| }; | |
| // | Convert a list into any unfoldable structure. | |
| // | | |
| // | Running time: `O(n)` | |
| var toUnfoldable = function (dictUnfoldable) { | |
| return Data_Unfoldable.unfoldr(dictUnfoldable)(function (xs) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (rec) { | |
| return new Data_Tuple.Tuple(rec.head, rec.tail); | |
| })(uncons(xs)); | |
| }); | |
| }; | |
| // | Get all but the first element of a list, or `Nothing` if the list is empty. | |
| // | | |
| // | Running time: `O(1)` | |
| var tail = function (v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| return new Data_Maybe.Just(v.value1); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 242, column 1 - line 242, column 43: " + [ v.constructor.name ]); | |
| }; | |
| // | If the list starts with the given prefix, return the portion of the | |
| // | list left after removing it, as a Just value. Otherwise, return Nothing. | |
| // | * `stripPrefix (Pattern (1:Nil)) (1:2:Nil) == Just (2:Nil)` | |
| // | * `stripPrefix (Pattern Nil) (1:Nil) == Just (1:Nil)` | |
| // | * `stripPrefix (Pattern (2:Nil)) (1:Nil) == Nothing` | |
| // | | |
| // | Running time: `O(n)` where `n` is the number of elements to strip. | |
| var stripPrefix = function (dictEq) { | |
| return function (v) { | |
| return function (s) { | |
| var go = function (prefix) { | |
| return function (input) { | |
| if (prefix instanceof Data_List_Types.Cons && (input instanceof Data_List_Types.Cons && Data_Eq.eq(dictEq)(prefix.value0)(input.value0))) { | |
| return Data_Maybe.Just.create(new Control_Monad_Rec_Class.Loop({ | |
| a: prefix.value1, | |
| b: input.value1 | |
| })); | |
| }; | |
| if (prefix instanceof Data_List_Types.Nil) { | |
| return Data_Maybe.Just.create(new Control_Monad_Rec_Class.Done(input)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM2(Control_Monad_Rec_Class.monadRecMaybe)(go)(v)(s); | |
| }; | |
| }; | |
| }; | |
| // | Split a list into two parts: | |
| // | | |
| // | 1. the longest initial segment for which all elements satisfy the specified predicate | |
| // | 2. the remaining elements | |
| // | | |
| // | For example, | |
| // | | |
| // | ```purescript | |
| // | span (\n -> n % 2 == 1) (1 : 3 : 2 : 4 : 5 : Nil) == { init: (1 : 3 : Nil), rest: (2 : 4 : 5 : Nil) } | |
| // | ``` | |
| // | | |
| // | Running time: `O(n)` | |
| var span = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_List_Types.Cons && v(v1.value0)) { | |
| var v2 = span(v)(v1.value1); | |
| return { | |
| init: new Data_List_Types.Cons(v1.value0, v2.init), | |
| rest: v2.rest | |
| }; | |
| }; | |
| return { | |
| init: Data_List_Types.Nil.value, | |
| rest: v1 | |
| }; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Extending lists ------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Append an element to the end of a list, creating a new list. | |
| // | | |
| // | Running time: `O(n)` | |
| var snoc = function (xs) { | |
| return function (x) { | |
| return Data_Foldable.foldr(Data_List_Types.foldableList)(Data_List_Types.Cons.create)(new Data_List_Types.Cons(x, Data_List_Types.Nil.value))(xs); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // List creation --------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Create a list with a single element. | |
| // | | |
| // | Running time: `O(1)` | |
| var singleton = function (a) { | |
| return new Data_List_Types.Cons(a, Data_List_Types.Nil.value); | |
| }; | |
| // | Sort the elements of a list in increasing order, where elements are | |
| // | compared using the specified ordering. | |
| var sortBy = function (cmp) { | |
| var merge = function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_List_Types.Cons && v1 instanceof Data_List_Types.Cons) { | |
| if (Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(v.value0)(v1.value0))(Data_Ordering.GT.value)) { | |
| return new Data_List_Types.Cons(v1.value0, merge(v)(v1.value1)); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| return new Data_List_Types.Cons(v.value0, merge(v.value1)(v1)); | |
| }; | |
| }; | |
| if (v instanceof Data_List_Types.Nil) { | |
| return v1; | |
| }; | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return v; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 471, column 3 - line 471, column 38: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| var mergePairs = function (v) { | |
| if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Cons) { | |
| return new Data_List_Types.Cons(merge(v.value0)(v.value1.value0), mergePairs(v.value1.value1)); | |
| }; | |
| return v; | |
| }; | |
| var mergeAll = function ($copy_v) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return v.value0; | |
| }; | |
| $copy_v = mergePairs(v); | |
| return; | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| var sequences = function (v) { | |
| if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Cons) { | |
| if (Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(v.value0)(v.value1.value0))(Data_Ordering.GT.value)) { | |
| return descending(v.value1.value0)(singleton(v.value0))(v.value1.value1); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| return ascending(v.value1.value0)(function (v1) { | |
| return new Data_List_Types.Cons(v.value0, v1); | |
| })(v.value1.value1); | |
| }; | |
| }; | |
| return singleton(v); | |
| }; | |
| var descending = function ($copy_a) { | |
| return function ($copy_as) { | |
| return function ($copy_v) { | |
| var $tco_var_a = $copy_a; | |
| var $tco_var_as = $copy_as; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(a, as, v) { | |
| if (v instanceof Data_List_Types.Cons && Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(a)(v.value0))(Data_Ordering.GT.value)) { | |
| $tco_var_a = v.value0; | |
| $tco_var_as = new Data_List_Types.Cons(a, as); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return new Data_List_Types.Cons(new Data_List_Types.Cons(a, as), sequences(v)); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_a, $tco_var_as, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| var ascending = function ($copy_a) { | |
| return function ($copy_as) { | |
| return function ($copy_v) { | |
| var $tco_var_a = $copy_a; | |
| var $tco_var_as = $copy_as; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(a, as, v) { | |
| if (v instanceof Data_List_Types.Cons && Data_Eq.notEq(Data_Ordering.eqOrdering)(cmp(a)(v.value0))(Data_Ordering.GT.value)) { | |
| $tco_var_a = v.value0; | |
| $tco_var_as = function (ys) { | |
| return as(new Data_List_Types.Cons(a, ys)); | |
| }; | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return new Data_List_Types.Cons(as(singleton(a)), sequences(v)); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_a, $tco_var_as, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| return function ($340) { | |
| return mergeAll(sequences($340)); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Sorting --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Sort the elements of an list in increasing order. | |
| var sort = function (dictOrd) { | |
| return function (xs) { | |
| return sortBy(Data_Ord.compare(dictOrd))(xs); | |
| }; | |
| }; | |
| var showPattern = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Pattern " + (Data_Show.show(Data_List_Types.showList(dictShow))(v) + ")"); | |
| }); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Transformations ------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Reverse a list. | |
| // | | |
| // | Running time: `O(n)` | |
| var reverse = (function () { | |
| var go = function ($copy_acc) { | |
| return function ($copy_v) { | |
| var $tco_var_acc = $copy_acc; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(acc, v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return acc; | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| $tco_var_acc = new Data_List_Types.Cons(v.value0, acc); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 365, column 3 - line 365, column 19: " + [ acc.constructor.name, v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_acc, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(Data_List_Types.Nil.value); | |
| })(); | |
| // | Take the specified number of elements from the front of a list. | |
| // | | |
| // | Running time: `O(n)` where `n` is the number of elements to take. | |
| var take = (function () { | |
| var go = function ($copy_acc) { | |
| return function ($copy_v) { | |
| return function ($copy_v1) { | |
| var $tco_var_acc = $copy_acc; | |
| var $tco_var_v = $copy_v; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(acc, v, v1) { | |
| if (v === 0) { | |
| $tco_done = true; | |
| return reverse(acc); | |
| }; | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return reverse(acc); | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| $tco_var_acc = new Data_List_Types.Cons(v1.value0, acc); | |
| $tco_var_v = v - 1 | 0; | |
| $copy_v1 = v1.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 518, column 3 - line 518, column 27: " + [ acc.constructor.name, v.constructor.name, v1.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_acc, $tco_var_v, $copy_v1); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| return go(Data_List_Types.Nil.value); | |
| })(); | |
| // | Take those elements from the front of a list which match a predicate. | |
| // | | |
| // | Running time (worst case): `O(n)` | |
| var takeWhile = function (p) { | |
| var go = function ($copy_acc) { | |
| return function ($copy_v) { | |
| var $tco_var_acc = $copy_acc; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(acc, v) { | |
| if (v instanceof Data_List_Types.Cons && p(v.value0)) { | |
| $tco_var_acc = new Data_List_Types.Cons(v.value0, acc); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return reverse(acc); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_acc, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(Data_List_Types.Nil.value); | |
| }; | |
| // | Break a list into its last element, and the preceding elements, | |
| // | or `Nothing` if the list is empty. | |
| // | | |
| // | Running time: `O(n)` | |
| var unsnoc = function (lst) { | |
| var go = function ($copy_v) { | |
| return function ($copy_acc) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, acc) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return new Data_Maybe.Just({ | |
| revInit: acc, | |
| last: v.value0 | |
| }); | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| $tco_var_v = v.value1; | |
| $copy_acc = new Data_List_Types.Cons(v.value0, acc); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 267, column 3 - line 267, column 23: " + [ v.constructor.name, acc.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $copy_acc); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (h) { | |
| return { | |
| init: reverse(h.revInit), | |
| last: h.last | |
| }; | |
| })(go(lst)(Data_List_Types.Nil.value)); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Zipping --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Apply a function to pairs of elements at the same positions in two lists, | |
| // | collecting the results in a new list. | |
| // | | |
| // | If one list is longer, elements will be discarded from the longer list. | |
| // | | |
| // | For example | |
| // | | |
| // | ```purescript | |
| // | zipWith (*) (1 : 2 : 3 : Nil) (4 : 5 : 6 : 7 Nil) == 4 : 10 : 18 : Nil | |
| // | ``` | |
| // | | |
| // | Running time: `O(min(m, n))` | |
| var zipWith = function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| var go = function ($copy_v) { | |
| return function ($copy_v1) { | |
| return function ($copy_acc) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_var_v1 = $copy_v1; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1, acc) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return acc; | |
| }; | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return acc; | |
| }; | |
| if (v instanceof Data_List_Types.Cons && v1 instanceof Data_List_Types.Cons) { | |
| $tco_var_v = v.value1; | |
| $tco_var_v1 = v1.value1; | |
| $copy_acc = new Data_List_Types.Cons(f(v.value0)(v1.value0), acc); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 692, column 3 - line 692, column 21: " + [ v.constructor.name, v1.constructor.name, acc.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $tco_var_v1, $copy_acc); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| return reverse(go(xs)(ys)(Data_List_Types.Nil.value)); | |
| }; | |
| }; | |
| }; | |
| // | Collect pairs of elements at the same positions in two lists. | |
| // | | |
| // | Running time: `O(min(m, n))` | |
| var zip = zipWith(Data_Tuple.Tuple.create); | |
| // | A generalization of `zipWith` which accumulates results in some `Applicative` | |
| // | functor. | |
| var zipWithA = function (dictApplicative) { | |
| return function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| return Data_Traversable.sequence(Data_List_Types.traversableList)(dictApplicative)(zipWith(f)(xs)(ys)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Create a list containing a range of integers, including both endpoints. | |
| var range = function (start) { | |
| return function (end) { | |
| if (start === end) { | |
| return singleton(start); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| var go = function ($copy_s) { | |
| return function ($copy_e) { | |
| return function ($copy_step) { | |
| return function ($copy_rest) { | |
| var $tco_var_s = $copy_s; | |
| var $tco_var_e = $copy_e; | |
| var $tco_var_step = $copy_step; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(s, e, step, rest) { | |
| if (s === e) { | |
| $tco_done = true; | |
| return new Data_List_Types.Cons(s, rest); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| $tco_var_s = s + step | 0; | |
| $tco_var_e = e; | |
| $tco_var_step = step; | |
| $copy_rest = new Data_List_Types.Cons(s, rest); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 145, column 3 - line 146, column 65: " + [ s.constructor.name, e.constructor.name, step.constructor.name, rest.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_s, $tco_var_e, $tco_var_step, $copy_rest); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| }; | |
| return go(end)(start)((function () { | |
| var $221 = start > end; | |
| if ($221) { | |
| return 1; | |
| }; | |
| return -1 | 0; | |
| })())(Data_List_Types.Nil.value); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 141, column 1 - line 141, column 32: " + [ start.constructor.name, end.constructor.name ]); | |
| }; | |
| }; | |
| // | Returns a lists of elements which do and do not satisfy a predicate. | |
| // | | |
| // | Running time: `O(n)` | |
| var partition = function (p) { | |
| return function (xs) { | |
| var select = function (x) { | |
| return function (v) { | |
| var $224 = p(x); | |
| if ($224) { | |
| return { | |
| no: v.no, | |
| yes: new Data_List_Types.Cons(x, v.yes) | |
| }; | |
| }; | |
| return { | |
| no: new Data_List_Types.Cons(x, v.no), | |
| yes: v.yes | |
| }; | |
| }; | |
| }; | |
| return Data_Foldable.foldr(Data_List_Types.foldableList)(select)({ | |
| no: Data_List_Types.Nil.value, | |
| yes: Data_List_Types.Nil.value | |
| })(xs); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // List size ------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Test whether a list is empty. | |
| // | | |
| // | Running time: `O(1)` | |
| var $$null = function (v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| var newtypePattern = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Pattern); | |
| // | Apply a function to each element and its index in a list starting at 0. | |
| var mapWithIndex = function (f) { | |
| return function (lst) { | |
| var go = function ($copy_v) { | |
| return function ($copy_v1) { | |
| return function ($copy_acc) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_var_v1 = $copy_v1; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1, acc) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return acc; | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| $tco_var_v = v + 1 | 0; | |
| $tco_var_v1 = v1.value1; | |
| $copy_acc = new Data_List_Types.Cons(f(v)(v1.value0), acc); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 430, column 3 - line 430, column 21: " + [ v.constructor.name, v1.constructor.name, acc.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $tco_var_v1, $copy_acc); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| return reverse(go(0)(lst)(Data_List_Types.Nil.value)); | |
| }; | |
| }; | |
| // | Apply a function to each element in a list, keeping only the results which | |
| // | contain a value. | |
| // | | |
| // | Running time: `O(n)` | |
| var mapMaybe = function (f) { | |
| var go = function ($copy_acc) { | |
| return function ($copy_v) { | |
| var $tco_var_acc = $copy_acc; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(acc, v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return reverse(acc); | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| var v1 = f(v.value0); | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| $tco_var_acc = acc; | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| if (v1 instanceof Data_Maybe.Just) { | |
| $tco_var_acc = new Data_List_Types.Cons(v1.value0, acc); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 416, column 5 - line 418, column 32: " + [ v1.constructor.name ]); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 414, column 3 - line 414, column 27: " + [ acc.constructor.name, v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_acc, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(Data_List_Types.Nil.value); | |
| }; | |
| // | A stack-safe version of `many`, at the cost of a `MonadRec` constraint. | |
| var manyRec = function (dictMonadRec) { | |
| return function (dictAlternative) { | |
| return function (p) { | |
| var go = function (acc) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(Control_Alt.alt((dictAlternative.Plus1()).Alt0())(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())(Control_Monad_Rec_Class.Loop.create)(p))(Control_Applicative.pure(dictAlternative.Applicative0())(new Control_Monad_Rec_Class.Done(Data_Unit.unit))))(function (v) { | |
| return Control_Applicative.pure(dictAlternative.Applicative0())(Data_Bifunctor.bimap(Control_Monad_Rec_Class.bifunctorStep)(function (v1) { | |
| return new Data_List_Types.Cons(v1, acc); | |
| })(function (v1) { | |
| return reverse(acc); | |
| })(v)); | |
| }); | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go)(Data_List_Types.Nil.value); | |
| }; | |
| }; | |
| }; | |
| // | A stack-safe version of `some`, at the cost of a `MonadRec` constraint. | |
| var someRec = function (dictMonadRec) { | |
| return function (dictAlternative) { | |
| return function (v) { | |
| return Control_Apply.apply((dictAlternative.Applicative0()).Apply0())(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())(Data_List_Types.Cons.create)(v))(manyRec(dictMonadRec)(dictAlternative)(v)); | |
| }; | |
| }; | |
| }; | |
| // | Attempt a computation multiple times, requiring at least one success. | |
| // | | |
| // | The `Lazy` constraint is used to generate the result lazily, to ensure | |
| // | termination. | |
| var some = function (dictAlternative) { | |
| return function (dictLazy) { | |
| return function (v) { | |
| return Control_Apply.apply((dictAlternative.Applicative0()).Apply0())(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())(Data_List_Types.Cons.create)(v))(Control_Lazy.defer(dictLazy)(function (v1) { | |
| return many(dictAlternative)(dictLazy)(v); | |
| })); | |
| }; | |
| }; | |
| }; | |
| // | Attempt a computation multiple times, returning as many successful results | |
| // | as possible (possibly zero). | |
| // | | |
| // | The `Lazy` constraint is used to generate the result lazily, to ensure | |
| // | termination. | |
| var many = function (dictAlternative) { | |
| return function (dictLazy) { | |
| return function (v) { | |
| return Control_Alt.alt((dictAlternative.Plus1()).Alt0())(some(dictAlternative)(dictLazy)(v))(Control_Applicative.pure(dictAlternative.Applicative0())(Data_List_Types.Nil.value)); | |
| }; | |
| }; | |
| }; | |
| // | Get the length of a list | |
| // | | |
| // | Running time: `O(n)` | |
| var length = Data_Foldable.foldl(Data_List_Types.foldableList)(function (acc) { | |
| return function (v) { | |
| return acc + 1 | 0; | |
| }; | |
| })(0); | |
| // | Get the last element in a list, or `Nothing` if the list is empty. | |
| // | | |
| // | Running time: `O(n)`. | |
| var last = function ($copy_v) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| // | Insert an element into a sorted list, using the specified function to | |
| // | determine the ordering of elements. | |
| // | | |
| // | Running time: `O(n)` | |
| var insertBy = function (v) { | |
| return function (x) { | |
| return function (v1) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return singleton(x); | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| var v2 = v(x)(v1.value0); | |
| if (v2 instanceof Data_Ordering.GT) { | |
| return new Data_List_Types.Cons(v1.value0, insertBy(v)(x)(v1.value1)); | |
| }; | |
| return new Data_List_Types.Cons(x, v1); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 213, column 1 - line 213, column 68: " + [ v.constructor.name, x.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Insert an element into a list at the specified index, returning a new | |
| // | list or `Nothing` if the index is out-of-bounds. | |
| // | | |
| // | Running time: `O(n)` | |
| var insertAt = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v === 0) { | |
| return new Data_Maybe.Just(new Data_List_Types.Cons(v1, v2)); | |
| }; | |
| if (v2 instanceof Data_List_Types.Cons) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (v3) { | |
| return new Data_List_Types.Cons(v2.value0, v3); | |
| })(insertAt(v - 1 | 0)(v1)(v2.value1)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| }; | |
| // | Insert an element into a sorted list. | |
| // | | |
| // | Running time: `O(n)` | |
| var insert = function (dictOrd) { | |
| return insertBy(Data_Ord.compare(dictOrd)); | |
| }; | |
| // | Get all but the last element of a list, or `Nothing` if the list is empty. | |
| // | | |
| // | Running time: `O(n)` | |
| var init = function (lst) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (v) { | |
| return v.init; | |
| })(unsnoc(lst)); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Indexed operations ---------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Get the element at the specified index, or `Nothing` if the index is out-of-bounds. | |
| // | | |
| // | Running time: `O(n)` where `n` is the required index. | |
| var index = function ($copy_v) { | |
| return function ($copy_v1) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v instanceof Data_List_Types.Cons && v1 === 0) { | |
| $tco_done = true; | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| $tco_var_v = v.value1; | |
| $copy_v1 = v1 - 1 | 0; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 278, column 1 - line 278, column 44: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $copy_v1); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Non-indexed reads ----------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Get the first element in a list, or `Nothing` if the list is empty. | |
| // | | |
| // | Running time: `O(1)`. | |
| var head = function (v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 227, column 1 - line 227, column 22: " + [ v.constructor.name ]); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Transpose ------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | The 'transpose' function transposes the rows and columns of its argument. | |
| // | For example, | |
| // | | |
| // | transpose ((1:2:3:Nil) : (4:5:6:Nil) : Nil) == | |
| // | ((1:4:Nil) : (2:5:Nil) : (3:6:Nil) : Nil) | |
| // | | |
| // | If some of the rows are shorter than the following rows, their elements are skipped: | |
| // | | |
| // | transpose ((10:11:Nil) : (20:Nil) : Nil : (30:31:32:Nil) : Nil) == | |
| // | ((10:20:30:Nil) : (11:31:Nil) : (32:Nil) : Nil) | |
| var transpose = function (v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| return Data_List_Types.Nil.value; | |
| }; | |
| if (v instanceof Data_List_Types.Cons && v.value0 instanceof Data_List_Types.Nil) { | |
| return transpose(v.value1); | |
| }; | |
| if (v instanceof Data_List_Types.Cons && v.value0 instanceof Data_List_Types.Cons) { | |
| return new Data_List_Types.Cons(new Data_List_Types.Cons(v.value0.value0, mapMaybe(head)(v.value1)), transpose(new Data_List_Types.Cons(v.value0.value1, mapMaybe(tail)(v.value1)))); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 726, column 1 - line 726, column 54: " + [ v.constructor.name ]); | |
| }; | |
| // | Group equal, consecutive elements of a list into lists, using the specified | |
| // | equivalence relation to determine equality. | |
| // | | |
| // | Running time: `O(n)` | |
| var groupBy = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return Data_List_Types.Nil.value; | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| var v2 = span(v(v1.value0))(v1.value1); | |
| return new Data_List_Types.Cons(new Data_NonEmpty.NonEmpty(v1.value0, v2.init), groupBy(v)(v2.rest)); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 589, column 1 - line 589, column 80: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| // | Group equal, consecutive elements of a list into lists. | |
| // | | |
| // | For example, | |
| // | | |
| // | ```purescript | |
| // | group (1 : 1 : 2 : 2 : 1 : Nil) == (1 : 1 : Nil) : (2 : 2 : Nil) : (1 : Nil) : Nil | |
| // | ``` | |
| // | | |
| // | Running time: `O(n)` | |
| var group = function (dictEq) { | |
| return groupBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Sort and then group the elements of a list into lists. | |
| // | | |
| // | ```purescript | |
| // | group' [1,1,2,2,1] == [[1,1,1],[2,2]] | |
| // | ``` | |
| var group$prime = function (dictOrd) { | |
| return function ($341) { | |
| return group(dictOrd.Eq0())(sort(dictOrd)($341)); | |
| }; | |
| }; | |
| // | Construct a list from a foldable structure. | |
| // | | |
| // | Running time: `O(n)` | |
| var fromFoldable = function (dictFoldable) { | |
| return Data_Foldable.foldr(dictFoldable)(Data_List_Types.Cons.create)(Data_List_Types.Nil.value); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Folding --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Perform a fold using a monadic step function. | |
| var foldM = function (dictMonad) { | |
| return function (v) { | |
| return function (a) { | |
| return function (v1) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(a); | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v(a)(v1.value0))(function (a$prime) { | |
| return foldM(dictMonad)(v)(a$prime)(v1.value1); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 737, column 1 - line 737, column 72: " + [ v.constructor.name, a.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Find the first index for which a predicate holds. | |
| var findIndex = function (fn) { | |
| var go = function ($copy_v) { | |
| return function ($copy_v1) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1) { | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| if (fn(v1.value0)) { | |
| $tco_done = true; | |
| return new Data_Maybe.Just(v); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| $tco_var_v = v + 1 | 0; | |
| $copy_v1 = v1.value1; | |
| return; | |
| }; | |
| }; | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 298, column 3 - line 298, column 35: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $copy_v1); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(0); | |
| }; | |
| // | Find the last index for which a predicate holds. | |
| var findLastIndex = function (fn) { | |
| return function (xs) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (v) { | |
| return (length(xs) - 1 | 0) - v | 0; | |
| })(findIndex(fn)(reverse(xs))); | |
| }; | |
| }; | |
| // | Filter where the predicate returns a monadic `Boolean`. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | powerSet :: forall a. [a] -> [[a]] | |
| // | powerSet = filterM (const [true, false]) | |
| // | ``` | |
| var filterM = function (dictMonad) { | |
| return function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_List_Types.Nil.value); | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v(v1.value0))(function (v2) { | |
| return Control_Bind.bind(dictMonad.Bind1())(filterM(dictMonad)(v)(v1.value1))(function (v3) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())((function () { | |
| if (v2) { | |
| return new Data_List_Types.Cons(v1.value0, v3); | |
| }; | |
| return v3; | |
| })()); | |
| }); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 400, column 1 - line 400, column 75: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Filter a list, keeping the elements which satisfy a predicate function. | |
| // | | |
| // | Running time: `O(n)` | |
| var filter = function (p) { | |
| var go = function ($copy_acc) { | |
| return function ($copy_v) { | |
| var $tco_var_acc = $copy_acc; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(acc, v) { | |
| if (v instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return reverse(acc); | |
| }; | |
| if (v instanceof Data_List_Types.Cons) { | |
| if (p(v.value0)) { | |
| $tco_var_acc = new Data_List_Types.Cons(v.value0, acc); | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| $tco_var_acc = acc; | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 387, column 3 - line 387, column 27: " + [ acc.constructor.name, v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_acc, $copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(Data_List_Types.Nil.value); | |
| }; | |
| // | Calculate the intersection of two lists, using the specified | |
| // | function to determine equality of elements. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var intersectBy = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return Data_List_Types.Nil.value; | |
| }; | |
| if (v2 instanceof Data_List_Types.Nil) { | |
| return Data_List_Types.Nil.value; | |
| }; | |
| return filter(function (x) { | |
| return Data_Foldable.any(Data_List_Types.foldableList)(Data_HeytingAlgebra.heytingAlgebraBoolean)(v(x))(v2); | |
| })(v1); | |
| }; | |
| }; | |
| }; | |
| // | Calculate the intersection of two lists. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var intersect = function (dictEq) { | |
| return intersectBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Remove duplicate elements from a list, using the specified | |
| // | function to determine equality of elements. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var nubBy = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| return Data_List_Types.Nil.value; | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| return new Data_List_Types.Cons(v1.value0, nubBy(v)(filter(function (y) { | |
| return !v(v1.value0)(y); | |
| })(v1.value1))); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 618, column 1 - line 618, column 59: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Set-like operations --------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Remove duplicate elements from a list. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var nub = function (dictEq) { | |
| return nubBy(Data_Eq.eq(dictEq)); | |
| }; | |
| var eqPattern = function (dictEq) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(Data_List_Types.eqList(dictEq))(x)(y); | |
| }; | |
| }); | |
| }; | |
| var ordPattern = function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqPattern(dictOrd.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ord.compare(Data_List_Types.ordList(dictOrd))(x)(y); | |
| }; | |
| }); | |
| }; | |
| // | Find the index of the last element equal to the specified element. | |
| var elemLastIndex = function (dictEq) { | |
| return function (x) { | |
| return findLastIndex(function (v) { | |
| return Data_Eq.eq(dictEq)(v)(x); | |
| }); | |
| }; | |
| }; | |
| // | Find the index of the first element equal to the specified element. | |
| var elemIndex = function (dictEq) { | |
| return function (x) { | |
| return findIndex(function (v) { | |
| return Data_Eq.eq(dictEq)(v)(x); | |
| }); | |
| }; | |
| }; | |
| // | Drop those elements from the front of a list which match a predicate. | |
| // | | |
| // | Running time (worst case): `O(n)` | |
| var dropWhile = function (p) { | |
| var go = function ($copy_v) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| if (v instanceof Data_List_Types.Cons && p(v.value0)) { | |
| $copy_v = v.value1; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return v; | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| return go; | |
| }; | |
| // | Drop the specified number of elements from the front of a list. | |
| // | | |
| // | Running time: `O(n)` where `n` is the number of elements to drop. | |
| var drop = function ($copy_v) { | |
| return function ($copy_v1) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, v1) { | |
| if (v === 0) { | |
| $tco_done = true; | |
| return v1; | |
| }; | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return Data_List_Types.Nil.value; | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| $tco_var_v = v - 1 | 0; | |
| $copy_v1 = v1.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 534, column 1 - line 534, column 42: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $copy_v1); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| // | Extract a sublist by a start and end index. | |
| var slice = function (start) { | |
| return function (end) { | |
| return function (xs) { | |
| return take(end - start | 0)(drop(start)(xs)); | |
| }; | |
| }; | |
| }; | |
| // | Delete the first occurrence of an element from a list, using the specified | |
| // | function to determine equality of elements. | |
| // | | |
| // | Running time: `O(n)` | |
| var deleteBy = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Data_List_Types.Nil) { | |
| return Data_List_Types.Nil.value; | |
| }; | |
| if (v2 instanceof Data_List_Types.Cons && v(v1)(v2.value0)) { | |
| return v2.value1; | |
| }; | |
| if (v2 instanceof Data_List_Types.Cons) { | |
| return new Data_List_Types.Cons(v2.value0, deleteBy(v)(v1)(v2.value1)); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 645, column 1 - line 645, column 67: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Calculate the union of two lists, using the specified | |
| // | function to determine equality of elements. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var unionBy = function (eq) { | |
| return function (xs) { | |
| return function (ys) { | |
| return Data_Semigroup.append(Data_List_Types.semigroupList)(xs)(Data_Foldable.foldl(Data_List_Types.foldableList)(Data_Function.flip(deleteBy(eq)))(nubBy(eq)(ys))(xs)); | |
| }; | |
| }; | |
| }; | |
| // | Calculate the union of two lists. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var union = function (dictEq) { | |
| return unionBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Delete an element from a list at the specified index, returning a new | |
| // | list or `Nothing` if the index is out-of-bounds. | |
| // | | |
| // | Running time: `O(n)` | |
| var deleteAt = function (v) { | |
| return function (v1) { | |
| if (v === 0 && v1 instanceof Data_List_Types.Cons) { | |
| return new Data_Maybe.Just(v1.value1); | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (v2) { | |
| return new Data_List_Types.Cons(v1.value0, v2); | |
| })(deleteAt(v - 1 | 0)(v1.value1)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| // | Delete the first occurrence of an element from a list. | |
| // | | |
| // | Running time: `O(n)` | |
| var $$delete = function (dictEq) { | |
| return deleteBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Delete the first occurrence of each element in the second list from the first list. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var difference = function (dictEq) { | |
| return Data_Foldable.foldl(Data_List_Types.foldableList)(Data_Function.flip($$delete(dictEq))); | |
| }; | |
| // | Apply a function to each element in a list, and flatten the results | |
| // | into a single, new list. | |
| // | | |
| // | Running time: `O(n)`, where `n` is the total number of elements. | |
| var concatMap = Data_Function.flip(Control_Bind.bind(Data_List_Types.bindList)); | |
| // | Flatten a list of lists. | |
| // | | |
| // | Running time: `O(n)`, where `n` is the total number of elements. | |
| var concat = function (v) { | |
| return Control_Bind.bind(Data_List_Types.bindList)(v)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| // | Filter a list of optional values, keeping only the elements which contain | |
| // | a value. | |
| var catMaybes = mapMaybe(Control_Category.id(Control_Category.categoryFn)); | |
| // | Update or delete the element at the specified index by applying a | |
| // | function to the current value, returning a new list or `Nothing` if the | |
| // | index is out-of-bounds. | |
| // | | |
| // | Running time: `O(n)` | |
| var alterAt = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v === 0 && v2 instanceof Data_List_Types.Cons) { | |
| return Data_Maybe.Just.create((function () { | |
| var v3 = v1(v2.value0); | |
| if (v3 instanceof Data_Maybe.Nothing) { | |
| return v2.value1; | |
| }; | |
| if (v3 instanceof Data_Maybe.Just) { | |
| return new Data_List_Types.Cons(v3.value0, v2.value1); | |
| }; | |
| throw new Error("Failed pattern match at Data.List line 349, column 3 - line 351, column 23: " + [ v3.constructor.name ]); | |
| })()); | |
| }; | |
| if (v2 instanceof Data_List_Types.Cons) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(function (v3) { | |
| return new Data_List_Types.Cons(v2.value0, v3); | |
| })(alterAt(v - 1 | 0)(v1)(v2.value1)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| }; | |
| // | Update the element at the specified index by applying a function to | |
| // | the current value, returning a new list or `Nothing` if the index is | |
| // | out-of-bounds. | |
| // | | |
| // | Running time: `O(n)` | |
| var modifyAt = function (n) { | |
| return function (f) { | |
| return alterAt(n)(function ($342) { | |
| return Data_Maybe.Just.create(f($342)); | |
| }); | |
| }; | |
| }; | |
| exports["Pattern"] = Pattern; | |
| exports["alterAt"] = alterAt; | |
| exports["catMaybes"] = catMaybes; | |
| exports["concat"] = concat; | |
| exports["concatMap"] = concatMap; | |
| exports["delete"] = $$delete; | |
| exports["deleteAt"] = deleteAt; | |
| exports["deleteBy"] = deleteBy; | |
| exports["difference"] = difference; | |
| exports["drop"] = drop; | |
| exports["dropWhile"] = dropWhile; | |
| exports["elemIndex"] = elemIndex; | |
| exports["elemLastIndex"] = elemLastIndex; | |
| exports["filter"] = filter; | |
| exports["filterM"] = filterM; | |
| exports["findIndex"] = findIndex; | |
| exports["findLastIndex"] = findLastIndex; | |
| exports["foldM"] = foldM; | |
| exports["fromFoldable"] = fromFoldable; | |
| exports["group"] = group; | |
| exports["group'"] = group$prime; | |
| exports["groupBy"] = groupBy; | |
| exports["head"] = head; | |
| exports["index"] = index; | |
| exports["init"] = init; | |
| exports["insert"] = insert; | |
| exports["insertAt"] = insertAt; | |
| exports["insertBy"] = insertBy; | |
| exports["intersect"] = intersect; | |
| exports["intersectBy"] = intersectBy; | |
| exports["last"] = last; | |
| exports["length"] = length; | |
| exports["many"] = many; | |
| exports["manyRec"] = manyRec; | |
| exports["mapMaybe"] = mapMaybe; | |
| exports["mapWithIndex"] = mapWithIndex; | |
| exports["modifyAt"] = modifyAt; | |
| exports["nub"] = nub; | |
| exports["nubBy"] = nubBy; | |
| exports["null"] = $$null; | |
| exports["partition"] = partition; | |
| exports["range"] = range; | |
| exports["reverse"] = reverse; | |
| exports["singleton"] = singleton; | |
| exports["slice"] = slice; | |
| exports["snoc"] = snoc; | |
| exports["some"] = some; | |
| exports["someRec"] = someRec; | |
| exports["sort"] = sort; | |
| exports["sortBy"] = sortBy; | |
| exports["span"] = span; | |
| exports["stripPrefix"] = stripPrefix; | |
| exports["tail"] = tail; | |
| exports["take"] = take; | |
| exports["takeWhile"] = takeWhile; | |
| exports["toUnfoldable"] = toUnfoldable; | |
| exports["transpose"] = transpose; | |
| exports["uncons"] = uncons; | |
| exports["union"] = union; | |
| exports["unionBy"] = unionBy; | |
| exports["unsnoc"] = unsnoc; | |
| exports["unzip"] = unzip; | |
| exports["updateAt"] = updateAt; | |
| exports["zip"] = zip; | |
| exports["zipWith"] = zipWith; | |
| exports["zipWithA"] = zipWithA; | |
| exports["eqPattern"] = eqPattern; | |
| exports["ordPattern"] = ordPattern; | |
| exports["newtypePattern"] = newtypePattern; | |
| exports["showPattern"] = showPattern; | |
| })(PS["Data.List"] = PS["Data.List"] || {}); | |
| (function(exports) { | |
| // | This module defines a strict queue. | |
| // | | |
| // | The queue implementation is based on a pair of lists where all | |
| // | operations require `O(1)` amortized time. | |
| // | | |
| // | However, any single `uncons` operation may run in `O(n)` time. | |
| // | | |
| // | See [Simple and Efficient Purely Functional Queues and Dequeues](http://www.westpoint.edu/eecs/SiteAssets/SitePages/Faculty%20Publication%20Documents/Okasaki/jfp95queue.pdf) (Okasaki 1995) | |
| "use strict"; | |
| var Data_List = PS["Data.List"]; | |
| var Data_List_Types = PS["Data.List.Types"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| // | A strict queue representated using a pair of lists. | |
| var CatQueue = (function () { | |
| function CatQueue(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| CatQueue.create = function (value0) { | |
| return function (value1) { | |
| return new CatQueue(value0, value1); | |
| }; | |
| }; | |
| return CatQueue; | |
| })(); | |
| // | Decompose a queue into a `Tuple` of the first element and the rest of the queue. | |
| // | | |
| // | Running time: `O(1)` | |
| // | | |
| // | Note that any single operation may run in `O(n)`. | |
| var uncons = function ($copy_v) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v.value0 instanceof Data_List_Types.Nil) { | |
| $copy_v = new CatQueue(Data_List.reverse(v.value1), Data_List_Types.Nil.value); | |
| return; | |
| }; | |
| if (v.value0 instanceof Data_List_Types.Cons) { | |
| $tco_done = true; | |
| return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0.value0, new CatQueue(v.value0.value1, v.value1))); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatQueue line 50, column 1 - line 50, column 63: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| // | Append an element to the end of the queue, creating a new queue. | |
| // | | |
| // | Running time: `O(1)` | |
| var snoc = function (v) { | |
| return function (a) { | |
| return new CatQueue(v.value0, new Data_List_Types.Cons(a, v.value1)); | |
| }; | |
| }; | |
| var showCatQueue = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(CatQueue " + (Data_Show.show(Data_List_Types.showList(dictShow))(v.value0) + (" " + (Data_Show.show(Data_List_Types.showList(dictShow))(v.value1) + ")"))); | |
| }); | |
| }; | |
| // | Test whether a queue is empty. | |
| // | | |
| // | Running time: `O(1)` | |
| var $$null = function (v) { | |
| if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| // | Create an empty queue. | |
| // | | |
| // | Running time: `O(1)` | |
| var empty = new CatQueue(Data_List_Types.Nil.value, Data_List_Types.Nil.value); | |
| exports["CatQueue"] = CatQueue; | |
| exports["empty"] = empty; | |
| exports["null"] = $$null; | |
| exports["snoc"] = snoc; | |
| exports["uncons"] = uncons; | |
| exports["showCatQueue"] = showCatQueue; | |
| })(PS["Data.CatQueue"] = PS["Data.CatQueue"] || {}); | |
| (function(exports) { | |
| // | This module defines a strict catenable list. | |
| // | | |
| // | The implementation is based on a queue where all operations require | |
| // | `O(1)` amortized time. | |
| // | | |
| // | However, any single `uncons` operation may run in `O(n)` time. | |
| // | | |
| // | See [Purely Functional Data Structures](http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf) (Okasaki 1996) | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_CatQueue = PS["Data.CatQueue"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_List = PS["Data.List"]; | |
| var Data_List_Types = PS["Data.List.Types"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_NaturalTransformation = PS["Data.NaturalTransformation"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unfoldable = PS["Data.Unfoldable"]; | |
| // | A strict catenable list. | |
| // | | |
| // | `CatList` may be empty, represented by `CatNil`. | |
| // | | |
| // | `CatList` may be non-empty, represented by `CatCons`. The `CatCons` | |
| // | data constructor takes the first element of the list and a queue of | |
| // | `CatList`. | |
| var CatNil = (function () { | |
| function CatNil() { | |
| }; | |
| CatNil.value = new CatNil(); | |
| return CatNil; | |
| })(); | |
| // | A strict catenable list. | |
| // | | |
| // | `CatList` may be empty, represented by `CatNil`. | |
| // | | |
| // | `CatList` may be non-empty, represented by `CatCons`. The `CatCons` | |
| // | data constructor takes the first element of the list and a queue of | |
| // | `CatList`. | |
| var CatCons = (function () { | |
| function CatCons(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| CatCons.create = function (value0) { | |
| return function (value1) { | |
| return new CatCons(value0, value1); | |
| }; | |
| }; | |
| return CatCons; | |
| })(); | |
| var showCatList = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| if (v instanceof CatNil) { | |
| return "CatNil"; | |
| }; | |
| if (v instanceof CatCons) { | |
| return "(CatList " + (Data_Show.show(dictShow)(v.value0) + (" " + (Data_Show.show(Data_CatQueue.showCatQueue(showCatList(dictShow)))(v.value1) + ")"))); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 153, column 1 - line 153, column 51: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| // | Test whether a catenable list is empty. | |
| // | | |
| // | Running time: `O(1)` | |
| var $$null = function (v) { | |
| if (v instanceof CatNil) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| // | Links two catenable lists by making appending the queue in the | |
| // | first catenable list to the second catenable list. This operation | |
| // | creates a new catenable list. | |
| // | | |
| // | Running time: `O(1)` | |
| var link = function (v) { | |
| return function (cat) { | |
| if (v instanceof CatNil) { | |
| return cat; | |
| }; | |
| if (v instanceof CatCons) { | |
| return new CatCons(v.value0, Data_CatQueue.snoc(v.value1)(cat)); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 110, column 1 - line 110, column 54: " + [ v.constructor.name, cat.constructor.name ]); | |
| }; | |
| }; | |
| // | Tail recursive version of foldr on `CatList`. | |
| // | | |
| // | Ensures foldl on `List` is tail-recursive. | |
| var foldr = function (k) { | |
| return function (b) { | |
| return function (q) { | |
| var foldl = function ($copy_v) { | |
| return function ($copy_c) { | |
| return function ($copy_v1) { | |
| var $tco_var_v = $copy_v; | |
| var $tco_var_c = $copy_c; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v, c, v1) { | |
| if (v1 instanceof Data_List_Types.Nil) { | |
| $tco_done = true; | |
| return c; | |
| }; | |
| if (v1 instanceof Data_List_Types.Cons) { | |
| $tco_var_v = v; | |
| $tco_var_c = v(c)(v1.value0); | |
| $copy_v1 = v1.value1; | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 125, column 3 - line 125, column 59: " + [ v.constructor.name, c.constructor.name, v1.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_v, $tco_var_c, $copy_v1); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| }; | |
| var go = function ($copy_xs) { | |
| return function ($copy_ys) { | |
| var $tco_var_xs = $copy_xs; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(xs, ys) { | |
| var v = Data_CatQueue.uncons(xs); | |
| if (v instanceof Data_Maybe.Nothing) { | |
| $tco_done = true; | |
| return foldl(function (x) { | |
| return function (i) { | |
| return i(x); | |
| }; | |
| })(b)(ys); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| $tco_var_xs = v.value0.value1; | |
| $copy_ys = new Data_List_Types.Cons(k(v.value0.value0), ys); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 121, column 14 - line 123, column 67: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_xs, $copy_ys); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(q)(Data_List_Types.Nil.value); | |
| }; | |
| }; | |
| }; | |
| // | Decompose a catenable list into a `Tuple` of the first element and | |
| // | the rest of the catenable list. | |
| // | | |
| // | Running time: `O(1)` | |
| // | | |
| // | Note that any single operation may run in `O(n)`. | |
| var uncons = function (v) { | |
| if (v instanceof CatNil) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (v instanceof CatCons) { | |
| return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, (function () { | |
| var $41 = Data_CatQueue["null"](v.value1); | |
| if ($41) { | |
| return CatNil.value; | |
| }; | |
| return foldr(link)(CatNil.value)(v.value1); | |
| })())); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 101, column 1 - line 101, column 61: " + [ v.constructor.name ]); | |
| }; | |
| var foldMap = function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| if (v instanceof CatNil) { | |
| return Data_Monoid.mempty(dictMonoid); | |
| }; | |
| if (v instanceof CatCons) { | |
| var d = (function () { | |
| var $46 = Data_CatQueue["null"](v.value1); | |
| if ($46) { | |
| return CatNil.value; | |
| }; | |
| return foldr(link)(CatNil.value)(v.value1); | |
| })(); | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(f(v.value0))(foldMap(dictMonoid)(f)(d)); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 141, column 1 - line 141, column 62: " + [ f.constructor.name, v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| var foldableCatList = new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (l) { | |
| return foldMap(dictMonoid)(f)(l); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (s) { | |
| return function (l) { | |
| return Data_Foldable.foldlDefault(foldableCatList)(f)(s)(l); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (s) { | |
| return function (l) { | |
| return Data_Foldable.foldrDefault(foldableCatList)(f)(s)(l); | |
| }; | |
| }; | |
| }); | |
| // | Create an empty catenable list. | |
| // | | |
| // | Running time: `O(1)` | |
| var empty = CatNil.value; | |
| // | Append all elements of a catenable list to the end of another | |
| // | catenable list, create a new catenable list. | |
| // | | |
| // | Running time: `O(1)` | |
| var append = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof CatNil) { | |
| return v; | |
| }; | |
| if (v instanceof CatNil) { | |
| return v1; | |
| }; | |
| return link(v)(v1); | |
| }; | |
| }; | |
| // | Append an element to the beginning of the catenable list, creating a new | |
| // | catenable list. | |
| // | | |
| // | Running time: `O(1)` | |
| var cons = function (a) { | |
| return function (cat) { | |
| return append(new CatCons(a, Data_CatQueue.empty))(cat); | |
| }; | |
| }; | |
| var map = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof CatNil) { | |
| return CatNil.value; | |
| }; | |
| if (v1 instanceof CatCons) { | |
| var d = (function () { | |
| var $53 = Data_CatQueue["null"](v1.value1); | |
| if ($53) { | |
| return CatNil.value; | |
| }; | |
| return foldr(link)(CatNil.value)(v1.value1); | |
| })(); | |
| return cons(v(v1.value0))(map(v)(d)); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 135, column 1 - line 135, column 54: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| var functorCatList = new Data_Functor.Functor(map); | |
| // | Create a catenable list with a single item. | |
| // | | |
| // | Running time: `O(1)` | |
| var singleton = function (a) { | |
| return cons(a)(CatNil.value); | |
| }; | |
| var traversableCatList = new Data_Traversable.Traversable(function () { | |
| return foldableCatList; | |
| }, function () { | |
| return functorCatList; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| if (v instanceof CatNil) { | |
| return Control_Applicative.pure(dictApplicative)(CatNil.value); | |
| }; | |
| if (v instanceof CatCons) { | |
| var d = (function () { | |
| var $57 = Data_CatQueue["null"](v.value1); | |
| if ($57) { | |
| return CatNil.value; | |
| }; | |
| return foldr(link)(CatNil.value)(v.value1); | |
| })(); | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(cons)(v.value0))(Data_Traversable.sequence(traversableCatList)(dictApplicative)(d)); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 169, column 1 - line 169, column 51: " + [ v.constructor.name ]); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (v) { | |
| return function (v1) { | |
| if (v1 instanceof CatNil) { | |
| return Control_Applicative.pure(dictApplicative)(CatNil.value); | |
| }; | |
| if (v1 instanceof CatCons) { | |
| var d = (function () { | |
| var $62 = Data_CatQueue["null"](v1.value1); | |
| if ($62) { | |
| return CatNil.value; | |
| }; | |
| return foldr(link)(CatNil.value)(v1.value1); | |
| })(); | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(cons)(v(v1.value0)))(Data_Traversable.traverse(traversableCatList)(dictApplicative)(v)(d)); | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 169, column 1 - line 169, column 51: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| }); | |
| var semigroupCatList = new Data_Semigroup.Semigroup(append); | |
| var monoidCatList = new Data_Monoid.Monoid(function () { | |
| return semigroupCatList; | |
| }, CatNil.value); | |
| var monadCatList = new Control_Monad.Monad(function () { | |
| return applicativeCatList; | |
| }, function () { | |
| return bindCatList; | |
| }); | |
| var bindCatList = new Control_Bind.Bind(function () { | |
| return applyCatList; | |
| }, Data_Function.flip(foldMap(monoidCatList))); | |
| var applyCatList = new Control_Apply.Apply(function () { | |
| return functorCatList; | |
| }, Control_Monad.ap(monadCatList)); | |
| var applicativeCatList = new Control_Applicative.Applicative(function () { | |
| return applyCatList; | |
| }, singleton); | |
| // | Convert any `Foldable` into a `CatList`. | |
| // | | |
| // | Running time: `O(n)` | |
| var fromFoldable = function (dictFoldable) { | |
| return function (f) { | |
| return Data_Foldable.foldMap(dictFoldable)(monoidCatList)(singleton)(f); | |
| }; | |
| }; | |
| // | Append an element to the end of the catenable list, creating a new | |
| // | catenable list. | |
| // | | |
| // | Running time: `O(1)` | |
| var snoc = function (cat) { | |
| return function (a) { | |
| return append(cat)(new CatCons(a, Data_CatQueue.empty)); | |
| }; | |
| }; | |
| var unfoldableCatList = new Data_Unfoldable.Unfoldable(function (f) { | |
| return function (b) { | |
| var go = function ($copy_source) { | |
| return function ($copy_memo) { | |
| var $tco_var_source = $copy_source; | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(source, memo) { | |
| var v = f(source); | |
| if (v instanceof Data_Maybe.Nothing) { | |
| $tco_done = true; | |
| return memo; | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| $tco_var_source = v.value0.value1; | |
| $copy_memo = snoc(memo)(v.value0.value0); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Data.CatList line 165, column 24 - line 167, column 57: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($tco_var_source, $copy_memo); | |
| }; | |
| return $tco_result; | |
| }; | |
| }; | |
| return go(b)(CatNil.value); | |
| }; | |
| }); | |
| var altCatList = new Control_Alt.Alt(function () { | |
| return functorCatList; | |
| }, append); | |
| var plusCatList = new Control_Plus.Plus(function () { | |
| return altCatList; | |
| }, empty); | |
| var alternativeCatList = new Control_Alternative.Alternative(function () { | |
| return applicativeCatList; | |
| }, function () { | |
| return plusCatList; | |
| }); | |
| var monadZeroCatList = new Control_MonadZero.MonadZero(function () { | |
| return alternativeCatList; | |
| }, function () { | |
| return monadCatList; | |
| }); | |
| var monadPlusCatList = new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroCatList; | |
| }); | |
| exports["CatNil"] = CatNil; | |
| exports["CatCons"] = CatCons; | |
| exports["append"] = append; | |
| exports["cons"] = cons; | |
| exports["empty"] = empty; | |
| exports["fromFoldable"] = fromFoldable; | |
| exports["null"] = $$null; | |
| exports["snoc"] = snoc; | |
| exports["uncons"] = uncons; | |
| exports["semigroupCatList"] = semigroupCatList; | |
| exports["monoidCatList"] = monoidCatList; | |
| exports["showCatList"] = showCatList; | |
| exports["foldableCatList"] = foldableCatList; | |
| exports["unfoldableCatList"] = unfoldableCatList; | |
| exports["traversableCatList"] = traversableCatList; | |
| exports["functorCatList"] = functorCatList; | |
| exports["applyCatList"] = applyCatList; | |
| exports["applicativeCatList"] = applicativeCatList; | |
| exports["bindCatList"] = bindCatList; | |
| exports["monadCatList"] = monadCatList; | |
| exports["altCatList"] = altCatList; | |
| exports["plusCatList"] = plusCatList; | |
| exports["alternativeCatList"] = alternativeCatList; | |
| exports["monadZeroCatList"] = monadZeroCatList; | |
| exports["monadPlusCatList"] = monadPlusCatList; | |
| })(PS["Data.CatList"] = PS["Data.CatList"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_CatList = PS["Data.CatList"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| var ExpF = function (x) { | |
| return x; | |
| }; | |
| // | The free monad for a type constructor `f`. | |
| // | | |
| // | Implemented in the spirit of [Reflection without Remorse](http://okmij.org/ftp/Haskell/zseq.pdf), | |
| // | the free monad is represented using a sequential data structure in | |
| // | order to overcome the quadratic complexity of left-associated binds | |
| // | and traversal through the free monad structure. | |
| var Free = (function () { | |
| function Free(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Free.create = function (value0) { | |
| return function (value1) { | |
| return new Free(value0, value1); | |
| }; | |
| }; | |
| return Free; | |
| })(); | |
| var Return = (function () { | |
| function Return(value0) { | |
| this.value0 = value0; | |
| }; | |
| Return.create = function (value0) { | |
| return new Return(value0); | |
| }; | |
| return Return; | |
| })(); | |
| var Bind = (function () { | |
| function Bind(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Bind.create = function (value0) { | |
| return function (value1) { | |
| return new Bind(value0, value1); | |
| }; | |
| }; | |
| return Bind; | |
| })(); | |
| var toView = function ($copy_v) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(v) { | |
| var runExpF = function (v2) { | |
| return v2; | |
| }; | |
| var concatF = function (v2) { | |
| return function (r) { | |
| return new Free(v2.value0, Data_Semigroup.append(Data_CatList.semigroupCatList)(v2.value1)(r)); | |
| }; | |
| }; | |
| if (v.value0 instanceof Return) { | |
| var v2 = Data_CatList.uncons(v.value1); | |
| if (v2 instanceof Data_Maybe.Nothing) { | |
| $tco_done = true; | |
| return new Return(Unsafe_Coerce.unsafeCoerce(v.value0.value0)); | |
| }; | |
| if (v2 instanceof Data_Maybe.Just) { | |
| $copy_v = Unsafe_Coerce.unsafeCoerce(concatF(runExpF(v2.value0.value0)(v.value0.value0))(v2.value0.value1)); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 215, column 7 - line 219, column 64: " + [ v2.constructor.name ]); | |
| }; | |
| if (v.value0 instanceof Bind) { | |
| $tco_done = true; | |
| return new Bind(v.value0.value0, function (a) { | |
| return Unsafe_Coerce.unsafeCoerce(concatF(v.value0.value1(a))(v.value1)); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 213, column 3 - line 221, column 56: " + [ v.value0.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_v); | |
| }; | |
| return $tco_result; | |
| }; | |
| // | Run a free monad with a function mapping a functor `f` to a tail-recursive | |
| // | monad `m`. See the `MonadRec` type class for more details. | |
| var runFreeM = function (dictFunctor) { | |
| return function (dictMonadRec) { | |
| return function (k) { | |
| var go = function (f) { | |
| var v = toView(f); | |
| if (v instanceof Return) { | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(v.value0)); | |
| }; | |
| if (v instanceof Bind) { | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Loop.create)(k(Data_Functor.map(dictFunctor)(v.value1)(v.value0))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 182, column 10 - line 184, column 37: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); | |
| }; | |
| }; | |
| }; | |
| // | Run a free monad with a function that unwraps a single layer of the functor | |
| // | `f` at a time. | |
| var runFree = function (dictFunctor) { | |
| return function (k) { | |
| var go = function ($copy_f) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(f) { | |
| var v = toView(f); | |
| if (v instanceof Return) { | |
| $tco_done = true; | |
| return v.value0; | |
| }; | |
| if (v instanceof Bind) { | |
| $copy_f = k(Data_Functor.map(dictFunctor)(v.value1)(v.value0)); | |
| return; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 166, column 10 - line 168, column 33: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_f); | |
| }; | |
| return $tco_result; | |
| }; | |
| return go; | |
| }; | |
| }; | |
| // | Unwraps a single layer of `f`, providing the continuation. | |
| var resume$prime = function (k) { | |
| return function (j) { | |
| return function (f) { | |
| var v = toView(f); | |
| if (v instanceof Return) { | |
| return j(v.value0); | |
| }; | |
| if (v instanceof Bind) { | |
| return k(v.value0)(v.value1); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 201, column 17 - line 203, column 20: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| // | Unwraps a single layer of the functor `f`. | |
| var resume = function (dictFunctor) { | |
| return resume$prime(function (g) { | |
| return function (i) { | |
| return new Data_Either.Left(Data_Functor.map(dictFunctor)(i)(g)); | |
| }; | |
| })(Data_Either.Right.create); | |
| }; | |
| var fromView = function (f) { | |
| return new Free(Unsafe_Coerce.unsafeCoerce(f), Data_CatList.empty); | |
| }; | |
| // | Suspend a value given the applicative functor `f` into the free monad. | |
| var suspendF = function (dictApplicative) { | |
| return function (f) { | |
| return fromView(new Bind(Unsafe_Coerce.unsafeCoerce(Control_Applicative.pure(dictApplicative)(f)), Unsafe_Coerce.unsafeCoerce)); | |
| }; | |
| }; | |
| var freeMonad = new Control_Monad.Monad(function () { | |
| return freeApplicative; | |
| }, function () { | |
| return freeBind; | |
| }); | |
| var freeFunctor = new Data_Functor.Functor(function (k) { | |
| return function (f) { | |
| return Control_Bind.bindFlipped(freeBind)(function ($118) { | |
| return Control_Applicative.pure(freeApplicative)(k($118)); | |
| })(f); | |
| }; | |
| }); | |
| var freeBind = new Control_Bind.Bind(function () { | |
| return freeApply; | |
| }, function (v) { | |
| return function (k) { | |
| return new Free(v.value0, Data_CatList.snoc(v.value1)(Unsafe_Coerce.unsafeCoerce(k))); | |
| }; | |
| }); | |
| var freeApply = new Control_Apply.Apply(function () { | |
| return freeFunctor; | |
| }, Control_Monad.ap(freeMonad)); | |
| var freeApplicative = new Control_Applicative.Applicative(function () { | |
| return freeApply; | |
| }, function ($119) { | |
| return fromView(Return.create($119)); | |
| }); | |
| var freeMonadRec = new Control_Monad_Rec_Class.MonadRec(function () { | |
| return freeMonad; | |
| }, function (k) { | |
| return function (a) { | |
| return Control_Bind.bind(freeBind)(k(a))(function (v) { | |
| if (v instanceof Control_Monad_Rec_Class.Loop) { | |
| return Control_Monad_Rec_Class.tailRecM(freeMonadRec)(k)(v.value0); | |
| }; | |
| if (v instanceof Control_Monad_Rec_Class.Done) { | |
| return Control_Applicative.pure(freeApplicative)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 84, column 26 - line 86, column 21: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| }); | |
| // | Lift an impure value described by the generating type constructor `f` into | |
| // | the free monad. | |
| var liftF = function (f) { | |
| return fromView(new Bind(Unsafe_Coerce.unsafeCoerce(f), function ($120) { | |
| return Control_Applicative.pure(freeApplicative)(Unsafe_Coerce.unsafeCoerce($120)); | |
| })); | |
| }; | |
| var freeMonadTrans = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return liftF; | |
| }); | |
| // | Like `foldFree`, but for folding into some other Free monad without the | |
| // | overhead that `MonadRec` incurs. | |
| var substFree = function (k) { | |
| var go = function (f) { | |
| var v = toView(f); | |
| if (v instanceof Return) { | |
| return Control_Applicative.pure(freeApplicative)(v.value0); | |
| }; | |
| if (v instanceof Bind) { | |
| return Control_Bind.bind(freeBind)(k(v.value0))(Data_Functor.map(Data_Functor.functorFn)(go)(v.value1)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 156, column 10 - line 158, column 33: " + [ v.constructor.name ]); | |
| }; | |
| return go; | |
| }; | |
| // | Use a natural transformation to change the generating type constructor of a | |
| // | free monad. | |
| var hoistFree = function (k) { | |
| return substFree(function ($121) { | |
| return liftF(k($121)); | |
| }); | |
| }; | |
| var foldableFree = function (dictFunctor) { | |
| return function (dictFoldable) { | |
| return new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| var go = function ($122) { | |
| return (function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return Data_Foldable.foldMap(dictFoldable)(dictMonoid)(go)(v.value0); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return f(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 91, column 21 - line 93, column 21: " + [ v.constructor.name ]); | |
| })(resume(dictFunctor)($122)); | |
| }; | |
| return go; | |
| }; | |
| }, function (f) { | |
| var go = function (r) { | |
| return function ($123) { | |
| return (function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return Data_Foldable.foldl(dictFoldable)(go)(r)(v.value0); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return f(r)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 96, column 23 - line 98, column 23: " + [ v.constructor.name ]); | |
| })(resume(dictFunctor)($123)); | |
| }; | |
| }; | |
| return go; | |
| }, function (f) { | |
| var go = function (r) { | |
| return function ($124) { | |
| return (function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return Data_Foldable.foldr(dictFoldable)(Data_Function.flip(go))(r)(v.value0); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return f(v.value0)(r); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 101, column 23 - line 103, column 23: " + [ v.constructor.name ]); | |
| })(resume(dictFunctor)($124)); | |
| }; | |
| }; | |
| return go; | |
| }); | |
| }; | |
| }; | |
| var traversableFree = function (dictTraversable) { | |
| return new Data_Traversable.Traversable(function () { | |
| return foldableFree(dictTraversable.Functor0())(dictTraversable.Foldable1()); | |
| }, function () { | |
| return freeFunctor; | |
| }, function (dictApplicative) { | |
| return function (tma) { | |
| return Data_Traversable.traverse(traversableFree(dictTraversable))(dictApplicative)(Control_Category.id(Control_Category.categoryFn))(tma); | |
| }; | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| var go = function ($125) { | |
| return (function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(function ($126) { | |
| return Control_Bind.join(freeBind)(liftF($126)); | |
| })(Data_Traversable.traverse(dictTraversable)(dictApplicative)(go)(v.value0)); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Control_Applicative.pure(freeApplicative))(f(v.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 108, column 21 - line 110, column 30: " + [ v.constructor.name ]); | |
| })(resume(dictTraversable.Functor0())($125)); | |
| }; | |
| return go; | |
| }; | |
| }); | |
| }; | |
| // | Run a free monad with a natural transformation from the type constructor `f` | |
| // | to the tail-recursive monad `m`. See the `MonadRec` type class for more | |
| // | details. | |
| var foldFree = function (dictMonadRec) { | |
| return function (k) { | |
| var go = function (f) { | |
| var v = toView(f); | |
| if (v instanceof Return) { | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(v.value0)); | |
| }; | |
| if (v instanceof Bind) { | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(function ($127) { | |
| return Control_Monad_Rec_Class.Loop.create(v.value1($127)); | |
| })(k(v.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 146, column 10 - line 148, column 37: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); | |
| }; | |
| }; | |
| var eqFree = function (dictFunctor) { | |
| return function (dictEq1) { | |
| return function (dictEq) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| var v = resume(dictFunctor)(y); | |
| var v1 = resume(dictFunctor)(x); | |
| if (v1 instanceof Data_Either.Left && v instanceof Data_Either.Left) { | |
| return Data_Eq.eq1(dictEq1)(eqFree(dictFunctor)(dictEq1)(dictEq))(v1.value0)(v.value0); | |
| }; | |
| if (v1 instanceof Data_Either.Right && v instanceof Data_Either.Right) { | |
| return Data_Eq.eq(dictEq)(v1.value0)(v.value0); | |
| }; | |
| return false; | |
| }; | |
| }); | |
| }; | |
| }; | |
| }; | |
| var ordFree = function (dictFunctor) { | |
| return function (dictOrd1) { | |
| return function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqFree(dictFunctor)(dictOrd1.Eq10())(dictOrd.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| var v = resume(dictFunctor)(y); | |
| var v1 = resume(dictFunctor)(x); | |
| if (v1 instanceof Data_Either.Left && v instanceof Data_Either.Left) { | |
| return Data_Ord.compare1(dictOrd1)(ordFree(dictFunctor)(dictOrd1)(dictOrd))(v1.value0)(v.value0); | |
| }; | |
| if (v1 instanceof Data_Either.Left) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v instanceof Data_Either.Left) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v1 instanceof Data_Either.Right && v instanceof Data_Either.Right) { | |
| return Data_Ord.compare(dictOrd)(v1.value0)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free line 54, column 17 - line 58, column 36: " + [ v1.constructor.name, v.constructor.name ]); | |
| }; | |
| }); | |
| }; | |
| }; | |
| }; | |
| var eq1Free = function (dictFunctor) { | |
| return function (dictEq1) { | |
| return new Data_Eq.Eq1(function (dictEq) { | |
| return Data_Eq.eq(eqFree(dictFunctor)(dictEq1)(dictEq)); | |
| }); | |
| }; | |
| }; | |
| var ord1Free = function (dictFunctor) { | |
| return function (dictOrd1) { | |
| return function (dictOrd) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1Free(dictFunctor)(dictOrd1.Eq10()); | |
| }, function (dictOrd2) { | |
| return Data_Ord.compare(ordFree(dictFunctor)(dictOrd1)(dictOrd2)); | |
| }); | |
| }; | |
| }; | |
| }; | |
| exports["foldFree"] = foldFree; | |
| exports["hoistFree"] = hoistFree; | |
| exports["liftF"] = liftF; | |
| exports["resume"] = resume; | |
| exports["resume'"] = resume$prime; | |
| exports["runFree"] = runFree; | |
| exports["runFreeM"] = runFreeM; | |
| exports["substFree"] = substFree; | |
| exports["suspendF"] = suspendF; | |
| exports["eqFree"] = eqFree; | |
| exports["eq1Free"] = eq1Free; | |
| exports["ordFree"] = ordFree; | |
| exports["ord1Free"] = ord1Free; | |
| exports["freeFunctor"] = freeFunctor; | |
| exports["freeBind"] = freeBind; | |
| exports["freeApplicative"] = freeApplicative; | |
| exports["freeApply"] = freeApply; | |
| exports["freeMonad"] = freeMonad; | |
| exports["freeMonadTrans"] = freeMonadTrans; | |
| exports["freeMonadRec"] = freeMonadRec; | |
| exports["foldableFree"] = foldableFree; | |
| exports["traversableFree"] = traversableFree; | |
| })(PS["Control.Monad.Free"] = PS["Control.Monad.Free"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MonadState` type class and its instances. | |
| "use strict"; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MonadState s` type class represents those monads which support a single piece of mutable | |
| // | state of type `s`. | |
| // | | |
| // | - `state f` updates the state using the function `f`. | |
| // | | |
| // | An implementation is provided for `StateT`, and for other monad transformers | |
| // | defined in this library. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - `do { get ; get } = get` | |
| // | - `do { put x ; put y } = put y` | |
| // | - `do { put x ; get } = put x $> x` | |
| // | - `do { s <- get ; put s } = pure unit` | |
| // | | |
| var MonadState = function (Monad0, state) { | |
| this.Monad0 = Monad0; | |
| this.state = state; | |
| }; | |
| var state = function (dict) { | |
| return dict.state; | |
| }; | |
| // | Set the state. | |
| var put = function (dictMonadState) { | |
| return function (s) { | |
| return state(dictMonadState)(function (v) { | |
| return new Data_Tuple.Tuple(Data_Unit.unit, s); | |
| }); | |
| }; | |
| }; | |
| // | Modify the state by applying a function to the current state. | |
| var modify = function (dictMonadState) { | |
| return function (f) { | |
| return state(dictMonadState)(function (s) { | |
| return new Data_Tuple.Tuple(Data_Unit.unit, f(s)); | |
| }); | |
| }; | |
| }; | |
| // | Get a value which depends on the current state. | |
| var gets = function (dictMonadState) { | |
| return function (f) { | |
| return state(dictMonadState)(function (s) { | |
| return new Data_Tuple.Tuple(f(s), s); | |
| }); | |
| }; | |
| }; | |
| // | Get the current state. | |
| var get = function (dictMonadState) { | |
| return state(dictMonadState)(function (s) { | |
| return new Data_Tuple.Tuple(s, s); | |
| }); | |
| }; | |
| exports["MonadState"] = MonadState; | |
| exports["get"] = get; | |
| exports["gets"] = gets; | |
| exports["modify"] = modify; | |
| exports["put"] = put; | |
| exports["state"] = state; | |
| })(PS["Control.Monad.State.Class"] = PS["Control.Monad.State.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MonadCont` type class and its instances. | |
| "use strict"; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MonadCont` type class represents those monads which support the | |
| // | `callCC`, or _call-with-current-continuation_ operation. | |
| // | | |
| // | This action makes the current continuation available to the caller. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | delay :: forall eff. Number -> ContT Unit (Eff (timeout :: Timeout | eff)) Unit | |
| // | delay n = callCC \cont -> | |
| // | lift $ setTimeout n (runContT (cont unit) (\_ -> return unit)) | |
| // | ``` | |
| // | An implementation is provided for `ContT`, and for other monad transformers | |
| // | defined in this library. | |
| var MonadCont = function (Monad0, callCC) { | |
| this.Monad0 = Monad0; | |
| this.callCC = callCC; | |
| }; | |
| var callCC = function (dict) { | |
| return dict.callCC; | |
| }; | |
| exports["MonadCont"] = MonadCont; | |
| exports["callCC"] = callCC; | |
| })(PS["Control.Monad.Cont.Class"] = PS["Control.Monad.Cont.Class"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| // | The `MonadEff` class captures those monads which support native effects. | |
| // | | |
| // | Instances are provided for `Eff` itself, and the standard monad | |
| // | transformers. | |
| // | | |
| // | `liftEff` can be used in any appropriate monad transformer stack to lift an | |
| // | action of type `Eff eff a` into the monad. | |
| // | | |
| // | Note that `MonadEff` is parameterized by the row of effects, so type | |
| // | inference can be tricky. It is generally recommended to either work with a | |
| // | polymorphic row of effects, or a concrete, closed row of effects such as | |
| // | `(trace :: Trace)`. | |
| var MonadEff = function (Monad0, liftEff) { | |
| this.Monad0 = Monad0; | |
| this.liftEff = liftEff; | |
| }; | |
| var monadEffEff = new MonadEff(function () { | |
| return Control_Monad_Eff.monadEff; | |
| }, Control_Category.id(Control_Category.categoryFn)); | |
| var liftEff = function (dict) { | |
| return dict.liftEff; | |
| }; | |
| exports["MonadEff"] = MonadEff; | |
| exports["liftEff"] = liftEff; | |
| exports["monadEffEff"] = monadEffEff; | |
| })(PS["Control.Monad.Eff.Class"] = PS["Control.Monad.Eff.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MonadError` type class and its instances. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MonadThrow` type class represents those monads which support errors via | |
| // | `throwError`, where `throwError e` halts, yielding the error `e`. | |
| // | | |
| // | An implementation is provided for `ExceptT`, and for other monad transformers | |
| // | defined in this library. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - Left zero: `throwError e >>= f = throwError e` | |
| // | | |
| var MonadThrow = function (Monad0, throwError) { | |
| this.Monad0 = Monad0; | |
| this.throwError = throwError; | |
| }; | |
| // | The `MonadError` type class represents those monads which support catching | |
| // | errors. | |
| // | | |
| // | - `catchError x f` calls the error handler `f` if an error is thrown during the | |
| // | evaluation of `x`. | |
| // | | |
| // | An implementation is provided for `ExceptT`, and for other monad transformers | |
| // | defined in this library. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - Catch: `catchError (throwError e) f = f e` | |
| // | - Pure: `catchError (pure a) f = pure a` | |
| // | | |
| var MonadError = function (MonadThrow0, catchError) { | |
| this.MonadThrow0 = MonadThrow0; | |
| this.catchError = catchError; | |
| }; | |
| var throwError = function (dict) { | |
| return dict.throwError; | |
| }; | |
| var monadThrowMaybe = new MonadThrow(function () { | |
| return Data_Maybe.monadMaybe; | |
| }, Data_Function["const"](Data_Maybe.Nothing.value)); | |
| var monadThrowEither = new MonadThrow(function () { | |
| return Data_Either.monadEither; | |
| }, Data_Either.Left.create); | |
| var monadErrorMaybe = new MonadError(function () { | |
| return monadThrowMaybe; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return v1(Data_Unit.unit); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Error.Class line 76, column 1 - line 76, column 50: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var monadErrorEither = new MonadError(function () { | |
| return monadThrowEither; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof Data_Either.Left) { | |
| return v1(v.value0); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return new Data_Either.Right(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Error.Class line 69, column 1 - line 69, column 53: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| var catchError = function (dict) { | |
| return dict.catchError; | |
| }; | |
| // | This function allows you to provide a predicate for selecting the | |
| // | exceptions that you're interested in, and handle only those exceptons. | |
| // | If the inner computation throws an exception, and the predicate returns | |
| // | Nothing, then the whole computation will still fail with that exception. | |
| var catchJust = function (dictMonadError) { | |
| return function (p) { | |
| return function (act) { | |
| return function (handler) { | |
| var handle = function (e) { | |
| var v = p(e); | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return throwError(dictMonadError.MonadThrow0())(e); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return handler(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Error.Class line 54, column 5 - line 56, column 26: " + [ v.constructor.name ]); | |
| }; | |
| return catchError(dictMonadError)(act)(handle); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Return `Right` if the given action succeeds, `Left` if it throws. | |
| var $$try = function (dictMonadError) { | |
| return function (a) { | |
| return catchError(dictMonadError)(Data_Functor.map(((((dictMonadError.MonadThrow0()).Monad0()).Bind1()).Apply0()).Functor0())(Data_Either.Right.create)(a))(function ($21) { | |
| return Control_Applicative.pure(((dictMonadError.MonadThrow0()).Monad0()).Applicative0())(Data_Either.Left.create($21)); | |
| }); | |
| }; | |
| }; | |
| // | Make sure that a resource is cleaned up in the event of an exception. The | |
| // | release action is called regardless of whether the body action throws or | |
| // | returns. | |
| var withResource = function (dictMonadError) { | |
| return function (acquire) { | |
| return function (release) { | |
| return function (kleisli) { | |
| return Control_Bind.bind(((dictMonadError.MonadThrow0()).Monad0()).Bind1())(acquire)(function (v) { | |
| return Control_Bind.bind(((dictMonadError.MonadThrow0()).Monad0()).Bind1())($$try(dictMonadError)(kleisli(v)))(function (v1) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)(((dictMonadError.MonadThrow0()).Monad0()).Bind1())(release(v))(function () { | |
| return Data_Either.either(throwError(dictMonadError.MonadThrow0()))(Control_Applicative.pure(((dictMonadError.MonadThrow0()).Monad0()).Applicative0()))(v1); | |
| }); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["MonadError"] = MonadError; | |
| exports["MonadThrow"] = MonadThrow; | |
| exports["catchError"] = catchError; | |
| exports["catchJust"] = catchJust; | |
| exports["throwError"] = throwError; | |
| exports["try"] = $$try; | |
| exports["withResource"] = withResource; | |
| exports["monadThrowEither"] = monadThrowEither; | |
| exports["monadErrorEither"] = monadErrorEither; | |
| exports["monadThrowMaybe"] = monadThrowMaybe; | |
| exports["monadErrorMaybe"] = monadErrorMaybe; | |
| })(PS["Control.Monad.Error.Class"] = PS["Control.Monad.Error.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MonadReader` type class and its instances. | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MonadAsk` type class represents those monads which support a global | |
| // | context that can be provided via the `ask` function. | |
| // | | |
| // | An implementation is provided for `ReaderT`, and for other monad | |
| // | transformers defined in this library. | |
| // | | |
| // | Law: | |
| // | | |
| // | - `do { ask ; ask } = ask` | |
| var MonadAsk = function (Monad0, ask) { | |
| this.Monad0 = Monad0; | |
| this.ask = ask; | |
| }; | |
| // | An extension of the `MonadAsk` class that introduces a function `local f x` | |
| // | that allows the value of the local context to be modified for the duration | |
| // | of the execution of action `x`. | |
| // | | |
| // | An implementation is provided for `ReaderT`, and for other monad | |
| // | transformers defined in this library. | |
| // | | |
| // | Laws in addition to the `MonadAsk` law: | |
| // | | |
| // | - `local f ask = f <$> ask` | |
| // | - `local _ (pure a) = pure a` | |
| // | - `local f (do { a <- x ; y }) = do { a <- local f x ; local f y }` | |
| var MonadReader = function (MonadAsk0, local) { | |
| this.MonadAsk0 = MonadAsk0; | |
| this.local = local; | |
| }; | |
| var monadAskFun = new MonadAsk(function () { | |
| return Control_Monad.monadFn; | |
| }, Control_Category.id(Control_Category.categoryFn)); | |
| var monadReaderFun = new MonadReader(function () { | |
| return monadAskFun; | |
| }, Control_Semigroupoid.composeFlipped(Control_Semigroupoid.semigroupoidFn)); | |
| var local = function (dict) { | |
| return dict.local; | |
| }; | |
| var ask = function (dict) { | |
| return dict.ask; | |
| }; | |
| // | Projects a value from the global context in a `MonadAsk`. | |
| var asks = function (dictMonadAsk) { | |
| return function (f) { | |
| return Data_Functor.map((((dictMonadAsk.Monad0()).Bind1()).Apply0()).Functor0())(f)(ask(dictMonadAsk)); | |
| }; | |
| }; | |
| exports["MonadAsk"] = MonadAsk; | |
| exports["MonadReader"] = MonadReader; | |
| exports["ask"] = ask; | |
| exports["asks"] = asks; | |
| exports["local"] = local; | |
| exports["monadAskFun"] = monadAskFun; | |
| exports["monadReaderFun"] = monadReaderFun; | |
| })(PS["Control.Monad.Reader.Class"] = PS["Control.Monad.Reader.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MonadWriter` type class and its instances. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MonadTell w` type class represents those monads which support a | |
| // | monoidal accumulator of type `w`, were `tell` appends a value to the | |
| // | accumulator. | |
| // | | |
| // | An implementation is provided for `WriterT`, and for other monad | |
| // | transformers defined in this library. | |
| // | | |
| // | Law: | |
| // | | |
| // | - `do { tell x ; tell y } = tell (x <> y)` | |
| var MonadTell = function (Monad0, tell) { | |
| this.Monad0 = Monad0; | |
| this.tell = tell; | |
| }; | |
| // | An extension of the `MonadTell` class that introduces some operations on | |
| // | the accumulator: | |
| // | | |
| // | - `listen` modifies the result to include the changes to the accumulator. | |
| // | - `pass` applies the returned function to the accumulator. | |
| // | | |
| // | An implementation is provided for `WriterT`, and for other monad | |
| // | transformers defined in this library. | |
| // | | |
| // | Laws in addition to the `MonadTell` law: | |
| // | | |
| // | - `do { tell x ; tell y } = tell (x <> y)` | |
| // | - `listen (pure a) = pure (Tuple a mempty)` | |
| // | - `listen (writer a x) = tell x $> Tuple a x` | |
| var MonadWriter = function (MonadTell0, listen, pass) { | |
| this.MonadTell0 = MonadTell0; | |
| this.listen = listen; | |
| this.pass = pass; | |
| }; | |
| var tell = function (dict) { | |
| return dict.tell; | |
| }; | |
| var pass = function (dict) { | |
| return dict.pass; | |
| }; | |
| var listen = function (dict) { | |
| return dict.listen; | |
| }; | |
| // | Projects a value from modifications made to the accumulator during an | |
| // | action. | |
| var listens = function (dictMonadWriter) { | |
| return function (f) { | |
| return function (m) { | |
| return Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(listen(dictMonadWriter)(m))(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())(new Data_Tuple.Tuple(v.value0, f(v.value1))); | |
| }); | |
| }; | |
| }; | |
| }; | |
| // | Modify the final accumulator value by applying a function. | |
| var censor = function (dictMonadWriter) { | |
| return function (f) { | |
| return function (m) { | |
| return pass(dictMonadWriter)(Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(m)(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())(new Data_Tuple.Tuple(v, f)); | |
| })); | |
| }; | |
| }; | |
| }; | |
| exports["MonadTell"] = MonadTell; | |
| exports["MonadWriter"] = MonadWriter; | |
| exports["censor"] = censor; | |
| exports["listen"] = listen; | |
| exports["listens"] = listens; | |
| exports["pass"] = pass; | |
| exports["tell"] = tell; | |
| })(PS["Control.Monad.Writer.Class"] = PS["Control.Monad.Writer.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the state monad transformer, `StateT`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The state monad transformer. | |
| // | | |
| // | This monad transformer extends the base monad with the operations `get` | |
| // | and `put` which can be used to model a single piece of mutable state. | |
| // | | |
| // | The `MonadState` type class describes the operations supported by this monad. | |
| var StateT = function (x) { | |
| return x; | |
| }; | |
| // | Modify the final state in a `StateT` monad action. | |
| var withStateT = function (f) { | |
| return function (v) { | |
| return function ($107) { | |
| return v(f($107)); | |
| }; | |
| }; | |
| }; | |
| // | Run a computation in the `StateT` monad. | |
| var runStateT = function (v) { | |
| return v; | |
| }; | |
| var newtypeStateT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, StateT); | |
| var monadTransStateT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function (m) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m)(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v, s)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| // | Change the result type in a `StateT` monad action. | |
| var mapStateT = function (f) { | |
| return function (v) { | |
| return function ($108) { | |
| return f(v($108)); | |
| }; | |
| }; | |
| }; | |
| var lazyStateT = new Control_Lazy.Lazy(function (f) { | |
| return function (s) { | |
| var v = f(Data_Unit.unit); | |
| return v(s); | |
| }; | |
| }); | |
| var functorStateT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return function (s) { | |
| return Data_Functor.map(dictFunctor)(function (v1) { | |
| return new Data_Tuple.Tuple(f(v1.value0), v1.value1); | |
| })(v(s)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | Run a computation in the `StateT` monad discarding the result. | |
| var execStateT = function (dictFunctor) { | |
| return function (v) { | |
| return function (s) { | |
| return Data_Functor.map(dictFunctor)(Data_Tuple.snd)(v(s)); | |
| }; | |
| }; | |
| }; | |
| // | Run a computation in the `StateT` monad, discarding the final state. | |
| var evalStateT = function (dictFunctor) { | |
| return function (v) { | |
| return function (s) { | |
| return Data_Functor.map(dictFunctor)(Data_Tuple.fst)(v(s)); | |
| }; | |
| }; | |
| }; | |
| var monadStateT = function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeStateT(dictMonad); | |
| }, function () { | |
| return bindStateT(dictMonad); | |
| }); | |
| }; | |
| var bindStateT = function (dictMonad) { | |
| return new Control_Bind.Bind(function () { | |
| return applyStateT(dictMonad); | |
| }, function (v) { | |
| return function (f) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v(s))(function (v1) { | |
| var v3 = f(v1.value0); | |
| return v3(v1.value1); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var applyStateT = function (dictMonad) { | |
| return new Control_Apply.Apply(function () { | |
| return functorStateT(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, Control_Monad.ap(monadStateT(dictMonad))); | |
| }; | |
| var applicativeStateT = function (dictMonad) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyStateT(dictMonad); | |
| }, function (a) { | |
| return function (s) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(a, s)); | |
| }; | |
| }); | |
| }; | |
| var monadAskStateT = function (dictMonadAsk) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadStateT(dictMonadAsk.Monad0()); | |
| }, Control_Monad_Trans_Class.lift(monadTransStateT)(dictMonadAsk.Monad0())(Control_Monad_Reader_Class.ask(dictMonadAsk))); | |
| }; | |
| var monadReaderStateT = function (dictMonadReader) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskStateT(dictMonadReader.MonadAsk0()); | |
| }, function ($109) { | |
| return mapStateT(Control_Monad_Reader_Class.local(dictMonadReader)($109)); | |
| }); | |
| }; | |
| var monadContStateT = function (dictMonadCont) { | |
| return new Control_Monad_Cont_Class.MonadCont(function () { | |
| return monadStateT(dictMonadCont.Monad0()); | |
| }, function (f) { | |
| return function (s) { | |
| return Control_Monad_Cont_Class.callCC(dictMonadCont)(function (c) { | |
| var v = f(function (a) { | |
| return function (s$prime) { | |
| return c(new Data_Tuple.Tuple(a, s$prime)); | |
| }; | |
| }); | |
| return v(s); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var monadEffState = function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadStateT(dictMonadEff.Monad0()); | |
| }, function ($110) { | |
| return Control_Monad_Trans_Class.lift(monadTransStateT)(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($110)); | |
| }); | |
| }; | |
| var monadRecStateT = function (dictMonadRec) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadStateT(dictMonadRec.Monad0()); | |
| }, function (f) { | |
| return function (a) { | |
| var f$prime = function (v) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())((function () { | |
| var v1 = f(v.value0); | |
| return v1; | |
| })()(v.value1))(function (v1) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())((function () { | |
| if (v1.value0 instanceof Control_Monad_Rec_Class.Loop) { | |
| return new Control_Monad_Rec_Class.Loop(new Data_Tuple.Tuple(v1.value0.value0, v1.value1)); | |
| }; | |
| if (v1.value0 instanceof Control_Monad_Rec_Class.Done) { | |
| return new Control_Monad_Rec_Class.Done(new Data_Tuple.Tuple(v1.value0.value0, v1.value1)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.State.Trans line 88, column 16 - line 90, column 40: " + [ v1.value0.constructor.name ]); | |
| })()); | |
| }); | |
| }; | |
| return function (s) { | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(f$prime)(new Data_Tuple.Tuple(a, s)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var monadStateStateT = function (dictMonad) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadStateT(dictMonad); | |
| }, function (f) { | |
| return StateT(function ($111) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(f($111)); | |
| }); | |
| }); | |
| }; | |
| var monadTellStateT = function (dictMonadTell) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadStateT(dictMonadTell.Monad0()); | |
| }, function ($112) { | |
| return Control_Monad_Trans_Class.lift(monadTransStateT)(dictMonadTell.Monad0())(Control_Monad_Writer_Class.tell(dictMonadTell)($112)); | |
| }); | |
| }; | |
| var monadWriterStateT = function (dictMonadWriter) { | |
| return new Control_Monad_Writer_Class.MonadWriter(function () { | |
| return monadTellStateT(dictMonadWriter.MonadTell0()); | |
| }, function (m) { | |
| return function (s) { | |
| return Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(Control_Monad_Writer_Class.listen(dictMonadWriter)(m(s)))(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())(new Data_Tuple.Tuple(new Data_Tuple.Tuple(v.value0.value0, v.value1), v.value0.value1)); | |
| }); | |
| }; | |
| }, function (m) { | |
| return function (s) { | |
| return Control_Monad_Writer_Class.pass(dictMonadWriter)(Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(m(s))(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())(new Data_Tuple.Tuple(new Data_Tuple.Tuple(v.value0.value0, v.value1), v.value0.value1)); | |
| })); | |
| }; | |
| }); | |
| }; | |
| var monadThrowStateT = function (dictMonadThrow) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadStateT(dictMonadThrow.Monad0()); | |
| }, function (e) { | |
| return Control_Monad_Trans_Class.lift(monadTransStateT)(dictMonadThrow.Monad0())(Control_Monad_Error_Class.throwError(dictMonadThrow)(e)); | |
| }); | |
| }; | |
| var monadErrorStateT = function (dictMonadError) { | |
| return new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowStateT(dictMonadError.MonadThrow0()); | |
| }, function (v) { | |
| return function (h) { | |
| return function (s) { | |
| return Control_Monad_Error_Class.catchError(dictMonadError)(v(s))(function (e) { | |
| var v1 = h(e); | |
| return v1(s); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var altStateT = function (dictMonad) { | |
| return function (dictAlt) { | |
| return new Control_Alt.Alt(function () { | |
| return functorStateT(dictAlt.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return function (s) { | |
| return Control_Alt.alt(dictAlt)(v(s))(v1(s)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var plusStateT = function (dictMonad) { | |
| return function (dictPlus) { | |
| return new Control_Plus.Plus(function () { | |
| return altStateT(dictMonad)(dictPlus.Alt0()); | |
| }, function (v) { | |
| return Control_Plus.empty(dictPlus); | |
| }); | |
| }; | |
| }; | |
| var alternativeStateT = function (dictMonad) { | |
| return function (dictAlternative) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeStateT(dictMonad); | |
| }, function () { | |
| return plusStateT(dictMonad)(dictAlternative.Plus1()); | |
| }); | |
| }; | |
| }; | |
| var monadZeroStateT = function (dictMonadZero) { | |
| return new Control_MonadZero.MonadZero(function () { | |
| return alternativeStateT(dictMonadZero.Monad0())(dictMonadZero.Alternative1()); | |
| }, function () { | |
| return monadStateT(dictMonadZero.Monad0()); | |
| }); | |
| }; | |
| var monadPlusStateT = function (dictMonadPlus) { | |
| return new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroStateT(dictMonadPlus.MonadZero0()); | |
| }); | |
| }; | |
| exports["StateT"] = StateT; | |
| exports["evalStateT"] = evalStateT; | |
| exports["execStateT"] = execStateT; | |
| exports["mapStateT"] = mapStateT; | |
| exports["runStateT"] = runStateT; | |
| exports["withStateT"] = withStateT; | |
| exports["newtypeStateT"] = newtypeStateT; | |
| exports["functorStateT"] = functorStateT; | |
| exports["applyStateT"] = applyStateT; | |
| exports["applicativeStateT"] = applicativeStateT; | |
| exports["altStateT"] = altStateT; | |
| exports["plusStateT"] = plusStateT; | |
| exports["alternativeStateT"] = alternativeStateT; | |
| exports["bindStateT"] = bindStateT; | |
| exports["monadStateT"] = monadStateT; | |
| exports["monadRecStateT"] = monadRecStateT; | |
| exports["monadZeroStateT"] = monadZeroStateT; | |
| exports["monadPlusStateT"] = monadPlusStateT; | |
| exports["monadTransStateT"] = monadTransStateT; | |
| exports["lazyStateT"] = lazyStateT; | |
| exports["monadEffState"] = monadEffState; | |
| exports["monadContStateT"] = monadContStateT; | |
| exports["monadThrowStateT"] = monadThrowStateT; | |
| exports["monadErrorStateT"] = monadErrorStateT; | |
| exports["monadAskStateT"] = monadAskStateT; | |
| exports["monadReaderStateT"] = monadReaderStateT; | |
| exports["monadStateStateT"] = monadStateStateT; | |
| exports["monadTellStateT"] = monadTellStateT; | |
| exports["monadWriterStateT"] = monadWriterStateT; | |
| })(PS["Control.Monad.State.Trans"] = PS["Control.Monad.State.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the `State` monad. | |
| "use strict"; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_State_Trans = PS["Control.Monad.State.Trans"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Modify the state in a `State` action | |
| var withState = Control_Monad_State_Trans.withStateT; | |
| // | Run a computation in the `State` monad | |
| var runState = function (v) { | |
| return function ($16) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(v($16)); | |
| }; | |
| }; | |
| // | Change the type of the result in a `State` action | |
| var mapState = function (f) { | |
| return Control_Monad_State_Trans.mapStateT(function ($17) { | |
| return Data_Identity.Identity(f(Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($17))); | |
| }); | |
| }; | |
| // | Run a computation in the `State` monad, discarding the result | |
| var execState = function (v) { | |
| return function (s) { | |
| var v1 = v(s); | |
| return v1.value1; | |
| }; | |
| }; | |
| // | Run a computation in the `State` monad, discarding the final state | |
| var evalState = function (v) { | |
| return function (s) { | |
| var v1 = v(s); | |
| return v1.value0; | |
| }; | |
| }; | |
| exports["evalState"] = evalState; | |
| exports["execState"] = execState; | |
| exports["mapState"] = mapState; | |
| exports["runState"] = runState; | |
| exports["withState"] = withState; | |
| })(PS["Control.Monad.State"] = PS["Control.Monad.State"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.defer = function () { | |
| function Defer(thunk) { | |
| if (this instanceof Defer) { | |
| this.thunk = thunk; | |
| return this; | |
| } else { | |
| return new Defer(thunk); | |
| } | |
| } | |
| Defer.prototype.force = function () { | |
| var value = this.thunk(); | |
| this.thunk = null; | |
| this.force = function () { | |
| return value; | |
| }; | |
| return value; | |
| }; | |
| return Defer; | |
| }(); | |
| exports.force = function (l) { | |
| return l.force(); | |
| }; | |
| })(PS["Data.Lazy"] = PS["Data.Lazy"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Lazy"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Field = PS["Data.Field"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| var showLazy = function (dictShow) { | |
| return new Data_Show.Show(function (x) { | |
| return "(defer \\_ -> " + (Data_Show.show(dictShow)($foreign.force(x)) + ")"); | |
| }); | |
| }; | |
| var semiringLazy = function (dictSemiring) { | |
| return new Data_Semiring.Semiring(function (a) { | |
| return function (b) { | |
| return $foreign.defer(function (v) { | |
| return Data_Semiring.add(dictSemiring)($foreign.force(a))($foreign.force(b)); | |
| }); | |
| }; | |
| }, function (a) { | |
| return function (b) { | |
| return $foreign.defer(function (v) { | |
| return Data_Semiring.mul(dictSemiring)($foreign.force(a))($foreign.force(b)); | |
| }); | |
| }; | |
| }, $foreign.defer(function (v) { | |
| return Data_Semiring.one(dictSemiring); | |
| }), $foreign.defer(function (v) { | |
| return Data_Semiring.zero(dictSemiring); | |
| })); | |
| }; | |
| var semigroupLazy = function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(function (a) { | |
| return function (b) { | |
| return $foreign.defer(function (v) { | |
| return Data_Semigroup.append(dictSemigroup)($foreign.force(a))($foreign.force(b)); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var ringLazy = function (dictRing) { | |
| return new Data_Ring.Ring(function () { | |
| return semiringLazy(dictRing.Semiring0()); | |
| }, function (a) { | |
| return function (b) { | |
| return $foreign.defer(function (v) { | |
| return Data_Ring.sub(dictRing)($foreign.force(a))($foreign.force(b)); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var monoidLazy = function (dictMonoid) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupLazy(dictMonoid.Semigroup0()); | |
| }, $foreign.defer(function (v) { | |
| return Data_Monoid.mempty(dictMonoid); | |
| })); | |
| }; | |
| var lazyLazy = new Control_Lazy.Lazy(function (f) { | |
| return $foreign.defer(function (v) { | |
| return $foreign.force(f(Data_Unit.unit)); | |
| }); | |
| }); | |
| var functorLazy = new Data_Functor.Functor(function (f) { | |
| return function (l) { | |
| return $foreign.defer(function (v) { | |
| return f($foreign.force(l)); | |
| }); | |
| }; | |
| }); | |
| var invariantLazy = new Data_Functor_Invariant.Invariant(Data_Functor_Invariant.imapF(functorLazy)); | |
| var extendLazy = new Control_Extend.Extend(function () { | |
| return functorLazy; | |
| }, function (f) { | |
| return function (x) { | |
| return $foreign.defer(function (v) { | |
| return f(x); | |
| }); | |
| }; | |
| }); | |
| var eqLazy = function (dictEq) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(dictEq)($foreign.force(x))($foreign.force(y)); | |
| }; | |
| }); | |
| }; | |
| var ordLazy = function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqLazy(dictOrd.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ord.compare(dictOrd)($foreign.force(x))($foreign.force(y)); | |
| }; | |
| }); | |
| }; | |
| var comonadLazy = new Control_Comonad.Comonad(function () { | |
| return extendLazy; | |
| }, $foreign.force); | |
| var commutativeRingLazy = function (dictCommutativeRing) { | |
| return new Data_CommutativeRing.CommutativeRing(function () { | |
| return ringLazy(dictCommutativeRing.Ring0()); | |
| }); | |
| }; | |
| var euclideanRingLazy = function (dictEuclideanRing) { | |
| return new Data_EuclideanRing.EuclideanRing(function () { | |
| return commutativeRingLazy(dictEuclideanRing.CommutativeRing0()); | |
| }, function ($32) { | |
| return Data_EuclideanRing.degree(dictEuclideanRing)($foreign.force($32)); | |
| }, function (a) { | |
| return function (b) { | |
| return $foreign.defer(function (v) { | |
| return Data_EuclideanRing.div(dictEuclideanRing)($foreign.force(a))($foreign.force(b)); | |
| }); | |
| }; | |
| }, function (a) { | |
| return function (b) { | |
| return $foreign.defer(function (v) { | |
| return Data_EuclideanRing.mod(dictEuclideanRing)($foreign.force(a))($foreign.force(b)); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var fieldLazy = function (dictField) { | |
| return new Data_Field.Field(function () { | |
| return euclideanRingLazy(dictField.EuclideanRing0()); | |
| }); | |
| }; | |
| var boundedLazy = function (dictBounded) { | |
| return new Data_Bounded.Bounded(function () { | |
| return ordLazy(dictBounded.Ord0()); | |
| }, $foreign.defer(function (v) { | |
| return Data_Bounded.bottom(dictBounded); | |
| }), $foreign.defer(function (v) { | |
| return Data_Bounded.top(dictBounded); | |
| })); | |
| }; | |
| var applyLazy = new Control_Apply.Apply(function () { | |
| return functorLazy; | |
| }, function (f) { | |
| return function (x) { | |
| return $foreign.defer(function (v) { | |
| return $foreign.force(f)($foreign.force(x)); | |
| }); | |
| }; | |
| }); | |
| var bindLazy = new Control_Bind.Bind(function () { | |
| return applyLazy; | |
| }, function (l) { | |
| return function (f) { | |
| return $foreign.defer(function (v) { | |
| return $foreign.force(f($foreign.force(l))); | |
| }); | |
| }; | |
| }); | |
| var heytingAlgebraLazy = function (dictHeytingAlgebra) { | |
| return new Data_HeytingAlgebra.HeytingAlgebra(function (a) { | |
| return function (b) { | |
| return Control_Apply.apply(applyLazy)(Data_Functor.map(functorLazy)(Data_HeytingAlgebra.conj(dictHeytingAlgebra))(a))(b); | |
| }; | |
| }, function (a) { | |
| return function (b) { | |
| return Control_Apply.apply(applyLazy)(Data_Functor.map(functorLazy)(Data_HeytingAlgebra.disj(dictHeytingAlgebra))(a))(b); | |
| }; | |
| }, $foreign.defer(function (v) { | |
| return Data_HeytingAlgebra.ff(dictHeytingAlgebra); | |
| }), function (a) { | |
| return function (b) { | |
| return Control_Apply.apply(applyLazy)(Data_Functor.map(functorLazy)(Data_HeytingAlgebra.implies(dictHeytingAlgebra))(a))(b); | |
| }; | |
| }, function (a) { | |
| return Data_Functor.map(functorLazy)(Data_HeytingAlgebra.not(dictHeytingAlgebra))(a); | |
| }, $foreign.defer(function (v) { | |
| return Data_HeytingAlgebra.tt(dictHeytingAlgebra); | |
| })); | |
| }; | |
| var booleanAlgebraLazy = function (dictBooleanAlgebra) { | |
| return new Data_BooleanAlgebra.BooleanAlgebra(function () { | |
| return heytingAlgebraLazy(dictBooleanAlgebra.HeytingAlgebra0()); | |
| }); | |
| }; | |
| var applicativeLazy = new Control_Applicative.Applicative(function () { | |
| return applyLazy; | |
| }, function (a) { | |
| return $foreign.defer(function (v) { | |
| return a; | |
| }); | |
| }); | |
| var monadLazy = new Control_Monad.Monad(function () { | |
| return applicativeLazy; | |
| }, function () { | |
| return bindLazy; | |
| }); | |
| exports["semiringLazy"] = semiringLazy; | |
| exports["ringLazy"] = ringLazy; | |
| exports["commutativeRingLazy"] = commutativeRingLazy; | |
| exports["euclideanRingLazy"] = euclideanRingLazy; | |
| exports["fieldLazy"] = fieldLazy; | |
| exports["eqLazy"] = eqLazy; | |
| exports["ordLazy"] = ordLazy; | |
| exports["boundedLazy"] = boundedLazy; | |
| exports["semigroupLazy"] = semigroupLazy; | |
| exports["monoidLazy"] = monoidLazy; | |
| exports["heytingAlgebraLazy"] = heytingAlgebraLazy; | |
| exports["booleanAlgebraLazy"] = booleanAlgebraLazy; | |
| exports["functorLazy"] = functorLazy; | |
| exports["invariantLazy"] = invariantLazy; | |
| exports["applyLazy"] = applyLazy; | |
| exports["applicativeLazy"] = applicativeLazy; | |
| exports["bindLazy"] = bindLazy; | |
| exports["monadLazy"] = monadLazy; | |
| exports["extendLazy"] = extendLazy; | |
| exports["comonadLazy"] = comonadLazy; | |
| exports["showLazy"] = showLazy; | |
| exports["lazyLazy"] = lazyLazy; | |
| exports["defer"] = $foreign.defer; | |
| exports["force"] = $foreign.force; | |
| })(PS["Data.Lazy"] = PS["Data.Lazy"] || {}); | |
| (function(exports) { | |
| // | The _cofree comonad_ for a `Functor`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Free = PS["Control.Monad.Free"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State = PS["Control.Monad.State"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_State_Trans = PS["Control.Monad.State.Trans"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Lazy = PS["Data.Lazy"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `Cofree` `Comonad` for a functor. | |
| // | | |
| // | A value of type `Cofree f a` consists of an `f`-branching | |
| // | tree, annotated with labels of type `a`. | |
| // | | |
| // | The `Comonad` instance supports _redecoration_, recomputing | |
| // | labels from the local context. | |
| var Cofree = (function () { | |
| function Cofree(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Cofree.create = function (value0) { | |
| return function (value1) { | |
| return new Cofree(value0, value1); | |
| }; | |
| }; | |
| return Cofree; | |
| })(); | |
| var unfoldCofree = function (dictFunctor) { | |
| return function (e) { | |
| return function (n) { | |
| return function (s) { | |
| return new Cofree(e(s), Data_Lazy.defer(function (v) { | |
| return Data_Functor.map(dictFunctor)(unfoldCofree(dictFunctor)(e)(n))(n(s)); | |
| })); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Returns the "subtrees" of a tree. | |
| var tail = function (v) { | |
| return Data_Lazy.force(v.value1); | |
| }; | |
| // | Create a value of type `Cofree f a` from a label and a | |
| // | functor-full of "subtrees". | |
| var mkCofree = function (a) { | |
| return function (t) { | |
| return new Cofree(a, Data_Lazy.defer(function (v) { | |
| return t; | |
| })); | |
| }; | |
| }; | |
| // | Returns the label for a tree. | |
| var head = function (v) { | |
| return v.value0; | |
| }; | |
| var hoistCofree = function (dictFunctor) { | |
| return function (nat) { | |
| return function (cf) { | |
| return mkCofree(head(cf))(nat(Data_Functor.map(dictFunctor)(hoistCofree(dictFunctor)(nat))(tail(cf)))); | |
| }; | |
| }; | |
| }; | |
| var foldableCofree = function (dictFoldable) { | |
| return new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| var go = function (fa) { | |
| return Data_Semigroup.append(dictMonoid.Semigroup0())(f(head(fa)))(Data_Foldable.foldMap(dictFoldable)(dictMonoid)(go)(tail(fa))); | |
| }; | |
| return go; | |
| }; | |
| }, function (f) { | |
| var go = function (b) { | |
| return function (fa) { | |
| return Data_Foldable.foldl(dictFoldable)(go)(f(b)(head(fa)))(tail(fa)); | |
| }; | |
| }; | |
| return go; | |
| }, function (f) { | |
| var go = function (fa) { | |
| return function (b) { | |
| return f(head(fa))(Data_Foldable.foldr(dictFoldable)(go)(b)(tail(fa))); | |
| }; | |
| }; | |
| return Data_Function.flip(go); | |
| }); | |
| }; | |
| var eqCofree = function (dictEq1) { | |
| return function (dictEq) { | |
| return new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(dictEq)(head(x))(head(y)) && Data_Eq.eq1(dictEq1)(eqCofree(dictEq1)(dictEq))(tail(x))(tail(y)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var ordCofree = function (dictOrd1) { | |
| return function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqCofree(dictOrd1.Eq10())(dictOrd.Eq0()); | |
| }, function (x) { | |
| return function (y) { | |
| var v = Data_Ord.compare(dictOrd)(head(x))(head(y)); | |
| if (v instanceof Data_Ordering.EQ) { | |
| return Data_Ord.compare1(dictOrd1)(ordCofree(dictOrd1)(dictOrd))(tail(x))(tail(y)); | |
| }; | |
| return v; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var eq1Cofree = function (dictEq1) { | |
| return new Data_Eq.Eq1(function (dictEq) { | |
| return Data_Eq.eq(eqCofree(dictEq1)(dictEq)); | |
| }); | |
| }; | |
| var ord1Cofree = function (dictOrd1) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1Cofree(dictOrd1.Eq10()); | |
| }, function (dictOrd) { | |
| return Data_Ord.compare(ordCofree(dictOrd1)(dictOrd)); | |
| }); | |
| }; | |
| var _tail = function (v) { | |
| return v.value1; | |
| }; | |
| var _lift = function (dictFunctor) { | |
| return function ($53) { | |
| return Data_Functor.map(Data_Lazy.functorLazy)(Data_Functor.map(dictFunctor)($53)); | |
| }; | |
| }; | |
| var functorCofree = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| var loop = function (fa) { | |
| return new Cofree(f(head(fa)), _lift(dictFunctor)(loop)(_tail(fa))); | |
| }; | |
| return loop; | |
| }); | |
| }; | |
| var monadCofree = function (dictAlternative) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeCofree(dictAlternative); | |
| }, function () { | |
| return bindCofree(dictAlternative); | |
| }); | |
| }; | |
| var bindCofree = function (dictAlternative) { | |
| return new Control_Bind.Bind(function () { | |
| return applyCofree(dictAlternative); | |
| }, function (fa) { | |
| return function (f) { | |
| var loop = function (fa$prime) { | |
| var fh = f(head(fa$prime)); | |
| return mkCofree(head(fh))(Control_Alt.alt((dictAlternative.Plus1()).Alt0())(tail(fh))(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())(loop)(tail(fa$prime)))); | |
| }; | |
| return loop(fa); | |
| }; | |
| }); | |
| }; | |
| var applyCofree = function (dictAlternative) { | |
| return new Control_Apply.Apply(function () { | |
| return functorCofree(((dictAlternative.Plus1()).Alt0()).Functor0()); | |
| }, Control_Monad.ap(monadCofree(dictAlternative))); | |
| }; | |
| var applicativeCofree = function (dictAlternative) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyCofree(dictAlternative); | |
| }, function (a) { | |
| return mkCofree(a)(Control_Plus.empty(dictAlternative.Plus1())); | |
| }); | |
| }; | |
| var extendCofree = function (dictFunctor) { | |
| return new Control_Extend.Extend(function () { | |
| return functorCofree(dictFunctor); | |
| }, function (f) { | |
| var loop = function (fa) { | |
| return new Cofree(f(fa), _lift(dictFunctor)(loop)(_tail(fa))); | |
| }; | |
| return loop; | |
| }); | |
| }; | |
| var comonadCofree = function (dictFunctor) { | |
| return new Control_Comonad.Comonad(function () { | |
| return extendCofree(dictFunctor); | |
| }, head); | |
| }; | |
| // | Explore a value in the cofree comonad by using an expression in a | |
| // | corresponding free monad. | |
| // | | |
| // | The free monad should be built from a functor which pairs with the | |
| // | functor underlying the cofree comonad. | |
| var explore = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (pair) { | |
| return function (m) { | |
| return function (w) { | |
| var step = function (ff) { | |
| return Control_Monad_State_Class.state(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity))(function (cof) { | |
| return pair(Data_Functor.map(dictFunctor)(Data_Tuple.Tuple.create)(ff))(tail(cof)); | |
| }); | |
| }; | |
| var v = Control_Monad_State.runState(Control_Monad_Free.runFreeM(dictFunctor)(Control_Monad_State_Trans.monadRecStateT(Control_Monad_Rec_Class.monadRecIdentity))(step)(m))(w); | |
| return v.value0(Control_Comonad.extract(comonadCofree(dictFunctor1))(v.value1)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var exploreM = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictMonadRec) { | |
| return function (pair) { | |
| return function (m) { | |
| return function (w) { | |
| var step = function (ff) { | |
| return function (cof) { | |
| return pair(Data_Functor.map(dictFunctor)(Data_Tuple.Tuple.create)(ff))(tail(cof)); | |
| }; | |
| }; | |
| var $$eval = function (v) { | |
| return v.value0(Control_Comonad.extract(comonadCofree(dictFunctor1))(v.value1)); | |
| }; | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())($$eval)(Control_Monad_State_Trans.runStateT(Control_Monad_Free.runFreeM(dictFunctor)(Control_Monad_State_Trans.monadRecStateT(dictMonadRec))(step)(m))(w)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var traversableCofree = function (dictTraversable) { | |
| return new Data_Traversable.Traversable(function () { | |
| return foldableCofree(dictTraversable.Foldable1()); | |
| }, function () { | |
| return functorCofree(dictTraversable.Functor0()); | |
| }, function (dictApplicative) { | |
| return Data_Traversable.traverse(traversableCofree(dictTraversable))(dictApplicative)(Control_Category.id(Control_Category.categoryFn)); | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| var loop = function (ta) { | |
| return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(mkCofree)(f(head(ta))))(Data_Traversable.traverse(dictTraversable)(dictApplicative)(loop)(tail(ta))); | |
| }; | |
| return loop; | |
| }; | |
| }); | |
| }; | |
| exports["explore"] = explore; | |
| exports["exploreM"] = exploreM; | |
| exports["head"] = head; | |
| exports["hoistCofree"] = hoistCofree; | |
| exports["mkCofree"] = mkCofree; | |
| exports["tail"] = tail; | |
| exports["unfoldCofree"] = unfoldCofree; | |
| exports["eqCofree"] = eqCofree; | |
| exports["eq1Cofree"] = eq1Cofree; | |
| exports["ordCofree"] = ordCofree; | |
| exports["ord1Cofree"] = ord1Cofree; | |
| exports["functorCofree"] = functorCofree; | |
| exports["foldableCofree"] = foldableCofree; | |
| exports["traversableCofree"] = traversableCofree; | |
| exports["extendCofree"] = extendCofree; | |
| exports["comonadCofree"] = comonadCofree; | |
| exports["applyCofree"] = applyCofree; | |
| exports["applicativeCofree"] = applicativeCofree; | |
| exports["bindCofree"] = bindCofree; | |
| exports["monadCofree"] = monadCofree; | |
| })(PS["Control.Comonad.Cofree"] = PS["Control.Comonad.Cofree"] || {}); | |
| (function(exports) { | |
| // | This module defines the `ComonadTrans` type class of _comonad transformers_. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| // | The `ComonadTrans` type class represents _comonad transformers_. | |
| // | | |
| // | A comonad transformer is a type constructor of kind `(* -> *) -> * -> *`, which | |
| // | takes a `Comonad` as its first argument, and returns another `Comonad`. | |
| // | | |
| // | This allows us to extend a comonad to provide additional context. By iterating this | |
| // | process, we create comonad transformer _stacks_, which contain all of the contextual information | |
| // | required for a particular computation. | |
| // | | |
| // | The laws state that `lower` is a `Comonad` morphism. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - `extract (lower a) = extract a` | |
| // | - `lower (extend w (f <<< lower)) = extend (lower w) f` | |
| var ComonadTrans = function (lower) { | |
| this.lower = lower; | |
| }; | |
| var lower = function (dict) { | |
| return dict.lower; | |
| }; | |
| exports["ComonadTrans"] = ComonadTrans; | |
| exports["lower"] = lower; | |
| })(PS["Control.Comonad.Trans.Class"] = PS["Control.Comonad.Trans.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the environment comonad transformer, `EnvT`. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Comonad_Trans_Class = PS["Control.Comonad.Trans.Class"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The environment comonad transformer. | |
| // | | |
| // | This comonad transformer extends the context of a value in the base comonad with a _global environment_ of | |
| // | type `e`. | |
| // | | |
| // | The `ComonadEnv` type class describes the operations supported by this comonad. | |
| var EnvT = function (x) { | |
| return x; | |
| }; | |
| // | Change the environment type in an `EnvT` context. | |
| var withEnvT = function (f) { | |
| return function (v) { | |
| return EnvT(new Data_Tuple.Tuple(f(v.value0), v.value1)); | |
| }; | |
| }; | |
| // | Unwrap a value in the `EnvT` comonad. | |
| var runEnvT = function (v) { | |
| return v; | |
| }; | |
| var newtypeEnvT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, EnvT); | |
| // | Change the underlying comonad and data type in an `EnvT` context. | |
| var mapEnvT = function (f) { | |
| return function (v) { | |
| return EnvT(new Data_Tuple.Tuple(v.value0, f(v.value1))); | |
| }; | |
| }; | |
| var functorEnvT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return EnvT(new Data_Tuple.Tuple(v.value0, Data_Functor.map(dictFunctor)(f)(v.value1))); | |
| }; | |
| }); | |
| }; | |
| var extendEnvT = function (dictExtend) { | |
| return new Control_Extend.Extend(function () { | |
| return functorEnvT(dictExtend.Functor0()); | |
| }, function (f) { | |
| return function (v) { | |
| return EnvT(new Data_Tuple.Tuple(v.value0, Data_Functor.map(dictExtend.Functor0())(f)(Control_Extend.extend(dictExtend)(function ($37) { | |
| return EnvT(Data_Tuple.Tuple.create(v.value0)($37)); | |
| })(v.value1)))); | |
| }; | |
| }); | |
| }; | |
| var comonadTransEnvT = new Control_Comonad_Trans_Class.ComonadTrans(function (dictComonad) { | |
| return function (v) { | |
| return v.value1; | |
| }; | |
| }); | |
| var comonadEnvT = function (dictComonad) { | |
| return new Control_Comonad.Comonad(function () { | |
| return extendEnvT(dictComonad.Extend0()); | |
| }, function (v) { | |
| return Control_Comonad.extract(dictComonad)(v.value1); | |
| }); | |
| }; | |
| exports["EnvT"] = EnvT; | |
| exports["mapEnvT"] = mapEnvT; | |
| exports["runEnvT"] = runEnvT; | |
| exports["withEnvT"] = withEnvT; | |
| exports["newtypeEnvT"] = newtypeEnvT; | |
| exports["functorEnvT"] = functorEnvT; | |
| exports["extendEnvT"] = extendEnvT; | |
| exports["comonadEnvT"] = comonadEnvT; | |
| exports["comonadTransEnvT"] = comonadTransEnvT; | |
| })(PS["Control.Comonad.Env.Trans"] = PS["Control.Comonad.Env.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the `ComonadEnv` type class and its instances. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Comonad_Env_Trans = PS["Control.Comonad.Env.Trans"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| // | The `ComonadEnv` type class represents those comonads which support a | |
| // | global environment that can be provided via the `ask` function. | |
| // | | |
| // | An implementation is provided for `EnvT`. | |
| var ComonadAsk = function (Comonad0, ask) { | |
| this.Comonad0 = Comonad0; | |
| this.ask = ask; | |
| }; | |
| // | The `ComonadEnv` type class extends `ComonadAsk` with a function | |
| // | `local f x` that allows the value of the local context to be modified for | |
| // | the duration of the execution of action `x`. | |
| // | | |
| // | An implementation is provided for `EnvT`. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - `ask (local f x) = f (ask x)` | |
| // | - `extract (local _ x) = extract a` | |
| // | - `extend g (local f x) = extend (g <<< local f) x` | |
| var ComonadEnv = function (ComonadAsk0, local) { | |
| this.ComonadAsk0 = ComonadAsk0; | |
| this.local = local; | |
| }; | |
| var local = function (dict) { | |
| return dict.local; | |
| }; | |
| var comonadAskTuple = new ComonadAsk(function () { | |
| return Data_Tuple.comonadTuple; | |
| }, Data_Tuple.fst); | |
| var comonadEnvTuple = new ComonadEnv(function () { | |
| return comonadAskTuple; | |
| }, function (f) { | |
| return function (v) { | |
| return new Data_Tuple.Tuple(f(v.value0), v.value1); | |
| }; | |
| }); | |
| var comonadAskEnvT = function (dictComonad) { | |
| return new ComonadAsk(function () { | |
| return Control_Comonad_Env_Trans.comonadEnvT(dictComonad); | |
| }, function (v) { | |
| return Data_Tuple.fst(v); | |
| }); | |
| }; | |
| var comonadEnvEnvT = function (dictComonad) { | |
| return new ComonadEnv(function () { | |
| return comonadAskEnvT(dictComonad); | |
| }, function (f) { | |
| return function (v) { | |
| return new Data_Tuple.Tuple(f(v.value0), v.value1); | |
| }; | |
| }); | |
| }; | |
| var ask = function (dict) { | |
| return dict.ask; | |
| }; | |
| // | Get a value which depends on the environment. | |
| var asks = function (dictComonadEnv) { | |
| return function (f) { | |
| return function (x) { | |
| return f(ask(dictComonadEnv.ComonadAsk0())(x)); | |
| }; | |
| }; | |
| }; | |
| exports["ComonadAsk"] = ComonadAsk; | |
| exports["ComonadEnv"] = ComonadEnv; | |
| exports["ask"] = ask; | |
| exports["asks"] = asks; | |
| exports["local"] = local; | |
| exports["comonadAskTuple"] = comonadAskTuple; | |
| exports["comonadEnvTuple"] = comonadEnvTuple; | |
| exports["comonadAskEnvT"] = comonadAskEnvT; | |
| exports["comonadEnvEnvT"] = comonadEnvEnvT; | |
| })(PS["Control.Comonad.Env.Class"] = PS["Control.Comonad.Env.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `Env` comonad. | |
| "use strict"; | |
| var Control_Comonad_Env_Class = PS["Control.Comonad.Env.Class"]; | |
| var Control_Comonad_Env_Trans = PS["Control.Comonad.Env.Trans"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Change the environment type in an `Env` computation. | |
| var withEnv = Control_Comonad_Env_Trans.withEnvT; | |
| // | Unwrap a value in the `Env` comonad. | |
| var runEnv = function (v) { | |
| return Data_Functor.map(Data_Tuple.functorTuple)(Data_Newtype.unwrap(Data_Identity.newtypeIdentity))(v); | |
| }; | |
| // | Change the data type in an `Env` computation. | |
| var mapEnv = Data_Functor.map(Control_Comonad_Env_Trans.functorEnvT(Data_Identity.functorIdentity)); | |
| // | Create a value in context in the `Env` comonad. | |
| var env = function (e) { | |
| return function (a) { | |
| return Control_Comonad_Env_Trans.EnvT(Data_Tuple.Tuple.create(e)(a)); | |
| }; | |
| }; | |
| exports["env"] = env; | |
| exports["mapEnv"] = mapEnv; | |
| exports["runEnv"] = runEnv; | |
| exports["withEnv"] = withEnv; | |
| })(PS["Control.Comonad.Env"] = PS["Control.Comonad.Env"] || {}); | |
| (function(exports) { | |
| // | This module defines the store comonad transformer, `StoreT`. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Comonad_Trans_Class = PS["Control.Comonad.Trans.Class"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The store comonad transformer. | |
| // | | |
| // | This comonad transformer extends the context of a value in the base comonad so that the value | |
| // | depends on a position of type `s`. | |
| // | | |
| // | The `ComonadStore` type class describes the operations supported by this comonad. | |
| var StoreT = function (x) { | |
| return x; | |
| }; | |
| // | Unwrap a value in the `StoreT` comonad. | |
| var runStoreT = function (v) { | |
| return v; | |
| }; | |
| var newtypeStoreT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, StoreT); | |
| var functorStoreT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return StoreT(new Data_Tuple.Tuple(Data_Functor.map(dictFunctor)(function (h) { | |
| return function ($28) { | |
| return f(h($28)); | |
| }; | |
| })(v.value0), v.value1)); | |
| }; | |
| }); | |
| }; | |
| var extendStoreT = function (dictExtend) { | |
| return new Control_Extend.Extend(function () { | |
| return functorStoreT(dictExtend.Functor0()); | |
| }, function (f) { | |
| return function (v) { | |
| return StoreT(new Data_Tuple.Tuple(Control_Extend.extend(dictExtend)(function (w$prime) { | |
| return function (s$prime) { | |
| return f(StoreT(new Data_Tuple.Tuple(w$prime, s$prime))); | |
| }; | |
| })(v.value0), v.value1)); | |
| }; | |
| }); | |
| }; | |
| var comonadTransStoreT = new Control_Comonad_Trans_Class.ComonadTrans(function (dictComonad) { | |
| return function (v) { | |
| return Data_Functor.map((dictComonad.Extend0()).Functor0())(function (v1) { | |
| return v1(v.value1); | |
| })(v.value0); | |
| }; | |
| }); | |
| var comonadStoreT = function (dictComonad) { | |
| return new Control_Comonad.Comonad(function () { | |
| return extendStoreT(dictComonad.Extend0()); | |
| }, function (v) { | |
| return Control_Comonad.extract(dictComonad)(v.value0)(v.value1); | |
| }); | |
| }; | |
| exports["StoreT"] = StoreT; | |
| exports["runStoreT"] = runStoreT; | |
| exports["newtypeStoreT"] = newtypeStoreT; | |
| exports["functorStoreT"] = functorStoreT; | |
| exports["extendStoreT"] = extendStoreT; | |
| exports["comonadStoreT"] = comonadStoreT; | |
| exports["comonadTransStoreT"] = comonadTransStoreT; | |
| })(PS["Control.Comonad.Store.Trans"] = PS["Control.Comonad.Store.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the `ComonadStore` type class and its instances. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Comonad_Store_Trans = PS["Control.Comonad.Store.Trans"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `ComonadStore` type class represents those monads which support local position information via | |
| // | `pos` and `peek`. | |
| // | | |
| // | - `pos` reads the current position. | |
| // | - `peek` reads the value at the specified position in the specified context. | |
| // | | |
| // | An implementation is provided for `StoreT`. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - `pos (extend _ x) = pos x` | |
| // | - `peek (pos x) x = extract x` | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | blur :: forall w. (ComonadStore Number w) -> w Number -> w Number | |
| // | blur = extend \r -> (peeks (\n -> n - 1) r + peeks (\n -> n + 1) r) / 2) | |
| // | ``` | |
| var ComonadStore = function (Comonad0, peek, pos) { | |
| this.Comonad0 = Comonad0; | |
| this.peek = peek; | |
| this.pos = pos; | |
| }; | |
| var pos = function (dict) { | |
| return dict.pos; | |
| }; | |
| var peek = function (dict) { | |
| return dict.peek; | |
| }; | |
| // | Extract a value from a position which depends on the current position. | |
| var peeks = function (dictComonadStore) { | |
| return function (f) { | |
| return function (x) { | |
| return peek(dictComonadStore)(f(pos(dictComonadStore)(x)))(x); | |
| }; | |
| }; | |
| }; | |
| // | Reposition the focus at the specified position, which depends on the current position. | |
| var seeks = function (dictComonadStore) { | |
| return function (f) { | |
| return function ($15) { | |
| return peeks(dictComonadStore)(f)(Control_Extend.duplicate((dictComonadStore.Comonad0()).Extend0())($15)); | |
| }; | |
| }; | |
| }; | |
| // | Reposition the focus at the specified position. | |
| var seek = function (dictComonadStore) { | |
| return function (s) { | |
| return function ($16) { | |
| return peek(dictComonadStore)(s)(Control_Extend.duplicate((dictComonadStore.Comonad0()).Extend0())($16)); | |
| }; | |
| }; | |
| }; | |
| // | Extract a collection of values from positions which depend on the current position. | |
| var experiment = function (dictComonadStore) { | |
| return function (dictFunctor) { | |
| return function (f) { | |
| return function (x) { | |
| return Data_Functor.map(dictFunctor)(Data_Function.flip(peek(dictComonadStore))(x))(f(pos(dictComonadStore)(x))); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var comonadStoreStoreT = function (dictComonad) { | |
| return new ComonadStore(function () { | |
| return Control_Comonad_Store_Trans.comonadStoreT(dictComonad); | |
| }, function (s) { | |
| return function (v) { | |
| return Control_Comonad.extract(dictComonad)(v.value0)(s); | |
| }; | |
| }, function (v) { | |
| return v.value1; | |
| }); | |
| }; | |
| exports["ComonadStore"] = ComonadStore; | |
| exports["experiment"] = experiment; | |
| exports["peek"] = peek; | |
| exports["peeks"] = peeks; | |
| exports["pos"] = pos; | |
| exports["seek"] = seek; | |
| exports["seeks"] = seeks; | |
| exports["comonadStoreStoreT"] = comonadStoreStoreT; | |
| })(PS["Control.Comonad.Store.Class"] = PS["Control.Comonad.Store.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `Store` comonad. | |
| "use strict"; | |
| var Control_Comonad_Store_Class = PS["Control.Comonad.Store.Class"]; | |
| var Control_Comonad_Store_Trans = PS["Control.Comonad.Store.Trans"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Create a value in context in the `Store` comonad. | |
| var store = function (f) { | |
| return function (x) { | |
| return Control_Comonad_Store_Trans.StoreT(new Data_Tuple.Tuple(f, x)); | |
| }; | |
| }; | |
| // | Unwrap a value in the `Store` comonad. | |
| var runStore = function (v) { | |
| return Data_Tuple.swap(Data_Functor.map(Data_Tuple.functorTuple)(Data_Newtype.unwrap(Data_Identity.newtypeIdentity))(Data_Tuple.swap(v))); | |
| }; | |
| exports["runStore"] = runStore; | |
| exports["store"] = store; | |
| })(PS["Control.Comonad.Store"] = PS["Control.Comonad.Store"] || {}); | |
| (function(exports) { | |
| // | This module defines the cowriter comonad transformer, `TracedT`. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Comonad_Trans_Class = PS["Control.Comonad.Trans.Class"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The cowriter comonad transformer. | |
| // | | |
| // | This comonad transformer extends the context of a value in the base comonad so that the value | |
| // | depends on a monoidal position of type `t`. | |
| // | | |
| // | The `ComonadTraced` type class describes the operations supported by this comonad. | |
| var TracedT = function (x) { | |
| return x; | |
| }; | |
| // | Unwrap a value in the `TracedT` comonad. | |
| var runTracedT = function (v) { | |
| return v; | |
| }; | |
| var newtypeTracedT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, TracedT); | |
| var functorTracedT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(function (g) { | |
| return function (t) { | |
| return f(g(t)); | |
| }; | |
| })(v); | |
| }; | |
| }); | |
| }; | |
| var extendTracedT = function (dictExtend) { | |
| return function (dictSemigroup) { | |
| return new Control_Extend.Extend(function () { | |
| return functorTracedT(dictExtend.Functor0()); | |
| }, function (f) { | |
| return function (v) { | |
| return Control_Extend.extend(dictExtend)(function (w$prime) { | |
| return function (t) { | |
| return f(Data_Functor.map(dictExtend.Functor0())(function (h) { | |
| return function (t$prime) { | |
| return h(Data_Semigroup.append(dictSemigroup)(t)(t$prime)); | |
| }; | |
| })(w$prime)); | |
| }; | |
| })(v); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var comonadTransTracedT = function (dictMonoid) { | |
| return new Control_Comonad_Trans_Class.ComonadTrans(function (dictComonad) { | |
| return function (v) { | |
| return Data_Functor.map((dictComonad.Extend0()).Functor0())(function (f) { | |
| return f(Data_Monoid.mempty(dictMonoid)); | |
| })(v); | |
| }; | |
| }); | |
| }; | |
| var comonadTracedT = function (dictComonad) { | |
| return function (dictMonoid) { | |
| return new Control_Comonad.Comonad(function () { | |
| return extendTracedT(dictComonad.Extend0())(dictMonoid.Semigroup0()); | |
| }, function (v) { | |
| return Control_Comonad.extract(dictComonad)(v)(Data_Monoid.mempty(dictMonoid)); | |
| }); | |
| }; | |
| }; | |
| exports["TracedT"] = TracedT; | |
| exports["runTracedT"] = runTracedT; | |
| exports["newtypeTracedT"] = newtypeTracedT; | |
| exports["functorTracedT"] = functorTracedT; | |
| exports["extendTracedT"] = extendTracedT; | |
| exports["comonadTracedT"] = comonadTracedT; | |
| exports["comonadTransTracedT"] = comonadTransTracedT; | |
| })(PS["Control.Comonad.Traced.Trans"] = PS["Control.Comonad.Traced.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the `ComonadTraced` type class and its instances. | |
| "use strict"; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Comonad_Traced_Trans = PS["Control.Comonad.Traced.Trans"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `ComonadTraced` type class represents those monads which support relative (monoidal) | |
| // | position information via `track`. | |
| // | | |
| // | - `track` extracts a value at the specified relative position. | |
| // | | |
| // | An implementation is provided for `TracedT`. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - `track mempty = extract` | |
| // | - `track s <<= track t x = track (s <> t) x` | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | blur :: forall w. (ComonadTraced (Additive Number) w) -> w Number -> w Number | |
| // | blur = extend \r -> (track (Additive (-1)) r + track (Additive 1) r) / 2 | |
| // | ``` | |
| var ComonadTraced = function (Comonad0, track) { | |
| this.Comonad0 = Comonad0; | |
| this.track = track; | |
| }; | |
| var track = function (dict) { | |
| return dict.track; | |
| }; | |
| // | Extracts a value at a relative position which depends on the current value. | |
| var tracks = function (dictComonadTraced) { | |
| return function (f) { | |
| return function (w) { | |
| return track(dictComonadTraced)(f(Control_Comonad.extract(dictComonadTraced.Comonad0())(w)))(w); | |
| }; | |
| }; | |
| }; | |
| // | Get a value which depends on the current position. | |
| var listens = function (dictFunctor) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(function (g) { | |
| return function (t) { | |
| return new Data_Tuple.Tuple(g(t), f(t)); | |
| }; | |
| })(v); | |
| }; | |
| }; | |
| }; | |
| // | Get the current position. | |
| var listen = function (dictFunctor) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(function (f) { | |
| return function (t) { | |
| return new Data_Tuple.Tuple(f(t), t); | |
| }; | |
| })(v); | |
| }; | |
| }; | |
| var comonadTracedTracedT = function (dictComonad) { | |
| return function (dictMonoid) { | |
| return new ComonadTraced(function () { | |
| return Control_Comonad_Traced_Trans.comonadTracedT(dictComonad)(dictMonoid); | |
| }, function (t) { | |
| return function (v) { | |
| return Control_Comonad.extract(dictComonad)(v)(t); | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Apply a function to the current position. | |
| var censor = function (dictFunctor) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(function (v1) { | |
| return function ($18) { | |
| return v1(f($18)); | |
| }; | |
| })(v); | |
| }; | |
| }; | |
| }; | |
| exports["ComonadTraced"] = ComonadTraced; | |
| exports["censor"] = censor; | |
| exports["listen"] = listen; | |
| exports["listens"] = listens; | |
| exports["track"] = track; | |
| exports["tracks"] = tracks; | |
| exports["comonadTracedTracedT"] = comonadTracedTracedT; | |
| })(PS["Control.Comonad.Traced.Class"] = PS["Control.Comonad.Traced.Class"] || {}); | |
| (function(exports) { | |
| // | This module defines the `Traced` comonad. | |
| "use strict"; | |
| var Control_Comonad_Traced_Class = PS["Control.Comonad.Traced.Class"]; | |
| var Control_Comonad_Traced_Trans = PS["Control.Comonad.Traced.Trans"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Create a value in context in the `Traced` comonad. | |
| var traced = function ($2) { | |
| return Control_Comonad_Traced_Trans.TracedT(Data_Identity.Identity($2)); | |
| }; | |
| // | Unwrap a value in the `Traced` comonad. | |
| var runTraced = function (v) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(v); | |
| }; | |
| exports["runTraced"] = runTraced; | |
| exports["traced"] = traced; | |
| })(PS["Control.Comonad.Traced"] = PS["Control.Comonad.Traced"] || {}); | |
| (function(exports) { | |
| // | This module defines the _exception monad transformer_ `ExceptT`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A monad transformer which adds exceptions to other monads, in the same way | |
| // | as `Except`. As before, `e` is the type of exceptions, and `a` is the type | |
| // | of successful results. The new type parameter `m` is the inner monad that | |
| // | computations run in. | |
| var ExceptT = function (x) { | |
| return x; | |
| }; | |
| // | Transform any exceptions thrown by an `ExceptT` computation using the given function. | |
| var withExceptT = function (dictFunctor) { | |
| return function (f) { | |
| return function (v) { | |
| var mapLeft = function (v1) { | |
| return function (v2) { | |
| if (v2 instanceof Data_Either.Right) { | |
| return new Data_Either.Right(v2.value0); | |
| }; | |
| if (v2 instanceof Data_Either.Left) { | |
| return new Data_Either.Left(v1(v2.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Except.Trans line 44, column 3 - line 44, column 32: " + [ v1.constructor.name, v2.constructor.name ]); | |
| }; | |
| }; | |
| return ExceptT(Data_Functor.map(dictFunctor)(mapLeft(f))(v)); | |
| }; | |
| }; | |
| }; | |
| // | The inverse of `ExceptT`. Run a computation in the `ExceptT` monad. | |
| var runExceptT = function (v) { | |
| return v; | |
| }; | |
| var newtypeExceptT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, ExceptT); | |
| var monadTransExceptT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function (m) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m)(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(v)); | |
| }); | |
| }; | |
| }); | |
| // | Transform the unwrapped computation using the given function. | |
| var mapExceptT = function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| var functorExceptT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return mapExceptT(Data_Functor.map(dictFunctor)(Data_Functor.map(Data_Either.functorEither)(f))); | |
| }); | |
| }; | |
| // | Construct a computation in the `ExceptT` transformer from an `Either` value. | |
| var except = function (dictApplicative) { | |
| return function ($96) { | |
| return ExceptT(Control_Applicative.pure(dictApplicative)($96)); | |
| }; | |
| }; | |
| var monadExceptT = function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeExceptT(dictMonad); | |
| }, function () { | |
| return bindExceptT(dictMonad); | |
| }); | |
| }; | |
| var bindExceptT = function (dictMonad) { | |
| return new Control_Bind.Bind(function () { | |
| return applyExceptT(dictMonad); | |
| }, function (v) { | |
| return function (k) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(Data_Either.either(function ($97) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Left.create($97)); | |
| })(function (a) { | |
| var v1 = k(a); | |
| return v1; | |
| })); | |
| }; | |
| }); | |
| }; | |
| var applyExceptT = function (dictMonad) { | |
| return new Control_Apply.Apply(function () { | |
| return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, Control_Monad.ap(monadExceptT(dictMonad))); | |
| }; | |
| var applicativeExceptT = function (dictMonad) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyExceptT(dictMonad); | |
| }, function ($98) { | |
| return ExceptT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Right.create($98))); | |
| }); | |
| }; | |
| var monadAskExceptT = function (dictMonadAsk) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadExceptT(dictMonadAsk.Monad0()); | |
| }, Control_Monad_Trans_Class.lift(monadTransExceptT)(dictMonadAsk.Monad0())(Control_Monad_Reader_Class.ask(dictMonadAsk))); | |
| }; | |
| var monadReaderExceptT = function (dictMonadReader) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskExceptT(dictMonadReader.MonadAsk0()); | |
| }, function (f) { | |
| return mapExceptT(Control_Monad_Reader_Class.local(dictMonadReader)(f)); | |
| }); | |
| }; | |
| var monadContExceptT = function (dictMonadCont) { | |
| return new Control_Monad_Cont_Class.MonadCont(function () { | |
| return monadExceptT(dictMonadCont.Monad0()); | |
| }, function (f) { | |
| return ExceptT(Control_Monad_Cont_Class.callCC(dictMonadCont)(function (c) { | |
| var v = f(function (a) { | |
| return ExceptT(c(new Data_Either.Right(a))); | |
| }); | |
| return v; | |
| })); | |
| }); | |
| }; | |
| var monadEffExceptT = function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadExceptT(dictMonadEff.Monad0()); | |
| }, function ($99) { | |
| return Control_Monad_Trans_Class.lift(monadTransExceptT)(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($99)); | |
| }); | |
| }; | |
| var monadRecExceptT = function (dictMonadRec) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadExceptT(dictMonadRec.Monad0()); | |
| }, function (f) { | |
| return function ($100) { | |
| return ExceptT(Control_Monad_Rec_Class.tailRecM(dictMonadRec)(function (a) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())((function () { | |
| var v = f(a); | |
| return v; | |
| })())(function (m$prime) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())((function () { | |
| if (m$prime instanceof Data_Either.Left) { | |
| return new Control_Monad_Rec_Class.Done(new Data_Either.Left(m$prime.value0)); | |
| }; | |
| if (m$prime instanceof Data_Either.Right && m$prime.value0 instanceof Control_Monad_Rec_Class.Loop) { | |
| return new Control_Monad_Rec_Class.Loop(m$prime.value0.value0); | |
| }; | |
| if (m$prime instanceof Data_Either.Right && m$prime.value0 instanceof Control_Monad_Rec_Class.Done) { | |
| return new Control_Monad_Rec_Class.Done(new Data_Either.Right(m$prime.value0.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Except.Trans line 76, column 14 - line 79, column 43: " + [ m$prime.constructor.name ]); | |
| })()); | |
| }); | |
| })($100)); | |
| }; | |
| }); | |
| }; | |
| var monadStateExceptT = function (dictMonadState) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadExceptT(dictMonadState.Monad0()); | |
| }, function (f) { | |
| return Control_Monad_Trans_Class.lift(monadTransExceptT)(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)(f)); | |
| }); | |
| }; | |
| var monadTellExceptT = function (dictMonadTell) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadExceptT(dictMonadTell.Monad0()); | |
| }, function ($101) { | |
| return Control_Monad_Trans_Class.lift(monadTransExceptT)(dictMonadTell.Monad0())(Control_Monad_Writer_Class.tell(dictMonadTell)($101)); | |
| }); | |
| }; | |
| var monadWriterExceptT = function (dictMonadWriter) { | |
| return new Control_Monad_Writer_Class.MonadWriter(function () { | |
| return monadTellExceptT(dictMonadWriter.MonadTell0()); | |
| }, mapExceptT(function (m) { | |
| return Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(Control_Monad_Writer_Class.listen(dictMonadWriter)(m))(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())(Data_Functor.map(Data_Either.functorEither)(function (r) { | |
| return new Data_Tuple.Tuple(r, v.value1); | |
| })(v.value0)); | |
| }); | |
| }), mapExceptT(function (m) { | |
| return Control_Monad_Writer_Class.pass(dictMonadWriter)(Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(m)(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())((function () { | |
| if (v instanceof Data_Either.Left) { | |
| return new Data_Tuple.Tuple(new Data_Either.Left(v.value0), Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return new Data_Tuple.Tuple(new Data_Either.Right(v.value0.value0), v.value0.value1); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Except.Trans line 138, column 10 - line 140, column 44: " + [ v.constructor.name ]); | |
| })()); | |
| })); | |
| })); | |
| }; | |
| var monadThrowExceptT = function (dictMonad) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadExceptT(dictMonad); | |
| }, function ($102) { | |
| return ExceptT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Left.create($102))); | |
| }); | |
| }; | |
| var monadErrorExceptT = function (dictMonad) { | |
| return new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowExceptT(dictMonad); | |
| }, function (v) { | |
| return function (k) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(Data_Either.either(function (a) { | |
| var v1 = k(a); | |
| return v1; | |
| })(function ($103) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Right.create($103)); | |
| })); | |
| }; | |
| }); | |
| }; | |
| var altExceptT = function (dictSemigroup) { | |
| return function (dictMonad) { | |
| return new Control_Alt.Alt(function () { | |
| return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(function (v2) { | |
| if (v2 instanceof Data_Either.Right) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(v2.value0)); | |
| }; | |
| if (v2 instanceof Data_Either.Left) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v1)(function (v3) { | |
| if (v3 instanceof Data_Either.Right) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(v3.value0)); | |
| }; | |
| if (v3 instanceof Data_Either.Left) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Left(Data_Semigroup.append(dictSemigroup)(v2.value0)(v3.value0))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Except.Trans line 88, column 9 - line 90, column 49: " + [ v3.constructor.name ]); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Except.Trans line 84, column 5 - line 90, column 49: " + [ v2.constructor.name ]); | |
| }); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var plusExceptT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_Plus.Plus(function () { | |
| return altExceptT(dictMonoid.Semigroup0())(dictMonad); | |
| }, Control_Monad_Error_Class.throwError(monadThrowExceptT(dictMonad))(Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }; | |
| var alternativeExceptT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeExceptT(dictMonad); | |
| }, function () { | |
| return plusExceptT(dictMonoid)(dictMonad); | |
| }); | |
| }; | |
| }; | |
| var monadZeroExceptT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_MonadZero.MonadZero(function () { | |
| return alternativeExceptT(dictMonoid)(dictMonad); | |
| }, function () { | |
| return monadExceptT(dictMonad); | |
| }); | |
| }; | |
| }; | |
| var monadPlusExceptT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroExceptT(dictMonoid)(dictMonad); | |
| }); | |
| }; | |
| }; | |
| exports["ExceptT"] = ExceptT; | |
| exports["except"] = except; | |
| exports["mapExceptT"] = mapExceptT; | |
| exports["runExceptT"] = runExceptT; | |
| exports["withExceptT"] = withExceptT; | |
| exports["newtypeExceptT"] = newtypeExceptT; | |
| exports["functorExceptT"] = functorExceptT; | |
| exports["applyExceptT"] = applyExceptT; | |
| exports["applicativeExceptT"] = applicativeExceptT; | |
| exports["bindExceptT"] = bindExceptT; | |
| exports["monadExceptT"] = monadExceptT; | |
| exports["monadRecExceptT"] = monadRecExceptT; | |
| exports["altExceptT"] = altExceptT; | |
| exports["plusExceptT"] = plusExceptT; | |
| exports["alternativeExceptT"] = alternativeExceptT; | |
| exports["monadPlusExceptT"] = monadPlusExceptT; | |
| exports["monadZeroExceptT"] = monadZeroExceptT; | |
| exports["monadTransExceptT"] = monadTransExceptT; | |
| exports["monadEffExceptT"] = monadEffExceptT; | |
| exports["monadContExceptT"] = monadContExceptT; | |
| exports["monadThrowExceptT"] = monadThrowExceptT; | |
| exports["monadErrorExceptT"] = monadErrorExceptT; | |
| exports["monadAskExceptT"] = monadAskExceptT; | |
| exports["monadReaderExceptT"] = monadReaderExceptT; | |
| exports["monadStateExceptT"] = monadStateExceptT; | |
| exports["monadTellExceptT"] = monadTellExceptT; | |
| exports["monadWriterExceptT"] = monadWriterExceptT; | |
| })(PS["Control.Monad.Except.Trans"] = PS["Control.Monad.Except.Trans"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Transform any exceptions thrown by an `Except` computation using the given function. | |
| var withExcept = Control_Monad_Except_Trans.withExceptT(Data_Identity.functorIdentity); | |
| // | Run a computation in the `Except` monad. The inverse of `except`. | |
| var runExcept = function ($0) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(Control_Monad_Except_Trans.runExceptT($0)); | |
| }; | |
| // | Transform the unwrapped computation using the given function. | |
| var mapExcept = function (f) { | |
| return Control_Monad_Except_Trans.mapExceptT(function ($1) { | |
| return Data_Identity.Identity(f(Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($1))); | |
| }); | |
| }; | |
| exports["mapExcept"] = mapExcept; | |
| exports["runExcept"] = runExcept; | |
| exports["withExcept"] = withExcept; | |
| })(PS["Control.Monad.Except"] = PS["Control.Monad.Except"] || {}); | |
| (function(exports) { | |
| // | This module defines a stack-safe implementation of the _free monad transformer_. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Exists = PS["Data.Exists"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Instead of implementing `bind` directly, we capture the bind using this data structure, to | |
| // | evaluate later. | |
| var Bound = (function () { | |
| function Bound(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Bound.create = function (value0) { | |
| return function (value1) { | |
| return new Bound(value0, value1); | |
| }; | |
| }; | |
| return Bound; | |
| })(); | |
| // | The free monad transformer for the functor `f`. | |
| var FreeT = (function () { | |
| function FreeT(value0) { | |
| this.value0 = value0; | |
| }; | |
| FreeT.create = function (value0) { | |
| return new FreeT(value0); | |
| }; | |
| return FreeT; | |
| })(); | |
| // | The free monad transformer for the functor `f`. | |
| var Bind = (function () { | |
| function Bind(value0) { | |
| this.value0 = value0; | |
| }; | |
| Bind.create = function (value0) { | |
| return new Bind(value0); | |
| }; | |
| return Bind; | |
| })(); | |
| var monadTransFreeT = function (dictFunctor) { | |
| return new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function (ma) { | |
| return new FreeT(function (v) { | |
| return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Either.Left.create)(ma); | |
| }); | |
| }; | |
| }); | |
| }; | |
| // | Construct a computation of type `FreeT`. | |
| var freeT = FreeT.create; | |
| // | Capture a `bind` operation for the `FreeT` monad. | |
| var bound = function (m) { | |
| return function (f) { | |
| return new Bind(Data_Exists.mkExists(new Bound(m, f))); | |
| }; | |
| }; | |
| var functorFreeT = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| if (v instanceof FreeT) { | |
| return new FreeT(function (v1) { | |
| return Data_Functor.map(dictFunctor1)(Data_Bifunctor.bimap(Data_Either.bifunctorEither)(f)(Data_Functor.map(dictFunctor)(Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f))))(v.value0(Data_Unit.unit)); | |
| }); | |
| }; | |
| if (v instanceof Bind) { | |
| return Data_Exists.runExists(function (v1) { | |
| return bound(v1.value0)(function ($104) { | |
| return Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f)(v1.value1($104)); | |
| }); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 58, column 1 - line 58, column 71: " + [ f.constructor.name, v.constructor.name ]); | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Change the base functor `f` and the underlying `Monad` for a `FreeT` action. | |
| var bimapFreeT = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (nf) { | |
| return function (nm) { | |
| return function (v) { | |
| if (v instanceof Bind) { | |
| return Data_Exists.runExists(function (v1) { | |
| return bound(function ($105) { | |
| return bimapFreeT(dictFunctor)(dictFunctor1)(nf)(nm)(v1.value0($105)); | |
| })(function ($106) { | |
| return bimapFreeT(dictFunctor)(dictFunctor1)(nf)(nm)(v1.value1($106)); | |
| }); | |
| })(v.value0); | |
| }; | |
| if (v instanceof FreeT) { | |
| return new FreeT(function (v1) { | |
| return Data_Functor.map(dictFunctor1)(Data_Functor.map(Data_Either.functorEither)(function ($107) { | |
| return nf(Data_Functor.map(dictFunctor)(bimapFreeT(dictFunctor)(dictFunctor1)(nf)(nm))($107)); | |
| }))(nm(v.value0(Data_Unit.unit))); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 119, column 1 - line 119, column 109: " + [ nf.constructor.name, nm.constructor.name, v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Change the underlying `Monad` for a `FreeT` action. | |
| var hoistFreeT = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return bimapFreeT(dictFunctor)(dictFunctor1)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | Change the base functor `f` for a `FreeT` action. | |
| var interpret = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (nf) { | |
| return bimapFreeT(dictFunctor)(dictFunctor1)(nf)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| }; | |
| var monadFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeFreeT(dictFunctor)(dictMonad); | |
| }, function () { | |
| return bindFreeT(dictFunctor)(dictMonad); | |
| }); | |
| }; | |
| }; | |
| var bindFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return new Control_Bind.Bind(function () { | |
| return applyFreeT(dictFunctor)(dictMonad); | |
| }, function (v) { | |
| return function (f) { | |
| if (v instanceof Bind) { | |
| return Data_Exists.runExists(function (v1) { | |
| return bound(v1.value0)(function (x) { | |
| return bound(function (v2) { | |
| return v1.value1(x); | |
| })(f); | |
| }); | |
| })(v.value0); | |
| }; | |
| return bound(function (v1) { | |
| return v; | |
| })(f); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var applyFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return new Control_Apply.Apply(function () { | |
| return functorFreeT(dictFunctor)(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, Control_Monad.ap(monadFreeT(dictFunctor)(dictMonad))); | |
| }; | |
| }; | |
| var applicativeFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyFreeT(dictFunctor)(dictMonad); | |
| }, function (a) { | |
| return new FreeT(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Left(a)); | |
| }); | |
| }); | |
| }; | |
| }; | |
| // | Lift an action from the functor `f` to a `FreeT` action. | |
| var liftFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return function (fa) { | |
| return new FreeT(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(Data_Functor.map(dictFunctor)(Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad)))(fa))); | |
| }); | |
| }; | |
| }; | |
| }; | |
| // | Unpack `FreeT`, exposing the first step of the computation. | |
| var resume = function (dictFunctor) { | |
| return function (dictMonadRec) { | |
| var go = function (v) { | |
| if (v instanceof FreeT) { | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(v.value0(Data_Unit.unit)); | |
| }; | |
| if (v instanceof Bind) { | |
| return Data_Exists.runExists(function (v1) { | |
| var v2 = v1.value0(Data_Unit.unit); | |
| if (v2 instanceof FreeT) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(v2.value0(Data_Unit.unit))(function (v3) { | |
| if (v3 instanceof Data_Either.Left) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop(v1.value1(v3.value0))); | |
| }; | |
| if (v3 instanceof Data_Either.Right) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(new Data_Either.Right(Data_Functor.map(dictFunctor)(function (h) { | |
| return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(h)(v1.value1); | |
| })(v3.value0)))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 53, column 20 - line 55, column 67: " + [ v3.constructor.name ]); | |
| }); | |
| }; | |
| if (v2 instanceof Bind) { | |
| return Data_Exists.runExists(function (v3) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop(Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(v3.value0(Data_Unit.unit))(function (z) { | |
| return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(v3.value1(z))(v1.value1); | |
| }))); | |
| })(v2.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 51, column 5 - line 56, column 98: " + [ v2.constructor.name ]); | |
| })(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 48, column 3 - line 48, column 75: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); | |
| }; | |
| }; | |
| // | Run a `FreeT` computation to completion. | |
| var runFreeT = function (dictFunctor) { | |
| return function (dictMonadRec) { | |
| return function (interp) { | |
| var go = function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(v.value0)); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Loop.create)(interp(v.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 127, column 3 - line 127, column 63: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(Control_Bind.composeKleisliFlipped((dictMonadRec.Monad0()).Bind1())(go)(resume(dictFunctor)(dictMonadRec))); | |
| }; | |
| }; | |
| }; | |
| var semigroupFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(Control_Apply.lift2(applyFreeT(dictFunctor)(dictMonad))(Data_Semigroup.append(dictSemigroup))); | |
| }; | |
| }; | |
| }; | |
| var monadAskFreeT = function (dictFunctor) { | |
| return function (dictMonadAsk) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadFreeT(dictFunctor)(dictMonadAsk.Monad0()); | |
| }, Control_Monad_Trans_Class.lift(monadTransFreeT(dictFunctor))(dictMonadAsk.Monad0())(Control_Monad_Reader_Class.ask(dictMonadAsk))); | |
| }; | |
| }; | |
| var monadEffFreeT = function (dictFunctor) { | |
| return function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadFreeT(dictFunctor)(dictMonadEff.Monad0()); | |
| }, function ($108) { | |
| return Control_Monad_Trans_Class.lift(monadTransFreeT(dictFunctor))(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($108)); | |
| }); | |
| }; | |
| }; | |
| var monadStateFreeT = function (dictFunctor) { | |
| return function (dictMonadState) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadFreeT(dictFunctor)(dictMonadState.Monad0()); | |
| }, function ($109) { | |
| return Control_Monad_Trans_Class.lift(monadTransFreeT(dictFunctor))(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)($109)); | |
| }); | |
| }; | |
| }; | |
| var monadTellFreeT = function (dictFunctor) { | |
| return function (dictMonadTell) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadFreeT(dictFunctor)(dictMonadTell.Monad0()); | |
| }, function ($110) { | |
| return Control_Monad_Trans_Class.lift(monadTransFreeT(dictFunctor))(dictMonadTell.Monad0())(Control_Monad_Writer_Class.tell(dictMonadTell)($110)); | |
| }); | |
| }; | |
| }; | |
| var monadThrowFreeT = function (dictFunctor) { | |
| return function (dictMonadThrow) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadFreeT(dictFunctor)(dictMonadThrow.Monad0()); | |
| }, function ($111) { | |
| return Control_Monad_Trans_Class.lift(monadTransFreeT(dictFunctor))(dictMonadThrow.Monad0())(Control_Monad_Error_Class.throwError(dictMonadThrow)($111)); | |
| }); | |
| }; | |
| }; | |
| var monadRecFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadFreeT(dictFunctor)(dictMonad); | |
| }, function (f) { | |
| var go = function (s) { | |
| return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonad))(f(s))(function (v) { | |
| if (v instanceof Control_Monad_Rec_Class.Loop) { | |
| return go(v.value0); | |
| }; | |
| if (v instanceof Control_Monad_Rec_Class.Done) { | |
| return Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad))(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Free.Trans line 81, column 15 - line 83, column 25: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| return go; | |
| }); | |
| }; | |
| }; | |
| var monoidFreeT = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupFreeT(dictFunctor)(dictMonad)(dictMonoid.Semigroup0()); | |
| }, Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad))(Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }; | |
| }; | |
| exports["bimapFreeT"] = bimapFreeT; | |
| exports["freeT"] = freeT; | |
| exports["hoistFreeT"] = hoistFreeT; | |
| exports["interpret"] = interpret; | |
| exports["liftFreeT"] = liftFreeT; | |
| exports["resume"] = resume; | |
| exports["runFreeT"] = runFreeT; | |
| exports["functorFreeT"] = functorFreeT; | |
| exports["applyFreeT"] = applyFreeT; | |
| exports["applicativeFreeT"] = applicativeFreeT; | |
| exports["bindFreeT"] = bindFreeT; | |
| exports["monadFreeT"] = monadFreeT; | |
| exports["monadTransFreeT"] = monadTransFreeT; | |
| exports["monadRecFreeT"] = monadRecFreeT; | |
| exports["semigroupFreeT"] = semigroupFreeT; | |
| exports["monoidFreeT"] = monoidFreeT; | |
| exports["monadEffFreeT"] = monadEffFreeT; | |
| exports["monadAskFreeT"] = monadAskFreeT; | |
| exports["monadTellFreeT"] = monadTellFreeT; | |
| exports["monadStateFreeT"] = monadStateFreeT; | |
| exports["monadThrowFreeT"] = monadThrowFreeT; | |
| })(PS["Control.Monad.Free.Trans"] = PS["Control.Monad.Free.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the CPS monad transformer. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The CPS monad transformer. | |
| // | | |
| // | This monad transformer extends the base monad with the operation `callCC`. | |
| var ContT = function (x) { | |
| return x; | |
| }; | |
| // | Modify the continuation in a `ContT` monad action | |
| var withContT = function (f) { | |
| return function (v) { | |
| return function (k) { | |
| return v(f(k)); | |
| }; | |
| }; | |
| }; | |
| // | Run a computation in the `ContT` monad, by providing a continuation. | |
| var runContT = function (v) { | |
| return function (k) { | |
| return v(k); | |
| }; | |
| }; | |
| var newtypeContT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, ContT); | |
| var monadTransContT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function (m) { | |
| return function (k) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m)(k); | |
| }; | |
| }; | |
| }); | |
| // | Modify the underlying action in a `ContT` monad action. | |
| var mapContT = function (f) { | |
| return function (v) { | |
| return function (k) { | |
| return f(v(k)); | |
| }; | |
| }; | |
| }; | |
| var functorContT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return function (k) { | |
| return v(function (a) { | |
| return k(f(a)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var applyContT = function (dictApply) { | |
| return new Control_Apply.Apply(function () { | |
| return functorContT(dictApply.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return function (k) { | |
| return v(function (g) { | |
| return v1(function (a) { | |
| return k(g(a)); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var bindContT = function (dictBind) { | |
| return new Control_Bind.Bind(function () { | |
| return applyContT(dictBind.Apply0()); | |
| }, function (v) { | |
| return function (k) { | |
| return function (k$prime) { | |
| return v(function (a) { | |
| var v1 = k(a); | |
| return v1(k$prime); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var applicativeContT = function (dictApplicative) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyContT(dictApplicative.Apply0()); | |
| }, function (a) { | |
| return function (k) { | |
| return k(a); | |
| }; | |
| }); | |
| }; | |
| var monadContT = function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeContT(dictMonad.Applicative0()); | |
| }, function () { | |
| return bindContT(dictMonad.Bind1()); | |
| }); | |
| }; | |
| var monadAskContT = function (dictMonadAsk) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadContT(dictMonadAsk.Monad0()); | |
| }, Control_Monad_Trans_Class.lift(monadTransContT)(dictMonadAsk.Monad0())(Control_Monad_Reader_Class.ask(dictMonadAsk))); | |
| }; | |
| var monadReaderContT = function (dictMonadReader) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskContT(dictMonadReader.MonadAsk0()); | |
| }, function (f) { | |
| return function (v) { | |
| return function (k) { | |
| return Control_Bind.bind(((dictMonadReader.MonadAsk0()).Monad0()).Bind1())(Control_Monad_Reader_Class.ask(dictMonadReader.MonadAsk0()))(function (v1) { | |
| return Control_Monad_Reader_Class.local(dictMonadReader)(f)(v(function ($45) { | |
| return Control_Monad_Reader_Class.local(dictMonadReader)(Data_Function["const"](v1))(k($45)); | |
| })); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var monadContContT = function (dictMonad) { | |
| return new Control_Monad_Cont_Class.MonadCont(function () { | |
| return monadContT(dictMonad); | |
| }, function (f) { | |
| return function (k) { | |
| var v = f(function (a) { | |
| return function (v1) { | |
| return k(a); | |
| }; | |
| }); | |
| return v(k); | |
| }; | |
| }); | |
| }; | |
| var monadEffContT = function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadContT(dictMonadEff.Monad0()); | |
| }, function ($46) { | |
| return Control_Monad_Trans_Class.lift(monadTransContT)(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($46)); | |
| }); | |
| }; | |
| var monadStateContT = function (dictMonadState) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadContT(dictMonadState.Monad0()); | |
| }, function ($47) { | |
| return Control_Monad_Trans_Class.lift(monadTransContT)(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)($47)); | |
| }); | |
| }; | |
| exports["ContT"] = ContT; | |
| exports["mapContT"] = mapContT; | |
| exports["runContT"] = runContT; | |
| exports["withContT"] = withContT; | |
| exports["newtypeContT"] = newtypeContT; | |
| exports["monadContContT"] = monadContContT; | |
| exports["functorContT"] = functorContT; | |
| exports["applyContT"] = applyContT; | |
| exports["applicativeContT"] = applicativeContT; | |
| exports["bindContT"] = bindContT; | |
| exports["monadContT"] = monadContT; | |
| exports["monadTransContT"] = monadTransContT; | |
| exports["monadEffContT"] = monadEffContT; | |
| exports["monadAskContT"] = monadAskContT; | |
| exports["monadReaderContT"] = monadReaderContT; | |
| exports["monadStateContT"] = monadStateContT; | |
| })(PS["Control.Monad.Cont.Trans"] = PS["Control.Monad.Cont.Trans"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.newRef = function (val) { | |
| return function () { | |
| return { value: val }; | |
| }; | |
| }; | |
| exports.readRef = function (ref) { | |
| return function () { | |
| return ref.value; | |
| }; | |
| }; | |
| exports["modifyRef'"] = function (ref) { | |
| return function (f) { | |
| return function () { | |
| var t = f(ref.value); | |
| ref.value = t.state; | |
| return t.value; | |
| }; | |
| }; | |
| }; | |
| exports.writeRef = function (ref) { | |
| return function (val) { | |
| return function () { | |
| ref.value = val; | |
| return {}; | |
| }; | |
| }; | |
| }; | |
| })(PS["Control.Monad.Eff.Ref"] = PS["Control.Monad.Eff.Ref"] || {}); | |
| (function(exports) { | |
| // | This module defines an effect and actions for working with | |
| // | global mutable variables. | |
| // | | |
| // | _Note_: The `Control.Monad.ST` provides a _safe_ alternative | |
| // | to global mutable variables when mutation is restricted to a | |
| // | local scope. | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Eff.Ref"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Update the value of a mutable reference by applying a function | |
| // | to the current value. | |
| var modifyRef = function (ref) { | |
| return function (f) { | |
| return $foreign["modifyRef'"](ref)(function (s) { | |
| return { | |
| state: f(s), | |
| value: Data_Unit.unit | |
| }; | |
| }); | |
| }; | |
| }; | |
| exports["modifyRef"] = modifyRef; | |
| exports["modifyRef'"] = $foreign["modifyRef'"]; | |
| exports["newRef"] = $foreign.newRef; | |
| exports["readRef"] = $foreign.readRef; | |
| exports["writeRef"] = $foreign.writeRef; | |
| })(PS["Control.Monad.Eff.Ref"] = PS["Control.Monad.Eff.Ref"] || {}); | |
| (function(exports) { | |
| // | This module defines the `MaybeT` monad transformer. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `MaybeT` monad transformer. | |
| // | | |
| // | This monad transformer extends the base monad, supporting failure and alternation via | |
| // | the `MonadPlus` type class. | |
| var MaybeT = function (x) { | |
| return x; | |
| }; | |
| // | Run a computation in the `MaybeT` monad. | |
| var runMaybeT = function (v) { | |
| return v; | |
| }; | |
| var newtypeMaybeT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, MaybeT); | |
| var monadTransMaybeT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function ($75) { | |
| return MaybeT(Control_Monad.liftM1(dictMonad)(Data_Maybe.Just.create)($75)); | |
| }; | |
| }); | |
| // | Change the result type of a `MaybeT` monad action. | |
| var mapMaybeT = function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| var functorMaybeT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v); | |
| }; | |
| }); | |
| }; | |
| var monadMaybeT = function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeMaybeT(dictMonad); | |
| }, function () { | |
| return bindMaybeT(dictMonad); | |
| }); | |
| }; | |
| var bindMaybeT = function (dictMonad) { | |
| return new Control_Bind.Bind(function () { | |
| return applyMaybeT(dictMonad); | |
| }, function (v) { | |
| return function (f) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(function (v1) { | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_Maybe.Nothing.value); | |
| }; | |
| if (v1 instanceof Data_Maybe.Just) { | |
| var v2 = f(v1.value0); | |
| return v2; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Maybe.Trans line 55, column 11 - line 57, column 42: " + [ v1.constructor.name ]); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var applyMaybeT = function (dictMonad) { | |
| return new Control_Apply.Apply(function () { | |
| return functorMaybeT(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, Control_Monad.ap(monadMaybeT(dictMonad))); | |
| }; | |
| var applicativeMaybeT = function (dictMonad) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyMaybeT(dictMonad); | |
| }, function ($76) { | |
| return MaybeT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Maybe.Just.create($76))); | |
| }); | |
| }; | |
| var monadAskMaybeT = function (dictMonadAsk) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadMaybeT(dictMonadAsk.Monad0()); | |
| }, Control_Monad_Trans_Class.lift(monadTransMaybeT)(dictMonadAsk.Monad0())(Control_Monad_Reader_Class.ask(dictMonadAsk))); | |
| }; | |
| var monadReaderMaybeT = function (dictMonadReader) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskMaybeT(dictMonadReader.MonadAsk0()); | |
| }, function (f) { | |
| return mapMaybeT(Control_Monad_Reader_Class.local(dictMonadReader)(f)); | |
| }); | |
| }; | |
| var monadContMaybeT = function (dictMonadCont) { | |
| return new Control_Monad_Cont_Class.MonadCont(function () { | |
| return monadMaybeT(dictMonadCont.Monad0()); | |
| }, function (f) { | |
| return MaybeT(Control_Monad_Cont_Class.callCC(dictMonadCont)(function (c) { | |
| var v = f(function (a) { | |
| return MaybeT(c(new Data_Maybe.Just(a))); | |
| }); | |
| return v; | |
| })); | |
| }); | |
| }; | |
| var monadEffMaybe = function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadMaybeT(dictMonadEff.Monad0()); | |
| }, function ($77) { | |
| return Control_Monad_Trans_Class.lift(monadTransMaybeT)(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($77)); | |
| }); | |
| }; | |
| var monadRecMaybeT = function (dictMonadRec) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadMaybeT(dictMonadRec.Monad0()); | |
| }, function (f) { | |
| return function ($78) { | |
| return MaybeT(Control_Monad_Rec_Class.tailRecM(dictMonadRec)(function (a) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())((function () { | |
| var v = f(a); | |
| return v; | |
| })())(function (m$prime) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())((function () { | |
| if (m$prime instanceof Data_Maybe.Nothing) { | |
| return new Control_Monad_Rec_Class.Done(Data_Maybe.Nothing.value); | |
| }; | |
| if (m$prime instanceof Data_Maybe.Just && m$prime.value0 instanceof Control_Monad_Rec_Class.Loop) { | |
| return new Control_Monad_Rec_Class.Loop(m$prime.value0.value0); | |
| }; | |
| if (m$prime instanceof Data_Maybe.Just && m$prime.value0 instanceof Control_Monad_Rec_Class.Done) { | |
| return new Control_Monad_Rec_Class.Done(new Data_Maybe.Just(m$prime.value0.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Maybe.Trans line 85, column 16 - line 88, column 43: " + [ m$prime.constructor.name ]); | |
| })()); | |
| }); | |
| })($78)); | |
| }; | |
| }); | |
| }; | |
| var monadStateMaybeT = function (dictMonadState) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadMaybeT(dictMonadState.Monad0()); | |
| }, function (f) { | |
| return Control_Monad_Trans_Class.lift(monadTransMaybeT)(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)(f)); | |
| }); | |
| }; | |
| var monadTellMaybeT = function (dictMonadTell) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadMaybeT(dictMonadTell.Monad0()); | |
| }, function ($79) { | |
| return Control_Monad_Trans_Class.lift(monadTransMaybeT)(dictMonadTell.Monad0())(Control_Monad_Writer_Class.tell(dictMonadTell)($79)); | |
| }); | |
| }; | |
| var monadWriterMaybeT = function (dictMonadWriter) { | |
| return new Control_Monad_Writer_Class.MonadWriter(function () { | |
| return monadTellMaybeT(dictMonadWriter.MonadTell0()); | |
| }, mapMaybeT(function (m) { | |
| return Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(Control_Monad_Writer_Class.listen(dictMonadWriter)(m))(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())(Data_Functor.map(Data_Maybe.functorMaybe)(function (r) { | |
| return new Data_Tuple.Tuple(r, v.value1); | |
| })(v.value0)); | |
| }); | |
| }), mapMaybeT(function (m) { | |
| return Control_Monad_Writer_Class.pass(dictMonadWriter)(Control_Bind.bind(((dictMonadWriter.MonadTell0()).Monad0()).Bind1())(m)(function (v) { | |
| return Control_Applicative.pure(((dictMonadWriter.MonadTell0()).Monad0()).Applicative0())((function () { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return new Data_Tuple.Tuple(Data_Maybe.Nothing.value, Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return new Data_Tuple.Tuple(new Data_Maybe.Just(v.value0.value0), v.value0.value1); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Maybe.Trans line 122, column 10 - line 124, column 42: " + [ v.constructor.name ]); | |
| })()); | |
| })); | |
| })); | |
| }; | |
| var monadThrowMaybeT = function (dictMonadThrow) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadMaybeT(dictMonadThrow.Monad0()); | |
| }, function (e) { | |
| return Control_Monad_Trans_Class.lift(monadTransMaybeT)(dictMonadThrow.Monad0())(Control_Monad_Error_Class.throwError(dictMonadThrow)(e)); | |
| }); | |
| }; | |
| var monadErrorMaybeT = function (dictMonadError) { | |
| return new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowMaybeT(dictMonadError.MonadThrow0()); | |
| }, function (v) { | |
| return function (h) { | |
| return MaybeT(Control_Monad_Error_Class.catchError(dictMonadError)(v)(function (a) { | |
| var v1 = h(a); | |
| return v1; | |
| })); | |
| }; | |
| }); | |
| }; | |
| var altMaybeT = function (dictMonad) { | |
| return new Control_Alt.Alt(function () { | |
| return functorMaybeT(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(function (v2) { | |
| if (v2 instanceof Data_Maybe.Nothing) { | |
| return v1; | |
| }; | |
| return Control_Applicative.pure(dictMonad.Applicative0())(v2); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var plusMaybeT = function (dictMonad) { | |
| return new Control_Plus.Plus(function () { | |
| return altMaybeT(dictMonad); | |
| }, Control_Applicative.pure(dictMonad.Applicative0())(Data_Maybe.Nothing.value)); | |
| }; | |
| var alternativeMaybeT = function (dictMonad) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeMaybeT(dictMonad); | |
| }, function () { | |
| return plusMaybeT(dictMonad); | |
| }); | |
| }; | |
| var monadZeroMaybeT = function (dictMonad) { | |
| return new Control_MonadZero.MonadZero(function () { | |
| return alternativeMaybeT(dictMonad); | |
| }, function () { | |
| return monadMaybeT(dictMonad); | |
| }); | |
| }; | |
| var monadPlusMaybeT = function (dictMonad) { | |
| return new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroMaybeT(dictMonad); | |
| }); | |
| }; | |
| exports["MaybeT"] = MaybeT; | |
| exports["mapMaybeT"] = mapMaybeT; | |
| exports["runMaybeT"] = runMaybeT; | |
| exports["newtypeMaybeT"] = newtypeMaybeT; | |
| exports["functorMaybeT"] = functorMaybeT; | |
| exports["applyMaybeT"] = applyMaybeT; | |
| exports["applicativeMaybeT"] = applicativeMaybeT; | |
| exports["bindMaybeT"] = bindMaybeT; | |
| exports["monadMaybeT"] = monadMaybeT; | |
| exports["monadTransMaybeT"] = monadTransMaybeT; | |
| exports["altMaybeT"] = altMaybeT; | |
| exports["plusMaybeT"] = plusMaybeT; | |
| exports["alternativeMaybeT"] = alternativeMaybeT; | |
| exports["monadPlusMaybeT"] = monadPlusMaybeT; | |
| exports["monadZeroMaybeT"] = monadZeroMaybeT; | |
| exports["monadRecMaybeT"] = monadRecMaybeT; | |
| exports["monadEffMaybe"] = monadEffMaybe; | |
| exports["monadContMaybeT"] = monadContMaybeT; | |
| exports["monadThrowMaybeT"] = monadThrowMaybeT; | |
| exports["monadErrorMaybeT"] = monadErrorMaybeT; | |
| exports["monadAskMaybeT"] = monadAskMaybeT; | |
| exports["monadReaderMaybeT"] = monadReaderMaybeT; | |
| exports["monadStateMaybeT"] = monadStateMaybeT; | |
| exports["monadTellMaybeT"] = monadTellMaybeT; | |
| exports["monadWriterMaybeT"] = monadWriterMaybeT; | |
| })(PS["Control.Monad.Maybe.Trans"] = PS["Control.Monad.Maybe.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the reader monad transformer, `ReaderT`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Distributive = PS["Data.Distributive"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The reader monad transformer. | |
| // | | |
| // | This monad transformer extends the base monad transformer with a _global context_ of | |
| // | type `r`. | |
| // | | |
| // | The `MonadReader` type class describes the operations supported by this monad. | |
| var ReaderT = function (x) { | |
| return x; | |
| }; | |
| // | Change the type of the context in a `ReaderT` monad action. | |
| var withReaderT = function (f) { | |
| return function (v) { | |
| return function ($66) { | |
| return v(f($66)); | |
| }; | |
| }; | |
| }; | |
| // | Run a computation in the `ReaderT` monad. | |
| var runReaderT = function (v) { | |
| return v; | |
| }; | |
| var newtypeReaderT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, ReaderT); | |
| var monadTransReaderT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function ($67) { | |
| return ReaderT(Data_Function["const"]($67)); | |
| }; | |
| }); | |
| // | Change the type of the result in a `ReaderT` monad action. | |
| var mapReaderT = function (f) { | |
| return function (v) { | |
| return function ($68) { | |
| return f(v($68)); | |
| }; | |
| }; | |
| }; | |
| var functorReaderT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function ($69) { | |
| return mapReaderT(Data_Functor.map(dictFunctor)($69)); | |
| }); | |
| }; | |
| var distributiveReaderT = function (dictDistributive) { | |
| return new Data_Distributive.Distributive(function () { | |
| return functorReaderT(dictDistributive.Functor0()); | |
| }, function (dictFunctor) { | |
| return function (f) { | |
| return function ($70) { | |
| return Data_Distributive.distribute(distributiveReaderT(dictDistributive))(dictFunctor)(Data_Functor.map(dictFunctor)(f)($70)); | |
| }; | |
| }; | |
| }, function (dictFunctor) { | |
| return function (a) { | |
| return function (e) { | |
| return Data_Distributive.collect(dictDistributive)(dictFunctor)(function (r) { | |
| return r(e); | |
| })(a); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var applyReaderT = function (dictApply) { | |
| return new Control_Apply.Apply(function () { | |
| return functorReaderT(dictApply.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return function (r) { | |
| return Control_Apply.apply(dictApply)(v(r))(v1(r)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var bindReaderT = function (dictBind) { | |
| return new Control_Bind.Bind(function () { | |
| return applyReaderT(dictBind.Apply0()); | |
| }, function (v) { | |
| return function (k) { | |
| return function (r) { | |
| return Control_Bind.bind(dictBind)(v(r))(function (a) { | |
| var v1 = k(a); | |
| return v1(r); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var semigroupReaderT = function (dictApply) { | |
| return function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(Control_Apply.lift2(applyReaderT(dictApply))(Data_Semigroup.append(dictSemigroup))); | |
| }; | |
| }; | |
| var applicativeReaderT = function (dictApplicative) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyReaderT(dictApplicative.Apply0()); | |
| }, function ($71) { | |
| return ReaderT(Data_Function["const"](Control_Applicative.pure(dictApplicative)($71))); | |
| }); | |
| }; | |
| var monadReaderT = function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeReaderT(dictMonad.Applicative0()); | |
| }, function () { | |
| return bindReaderT(dictMonad.Bind1()); | |
| }); | |
| }; | |
| var monadAskReaderT = function (dictMonad) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadReaderT(dictMonad); | |
| }, Control_Applicative.pure(dictMonad.Applicative0())); | |
| }; | |
| var monadReaderReaderT = function (dictMonad) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskReaderT(dictMonad); | |
| }, withReaderT); | |
| }; | |
| var monadContReaderT = function (dictMonadCont) { | |
| return new Control_Monad_Cont_Class.MonadCont(function () { | |
| return monadReaderT(dictMonadCont.Monad0()); | |
| }, function (f) { | |
| return function (r) { | |
| return Control_Monad_Cont_Class.callCC(dictMonadCont)(function (c) { | |
| var v = f(function ($72) { | |
| return ReaderT(Data_Function["const"](c($72))); | |
| }); | |
| return v(r); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var monadEffReader = function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadReaderT(dictMonadEff.Monad0()); | |
| }, function ($73) { | |
| return Control_Monad_Trans_Class.lift(monadTransReaderT)(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($73)); | |
| }); | |
| }; | |
| var monadRecReaderT = function (dictMonadRec) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadReaderT(dictMonadRec.Monad0()); | |
| }, function (k) { | |
| return function (a) { | |
| var k$prime = function (r) { | |
| return function (a$prime) { | |
| var v = k(a$prime); | |
| return Control_Bind.bindFlipped((dictMonadRec.Monad0()).Bind1())(Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0()))(v(r)); | |
| }; | |
| }; | |
| return function (r) { | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(k$prime(r))(a); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var monadStateReaderT = function (dictMonadState) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadReaderT(dictMonadState.Monad0()); | |
| }, function ($74) { | |
| return Control_Monad_Trans_Class.lift(monadTransReaderT)(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)($74)); | |
| }); | |
| }; | |
| var monadTellReaderT = function (dictMonadTell) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadReaderT(dictMonadTell.Monad0()); | |
| }, function ($75) { | |
| return Control_Monad_Trans_Class.lift(monadTransReaderT)(dictMonadTell.Monad0())(Control_Monad_Writer_Class.tell(dictMonadTell)($75)); | |
| }); | |
| }; | |
| var monadWriterReaderT = function (dictMonadWriter) { | |
| return new Control_Monad_Writer_Class.MonadWriter(function () { | |
| return monadTellReaderT(dictMonadWriter.MonadTell0()); | |
| }, mapReaderT(Control_Monad_Writer_Class.listen(dictMonadWriter)), mapReaderT(Control_Monad_Writer_Class.pass(dictMonadWriter))); | |
| }; | |
| var monadThrowReaderT = function (dictMonadThrow) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadReaderT(dictMonadThrow.Monad0()); | |
| }, function ($76) { | |
| return Control_Monad_Trans_Class.lift(monadTransReaderT)(dictMonadThrow.Monad0())(Control_Monad_Error_Class.throwError(dictMonadThrow)($76)); | |
| }); | |
| }; | |
| var monadErrorReaderT = function (dictMonadError) { | |
| return new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowReaderT(dictMonadError.MonadThrow0()); | |
| }, function (v) { | |
| return function (h) { | |
| return function (r) { | |
| return Control_Monad_Error_Class.catchError(dictMonadError)(v(r))(function (e) { | |
| var v1 = h(e); | |
| return v1(r); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var monoidReaderT = function (dictApplicative) { | |
| return function (dictMonoid) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupReaderT(dictApplicative.Apply0())(dictMonoid.Semigroup0()); | |
| }, Control_Applicative.pure(applicativeReaderT(dictApplicative))(Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }; | |
| var altReaderT = function (dictAlt) { | |
| return new Control_Alt.Alt(function () { | |
| return functorReaderT(dictAlt.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return function (r) { | |
| return Control_Alt.alt(dictAlt)(v(r))(v1(r)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var plusReaderT = function (dictPlus) { | |
| return new Control_Plus.Plus(function () { | |
| return altReaderT(dictPlus.Alt0()); | |
| }, Data_Function["const"](Control_Plus.empty(dictPlus))); | |
| }; | |
| var alternativeReaderT = function (dictAlternative) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeReaderT(dictAlternative.Applicative0()); | |
| }, function () { | |
| return plusReaderT(dictAlternative.Plus1()); | |
| }); | |
| }; | |
| var monadZeroReaderT = function (dictMonadZero) { | |
| return new Control_MonadZero.MonadZero(function () { | |
| return alternativeReaderT(dictMonadZero.Alternative1()); | |
| }, function () { | |
| return monadReaderT(dictMonadZero.Monad0()); | |
| }); | |
| }; | |
| var monadPlusReaderT = function (dictMonadPlus) { | |
| return new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroReaderT(dictMonadPlus.MonadZero0()); | |
| }); | |
| }; | |
| exports["ReaderT"] = ReaderT; | |
| exports["mapReaderT"] = mapReaderT; | |
| exports["runReaderT"] = runReaderT; | |
| exports["withReaderT"] = withReaderT; | |
| exports["newtypeReaderT"] = newtypeReaderT; | |
| exports["functorReaderT"] = functorReaderT; | |
| exports["applyReaderT"] = applyReaderT; | |
| exports["applicativeReaderT"] = applicativeReaderT; | |
| exports["altReaderT"] = altReaderT; | |
| exports["plusReaderT"] = plusReaderT; | |
| exports["alternativeReaderT"] = alternativeReaderT; | |
| exports["bindReaderT"] = bindReaderT; | |
| exports["monadReaderT"] = monadReaderT; | |
| exports["monadZeroReaderT"] = monadZeroReaderT; | |
| exports["semigroupReaderT"] = semigroupReaderT; | |
| exports["monoidReaderT"] = monoidReaderT; | |
| exports["monadPlusReaderT"] = monadPlusReaderT; | |
| exports["monadTransReaderT"] = monadTransReaderT; | |
| exports["monadEffReader"] = monadEffReader; | |
| exports["monadContReaderT"] = monadContReaderT; | |
| exports["monadThrowReaderT"] = monadThrowReaderT; | |
| exports["monadErrorReaderT"] = monadErrorReaderT; | |
| exports["monadAskReaderT"] = monadAskReaderT; | |
| exports["monadReaderReaderT"] = monadReaderReaderT; | |
| exports["monadStateReaderT"] = monadStateReaderT; | |
| exports["monadTellReaderT"] = monadTellReaderT; | |
| exports["monadWriterReaderT"] = monadWriterReaderT; | |
| exports["distributiveReaderT"] = distributiveReaderT; | |
| exports["monadRecReaderT"] = monadRecReaderT; | |
| })(PS["Control.Monad.Reader.Trans"] = PS["Control.Monad.Reader.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the writer monad transformer, `WriterT`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The writer monad transformer. | |
| // | | |
| // | This monad transformer extends the base monad with a monoidal accumulator of | |
| // | type `w`. | |
| // | | |
| // | The `MonadWriter` type class describes the operations supported by this monad. | |
| var WriterT = function (x) { | |
| return x; | |
| }; | |
| // | Run a computation in the `WriterT` monad. | |
| var runWriterT = function (v) { | |
| return v; | |
| }; | |
| var newtypeWriterT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, WriterT); | |
| var monadTransWriterT = function (dictMonoid) { | |
| return new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function (m) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m)(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v, Data_Monoid.mempty(dictMonoid))); | |
| }); | |
| }; | |
| }); | |
| }; | |
| // | Change the accumulator and base monad types in a `WriterT` monad action. | |
| var mapWriterT = function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| var functorWriterT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return mapWriterT(Data_Functor.map(dictFunctor)(function (v) { | |
| return new Data_Tuple.Tuple(f(v.value0), v.value1); | |
| })); | |
| }); | |
| }; | |
| // | Run a computation in the `WriterT` monad, discarding the result. | |
| var execWriterT = function (dictFunctor) { | |
| return function (v) { | |
| return Data_Functor.map(dictFunctor)(Data_Tuple.snd)(v); | |
| }; | |
| }; | |
| var applyWriterT = function (dictSemigroup) { | |
| return function (dictApply) { | |
| return new Control_Apply.Apply(function () { | |
| return functorWriterT(dictApply.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| var k = function (v3) { | |
| return function (v4) { | |
| return new Data_Tuple.Tuple(v3.value0(v4.value0), Data_Semigroup.append(dictSemigroup)(v3.value1)(v4.value1)); | |
| }; | |
| }; | |
| return Control_Apply.apply(dictApply)(Data_Functor.map(dictApply.Functor0())(k)(v))(v1); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bindWriterT = function (dictSemigroup) { | |
| return function (dictBind) { | |
| return new Control_Bind.Bind(function () { | |
| return applyWriterT(dictSemigroup)(dictBind.Apply0()); | |
| }, function (v) { | |
| return function (k) { | |
| return WriterT(Control_Bind.bind(dictBind)(v)(function (v1) { | |
| var v2 = k(v1.value0); | |
| return Data_Functor.map((dictBind.Apply0()).Functor0())(function (v3) { | |
| return new Data_Tuple.Tuple(v3.value0, Data_Semigroup.append(dictSemigroup)(v1.value1)(v3.value1)); | |
| })(v2); | |
| })); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var applicativeWriterT = function (dictMonoid) { | |
| return function (dictApplicative) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyWriterT(dictMonoid.Semigroup0())(dictApplicative.Apply0()); | |
| }, function (a) { | |
| return WriterT(Control_Applicative.pure(dictApplicative)(new Data_Tuple.Tuple(a, Data_Monoid.mempty(dictMonoid)))); | |
| }); | |
| }; | |
| }; | |
| var monadWriterT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeWriterT(dictMonoid)(dictMonad.Applicative0()); | |
| }, function () { | |
| return bindWriterT(dictMonoid.Semigroup0())(dictMonad.Bind1()); | |
| }); | |
| }; | |
| }; | |
| var monadAskWriterT = function (dictMonoid) { | |
| return function (dictMonadAsk) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadWriterT(dictMonoid)(dictMonadAsk.Monad0()); | |
| }, Control_Monad_Trans_Class.lift(monadTransWriterT(dictMonoid))(dictMonadAsk.Monad0())(Control_Monad_Reader_Class.ask(dictMonadAsk))); | |
| }; | |
| }; | |
| var monadReaderWriterT = function (dictMonoid) { | |
| return function (dictMonadReader) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskWriterT(dictMonoid)(dictMonadReader.MonadAsk0()); | |
| }, function (f) { | |
| return mapWriterT(Control_Monad_Reader_Class.local(dictMonadReader)(f)); | |
| }); | |
| }; | |
| }; | |
| var monadContWriterT = function (dictMonoid) { | |
| return function (dictMonadCont) { | |
| return new Control_Monad_Cont_Class.MonadCont(function () { | |
| return monadWriterT(dictMonoid)(dictMonadCont.Monad0()); | |
| }, function (f) { | |
| return WriterT(Control_Monad_Cont_Class.callCC(dictMonadCont)(function (c) { | |
| var v = f(function (a) { | |
| return WriterT(c(new Data_Tuple.Tuple(a, Data_Monoid.mempty(dictMonoid)))); | |
| }); | |
| return v; | |
| })); | |
| }); | |
| }; | |
| }; | |
| var monadEffWriter = function (dictMonoid) { | |
| return function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadWriterT(dictMonoid)(dictMonadEff.Monad0()); | |
| }, function ($123) { | |
| return Control_Monad_Trans_Class.lift(monadTransWriterT(dictMonoid))(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($123)); | |
| }); | |
| }; | |
| }; | |
| var monadRecWriterT = function (dictMonoid) { | |
| return function (dictMonadRec) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadWriterT(dictMonoid)(dictMonadRec.Monad0()); | |
| }, function (f) { | |
| return function (a) { | |
| var f$prime = function (v) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())((function () { | |
| var v1 = f(v.value0); | |
| return v1; | |
| })())(function (v1) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())((function () { | |
| if (v1.value0 instanceof Control_Monad_Rec_Class.Loop) { | |
| return new Control_Monad_Rec_Class.Loop(new Data_Tuple.Tuple(v1.value0.value0, Data_Semigroup.append(dictMonoid.Semigroup0())(v.value1)(v1.value1))); | |
| }; | |
| if (v1.value0 instanceof Control_Monad_Rec_Class.Done) { | |
| return new Control_Monad_Rec_Class.Done(new Data_Tuple.Tuple(v1.value0.value0, Data_Semigroup.append(dictMonoid.Semigroup0())(v.value1)(v1.value1))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.Writer.Trans line 85, column 16 - line 87, column 47: " + [ v1.value0.constructor.name ]); | |
| })()); | |
| }); | |
| }; | |
| return WriterT(Control_Monad_Rec_Class.tailRecM(dictMonadRec)(f$prime)(new Data_Tuple.Tuple(a, Data_Monoid.mempty(dictMonoid)))); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadStateWriterT = function (dictMonoid) { | |
| return function (dictMonadState) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadWriterT(dictMonoid)(dictMonadState.Monad0()); | |
| }, function (f) { | |
| return Control_Monad_Trans_Class.lift(monadTransWriterT(dictMonoid))(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)(f)); | |
| }); | |
| }; | |
| }; | |
| var monadTellWriterT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadWriterT(dictMonoid)(dictMonad); | |
| }, function ($124) { | |
| return WriterT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Tuple.Tuple.create(Data_Unit.unit)($124))); | |
| }); | |
| }; | |
| }; | |
| var monadWriterWriterT = function (dictMonoid) { | |
| return function (dictMonad) { | |
| return new Control_Monad_Writer_Class.MonadWriter(function () { | |
| return monadTellWriterT(dictMonoid)(dictMonad); | |
| }, function (v) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(function (v1) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(new Data_Tuple.Tuple(v1.value0, v1.value1), v1.value1)); | |
| }); | |
| }, function (v) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(function (v1) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value0.value0, v1.value0.value1(v1.value1))); | |
| }); | |
| }); | |
| }; | |
| }; | |
| var monadThrowWriterT = function (dictMonoid) { | |
| return function (dictMonadThrow) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadWriterT(dictMonoid)(dictMonadThrow.Monad0()); | |
| }, function (e) { | |
| return Control_Monad_Trans_Class.lift(monadTransWriterT(dictMonoid))(dictMonadThrow.Monad0())(Control_Monad_Error_Class.throwError(dictMonadThrow)(e)); | |
| }); | |
| }; | |
| }; | |
| var monadErrorWriterT = function (dictMonoid) { | |
| return function (dictMonadError) { | |
| return new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowWriterT(dictMonoid)(dictMonadError.MonadThrow0()); | |
| }, function (v) { | |
| return function (h) { | |
| return WriterT(Control_Monad_Error_Class.catchError(dictMonadError)(v)(function (e) { | |
| var v1 = h(e); | |
| return v1; | |
| })); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var altWriterT = function (dictAlt) { | |
| return new Control_Alt.Alt(function () { | |
| return functorWriterT(dictAlt.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Alt.alt(dictAlt)(v)(v1); | |
| }; | |
| }); | |
| }; | |
| var plusWriterT = function (dictPlus) { | |
| return new Control_Plus.Plus(function () { | |
| return altWriterT(dictPlus.Alt0()); | |
| }, Control_Plus.empty(dictPlus)); | |
| }; | |
| var alternativeWriterT = function (dictMonoid) { | |
| return function (dictAlternative) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeWriterT(dictMonoid)(dictAlternative.Applicative0()); | |
| }, function () { | |
| return plusWriterT(dictAlternative.Plus1()); | |
| }); | |
| }; | |
| }; | |
| var monadZeroWriterT = function (dictMonoid) { | |
| return function (dictMonadZero) { | |
| return new Control_MonadZero.MonadZero(function () { | |
| return alternativeWriterT(dictMonoid)(dictMonadZero.Alternative1()); | |
| }, function () { | |
| return monadWriterT(dictMonoid)(dictMonadZero.Monad0()); | |
| }); | |
| }; | |
| }; | |
| var monadPlusWriterT = function (dictMonoid) { | |
| return function (dictMonadPlus) { | |
| return new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroWriterT(dictMonoid)(dictMonadPlus.MonadZero0()); | |
| }); | |
| }; | |
| }; | |
| exports["WriterT"] = WriterT; | |
| exports["execWriterT"] = execWriterT; | |
| exports["mapWriterT"] = mapWriterT; | |
| exports["runWriterT"] = runWriterT; | |
| exports["newtypeWriterT"] = newtypeWriterT; | |
| exports["functorWriterT"] = functorWriterT; | |
| exports["applyWriterT"] = applyWriterT; | |
| exports["applicativeWriterT"] = applicativeWriterT; | |
| exports["altWriterT"] = altWriterT; | |
| exports["plusWriterT"] = plusWriterT; | |
| exports["alternativeWriterT"] = alternativeWriterT; | |
| exports["bindWriterT"] = bindWriterT; | |
| exports["monadWriterT"] = monadWriterT; | |
| exports["monadRecWriterT"] = monadRecWriterT; | |
| exports["monadZeroWriterT"] = monadZeroWriterT; | |
| exports["monadPlusWriterT"] = monadPlusWriterT; | |
| exports["monadTransWriterT"] = monadTransWriterT; | |
| exports["monadEffWriter"] = monadEffWriter; | |
| exports["monadContWriterT"] = monadContWriterT; | |
| exports["monadThrowWriterT"] = monadThrowWriterT; | |
| exports["monadErrorWriterT"] = monadErrorWriterT; | |
| exports["monadAskWriterT"] = monadAskWriterT; | |
| exports["monadReaderWriterT"] = monadReaderWriterT; | |
| exports["monadStateWriterT"] = monadStateWriterT; | |
| exports["monadTellWriterT"] = monadTellWriterT; | |
| exports["monadWriterWriterT"] = monadWriterWriterT; | |
| })(PS["Control.Monad.Writer.Trans"] = PS["Control.Monad.Writer.Trans"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Comonad = PS["Control.Comonad"]; | |
| var Control_Extend = PS["Control.Extend"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| var App = function (x) { | |
| return x; | |
| }; | |
| var traversableApp = function (dictTraversable) { | |
| return dictTraversable; | |
| }; | |
| var showApp = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(App " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var plusApp = function (dictPlus) { | |
| return dictPlus; | |
| }; | |
| var newtypeApp = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, App); | |
| var monadZeroApp = function (dictMonadZero) { | |
| return dictMonadZero; | |
| }; | |
| var monadPlusApp = function (dictMonadPlus) { | |
| return dictMonadPlus; | |
| }; | |
| var monadApp = function (dictMonad) { | |
| return dictMonad; | |
| }; | |
| var lazyApp = function (dictLazy) { | |
| return dictLazy; | |
| }; | |
| // safe as newtypes have no runtime representation | |
| var hoistLowerApp = Unsafe_Coerce.unsafeCoerce; | |
| var hoistLiftApp = Unsafe_Coerce.unsafeCoerce; | |
| var hoistApp = function (f) { | |
| return function (v) { | |
| return f(v); | |
| }; | |
| }; | |
| var functorApp = function (dictFunctor) { | |
| return dictFunctor; | |
| }; | |
| var foldableApp = function (dictFoldable) { | |
| return dictFoldable; | |
| }; | |
| var extendApp = function (dictExtend) { | |
| return dictExtend; | |
| }; | |
| var eq1App = function (dictEq1) { | |
| return new Data_Eq.Eq1(function (dictEq) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Eq.eq1(dictEq1)(dictEq)(v)(v1); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var eqApp = function (dictEq1) { | |
| return function (dictEq) { | |
| return new Data_Eq.Eq(Data_Eq.eq1(eq1App(dictEq1))(dictEq)); | |
| }; | |
| }; | |
| var ord1App = function (dictOrd1) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1App(dictOrd1.Eq10()); | |
| }, function (dictOrd) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Ord.compare1(dictOrd1)(dictOrd)(v)(v1); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var ordApp = function (dictOrd1) { | |
| return function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqApp(dictOrd1.Eq10())(dictOrd.Eq0()); | |
| }, Data_Ord.compare1(ord1App(dictOrd1))(dictOrd)); | |
| }; | |
| }; | |
| var comonadApp = function (dictComonad) { | |
| return dictComonad; | |
| }; | |
| var bindApp = function (dictBind) { | |
| return dictBind; | |
| }; | |
| var applyApp = function (dictApply) { | |
| return dictApply; | |
| }; | |
| var applicativeApp = function (dictApplicative) { | |
| return dictApplicative; | |
| }; | |
| var alternativeApp = function (dictAlternative) { | |
| return dictAlternative; | |
| }; | |
| var altApp = function (dictAlt) { | |
| return dictAlt; | |
| }; | |
| exports["App"] = App; | |
| exports["hoistApp"] = hoistApp; | |
| exports["hoistLiftApp"] = hoistLiftApp; | |
| exports["hoistLowerApp"] = hoistLowerApp; | |
| exports["newtypeApp"] = newtypeApp; | |
| exports["eqApp"] = eqApp; | |
| exports["eq1App"] = eq1App; | |
| exports["ordApp"] = ordApp; | |
| exports["ord1App"] = ord1App; | |
| exports["showApp"] = showApp; | |
| exports["functorApp"] = functorApp; | |
| exports["applyApp"] = applyApp; | |
| exports["applicativeApp"] = applicativeApp; | |
| exports["bindApp"] = bindApp; | |
| exports["monadApp"] = monadApp; | |
| exports["altApp"] = altApp; | |
| exports["plusApp"] = plusApp; | |
| exports["alternativeApp"] = alternativeApp; | |
| exports["monadZeroApp"] = monadZeroApp; | |
| exports["monadPlusApp"] = monadPlusApp; | |
| exports["lazyApp"] = lazyApp; | |
| exports["foldableApp"] = foldableApp; | |
| exports["traversableApp"] = traversableApp; | |
| exports["extendApp"] = extendApp; | |
| exports["comonadApp"] = comonadApp; | |
| })(PS["Data.Functor.App"] = PS["Data.Functor.App"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_App = PS["Data.Functor.App"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | `Compose f g` is the composition of the two functors `f` and `g`. | |
| var Compose = function (x) { | |
| return x; | |
| }; | |
| var showCompose = function (dictShow) { | |
| return new Data_Show.Show(function (v) { | |
| return "(Compose " + (Data_Show.show(dictShow)(v) + ")"); | |
| }); | |
| }; | |
| var newtypeCompose = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Compose); | |
| var functorCompose = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return Compose(Data_Functor.map(dictFunctor)(Data_Functor.map(dictFunctor1)(f))(v)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var foldableCompose = function (dictFoldable) { | |
| return function (dictFoldable1) { | |
| return new Data_Foldable.Foldable(function (dictMonoid) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Foldable.foldMap(dictFoldable)(dictMonoid)(Data_Foldable.foldMap(dictFoldable1)(dictMonoid)(f))(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (i) { | |
| return function (v) { | |
| return Data_Foldable.foldl(dictFoldable)(Data_Foldable.foldl(dictFoldable1)(f))(i)(v); | |
| }; | |
| }; | |
| }, function (f) { | |
| return function (i) { | |
| return function (v) { | |
| return Data_Foldable.foldr(dictFoldable)(Data_Function.flip(Data_Foldable.foldr(dictFoldable1)(f)))(i)(v); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var traversableCompose = function (dictTraversable) { | |
| return function (dictTraversable1) { | |
| return new Data_Traversable.Traversable(function () { | |
| return foldableCompose(dictTraversable.Foldable1())(dictTraversable1.Foldable1()); | |
| }, function () { | |
| return functorCompose(dictTraversable.Functor0())(dictTraversable1.Functor0()); | |
| }, function (dictApplicative) { | |
| return Data_Traversable.traverse(traversableCompose(dictTraversable)(dictTraversable1))(dictApplicative)(Control_Category.id(Control_Category.categoryFn)); | |
| }, function (dictApplicative) { | |
| return function (f) { | |
| return function (v) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Compose)(Data_Traversable.traverse(dictTraversable)(dictApplicative)(Data_Traversable.traverse(dictTraversable1)(dictApplicative)(f))(v)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var eq1Compose = function (dictEq1) { | |
| return function (dictEq11) { | |
| return new Data_Eq.Eq1(function (dictEq) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Eq.eq1(dictEq1)(Data_Functor_App.eqApp(dictEq11)(dictEq))(Data_Functor_App.hoistLiftApp(v))(Data_Functor_App.hoistLiftApp(v1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var eqCompose = function (dictEq1) { | |
| return function (dictEq11) { | |
| return function (dictEq) { | |
| return new Data_Eq.Eq(Data_Eq.eq1(eq1Compose(dictEq1)(dictEq11))(dictEq)); | |
| }; | |
| }; | |
| }; | |
| var ord1Compose = function (dictOrd1) { | |
| return function (dictOrd11) { | |
| return new Data_Ord.Ord1(function () { | |
| return eq1Compose(dictOrd1.Eq10())(dictOrd11.Eq10()); | |
| }, function (dictOrd) { | |
| return function (v) { | |
| return function (v1) { | |
| return Data_Ord.compare1(dictOrd1)(Data_Functor_App.ordApp(dictOrd11)(dictOrd))(Data_Functor_App.hoistLiftApp(v))(Data_Functor_App.hoistLiftApp(v1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var ordCompose = function (dictOrd1) { | |
| return function (dictOrd11) { | |
| return function (dictOrd) { | |
| return new Data_Ord.Ord(function () { | |
| return eqCompose(dictOrd1.Eq10())(dictOrd11.Eq10())(dictOrd.Eq0()); | |
| }, Data_Ord.compare1(ord1Compose(dictOrd1)(dictOrd11))(dictOrd)); | |
| }; | |
| }; | |
| }; | |
| var bihoistCompose = function (dictFunctor) { | |
| return function (natF) { | |
| return function (natG) { | |
| return function (v) { | |
| return natF(Data_Functor.map(dictFunctor)(natG)(v)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var applyCompose = function (dictApply) { | |
| return function (dictApply1) { | |
| return new Control_Apply.Apply(function () { | |
| return functorCompose(dictApply.Functor0())(dictApply1.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Compose(Control_Apply.apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Control_Apply.apply(dictApply1))(v))(v1)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var applicativeCompose = function (dictApplicative) { | |
| return function (dictApplicative1) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyCompose(dictApplicative.Apply0())(dictApplicative1.Apply0()); | |
| }, function ($75) { | |
| return Compose(Control_Applicative.pure(dictApplicative)(Control_Applicative.pure(dictApplicative1)($75))); | |
| }); | |
| }; | |
| }; | |
| var altCompose = function (dictAlt) { | |
| return function (dictFunctor) { | |
| return new Control_Alt.Alt(function () { | |
| return functorCompose(dictAlt.Functor0())(dictFunctor); | |
| }, function (v) { | |
| return function (v1) { | |
| return Compose(Control_Alt.alt(dictAlt)(v)(v1)); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var plusCompose = function (dictPlus) { | |
| return function (dictFunctor) { | |
| return new Control_Plus.Plus(function () { | |
| return altCompose(dictPlus.Alt0())(dictFunctor); | |
| }, Control_Plus.empty(dictPlus)); | |
| }; | |
| }; | |
| var alternativeCompose = function (dictAlternative) { | |
| return function (dictApplicative) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeCompose(dictAlternative.Applicative0())(dictApplicative); | |
| }, function () { | |
| return plusCompose(dictAlternative.Plus1())((dictApplicative.Apply0()).Functor0()); | |
| }); | |
| }; | |
| }; | |
| exports["Compose"] = Compose; | |
| exports["bihoistCompose"] = bihoistCompose; | |
| exports["newtypeCompose"] = newtypeCompose; | |
| exports["eq1Compose"] = eq1Compose; | |
| exports["eqCompose"] = eqCompose; | |
| exports["ord1Compose"] = ord1Compose; | |
| exports["ordCompose"] = ordCompose; | |
| exports["showCompose"] = showCompose; | |
| exports["functorCompose"] = functorCompose; | |
| exports["applyCompose"] = applyCompose; | |
| exports["applicativeCompose"] = applicativeCompose; | |
| exports["foldableCompose"] = foldableCompose; | |
| exports["traversableCompose"] = traversableCompose; | |
| exports["altCompose"] = altCompose; | |
| exports["plusCompose"] = plusCompose; | |
| exports["alternativeCompose"] = alternativeCompose; | |
| })(PS["Data.Functor.Compose"] = PS["Data.Functor.Compose"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad_Cont_Trans = PS["Control.Monad.Cont.Trans"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; | |
| var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; | |
| var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; | |
| var Control_Monad_Maybe_Trans = PS["Control.Monad.Maybe.Trans"]; | |
| var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; | |
| var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Functor_Compose = PS["Data.Functor.Compose"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The `ParCont` type constructor provides an `Applicative` instance | |
| // | based on `ContT Unit m`, which waits for multiple continuations to be | |
| // | resumed simultaneously. | |
| // | | |
| // | ParCont sections of code can be embedded in sequential code by using | |
| // | the `parallel` and `sequential` functions: | |
| // | | |
| // | ```purescript | |
| // | loadModel :: ContT Unit (Eff (ajax :: AJAX)) Model | |
| // | loadModel = do | |
| // | token <- authenticate | |
| // | sequential $ | |
| // | Model <$> parallel (get "/products/popular/" token) | |
| // | <*> parallel (get "/categories/all" token) | |
| // | ``` | |
| var ParCont = function (x) { | |
| return x; | |
| }; | |
| // | The `Parallel` class abstracts over monads which support | |
| // | parallel composition via some related `Applicative`. | |
| var Parallel = function (Applicative1, Monad0, parallel, sequential) { | |
| this.Applicative1 = Applicative1; | |
| this.Monad0 = Monad0; | |
| this.parallel = parallel; | |
| this.sequential = sequential; | |
| }; | |
| var unsafeWithRef = Control_Monad_Eff_Unsafe.unsafeCoerceEff; | |
| var sequential = function (dict) { | |
| return dict.sequential; | |
| }; | |
| var parallel = function (dict) { | |
| return dict.parallel; | |
| }; | |
| var newtypeParCont = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, ParCont); | |
| var monadParWriterT = function (dictMonoid) { | |
| return function (dictParallel) { | |
| return new Parallel(function () { | |
| return Control_Monad_Writer_Trans.applicativeWriterT(dictMonoid)(dictParallel.Applicative1()); | |
| }, function () { | |
| return Control_Monad_Writer_Trans.monadWriterT(dictMonoid)(dictParallel.Monad0()); | |
| }, Control_Monad_Writer_Trans.mapWriterT(parallel(dictParallel)), Control_Monad_Writer_Trans.mapWriterT(sequential(dictParallel))); | |
| }; | |
| }; | |
| var monadParReaderT = function (dictParallel) { | |
| return new Parallel(function () { | |
| return Control_Monad_Reader_Trans.applicativeReaderT(dictParallel.Applicative1()); | |
| }, function () { | |
| return Control_Monad_Reader_Trans.monadReaderT(dictParallel.Monad0()); | |
| }, Control_Monad_Reader_Trans.mapReaderT(parallel(dictParallel)), Control_Monad_Reader_Trans.mapReaderT(sequential(dictParallel))); | |
| }; | |
| var monadParMaybeT = function (dictParallel) { | |
| return new Parallel(function () { | |
| return Data_Functor_Compose.applicativeCompose(dictParallel.Applicative1())(Data_Maybe.applicativeMaybe); | |
| }, function () { | |
| return Control_Monad_Maybe_Trans.monadMaybeT(dictParallel.Monad0()); | |
| }, function (v) { | |
| return parallel(dictParallel)(v); | |
| }, function (v) { | |
| return sequential(dictParallel)(v); | |
| }); | |
| }; | |
| var monadParExceptT = function (dictParallel) { | |
| return new Parallel(function () { | |
| return Data_Functor_Compose.applicativeCompose(dictParallel.Applicative1())(Data_Either.applicativeEither); | |
| }, function () { | |
| return Control_Monad_Except_Trans.monadExceptT(dictParallel.Monad0()); | |
| }, function (v) { | |
| return parallel(dictParallel)(v); | |
| }, function (v) { | |
| return sequential(dictParallel)(v); | |
| }); | |
| }; | |
| var monadParParCont = function (dictMonadEff) { | |
| return new Parallel(function () { | |
| return applicativeParCont(dictMonadEff); | |
| }, function () { | |
| return Control_Monad_Cont_Trans.monadContT(dictMonadEff.Monad0()); | |
| }, ParCont, function (v) { | |
| return v; | |
| }); | |
| }; | |
| var functorParCont = function (dictMonadEff) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function ($54) { | |
| return parallel(monadParParCont(dictMonadEff))(Data_Functor.map(Control_Monad_Cont_Trans.functorContT((((dictMonadEff.Monad0()).Bind1()).Apply0()).Functor0()))(f)(sequential(monadParParCont(dictMonadEff))($54))); | |
| }; | |
| }); | |
| }; | |
| var applyParCont = function (dictMonadEff) { | |
| return new Control_Apply.Apply(function () { | |
| return functorParCont(dictMonadEff); | |
| }, function (v) { | |
| return function (v1) { | |
| return ParCont(function (k) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.newRef(Data_Maybe.Nothing.value))))(function (v2) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.newRef(Data_Maybe.Nothing.value))))(function (v3) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadEff.Monad0()).Bind1())(Control_Monad_Cont_Trans.runContT(v)(function (a) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.readRef(v3))))(function (v4) { | |
| if (v4 instanceof Data_Maybe.Nothing) { | |
| return Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.writeRef(v2)(new Data_Maybe.Just(a)))); | |
| }; | |
| if (v4 instanceof Data_Maybe.Just) { | |
| return k(a(v4.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Parallel.Class line 81, column 7 - line 83, column 26: " + [ v4.constructor.name ]); | |
| }); | |
| }))(function () { | |
| return Control_Monad_Cont_Trans.runContT(v1)(function (b) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.readRef(v2))))(function (v4) { | |
| if (v4 instanceof Data_Maybe.Nothing) { | |
| return Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.writeRef(v3)(new Data_Maybe.Just(b)))); | |
| }; | |
| if (v4 instanceof Data_Maybe.Just) { | |
| return k(v4.value0(b)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Parallel.Class line 87, column 7 - line 89, column 26: " + [ v4.constructor.name ]); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var applicativeParCont = function (dictMonadEff) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyParCont(dictMonadEff); | |
| }, function ($55) { | |
| return parallel(monadParParCont(dictMonadEff))(Control_Applicative.pure(Control_Monad_Cont_Trans.applicativeContT((dictMonadEff.Monad0()).Applicative0()))($55)); | |
| }); | |
| }; | |
| var altParCont = function (dictMonadEff) { | |
| return new Control_Alt.Alt(function () { | |
| return functorParCont(dictMonadEff); | |
| }, function (v) { | |
| return function (v1) { | |
| return ParCont(function (k) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.newRef(false))))(function (v2) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadEff.Monad0()).Bind1())(Control_Monad_Cont_Trans.runContT(v)(function (a) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.readRef(v2))))(function (v3) { | |
| if (v3) { | |
| return Control_Applicative.pure((dictMonadEff.Monad0()).Applicative0())(Data_Unit.unit); | |
| }; | |
| return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.writeRef(v2)(true))))(function () { | |
| return k(a); | |
| }); | |
| }); | |
| }))(function () { | |
| return Control_Monad_Cont_Trans.runContT(v1)(function (a) { | |
| return Control_Bind.bind((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.readRef(v2))))(function (v3) { | |
| if (v3) { | |
| return Control_Applicative.pure((dictMonadEff.Monad0()).Applicative0())(Data_Unit.unit); | |
| }; | |
| return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadEff.Monad0()).Bind1())(Control_Monad_Eff_Class.liftEff(dictMonadEff)(unsafeWithRef(Control_Monad_Eff_Ref.writeRef(v2)(true))))(function () { | |
| return k(a); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }; | |
| }); | |
| }; | |
| var plusParCont = function (dictMonadEff) { | |
| return new Control_Plus.Plus(function () { | |
| return altParCont(dictMonadEff); | |
| }, ParCont(function (v) { | |
| return Control_Applicative.pure((dictMonadEff.Monad0()).Applicative0())(Data_Unit.unit); | |
| })); | |
| }; | |
| var alternativeParCont = function (dictMonadEff) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeParCont(dictMonadEff); | |
| }, function () { | |
| return plusParCont(dictMonadEff); | |
| }); | |
| }; | |
| exports["ParCont"] = ParCont; | |
| exports["Parallel"] = Parallel; | |
| exports["parallel"] = parallel; | |
| exports["sequential"] = sequential; | |
| exports["monadParExceptT"] = monadParExceptT; | |
| exports["monadParReaderT"] = monadParReaderT; | |
| exports["monadParWriterT"] = monadParWriterT; | |
| exports["monadParMaybeT"] = monadParMaybeT; | |
| exports["newtypeParCont"] = newtypeParCont; | |
| exports["functorParCont"] = functorParCont; | |
| exports["applyParCont"] = applyParCont; | |
| exports["applicativeParCont"] = applicativeParCont; | |
| exports["altParCont"] = altParCont; | |
| exports["plusParCont"] = plusParCont; | |
| exports["alternativeParCont"] = alternativeParCont; | |
| exports["monadParParCont"] = monadParParCont; | |
| })(PS["Control.Parallel.Class"] = PS["Control.Parallel.Class"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Parallel_Class = PS["Control.Parallel.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Traverse a collection in parallel, discarding any results. | |
| var parTraverse_ = function (dictParallel) { | |
| return function (dictFoldable) { | |
| return function (f) { | |
| return function ($8) { | |
| return Control_Parallel_Class.sequential(dictParallel)(Data_Foldable.traverse_(dictParallel.Applicative1())(dictFoldable)(function ($9) { | |
| return Control_Parallel_Class.parallel(dictParallel)(f($9)); | |
| })($8)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Traverse a collection in parallel. | |
| var parTraverse = function (dictParallel) { | |
| return function (dictTraversable) { | |
| return function (f) { | |
| return function ($10) { | |
| return Control_Parallel_Class.sequential(dictParallel)(Data_Traversable.traverse(dictTraversable)(dictParallel.Applicative1())(function ($11) { | |
| return Control_Parallel_Class.parallel(dictParallel)(f($11)); | |
| })($10)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var parSequence_ = function (dictParallel) { | |
| return function (dictFoldable) { | |
| return parTraverse_(dictParallel)(dictFoldable)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| var parSequence = function (dictParallel) { | |
| return function (dictTraversable) { | |
| return parTraverse(dictParallel)(dictTraversable)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| exports["parSequence"] = parSequence; | |
| exports["parSequence_"] = parSequence_; | |
| exports["parTraverse"] = parTraverse; | |
| exports["parTraverse_"] = parTraverse_; | |
| })(PS["Control.Parallel"] = PS["Control.Parallel"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A `Profunctor` is a `Functor` from the pair category `(Type^op, Type)` | |
| // | to `Type`. | |
| // | | |
| // | In other words, a `Profunctor` is a type constructor of two type | |
| // | arguments, which is contravariant in its first argument and covariant | |
| // | in its second argument. | |
| // | | |
| // | The `dimap` function can be used to map functions over both arguments | |
| // | simultaneously. | |
| // | | |
| // | A straightforward example of a profunctor is the function arrow `(->)`. | |
| // | | |
| // | Laws: | |
| // | | |
| // | - Identity: `dimap id id = id` | |
| // | - Composition: `dimap f1 g1 <<< dimap f2 g2 = dimap (f1 >>> f2) (g1 <<< g2)` | |
| var Profunctor = function (dimap) { | |
| this.dimap = dimap; | |
| }; | |
| var profunctorFn = new Profunctor(function (a2b) { | |
| return function (c2d) { | |
| return function (b2c) { | |
| return function ($9) { | |
| return c2d(b2c(a2b($9))); | |
| }; | |
| }; | |
| }; | |
| }); | |
| var dimap = function (dict) { | |
| return dict.dimap; | |
| }; | |
| // | Map a function over the (contravariant) first type argument only. | |
| var lmap = function (dictProfunctor) { | |
| return function (a2b) { | |
| return dimap(dictProfunctor)(a2b)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| }; | |
| // | Map a function over the (covariant) second type argument only. | |
| var rmap = function (dictProfunctor) { | |
| return function (b2c) { | |
| return dimap(dictProfunctor)(Control_Category.id(Control_Category.categoryFn))(b2c); | |
| }; | |
| }; | |
| var unwrapIso = function (dictProfunctor) { | |
| return function (dictNewtype) { | |
| return dimap(dictProfunctor)(Data_Newtype.wrap(dictNewtype))(Data_Newtype.unwrap(dictNewtype)); | |
| }; | |
| }; | |
| var wrapIso = function (dictProfunctor) { | |
| return function (dictNewtype) { | |
| return function (v) { | |
| return dimap(dictProfunctor)(Data_Newtype.unwrap(dictNewtype))(Data_Newtype.wrap(dictNewtype)); | |
| }; | |
| }; | |
| }; | |
| // | Lift a pure function into any `Profunctor` which is also a `Category`. | |
| var arr = function (dictCategory) { | |
| return function (dictProfunctor) { | |
| return function (f) { | |
| return rmap(dictProfunctor)(f)(Control_Category.id(dictCategory)); | |
| }; | |
| }; | |
| }; | |
| exports["Profunctor"] = Profunctor; | |
| exports["arr"] = arr; | |
| exports["dimap"] = dimap; | |
| exports["lmap"] = lmap; | |
| exports["rmap"] = rmap; | |
| exports["unwrapIso"] = unwrapIso; | |
| exports["wrapIso"] = wrapIso; | |
| exports["profunctorFn"] = profunctorFn; | |
| })(PS["Data.Profunctor"] = PS["Data.Profunctor"] || {}); | |
| (function(exports) { | |
| // | This module defines types and functions for working with coroutines. | |
| // | Coroutines are defined based on some underlying functor, which means that | |
| // | the same machinery can be used for coroutines which emit values, await values, | |
| // | fork, join, or any combination. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad_Except = PS["Control.Monad.Except"]; | |
| var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; | |
| var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Parallel = PS["Control.Parallel"]; | |
| var Control_Parallel_Class = PS["Control.Parallel.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Bifunctor = PS["Data.Bifunctor"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Profunctor = PS["Data.Profunctor"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A generating functor for transforming input values into output values. | |
| var Transform = function (x) { | |
| return x; | |
| }; | |
| // | A generating functor for emitting output values. | |
| var Emit = (function () { | |
| function Emit(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Emit.create = function (value0) { | |
| return function (value1) { | |
| return new Emit(value0, value1); | |
| }; | |
| }; | |
| return Emit; | |
| })(); | |
| // | A generating functor which yields a value before waiting for an input. | |
| var CoTransform = (function () { | |
| function CoTransform(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| CoTransform.create = function (value0) { | |
| return function (value1) { | |
| return new CoTransform(value0, value1); | |
| }; | |
| }; | |
| return CoTransform; | |
| })(); | |
| // | A generating functor for awaiting input values. | |
| var Await = function (x) { | |
| return x; | |
| }; | |
| // | Run a `Process` to completion. | |
| var runProcess = function (dictMonadRec) { | |
| return Control_Monad_Free_Trans.runFreeT(Data_Identity.functorIdentity)(dictMonadRec)(function ($186) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($186)); | |
| }); | |
| }; | |
| var profunctorAwait = new Data_Profunctor.Profunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return Data_Profunctor.dimap(Data_Profunctor.profunctorFn)(f)(g)(v); | |
| }; | |
| }; | |
| }); | |
| // | Loop until the computation returns a `Just`. | |
| var loop = function (dictFunctor) { | |
| return function (dictMonad) { | |
| return function (me) { | |
| return Control_Monad_Rec_Class.tailRecM(Control_Monad_Free_Trans.monadRecFreeT(dictFunctor)(dictMonad))(function (v) { | |
| return Data_Functor.map(Control_Monad_Free_Trans.functorFreeT(dictFunctor)(((dictMonad.Bind1()).Apply0()).Functor0()))(Data_Maybe.maybe(new Control_Monad_Rec_Class.Loop(Data_Unit.unit))(Control_Monad_Rec_Class.Done.create))(me); | |
| })(Data_Unit.unit); | |
| }; | |
| }; | |
| }; | |
| // | Fuse two `Co`routines with a bias to the left. | |
| var fuseWithL = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictFunctor2) { | |
| return function (dictMonadRec) { | |
| return function (zap) { | |
| return function (fs) { | |
| return function (gs) { | |
| var go = function (v) { | |
| return Control_Monad_Except_Trans.runExceptT(Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(dictMonadRec.Monad0()))(Control_Monad_Except_Trans.ExceptT(Control_Monad_Free_Trans.resume(dictFunctor)(dictMonadRec)(v.value0)))(function (v1) { | |
| return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(dictMonadRec.Monad0()))(Control_Monad_Except_Trans.ExceptT(Control_Monad_Free_Trans.resume(dictFunctor1)(dictMonadRec)(v.value1)))(function (v2) { | |
| return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonadRec.Monad0()))(Data_Functor.map(dictFunctor2)(function (t) { | |
| return Control_Monad_Free_Trans.freeT(function (v3) { | |
| return go(t); | |
| }); | |
| })(zap(Data_Tuple.Tuple.create)(v1)(v2))); | |
| }); | |
| })); | |
| }; | |
| return Control_Monad_Free_Trans.freeT(function (v) { | |
| return go(new Data_Tuple.Tuple(fs, gs)); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Fuse two `Co`routines. | |
| var fuseWith = function (dictFunctor) { | |
| return function (dictFunctor1) { | |
| return function (dictFunctor2) { | |
| return function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return function (zap) { | |
| return function (fs) { | |
| return function (gs) { | |
| var go = function (v) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(Control_Parallel_Class.sequential(dictParallel)(Control_Apply.apply((dictParallel.Applicative1()).Apply0())(Data_Functor.map(((dictParallel.Applicative1()).Apply0()).Functor0())(Control_Apply.lift2(Data_Either.applyEither)(zap(Data_Tuple.Tuple.create)))(Control_Parallel_Class.parallel(dictParallel)(Control_Monad_Free_Trans.resume(dictFunctor)(dictMonadRec)(v.value0))))(Control_Parallel_Class.parallel(dictParallel)(Control_Monad_Free_Trans.resume(dictFunctor1)(dictMonadRec)(v.value1)))))(function (v1) { | |
| if (v1 instanceof Data_Either.Left) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Data_Either.Left(v1.value0)); | |
| }; | |
| if (v1 instanceof Data_Either.Right) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Data_Either.Right(Data_Functor.map(dictFunctor2)(function (t) { | |
| return Control_Monad_Free_Trans.freeT(function (v2) { | |
| return go(t); | |
| }); | |
| })(v1.value0))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Coroutine line 80, column 5 - line 82, column 63: " + [ v1.constructor.name ]); | |
| }); | |
| }; | |
| return Control_Monad_Free_Trans.freeT(function (v) { | |
| return go(new Data_Tuple.Tuple(fs, gs)); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| var functorAwait = new Data_Functor.Functor(Data_Profunctor.rmap(profunctorAwait)); | |
| // | Run two consumers together | |
| var joinConsumers = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorAwait)(functorAwait)(functorAwait)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| return f(v(v2.value0))(v1(v2.value1)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bifunctorTransform = new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return function ($187) { | |
| return Data_Bifunctor.bimap(Data_Tuple.bifunctorTuple)(f)(g)(v($187)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| var functorTransform = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorTransform)); | |
| // | Compose transformers | |
| var composeTransformers = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorTransform)(functorTransform)(functorTransform)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return function (i) { | |
| var v2 = v(i); | |
| var v3 = v1(v2.value0); | |
| return new Data_Tuple.Tuple(v3.value0, f(v2.value1)(v3.value1)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Transform input values. | |
| var transform = function (dictMonad) { | |
| return function (f) { | |
| return Control_Monad_Free_Trans.liftFreeT(functorTransform)(dictMonad)(function (i) { | |
| return new Data_Tuple.Tuple(f(i), Data_Unit.unit); | |
| }); | |
| }; | |
| }; | |
| // | Transform a consumer. | |
| var transformConsumer = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorTransform)(functorAwait)(functorAwait)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return function (i) { | |
| var v2 = v(i); | |
| return f(v2.value1)(v1(v2.value0)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bifunctorEmit = new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return new Emit(f(v.value0), g(v.value1)); | |
| }; | |
| }; | |
| }); | |
| var functorEmit = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorEmit)); | |
| // | Connect a producer and a consumer. | |
| var connect = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorEmit)(functorAwait)(Data_Identity.functorIdentity)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return f(v.value1)(v1(v.value0)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Emit an output value. | |
| var emit = function (dictMonad) { | |
| return function (o) { | |
| return Control_Monad_Free_Trans.liftFreeT(functorEmit)(dictMonad)(new Emit(o, Data_Unit.unit)); | |
| }; | |
| }; | |
| // | Run two producers together. | |
| var joinProducers = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorEmit)(functorEmit)(functorEmit)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return new Emit(new Data_Tuple.Tuple(v.value0, v1.value0), f(v.value1)(v1.value1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Create a `Producer` by providing a monadic function that produces values. | |
| // | | |
| // | The function should return a value of type `r` at most once, when the | |
| // | `Producer` is ready to close. | |
| var producer = function (dictMonad) { | |
| return function (recv) { | |
| return loop(functorEmit)(dictMonad)(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(functorEmit)(dictMonad))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(functorEmit))(dictMonad)(recv))(function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return Data_Functor.voidLeft(Control_Monad_Free_Trans.functorFreeT(functorEmit)(((dictMonad.Bind1()).Apply0()).Functor0()))(emit(dictMonad)(v.value0))(Data_Maybe.Nothing.value); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return Control_Applicative.pure(Control_Monad_Free_Trans.applicativeFreeT(functorEmit)(dictMonad))(new Data_Maybe.Just(v.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Coroutine line 126, column 3 - line 128, column 29: " + [ v.constructor.name ]); | |
| })); | |
| }; | |
| }; | |
| // | Connect a producer and a consumer so that the consumer pulls from the | |
| // | producer. This means the process ends immediately when the consumer closes. | |
| var pullFrom = function (dictMonadRec) { | |
| return fuseWithL(functorAwait)(functorEmit)(Data_Identity.functorIdentity)(dictMonadRec)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return Control_Applicative.pure(Data_Identity.applicativeIdentity)(f(v(v1.value0))(v1.value1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | Transform a producer. | |
| var transformProducer = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorEmit)(functorTransform)(functorEmit)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| var v2 = v1(v.value0); | |
| return new Emit(v2.value0, f(v.value1)(v2.value1)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bifunctorCoTransform = new Data_Bifunctor.Bifunctor(function (f) { | |
| return function (g) { | |
| return function (v) { | |
| return new CoTransform(f(v.value0), function ($188) { | |
| return g(v.value1($188)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| var functorCoTransform = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorCoTransform)); | |
| // | Compose cotransformers | |
| var composeCoTransformers = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorCoTransform)(functorCoTransform)(functorCoTransform)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return new CoTransform(v1.value0, function (i) { | |
| return f(v.value1(i))(v1.value1(v.value0)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Cotransform input values. | |
| var cotransform = function (dictMonad) { | |
| return function (o) { | |
| return Control_Monad_Free_Trans.freeT(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(new CoTransform(o, Control_Applicative.pure(Control_Monad_Free_Trans.applicativeFreeT(functorCoTransform)(dictMonad))))); | |
| }); | |
| }; | |
| }; | |
| // | Fuse a transformer and a cotransformer. | |
| var fuseCoTransform = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorTransform)(functorCoTransform)(Data_Identity.functorIdentity)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| var v2 = v(v1.value0); | |
| return f(v2.value1)(v1.value1(v2.value0)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Transform a `CoTransformer` on the left. | |
| var transformCoTransformL = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorTransform)(functorCoTransform)(functorCoTransform)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| return new CoTransform(v1.value0, function (i1) { | |
| var v2 = v(i1); | |
| return f(v2.value1)(v1.value1(v2.value0)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Transform a `CoTransformer` on the right. | |
| var transformCoTransformR = function (dictMonadRec) { | |
| return function (dictParallel) { | |
| return fuseWith(functorCoTransform)(functorTransform)(functorCoTransform)(dictMonadRec)(dictParallel)(function (f) { | |
| return function (v) { | |
| return function (v1) { | |
| var v2 = v1(v.value0); | |
| return new CoTransform(v2.value0, function ($189) { | |
| return (function (v3) { | |
| return f(v3)(v2.value1); | |
| })(v.value1($189)); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| // | Await an input value. | |
| var $$await = function (dictMonad) { | |
| return Control_Monad_Free_Trans.liftFreeT(functorAwait)(dictMonad)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| // | Create a `Consumer` by providing a handler function which consumes values. | |
| // | | |
| // | The handler function should return a value of type `r` at most once, when the | |
| // | `Consumer` is ready to close. | |
| var consumer = function (dictMonad) { | |
| return function (send) { | |
| return loop(functorAwait)(dictMonad)(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(functorAwait)(dictMonad))($$await(dictMonad))(function (v) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(functorAwait))(dictMonad)(send(v)); | |
| })); | |
| }; | |
| }; | |
| exports["Await"] = Await; | |
| exports["CoTransform"] = CoTransform; | |
| exports["Emit"] = Emit; | |
| exports["Transform"] = Transform; | |
| exports["await"] = $$await; | |
| exports["composeCoTransformers"] = composeCoTransformers; | |
| exports["composeTransformers"] = composeTransformers; | |
| exports["connect"] = connect; | |
| exports["consumer"] = consumer; | |
| exports["cotransform"] = cotransform; | |
| exports["emit"] = emit; | |
| exports["fuseCoTransform"] = fuseCoTransform; | |
| exports["fuseWith"] = fuseWith; | |
| exports["fuseWithL"] = fuseWithL; | |
| exports["joinConsumers"] = joinConsumers; | |
| exports["joinProducers"] = joinProducers; | |
| exports["loop"] = loop; | |
| exports["producer"] = producer; | |
| exports["pullFrom"] = pullFrom; | |
| exports["runProcess"] = runProcess; | |
| exports["transform"] = transform; | |
| exports["transformCoTransformL"] = transformCoTransformL; | |
| exports["transformCoTransformR"] = transformCoTransformR; | |
| exports["transformConsumer"] = transformConsumer; | |
| exports["transformProducer"] = transformProducer; | |
| exports["bifunctorEmit"] = bifunctorEmit; | |
| exports["functorEmit"] = functorEmit; | |
| exports["profunctorAwait"] = profunctorAwait; | |
| exports["functorAwait"] = functorAwait; | |
| exports["bifunctorTransform"] = bifunctorTransform; | |
| exports["functorTransform"] = functorTransform; | |
| exports["bifunctorCoTransform"] = bifunctorCoTransform; | |
| exports["functorCoTransform"] = functorCoTransform; | |
| })(PS["Control.Coroutine"] = PS["Control.Coroutine"] || {}); | |
| (function(exports) { | |
| /* globals setTimeout, clearTimeout, setImmediate, clearImmediate */ | |
| "use strict"; | |
| exports._cancelWith = function (nonCanceler, aff, canceler1) { | |
| return function (success, error) { | |
| var canceler2 = aff(success, error); | |
| return function (e) { | |
| return function (success, error) { | |
| var cancellations = 0; | |
| var result = false; | |
| var errored = false; | |
| var s = function (bool) { | |
| cancellations = cancellations + 1; | |
| result = result || bool; | |
| if (cancellations === 2 && !errored) { | |
| success(result); | |
| } | |
| }; | |
| var f = function (err) { | |
| if (!errored) { | |
| errored = true; | |
| error(err); | |
| } | |
| }; | |
| canceler2(e)(s, f); | |
| canceler1(e)(s, f); | |
| return nonCanceler; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._delay = function (nonCanceler, millis) { | |
| var set = setTimeout; | |
| var clear = clearTimeout; | |
| if (millis <= 0 && typeof setImmediate === "function") { | |
| set = setImmediate; | |
| clear = clearImmediate; | |
| } | |
| return function (success) { | |
| var timedOut = false; | |
| var timer = set(function () { | |
| timedOut = true; | |
| success(); | |
| }, millis); | |
| return function () { | |
| return function (s) { | |
| if (timedOut) { | |
| s(false); | |
| } else { | |
| clear(timer); | |
| s(true); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._unsafeInterleaveAff = function (aff) { | |
| return aff; | |
| }; | |
| exports._forkAff = function (nonCanceler, aff) { | |
| var voidF = function () {}; | |
| return function (success) { | |
| var canceler = aff(voidF, voidF); | |
| success(canceler); | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._forkAll = function (nonCanceler, foldl, affs) { | |
| var voidF = function () {}; | |
| return function (success) { | |
| var cancelers = foldl(function (acc) { | |
| return function (aff) { | |
| acc.push(aff(voidF, voidF)); | |
| return acc; | |
| }; | |
| })([])(affs); | |
| var canceler = function (e) { | |
| return function (success, error) { | |
| var cancellations = 0; | |
| var result = false; | |
| var errored = false; | |
| var s = function (bool) { | |
| cancellations = cancellations + 1; | |
| result = result || bool; | |
| if (cancellations === cancelers.length && !errored) { | |
| success(result); | |
| } | |
| }; | |
| var f = function (err) { | |
| if (!errored) { | |
| errored = true; | |
| error(err); | |
| } | |
| }; | |
| for (var i = 0; i < cancelers.length; i++) { | |
| cancelers[i](e)(s, f); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| success(canceler); | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._makeAff = function (cb) { | |
| return function (success, error) { | |
| try { | |
| return cb(function (e) { | |
| return function () { | |
| error(e); | |
| }; | |
| })(function (v) { | |
| return function () { | |
| success(v); | |
| }; | |
| })(); | |
| } catch (err) { | |
| error(err); | |
| } | |
| }; | |
| }; | |
| exports._pure = function (nonCanceler, v) { | |
| return function (success) { | |
| success(v); | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._throwError = function (nonCanceler, e) { | |
| return function (success, error) { | |
| error(e); | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._fmap = function (f, aff) { | |
| return function (success, error) { | |
| return aff(function (v) { | |
| success(f(v)); | |
| }, error); | |
| }; | |
| }; | |
| exports._bind = function (alwaysCanceler, aff, f) { | |
| return function (success, error) { | |
| var canceler1, canceler2; | |
| var isCanceled = false; | |
| var requestCancel = false; | |
| var onCanceler = function () {}; | |
| canceler1 = aff(function (v) { | |
| if (requestCancel) { | |
| isCanceled = true; | |
| return alwaysCanceler; | |
| } else { | |
| canceler2 = f(v)(success, error); | |
| onCanceler(canceler2); | |
| return canceler2; | |
| } | |
| }, error); | |
| return function (e) { | |
| return function (s, f) { | |
| requestCancel = true; | |
| if (canceler2 !== undefined) { | |
| return canceler2(e)(s, f); | |
| } else { | |
| return canceler1(e)(function (bool) { | |
| if (bool || isCanceled) { | |
| s(true); | |
| } else { | |
| onCanceler = function (canceler) { | |
| canceler(e)(s, f); | |
| }; | |
| } | |
| }, f); | |
| } | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._attempt = function (Left, Right, aff) { | |
| return function (success) { | |
| return aff(function (v) { | |
| success(Right(v)); | |
| }, function (e) { | |
| success(Left(e)); | |
| }); | |
| }; | |
| }; | |
| exports._runAff = function (errorT, successT, aff) { | |
| // If errorT or successT throw, and an Aff is comprised only of synchronous | |
| // effects, then it's possible for makeAff/liftEff to accidentally catch | |
| // it, which may end up rerunning the Aff depending on error recovery | |
| // behavior. To mitigate this, we observe synchronicity using mutation. If | |
| // an Aff is observed to be synchronous, we let the stack reset and run the | |
| // handlers outside of the normal callback flow. | |
| return function () { | |
| var status = 0; | |
| var result, success; | |
| var canceler = aff(function (v) { | |
| if (status === 2) { | |
| successT(v)(); | |
| } else { | |
| status = 1; | |
| result = v; | |
| success = true; | |
| } | |
| }, function (e) { | |
| if (status === 2) { | |
| errorT(e)(); | |
| } else { | |
| status = 1; | |
| result = e; | |
| success = false; | |
| } | |
| }); | |
| if (status === 1) { | |
| if (success) { | |
| successT(result)(); | |
| } else { | |
| errorT(result)(); | |
| } | |
| } else { | |
| status = 2; | |
| } | |
| return canceler; | |
| }; | |
| }; | |
| exports._liftEff = function (nonCanceler, e) { | |
| return function (success, error) { | |
| var result; | |
| try { | |
| result = e(); | |
| } catch (err) { | |
| error(err); | |
| return nonCanceler; | |
| } | |
| success(result); | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._tailRecM = function (isLeft, f, a) { | |
| return function (success, error) { | |
| return function go (acc) { | |
| var result, status, canceler; | |
| // Observes synchronous effects using a flag. | |
| // status = 0 (unresolved status) | |
| // status = 1 (synchronous effect) | |
| // status = 2 (asynchronous effect) | |
| var csuccess = function (v) { | |
| // If the status is still unresolved, we have observed a | |
| // synchronous effect. Otherwise, the status will be `2`. | |
| if (status === 0) { | |
| // Store the result for further synchronous processing. | |
| result = v; | |
| status = 1; | |
| } else { | |
| // When we have observed an asynchronous effect, we use normal | |
| // recursion. This is safe because we will be on a new stack. | |
| if (isLeft(v)) { | |
| go(v.value0); | |
| } else { | |
| success(v.value0); | |
| } | |
| } | |
| }; | |
| while (true) { | |
| status = 0; | |
| canceler = f(acc)(csuccess, error); | |
| // If the status has already resolved to `1` by our Aff handler, then | |
| // we have observed a synchronous effect. Otherwise it will still be | |
| // `0`. | |
| if (status === 1) { | |
| // When we have observed a synchronous effect, we merely swap out the | |
| // accumulator and continue the loop, preserving stack. | |
| if (isLeft(result)) { | |
| acc = result.value0; | |
| continue; | |
| } else { | |
| success(result.value0); | |
| } | |
| } else { | |
| // If the status has not resolved yet, then we have observed an | |
| // asynchronous effect. | |
| status = 2; | |
| } | |
| return canceler; | |
| } | |
| }(a); | |
| }; | |
| }; | |
| })(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports._makeVar = function (nonCanceler) { | |
| return function (success) { | |
| success({ | |
| consumers: [], | |
| producers: [], | |
| error: undefined | |
| }); | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._takeVar = function (nonCanceler, avar) { | |
| return function (success, error) { | |
| if (avar.error !== undefined) { | |
| error(avar.error); | |
| } else if (avar.producers.length > 0) { | |
| avar.producers.shift()(success, error); | |
| } else { | |
| avar.consumers.push({ peek: false, success: success, error: error }); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._tryTakeVar = function (nothing, just, nonCanceler, avar) { | |
| return function (success, error) { | |
| if (avar.error !== undefined) { | |
| error(avar.error); | |
| } else if (avar.producers.length > 0) { | |
| avar.producers.shift()(function (x) { | |
| return success(just(x)); | |
| }, error); | |
| } else { | |
| success(nothing); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._peekVar = function (nonCanceler, avar) { | |
| return function (success, error) { | |
| if (avar.error !== undefined) { | |
| error(avar.error); | |
| } else if (avar.producers.length > 0) { | |
| avar.producers[0](success, error); | |
| } else { | |
| avar.consumers.push({ peek: true, success: success, error: error }); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._tryPeekVar = function (nothing, just, nonCanceler, avar) { | |
| return function (success, error) { | |
| if (avar.error !== undefined) { | |
| error(avar.error); | |
| } else if (avar.producers.length > 0) { | |
| avar.producers[0](function (x) { | |
| return success(just(x)); | |
| }, error); | |
| } else { | |
| success(nothing); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._putVar = function (nonCanceler, avar, a) { | |
| return function (success, error) { | |
| if (avar.error !== undefined) { | |
| error(avar.error); | |
| } else { | |
| var shouldQueue = true; | |
| var consumers = []; | |
| var consumer; | |
| while (true) { | |
| consumer = avar.consumers.shift(); | |
| if (consumer) { | |
| consumers.push(consumer); | |
| if (consumer.peek) { | |
| continue; | |
| } else { | |
| shouldQueue = false; | |
| } | |
| } | |
| break; | |
| } | |
| if (shouldQueue) { | |
| avar.producers.push(function (success) { | |
| success(a); | |
| return nonCanceler; | |
| }); | |
| } | |
| for (var i = 0; i < consumers.length; i++) { | |
| consumers[i].success(a); | |
| } | |
| success({}); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| exports._killVar = function (nonCanceler, avar, e) { | |
| return function (success, error) { | |
| if (avar.error !== undefined) { | |
| error(avar.error); | |
| } else { | |
| avar.error = e; | |
| while (avar.consumers.length) { | |
| avar.consumers.shift().error(e); | |
| } | |
| success({}); | |
| } | |
| return nonCanceler; | |
| }; | |
| }; | |
| })(PS["Control.Monad.Aff.Internal"] = PS["Control.Monad.Aff.Internal"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.showErrorImpl = function (err) { | |
| return err.stack || err.toString(); | |
| }; | |
| exports.error = function (msg) { | |
| return new Error(msg); | |
| }; | |
| exports.message = function (e) { | |
| return e.message; | |
| }; | |
| exports.stackImpl = function (just) { | |
| return function (nothing) { | |
| return function (e) { | |
| return e.stack ? just(e.stack) : nothing; | |
| }; | |
| }; | |
| }; | |
| exports.throwException = function (e) { | |
| return function () { | |
| throw e; | |
| }; | |
| }; | |
| exports.catchException = function (c) { | |
| return function (t) { | |
| return function () { | |
| try { | |
| return t(); | |
| } catch (e) { | |
| if (e instanceof Error || Object.prototype.toString.call(e) === "[object Error]") { | |
| return c(e)(); | |
| } else { | |
| return c(new Error(e.toString()))(); | |
| } | |
| } | |
| }; | |
| }; | |
| }; | |
| })(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}); | |
| (function(exports) { | |
| // | This module defines an effect, actions and handlers for working | |
| // | with JavaScript exceptions. | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Eff.Exception"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Runs an Eff and returns eventual Exceptions as a `Left` value. If the | |
| // | computation succeeds the result gets wrapped in a `Right`. | |
| // | | |
| // | For example: | |
| // | | |
| // | ```purescript | |
| // | -- Notice that there is no EXCEPTION effect | |
| // | main :: forall eff. Eff (console :: CONSOLE, fs :: FS | eff) Unit | |
| // | main = do | |
| // | result <- try (readTextFile UTF8 "README.md") | |
| // | case result of | |
| // | Right lines -> | |
| // | Console.log ("README: \n" <> lines ) | |
| // | Left error -> | |
| // | Console.error ("Couldn't open README.md. Error was: " <> show error) | |
| // | ``` | |
| var $$try = function (action) { | |
| return $foreign.catchException(function ($0) { | |
| return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Either.Left.create($0)); | |
| })(Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Either.Right.create)(action)); | |
| }; | |
| // | A shortcut allowing you to throw an error in one step. Defined as | |
| // | `throwException <<< error`. | |
| var $$throw = function ($1) { | |
| return $foreign.throwException($foreign.error($1)); | |
| }; | |
| // | Get the stack trace from a JavaScript error | |
| var stack = $foreign.stackImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| var showError = new Data_Show.Show($foreign.showErrorImpl); | |
| exports["stack"] = stack; | |
| exports["throw"] = $$throw; | |
| exports["try"] = $$try; | |
| exports["showError"] = showError; | |
| exports["catchException"] = $foreign.catchException; | |
| exports["error"] = $foreign.error; | |
| exports["message"] = $foreign.message; | |
| exports["throwException"] = $foreign.throwException; | |
| })(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // module Data.Function.Uncurried | |
| exports.mkFn0 = function (fn) { | |
| return function () { | |
| return fn({}); | |
| }; | |
| }; | |
| exports.mkFn2 = function (fn) { | |
| /* jshint maxparams: 2 */ | |
| return function (a, b) { | |
| return fn(a)(b); | |
| }; | |
| }; | |
| exports.mkFn3 = function (fn) { | |
| /* jshint maxparams: 3 */ | |
| return function (a, b, c) { | |
| return fn(a)(b)(c); | |
| }; | |
| }; | |
| exports.mkFn4 = function (fn) { | |
| /* jshint maxparams: 4 */ | |
| return function (a, b, c, d) { | |
| return fn(a)(b)(c)(d); | |
| }; | |
| }; | |
| exports.mkFn5 = function (fn) { | |
| /* jshint maxparams: 5 */ | |
| return function (a, b, c, d, e) { | |
| return fn(a)(b)(c)(d)(e); | |
| }; | |
| }; | |
| exports.mkFn6 = function (fn) { | |
| /* jshint maxparams: 6 */ | |
| return function (a, b, c, d, e, f) { | |
| return fn(a)(b)(c)(d)(e)(f); | |
| }; | |
| }; | |
| exports.mkFn7 = function (fn) { | |
| /* jshint maxparams: 7 */ | |
| return function (a, b, c, d, e, f, g) { | |
| return fn(a)(b)(c)(d)(e)(f)(g); | |
| }; | |
| }; | |
| exports.mkFn8 = function (fn) { | |
| /* jshint maxparams: 8 */ | |
| return function (a, b, c, d, e, f, g, h) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(h); | |
| }; | |
| }; | |
| exports.mkFn9 = function (fn) { | |
| /* jshint maxparams: 9 */ | |
| return function (a, b, c, d, e, f, g, h, i) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(h)(i); | |
| }; | |
| }; | |
| exports.mkFn10 = function (fn) { | |
| /* jshint maxparams: 10 */ | |
| return function (a, b, c, d, e, f, g, h, i, j) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j); | |
| }; | |
| }; | |
| exports.runFn0 = function (fn) { | |
| return fn(); | |
| }; | |
| exports.runFn2 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return fn(a, b); | |
| }; | |
| }; | |
| }; | |
| exports.runFn3 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return fn(a, b, c); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn4 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return fn(a, b, c, d); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn5 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return function (e) { | |
| return fn(a, b, c, d, e); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn6 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return function (e) { | |
| return function (f) { | |
| return fn(a, b, c, d, e, f); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn7 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return function (e) { | |
| return function (f) { | |
| return function (g) { | |
| return fn(a, b, c, d, e, f, g); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn8 = function (fn) { | |
| return function (a) { | |
| return function (b) { | |
| return function (c) { | |
| return function (d) { | |
| return function (e) { | |
| return function (f) { | |
| return function (g) { | |
| return function (h) { | |
| return fn(a, b, c, d, e, f, g, h); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn9 = function (fn) { | |
| return function (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 fn(a, b, c, d, e, f, g, h, i); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runFn10 = function (fn) { | |
| return function (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 function (j) { | |
| return fn(a, b, c, d, e, f, g, h, i, j); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Function.Uncurried"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | Apply a function of one argument | |
| var runFn1 = function (f) { | |
| return f; | |
| }; | |
| // | Create a function of one argument | |
| var mkFn1 = function (f) { | |
| return f; | |
| }; | |
| exports["mkFn1"] = mkFn1; | |
| exports["runFn1"] = runFn1; | |
| exports["mkFn0"] = $foreign.mkFn0; | |
| exports["mkFn10"] = $foreign.mkFn10; | |
| exports["mkFn2"] = $foreign.mkFn2; | |
| exports["mkFn3"] = $foreign.mkFn3; | |
| exports["mkFn4"] = $foreign.mkFn4; | |
| exports["mkFn5"] = $foreign.mkFn5; | |
| exports["mkFn6"] = $foreign.mkFn6; | |
| exports["mkFn7"] = $foreign.mkFn7; | |
| exports["mkFn8"] = $foreign.mkFn8; | |
| exports["mkFn9"] = $foreign.mkFn9; | |
| exports["runFn0"] = $foreign.runFn0; | |
| exports["runFn10"] = $foreign.runFn10; | |
| exports["runFn2"] = $foreign.runFn2; | |
| exports["runFn3"] = $foreign.runFn3; | |
| exports["runFn4"] = $foreign.runFn4; | |
| exports["runFn5"] = $foreign.runFn5; | |
| exports["runFn6"] = $foreign.runFn6; | |
| exports["runFn7"] = $foreign.runFn7; | |
| exports["runFn8"] = $foreign.runFn8; | |
| exports["runFn9"] = $foreign.runFn9; | |
| })(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Aff.Internal"]; | |
| var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; | |
| var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Prelude = PS["Prelude"]; | |
| exports["_killVar"] = $foreign._killVar; | |
| exports["_makeVar"] = $foreign._makeVar; | |
| exports["_peekVar"] = $foreign._peekVar; | |
| exports["_putVar"] = $foreign._putVar; | |
| exports["_takeVar"] = $foreign._takeVar; | |
| exports["_tryPeekVar"] = $foreign._tryPeekVar; | |
| exports["_tryTakeVar"] = $foreign._tryTakeVar; | |
| })(PS["Control.Monad.Aff.Internal"] = PS["Control.Monad.Aff.Internal"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| // module Data.Generic | |
| exports.zipAll = function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| var l = xs.length < ys.length ? xs.length : ys.length; | |
| for (var i = 0; i < l; i++) { | |
| if (!f(xs[i])(ys[i])) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| }; | |
| }; | |
| }; | |
| exports.zipCompare = function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| var i = 0; | |
| var xlen = xs.length; | |
| var ylen = ys.length; | |
| while (i < xlen && i < ylen) { | |
| var o = f(xs[i])(ys[i]); | |
| if (o !== 0) { | |
| return o; | |
| } | |
| i++; | |
| } | |
| if (xlen === ylen) { | |
| return 0; | |
| } else if (xlen > ylen) { | |
| return -1; | |
| } else { | |
| return 1; | |
| } | |
| }; | |
| }; | |
| }; | |
| })(PS["Data.Generic"] = PS["Data.Generic"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| //------------------------------------------------------------------------------ | |
| // Array creation -------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.range = function (start) { | |
| return function (end) { | |
| var step = start > end ? -1 : 1; | |
| var result = []; | |
| var i = start, n = 0; | |
| while (i !== end) { | |
| result[n++] = i; | |
| i += step; | |
| } | |
| result[n] = i; | |
| return result; | |
| }; | |
| }; | |
| var replicate = function (count) { | |
| return function (value) { | |
| if (count < 1) { | |
| return []; | |
| } | |
| var result = new Array(count); | |
| return result.fill(value); | |
| }; | |
| }; | |
| var replicatePolyfill = function (count) { | |
| return function (value) { | |
| var result = []; | |
| var n = 0; | |
| for (var i = 0; i < count; i++) { | |
| result[n++] = value; | |
| } | |
| return result; | |
| }; | |
| }; | |
| // In browsers that have Array.prototype.fill we use it, as it's faster. | |
| exports.replicate = typeof Array.prototype.fill === "function" ? | |
| replicate : | |
| replicatePolyfill; | |
| exports.fromFoldableImpl = (function () { | |
| // jshint maxparams: 2 | |
| function Cons(head, tail) { | |
| this.head = head; | |
| this.tail = tail; | |
| } | |
| var emptyList = {}; | |
| function curryCons(head) { | |
| return function (tail) { | |
| return new Cons(head, tail); | |
| }; | |
| } | |
| function listToArray(list) { | |
| var result = []; | |
| var count = 0; | |
| var xs = list; | |
| while (xs !== emptyList) { | |
| result[count++] = xs.head; | |
| xs = xs.tail; | |
| } | |
| return result; | |
| } | |
| return function (foldr) { | |
| return function (xs) { | |
| return listToArray(foldr(curryCons)(emptyList)(xs)); | |
| }; | |
| }; | |
| })(); | |
| //------------------------------------------------------------------------------ | |
| // Array size ------------------------------------------------------------------ | |
| //------------------------------------------------------------------------------ | |
| exports.length = function (xs) { | |
| return xs.length; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Extending arrays ------------------------------------------------------------ | |
| //------------------------------------------------------------------------------ | |
| exports.cons = function (e) { | |
| return function (l) { | |
| return [e].concat(l); | |
| }; | |
| }; | |
| exports.snoc = function (l) { | |
| return function (e) { | |
| var l1 = l.slice(); | |
| l1.push(e); | |
| return l1; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Non-indexed reads ----------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports["uncons'"] = function (empty) { | |
| return function (next) { | |
| return function (xs) { | |
| return xs.length === 0 ? empty({}) : next(xs[0])(xs.slice(1)); | |
| }; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Indexed operations ---------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.indexImpl = function (just) { | |
| return function (nothing) { | |
| return function (xs) { | |
| return function (i) { | |
| return i < 0 || i >= xs.length ? nothing : just(xs[i]); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.findIndexImpl = function (just) { | |
| return function (nothing) { | |
| return function (f) { | |
| return function (xs) { | |
| for (var i = 0, l = xs.length; i < l; i++) { | |
| if (f(xs[i])) return just(i); | |
| } | |
| return nothing; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.findLastIndexImpl = function (just) { | |
| return function (nothing) { | |
| return function (f) { | |
| return function (xs) { | |
| for (var i = xs.length - 1; i >= 0; i--) { | |
| if (f(xs[i])) return just(i); | |
| } | |
| return nothing; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._insertAt = function (just) { | |
| return function (nothing) { | |
| return function (i) { | |
| return function (a) { | |
| return function (l) { | |
| if (i < 0 || i > l.length) return nothing; | |
| var l1 = l.slice(); | |
| l1.splice(i, 0, a); | |
| return just(l1); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._deleteAt = function (just) { | |
| return function (nothing) { | |
| return function (i) { | |
| return function (l) { | |
| if (i < 0 || i >= l.length) return nothing; | |
| var l1 = l.slice(); | |
| l1.splice(i, 1); | |
| return just(l1); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._updateAt = function (just) { | |
| return function (nothing) { | |
| return function (i) { | |
| return function (a) { | |
| return function (l) { | |
| if (i < 0 || i >= l.length) return nothing; | |
| var l1 = l.slice(); | |
| l1[i] = a; | |
| return just(l1); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Transformations ------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.reverse = function (l) { | |
| return l.slice().reverse(); | |
| }; | |
| exports.concat = function (xss) { | |
| if (xss.length <= 10000) { | |
| // This method is faster, but it crashes on big arrays. | |
| // So we use it when can and fallback to simple variant otherwise. | |
| return Array.prototype.concat.apply([], xss); | |
| } | |
| var result = []; | |
| for (var i = 0, l = xss.length; i < l; i++) { | |
| var xs = xss[i]; | |
| for (var j = 0, m = xs.length; j < m; j++) { | |
| result.push(xs[j]); | |
| } | |
| } | |
| return result; | |
| }; | |
| exports.filter = function (f) { | |
| return function (xs) { | |
| return xs.filter(f); | |
| }; | |
| }; | |
| exports.partition = function (f) { | |
| return function (xs) { | |
| var yes = []; | |
| var no = []; | |
| for (var i = 0; i < xs.length; i++) { | |
| var x = xs[i]; | |
| if (f(x)) | |
| yes.push(x); | |
| else | |
| no.push(x); | |
| } | |
| return { yes: yes, no: no }; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Sorting --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.sortImpl = function (f) { | |
| return function (l) { | |
| // jshint maxparams: 2 | |
| return l.slice().sort(function (x, y) { | |
| return f(x)(y); | |
| }); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Subarrays ------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.slice = function (s) { | |
| return function (e) { | |
| return function (l) { | |
| return l.slice(s, e); | |
| }; | |
| }; | |
| }; | |
| exports.take = function (n) { | |
| return function (l) { | |
| return n < 1 ? [] : l.slice(0, n); | |
| }; | |
| }; | |
| exports.drop = function (n) { | |
| return function (l) { | |
| return n < 1 ? l : l.slice(n); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Zipping --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.zipWith = function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| var l = xs.length < ys.length ? xs.length : ys.length; | |
| var result = new Array(l); | |
| for (var i = 0; i < l; i++) { | |
| result[i] = f(xs[i])(ys[i]); | |
| } | |
| return result; | |
| }; | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Partial --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| exports.unsafeIndexImpl = function (xs) { | |
| return function (n) { | |
| return xs[n]; | |
| }; | |
| }; | |
| })(PS["Data.Array"] = PS["Data.Array"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.runSTArray = function (f) { | |
| return f; | |
| }; | |
| exports.emptySTArray = function () { | |
| return []; | |
| }; | |
| exports.peekSTArrayImpl = function (just) { | |
| return function (nothing) { | |
| return function (xs) { | |
| return function (i) { | |
| return function () { | |
| return i >= 0 && i < xs.length ? just(xs[i]) : nothing; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.pokeSTArray = function (xs) { | |
| return function (i) { | |
| return function (a) { | |
| return function () { | |
| var ret = i >= 0 && i < xs.length; | |
| if (ret) xs[i] = a; | |
| return ret; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.pushAllSTArray = function (xs) { | |
| return function (as) { | |
| return function () { | |
| return xs.push.apply(xs, as); | |
| }; | |
| }; | |
| }; | |
| exports.spliceSTArray = function (xs) { | |
| return function (i) { | |
| return function (howMany) { | |
| return function (bs) { | |
| return function () { | |
| return xs.splice.apply(xs, [i, howMany].concat(bs)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.copyImpl = function (xs) { | |
| return function () { | |
| return xs.slice(); | |
| }; | |
| }; | |
| exports.toAssocArray = function (xs) { | |
| return function () { | |
| var n = xs.length; | |
| var as = new Array(n); | |
| for (var i = 0; i < n; i++) as[i] = { value: xs[i], index: i }; | |
| return as; | |
| }; | |
| }; | |
| })(PS["Data.Array.ST"] = PS["Data.Array.ST"] || {}); | |
| (function(exports) { | |
| // | Helper functions for working with mutable arrays using the `ST` effect. | |
| // | | |
| // | This module can be used when performance is important and mutation is a local effect. | |
| "use strict"; | |
| var $foreign = PS["Data.Array.ST"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_ST = PS["Control.Monad.ST"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Prelude = PS["Prelude"]; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| // | O(1). Convert a mutable array to an immutable array, without copying. The mutable | |
| // | array must not be mutated afterwards. | |
| var unsafeFreeze = function ($7) { | |
| return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Unsafe_Coerce.unsafeCoerce($7)); | |
| }; | |
| // | Create a mutable copy of an immutable array. | |
| var thaw = $foreign.copyImpl; | |
| // | Perform an effect requiring a mutable array on a copy of an immutable array, | |
| // | safely returning the result as an immutable array. | |
| var withArray = function (f) { | |
| return function (xs) { | |
| return function __do() { | |
| var v = thaw(xs)(); | |
| var v1 = f(v)(); | |
| return unsafeFreeze(v)(); | |
| }; | |
| }; | |
| }; | |
| // | Append an element to the end of a mutable array. Returns the new length of | |
| // | the array. | |
| var pushSTArray = function (arr) { | |
| return function (a) { | |
| return $foreign.pushAllSTArray(arr)([ a ]); | |
| }; | |
| }; | |
| // | Read the value at the specified index in a mutable array. | |
| var peekSTArray = $foreign.peekSTArrayImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Mutate the element at the specified index using the supplied function. | |
| var modifySTArray = function (xs) { | |
| return function (i) { | |
| return function (f) { | |
| return function __do() { | |
| var v = peekSTArray(xs)(i)(); | |
| if (v instanceof Data_Maybe.Just) { | |
| return $foreign.pokeSTArray(xs)(i)(f(v.value0))(); | |
| }; | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return false; | |
| }; | |
| throw new Error("Failed pattern match at Data.Array.ST line 120, column 3 - line 122, column 26: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Create an immutable copy of a mutable array. | |
| var freeze = $foreign.copyImpl; | |
| exports["freeze"] = freeze; | |
| exports["modifySTArray"] = modifySTArray; | |
| exports["peekSTArray"] = peekSTArray; | |
| exports["pushSTArray"] = pushSTArray; | |
| exports["thaw"] = thaw; | |
| exports["unsafeFreeze"] = unsafeFreeze; | |
| exports["withArray"] = withArray; | |
| exports["emptySTArray"] = $foreign.emptySTArray; | |
| exports["pokeSTArray"] = $foreign.pokeSTArray; | |
| exports["pushAllSTArray"] = $foreign.pushAllSTArray; | |
| exports["runSTArray"] = $foreign.runSTArray; | |
| exports["spliceSTArray"] = $foreign.spliceSTArray; | |
| exports["toAssocArray"] = $foreign.toAssocArray; | |
| })(PS["Data.Array.ST"] = PS["Data.Array.ST"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_ST = PS["Control.Monad.ST"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Array_ST = PS["Data.Array.ST"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Prelude = PS["Prelude"]; | |
| // | This type provides a slightly easier way of iterating over an array's | |
| // | elements in an STArray computation, without having to keep track of | |
| // | indices. | |
| var Iterator = (function () { | |
| function Iterator(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Iterator.create = function (value0) { | |
| return function (value1) { | |
| return new Iterator(value0, value1); | |
| }; | |
| }; | |
| return Iterator; | |
| })(); | |
| // | Get the next item out of an iterator without advancing it. | |
| var peek = function (v) { | |
| return function __do() { | |
| var v1 = Control_Monad_ST.readSTRef(v.value1)(); | |
| return v.value0(v1); | |
| }; | |
| }; | |
| // | Get the next item out of an iterator, advancing it. Returns Nothing if the | |
| // | Iterator is exhausted. | |
| var next = function (v) { | |
| return function __do() { | |
| var v1 = Control_Monad_ST.readSTRef(v.value1)(); | |
| var v2 = Control_Monad_ST.modifySTRef(v.value1)(function (v2) { | |
| return v2 + 1 | 0; | |
| })(); | |
| return v.value0(v1); | |
| }; | |
| }; | |
| // | Extract elements from an iterator and push them on to an STArray for as | |
| // | long as those elements satisfy a given predicate. | |
| var pushWhile = function (p) { | |
| return function (iter) { | |
| return function (array) { | |
| return function __do() { | |
| var v = Control_Monad_ST.newSTRef(false)(); | |
| while (Data_Functor.map(Control_Monad_Eff.functorEff)(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(Control_Monad_ST.readSTRef(v))()) { | |
| (function __do() { | |
| var v1 = peek(iter)(); | |
| if (v1 instanceof Data_Maybe.Just && p(v1.value0)) { | |
| var v2 = Data_Array_ST.pushSTArray(array)(v1.value0)(); | |
| return Data_Functor["void"](Control_Monad_Eff.functorEff)(next(iter))(); | |
| }; | |
| return Data_Functor["void"](Control_Monad_Eff.functorEff)(Control_Monad_ST.writeSTRef(v)(true))(); | |
| })(); | |
| }; | |
| return {}; | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Push the entire remaining contents of an iterator onto an STArray. | |
| var pushAll = pushWhile(Data_Function["const"](true)); | |
| // | Make an Iterator given an indexing function into an array (or anything | |
| // | else). If `xs :: Array a`, the standard way to create an iterator over | |
| // | `xs` is to use `iterator (xs !! _)`, where `(!!)` comes from `Data.Array`. | |
| var iterator = function (f) { | |
| return Data_Functor.map(Control_Monad_Eff.functorEff)(Iterator.create(f))(Control_Monad_ST.newSTRef(0)); | |
| }; | |
| // | Perform an action once for each item left in an iterator. If the action | |
| // | itself also advances the same iterator, `iterate` will miss those items | |
| // | out. | |
| var iterate = function (iter) { | |
| return function (f) { | |
| return function __do() { | |
| var v = Control_Monad_ST.newSTRef(false)(); | |
| while (Data_Functor.map(Control_Monad_Eff.functorEff)(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(Control_Monad_ST.readSTRef(v))()) { | |
| (function __do() { | |
| var v1 = next(iter)(); | |
| if (v1 instanceof Data_Maybe.Just) { | |
| return f(v1.value0)(); | |
| }; | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return Data_Functor["void"](Control_Monad_Eff.functorEff)(Control_Monad_ST.writeSTRef(v)(true))(); | |
| }; | |
| throw new Error("Failed pattern match at Data.Array.ST.Iterator line 39, column 5 - line 41, column 46: " + [ v1.constructor.name ]); | |
| })(); | |
| }; | |
| return {}; | |
| }; | |
| }; | |
| }; | |
| // | Check whether an iterator has been exhausted. | |
| var exhausted = function ($27) { | |
| return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Maybe.isNothing)(peek($27)); | |
| }; | |
| exports["exhausted"] = exhausted; | |
| exports["iterate"] = iterate; | |
| exports["iterator"] = iterator; | |
| exports["next"] = next; | |
| exports["peek"] = peek; | |
| exports["pushAll"] = pushAll; | |
| exports["pushWhile"] = pushWhile; | |
| })(PS["Data.Array.ST.Iterator"] = PS["Data.Array.ST.Iterator"] || {}); | |
| (function(exports) { | |
| // | Helper functions for working with immutable Javascript arrays. | |
| // | | |
| // | _Note_: Depending on your use-case, you may prefer to use `Data.List` or | |
| // | `Data.Sequence` instead, which might give better performance for certain | |
| // | use cases. This module is useful when integrating with JavaScript libraries | |
| // | which use arrays, but immutable arrays are not a practical data structure | |
| // | for many use cases due to their poor asymptotics. | |
| // | | |
| // | In addition to the functions in this module, Arrays have a number of | |
| // | useful instances: | |
| // | | |
| // | * `Functor`, which provides `map :: forall a b. (a -> b) -> Array a -> | |
| // | Array b` | |
| // | * `Apply`, which provides `(<*>) :: forall a b. Array (a -> b) -> Array a | |
| // | -> Array b`. This function works a bit like a Cartesian product; the | |
| // | result array is constructed by applying each function in the first | |
| // | array to each value in the second, so that the result array ends up with | |
| // | a length equal to the product of the two arguments' lengths. | |
| // | * `Bind`, which provides `(>>=) :: forall a b. (a -> Array b) -> Array a | |
| // | -> Array b` (this is the same as `concatMap`). | |
| // | * `Semigroup`, which provides `(<>) :: forall a. Array a -> Array a -> | |
| // | Array a`, for concatenating arrays. | |
| // | * `Foldable`, which provides a slew of functions for *folding* (also known | |
| // | as *reducing*) arrays down to one value. For example, | |
| // | `Data.Foldable.or` tests whether an array of `Boolean` values contains | |
| // | at least one `true` value. | |
| // | * `Traversable`, which provides the PureScript version of a for-loop, | |
| // | allowing you to iterate over an array and accumulate effects. | |
| // | | |
| "use strict"; | |
| var $foreign = PS["Data.Array"]; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_ST = PS["Control.Monad.ST"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Array_ST = PS["Data.Array.ST"]; | |
| var Data_Array_ST_Iterator = PS["Data.Array.ST.Iterator"]; | |
| var Data_Boolean = PS["Data.Boolean"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_NonEmpty = PS["Data.NonEmpty"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unfoldable = PS["Data.Unfoldable"]; | |
| var Partial_Unsafe = PS["Partial.Unsafe"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A generalization of `zipWith` which accumulates results in some | |
| // | `Applicative` functor. | |
| var zipWithA = function (dictApplicative) { | |
| return function (f) { | |
| return function (xs) { | |
| return function (ys) { | |
| return Data_Traversable.sequence(Data_Traversable.traversableArray)(dictApplicative)($foreign.zipWith(f)(xs)(ys)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Takes two arrays and returns an array of corresponding pairs. | |
| // | If one input array is short, excess elements of the longer array are | |
| // | discarded. | |
| var zip = $foreign.zipWith(Data_Tuple.Tuple.create); | |
| // | Change the elements at the specified indices in index/value pairs. | |
| // | Out-of-bounds indices will have no effect. | |
| var updateAtIndices = function (dictFoldable) { | |
| return function (us) { | |
| return function (xs) { | |
| return Control_Monad_ST.pureST(Data_Array_ST.withArray(function (res) { | |
| return Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(dictFoldable)(Data_Tuple.uncurry(Data_Array_ST.pokeSTArray(res)))(us); | |
| })(xs)); | |
| }; | |
| }; | |
| }; | |
| // | Change the element at the specified index, creating a new array, or | |
| // | returning `Nothing` if the index is out of bounds. | |
| var updateAt = $foreign._updateAt(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Find the element of an array at the specified index. | |
| var unsafeIndex = function (dictPartial) { | |
| return $foreign.unsafeIndexImpl; | |
| }; | |
| // | Break an array into its first element and remaining elements. | |
| // | | |
| // | Using `uncons` provides a way of writing code that would use cons patterns | |
| // | in Haskell or pre-PureScript 0.7: | |
| // | ``` purescript | |
| // | f (x : xs) = something | |
| // | f [] = somethingElse | |
| // | ``` | |
| // | Becomes: | |
| // | ``` purescript | |
| // | f arr = case uncons arr of | |
| // | Just { head: x, tail: xs } -> something | |
| // | Nothing -> somethingElse | |
| // | ``` | |
| var uncons = $foreign["uncons'"](Data_Function["const"](Data_Maybe.Nothing.value))(function (x) { | |
| return function (xs) { | |
| return new Data_Maybe.Just({ | |
| head: x, | |
| tail: xs | |
| }); | |
| }; | |
| }); | |
| // | Convert an `Array` into an `Unfoldable` structure. | |
| var toUnfoldable = function (dictUnfoldable) { | |
| return function (xs) { | |
| var len = $foreign.length(xs); | |
| var f = function (i) { | |
| if (i < len) { | |
| return new Data_Maybe.Just(new Data_Tuple.Tuple(unsafeIndex()(xs)(i), i + 1 | 0)); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 137, column 3 - line 139, column 26: " + [ i.constructor.name ]); | |
| }; | |
| return Data_Unfoldable.unfoldr(dictUnfoldable)(f)(0); | |
| }; | |
| }; | |
| // | Get all but the first element of an array, creating a new array, or | |
| // | `Nothing` if the array is empty | |
| // | | |
| // | Running time: `O(n)` where `n` is the length of the array | |
| var tail = $foreign["uncons'"](Data_Function["const"](Data_Maybe.Nothing.value))(function (v) { | |
| return function (xs) { | |
| return new Data_Maybe.Just(xs); | |
| }; | |
| }); | |
| // | Sort the elements of an array in increasing order, where elements are | |
| // | compared using the specified partial ordering, creating a new array. | |
| var sortBy = function (comp) { | |
| return function (xs) { | |
| var comp$prime = function (x) { | |
| return function (y) { | |
| var v = comp(x)(y); | |
| if (v instanceof Data_Ordering.GT) { | |
| return 1; | |
| }; | |
| if (v instanceof Data_Ordering.EQ) { | |
| return 0; | |
| }; | |
| if (v instanceof Data_Ordering.LT) { | |
| return -1 | 0; | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 475, column 15 - line 480, column 1: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| return $foreign.sortImpl(comp$prime)(xs); | |
| }; | |
| }; | |
| // | Sort the elements of an array in increasing order, where elements are | |
| // | sorted based on a projection | |
| var sortWith = function (dictOrd) { | |
| return function (f) { | |
| return sortBy(Data_Ord.comparing(dictOrd)(f)); | |
| }; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Sorting --------------------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Sort the elements of an array in increasing order, creating a new array. | |
| var sort = function (dictOrd) { | |
| return function (xs) { | |
| return sortBy(Data_Ord.compare(dictOrd))(xs); | |
| }; | |
| }; | |
| // | Create an array of one element | |
| var singleton = function (a) { | |
| return [ a ]; | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Array size ------------------------------------------------------------------ | |
| //------------------------------------------------------------------------------ | |
| // | Test whether an array is empty. | |
| var $$null = function (xs) { | |
| return $foreign.length(xs) === 0; | |
| }; | |
| // | Remove the duplicates from an array, where element equality is determined | |
| // | by the specified equivalence relation, creating a new array. | |
| var nubBy = function (eq) { | |
| return function (xs) { | |
| var v = uncons(xs); | |
| if (v instanceof Data_Maybe.Just) { | |
| return $foreign.cons(v.value0.head)(nubBy(eq)($foreign.filter(function (y) { | |
| return !eq(v.value0.head)(y); | |
| })(v.value0.tail))); | |
| }; | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return [ ]; | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 583, column 3 - line 585, column 18: " + [ v.constructor.name ]); | |
| }; | |
| }; | |
| // | Remove the duplicates from an array, creating a new array. | |
| var nub = function (dictEq) { | |
| return nubBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Apply a function to the element at the specified indices, | |
| // | creating a new array. Out-of-bounds indices will have no effect. | |
| var modifyAtIndices = function (dictFoldable) { | |
| return function (is) { | |
| return function (f) { | |
| return function (xs) { | |
| return Control_Monad_ST.pureST(Data_Array_ST.withArray(function (res) { | |
| return Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(dictFoldable)(function (i) { | |
| return Data_Array_ST.modifySTArray(res)(i)(f); | |
| })(is); | |
| })(xs)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Apply a function to each element in an array, supplying a generated | |
| // | zero-based index integer along with the element, creating an array | |
| // | with the new elements. | |
| var mapWithIndex = function (f) { | |
| return function (xs) { | |
| return $foreign.zipWith(f)($foreign.range(0)($foreign.length(xs) - 1 | 0))(xs); | |
| }; | |
| }; | |
| // | Attempt a computation multiple times, requiring at least one success. | |
| // | | |
| // | The `Lazy` constraint is used to generate the result lazily, to ensure | |
| // | termination. | |
| var some = function (dictAlternative) { | |
| return function (dictLazy) { | |
| return function (v) { | |
| return Control_Apply.apply((dictAlternative.Applicative0()).Apply0())(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())($foreign.cons)(v))(Control_Lazy.defer(dictLazy)(function (v1) { | |
| return many(dictAlternative)(dictLazy)(v); | |
| })); | |
| }; | |
| }; | |
| }; | |
| // | Attempt a computation multiple times, returning as many successful results | |
| // | as possible (possibly zero). | |
| // | | |
| // | The `Lazy` constraint is used to generate the result lazily, to ensure | |
| // | termination. | |
| var many = function (dictAlternative) { | |
| return function (dictLazy) { | |
| return function (v) { | |
| return Control_Alt.alt((dictAlternative.Plus1()).Alt0())(some(dictAlternative)(dictLazy)(v))(Control_Applicative.pure(dictAlternative.Applicative0())([ ])); | |
| }; | |
| }; | |
| }; | |
| // | Insert an element at the specified index, creating a new array, or | |
| // | returning `Nothing` if the index is out of bounds. | |
| var insertAt = $foreign._insertAt(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Get all but the last element of an array, creating a new array, or | |
| // | `Nothing` if the array is empty. | |
| // | | |
| // | Running time: `O(n)` where `n` is the length of the array | |
| var init = function (xs) { | |
| if ($$null(xs)) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| return new Data_Maybe.Just($foreign.slice(0)($foreign.length(xs) - 1 | 0)(xs)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 249, column 1 - line 249, column 45: " + [ xs.constructor.name ]); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Indexed operations ---------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | This function provides a safe way to read a value at a particular index | |
| // | from an array. | |
| var index = $foreign.indexImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Get the last element in an array, or `Nothing` if the array is empty | |
| // | | |
| // | Running time: `O(1)`. | |
| var last = function (xs) { | |
| return index(xs)($foreign.length(xs) - 1 | 0); | |
| }; | |
| // | Break an array into its last element and all preceding elements. | |
| // | | |
| // | Running time: `O(n)` where `n` is the length of the array | |
| var unsnoc = function (xs) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(function (v) { | |
| return function (v1) { | |
| return { | |
| init: v, | |
| last: v1 | |
| }; | |
| }; | |
| })(init(xs)))(last(xs)); | |
| }; | |
| // | Apply a function to the element at the specified index, creating a new | |
| // | array, or returning `Nothing` if the index is out of bounds. | |
| var modifyAt = function (i) { | |
| return function (f) { | |
| return function (xs) { | |
| var go = function (x) { | |
| return updateAt(i)(f(x))(xs); | |
| }; | |
| return Data_Maybe.maybe(Data_Maybe.Nothing.value)(go)(index(xs)(i)); | |
| }; | |
| }; | |
| }; | |
| // | Split an array into two parts: | |
| // | | |
| // | 1. the longest initial subarray for which all elements satisfy the | |
| // | specified predicate | |
| // | 2. the remaining elements | |
| // | | |
| // | ```purescript | |
| // | span (\n -> n % 2 == 1) [1,3,2,4,5] == { init: [1,3], rest: [2,4,5] } | |
| // | ``` | |
| // | | |
| // | Running time: `O(n)`. | |
| var span = function (p) { | |
| return function (arr) { | |
| var go = function ($copy_i) { | |
| var $tco_done = false; | |
| var $tco_result; | |
| function $tco_loop(i) { | |
| var v = index(arr)(i); | |
| if (v instanceof Data_Maybe.Just) { | |
| var $64 = p(v.value0); | |
| if ($64) { | |
| $copy_i = i + 1 | 0; | |
| return; | |
| }; | |
| $tco_done = true; | |
| return new Data_Maybe.Just(i); | |
| }; | |
| if (v instanceof Data_Maybe.Nothing) { | |
| $tco_done = true; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 541, column 5 - line 543, column 25: " + [ v.constructor.name ]); | |
| }; | |
| while (!$tco_done) { | |
| $tco_result = $tco_loop($copy_i); | |
| }; | |
| return $tco_result; | |
| }; | |
| var breakIndex = go(0); | |
| if (breakIndex instanceof Data_Maybe.Just && breakIndex.value0 === 0) { | |
| return { | |
| init: [ ], | |
| rest: arr | |
| }; | |
| }; | |
| if (breakIndex instanceof Data_Maybe.Just) { | |
| return { | |
| init: $foreign.slice(0)(breakIndex.value0)(arr), | |
| rest: $foreign.slice(breakIndex.value0)($foreign.length(arr))(arr) | |
| }; | |
| }; | |
| if (breakIndex instanceof Data_Maybe.Nothing) { | |
| return { | |
| init: arr, | |
| rest: [ ] | |
| }; | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 528, column 3 - line 534, column 30: " + [ breakIndex.constructor.name ]); | |
| }; | |
| }; | |
| // | Calculate the longest initial subarray for which all element satisfy the | |
| // | specified predicate, creating a new array. | |
| var takeWhile = function (p) { | |
| return function (xs) { | |
| return (span(p)(xs)).init; | |
| }; | |
| }; | |
| // | Transforms an array of pairs into an array of first components and an | |
| // | array of second components. | |
| var unzip = function (xs) { | |
| return Control_Monad_ST.pureST(function __do() { | |
| var v = Data_Array_ST.emptySTArray(); | |
| var v1 = Data_Array_ST.emptySTArray(); | |
| var v2 = Data_Array_ST_Iterator.iterator(function (v2) { | |
| return index(xs)(v2); | |
| })(); | |
| Data_Array_ST_Iterator.iterate(v2)(function (v3) { | |
| return function __do() { | |
| Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_Array_ST.pushSTArray(v)(v3.value0))(); | |
| return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_Array_ST.pushSTArray(v1)(v3.value1))(); | |
| }; | |
| })(); | |
| var v3 = Data_Array_ST.unsafeFreeze(v)(); | |
| var v4 = Data_Array_ST.unsafeFreeze(v1)(); | |
| return new Data_Tuple.Tuple(v3, v4); | |
| }); | |
| }; | |
| //------------------------------------------------------------------------------ | |
| // Non-indexed reads ----------------------------------------------------------- | |
| //------------------------------------------------------------------------------ | |
| // | Get the first element in an array, or `Nothing` if the array is empty | |
| // | | |
| // | Running time: `O(1)`. | |
| var head = function (xs) { | |
| return index(xs)(0); | |
| }; | |
| // | Group equal, consecutive elements of an array into arrays, using the | |
| // | specified equivalence relation to detemine equality. | |
| var groupBy = function (op) { | |
| return function (xs) { | |
| return Control_Monad_ST.pureST(function __do() { | |
| var v = Data_Array_ST.emptySTArray(); | |
| var v1 = Data_Array_ST_Iterator.iterator(function (v1) { | |
| return index(xs)(v1); | |
| })(); | |
| Data_Array_ST_Iterator.iterate(v1)(function (x) { | |
| return Data_Functor["void"](Control_Monad_Eff.functorEff)(function __do() { | |
| var v2 = Data_Array_ST.emptySTArray(); | |
| Data_Array_ST_Iterator.pushWhile(op(x))(v1)(v2)(); | |
| var v3 = Data_Array_ST.unsafeFreeze(v2)(); | |
| return Data_Array_ST.pushSTArray(v)(new Data_NonEmpty.NonEmpty(x, v3))(); | |
| }); | |
| })(); | |
| return Data_Array_ST.unsafeFreeze(v)(); | |
| }); | |
| }; | |
| }; | |
| // | Group equal, consecutive elements of an array into arrays. | |
| // | | |
| // | ```purescript | |
| // | group [1,1,2,2,1] == [[1,1],[2,2],[1]] | |
| // | ``` | |
| var group = function (dictEq) { | |
| return function (xs) { | |
| return groupBy(Data_Eq.eq(dictEq))(xs); | |
| }; | |
| }; | |
| // | Sort and then group the elements of an array into arrays. | |
| // | | |
| // | ```purescript | |
| // | group' [1,1,2,2,1] == [[1,1,1],[2,2]] | |
| // | ``` | |
| var group$prime = function (dictOrd) { | |
| return function ($93) { | |
| return group(dictOrd.Eq0())(sort(dictOrd)($93)); | |
| }; | |
| }; | |
| // | Convert a `Foldable` structure into an `Array`. | |
| var fromFoldable = function (dictFoldable) { | |
| return $foreign.fromFoldableImpl(Data_Foldable.foldr(dictFoldable)); | |
| }; | |
| var foldRecM = function (dictMonadRec) { | |
| return function (f) { | |
| return function (a) { | |
| return function (array) { | |
| var go = function (res) { | |
| return function (i) { | |
| if (i >= $foreign.length(array)) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(res)); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(f(res)(unsafeIndex()(array)(i)))(function (v) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop({ | |
| a: v, | |
| b: i + 1 | 0 | |
| })); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 693, column 3 - line 697, column 42: " + [ res.constructor.name, i.constructor.name ]); | |
| }; | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM2(dictMonadRec)(go)(a)(0); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Perform a fold using a monadic step function. | |
| var foldM = function (dictMonad) { | |
| return function (f) { | |
| return function (a) { | |
| return $foreign["uncons'"](function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(a); | |
| })(function (b) { | |
| return function (bs) { | |
| return Control_Bind.bind(dictMonad.Bind1())(f(a)(b))(function (a$prime) { | |
| return foldM(dictMonad)(f)(a$prime)(bs); | |
| }); | |
| }; | |
| }); | |
| }; | |
| }; | |
| }; | |
| // | Find the last index for which a predicate holds. | |
| var findLastIndex = $foreign.findLastIndexImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Insert an element into a sorted array, using the specified function to | |
| // | determine the ordering of elements. | |
| var insertBy = function (cmp) { | |
| return function (x) { | |
| return function (ys) { | |
| var i = Data_Maybe.maybe(0)(function (v) { | |
| return v + 1 | 0; | |
| })(findLastIndex(function (y) { | |
| return Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(x)(y))(Data_Ordering.GT.value); | |
| })(ys)); | |
| return Data_Maybe.fromJust()(insertAt(i)(x)(ys)); | |
| }; | |
| }; | |
| }; | |
| // | Insert an element into a sorted array. | |
| var insert = function (dictOrd) { | |
| return insertBy(Data_Ord.compare(dictOrd)); | |
| }; | |
| // | Find the first index for which a predicate holds. | |
| var findIndex = $foreign.findIndexImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Calculate the intersection of two arrays, using the specified equivalence | |
| // | relation to compare elements, creating a new array. Note that duplicates | |
| // | in the first array are preserved while duplicates in the second array are | |
| // | removed. | |
| var intersectBy = function (eq) { | |
| return function (xs) { | |
| return function (ys) { | |
| return $foreign.filter(function (x) { | |
| return Data_Maybe.isJust(findIndex(eq(x))(ys)); | |
| })(xs); | |
| }; | |
| }; | |
| }; | |
| // | Calculate the intersection of two arrays, creating a new array. Note that | |
| // | duplicates in the first array are preserved while duplicates in the second | |
| // | array are removed. | |
| var intersect = function (dictEq) { | |
| return intersectBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Find the index of the last element equal to the specified element. | |
| var elemLastIndex = function (dictEq) { | |
| return function (x) { | |
| return findLastIndex(function (v) { | |
| return Data_Eq.eq(dictEq)(v)(x); | |
| }); | |
| }; | |
| }; | |
| // | Find the index of the first element equal to the specified element. | |
| var elemIndex = function (dictEq) { | |
| return function (x) { | |
| return findIndex(function (v) { | |
| return Data_Eq.eq(dictEq)(v)(x); | |
| }); | |
| }; | |
| }; | |
| // | Remove the longest initial subarray for which all element satisfy the | |
| // | specified predicate, creating a new array. | |
| var dropWhile = function (p) { | |
| return function (xs) { | |
| return (span(p)(xs)).rest; | |
| }; | |
| }; | |
| // | Delete the element at the specified index, creating a new array, or | |
| // | returning `Nothing` if the index is out of bounds. | |
| var deleteAt = $foreign._deleteAt(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Delete the first element of an array which matches the specified value, | |
| // | under the equivalence relation provided in the first argument, creating a | |
| // | new array. | |
| var deleteBy = function (v) { | |
| return function (v1) { | |
| return function (v2) { | |
| if (v2.length === 0) { | |
| return [ ]; | |
| }; | |
| return Data_Maybe.maybe(v2)(function (i) { | |
| return Data_Maybe.fromJust()(deleteAt(i)(v2)); | |
| })(findIndex(v(v1))(v2)); | |
| }; | |
| }; | |
| }; | |
| // | Calculate the union of two arrays, using the specified function to | |
| // | determine equality of elements. Note that duplicates in the first array | |
| // | are preserved while duplicates in the second array are removed. | |
| var unionBy = function (eq) { | |
| return function (xs) { | |
| return function (ys) { | |
| return Data_Semigroup.append(Data_Semigroup.semigroupArray)(xs)(Data_Foldable.foldl(Data_Foldable.foldableArray)(Data_Function.flip(deleteBy(eq)))(nubBy(eq)(ys))(xs)); | |
| }; | |
| }; | |
| }; | |
| // | Calculate the union of two arrays. Note that duplicates in the first array | |
| // | are preserved while duplicates in the second array are removed. | |
| // | | |
| // | Running time: `O(n^2)` | |
| var union = function (dictEq) { | |
| return unionBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Delete the first element of an array which is equal to the specified value, | |
| // | creating a new array. | |
| // | | |
| // | Running time: `O(n)` | |
| var $$delete = function (dictEq) { | |
| return deleteBy(Data_Eq.eq(dictEq)); | |
| }; | |
| // | Delete the first occurrence of each element in the second array from the | |
| // | first array, creating a new array. | |
| // | | |
| // | Running time: `O(n*m)`, where n is the length of the first array, and m is | |
| // | the length of the second. | |
| var difference = function (dictEq) { | |
| return Data_Foldable.foldr(Data_Foldable.foldableArray)($$delete(dictEq)); | |
| }; | |
| // | Apply a function to each element in an array, and flatten the results | |
| // | into a single, new array. | |
| var concatMap = Data_Function.flip(Control_Bind.bind(Control_Bind.bindArray)); | |
| // | Apply a function to each element in an array, keeping only the results | |
| // | which contain a value, creating a new array. | |
| var mapMaybe = function (f) { | |
| return concatMap(function ($94) { | |
| return Data_Maybe.maybe([ ])(singleton)(f($94)); | |
| }); | |
| }; | |
| // | Filter where the predicate returns a `Boolean` in some `Applicative`. | |
| // | | |
| // | ```purescript | |
| // | powerSet :: forall a. Array a -> Array (Array a) | |
| // | powerSet = filterA (const [true, false]) | |
| // | ``` | |
| var filterA = function (dictApplicative) { | |
| return function (p) { | |
| return function ($95) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(mapMaybe(function (v) { | |
| if (v.value1) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }))(Data_Traversable.traverse(Data_Traversable.traversableArray)(dictApplicative)(function (x) { | |
| return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Tuple.Tuple.create(x))(p(x)); | |
| })($95)); | |
| }; | |
| }; | |
| }; | |
| // | Filter an array of optional values, keeping only the elements which contain | |
| // | a value, creating a new array. | |
| var catMaybes = mapMaybe(Control_Category.id(Control_Category.categoryFn)); | |
| // | Update or delete the element at the specified index by applying a | |
| // | function to the current value, returning a new array or `Nothing` if the | |
| // | index is out-of-bounds. | |
| var alterAt = function (i) { | |
| return function (f) { | |
| return function (xs) { | |
| var go = function (x) { | |
| var v = f(x); | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return deleteAt(i)(xs); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return updateAt(i)(v.value0)(xs); | |
| }; | |
| throw new Error("Failed pattern match at Data.Array line 390, column 10 - line 392, column 32: " + [ v.constructor.name ]); | |
| }; | |
| return Data_Maybe.maybe(Data_Maybe.Nothing.value)(go)(index(xs)(i)); | |
| }; | |
| }; | |
| }; | |
| exports["alterAt"] = alterAt; | |
| exports["catMaybes"] = catMaybes; | |
| exports["concatMap"] = concatMap; | |
| exports["delete"] = $$delete; | |
| exports["deleteAt"] = deleteAt; | |
| exports["deleteBy"] = deleteBy; | |
| exports["difference"] = difference; | |
| exports["dropWhile"] = dropWhile; | |
| exports["elemIndex"] = elemIndex; | |
| exports["elemLastIndex"] = elemLastIndex; | |
| exports["filterA"] = filterA; | |
| exports["findIndex"] = findIndex; | |
| exports["findLastIndex"] = findLastIndex; | |
| exports["foldM"] = foldM; | |
| exports["foldRecM"] = foldRecM; | |
| exports["fromFoldable"] = fromFoldable; | |
| exports["group"] = group; | |
| exports["group'"] = group$prime; | |
| exports["groupBy"] = groupBy; | |
| exports["head"] = head; | |
| exports["index"] = index; | |
| exports["init"] = init; | |
| exports["insert"] = insert; | |
| exports["insertAt"] = insertAt; | |
| exports["insertBy"] = insertBy; | |
| exports["intersect"] = intersect; | |
| exports["intersectBy"] = intersectBy; | |
| exports["last"] = last; | |
| exports["many"] = many; | |
| exports["mapMaybe"] = mapMaybe; | |
| exports["mapWithIndex"] = mapWithIndex; | |
| exports["modifyAt"] = modifyAt; | |
| exports["modifyAtIndices"] = modifyAtIndices; | |
| exports["nub"] = nub; | |
| exports["nubBy"] = nubBy; | |
| exports["null"] = $$null; | |
| exports["singleton"] = singleton; | |
| exports["some"] = some; | |
| exports["sort"] = sort; | |
| exports["sortBy"] = sortBy; | |
| exports["sortWith"] = sortWith; | |
| exports["span"] = span; | |
| exports["tail"] = tail; | |
| exports["takeWhile"] = takeWhile; | |
| exports["toUnfoldable"] = toUnfoldable; | |
| exports["uncons"] = uncons; | |
| exports["union"] = union; | |
| exports["unionBy"] = unionBy; | |
| exports["unsafeIndex"] = unsafeIndex; | |
| exports["unsnoc"] = unsnoc; | |
| exports["unzip"] = unzip; | |
| exports["updateAt"] = updateAt; | |
| exports["updateAtIndices"] = updateAtIndices; | |
| exports["zip"] = zip; | |
| exports["zipWithA"] = zipWithA; | |
| exports["concat"] = $foreign.concat; | |
| exports["cons"] = $foreign.cons; | |
| exports["drop"] = $foreign.drop; | |
| exports["filter"] = $foreign.filter; | |
| exports["length"] = $foreign.length; | |
| exports["partition"] = $foreign.partition; | |
| exports["range"] = $foreign.range; | |
| exports["replicate"] = $foreign.replicate; | |
| exports["reverse"] = $foreign.reverse; | |
| exports["slice"] = $foreign.slice; | |
| exports["snoc"] = $foreign.snoc; | |
| exports["take"] = $foreign.take; | |
| exports["zipWith"] = $foreign.zipWith; | |
| })(PS["Data.Array"] = PS["Data.Array"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports._charAt = function (just) { | |
| return function (nothing) { | |
| return function (i) { | |
| return function (s) { | |
| return i >= 0 && i < s.length ? just(s.charAt(i)) : nothing; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.singleton = function (c) { | |
| return c; | |
| }; | |
| exports._charCodeAt = function (just) { | |
| return function (nothing) { | |
| return function (i) { | |
| return function (s) { | |
| return i >= 0 && i < s.length ? just(s.charCodeAt(i)) : nothing; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._toChar = function (just) { | |
| return function (nothing) { | |
| return function (s) { | |
| return s.length === 1 ? just(s) : nothing; | |
| }; | |
| }; | |
| }; | |
| exports.fromCharArray = function (a) { | |
| return a.join(""); | |
| }; | |
| exports._indexOf = function (just) { | |
| return function (nothing) { | |
| return function (x) { | |
| return function (s) { | |
| var i = s.indexOf(x); | |
| return i === -1 ? nothing : just(i); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["_indexOf'"] = function (just) { | |
| return function (nothing) { | |
| return function (x) { | |
| return function (startAt) { | |
| return function (s) { | |
| if (startAt < 0 || startAt > s.length) return nothing; | |
| var i = s.indexOf(x, startAt); | |
| return i === -1 ? nothing : just(i); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports._lastIndexOf = function (just) { | |
| return function (nothing) { | |
| return function (x) { | |
| return function (s) { | |
| var i = s.lastIndexOf(x); | |
| return i === -1 ? nothing : just(i); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports["_lastIndexOf'"] = function (just) { | |
| return function (nothing) { | |
| return function (x) { | |
| return function (startAt) { | |
| return function (s) { | |
| if (startAt < 0 || startAt > s.length) return nothing; | |
| var i = s.lastIndexOf(x, startAt); | |
| return i === -1 ? nothing : just(i); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.length = function (s) { | |
| return s.length; | |
| }; | |
| exports._localeCompare = function (lt) { | |
| return function (eq) { | |
| return function (gt) { | |
| return function (s1) { | |
| return function (s2) { | |
| var result = s1.localeCompare(s2); | |
| return result < 0 ? lt : result > 0 ? gt : eq; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.replace = function (s1) { | |
| return function (s2) { | |
| return function (s3) { | |
| return s3.replace(s1, s2); | |
| }; | |
| }; | |
| }; | |
| exports.replaceAll = function (s1) { | |
| return function (s2) { | |
| return function (s3) { | |
| return s3.replace(new RegExp(s1.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), s2); | |
| }; | |
| }; | |
| }; | |
| exports.take = function (n) { | |
| return function (s) { | |
| return s.substr(0, n); | |
| }; | |
| }; | |
| exports.drop = function (n) { | |
| return function (s) { | |
| return s.substring(n); | |
| }; | |
| }; | |
| exports.count = function (p) { | |
| return function (s) { | |
| var i = 0; | |
| while (i < s.length && p(s.charAt(i))) i++; | |
| return i; | |
| }; | |
| }; | |
| exports.split = function (sep) { | |
| return function (s) { | |
| return s.split(sep); | |
| }; | |
| }; | |
| exports._splitAt = function (just) { | |
| return function (nothing) { | |
| return function (i) { | |
| return function (s) { | |
| return i >= 0 && i < s.length ? | |
| just({ before: s.substring(0, i), after: s.substring(i) }) : | |
| nothing; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.toCharArray = function (s) { | |
| return s.split(""); | |
| }; | |
| exports.toLower = function (s) { | |
| return s.toLowerCase(); | |
| }; | |
| exports.toUpper = function (s) { | |
| return s.toUpperCase(); | |
| }; | |
| exports.trim = function (s) { | |
| return s.trim(); | |
| }; | |
| exports.joinWith = function (s) { | |
| return function (xs) { | |
| return xs.join(s); | |
| }; | |
| }; | |
| })(PS["Data.String"] = PS["Data.String"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.charCodeAt = function (i) { | |
| return function (s) { | |
| if (i >= 0 && i < s.length) return s.charCodeAt(i); | |
| throw new Error("Data.String.Unsafe.charCodeAt: Invalid index."); | |
| }; | |
| }; | |
| exports.charAt = function (i) { | |
| return function (s) { | |
| if (i >= 0 && i < s.length) return s.charAt(i); | |
| throw new Error("Data.String.Unsafe.charAt: Invalid index."); | |
| }; | |
| }; | |
| exports.char = function (s) { | |
| if (s.length === 1) return s.charAt(0); | |
| throw new Error("Data.String.Unsafe.char: Expected string of length 1."); | |
| }; | |
| })(PS["Data.String.Unsafe"] = PS["Data.String.Unsafe"] || {}); | |
| (function(exports) { | |
| // | Unsafe string and character functions. | |
| "use strict"; | |
| var $foreign = PS["Data.String.Unsafe"]; | |
| exports["char"] = $foreign["char"]; | |
| exports["charAt"] = $foreign.charAt; | |
| exports["charCodeAt"] = $foreign.charCodeAt; | |
| })(PS["Data.String.Unsafe"] = PS["Data.String.Unsafe"] || {}); | |
| (function(exports) { | |
| // | Wraps the functions of Javascript's `String` object. | |
| // | A String represents a sequence of characters. | |
| // | For details of the underlying implementation, see [String Reference at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String). | |
| "use strict"; | |
| var $foreign = PS["Data.String"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_String_Unsafe = PS["Data.String.Unsafe"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A newtype used in cases to specify a replacement for a pattern. | |
| var Replacement = function (x) { | |
| return x; | |
| }; | |
| // | A newtype used in cases where there is a string to be matched. | |
| var Pattern = function (x) { | |
| return x; | |
| }; | |
| // | Returns the first character and the rest of the string, | |
| // | if the string is not empty. | |
| var uncons = function (v) { | |
| if (v === "") { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| return new Data_Maybe.Just({ | |
| head: Data_String_Unsafe.charAt(0)(v), | |
| tail: $foreign.drop(1)(v) | |
| }); | |
| }; | |
| var toChar = $foreign._toChar(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Returns the longest prefix (possibly empty) of characters that satisfy | |
| // | the predicate. | |
| var takeWhile = function (p) { | |
| return function (s) { | |
| return $foreign.take($foreign.count(p)(s))(s); | |
| }; | |
| }; | |
| // | Returns the substrings of split at the given index, if the index is within bounds. | |
| var splitAt = $foreign._splitAt(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| var showReplacement = new Data_Show.Show(function (v) { | |
| return "(Replacement " + (v + ")"); | |
| }); | |
| var showPattern = new Data_Show.Show(function (v) { | |
| return "(Pattern " + (v + ")"); | |
| }); | |
| // | Returns `true` if the given string is empty. | |
| var $$null = function (s) { | |
| return s === ""; | |
| }; | |
| var newtypeReplacement = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Replacement); | |
| var newtypePattern = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Pattern); | |
| // | Locale-aware sort order comparison. | |
| var localeCompare = $foreign._localeCompare(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value); | |
| // | Returns the index of the last occurrence of the first string in the | |
| // | second string, starting at the given index. Returns `Nothing` if there is | |
| // | no match. | |
| var lastIndexOf$prime = $foreign["_lastIndexOf'"](Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Returns the index of the last occurrence of the first string in the | |
| // | second string. Returns `Nothing` if there is no match. | |
| var lastIndexOf = $foreign._lastIndexOf(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | If the string ends with the given suffix, return the portion of the | |
| // | string left after removing it, as a Just value. Otherwise, return Nothing. | |
| // | * `stripSuffix (Pattern ".exe") "psc.exe" == Just "psc"` | |
| // | * `stripSuffix (Pattern ".exe") "psc" == Nothing` | |
| var stripSuffix = function (v) { | |
| return function (str) { | |
| var v1 = lastIndexOf(v)(str); | |
| if (v1 instanceof Data_Maybe.Just && v1.value0 === ($foreign.length(str) - $foreign.length(v) | 0)) { | |
| return Data_Maybe.Just.create($foreign.take(v1.value0)(str)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| // | Returns the index of the first occurrence of the first string in the | |
| // | second string, starting at the given index. Returns `Nothing` if there is | |
| // | no match. | |
| var indexOf$prime = $foreign["_indexOf'"](Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Returns the index of the first occurrence of the first string in the | |
| // | second string. Returns `Nothing` if there is no match. | |
| var indexOf = $foreign._indexOf(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | If the string starts with the given prefix, return the portion of the | |
| // | string left after removing it, as a Just value. Otherwise, return Nothing. | |
| // | * `stripPrefix (Pattern "http:") "http://purescript.org" == Just "//purescript.org"` | |
| // | * `stripPrefix (Pattern "http:") "https://purescript.org" == Nothing` | |
| var stripPrefix = function (v) { | |
| return function (str) { | |
| var v1 = indexOf(v)(str); | |
| if (v1 instanceof Data_Maybe.Just && v1.value0 === 0) { | |
| return Data_Maybe.Just.create($foreign.drop($foreign.length(v))(str)); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| }; | |
| var eqReplacement = new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return x === y; | |
| }; | |
| }); | |
| var ordReplacement = new Data_Ord.Ord(function () { | |
| return eqReplacement; | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ord.compare(Data_Ord.ordString)(x)(y); | |
| }; | |
| }); | |
| var eqPattern = new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return x === y; | |
| }; | |
| }); | |
| var ordPattern = new Data_Ord.Ord(function () { | |
| return eqPattern; | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ord.compare(Data_Ord.ordString)(x)(y); | |
| }; | |
| }); | |
| // | Returns the suffix remaining after `takeWhile`. | |
| var dropWhile = function (p) { | |
| return function (s) { | |
| return $foreign.drop($foreign.count(p)(s))(s); | |
| }; | |
| }; | |
| // | Checks whether the first string exists in the second string. | |
| var contains = function (pat) { | |
| return function ($48) { | |
| return Data_Maybe.isJust(indexOf(pat)($48)); | |
| }; | |
| }; | |
| // | Returns the numeric Unicode value of the character at the given index, | |
| // | if the index is within bounds. | |
| var charCodeAt = $foreign._charCodeAt(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| // | Returns the character at the given index, if the index is within bounds. | |
| var charAt = $foreign._charAt(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); | |
| exports["Pattern"] = Pattern; | |
| exports["Replacement"] = Replacement; | |
| exports["charAt"] = charAt; | |
| exports["charCodeAt"] = charCodeAt; | |
| exports["contains"] = contains; | |
| exports["dropWhile"] = dropWhile; | |
| exports["indexOf"] = indexOf; | |
| exports["indexOf'"] = indexOf$prime; | |
| exports["lastIndexOf"] = lastIndexOf; | |
| exports["lastIndexOf'"] = lastIndexOf$prime; | |
| exports["localeCompare"] = localeCompare; | |
| exports["null"] = $$null; | |
| exports["splitAt"] = splitAt; | |
| exports["stripPrefix"] = stripPrefix; | |
| exports["stripSuffix"] = stripSuffix; | |
| exports["takeWhile"] = takeWhile; | |
| exports["toChar"] = toChar; | |
| exports["uncons"] = uncons; | |
| exports["eqPattern"] = eqPattern; | |
| exports["ordPattern"] = ordPattern; | |
| exports["newtypePattern"] = newtypePattern; | |
| exports["showPattern"] = showPattern; | |
| exports["eqReplacement"] = eqReplacement; | |
| exports["ordReplacement"] = ordReplacement; | |
| exports["newtypeReplacement"] = newtypeReplacement; | |
| exports["showReplacement"] = showReplacement; | |
| exports["count"] = $foreign.count; | |
| exports["drop"] = $foreign.drop; | |
| exports["fromCharArray"] = $foreign.fromCharArray; | |
| exports["joinWith"] = $foreign.joinWith; | |
| exports["length"] = $foreign.length; | |
| exports["replace"] = $foreign.replace; | |
| exports["replaceAll"] = $foreign.replaceAll; | |
| exports["singleton"] = $foreign.singleton; | |
| exports["split"] = $foreign.split; | |
| exports["take"] = $foreign.take; | |
| exports["toCharArray"] = $foreign.toCharArray; | |
| exports["toLower"] = $foreign.toLower; | |
| exports["toUpper"] = $foreign.toUpper; | |
| exports["trim"] = $foreign.trim; | |
| })(PS["Data.String"] = PS["Data.String"] || {}); | |
| (function(exports) { | |
| // | The `Proxy` type and values are for situations where type information is | |
| // | required for an input to determine the type of an output, but where it is | |
| // | not possible or convenient to provide a _value_ for the input. | |
| // | | |
| // | A hypothetical example: if you have a class that is used to handle the | |
| // | result of an AJAX request, you may want to use this information to set the | |
| // | expected content type of the request, so you might have a class something | |
| // | like this: | |
| // | | |
| // | ``` purescript | |
| // | class AjaxResponse a where | |
| // | responseType :: a -> ResponseType | |
| // | fromResponse :: Foreign -> a | |
| // | ``` | |
| // | | |
| // | The problem here is `responseType` requires a value of type `a`, but we | |
| // | won't have a value of that type until the request has been completed. The | |
| // | solution is to use a `Proxy` type instead: | |
| // | | |
| // | ``` purescript | |
| // | class AjaxResponse a where | |
| // | responseType :: Proxy a -> ResponseType | |
| // | fromResponse :: Foreign -> a | |
| // | ``` | |
| // | | |
| // | We can now call `responseType (Proxy :: Proxy SomeContentType)` to produce | |
| // | a `ResponseType` for `SomeContentType` without having to construct some | |
| // | empty version of `SomeContentType` first. In situations like this where | |
| // | the `Proxy` type can be statically determined, it is recommended to pull | |
| // | out the definition to the top level and make a declaration like: | |
| // | | |
| // | ``` purescript | |
| // | _SomeContentType :: Proxy SomeContentType | |
| // | _SomeContentType = Proxy | |
| // | ``` | |
| // | | |
| // | That way the proxy value can be used as `responseType _SomeContentType` | |
| // | for improved readability. However, this is not always possible, sometimes | |
| // | the type required will be determined by a type variable. As PureScript has | |
| // | scoped type variables, we can do things like this: | |
| // | | |
| // | ``` purescript | |
| // | makeRequest :: URL -> ResponseType -> Aff _ Foreign | |
| // | makeRequest = ... | |
| // | | |
| // | fetchData :: forall a. (AjaxResponse a) => URL -> Aff _ a | |
| // | fetchData url = fromResponse <$> makeRequest url (responseType (Proxy :: Proxy a)) | |
| // | ``` | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; | |
| var Data_Bounded = PS["Data.Bounded"]; | |
| var Data_CommutativeRing = PS["Data.CommutativeRing"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Value proxy for kind `Type -> Type -> Type` types. | |
| var Proxy3 = (function () { | |
| function Proxy3() { | |
| }; | |
| Proxy3.value = new Proxy3(); | |
| return Proxy3; | |
| })(); | |
| // | Value proxy for kind `Type -> Type` types. | |
| var Proxy2 = (function () { | |
| function Proxy2() { | |
| }; | |
| Proxy2.value = new Proxy2(); | |
| return Proxy2; | |
| })(); | |
| // | Value proxy for kind `Type` types. | |
| var $$Proxy = (function () { | |
| function $$Proxy() { | |
| }; | |
| $$Proxy.value = new $$Proxy(); | |
| return $$Proxy; | |
| })(); | |
| var showProxy3 = new Data_Show.Show(function (v) { | |
| return "Proxy3"; | |
| }); | |
| var showProxy2 = new Data_Show.Show(function (v) { | |
| return "Proxy2"; | |
| }); | |
| var showProxy = new Data_Show.Show(function (v) { | |
| return "Proxy"; | |
| }); | |
| var semiringProxy3 = new Data_Semiring.Semiring(function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }, Proxy3.value, Proxy3.value); | |
| var semiringProxy2 = new Data_Semiring.Semiring(function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }, Proxy2.value, Proxy2.value); | |
| var semiringProxy = new Data_Semiring.Semiring(function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }, $$Proxy.value, $$Proxy.value); | |
| var semigroupProxy3 = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }); | |
| var semigroupProxy2 = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }); | |
| var semigroupProxy = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }); | |
| var ringProxy3 = new Data_Ring.Ring(function () { | |
| return semiringProxy3; | |
| }, function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }); | |
| var ringProxy2 = new Data_Ring.Ring(function () { | |
| return semiringProxy2; | |
| }, function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }); | |
| var ringProxy = new Data_Ring.Ring(function () { | |
| return semiringProxy; | |
| }, function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }); | |
| var heytingAlgebraProxy3 = new Data_HeytingAlgebra.HeytingAlgebra(function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }, Proxy3.value, function (v) { | |
| return function (v1) { | |
| return Proxy3.value; | |
| }; | |
| }, function (v) { | |
| return Proxy3.value; | |
| }, Proxy3.value); | |
| var heytingAlgebraProxy2 = new Data_HeytingAlgebra.HeytingAlgebra(function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }, Proxy2.value, function (v) { | |
| return function (v1) { | |
| return Proxy2.value; | |
| }; | |
| }, function (v) { | |
| return Proxy2.value; | |
| }, Proxy2.value); | |
| var heytingAlgebraProxy = new Data_HeytingAlgebra.HeytingAlgebra(function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }, function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }, $$Proxy.value, function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }, function (v) { | |
| return $$Proxy.value; | |
| }, $$Proxy.value); | |
| var functorProxy = new Data_Functor.Functor(function (f) { | |
| return function (m) { | |
| return $$Proxy.value; | |
| }; | |
| }); | |
| var eqProxy3 = new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return true; | |
| }; | |
| }); | |
| var ordProxy3 = new Data_Ord.Ord(function () { | |
| return eqProxy3; | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| }); | |
| var eqProxy2 = new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return true; | |
| }; | |
| }); | |
| var ordProxy2 = new Data_Ord.Ord(function () { | |
| return eqProxy2; | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| }); | |
| var eqProxy = new Data_Eq.Eq(function (x) { | |
| return function (y) { | |
| return true; | |
| }; | |
| }); | |
| var ordProxy = new Data_Ord.Ord(function () { | |
| return eqProxy; | |
| }, function (x) { | |
| return function (y) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| }); | |
| var discardProxy3 = new Control_Bind.Discard(function (dictBind) { | |
| return Control_Bind.bind(dictBind); | |
| }); | |
| var discardProxy2 = new Control_Bind.Discard(function (dictBind) { | |
| return Control_Bind.bind(dictBind); | |
| }); | |
| var discardProxy = new Control_Bind.Discard(function (dictBind) { | |
| return Control_Bind.bind(dictBind); | |
| }); | |
| var commutativeRingProxy3 = new Data_CommutativeRing.CommutativeRing(function () { | |
| return ringProxy3; | |
| }); | |
| var commutativeRingProxy2 = new Data_CommutativeRing.CommutativeRing(function () { | |
| return ringProxy2; | |
| }); | |
| var commutativeRingProxy = new Data_CommutativeRing.CommutativeRing(function () { | |
| return ringProxy; | |
| }); | |
| var boundedProxy3 = new Data_Bounded.Bounded(function () { | |
| return ordProxy3; | |
| }, Proxy3.value, Proxy3.value); | |
| var boundedProxy2 = new Data_Bounded.Bounded(function () { | |
| return ordProxy2; | |
| }, Proxy2.value, Proxy2.value); | |
| var boundedProxy = new Data_Bounded.Bounded(function () { | |
| return ordProxy; | |
| }, $$Proxy.value, $$Proxy.value); | |
| var booleanAlgebraProxy3 = new Data_BooleanAlgebra.BooleanAlgebra(function () { | |
| return heytingAlgebraProxy3; | |
| }); | |
| var booleanAlgebraProxy2 = new Data_BooleanAlgebra.BooleanAlgebra(function () { | |
| return heytingAlgebraProxy2; | |
| }); | |
| var booleanAlgebraProxy = new Data_BooleanAlgebra.BooleanAlgebra(function () { | |
| return heytingAlgebraProxy; | |
| }); | |
| var applyProxy = new Control_Apply.Apply(function () { | |
| return functorProxy; | |
| }, function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }); | |
| var bindProxy = new Control_Bind.Bind(function () { | |
| return applyProxy; | |
| }, function (v) { | |
| return function (v1) { | |
| return $$Proxy.value; | |
| }; | |
| }); | |
| var applicativeProxy = new Control_Applicative.Applicative(function () { | |
| return applyProxy; | |
| }, function (v) { | |
| return $$Proxy.value; | |
| }); | |
| var monadProxy = new Control_Monad.Monad(function () { | |
| return applicativeProxy; | |
| }, function () { | |
| return bindProxy; | |
| }); | |
| exports["Proxy"] = $$Proxy; | |
| exports["Proxy2"] = Proxy2; | |
| exports["Proxy3"] = Proxy3; | |
| exports["eqProxy"] = eqProxy; | |
| exports["functorProxy"] = functorProxy; | |
| exports["ordProxy"] = ordProxy; | |
| exports["applicativeProxy"] = applicativeProxy; | |
| exports["applyProxy"] = applyProxy; | |
| exports["bindProxy"] = bindProxy; | |
| exports["booleanAlgebraProxy"] = booleanAlgebraProxy; | |
| exports["boundedProxy"] = boundedProxy; | |
| exports["commutativeRingProxy"] = commutativeRingProxy; | |
| exports["discardProxy"] = discardProxy; | |
| exports["heytingAlgebraProxy"] = heytingAlgebraProxy; | |
| exports["monadProxy"] = monadProxy; | |
| exports["ringProxy"] = ringProxy; | |
| exports["semigroupProxy"] = semigroupProxy; | |
| exports["semiringProxy"] = semiringProxy; | |
| exports["showProxy"] = showProxy; | |
| exports["eqProxy2"] = eqProxy2; | |
| exports["ordProxy2"] = ordProxy2; | |
| exports["booleanAlgebraProxy2"] = booleanAlgebraProxy2; | |
| exports["boundedProxy2"] = boundedProxy2; | |
| exports["commutativeRingProxy2"] = commutativeRingProxy2; | |
| exports["discardProxy2"] = discardProxy2; | |
| exports["heytingAlgebraProxy2"] = heytingAlgebraProxy2; | |
| exports["ringProxy2"] = ringProxy2; | |
| exports["semigroupProxy2"] = semigroupProxy2; | |
| exports["semiringProxy2"] = semiringProxy2; | |
| exports["showProxy2"] = showProxy2; | |
| exports["eqProxy3"] = eqProxy3; | |
| exports["ordProxy3"] = ordProxy3; | |
| exports["booleanAlgebraProxy3"] = booleanAlgebraProxy3; | |
| exports["boundedProxy3"] = boundedProxy3; | |
| exports["commutativeRingProxy3"] = commutativeRingProxy3; | |
| exports["discardProxy3"] = discardProxy3; | |
| exports["heytingAlgebraProxy3"] = heytingAlgebraProxy3; | |
| exports["ringProxy3"] = ringProxy3; | |
| exports["semigroupProxy3"] = semigroupProxy3; | |
| exports["semiringProxy3"] = semiringProxy3; | |
| exports["showProxy3"] = showProxy3; | |
| })(PS["Type.Proxy"] = PS["Type.Proxy"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Data.Generic"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Array = PS["Data.Array"]; | |
| var Data_Boolean = PS["Data.Boolean"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_List_Types = PS["Data.List.Types"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_NonEmpty = PS["Data.NonEmpty"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ordering = PS["Data.Ordering"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_String = PS["Data.String"]; | |
| var Data_Traversable = PS["Data.Traversable"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Data_Void = PS["Data.Void"]; | |
| var Prelude = PS["Prelude"]; | |
| var Type_Proxy = PS["Type.Proxy"]; | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SProd = (function () { | |
| function SProd(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| SProd.create = function (value0) { | |
| return function (value1) { | |
| return new SProd(value0, value1); | |
| }; | |
| }; | |
| return SProd; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SRecord = (function () { | |
| function SRecord(value0) { | |
| this.value0 = value0; | |
| }; | |
| SRecord.create = function (value0) { | |
| return new SRecord(value0); | |
| }; | |
| return SRecord; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SNumber = (function () { | |
| function SNumber(value0) { | |
| this.value0 = value0; | |
| }; | |
| SNumber.create = function (value0) { | |
| return new SNumber(value0); | |
| }; | |
| return SNumber; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SBoolean = (function () { | |
| function SBoolean(value0) { | |
| this.value0 = value0; | |
| }; | |
| SBoolean.create = function (value0) { | |
| return new SBoolean(value0); | |
| }; | |
| return SBoolean; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SInt = (function () { | |
| function SInt(value0) { | |
| this.value0 = value0; | |
| }; | |
| SInt.create = function (value0) { | |
| return new SInt(value0); | |
| }; | |
| return SInt; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SString = (function () { | |
| function SString(value0) { | |
| this.value0 = value0; | |
| }; | |
| SString.create = function (value0) { | |
| return new SString(value0); | |
| }; | |
| return SString; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SChar = (function () { | |
| function SChar(value0) { | |
| this.value0 = value0; | |
| }; | |
| SChar.create = function (value0) { | |
| return new SChar(value0); | |
| }; | |
| return SChar; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SArray = (function () { | |
| function SArray(value0) { | |
| this.value0 = value0; | |
| }; | |
| SArray.create = function (value0) { | |
| return new SArray(value0); | |
| }; | |
| return SArray; | |
| })(); | |
| // | A GenericSpine is a universal representation of an arbitrary data | |
| // | structure (that does not contain function arrows). | |
| var SUnit = (function () { | |
| function SUnit() { | |
| }; | |
| SUnit.value = new SUnit(); | |
| return SUnit; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigProd = (function () { | |
| function SigProd(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| SigProd.create = function (value0) { | |
| return function (value1) { | |
| return new SigProd(value0, value1); | |
| }; | |
| }; | |
| return SigProd; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigRecord = (function () { | |
| function SigRecord(value0) { | |
| this.value0 = value0; | |
| }; | |
| SigRecord.create = function (value0) { | |
| return new SigRecord(value0); | |
| }; | |
| return SigRecord; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigNumber = (function () { | |
| function SigNumber() { | |
| }; | |
| SigNumber.value = new SigNumber(); | |
| return SigNumber; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigBoolean = (function () { | |
| function SigBoolean() { | |
| }; | |
| SigBoolean.value = new SigBoolean(); | |
| return SigBoolean; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigInt = (function () { | |
| function SigInt() { | |
| }; | |
| SigInt.value = new SigInt(); | |
| return SigInt; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigString = (function () { | |
| function SigString() { | |
| }; | |
| SigString.value = new SigString(); | |
| return SigString; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigChar = (function () { | |
| function SigChar() { | |
| }; | |
| SigChar.value = new SigChar(); | |
| return SigChar; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigArray = (function () { | |
| function SigArray(value0) { | |
| this.value0 = value0; | |
| }; | |
| SigArray.create = function (value0) { | |
| return new SigArray(value0); | |
| }; | |
| return SigArray; | |
| })(); | |
| // | A GenericSignature is a universal representation of the structure of an | |
| // | arbitrary data structure (that does not contain function arrows). | |
| var SigUnit = (function () { | |
| function SigUnit() { | |
| }; | |
| SigUnit.value = new SigUnit(); | |
| return SigUnit; | |
| })(); | |
| // | The Generic typeclass provides methods for sending data to/from spine | |
| // | representations, as well as querying about the signatures of spine | |
| // | representations. | |
| // | | |
| // | For standard data structures, you can simply write | |
| // | `derive instance genericFoo :: Generic Foo` in the module they are | |
| // | declared, and the instance methods will be filled in for you. | |
| var Generic = function (fromSpine, toSignature, toSpine) { | |
| this.fromSpine = fromSpine; | |
| this.toSignature = toSignature; | |
| this.toSpine = toSpine; | |
| }; | |
| var toSpine = function (dict) { | |
| return dict.toSpine; | |
| }; | |
| var toSignature = function (dict) { | |
| return dict.toSignature; | |
| }; | |
| // | Shows a lazily evaluated value under a function with `Unit` parameter. | |
| var showSuspended = function (dictShow) { | |
| return function (e) { | |
| return "\\_ -> " + Data_Show.show(dictShow)(e(Data_Unit.unit)); | |
| }; | |
| }; | |
| // We use this instead of the default Show Array instance to avoid escaping | |
| // strings twice. | |
| var showArray = function (v) { | |
| return function (v1) { | |
| if (v1.length === 0) { | |
| return "[]"; | |
| }; | |
| return "[ " + (Data_Foldable.intercalate(Data_Foldable.foldableArray)(Data_Monoid.monoidString)(", ")(Data_Functor.map(Data_Functor.functorArray)(v)(v1)) + " ]"); | |
| }; | |
| }; | |
| var showGenericSpine = new Data_Show.Show(function (v) { | |
| if (v instanceof SUnit) { | |
| return "SUnit"; | |
| }; | |
| if (v instanceof SChar) { | |
| return "SChar " + Data_Show.show(Data_Show.showChar)(v.value0); | |
| }; | |
| if (v instanceof SString) { | |
| return "SString " + Data_Show.show(Data_Show.showString)(v.value0); | |
| }; | |
| if (v instanceof SBoolean) { | |
| return "SBoolean " + Data_Show.show(Data_Show.showBoolean)(v.value0); | |
| }; | |
| if (v instanceof SNumber) { | |
| return "SNumber " + Data_Show.show(Data_Show.showNumber)(v.value0); | |
| }; | |
| if (v instanceof SInt) { | |
| return "SInt " + Data_Show.show(Data_Show.showInt)(v.value0); | |
| }; | |
| if (v instanceof SArray) { | |
| return "SArray " + showArray(showSuspended(showGenericSpine))(v.value0); | |
| }; | |
| if (v instanceof SProd) { | |
| return "SProd " + (Data_Show.show(Data_Show.showString)(v.value0) + (" " + showArray(showSuspended(showGenericSpine))(v.value1))); | |
| }; | |
| if (v instanceof SRecord) { | |
| var showElt = function (v1) { | |
| return Data_Foldable.fold(Data_Foldable.foldableArray)(Data_Monoid.monoidString)([ "{ recLabel: ", Data_Show.show(Data_Show.showString)(v1.recLabel), ", recValue: ", showSuspended(showGenericSpine)(v1.recValue), " }" ]); | |
| }; | |
| return "SRecord " + showArray(showElt)(v.value0); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 270, column 1 - line 270, column 47: " + [ v.constructor.name ]); | |
| }); | |
| var orderingToInt = function (v) { | |
| if (v instanceof Data_Ordering.EQ) { | |
| return 0; | |
| }; | |
| if (v instanceof Data_Ordering.LT) { | |
| return 1; | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return -1 | 0; | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 538, column 17 - line 541, column 10: " + [ v.constructor.name ]); | |
| }; | |
| var genericVoid = new Generic(function (v) { | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return new SigProd("Data.Void.Void", [ ]); | |
| }, Data_Void.absurd); | |
| var genericUnit = new Generic(function (v) { | |
| if (v instanceof SUnit) { | |
| return new Data_Maybe.Just(Data_Unit.unit); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return SigUnit.value; | |
| }, function (v) { | |
| return SUnit.value; | |
| }); | |
| var genericString = new Generic(function (v) { | |
| if (v instanceof SString) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return SigString.value; | |
| }, SString.create); | |
| var genericOrdering = new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.Ordering.LT" && v.value1.length === 0)) { | |
| return new Data_Maybe.Just(Data_Ordering.LT.value); | |
| }; | |
| if (v instanceof SProd && (v.value0 === "Data.Ordering.EQ" && v.value1.length === 0)) { | |
| return new Data_Maybe.Just(Data_Ordering.EQ.value); | |
| }; | |
| if (v instanceof SProd && (v.value0 === "Data.Ordering.GT" && v.value1.length === 0)) { | |
| return new Data_Maybe.Just(Data_Ordering.GT.value); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return new SigProd("Data.Ordering.Ordering", [ { | |
| sigConstructor: "Data.Ordering.LT", | |
| sigValues: [ ] | |
| }, { | |
| sigConstructor: "Data.Ordering.EQ", | |
| sigValues: [ ] | |
| }, { | |
| sigConstructor: "Data.Ordering.GT", | |
| sigValues: [ ] | |
| } ]); | |
| }, function (v) { | |
| if (v instanceof Data_Ordering.LT) { | |
| return new SProd("Data.Ordering.LT", [ ]); | |
| }; | |
| if (v instanceof Data_Ordering.EQ) { | |
| return new SProd("Data.Ordering.EQ", [ ]); | |
| }; | |
| if (v instanceof Data_Ordering.GT) { | |
| return new SProd("Data.Ordering.GT", [ ]); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 218, column 13 - line 221, column 38: " + [ v.constructor.name ]); | |
| }); | |
| var genericNumber = new Generic(function (v) { | |
| if (v instanceof SNumber) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return SigNumber.value; | |
| }, SNumber.create); | |
| var genericInt = new Generic(function (v) { | |
| if (v instanceof SInt) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return SigInt.value; | |
| }, SInt.create); | |
| var genericChar = new Generic(function (v) { | |
| if (v instanceof SChar) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return SigChar.value; | |
| }, SChar.create); | |
| var genericBool = new Generic(function (v) { | |
| if (v instanceof SBoolean) { | |
| return new Data_Maybe.Just(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (v) { | |
| return SigBoolean.value; | |
| }, SBoolean.create); | |
| var fromSpine = function (dict) { | |
| return dict.fromSpine; | |
| }; | |
| var force = function (f) { | |
| return f(Data_Unit.unit); | |
| }; | |
| var genericArray = function (dictGeneric) { | |
| return new Generic(function (v) { | |
| if (v instanceof SArray) { | |
| return Data_Traversable.traverse(Data_Traversable.traversableArray)(Data_Maybe.applicativeMaybe)(function ($310) { | |
| return fromSpine(dictGeneric)(force($310)); | |
| })(v.value0); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var lowerProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigArray(function (v) { | |
| return toSignature(dictGeneric)(lowerProxy(x)); | |
| }); | |
| }, function ($311) { | |
| return SArray.create(Data_Functor.map(Data_Functor.functorArray)(function (x) { | |
| return function (v) { | |
| return toSpine(dictGeneric)(x); | |
| }; | |
| })($311)); | |
| }); | |
| }; | |
| var genericEither = function (dictGeneric) { | |
| return function (dictGeneric1) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.Either.Left" && v.value1.length === 1)) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(Data_Either.Left.create)(fromSpine(dictGeneric)(force(v["value1"][0]))); | |
| }; | |
| if (v instanceof SProd && (v.value0 === "Data.Either.Right" && v.value1.length === 1)) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(Data_Either.Right.create)(fromSpine(dictGeneric1)(force(v["value1"][0]))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var rproxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| var lproxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.Either.Either", [ { | |
| sigConstructor: "Data.Either.Left", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric)(lproxy(x)); | |
| } ] | |
| }, { | |
| sigConstructor: "Data.Either.Right", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric1)(rproxy(x)); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| if (v instanceof Data_Either.Left) { | |
| return new SProd("Data.Either.Left", [ function (v1) { | |
| return toSpine(dictGeneric)(v.value0); | |
| } ]); | |
| }; | |
| if (v instanceof Data_Either.Right) { | |
| return new SProd("Data.Either.Right", [ function (v1) { | |
| return toSpine(dictGeneric1)(v.value0); | |
| } ]); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 180, column 1 - line 180, column 73: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| }; | |
| var genericIdentity = function (dictGeneric) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.Identity.Identity" && v.value1.length === 1)) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(Data_Identity.Identity)(fromSpine(dictGeneric)(force(v["value1"][0]))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var iproxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.Identity.Identity", [ { | |
| sigConstructor: "Data.Identity.Identity", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric)(iproxy(x)); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new SProd("Data.Identity.Identity", [ function (v1) { | |
| return toSpine(dictGeneric)(v); | |
| } ]); | |
| }); | |
| }; | |
| var genericList = function (dictGeneric) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.List.Types.Cons" && v.value1.length === 2)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_List_Types.Cons.create)(fromSpine(dictGeneric)(force(v["value1"][0]))))(fromSpine(genericList(dictGeneric))(force(v["value1"][1]))); | |
| }; | |
| if (v instanceof SProd && (v.value0 === "Data.List.Types.Nil" && v.value1.length === 0)) { | |
| return Control_Applicative.pure(Data_Maybe.applicativeMaybe)(Data_List_Types.Nil.value); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var headProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.List.Types.List", [ { | |
| sigConstructor: "Data.List.Types.Cons", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric)(headProxy(x)); | |
| }, function (v) { | |
| return toSignature(genericList(dictGeneric))(x); | |
| } ] | |
| }, { | |
| sigConstructor: "Data.List.Types.Nil", | |
| sigValues: [ ] | |
| } ]); | |
| }, function (v) { | |
| if (v instanceof Data_List_Types.Cons) { | |
| return new SProd("Data.List.Types.Cons", [ function (v1) { | |
| return toSpine(dictGeneric)(v.value0); | |
| }, function (v1) { | |
| return toSpine(genericList(dictGeneric))(v.value1); | |
| } ]); | |
| }; | |
| if (v instanceof Data_List_Types.Nil) { | |
| return new SProd("Data.List.Types.Nil", [ ]); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 116, column 1 - line 116, column 58: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| var genericMaybe = function (dictGeneric) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.Maybe.Just" && v.value1.length === 1)) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(Data_Maybe.Just.create)(fromSpine(dictGeneric)(force(v["value1"][0]))); | |
| }; | |
| if (v instanceof SProd && (v.value0 === "Data.Maybe.Nothing" && v.value1.length === 0)) { | |
| return Control_Applicative.pure(Data_Maybe.applicativeMaybe)(Data_Maybe.Nothing.value); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var mbProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.Maybe.Maybe", [ { | |
| sigConstructor: "Data.Maybe.Just", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric)(mbProxy(x)); | |
| } ] | |
| }, { | |
| sigConstructor: "Data.Maybe.Nothing", | |
| sigValues: [ ] | |
| } ]); | |
| }, function (v) { | |
| if (v instanceof Data_Maybe.Just) { | |
| return new SProd("Data.Maybe.Just", [ function (v1) { | |
| return toSpine(dictGeneric)(v.value0); | |
| } ]); | |
| }; | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return new SProd("Data.Maybe.Nothing", [ ]); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 160, column 1 - line 160, column 56: " + [ v.constructor.name ]); | |
| }); | |
| }; | |
| var genericNonEmpty = function (dictGeneric) { | |
| return function (dictGeneric1) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.NonEmpty.NonEmpty" && v.value1.length === 2)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_NonEmpty.NonEmpty.create)(fromSpine(dictGeneric1)(force(v["value1"][0]))))(fromSpine(dictGeneric)(force(v["value1"][1]))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var tailProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| var headProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.NonEmpty.NonEmpty", [ { | |
| sigConstructor: "Data.NonEmpty.NonEmpty", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric1)(headProxy(x)); | |
| }, function (v) { | |
| return toSignature(dictGeneric)(tailProxy(x)); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new SProd("Data.NonEmpty.NonEmpty", [ function (v1) { | |
| return toSpine(dictGeneric1)(v.value0); | |
| }, function (v1) { | |
| return toSpine(dictGeneric)(v.value1); | |
| } ]); | |
| }); | |
| }; | |
| }; | |
| var genericNonEmptyList = function (dictGeneric) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.List.Types.NonEmptyList" && v.value1.length === 1)) { | |
| return Data_Functor.map(Data_Maybe.functorMaybe)(Data_List_Types.NonEmptyList)(fromSpine(genericNonEmpty(genericList(dictGeneric))(dictGeneric))(force(v["value1"][0]))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var listProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.List.Types.NonEmptyList", [ { | |
| sigConstructor: "Data.List.Types.NonEmptyList", | |
| sigValues: [ function (v) { | |
| return toSignature(genericList(dictGeneric))(listProxy(x)); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new SProd("Data.List.Types.NonEmptyList", [ function (v1) { | |
| return toSpine(genericNonEmpty(genericList(dictGeneric))(dictGeneric))(v); | |
| } ]); | |
| }); | |
| }; | |
| var genericShowPrec = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof SProd) { | |
| if (Data_Array["null"](v1.value1)) { | |
| return v1.value0; | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| var showParen = function (v2) { | |
| return function (x) { | |
| if (!v2) { | |
| return x; | |
| }; | |
| if (v2) { | |
| return "(" + (x + ")"); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 467, column 7 - line 467, column 28: " + [ v2.constructor.name, x.constructor.name ]); | |
| }; | |
| }; | |
| return showParen(v > 10)(v1.value0 + (" " + Data_String.joinWith(" ")(Data_Functor.map(Data_Functor.functorArray)(function (x) { | |
| return genericShowPrec(11)(force(x)); | |
| })(v1.value1)))); | |
| }; | |
| }; | |
| if (v1 instanceof SRecord) { | |
| var showLabelPart = function (x) { | |
| return x.recLabel + (": " + genericShowPrec(0)(force(x.recValue))); | |
| }; | |
| return "{" + (Data_String.joinWith(", ")(Data_Functor.map(Data_Functor.functorArray)(showLabelPart)(v1.value0)) + "}"); | |
| }; | |
| if (v1 instanceof SBoolean) { | |
| return Data_Show.show(Data_Show.showBoolean)(v1.value0); | |
| }; | |
| if (v1 instanceof SInt) { | |
| return Data_Show.show(Data_Show.showInt)(v1.value0); | |
| }; | |
| if (v1 instanceof SNumber) { | |
| return Data_Show.show(Data_Show.showNumber)(v1.value0); | |
| }; | |
| if (v1 instanceof SString) { | |
| return Data_Show.show(Data_Show.showString)(v1.value0); | |
| }; | |
| if (v1 instanceof SChar) { | |
| return Data_Show.show(Data_Show.showChar)(v1.value0); | |
| }; | |
| if (v1 instanceof SArray) { | |
| return "[" + (Data_String.joinWith(", ")(Data_Functor.map(Data_Functor.functorArray)(function (x) { | |
| return genericShowPrec(0)(force(x)); | |
| })(v1.value0)) + "]"); | |
| }; | |
| if (v1 instanceof SUnit) { | |
| return "unit"; | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 460, column 1 - line 460, column 49: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| // ## Generic Functions | |
| // | This function can be used as the default instance for Show for any | |
| // | instance of Generic | |
| var gShow = function (dictGeneric) { | |
| return function ($312) { | |
| return genericShowPrec(0)(toSpine(dictGeneric)($312)); | |
| }; | |
| }; | |
| var genericTuple = function (dictGeneric) { | |
| return function (dictGeneric1) { | |
| return new Generic(function (v) { | |
| if (v instanceof SProd && (v.value0 === "Data.Tuple.Tuple" && v.value1.length === 2)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Tuple.Tuple.create)(fromSpine(dictGeneric)(force(v["value1"][0]))))(fromSpine(dictGeneric1)(force(v["value1"][1]))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function (x) { | |
| var sndProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| var fstProxy = function (v) { | |
| return Type_Proxy["Proxy"].value; | |
| }; | |
| return new SigProd("Data.Tuple.Tuple", [ { | |
| sigConstructor: "Data.Tuple.Tuple", | |
| sigValues: [ function (v) { | |
| return toSignature(dictGeneric)(fstProxy(x)); | |
| }, function (v) { | |
| return toSignature(dictGeneric1)(sndProxy(x)); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new SProd("Data.Tuple.Tuple", [ function (v1) { | |
| return toSpine(dictGeneric)(v.value0); | |
| }, function (v1) { | |
| return toSpine(dictGeneric1)(v.value1); | |
| } ]); | |
| }); | |
| }; | |
| }; | |
| // | Checks that the spine follows the structure defined by the signature | |
| var isValidSpine = function (v) { | |
| return function (v1) { | |
| if (v instanceof SigBoolean && v1 instanceof SBoolean) { | |
| return true; | |
| }; | |
| if (v instanceof SigNumber && v1 instanceof SNumber) { | |
| return true; | |
| }; | |
| if (v instanceof SigInt && v1 instanceof SInt) { | |
| return true; | |
| }; | |
| if (v instanceof SigString && v1 instanceof SString) { | |
| return true; | |
| }; | |
| if (v instanceof SigChar && v1 instanceof SChar) { | |
| return true; | |
| }; | |
| if (v instanceof SigArray && v1 instanceof SArray) { | |
| return Data_Foldable.all(Data_Foldable.foldableArray)(Data_HeytingAlgebra.heytingAlgebraBoolean)(function ($313) { | |
| return isValidSpine(force(v.value0))(force($313)); | |
| })(v1.value0); | |
| }; | |
| if (v instanceof SigProd && v1 instanceof SProd) { | |
| var v2 = Data_Foldable.find(Data_Foldable.foldableArray)(function (alt) { | |
| return alt.sigConstructor === v1.value0; | |
| })(v.value1); | |
| if (v2 instanceof Data_Maybe.Nothing) { | |
| return false; | |
| }; | |
| if (v2 instanceof Data_Maybe.Just) { | |
| return Data_Foldable.and(Data_Foldable.foldableArray)(Data_HeytingAlgebra.heytingAlgebraBoolean)(Data_Array.zipWith(function (sig) { | |
| return function (spine) { | |
| return isValidSpine(force(sig))(force(spine)); | |
| }; | |
| })(v2.value0.sigValues)(v1.value1)); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 438, column 3 - line 444, column 15: " + [ v2.constructor.name ]); | |
| }; | |
| if (v instanceof SigRecord && v1 instanceof SRecord) { | |
| return Data_Foldable.and(Data_Foldable.foldableArray)(Data_HeytingAlgebra.heytingAlgebraBoolean)(Data_Array.zipWith(function (sig) { | |
| return function (val) { | |
| return isValidSpine(force(sig.recValue))(force(val.recValue)); | |
| }; | |
| })(Data_Array.sortBy(function (a) { | |
| return function (b) { | |
| return Data_Ord.compare(Data_Ord.ordString)(a.recLabel)(b.recLabel); | |
| }; | |
| })(v.value0))(Data_Array.sortBy(function (a) { | |
| return function (b) { | |
| return Data_Ord.compare(Data_Ord.ordString)(a.recLabel)(b.recLabel); | |
| }; | |
| })(v1.value0))); | |
| }; | |
| if (v instanceof SigUnit && v1 instanceof SUnit) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| }; | |
| var showSignature = function (sig) { | |
| var needsParen = function (s) { | |
| if (s instanceof SigProd) { | |
| return true; | |
| }; | |
| if (s instanceof SigRecord) { | |
| return true; | |
| }; | |
| if (s instanceof SigNumber) { | |
| return false; | |
| }; | |
| if (s instanceof SigBoolean) { | |
| return false; | |
| }; | |
| if (s instanceof SigInt) { | |
| return false; | |
| }; | |
| if (s instanceof SigString) { | |
| return false; | |
| }; | |
| if (s instanceof SigChar) { | |
| return false; | |
| }; | |
| if (s instanceof SigArray) { | |
| return true; | |
| }; | |
| if (s instanceof SigUnit) { | |
| return false; | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 403, column 18 - line 412, column 21: " + [ s.constructor.name ]); | |
| }; | |
| var paren = function (s) { | |
| if (needsParen(s)) { | |
| return "(" + (showSignature(s) + ")"); | |
| }; | |
| if (Data_Boolean.otherwise) { | |
| return showSignature(s); | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 399, column 3 - line 401, column 34: " + [ s.constructor.name ]); | |
| }; | |
| return Data_Foldable.fold(Data_Foldable.foldableArray)(Data_Monoid.monoidString)((function () { | |
| if (sig instanceof SigProd) { | |
| return [ "SigProd ", Data_Show.show(Data_Show.showString)(sig.value0), " ", showArray(showDataConstructor)(sig.value1) ]; | |
| }; | |
| if (sig instanceof SigRecord) { | |
| return [ "SigRecord ", showArray(showLabel)(sig.value0) ]; | |
| }; | |
| if (sig instanceof SigNumber) { | |
| return [ "SigNumber" ]; | |
| }; | |
| if (sig instanceof SigBoolean) { | |
| return [ "SigBoolean" ]; | |
| }; | |
| if (sig instanceof SigInt) { | |
| return [ "SigInt" ]; | |
| }; | |
| if (sig instanceof SigString) { | |
| return [ "SigString" ]; | |
| }; | |
| if (sig instanceof SigChar) { | |
| return [ "SigChar" ]; | |
| }; | |
| if (sig instanceof SigArray) { | |
| return [ "SigArray ", paren(force(sig.value0)) ]; | |
| }; | |
| if (sig instanceof SigUnit) { | |
| return [ "SigUnit" ]; | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 386, column 10 - line 396, column 27: " + [ sig.constructor.name ]); | |
| })()); | |
| }; | |
| var showLabel = function (l) { | |
| return "{ recLabel: " + (Data_Show.show(Data_Show.showString)(l.recLabel) + (", recValue: " + (showSignature(force(l.recValue)) + " }"))); | |
| }; | |
| var showDataConstructor = function (dc) { | |
| return "{ sigConstructor: " + (Data_Show.show(Data_Show.showString)(dc.sigConstructor) + (", sigValues: " + (showArray(function ($314) { | |
| return showSignature(force($314)); | |
| })(dc.sigValues) + " }"))); | |
| }; | |
| var showGenericSignature = new Data_Show.Show(showSignature); | |
| var eqThunk = function (dictEq) { | |
| return function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(dictEq)(force(x))(force(y)); | |
| }; | |
| }; | |
| }; | |
| var eqRecordSigs = function (dictEq) { | |
| return function (arr1) { | |
| return function (arr2) { | |
| var labelCompare = function (r1) { | |
| return function (r2) { | |
| return Data_Ord.compare(Data_Ord.ordString)(r1.recLabel)(r2.recLabel); | |
| }; | |
| }; | |
| var sorted1 = Data_Array.sortBy(labelCompare)(arr1); | |
| var sorted2 = Data_Array.sortBy(labelCompare)(arr2); | |
| var doCmp = function (x) { | |
| return function (y) { | |
| return x.recLabel === y.recLabel && Data_Eq.eq(dictEq)(force(x.recValue))(force(y.recValue)); | |
| }; | |
| }; | |
| return Data_Array.length(arr1) === Data_Array.length(arr2) && $foreign.zipAll(doCmp)(sorted1)(sorted2); | |
| }; | |
| }; | |
| }; | |
| var eqGenericSpine = new Data_Eq.Eq(function (v) { | |
| return function (v1) { | |
| if (v instanceof SProd && v1 instanceof SProd) { | |
| return v.value0 === v1.value0 && (Data_Array.length(v.value1) === Data_Array.length(v1.value1) && $foreign.zipAll(eqThunk(eqGenericSpine))(v.value1)(v1.value1)); | |
| }; | |
| if (v instanceof SRecord && v1 instanceof SRecord) { | |
| return eqRecordSigs(eqGenericSpine)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SNumber && v1 instanceof SNumber) { | |
| return v.value0 === v1.value0; | |
| }; | |
| if (v instanceof SBoolean && v1 instanceof SBoolean) { | |
| return v.value0 === v1.value0; | |
| }; | |
| if (v instanceof SInt && v1 instanceof SInt) { | |
| return v.value0 === v1.value0; | |
| }; | |
| if (v instanceof SString && v1 instanceof SString) { | |
| return v.value0 === v1.value0; | |
| }; | |
| if (v instanceof SChar && v1 instanceof SChar) { | |
| return v.value0 === v1.value0; | |
| }; | |
| if (v instanceof SArray && v1 instanceof SArray) { | |
| return Data_Array.length(v.value0) === Data_Array.length(v1.value0) && $foreign.zipAll(eqThunk(eqGenericSpine))(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SUnit && v1 instanceof SUnit) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| }); | |
| // | This function can be used as an implementation of the `eq` function of `Eq` | |
| // | for any type with a `Generic` instance. | |
| // | | |
| // | **Note**: It is preferrable to use `derive instance` for `Eq` instances | |
| // | rather than relying on `gEq`, where possible. | |
| var gEq = function (dictGeneric) { | |
| return function (x) { | |
| return function (y) { | |
| return Data_Eq.eq(eqGenericSpine)(toSpine(dictGeneric)(x))(toSpine(dictGeneric)(y)); | |
| }; | |
| }; | |
| }; | |
| var eqGenericSignature = new Data_Eq.Eq(function (v) { | |
| return function (v1) { | |
| if (v instanceof SigProd && v1 instanceof SigProd) { | |
| return v.value0 === v1.value0 && (Data_Array.length(v.value1) === Data_Array.length(v1.value1) && $foreign.zipAll(eqDataConstructor)(v.value1)(v1.value1)); | |
| }; | |
| if (v instanceof SigRecord && v1 instanceof SigRecord) { | |
| return eqRecordSigs(eqGenericSignature)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SigNumber && v1 instanceof SigNumber) { | |
| return true; | |
| }; | |
| if (v instanceof SigBoolean && v1 instanceof SigBoolean) { | |
| return true; | |
| }; | |
| if (v instanceof SigInt && v1 instanceof SigInt) { | |
| return true; | |
| }; | |
| if (v instanceof SigString && v1 instanceof SigString) { | |
| return true; | |
| }; | |
| if (v instanceof SigChar && v1 instanceof SigChar) { | |
| return true; | |
| }; | |
| if (v instanceof SigArray && v1 instanceof SigArray) { | |
| return eqThunk(eqGenericSignature)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SigUnit && v1 instanceof SigUnit) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| }); | |
| var eqDataConstructor = function (p1) { | |
| return function (p2) { | |
| return p1.sigConstructor === p2.sigConstructor && $foreign.zipAll(eqThunk(eqGenericSignature))(p1.sigValues)(p2.sigValues); | |
| }; | |
| }; | |
| var compareThunk = function (dictOrd) { | |
| return function (x) { | |
| return function (y) { | |
| return orderingToInt(Data_Ord.compare(dictOrd)(force(x))(force(y))); | |
| }; | |
| }; | |
| }; | |
| var ordGenericSpine = new Data_Ord.Ord(function () { | |
| return eqGenericSpine; | |
| }, function (v) { | |
| return function (v1) { | |
| if (v instanceof SProd && v1 instanceof SProd) { | |
| var v2 = Data_Ord.compare(Data_Ord.ordString)(v.value0)(v1.value0); | |
| if (v2 instanceof Data_Ordering.EQ) { | |
| return Data_Ord.compare(Data_Ord.ordInt)(0)($foreign.zipCompare(compareThunk(ordGenericSpine))(v.value1)(v1.value1)); | |
| }; | |
| return v2; | |
| }; | |
| if (v instanceof SProd) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SProd) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SRecord && v1 instanceof SRecord) { | |
| var go = function (x) { | |
| return function (y) { | |
| var v2 = Data_Ord.compare(Data_Ord.ordString)(x.recLabel)(y.recLabel); | |
| if (v2 instanceof Data_Ordering.EQ) { | |
| return orderingToInt(Data_Ord.compare(ordGenericSpine)(force(x.recValue))(force(y.recValue))); | |
| }; | |
| return orderingToInt(v2); | |
| }; | |
| }; | |
| return Data_Ord.compare(Data_Ord.ordInt)(0)($foreign.zipCompare(go)(v.value0)(v1.value0)); | |
| }; | |
| if (v instanceof SRecord) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SRecord) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SInt && v1 instanceof SInt) { | |
| return Data_Ord.compare(Data_Ord.ordInt)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SInt) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SInt) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SBoolean && v1 instanceof SBoolean) { | |
| return Data_Ord.compare(Data_Ord.ordBoolean)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SBoolean) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SBoolean) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SNumber && v1 instanceof SNumber) { | |
| return Data_Ord.compare(Data_Ord.ordNumber)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SNumber) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SNumber) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SString && v1 instanceof SString) { | |
| return Data_Ord.compare(Data_Ord.ordString)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SString) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SString) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SChar && v1 instanceof SChar) { | |
| return Data_Ord.compare(Data_Ord.ordChar)(v.value0)(v1.value0); | |
| }; | |
| if (v instanceof SChar) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SChar) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SArray && v1 instanceof SArray) { | |
| return Data_Ord.compare(Data_Ord.ordInt)(0)($foreign.zipCompare(compareThunk(ordGenericSpine))(v.value0)(v1.value0)); | |
| }; | |
| if (v instanceof SArray) { | |
| return Data_Ordering.LT.value; | |
| }; | |
| if (v1 instanceof SArray) { | |
| return Data_Ordering.GT.value; | |
| }; | |
| if (v instanceof SUnit && v1 instanceof SUnit) { | |
| return Data_Ordering.EQ.value; | |
| }; | |
| throw new Error("Failed pattern match at Data.Generic line 303, column 1 - line 303, column 45: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }); | |
| // | This function can be used as an implementation of the `compare` function | |
| // | of `Ord` for any type with a `Generic` instance. | |
| // | | |
| // | **Note**: It is preferrable to use `derive instance` for `Ord` instances | |
| // | rather than relying on `gCompare`, where possible. | |
| var gCompare = function (dictGeneric) { | |
| return function (x) { | |
| return function (y) { | |
| return Data_Ord.compare(ordGenericSpine)(toSpine(dictGeneric)(x))(toSpine(dictGeneric)(y)); | |
| }; | |
| }; | |
| }; | |
| exports["SigProd"] = SigProd; | |
| exports["SigRecord"] = SigRecord; | |
| exports["SigNumber"] = SigNumber; | |
| exports["SigBoolean"] = SigBoolean; | |
| exports["SigInt"] = SigInt; | |
| exports["SigString"] = SigString; | |
| exports["SigChar"] = SigChar; | |
| exports["SigArray"] = SigArray; | |
| exports["SigUnit"] = SigUnit; | |
| exports["SProd"] = SProd; | |
| exports["SRecord"] = SRecord; | |
| exports["SNumber"] = SNumber; | |
| exports["SBoolean"] = SBoolean; | |
| exports["SInt"] = SInt; | |
| exports["SString"] = SString; | |
| exports["SChar"] = SChar; | |
| exports["SArray"] = SArray; | |
| exports["SUnit"] = SUnit; | |
| exports["Generic"] = Generic; | |
| exports["fromSpine"] = fromSpine; | |
| exports["gCompare"] = gCompare; | |
| exports["gEq"] = gEq; | |
| exports["gShow"] = gShow; | |
| exports["isValidSpine"] = isValidSpine; | |
| exports["showDataConstructor"] = showDataConstructor; | |
| exports["showSignature"] = showSignature; | |
| exports["toSignature"] = toSignature; | |
| exports["toSpine"] = toSpine; | |
| exports["genericNumber"] = genericNumber; | |
| exports["genericInt"] = genericInt; | |
| exports["genericString"] = genericString; | |
| exports["genericChar"] = genericChar; | |
| exports["genericBool"] = genericBool; | |
| exports["genericArray"] = genericArray; | |
| exports["genericUnit"] = genericUnit; | |
| exports["genericVoid"] = genericVoid; | |
| exports["genericTuple"] = genericTuple; | |
| exports["genericList"] = genericList; | |
| exports["genericNonEmptyList"] = genericNonEmptyList; | |
| exports["genericMaybe"] = genericMaybe; | |
| exports["genericEither"] = genericEither; | |
| exports["genericIdentity"] = genericIdentity; | |
| exports["genericOrdering"] = genericOrdering; | |
| exports["genericNonEmpty"] = genericNonEmpty; | |
| exports["showGenericSpine"] = showGenericSpine; | |
| exports["eqGenericSpine"] = eqGenericSpine; | |
| exports["ordGenericSpine"] = ordGenericSpine; | |
| exports["eqGenericSignature"] = eqGenericSignature; | |
| exports["showGenericSignature"] = showGenericSignature; | |
| })(PS["Data.Generic"] = PS["Data.Generic"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_EuclideanRing = PS["Data.EuclideanRing"]; | |
| var Data_Generic = PS["Data.Generic"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ord = PS["Data.Ord"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | A duration measured in seconds. | |
| var Seconds = function (x) { | |
| return x; | |
| }; | |
| // | A duration measured in minutes. | |
| var Minutes = function (x) { | |
| return x; | |
| }; | |
| // | A duration measured in milliseconds. | |
| var Milliseconds = function (x) { | |
| return x; | |
| }; | |
| // | A duration measured in hours. | |
| var Hours = function (x) { | |
| return x; | |
| }; | |
| // | A duration measured in days, where a day is assumed to be exactly 24 hours. | |
| var Days = function (x) { | |
| return x; | |
| }; | |
| // | A class for enabling conversions between duration types. | |
| var Duration = function (fromDuration, toDuration) { | |
| this.fromDuration = fromDuration; | |
| this.toDuration = toDuration; | |
| }; | |
| var toDuration = function (dict) { | |
| return dict.toDuration; | |
| }; | |
| var showSeconds = new Data_Show.Show(function (v) { | |
| return "(Seconds " + (Data_Show.show(Data_Show.showNumber)(v) + ")"); | |
| }); | |
| var showMinutes = new Data_Show.Show(function (v) { | |
| return "(Minutes " + (Data_Show.show(Data_Show.showNumber)(v) + ")"); | |
| }); | |
| var showMilliseconds = new Data_Show.Show(function (v) { | |
| return "(Milliseconds " + (Data_Show.show(Data_Show.showNumber)(v) + ")"); | |
| }); | |
| var showHours = new Data_Show.Show(function (v) { | |
| return "(Hours " + (Data_Show.show(Data_Show.showNumber)(v) + ")"); | |
| }); | |
| var showDays = new Data_Show.Show(function (v) { | |
| return "(Days " + (Data_Show.show(Data_Show.showNumber)(v) + ")"); | |
| }); | |
| var semiringSeconds = Data_Semiring.semiringNumber; | |
| var semiringMinutes = Data_Semiring.semiringNumber; | |
| var semiringMilliseconds = Data_Semiring.semiringNumber; | |
| var semiringHours = Data_Semiring.semiringNumber; | |
| var semiringDays = Data_Semiring.semiringNumber; | |
| var ringSeconds = Data_Ring.ringNumber; | |
| var ringMinutes = Data_Ring.ringNumber; | |
| var ringMilliseconds = Data_Ring.ringNumber; | |
| var ringHours = Data_Ring.ringNumber; | |
| var ringDays = Data_Ring.ringNumber; | |
| var ordSeconds = Data_Ord.ordNumber; | |
| var ordMinutes = Data_Ord.ordNumber; | |
| var ordMilliseconds = Data_Ord.ordNumber; | |
| var ordHours = Data_Ord.ordNumber; | |
| var ordDays = Data_Ord.ordNumber; | |
| var newtypeSeconds = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Seconds); | |
| var newtypeMinutes = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Minutes); | |
| var newtypeMilliseconds = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Milliseconds); | |
| var newtypeHours = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Hours); | |
| var newtypeDays = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Days); | |
| var genericSeconds = new Data_Generic.Generic(function (v) { | |
| if (v instanceof Data_Generic.SProd && (v.value0 === "Data.Time.Duration.Seconds" && v.value1.length === 1)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(new Data_Maybe.Just(Seconds))(Data_Generic.fromSpine(Data_Generic.genericNumber)(v["value1"][0](Data_Unit.unit))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function ($dollarq) { | |
| return new Data_Generic.SigProd("Data.Time.Duration.Seconds", [ { | |
| sigConstructor: "Data.Time.Duration.Seconds", | |
| sigValues: [ function ($dollarq1) { | |
| return Data_Generic.toSignature(Data_Generic.genericNumber)(Data_Generic.anyProxy); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new Data_Generic.SProd("Data.Time.Duration.Seconds", [ function ($dollarq) { | |
| return Data_Generic.toSpine(Data_Generic.genericNumber)(v); | |
| } ]); | |
| }); | |
| var genericMinutes = new Data_Generic.Generic(function (v) { | |
| if (v instanceof Data_Generic.SProd && (v.value0 === "Data.Time.Duration.Minutes" && v.value1.length === 1)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(new Data_Maybe.Just(Minutes))(Data_Generic.fromSpine(Data_Generic.genericNumber)(v["value1"][0](Data_Unit.unit))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function ($dollarq) { | |
| return new Data_Generic.SigProd("Data.Time.Duration.Minutes", [ { | |
| sigConstructor: "Data.Time.Duration.Minutes", | |
| sigValues: [ function ($dollarq1) { | |
| return Data_Generic.toSignature(Data_Generic.genericNumber)(Data_Generic.anyProxy); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new Data_Generic.SProd("Data.Time.Duration.Minutes", [ function ($dollarq) { | |
| return Data_Generic.toSpine(Data_Generic.genericNumber)(v); | |
| } ]); | |
| }); | |
| var genericMilliseconds = new Data_Generic.Generic(function (v) { | |
| if (v instanceof Data_Generic.SProd && (v.value0 === "Data.Time.Duration.Milliseconds" && v.value1.length === 1)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(new Data_Maybe.Just(Milliseconds))(Data_Generic.fromSpine(Data_Generic.genericNumber)(v["value1"][0](Data_Unit.unit))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function ($dollarq) { | |
| return new Data_Generic.SigProd("Data.Time.Duration.Milliseconds", [ { | |
| sigConstructor: "Data.Time.Duration.Milliseconds", | |
| sigValues: [ function ($dollarq1) { | |
| return Data_Generic.toSignature(Data_Generic.genericNumber)(Data_Generic.anyProxy); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new Data_Generic.SProd("Data.Time.Duration.Milliseconds", [ function ($dollarq) { | |
| return Data_Generic.toSpine(Data_Generic.genericNumber)(v); | |
| } ]); | |
| }); | |
| var genericHours = new Data_Generic.Generic(function (v) { | |
| if (v instanceof Data_Generic.SProd && (v.value0 === "Data.Time.Duration.Hours" && v.value1.length === 1)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(new Data_Maybe.Just(Hours))(Data_Generic.fromSpine(Data_Generic.genericNumber)(v["value1"][0](Data_Unit.unit))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function ($dollarq) { | |
| return new Data_Generic.SigProd("Data.Time.Duration.Hours", [ { | |
| sigConstructor: "Data.Time.Duration.Hours", | |
| sigValues: [ function ($dollarq1) { | |
| return Data_Generic.toSignature(Data_Generic.genericNumber)(Data_Generic.anyProxy); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new Data_Generic.SProd("Data.Time.Duration.Hours", [ function ($dollarq) { | |
| return Data_Generic.toSpine(Data_Generic.genericNumber)(v); | |
| } ]); | |
| }); | |
| var genericDays = new Data_Generic.Generic(function (v) { | |
| if (v instanceof Data_Generic.SProd && (v.value0 === "Data.Time.Duration.Days" && v.value1.length === 1)) { | |
| return Control_Apply.apply(Data_Maybe.applyMaybe)(new Data_Maybe.Just(Days))(Data_Generic.fromSpine(Data_Generic.genericNumber)(v["value1"][0](Data_Unit.unit))); | |
| }; | |
| return Data_Maybe.Nothing.value; | |
| }, function ($dollarq) { | |
| return new Data_Generic.SigProd("Data.Time.Duration.Days", [ { | |
| sigConstructor: "Data.Time.Duration.Days", | |
| sigValues: [ function ($dollarq1) { | |
| return Data_Generic.toSignature(Data_Generic.genericNumber)(Data_Generic.anyProxy); | |
| } ] | |
| } ]); | |
| }, function (v) { | |
| return new Data_Generic.SProd("Data.Time.Duration.Days", [ function ($dollarq) { | |
| return Data_Generic.toSpine(Data_Generic.genericNumber)(v); | |
| } ]); | |
| }); | |
| var fromDuration = function (dict) { | |
| return dict.fromDuration; | |
| }; | |
| var eqSeconds = Data_Eq.eqNumber; | |
| var eqMinutes = Data_Eq.eqNumber; | |
| var eqMilliseconds = Data_Eq.eqNumber; | |
| var eqHours = Data_Eq.eqNumber; | |
| var eqDays = Data_Eq.eqNumber; | |
| var durationSeconds = new Duration(Data_Newtype.over(newtypeSeconds)(newtypeMilliseconds)(Seconds)(function (v) { | |
| return v * 1000.0; | |
| }), Data_Newtype.over(newtypeMilliseconds)(newtypeSeconds)(Milliseconds)(function (v) { | |
| return v / 1000.0; | |
| })); | |
| var durationMinutes = new Duration(Data_Newtype.over(newtypeMinutes)(newtypeMilliseconds)(Minutes)(function (v) { | |
| return v * 60000.0; | |
| }), Data_Newtype.over(newtypeMilliseconds)(newtypeMinutes)(Milliseconds)(function (v) { | |
| return v / 60000.0; | |
| })); | |
| var durationMilliseconds = new Duration(Control_Category.id(Control_Category.categoryFn), Control_Category.id(Control_Category.categoryFn)); | |
| var durationHours = new Duration(Data_Newtype.over(newtypeHours)(newtypeMilliseconds)(Hours)(function (v) { | |
| return v * 3600000.0; | |
| }), Data_Newtype.over(newtypeMilliseconds)(newtypeHours)(Milliseconds)(function (v) { | |
| return v / 3600000.0; | |
| })); | |
| var durationDays = new Duration(Data_Newtype.over(newtypeDays)(newtypeMilliseconds)(Days)(function (v) { | |
| return v * 8.64e7; | |
| }), Data_Newtype.over(newtypeMilliseconds)(newtypeDays)(Milliseconds)(function (v) { | |
| return v / 8.64e7; | |
| })); | |
| // | Converts directly between durations of differing types. | |
| var convertDuration = function (dictDuration) { | |
| return function (dictDuration1) { | |
| return function ($80) { | |
| return toDuration(dictDuration1)(fromDuration(dictDuration)($80)); | |
| }; | |
| }; | |
| }; | |
| exports["Days"] = Days; | |
| exports["Hours"] = Hours; | |
| exports["Milliseconds"] = Milliseconds; | |
| exports["Minutes"] = Minutes; | |
| exports["Seconds"] = Seconds; | |
| exports["Duration"] = Duration; | |
| exports["convertDuration"] = convertDuration; | |
| exports["fromDuration"] = fromDuration; | |
| exports["toDuration"] = toDuration; | |
| exports["newtypeMilliseconds"] = newtypeMilliseconds; | |
| exports["genericMilliseconds"] = genericMilliseconds; | |
| exports["eqMilliseconds"] = eqMilliseconds; | |
| exports["ordMilliseconds"] = ordMilliseconds; | |
| exports["semiringMilliseconds"] = semiringMilliseconds; | |
| exports["ringMilliseconds"] = ringMilliseconds; | |
| exports["showMilliseconds"] = showMilliseconds; | |
| exports["newtypeSeconds"] = newtypeSeconds; | |
| exports["genericSeconds"] = genericSeconds; | |
| exports["eqSeconds"] = eqSeconds; | |
| exports["ordSeconds"] = ordSeconds; | |
| exports["semiringSeconds"] = semiringSeconds; | |
| exports["ringSeconds"] = ringSeconds; | |
| exports["showSeconds"] = showSeconds; | |
| exports["newtypeMinutes"] = newtypeMinutes; | |
| exports["genericMinutes"] = genericMinutes; | |
| exports["eqMinutes"] = eqMinutes; | |
| exports["ordMinutes"] = ordMinutes; | |
| exports["semiringMinutes"] = semiringMinutes; | |
| exports["ringMinutes"] = ringMinutes; | |
| exports["showMinutes"] = showMinutes; | |
| exports["newtypeHours"] = newtypeHours; | |
| exports["genericHours"] = genericHours; | |
| exports["eqHours"] = eqHours; | |
| exports["ordHours"] = ordHours; | |
| exports["semiringHours"] = semiringHours; | |
| exports["ringHours"] = ringHours; | |
| exports["showHours"] = showHours; | |
| exports["newtypeDays"] = newtypeDays; | |
| exports["genericDays"] = genericDays; | |
| exports["eqDays"] = eqDays; | |
| exports["ordDays"] = ordDays; | |
| exports["semiringDays"] = semiringDays; | |
| exports["ringDays"] = ringDays; | |
| exports["showDays"] = showDays; | |
| exports["durationMilliseconds"] = durationMilliseconds; | |
| exports["durationSeconds"] = durationSeconds; | |
| exports["durationMinutes"] = durationMinutes; | |
| exports["durationHours"] = durationHours; | |
| exports["durationDays"] = durationDays; | |
| })(PS["Data.Time.Duration"] = PS["Data.Time.Duration"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Aff"]; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Aff_Internal = PS["Control.Monad.Aff.Internal"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Parallel = PS["Control.Parallel"]; | |
| var Control_Parallel_Class = PS["Control.Parallel.Class"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Either = PS["Data.Either"]; | |
| var Data_Eq = PS["Data.Eq"]; | |
| var Data_Foldable = PS["Data.Foldable"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Semiring = PS["Data.Semiring"]; | |
| var Data_Time_Duration = PS["Data.Time.Duration"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| var ParAff = function (x) { | |
| return x; | |
| }; | |
| // | A canceler is an asynchronous function that can be used to attempt the | |
| // | cancelation of a computation. Returns a boolean flag indicating whether | |
| // | or not the cancellation was successful. Many computations may be composite, | |
| // | in such cases the flag indicates whether any part of the computation was | |
| // | successfully canceled. The flag should not be used for communication. | |
| var Canceler = function (x) { | |
| return x; | |
| }; | |
| // | Runs the asynchronous computation. You must supply an error callback and a | |
| // | success callback. | |
| // | | |
| // | Returns a canceler that can be used to attempt cancellation of the | |
| // | asynchronous computation. | |
| var runAff = function (ex) { | |
| return function (f) { | |
| return function (aff) { | |
| return $foreign._runAff(ex, f, aff); | |
| }; | |
| }; | |
| }; | |
| var newtypeParAff = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, ParAff); | |
| // | Creates an asynchronous effect from a function that accepts error and | |
| // | success callbacks, and returns a canceler for the computation. This | |
| // | function can be used for asynchronous computations that can be canceled. | |
| var makeAff$prime = function (h) { | |
| return $foreign._makeAff(h); | |
| }; | |
| var functorAff = new Data_Functor.Functor(function (f) { | |
| return function (fa) { | |
| return $foreign._fmap(f, fa); | |
| }; | |
| }); | |
| var functorParAff = functorAff; | |
| var fromAVBox = Unsafe_Coerce.unsafeCoerce; | |
| // | Unwraps the canceler function from the newtype that wraps it. | |
| var cancel = function (v) { | |
| return v; | |
| }; | |
| // | Converts the asynchronous computation into a synchronous one. All values | |
| // | are ignored, and if the computation produces an error, it is thrown. | |
| // | | |
| // | Catching exceptions by using `catchException` with the resulting Eff | |
| // | computation is not recommended, as exceptions may end up being thrown | |
| // | asynchronously, in which case they cannot be caught. | |
| // | | |
| // | If you do need to handle exceptions, you can use `runAff` instead, or | |
| // | you can handle the exception within the Aff computation, using | |
| // | `catchError` (or any of the other mechanisms). | |
| var launchAff = (function () { | |
| var lowerEx = Data_Functor.map(Control_Monad_Eff.functorEff)(function ($54) { | |
| return Canceler(Data_Functor.map(Data_Functor.functorFn)($foreign._unsafeInterleaveAff)(cancel($54))); | |
| }); | |
| return function ($55) { | |
| return lowerEx(runAff(Control_Monad_Eff_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit)))($foreign._unsafeInterleaveAff($55))); | |
| }; | |
| })(); | |
| // | Promotes any error to the value level of the asynchronous monad. | |
| var attempt = function (aff) { | |
| return $foreign._attempt(Data_Either.Left.create, Data_Either.Right.create, aff); | |
| }; | |
| // | Ignores any errors. | |
| var apathize = function (a) { | |
| return Data_Functor.map(functorAff)(Data_Function["const"](Data_Unit.unit))(attempt(a)); | |
| }; | |
| var applyAff = new Control_Apply.Apply(function () { | |
| return functorAff; | |
| }, function (ff) { | |
| return function (fa) { | |
| return $foreign._bind(alwaysCanceler, ff, function (f) { | |
| return Data_Functor.map(functorAff)(f)(fa); | |
| }); | |
| }; | |
| }); | |
| var applicativeAff = new Control_Applicative.Applicative(function () { | |
| return applyAff; | |
| }, function (v) { | |
| return $foreign._pure(nonCanceler, v); | |
| }); | |
| // | A constant canceller that always returns false. | |
| var nonCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(false)); | |
| // | A constant canceller that always returns true. | |
| var alwaysCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(true)); | |
| // | This function allows you to attach a custom canceler to an asynchronous | |
| // | computation. If the computation is canceled, then the custom canceler | |
| // | will be run along side the computation's own canceler. | |
| var cancelWith = function (aff) { | |
| return function (c) { | |
| return $foreign._cancelWith(nonCanceler, aff, c); | |
| }; | |
| }; | |
| // | Pauses execuation of the current computation for the specified number of milliseconds. | |
| var delay = function (v) { | |
| return $foreign._delay(nonCanceler, v); | |
| }; | |
| // | Forks the specified asynchronous computation so subsequent computations | |
| // | will not block on the result of the computation. | |
| // | | |
| // | Returns a canceler that can be used to attempt cancellation of the | |
| // | forked computation. | |
| var forkAff = function (aff) { | |
| return $foreign._forkAff(nonCanceler, aff); | |
| }; | |
| // | Forks many asynchronous computation in a synchronous manner while being | |
| // | stack-safe up to the selected Foldable instance. | |
| // | | |
| // | Returns a canceler that can be used to attempt cancellation of all | |
| // | forked computations. | |
| var forkAll = function (dictFoldable) { | |
| return function (affs) { | |
| return $foreign._forkAll(nonCanceler, Data_Foldable.foldl(dictFoldable), affs); | |
| }; | |
| }; | |
| var killVar = function (q) { | |
| return function (e) { | |
| return fromAVBox(Control_Monad_Aff_Internal._killVar(nonCanceler, q, e)); | |
| }; | |
| }; | |
| // | Lifts a synchronous computation and makes explicit any failure from exceptions. | |
| var liftEff$prime = function (eff) { | |
| return attempt($foreign._unsafeInterleaveAff($foreign._liftEff(nonCanceler, eff))); | |
| }; | |
| // | Creates an asynchronous effect from a function that accepts error and | |
| // | success callbacks. This function can be used for asynchronous computations | |
| // | that cannot be canceled. | |
| var makeAff = function (h) { | |
| return makeAff$prime(function (e) { | |
| return function (a) { | |
| return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Function["const"](nonCanceler))(h(e)(a)); | |
| }; | |
| }); | |
| }; | |
| var makeVar = fromAVBox(Control_Monad_Aff_Internal._makeVar(nonCanceler)); | |
| var putVar = function (q) { | |
| return function (a) { | |
| return fromAVBox(Control_Monad_Aff_Internal._putVar(nonCanceler, q, a)); | |
| }; | |
| }; | |
| var takeVar = function (q) { | |
| return fromAVBox(Control_Monad_Aff_Internal._takeVar(nonCanceler, q)); | |
| }; | |
| var semigroupAff = function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(function (a) { | |
| return function (b) { | |
| return Control_Apply.apply(applyAff)(Data_Functor.map(functorAff)(Data_Semigroup.append(dictSemigroup))(a))(b); | |
| }; | |
| }); | |
| }; | |
| var monoidAff = function (dictMonoid) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupAff(dictMonoid.Semigroup0()); | |
| }, Control_Applicative.pure(applicativeAff)(Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| var semigroupCanceler = new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return function (e) { | |
| return Control_Apply.apply(applyAff)(Data_Functor.map(functorAff)(Data_HeytingAlgebra.disj(Data_HeytingAlgebra.heytingAlgebraBoolean))(v(e)))(v1(e)); | |
| }; | |
| }; | |
| }); | |
| var monoidCanceler = new Data_Monoid.Monoid(function () { | |
| return semigroupCanceler; | |
| }, Data_Function["const"](Control_Applicative.pure(applicativeAff)(true))); | |
| var bindAff = new Control_Bind.Bind(function () { | |
| return applyAff; | |
| }, function (fa) { | |
| return function (f) { | |
| return $foreign._bind(alwaysCanceler, fa, f); | |
| }; | |
| }); | |
| var applyParAff = new Control_Apply.Apply(function () { | |
| return functorParAff; | |
| }, function (v) { | |
| return function (v1) { | |
| var putOrKill = function (v2) { | |
| return Data_Either.either(killVar(v2))(putVar(v2)); | |
| }; | |
| return Control_Bind.bind(bindAff)(makeVar)(function (v2) { | |
| return Control_Bind.bind(bindAff)(makeVar)(function (v3) { | |
| return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(putOrKill(v2))(attempt(v))))(function (v4) { | |
| return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(putOrKill(v3))(attempt(v1))))(function (v5) { | |
| return cancelWith(Control_Apply.apply(applyAff)(takeVar(v2))(takeVar(v3)))(Data_Semigroup.append(semigroupCanceler)(v4)(v5)); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }; | |
| }); | |
| var applicativeParAff = new Control_Applicative.Applicative(function () { | |
| return applyParAff; | |
| }, function ($56) { | |
| return ParAff(Control_Applicative.pure(applicativeAff)($56)); | |
| }); | |
| var semigroupParAff = function (dictSemigroup) { | |
| return new Data_Semigroup.Semigroup(function (a) { | |
| return function (b) { | |
| return Control_Apply.apply(applyParAff)(Data_Functor.map(functorParAff)(Data_Semigroup.append(dictSemigroup))(a))(b); | |
| }; | |
| }); | |
| }; | |
| var monoidParAff = function (dictMonoid) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupParAff(dictMonoid.Semigroup0()); | |
| }, Control_Applicative.pure(applicativeParAff)(Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| var monadAff = new Control_Monad.Monad(function () { | |
| return applicativeAff; | |
| }, function () { | |
| return bindAff; | |
| }); | |
| var monadEffAff = new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadAff; | |
| }, function (eff) { | |
| return $foreign._liftEff(nonCanceler, eff); | |
| }); | |
| var monadRecAff = new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadAff; | |
| }, function (f) { | |
| return function (a) { | |
| var isLoop = function (v) { | |
| if (v instanceof Control_Monad_Rec_Class.Loop) { | |
| return true; | |
| }; | |
| return false; | |
| }; | |
| return $foreign._tailRecM(isLoop, f, a); | |
| }; | |
| }); | |
| // | Allows users to throw errors on the error channel of the | |
| // | asynchronous computation. See documentation in `purescript-transformers`. | |
| var monadThrowAff = new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadAff; | |
| }, function (e) { | |
| return $foreign._throwError(nonCanceler, e); | |
| }); | |
| // | Compute `aff1`, followed by `aff2` regardless of whether `aff1` terminated successfully. | |
| var $$finally = function (aff1) { | |
| return function (aff2) { | |
| return Control_Bind.bind(bindAff)(attempt(aff1))(function (v) { | |
| return Control_Bind.bind(bindAff)(aff2)(function (v1) { | |
| return Data_Either.either(Control_Monad_Error_Class.throwError(monadThrowAff))(Control_Applicative.pure(applicativeAff))(v); | |
| }); | |
| }); | |
| }; | |
| }; | |
| var parallelParAff = new Control_Parallel_Class.Parallel(function () { | |
| return applicativeParAff; | |
| }, function () { | |
| return monadAff; | |
| }, ParAff, function (v) { | |
| return v; | |
| }); | |
| // | Allows users to catch errors on the error channel of the | |
| // | asynchronous computation. See documentation in `purescript-transformers`. | |
| var monadErrorAff = new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowAff; | |
| }, function (aff) { | |
| return function (ex) { | |
| return Control_Bind.bind(bindAff)(attempt(aff))(Data_Either.either(ex)(Control_Applicative.pure(applicativeAff))); | |
| }; | |
| }); | |
| // | Returns the first value, or the first error if both error. | |
| var altParAff = new Control_Alt.Alt(function () { | |
| return functorParAff; | |
| }, function (v) { | |
| return function (v1) { | |
| var maybeKill = function (va) { | |
| return function (ve) { | |
| return function (err) { | |
| return Control_Bind.bind(bindAff)(takeVar(ve))(function (v2) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)(bindAff)(Control_Applicative.when(applicativeAff)(v2 === 1)(killVar(va)(err)))(function () { | |
| return putVar(ve)(v2 + 1 | 0); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }; | |
| var done = function (cs) { | |
| return function (get) { | |
| return function (va) { | |
| return function (x) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)(bindAff)(putVar(va)(x))(function () { | |
| return Control_Bind.bind(bindAff)(Data_Functor.map(functorAff)(get)(takeVar(cs)))(function (v2) { | |
| return Data_Functor["void"](functorAff)(cancel(v2)(Control_Monad_Eff_Exception.error("Alt early exit"))); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| return Control_Bind.bind(bindAff)(makeVar)(function (v2) { | |
| return Control_Bind.bind(bindAff)(makeVar)(function (v3) { | |
| return Control_Bind.bind(bindAff)(makeVar)(function (v4) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)(bindAff)(putVar(v3)(0))(function () { | |
| return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(Data_Either.either(maybeKill(v2)(v3))(done(v4)(Data_Tuple.snd)(v2)))(attempt(v))))(function (v5) { | |
| return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(Data_Either.either(maybeKill(v2)(v3))(done(v4)(Data_Tuple.fst)(v2)))(attempt(v1))))(function (v6) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)(bindAff)(putVar(v4)(new Data_Tuple.Tuple(v5, v6)))(function () { | |
| return cancelWith(takeVar(v2))(Data_Semigroup.append(semigroupCanceler)(v5)(v6)); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }; | |
| }); | |
| var altAff = new Control_Alt.Alt(function () { | |
| return functorAff; | |
| }, function (a1) { | |
| return function (a2) { | |
| return Control_Bind.bind(bindAff)(attempt(a1))(Data_Either.either(Data_Function["const"](a2))(Control_Applicative.pure(applicativeAff))); | |
| }; | |
| }); | |
| var plusAff = new Control_Plus.Plus(function () { | |
| return altAff; | |
| }, Control_Monad_Error_Class.throwError(monadThrowAff)(Control_Monad_Eff_Exception.error("Always fails"))); | |
| var alternativeAff = new Control_Alternative.Alternative(function () { | |
| return applicativeAff; | |
| }, function () { | |
| return plusAff; | |
| }); | |
| var monadZero = new Control_MonadZero.MonadZero(function () { | |
| return alternativeAff; | |
| }, function () { | |
| return monadAff; | |
| }); | |
| var monadPlusAff = new Control_MonadPlus.MonadPlus(function () { | |
| return monadZero; | |
| }); | |
| var plusParAff = new Control_Plus.Plus(function () { | |
| return altParAff; | |
| }, Control_Plus.empty(plusAff)); | |
| var alternativeParAff = new Control_Alternative.Alternative(function () { | |
| return applicativeParAff; | |
| }, function () { | |
| return plusParAff; | |
| }); | |
| exports["Canceler"] = Canceler; | |
| exports["ParAff"] = ParAff; | |
| exports["apathize"] = apathize; | |
| exports["attempt"] = attempt; | |
| exports["cancel"] = cancel; | |
| exports["cancelWith"] = cancelWith; | |
| exports["delay"] = delay; | |
| exports["finally"] = $$finally; | |
| exports["forkAff"] = forkAff; | |
| exports["forkAll"] = forkAll; | |
| exports["launchAff"] = launchAff; | |
| exports["liftEff'"] = liftEff$prime; | |
| exports["makeAff"] = makeAff; | |
| exports["makeAff'"] = makeAff$prime; | |
| exports["nonCanceler"] = nonCanceler; | |
| exports["runAff"] = runAff; | |
| exports["semigroupAff"] = semigroupAff; | |
| exports["monoidAff"] = monoidAff; | |
| exports["functorAff"] = functorAff; | |
| exports["applyAff"] = applyAff; | |
| exports["applicativeAff"] = applicativeAff; | |
| exports["bindAff"] = bindAff; | |
| exports["monadAff"] = monadAff; | |
| exports["monadEffAff"] = monadEffAff; | |
| exports["monadThrowAff"] = monadThrowAff; | |
| exports["monadErrorAff"] = monadErrorAff; | |
| exports["altAff"] = altAff; | |
| exports["plusAff"] = plusAff; | |
| exports["alternativeAff"] = alternativeAff; | |
| exports["monadZero"] = monadZero; | |
| exports["monadPlusAff"] = monadPlusAff; | |
| exports["monadRecAff"] = monadRecAff; | |
| exports["semigroupCanceler"] = semigroupCanceler; | |
| exports["monoidCanceler"] = monoidCanceler; | |
| exports["newtypeParAff"] = newtypeParAff; | |
| exports["semigroupParAff"] = semigroupParAff; | |
| exports["monoidParAff"] = monoidParAff; | |
| exports["functorParAff"] = functorParAff; | |
| exports["applyParAff"] = applyParAff; | |
| exports["applicativeParAff"] = applicativeParAff; | |
| exports["altParAff"] = altParAff; | |
| exports["plusParAff"] = plusParAff; | |
| exports["alternativeParAff"] = alternativeParAff; | |
| exports["parallelParAff"] = parallelParAff; | |
| })(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}); | |
| (function(exports) { | |
| // | A low-level primitive for building asynchronous code. | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Monad_Aff = PS["Control.Monad.Aff"]; | |
| var Control_Monad_Aff_Internal = PS["Control.Monad.Aff.Internal"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Prelude = PS["Prelude"]; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| var fromAVBox = Unsafe_Coerce.unsafeCoerce; | |
| // | Kills an asynchronous avar. | |
| var killVar = function (q) { | |
| return function (e) { | |
| return fromAVBox(Control_Monad_Aff_Internal._killVar(Control_Monad_Aff.nonCanceler, q, e)); | |
| }; | |
| }; | |
| // | Makes a new asynchronous avar. | |
| var makeVar = fromAVBox(Control_Monad_Aff_Internal._makeVar(Control_Monad_Aff.nonCanceler)); | |
| // | Reads a value from the asynchronous var but does not consume it. | |
| var peekVar = function (q) { | |
| return fromAVBox(Control_Monad_Aff_Internal._peekVar(Control_Monad_Aff.nonCanceler, q)); | |
| }; | |
| // | Puts a new value into the asynchronous avar. If the avar has | |
| // | been killed, this will result in an error. | |
| var putVar = function (q) { | |
| return function (a) { | |
| return fromAVBox(Control_Monad_Aff_Internal._putVar(Control_Monad_Aff.nonCanceler, q, a)); | |
| }; | |
| }; | |
| // | Makes a avar and sets it to some value. | |
| var makeVar$prime = function (a) { | |
| return Control_Bind.bind(Control_Monad_Aff.bindAff)(makeVar)(function (v) { | |
| return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(putVar(v)(a))(function () { | |
| return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v); | |
| }); | |
| }); | |
| }; | |
| // | Takes the next value from the asynchronous avar. | |
| var takeVar = function (q) { | |
| return fromAVBox(Control_Monad_Aff_Internal._takeVar(Control_Monad_Aff.nonCanceler, q)); | |
| }; | |
| // | Modifies the value at the head of the avar (will suspend until one is available). | |
| var modifyVar = function (f) { | |
| return function (v) { | |
| return Control_Bind.bind(Control_Monad_Aff.bindAff)(takeVar(v))(function ($2) { | |
| return putVar(v)(f($2)); | |
| }); | |
| }; | |
| }; | |
| // | A variant of `peekVar` which return immediately when the asynchronous avar | |
| // | was empty. Nothing if the avar empty and `Just a` if the avar have contents `a`. | |
| var tryPeekVar = function (q) { | |
| return fromAVBox(Control_Monad_Aff_Internal._tryPeekVar(Data_Maybe.Nothing.value, Data_Maybe.Just.create, Control_Monad_Aff.nonCanceler, q)); | |
| }; | |
| // | A variant of `takeVar` which return immediately if the asynchronous avar | |
| // | was empty. Nothing if the avar empty and `Just a` if the avar have contents `a`. | |
| var tryTakeVar = function (q) { | |
| return fromAVBox(Control_Monad_Aff_Internal._tryTakeVar(Data_Maybe.Nothing.value, Data_Maybe.Just.create, Control_Monad_Aff.nonCanceler, q)); | |
| }; | |
| exports["killVar"] = killVar; | |
| exports["makeVar"] = makeVar; | |
| exports["makeVar'"] = makeVar$prime; | |
| exports["modifyVar"] = modifyVar; | |
| exports["peekVar"] = peekVar; | |
| exports["putVar"] = putVar; | |
| exports["takeVar"] = takeVar; | |
| exports["tryPeekVar"] = tryPeekVar; | |
| exports["tryTakeVar"] = tryTakeVar; | |
| })(PS["Control.Monad.Aff.AVar"] = PS["Control.Monad.Aff.AVar"] || {}); | |
| (function(exports) { | |
| // | This module defines the list monad transformer, `ListT`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_MonadPlus = PS["Control.MonadPlus"]; | |
| var Control_MonadZero = PS["Control.MonadZero"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Lazy = PS["Data.Lazy"]; | |
| var Data_Maybe = PS["Data.Maybe"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Ring = PS["Data.Ring"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unfoldable = PS["Data.Unfoldable"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| // | The result of a single step in a `ListT` computation. Either: | |
| // | | |
| // | - Computation has finished (`Done`), or | |
| // | - A result has been returned, along with the next part of the computation (`Yield`). | |
| // | | |
| // | The `Skip` constructor allows us to avoid traversing lists during certain operations. | |
| var Yield = (function () { | |
| function Yield(value0, value1) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| }; | |
| Yield.create = function (value0) { | |
| return function (value1) { | |
| return new Yield(value0, value1); | |
| }; | |
| }; | |
| return Yield; | |
| })(); | |
| // | The result of a single step in a `ListT` computation. Either: | |
| // | | |
| // | - Computation has finished (`Done`), or | |
| // | - A result has been returned, along with the next part of the computation (`Yield`). | |
| // | | |
| // | The `Skip` constructor allows us to avoid traversing lists during certain operations. | |
| var Skip = (function () { | |
| function Skip(value0) { | |
| this.value0 = value0; | |
| }; | |
| Skip.create = function (value0) { | |
| return new Skip(value0); | |
| }; | |
| return Skip; | |
| })(); | |
| // | The result of a single step in a `ListT` computation. Either: | |
| // | | |
| // | - Computation has finished (`Done`), or | |
| // | - A result has been returned, along with the next part of the computation (`Yield`). | |
| // | | |
| // | The `Skip` constructor allows us to avoid traversing lists during certain operations. | |
| var Done = (function () { | |
| function Done() { | |
| }; | |
| Done.value = new Done(); | |
| return Done; | |
| })(); | |
| // | The list monad transformer. | |
| // | | |
| // | This monad transformer extends the base monad with _non-determinism_. | |
| // | That is, the transformed monad supports the same effects as the base monad | |
| // | but with multiple return values. | |
| var ListT = function (x) { | |
| return x; | |
| }; | |
| // | Defer evaluation of a list. | |
| var wrapLazy = function (dictApplicative) { | |
| return function (v) { | |
| return ListT(Control_Applicative.pure(dictApplicative)(new Skip(v))); | |
| }; | |
| }; | |
| // | Lift a computation from the base monad. | |
| var wrapEffect = function (dictFunctor) { | |
| return function (v) { | |
| return ListT(Data_Functor.map(dictFunctor)(function ($178) { | |
| return Skip.create(Data_Lazy.defer(Data_Function["const"]($178))); | |
| })(v)); | |
| }; | |
| }; | |
| // | Unfold a list using an effectful generator function. | |
| var unfold = function (dictMonad) { | |
| return function (f) { | |
| return function (z) { | |
| var g = function (v) { | |
| if (v instanceof Data_Maybe.Just) { | |
| return new Yield(v.value0.value1, Data_Lazy.defer(function (v1) { | |
| return unfold(dictMonad)(f)(v.value0.value0); | |
| })); | |
| }; | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 131, column 3 - line 131, column 60: " + [ v.constructor.name ]); | |
| }; | |
| return ListT(Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(g)(f(z))); | |
| }; | |
| }; | |
| }; | |
| // | Perform the first step of a computation in the `ListT` monad. | |
| var uncons = function (dictMonad) { | |
| return function (v) { | |
| var g = function (v1) { | |
| if (v1 instanceof Yield) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_Maybe.Just.create(new Data_Tuple.Tuple(v1.value0, Data_Lazy.force(v1.value1)))); | |
| }; | |
| if (v1 instanceof Skip) { | |
| return uncons(dictMonad)(Data_Lazy.force(v1.value0)); | |
| }; | |
| if (v1 instanceof Done) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_Maybe.Nothing.value); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 196, column 3 - line 196, column 50: " + [ v1.constructor.name ]); | |
| }; | |
| return Control_Bind.bind(dictMonad.Bind1())(v)(g); | |
| }; | |
| }; | |
| // | Extract all but the first element of a list. | |
| var tail = function (dictMonad) { | |
| return function (l) { | |
| return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Tuple.snd))(uncons(dictMonad)(l)); | |
| }; | |
| }; | |
| // | Lift a computation on list steps to a computation on whole lists. | |
| var stepMap = function (dictFunctor) { | |
| return function (f) { | |
| return function (v) { | |
| return ListT(Data_Functor.map(dictFunctor)(f)(v)); | |
| }; | |
| }; | |
| }; | |
| // | Take elements from the front of a list while a predicate holds. | |
| var takeWhile = function (dictApplicative) { | |
| return function (f) { | |
| var g = function (v) { | |
| if (v instanceof Yield) { | |
| var $98 = f(v.value0); | |
| if ($98) { | |
| return new Yield(v.value0, Data_Functor.map(Data_Lazy.functorLazy)(takeWhile(dictApplicative)(f))(v.value1)); | |
| }; | |
| return Done.value; | |
| }; | |
| if (v instanceof Skip) { | |
| return Skip.create(Data_Functor.map(Data_Lazy.functorLazy)(takeWhile(dictApplicative)(f))(v.value0)); | |
| }; | |
| if (v instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 155, column 3 - line 155, column 68: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap((dictApplicative.Apply0()).Functor0())(g); | |
| }; | |
| }; | |
| // | Fold a list from the left, accumulating the list of results using the specified function. | |
| var scanl = function (dictMonad) { | |
| return function (f) { | |
| return function (b) { | |
| return function (l) { | |
| var g = function (v) { | |
| var h = function (v1) { | |
| if (v1 instanceof Yield) { | |
| var b$prime$prime = f(v.value0)(v1.value0); | |
| return Data_Maybe.Just.create(new Data_Tuple.Tuple(new Data_Tuple.Tuple(b$prime$prime, Data_Lazy.force(v1.value1)), v.value0)); | |
| }; | |
| if (v1 instanceof Skip) { | |
| return Data_Maybe.Just.create(new Data_Tuple.Tuple(new Data_Tuple.Tuple(v.value0, Data_Lazy.force(v1.value0)), v.value0)); | |
| }; | |
| if (v1 instanceof Done) { | |
| return Data_Maybe.Nothing.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 249, column 5 - line 249, column 78: " + [ v1.constructor.name ]); | |
| }; | |
| return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(h)(v.value1); | |
| }; | |
| return unfold(dictMonad)(g)(new Data_Tuple.Tuple(b, l)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Prepend an element to a lazily-evaluated list. | |
| var prepend$prime = function (dictApplicative) { | |
| return function (h) { | |
| return function (t) { | |
| return ListT(Control_Applicative.pure(dictApplicative)(new Yield(h, t))); | |
| }; | |
| }; | |
| }; | |
| // | Prepend an element to a list. | |
| var prepend = function (dictApplicative) { | |
| return function (h) { | |
| return function (t) { | |
| return prepend$prime(dictApplicative)(h)(Data_Lazy.defer(Data_Function["const"](t))); | |
| }; | |
| }; | |
| }; | |
| // | The empty list. | |
| var nil = function (dictApplicative) { | |
| return ListT(Control_Applicative.pure(dictApplicative)(Done.value)); | |
| }; | |
| // | Create a list with one element. | |
| var singleton = function (dictApplicative) { | |
| return function (a) { | |
| return prepend(dictApplicative)(a)(nil(dictApplicative)); | |
| }; | |
| }; | |
| // | Take a number of elements from the front of a list. | |
| var take = function (dictApplicative) { | |
| return function (v) { | |
| return function (fa) { | |
| if (v === 0) { | |
| return nil(dictApplicative); | |
| }; | |
| var f = function (v1) { | |
| if (v1 instanceof Yield) { | |
| return new Yield(v1.value0, Data_Functor.map(Data_Lazy.functorLazy)(take(dictApplicative)(v - 1 | 0))(v1.value1)); | |
| }; | |
| if (v1 instanceof Skip) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(take(dictApplicative)(v))(v1.value0)); | |
| }; | |
| if (v1 instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 148, column 3 - line 148, column 47: " + [ v1.constructor.name ]); | |
| }; | |
| return stepMap((dictApplicative.Apply0()).Functor0())(f)(fa); | |
| }; | |
| }; | |
| }; | |
| // | Zip the elements of two lists, combining elements at the same position from each list. | |
| var zipWith$prime = function (dictMonad) { | |
| return function (f) { | |
| var g = function (v) { | |
| return function (v1) { | |
| if (v1 instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(nil(dictMonad.Applicative0())); | |
| }; | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(nil(dictMonad.Applicative0())); | |
| }; | |
| if (v instanceof Data_Maybe.Just && v1 instanceof Data_Maybe.Just) { | |
| return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Function.flip(prepend$prime(dictMonad.Applicative0()))(Data_Lazy.defer(function (v2) { | |
| return zipWith$prime(dictMonad)(f)(v.value0.value1)(v1.value0.value1); | |
| })))(f(v.value0.value0)(v1.value0.value0)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 261, column 3 - line 261, column 25: " + [ v.constructor.name, v1.constructor.name ]); | |
| }; | |
| }; | |
| var loop = function (fa) { | |
| return function (fb) { | |
| return wrapEffect(((dictMonad.Bind1()).Apply0()).Functor0())(Control_Bind.bind(dictMonad.Bind1())(uncons(dictMonad)(fa))(function (v) { | |
| return Control_Bind.bind(dictMonad.Bind1())(uncons(dictMonad)(fb))(function (v1) { | |
| return g(v)(v1); | |
| }); | |
| })); | |
| }; | |
| }; | |
| return loop; | |
| }; | |
| }; | |
| // | Zip the elements of two lists, combining elements at the same position from each list. | |
| var zipWith = function (dictMonad) { | |
| return function (f) { | |
| var g = function (a) { | |
| return function (b) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(f(a)(b)); | |
| }; | |
| }; | |
| return zipWith$prime(dictMonad)(g); | |
| }; | |
| }; | |
| var newtypeListT = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, ListT); | |
| // | Apply a function to the elements of a list, keeping only those return values which contain a result. | |
| var mapMaybe = function (dictFunctor) { | |
| return function (f) { | |
| var g = function (v) { | |
| if (v instanceof Yield) { | |
| return Data_Maybe.fromMaybe(Skip.create)(Data_Functor.map(Data_Maybe.functorMaybe)(Yield.create)(f(v.value0)))(Data_Functor.map(Data_Lazy.functorLazy)(mapMaybe(dictFunctor)(f))(v.value1)); | |
| }; | |
| if (v instanceof Skip) { | |
| return Skip.create(Data_Functor.map(Data_Lazy.functorLazy)(mapMaybe(dictFunctor)(f))(v.value0)); | |
| }; | |
| if (v instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 184, column 3 - line 184, column 72: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap(dictFunctor)(g); | |
| }; | |
| }; | |
| // | Generate an infinite list by iterating a function. | |
| var iterate = function (dictMonad) { | |
| return function (f) { | |
| return function (a) { | |
| var g = function (x) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Maybe.Just(new Data_Tuple.Tuple(f(x), x))); | |
| }; | |
| return unfold(dictMonad)(g)(a); | |
| }; | |
| }; | |
| }; | |
| // | Generate an infinite list by repeating a value. | |
| var repeat = function (dictMonad) { | |
| return iterate(dictMonad)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| // | Extract the first element of a list. | |
| var head = function (dictMonad) { | |
| return function (l) { | |
| return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Tuple.fst))(uncons(dictMonad)(l)); | |
| }; | |
| }; | |
| var functorListT = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| var g = function (v) { | |
| if (v instanceof Yield) { | |
| return new Yield(f(v.value0), Data_Functor.map(Data_Lazy.functorLazy)(Data_Functor.map(functorListT(dictFunctor))(f))(v.value1)); | |
| }; | |
| if (v instanceof Skip) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(Data_Functor.map(functorListT(dictFunctor))(f))(v.value0)); | |
| }; | |
| if (v instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 281, column 5 - line 281, column 48: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap(dictFunctor)(g); | |
| }); | |
| }; | |
| // | Lift a computation from the base functor. | |
| var fromEffect = function (dictApplicative) { | |
| return function (fa) { | |
| return ListT(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Function.flip(Yield.create)(Data_Lazy.defer(function (v) { | |
| return nil(dictApplicative); | |
| })))(fa)); | |
| }; | |
| }; | |
| var monadTransListT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return fromEffect(dictMonad.Applicative0()); | |
| }); | |
| // | Fold a list from the left, accumulating the result (effectfully) using the specified function. | |
| // | Uses tail call optimization. | |
| var foldlRec$prime = function (dictMonadRec) { | |
| return function (f) { | |
| var loop = function (b) { | |
| return function (l) { | |
| var g = function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(b)); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(f(b)(v.value0.value0))(function (b$prime) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop({ | |
| a: b$prime, | |
| b: v.value0.value1 | |
| })); | |
| }); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 222, column 5 - line 222, column 45: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(uncons(dictMonadRec.Monad0())(l))(g); | |
| }; | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM2(dictMonadRec)(loop); | |
| }; | |
| }; | |
| // | Drain a `ListT`, running it to completion and discarding all values. | |
| // | Stack safe: Uses tail call optimization. | |
| var runListTRec = function (dictMonadRec) { | |
| return foldlRec$prime(dictMonadRec)(function (v) { | |
| return function (v1) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(Data_Unit.unit); | |
| }; | |
| })(Data_Unit.unit); | |
| }; | |
| // | Fold a list from the left, accumulating the result using the specified function. | |
| // | Uses tail call optimization. | |
| var foldlRec = function (dictMonadRec) { | |
| return function (f) { | |
| var loop = function (b) { | |
| return function (l) { | |
| var g = function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(b)); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop({ | |
| a: f(b)(v.value0.value0), | |
| b: v.value0.value1 | |
| })); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 240, column 7 - line 240, column 47: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(uncons(dictMonadRec.Monad0())(l))(g); | |
| }; | |
| }; | |
| return Control_Monad_Rec_Class.tailRecM2(dictMonadRec)(loop); | |
| }; | |
| }; | |
| // | Fold a list from the left, accumulating the result (effectfully) using the specified function. | |
| var foldl$prime = function (dictMonad) { | |
| return function (f) { | |
| var loop = function (b) { | |
| return function (l) { | |
| var g = function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(b); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return Control_Bind.bind(dictMonad.Bind1())(f(b)(v.value0.value0))(Data_Function.flip(loop)(v.value0.value1)); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 213, column 5 - line 213, column 35: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Bind.bind(dictMonad.Bind1())(uncons(dictMonad)(l))(g); | |
| }; | |
| }; | |
| return loop; | |
| }; | |
| }; | |
| // | Drain a `ListT`, running it to completion and discarding all values. | |
| var runListT = function (dictMonad) { | |
| return foldl$prime(dictMonad)(function (v) { | |
| return function (v1) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(Data_Unit.unit); | |
| }; | |
| })(Data_Unit.unit); | |
| }; | |
| // | Fold a list from the left, accumulating the result using the specified function. | |
| var foldl = function (dictMonad) { | |
| return function (f) { | |
| var loop = function (b) { | |
| return function (l) { | |
| var g = function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(b); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return loop(f(b)(v.value0.value0))(v.value0.value1); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 230, column 5 - line 230, column 35: " + [ v.constructor.name ]); | |
| }; | |
| return Control_Bind.bind(dictMonad.Bind1())(uncons(dictMonad)(l))(g); | |
| }; | |
| }; | |
| return loop; | |
| }; | |
| }; | |
| // | Remove elements from a list for which a predicate fails to hold. | |
| var filter = function (dictFunctor) { | |
| return function (f) { | |
| var g = function (v) { | |
| if (v instanceof Yield) { | |
| var s$prime = Data_Functor.map(Data_Lazy.functorLazy)(filter(dictFunctor)(f))(v.value1); | |
| var $151 = f(v.value0); | |
| if ($151) { | |
| return new Yield(v.value0, s$prime); | |
| }; | |
| return new Skip(s$prime); | |
| }; | |
| if (v instanceof Skip) { | |
| var s$prime = Data_Functor.map(Data_Lazy.functorLazy)(filter(dictFunctor)(f))(v.value0); | |
| return new Skip(s$prime); | |
| }; | |
| if (v instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 177, column 3 - line 177, column 80: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap(dictFunctor)(g); | |
| }; | |
| }; | |
| // | Drop elements from the front of a list while a predicate holds. | |
| var dropWhile = function (dictApplicative) { | |
| return function (f) { | |
| var g = function (v) { | |
| if (v instanceof Yield) { | |
| var $156 = f(v.value0); | |
| if ($156) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(dropWhile(dictApplicative)(f))(v.value1)); | |
| }; | |
| return new Yield(v.value0, v.value1); | |
| }; | |
| if (v instanceof Skip) { | |
| return Skip.create(Data_Functor.map(Data_Lazy.functorLazy)(dropWhile(dictApplicative)(f))(v.value0)); | |
| }; | |
| if (v instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 170, column 3 - line 170, column 70: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap((dictApplicative.Apply0()).Functor0())(g); | |
| }; | |
| }; | |
| // | Drop a number of elements from the front of a list. | |
| var drop = function (dictApplicative) { | |
| return function (v) { | |
| return function (fa) { | |
| if (v === 0) { | |
| return fa; | |
| }; | |
| var f = function (v1) { | |
| if (v1 instanceof Yield) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(drop(dictApplicative)(v - 1 | 0))(v1.value1)); | |
| }; | |
| if (v1 instanceof Skip) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(drop(dictApplicative)(v))(v1.value0)); | |
| }; | |
| if (v1 instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 163, column 3 - line 163, column 44: " + [ v1.constructor.name ]); | |
| }; | |
| return stepMap((dictApplicative.Apply0()).Functor0())(f)(fa); | |
| }; | |
| }; | |
| }; | |
| // | Attach an element to the front of a list. | |
| var cons = function (dictApplicative) { | |
| return function (lh) { | |
| return function (t) { | |
| return ListT(Control_Applicative.pure(dictApplicative)(new Yield(Data_Lazy.force(lh), t))); | |
| }; | |
| }; | |
| }; | |
| var unfoldableListT = function (dictMonad) { | |
| return new Data_Unfoldable.Unfoldable(function (f) { | |
| return function (b) { | |
| var go = function (v) { | |
| if (v instanceof Data_Maybe.Nothing) { | |
| return nil(dictMonad.Applicative0()); | |
| }; | |
| if (v instanceof Data_Maybe.Just) { | |
| return cons(dictMonad.Applicative0())(Control_Applicative.pure(Data_Lazy.applicativeLazy)(v.value0.value0))(Data_Lazy.defer(function (v1) { | |
| return go(f(v.value0.value1)); | |
| })); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 287, column 11 - line 287, column 27: " + [ v.constructor.name ]); | |
| }; | |
| return go(f(b)); | |
| }; | |
| }); | |
| }; | |
| var semigroupListT = function (dictApplicative) { | |
| return new Data_Semigroup.Semigroup(concat(dictApplicative)); | |
| }; | |
| // | Append one list to another. | |
| var concat = function (dictApplicative) { | |
| return function (x) { | |
| return function (y) { | |
| var f = function (v) { | |
| if (v instanceof Yield) { | |
| return new Yield(v.value0, Data_Functor.map(Data_Lazy.functorLazy)(function (v1) { | |
| return Data_Semigroup.append(semigroupListT(dictApplicative))(v1)(y); | |
| })(v.value1)); | |
| }; | |
| if (v instanceof Skip) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(function (v1) { | |
| return Data_Semigroup.append(semigroupListT(dictApplicative))(v1)(y); | |
| })(v.value0)); | |
| }; | |
| if (v instanceof Done) { | |
| return new Skip(Data_Lazy.defer(Data_Function["const"](y))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 107, column 3 - line 107, column 43: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap((dictApplicative.Apply0()).Functor0())(f)(x); | |
| }; | |
| }; | |
| }; | |
| var monoidListT = function (dictApplicative) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupListT(dictApplicative); | |
| }, nil(dictApplicative)); | |
| }; | |
| // | Remove elements from a list which do not contain a value. | |
| var catMaybes = function (dictFunctor) { | |
| return mapMaybe(dictFunctor)(Control_Category.id(Control_Category.categoryFn)); | |
| }; | |
| var monadListT = function (dictMonad) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeListT(dictMonad); | |
| }, function () { | |
| return bindListT(dictMonad); | |
| }); | |
| }; | |
| var bindListT = function (dictMonad) { | |
| return new Control_Bind.Bind(function () { | |
| return applyListT(dictMonad); | |
| }, function (fa) { | |
| return function (f) { | |
| var g = function (v) { | |
| if (v instanceof Yield) { | |
| var h = function (s$prime) { | |
| return Data_Semigroup.append(semigroupListT(dictMonad.Applicative0()))(f(v.value0))(Control_Bind.bind(bindListT(dictMonad))(s$prime)(f)); | |
| }; | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(h)(v.value1)); | |
| }; | |
| if (v instanceof Skip) { | |
| return new Skip(Data_Functor.map(Data_Lazy.functorLazy)(function (v1) { | |
| return Control_Bind.bind(bindListT(dictMonad))(v1)(f); | |
| })(v.value0)); | |
| }; | |
| if (v instanceof Done) { | |
| return Done.value; | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.List.Trans line 298, column 5 - line 300, column 31: " + [ v.constructor.name ]); | |
| }; | |
| return stepMap(((dictMonad.Bind1()).Apply0()).Functor0())(g)(fa); | |
| }; | |
| }); | |
| }; | |
| var applyListT = function (dictMonad) { | |
| return new Control_Apply.Apply(function () { | |
| return functorListT(((dictMonad.Bind1()).Apply0()).Functor0()); | |
| }, Control_Monad.ap(monadListT(dictMonad))); | |
| }; | |
| var applicativeListT = function (dictMonad) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyListT(dictMonad); | |
| }, singleton(dictMonad.Applicative0())); | |
| }; | |
| var monadEffListT = function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadListT(dictMonadEff.Monad0()); | |
| }, function ($179) { | |
| return Control_Monad_Trans_Class.lift(monadTransListT)(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($179)); | |
| }); | |
| }; | |
| var altListT = function (dictApplicative) { | |
| return new Control_Alt.Alt(function () { | |
| return functorListT((dictApplicative.Apply0()).Functor0()); | |
| }, concat(dictApplicative)); | |
| }; | |
| var plusListT = function (dictMonad) { | |
| return new Control_Plus.Plus(function () { | |
| return altListT(dictMonad.Applicative0()); | |
| }, nil(dictMonad.Applicative0())); | |
| }; | |
| var alternativeListT = function (dictMonad) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeListT(dictMonad); | |
| }, function () { | |
| return plusListT(dictMonad); | |
| }); | |
| }; | |
| var monadZeroListT = function (dictMonad) { | |
| return new Control_MonadZero.MonadZero(function () { | |
| return alternativeListT(dictMonad); | |
| }, function () { | |
| return monadListT(dictMonad); | |
| }); | |
| }; | |
| var monadPlusListT = function (dictMonad) { | |
| return new Control_MonadPlus.MonadPlus(function () { | |
| return monadZeroListT(dictMonad); | |
| }); | |
| }; | |
| exports["ListT"] = ListT; | |
| exports["Yield"] = Yield; | |
| exports["Skip"] = Skip; | |
| exports["Done"] = Done; | |
| exports["catMaybes"] = catMaybes; | |
| exports["cons"] = cons; | |
| exports["drop"] = drop; | |
| exports["dropWhile"] = dropWhile; | |
| exports["filter"] = filter; | |
| exports["foldl"] = foldl; | |
| exports["foldl'"] = foldl$prime; | |
| exports["foldlRec"] = foldlRec; | |
| exports["foldlRec'"] = foldlRec$prime; | |
| exports["fromEffect"] = fromEffect; | |
| exports["head"] = head; | |
| exports["iterate"] = iterate; | |
| exports["mapMaybe"] = mapMaybe; | |
| exports["nil"] = nil; | |
| exports["prepend"] = prepend; | |
| exports["prepend'"] = prepend$prime; | |
| exports["repeat"] = repeat; | |
| exports["runListT"] = runListT; | |
| exports["runListTRec"] = runListTRec; | |
| exports["scanl"] = scanl; | |
| exports["singleton"] = singleton; | |
| exports["tail"] = tail; | |
| exports["take"] = take; | |
| exports["takeWhile"] = takeWhile; | |
| exports["uncons"] = uncons; | |
| exports["unfold"] = unfold; | |
| exports["wrapEffect"] = wrapEffect; | |
| exports["wrapLazy"] = wrapLazy; | |
| exports["zipWith"] = zipWith; | |
| exports["zipWith'"] = zipWith$prime; | |
| exports["newtypeListT"] = newtypeListT; | |
| exports["semigroupListT"] = semigroupListT; | |
| exports["monoidListT"] = monoidListT; | |
| exports["functorListT"] = functorListT; | |
| exports["unfoldableListT"] = unfoldableListT; | |
| exports["applyListT"] = applyListT; | |
| exports["applicativeListT"] = applicativeListT; | |
| exports["bindListT"] = bindListT; | |
| exports["monadListT"] = monadListT; | |
| exports["monadTransListT"] = monadTransListT; | |
| exports["altListT"] = altListT; | |
| exports["plusListT"] = plusListT; | |
| exports["alternativeListT"] = alternativeListT; | |
| exports["monadZeroListT"] = monadZeroListT; | |
| exports["monadPlusListT"] = monadPlusListT; | |
| exports["monadEffListT"] = monadEffListT; | |
| })(PS["Control.Monad.List.Trans"] = PS["Control.Monad.List.Trans"] || {}); | |
| (function(exports) { | |
| // | This module defines the reader-writer-state monad transformer, `RWST`. | |
| "use strict"; | |
| var Control_Alt = PS["Control.Alt"]; | |
| var Control_Alternative = PS["Control.Alternative"]; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Control_Bind = PS["Control.Bind"]; | |
| var Control_Lazy = PS["Control.Lazy"]; | |
| var Control_Monad = PS["Control.Monad"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; | |
| var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; | |
| var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; | |
| var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; | |
| var Control_Plus = PS["Control.Plus"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Data_Tuple = PS["Data.Tuple"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| var Prelude = PS["Prelude"]; | |
| var RWSResult = (function () { | |
| function RWSResult(value0, value1, value2) { | |
| this.value0 = value0; | |
| this.value1 = value1; | |
| this.value2 = value2; | |
| }; | |
| RWSResult.create = function (value0) { | |
| return function (value1) { | |
| return function (value2) { | |
| return new RWSResult(value0, value1, value2); | |
| }; | |
| }; | |
| }; | |
| return RWSResult; | |
| })(); | |
| // | The reader-writer-state monad transformer, which combines the operations | |
| // | of `RWST`, `WriterT` and `StateT` into a single monad transformer. | |
| var RWST = function (x) { | |
| return x; | |
| }; | |
| // | Change the context type in a `RWST` monad action. | |
| var withRWST = function (f) { | |
| return function (m) { | |
| return function (r) { | |
| return function (s) { | |
| return Data_Tuple.uncurry(m)(f(r)(s)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Run a computation in the `RWST` monad. | |
| var runRWST = function (v) { | |
| return v; | |
| }; | |
| var newtypeRWST = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, RWST); | |
| var monadTransRWST = function (dictMonoid) { | |
| return new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { | |
| return function (m) { | |
| return function (v) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m)(function (a) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(s, a, Data_Monoid.mempty(dictMonoid))); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | Change the result and accumulator types in a `RWST` monad action. | |
| var mapRWST = function (f) { | |
| return function (v) { | |
| return function (r) { | |
| return function (s) { | |
| return f(v(r)(s)); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var lazyRWST = new Control_Lazy.Lazy(function (f) { | |
| return function (r) { | |
| return function (s) { | |
| var v = f(Data_Unit.unit); | |
| return v(r)(s); | |
| }; | |
| }; | |
| }); | |
| var functorRWST = function (dictFunctor) { | |
| return new Data_Functor.Functor(function (f) { | |
| return function (v) { | |
| return function (r) { | |
| return function (s) { | |
| return Data_Functor.map(dictFunctor)(function (v1) { | |
| return new RWSResult(v1.value0, f(v1.value1), v1.value2); | |
| })(v(r)(s)); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| // | Run a computation in the `RWST` monad, discarding the result. | |
| var execRWST = function (dictMonad) { | |
| return function (v) { | |
| return function (r) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v(r)(s))(function (v1) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value0, v1.value2)); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| // | Run a computation in the `RWST` monad, discarding the final state. | |
| var evalRWST = function (dictMonad) { | |
| return function (v) { | |
| return function (r) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(v(r)(s))(function (v1) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value1, v1.value2)); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }; | |
| var applyRWST = function (dictBind) { | |
| return function (dictMonoid) { | |
| return new Control_Apply.Apply(function () { | |
| return functorRWST((dictBind.Apply0()).Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return function (r) { | |
| return function (s) { | |
| return Control_Bind.bind(dictBind)(v(r)(s))(function (v2) { | |
| return Data_Functor.mapFlipped((dictBind.Apply0()).Functor0())(v1(r)(v2.value0))(function (v3) { | |
| return new RWSResult(v3.value0, v2.value1(v3.value1), Data_Semigroup.append(dictMonoid.Semigroup0())(v2.value2)(v3.value2)); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var bindRWST = function (dictBind) { | |
| return function (dictMonoid) { | |
| return new Control_Bind.Bind(function () { | |
| return applyRWST(dictBind)(dictMonoid); | |
| }, function (v) { | |
| return function (f) { | |
| return function (r) { | |
| return function (s) { | |
| return Control_Bind.bind(dictBind)(v(r)(s))(function (v1) { | |
| var v2 = f(v1.value1); | |
| return Data_Functor.mapFlipped((dictBind.Apply0()).Functor0())(v2(r)(v1.value0))(function (v3) { | |
| return new RWSResult(v3.value0, v3.value1, Data_Semigroup.append(dictMonoid.Semigroup0())(v1.value2)(v3.value2)); | |
| }); | |
| }); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var applicativeRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Applicative.Applicative(function () { | |
| return applyRWST(dictMonad.Bind1())(dictMonoid); | |
| }, function (a) { | |
| return function (v) { | |
| return function (s) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(s, a, Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Monad.Monad(function () { | |
| return applicativeRWST(dictMonad)(dictMonoid); | |
| }, function () { | |
| return bindRWST(dictMonad.Bind1())(dictMonoid); | |
| }); | |
| }; | |
| }; | |
| var monadAskRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Reader_Class.MonadAsk(function () { | |
| return monadRWST(dictMonad)(dictMonoid); | |
| }, function (r) { | |
| return function (s) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(s, r, Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadReaderRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Reader_Class.MonadReader(function () { | |
| return monadAskRWST(dictMonad)(dictMonoid); | |
| }, function (f) { | |
| return function (m) { | |
| return function (r) { | |
| return function (s) { | |
| return m(f(r))(s); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadEffRWS = function (dictMonoid) { | |
| return function (dictMonadEff) { | |
| return new Control_Monad_Eff_Class.MonadEff(function () { | |
| return monadRWST(dictMonadEff.Monad0())(dictMonoid); | |
| }, function ($155) { | |
| return Control_Monad_Trans_Class.lift(monadTransRWST(dictMonoid))(dictMonadEff.Monad0())(Control_Monad_Eff_Class.liftEff(dictMonadEff)($155)); | |
| }); | |
| }; | |
| }; | |
| var monadRecRWST = function (dictMonadRec) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Rec_Class.MonadRec(function () { | |
| return monadRWST(dictMonadRec.Monad0())(dictMonoid); | |
| }, function (k) { | |
| return function (a) { | |
| var k$prime = function (r) { | |
| return function (v) { | |
| var v1 = k(v.value1); | |
| return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(v1(r)(v.value0))(function (v2) { | |
| return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())((function () { | |
| if (v2.value1 instanceof Control_Monad_Rec_Class.Loop) { | |
| return new Control_Monad_Rec_Class.Loop(new RWSResult(v2.value0, v2.value1.value0, Data_Semigroup.append(dictMonoid.Semigroup0())(v.value2)(v2.value2))); | |
| }; | |
| if (v2.value1 instanceof Control_Monad_Rec_Class.Done) { | |
| return new Control_Monad_Rec_Class.Done(new RWSResult(v2.value0, v2.value1.value0, Data_Semigroup.append(dictMonoid.Semigroup0())(v.value2)(v2.value2))); | |
| }; | |
| throw new Error("Failed pattern match at Control.Monad.RWS.Trans line 129, column 16 - line 131, column 68: " + [ v2.value1.constructor.name ]); | |
| })()); | |
| }); | |
| }; | |
| }; | |
| return function (r) { | |
| return function (s) { | |
| return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(k$prime(r))(new RWSResult(s, a, Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadStateRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_State_Class.MonadState(function () { | |
| return monadRWST(dictMonad)(dictMonoid); | |
| }, function (f) { | |
| return function (v) { | |
| return function (s) { | |
| var v1 = f(s); | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(v1.value1, v1.value0, Data_Monoid.mempty(dictMonoid))); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadTellRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Writer_Class.MonadTell(function () { | |
| return monadRWST(dictMonad)(dictMonoid); | |
| }, function (w) { | |
| return function (v) { | |
| return function (s) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(s, Data_Unit.unit, w)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadWriterRWST = function (dictMonad) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Writer_Class.MonadWriter(function () { | |
| return monadTellRWST(dictMonad)(dictMonoid); | |
| }, function (m) { | |
| return function (r) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m(r)(s))(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(v.value0, new Data_Tuple.Tuple(v.value1, v.value2), v.value2)); | |
| }); | |
| }; | |
| }; | |
| }, function (m) { | |
| return function (r) { | |
| return function (s) { | |
| return Control_Bind.bind(dictMonad.Bind1())(m(r)(s))(function (v) { | |
| return Control_Applicative.pure(dictMonad.Applicative0())(new RWSResult(v.value0, v.value1.value0, v.value1.value1(v.value2))); | |
| }); | |
| }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| var monadThrowRWST = function (dictMonadThrow) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Error_Class.MonadThrow(function () { | |
| return monadRWST(dictMonadThrow.Monad0())(dictMonoid); | |
| }, function (e) { | |
| return Control_Monad_Trans_Class.lift(monadTransRWST(dictMonoid))(dictMonadThrow.Monad0())(Control_Monad_Error_Class.throwError(dictMonadThrow)(e)); | |
| }); | |
| }; | |
| }; | |
| var monadErrorRWST = function (dictMonadError) { | |
| return function (dictMonoid) { | |
| return new Control_Monad_Error_Class.MonadError(function () { | |
| return monadThrowRWST(dictMonadError.MonadThrow0())(dictMonoid); | |
| }, function (m) { | |
| return function (h) { | |
| return RWST(function (r) { | |
| return function (s) { | |
| return Control_Monad_Error_Class.catchError(dictMonadError)(m(r)(s))(function (e) { | |
| var v = h(e); | |
| return v(r)(s); | |
| }); | |
| }; | |
| }); | |
| }; | |
| }); | |
| }; | |
| }; | |
| var altRWST = function (dictAlt) { | |
| return new Control_Alt.Alt(function () { | |
| return functorRWST(dictAlt.Functor0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return RWST(function (r) { | |
| return function (s) { | |
| return Control_Alt.alt(dictAlt)(v(r)(s))(v1(r)(s)); | |
| }; | |
| }); | |
| }; | |
| }); | |
| }; | |
| var plusRWST = function (dictPlus) { | |
| return new Control_Plus.Plus(function () { | |
| return altRWST(dictPlus.Alt0()); | |
| }, function (v) { | |
| return function (v1) { | |
| return Control_Plus.empty(dictPlus); | |
| }; | |
| }); | |
| }; | |
| var alternativeRWST = function (dictMonoid) { | |
| return function (dictAlternative) { | |
| return function (dictMonad) { | |
| return new Control_Alternative.Alternative(function () { | |
| return applicativeRWST(dictMonad)(dictMonoid); | |
| }, function () { | |
| return plusRWST(dictAlternative.Plus1()); | |
| }); | |
| }; | |
| }; | |
| }; | |
| exports["RWSResult"] = RWSResult; | |
| exports["RWST"] = RWST; | |
| exports["evalRWST"] = evalRWST; | |
| exports["execRWST"] = execRWST; | |
| exports["mapRWST"] = mapRWST; | |
| exports["runRWST"] = runRWST; | |
| exports["withRWST"] = withRWST; | |
| exports["newtypeRWST"] = newtypeRWST; | |
| exports["functorRWST"] = functorRWST; | |
| exports["applyRWST"] = applyRWST; | |
| exports["altRWST"] = altRWST; | |
| exports["alternativeRWST"] = alternativeRWST; | |
| exports["bindRWST"] = bindRWST; | |
| exports["applicativeRWST"] = applicativeRWST; | |
| exports["monadRWST"] = monadRWST; | |
| exports["monadTransRWST"] = monadTransRWST; | |
| exports["lazyRWST"] = lazyRWST; | |
| exports["monadEffRWS"] = monadEffRWS; | |
| exports["monadAskRWST"] = monadAskRWST; | |
| exports["monadReaderRWST"] = monadReaderRWST; | |
| exports["monadStateRWST"] = monadStateRWST; | |
| exports["monadTellRWST"] = monadTellRWST; | |
| exports["monadWriterRWST"] = monadWriterRWST; | |
| exports["monadThrowRWST"] = monadThrowRWST; | |
| exports["monadErrorRWST"] = monadErrorRWST; | |
| exports["monadRecRWST"] = monadRecRWST; | |
| exports["plusRWST"] = plusRWST; | |
| })(PS["Control.Monad.RWS.Trans"] = PS["Control.Monad.RWS.Trans"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Category = PS["Control.Category"]; | |
| var Control_Monad_Aff = PS["Control.Monad.Aff"]; | |
| var Control_Monad_Cont_Trans = PS["Control.Monad.Cont.Trans"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; | |
| var Control_Monad_List_Trans = PS["Control.Monad.List.Trans"]; | |
| var Control_Monad_Maybe_Trans = PS["Control.Monad.Maybe.Trans"]; | |
| var Control_Monad_RWS_Trans = PS["Control.Monad.RWS.Trans"]; | |
| var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; | |
| var Control_Monad_State_Trans = PS["Control.Monad.State.Trans"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Prelude = PS["Prelude"]; | |
| var MonadAff = function (MonadEff0, liftAff) { | |
| this.MonadEff0 = MonadEff0; | |
| this.liftAff = liftAff; | |
| }; | |
| var monadAffAff = new MonadAff(function () { | |
| return Control_Monad_Aff.monadEffAff; | |
| }, Control_Category.id(Control_Category.categoryFn)); | |
| var liftAff = function (dict) { | |
| return dict.liftAff; | |
| }; | |
| var monadAffContT = function (dictMonadAff) { | |
| return new MonadAff(function () { | |
| return Control_Monad_Cont_Trans.monadEffContT(dictMonadAff.MonadEff0()); | |
| }, function ($10) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_Cont_Trans.monadTransContT)((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($10)); | |
| }); | |
| }; | |
| var monadAffExceptT = function (dictMonadAff) { | |
| return new MonadAff(function () { | |
| return Control_Monad_Except_Trans.monadEffExceptT(dictMonadAff.MonadEff0()); | |
| }, function ($11) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_Except_Trans.monadTransExceptT)((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($11)); | |
| }); | |
| }; | |
| var monadAffListT = function (dictMonadAff) { | |
| return new MonadAff(function () { | |
| return Control_Monad_List_Trans.monadEffListT(dictMonadAff.MonadEff0()); | |
| }, function ($12) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_List_Trans.monadTransListT)((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($12)); | |
| }); | |
| }; | |
| var monadAffMaybe = function (dictMonadAff) { | |
| return new MonadAff(function () { | |
| return Control_Monad_Maybe_Trans.monadEffMaybe(dictMonadAff.MonadEff0()); | |
| }, function ($13) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_Maybe_Trans.monadTransMaybeT)((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($13)); | |
| }); | |
| }; | |
| var monadAffRWS = function (dictMonadAff) { | |
| return function (dictMonoid) { | |
| return new MonadAff(function () { | |
| return Control_Monad_RWS_Trans.monadEffRWS(dictMonoid)(dictMonadAff.MonadEff0()); | |
| }, function ($14) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_RWS_Trans.monadTransRWST(dictMonoid))((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($14)); | |
| }); | |
| }; | |
| }; | |
| var monadAffReader = function (dictMonadAff) { | |
| return new MonadAff(function () { | |
| return Control_Monad_Reader_Trans.monadEffReader(dictMonadAff.MonadEff0()); | |
| }, function ($15) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_Reader_Trans.monadTransReaderT)((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($15)); | |
| }); | |
| }; | |
| var monadAffState = function (dictMonadAff) { | |
| return new MonadAff(function () { | |
| return Control_Monad_State_Trans.monadEffState(dictMonadAff.MonadEff0()); | |
| }, function ($16) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_State_Trans.monadTransStateT)((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($16)); | |
| }); | |
| }; | |
| var monadAffWriter = function (dictMonadAff) { | |
| return function (dictMonoid) { | |
| return new MonadAff(function () { | |
| return Control_Monad_Writer_Trans.monadEffWriter(dictMonoid)(dictMonadAff.MonadEff0()); | |
| }, function ($17) { | |
| return Control_Monad_Trans_Class.lift(Control_Monad_Writer_Trans.monadTransWriterT(dictMonoid))((dictMonadAff.MonadEff0()).Monad0())(liftAff(dictMonadAff)($17)); | |
| }); | |
| }; | |
| }; | |
| exports["MonadAff"] = MonadAff; | |
| exports["liftAff"] = liftAff; | |
| exports["monadAffAff"] = monadAffAff; | |
| exports["monadAffContT"] = monadAffContT; | |
| exports["monadAffExceptT"] = monadAffExceptT; | |
| exports["monadAffListT"] = monadAffListT; | |
| exports["monadAffMaybe"] = monadAffMaybe; | |
| exports["monadAffReader"] = monadAffReader; | |
| exports["monadAffRWS"] = monadAffRWS; | |
| exports["monadAffState"] = monadAffState; | |
| exports["monadAffWriter"] = monadAffWriter; | |
| })(PS["Control.Monad.Aff.Class"] = PS["Control.Monad.Aff.Class"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.log = function (s) { | |
| return function () { | |
| console.log(s); | |
| return {}; | |
| }; | |
| }; | |
| exports.warn = function (s) { | |
| return function () { | |
| console.warn(s); | |
| return {}; | |
| }; | |
| }; | |
| exports.error = function (s) { | |
| return function () { | |
| console.error(s); | |
| return {}; | |
| }; | |
| }; | |
| exports.info = function (s) { | |
| return function () { | |
| console.info(s); | |
| return {}; | |
| }; | |
| }; | |
| })(PS["Control.Monad.Eff.Console"] = PS["Control.Monad.Eff.Console"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Eff.Console"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Data_Show = PS["Data.Show"]; | |
| var Data_Unit = PS["Data.Unit"]; | |
| // | Write an warning value to the console, using its `Show` instance to produce | |
| // | a `String`. | |
| var warnShow = function (dictShow) { | |
| return function (a) { | |
| return $foreign.warn(Data_Show.show(dictShow)(a)); | |
| }; | |
| }; | |
| // | Write a value to the console, using its `Show` instance to produce a | |
| // | `String`. | |
| var logShow = function (dictShow) { | |
| return function (a) { | |
| return $foreign.log(Data_Show.show(dictShow)(a)); | |
| }; | |
| }; | |
| // | Write an info value to the console, using its `Show` instance to produce a | |
| // | `String`. | |
| var infoShow = function (dictShow) { | |
| return function (a) { | |
| return $foreign.info(Data_Show.show(dictShow)(a)); | |
| }; | |
| }; | |
| // | Write an error value to the console, using its `Show` instance to produce a | |
| // | `String`. | |
| var errorShow = function (dictShow) { | |
| return function (a) { | |
| return $foreign.error(Data_Show.show(dictShow)(a)); | |
| }; | |
| }; | |
| exports["errorShow"] = errorShow; | |
| exports["infoShow"] = infoShow; | |
| exports["logShow"] = logShow; | |
| exports["warnShow"] = warnShow; | |
| exports["error"] = $foreign.error; | |
| exports["info"] = $foreign.info; | |
| exports["log"] = $foreign.log; | |
| exports["warn"] = $foreign.warn; | |
| })(PS["Control.Monad.Eff.Console"] = PS["Control.Monad.Eff.Console"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Monad_Aff = PS["Control.Monad.Aff"]; | |
| var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; | |
| var Control_Monad_Eff_Console = PS["Control.Monad.Eff.Console"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Write a warning value to the console, using its `Show` instance to produce | |
| // | a `String`. Shorthand for `liftEff $ warnShow x`. | |
| var warnShow = function (dictShow) { | |
| return function ($4) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.warnShow(dictShow)($4)); | |
| }; | |
| }; | |
| // | Write a warning to the console. Shorthand for `liftEff $ warn x`. | |
| var warn = function ($5) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.warn($5)); | |
| }; | |
| // | Write a value to the console, using its `Show` instance to produce a | |
| // | `String`. Shorthand for `liftEff $ logShow x`. | |
| var logShow = function (dictShow) { | |
| return function ($6) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.logShow(dictShow)($6)); | |
| }; | |
| }; | |
| // | Write a message to the console. Shorthand for `liftEff $ log x`. | |
| var log = function ($7) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.log($7)); | |
| }; | |
| // | Write an info value to the console, using its `Show` instance to produce a | |
| // | `String`. Shorthand for `liftEff $ infoShow x`. | |
| var infoShow = function (dictShow) { | |
| return function ($8) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.infoShow(dictShow)($8)); | |
| }; | |
| }; | |
| // | Write an info message to the console. Shorthand for `liftEff $ info x`. | |
| var info = function ($9) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.info($9)); | |
| }; | |
| // | Write an error value to the console, using its `Show` instance to produce a | |
| // | `String`. Shorthand for `liftEff $ errorShow x`. | |
| var errorShow = function (dictShow) { | |
| return function ($10) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.errorShow(dictShow)($10)); | |
| }; | |
| }; | |
| // | Write an error to the console. Shorthand for `liftEff $ error x`. | |
| var error = function ($11) { | |
| return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Console.error($11)); | |
| }; | |
| exports["error"] = error; | |
| exports["errorShow"] = errorShow; | |
| exports["info"] = info; | |
| exports["infoShow"] = infoShow; | |
| exports["log"] = log; | |
| exports["logShow"] = logShow; | |
| exports["warn"] = warn; | |
| exports["warnShow"] = warnShow; | |
| })(PS["Control.Monad.Aff.Console"] = PS["Control.Monad.Aff.Console"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Monad_Aff = PS["Control.Monad.Aff"]; | |
| var Unsafe_Coerce = PS["Unsafe.Coerce"]; | |
| var unsafeCoerceAff = Unsafe_Coerce.unsafeCoerce; | |
| exports["unsafeCoerceAff"] = unsafeCoerceAff; | |
| })(PS["Control.Monad.Aff.Unsafe"] = PS["Control.Monad.Aff.Unsafe"] || {}); | |
| (function(exports) { | |
| // | This module defines the `Cont`inuation monad. | |
| "use strict"; | |
| var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; | |
| var Control_Monad_Cont_Trans = PS["Control.Monad.Cont.Trans"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Identity = PS["Data.Identity"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Transform the continuation passed into the continuation-passing function. | |
| var withCont = function (f) { | |
| return Control_Monad_Cont_Trans.withContT(function ($0) { | |
| return function ($1) { | |
| return Data_Identity.Identity(f(function ($2) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($0($2)); | |
| })($1)); | |
| }; | |
| }); | |
| }; | |
| // | Runs a computation in the `Cont` monad. | |
| var runCont = function (cc) { | |
| return function (k) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(Control_Monad_Cont_Trans.runContT(cc)(function ($3) { | |
| return Data_Identity.Identity(k($3)); | |
| })); | |
| }; | |
| }; | |
| // | Transform the result of a continuation-passing function. | |
| var mapCont = function (f) { | |
| return Control_Monad_Cont_Trans.mapContT(function ($4) { | |
| return Data_Identity.Identity(f(Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($4))); | |
| }); | |
| }; | |
| // | Creates a computation in the `Cont` monad. | |
| var cont = function (f) { | |
| return function (c) { | |
| return f(function ($5) { | |
| return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(c($5)); | |
| }); | |
| }; | |
| }; | |
| exports["cont"] = cont; | |
| exports["runCont"] = runCont; | |
| })(PS["Control.Monad.Cont"] = PS["Control.Monad.Cont"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; | |
| var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| // | Throw an exception in pure code. This function should be used very | |
| // | sparingly, as it can cause unexpected crashes at runtime. | |
| var unsafeThrowException = function ($0) { | |
| return Control_Monad_Eff_Unsafe.unsafePerformEff(Control_Monad_Eff_Exception.throwException($0)); | |
| }; | |
| // | Defined as `unsafeThrowException <<< error`. | |
| var unsafeThrow = function ($1) { | |
| return unsafeThrowException(Control_Monad_Eff_Exception.error($1)); | |
| }; | |
| exports["unsafeThrow"] = unsafeThrow; | |
| exports["unsafeThrowException"] = unsafeThrowException; | |
| })(PS["Control.Monad.Eff.Exception.Unsafe"] = PS["Control.Monad.Eff.Exception.Unsafe"] || {}); | |
| (function(exports) { | |
| // | Unsafe functions for working with mutable references. | |
| "use strict"; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; | |
| var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; | |
| // | This handler function unsafely removes the `Ref` effect from an | |
| // | effectful action. | |
| // | | |
| // | This function might be used when it is impossible to prove to the | |
| // | typechecker that a particular mutable reference does not escape | |
| // | its scope. | |
| var unsafeRunRef = Control_Monad_Eff_Unsafe.unsafeCoerceEff; | |
| exports["unsafeRunRef"] = unsafeRunRef; | |
| })(PS["Control.Monad.Eff.Ref.Unsafe"] = PS["Control.Monad.Eff.Ref.Unsafe"] || {}); | |
| (function(exports) { | |
| "use strict"; | |
| exports.mkEffFn1 = function mkEffFn1(fn) { | |
| return function(x) { | |
| return fn(x)(); | |
| }; | |
| }; | |
| exports.mkEffFn2 = function mkEffFn2(fn) { | |
| return function(a, b) { | |
| return fn(a)(b)(); | |
| }; | |
| }; | |
| exports.mkEffFn3 = function mkEffFn3(fn) { | |
| return function(a, b, c) { | |
| return fn(a)(b)(c)(); | |
| }; | |
| }; | |
| exports.mkEffFn4 = function mkEffFn4(fn) { | |
| return function(a, b, c, d) { | |
| return fn(a)(b)(c)(d)(); | |
| }; | |
| }; | |
| exports.mkEffFn5 = function mkEffFn5(fn) { | |
| return function(a, b, c, d, e) { | |
| return fn(a)(b)(c)(d)(e)(); | |
| }; | |
| }; | |
| exports.mkEffFn6 = function mkEffFn6(fn) { | |
| return function(a, b, c, d, e, f) { | |
| return fn(a)(b)(c)(d)(e)(f)(); | |
| }; | |
| }; | |
| exports.mkEffFn7 = function mkEffFn7(fn) { | |
| return function(a, b, c, d, e, f, g) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(); | |
| }; | |
| }; | |
| exports.mkEffFn8 = function mkEffFn8(fn) { | |
| return function(a, b, c, d, e, f, g, h) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(h)(); | |
| }; | |
| }; | |
| exports.mkEffFn9 = function mkEffFn9(fn) { | |
| return function(a, b, c, d, e, f, g, h, i) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(); | |
| }; | |
| }; | |
| exports.mkEffFn10 = function mkEffFn10(fn) { | |
| return function(a, b, c, d, e, f, g, h, i, j) { | |
| return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(); | |
| }; | |
| }; | |
| exports.runEffFn1 = function runEffFn1(fn) { | |
| return function(a) { | |
| return function() { | |
| return fn(a); | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn2 = function runEffFn2(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function() { | |
| return fn(a, b); | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn3 = function runEffFn3(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function(c) { | |
| return function() { | |
| return fn(a, b, c); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn4 = function runEffFn4(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function(c) { | |
| return function(d) { | |
| return function() { | |
| return fn(a, b, c, d); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn5 = function runEffFn5(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function(c) { | |
| return function(d) { | |
| return function(e) { | |
| return function() { | |
| return fn(a, b, c, d, e); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn6 = function runEffFn6(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function(c) { | |
| return function(d) { | |
| return function(e) { | |
| return function(f) { | |
| return function() { | |
| return fn(a, b, c, d, e, f); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn7 = function runEffFn7(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function(c) { | |
| return function(d) { | |
| return function(e) { | |
| return function(f) { | |
| return function(g) { | |
| return function() { | |
| return fn(a, b, c, d, e, f, g); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn8 = function runEffFn8(fn) { | |
| return function(a) { | |
| return function(b) { | |
| return function(c) { | |
| return function(d) { | |
| return function(e) { | |
| return function(f) { | |
| return function(g) { | |
| return function(h) { | |
| return function() { | |
| return fn(a, b, c, d, e, f, g, h); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn9 = function runEffFn9(fn) { | |
| return function(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 function() { | |
| return fn(a, b, c, d, e, f, g, h, i); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| exports.runEffFn10 = function runEffFn10(fn) { | |
| return function(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 function(j) { | |
| return function() { | |
| return fn(a, b, c, d, e, f, g, h, i, j); | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| }; | |
| })(PS["Control.Monad.Eff.Uncurried"] = PS["Control.Monad.Eff.Uncurried"] || {}); | |
| (function(exports) { | |
| // | This module defines types for effectful uncurried functions, as well as | |
| // | functions for converting back and forth between them. | |
| // | | |
| // | Traditionally, it has been difficult to give a PureScript type to | |
| // | JavaScript functions such as this one: | |
| // | | |
| // | ```javascript | |
| // | function logMessage(level, message) { | |
| // | console.log(level + ": " + message); | |
| // | } | |
| // | ``` | |
| // | | |
| // | In particular, note that `logMessage` performs effects immediately after | |
| // | receiving all of its parameters, so giving it the type `Data.Function.Fn2 | |
| // | String String Unit`, while convenient, would effectively be a lie. | |
| // | | |
| // | Because there has been no way of giving such functions types, we generally | |
| // | resort to converting functions into the normal PureScript form (namely, | |
| // | a curried function returning an Eff action), and performing the | |
| // | marshalling in JavaScript, in the FFI module, like this: | |
| // | | |
| // | ```purescript | |
| // | -- In the PureScript file: | |
| // | foreign import logMessage :: forall eff. | |
| // | String -> String -> Eff (console :: CONSOLE | eff) Unit | |
| // | ``` | |
| // | | |
| // | ```javascript | |
| // | // In the FFI file: | |
| // | exports.logMessage = function(level) { | |
| // | return function(message) { | |
| // | return function() { | |
| // | logMessage(level, message); | |
| // | }; | |
| // | }; | |
| // | }; | |
| // | ``` | |
| // | | |
| // | This method, unfortunately, turns out to be both tiresome and error-prone. | |
| // | This module offers an alternative solution. By providing you with: | |
| // | | |
| // | * the ability to give the real `logMessage` function a PureScript type, | |
| // | and | |
| // | * functions for converting between this form and the normal PureScript | |
| // | form, | |
| // | | |
| // | the FFI boilerplate is no longer needed. The previous example becomes: | |
| // | | |
| // | ```purescript | |
| // | -- In the PureScript file: | |
| // | foreign import logMessageImpl :: forall eff. | |
| // | EffFn2 (console :: CONSOLE | eff) String String Unit | |
| // | ``` | |
| // | | |
| // | ```javascript | |
| // | // In the FFI file: | |
| // | exports.logMessageImpl = logMessage | |
| // | ``` | |
| // | | |
| // | You can then use `runEffFn2` to provide a nicer version: | |
| // | | |
| // | ```purescript | |
| // | logMessage :: forall eff. | |
| // | String -> String -> Eff (console :: CONSOLE | eff) Unit | |
| // | logMessage = runEffFn2 logMessageImpl | |
| // | ``` | |
| // | | |
| // | (note that this has the same type as the original `logMessage`). | |
| // | | |
| // | Effectively, we have reduced the risk of errors by moving as much code | |
| // | into PureScript as possible, so that we can leverage the type system. | |
| // | Hopefully, this is a little less tiresome too. | |
| // | | |
| // | Here's a slightly more advanced example. Here, because we are using | |
| // | callbacks, we need to use `mkEffFn{N}` as well. | |
| // | | |
| // | Suppose our `logMessage` changes so that it sometimes sends details of the | |
| // | message to some external server, and in those cases, we want the resulting | |
| // | `HttpResponse` (for whatever reason). | |
| // | | |
| // | ```javascript | |
| // | function logMessage(level, message, callback) { | |
| // | console.log(level + ": " + message); | |
| // | if (level > LogLevel.WARN) { | |
| // | LogAggregatorService.post("/logs", { | |
| // | level: level, | |
| // | message: message | |
| // | }, callback); | |
| // | } else { | |
| // | callback(null); | |
| // | } | |
| // | } | |
| // | ``` | |
| // | | |
| // | The import then looks like this: | |
| // | ```purescript | |
| // | foreign import logMessageImpl :: forall eff. | |
| // | EffFn3 (http :: HTTP, console :: CONSOLE | eff) | |
| // | String | |
| // | String | |
| // | (EffFn1 (http :: HTTP, console :: CONSOLE | eff) | |
| // | (Nullable HttpResponse) | |
| // | Unit) | |
| // | Unit | |
| // | ``` | |
| // | | |
| // | And, as before, the FFI file is extremely simple: | |
| // | | |
| // | ```javascript | |
| // | exports.logMessageImpl = logMessage | |
| // | ``` | |
| // | | |
| // | Finally, we use `runEffFn{N}` and `mkEffFn{N}` for a more comfortable | |
| // | PureScript version: | |
| // | | |
| // | ```purescript | |
| // | logMessage :: forall eff. | |
| // | String -> | |
| // | String -> | |
| // | (Nullable HttpResponse -> Eff (http :: HTTP, console :: CONSOLE | eff) Unit) -> | |
| // | Eff (http :: HTTP, console :: CONSOLE | eff) Unit | |
| // | logMessage level message callback = | |
| // | runEffFn3 logMessageImpl level message (mkEffFn1 callback) | |
| // | ``` | |
| // | | |
| // | The general naming scheme for functions and types in this module is as | |
| // | follows: | |
| // | | |
| // | * `EffFn{N}` means, a curried function which accepts N arguments and | |
| // | performs some effects. The first type argument is the row of effects, | |
| // | which works exactly the same way as in `Eff`. The last type argument | |
| // | is the return type. All other arguments are the actual function's | |
| // | arguments. | |
| // | * `runEffFn{N}` takes an `EffFn` of N arguments, and converts it into the | |
| // | normal PureScript form: a curried function which returns an Eff action. | |
| // | * `mkEffFn{N}` is the inverse of `runEffFn{N}`. It can be useful for | |
| // | callbacks. | |
| // | | |
| "use strict"; | |
| var $foreign = PS["Control.Monad.Eff.Uncurried"]; | |
| var Control_Monad_Eff = PS["Control.Monad.Eff"]; | |
| exports["mkEffFn1"] = $foreign.mkEffFn1; | |
| exports["mkEffFn10"] = $foreign.mkEffFn10; | |
| exports["mkEffFn2"] = $foreign.mkEffFn2; | |
| exports["mkEffFn3"] = $foreign.mkEffFn3; | |
| exports["mkEffFn4"] = $foreign.mkEffFn4; | |
| exports["mkEffFn5"] = $foreign.mkEffFn5; | |
| exports["mkEffFn6"] = $foreign.mkEffFn6; | |
| exports["mkEffFn7"] = $foreign.mkEffFn7; | |
| exports["mkEffFn8"] = $foreign.mkEffFn8; | |
| exports["mkEffFn9"] = $foreign.mkEffFn9; | |
| exports["runEffFn1"] = $foreign.runEffFn1; | |
| exports["runEffFn10"] = $foreign.runEffFn10; | |
| exports["runEffFn2"] = $foreign.runEffFn2; | |
| exports["runEffFn3"] = $foreign.runEffFn3; | |
| exports["runEffFn4"] = $foreign.runEffFn4; | |
| exports["runEffFn5"] = $foreign.runEffFn5; | |
| exports["runEffFn6"] = $foreign.runEffFn6; | |
| exports["runEffFn7"] = $foreign.runEffFn7; | |
| exports["runEffFn8"] = $foreign.runEffFn8; | |
| exports["runEffFn9"] = $foreign.runEffFn9; | |
| })(PS["Control.Monad.Eff.Uncurried"] = PS["Control.Monad.Eff.Uncurried"] || {}); | |
| (function(exports) { | |
| /** | |
| * | |
| * Copyright 2016 SlamData, Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| "use strict"; | |
| var Control_Applicative = PS["Control.Applicative"]; | |
| var Control_Apply = PS["Control.Apply"]; | |
| var Data_Function = PS["Data.Function"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; | |
| var Data_Monoid = PS["Data.Monoid"]; | |
| var Data_Newtype = PS["Data.Newtype"]; | |
| var Data_Semigroup = PS["Data.Semigroup"]; | |
| var Prelude = PS["Prelude"]; | |
| // | Semigroup (and monoid) for combining cancel functions produced by `fork`. | |
| var Canceler = function (x) { | |
| return x; | |
| }; | |
| var semigroupCanceler = function (dictApply) { | |
| return new Data_Semigroup.Semigroup(function (v) { | |
| return function (v1) { | |
| return function (e) { | |
| return Control_Apply.apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_HeytingAlgebra.disj(Data_HeytingAlgebra.heytingAlgebraBoolean))(v(e)))(v1(e)); | |
| }; | |
| }; | |
| }); | |
| }; | |
| var newtypeCanceler = new Data_Newtype.Newtype(function (n) { | |
| return n; | |
| }, Canceler); | |
| var monoidCanceler = function (dictApplicative) { | |
| return new Data_Monoid.Monoid(function () { | |
| return semigroupCanceler(dictApplicative.Apply0()); | |
| }, Data_Function["const"](Control_Applicative.pure(dictApplicative)(false))); | |
| }; | |
| var cancel = function (v) { | |
| return v; | |
| }; | |
| exports["Canceler"] = Canceler; | |
| exports["cancel"] = cancel; | |
| exports["newtypeCanceler"] = newtypeCanceler; | |
| exports["semigroupCanceler"] = semigroupCanceler; | |
| exports["monoidCanceler"] = monoidCanceler; | |
| })(PS["Control.Monad.Fork.Canceler"] = PS["Control.Monad.Fork.Canceler"] || {}); | |
| (function(exports) { | |
| /** | |
| * | |
| * Copyright 2016 SlamData, Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| "use strict"; | |
| var Control_Monad_Aff = PS["Control.Monad.Aff"]; | |
| var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; | |
| var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; | |
| var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; | |
| var Control_Semigroupoid = PS["Control.Semigroupoid"]; | |
| var Data_Functor = PS["Data.Functor"]; | |
| var Prelude = PS["Prelude"]; | |
| var MonadFork = function (Monad0, fork) { | |
| this.Monad0 = Monad0; | |
| this.fork = fork; | |
| }; | |
| var monadForkAff = new MonadFork(function () { | |
| return Control_Monad_Aff.monadAff; | |
| }, function ($3) { | |
| return Data_Functor.map(Control_Monad_Aff.functorAff)(Control_Monad_Aff.cancel)(Control_Monad_Aff.forkAff($3)); | |
| }); | |
| var fork = function (dict) { | |
| return dict.fork; | |
| }; | |
| var monadForkReaderT = function (dictMonadFork) { | |
| return new MonadFork(function () { | |
| return Control_Monad_Reader_Trans.monadReaderT(dictMonadFork.Monad0()); | |
| }, function (v) { | |
| return function (r) { | |
| return Data_Functor.map((((dictMonadFork.Monad0()).Bind1()).Apply0()).Functor0())(Data_Functor.map(Data_Functor.functorFn)(Control_Monad_Trans_Class.lift(Control_Monad_Reader_Trans.monadTransReaderT)(dictMonadFork.Monad0())))(fork(dictMonadFork)(v(r))); | |
| }; | |
| }); | |
| }; | |
| exports["MonadFork"] = MonadFork; | |
| exports["fork"] = fork; | |
| exports["monadForkAff"] = monadForkAff; | |
| exports["m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment