git.iko.soy/rowtype-yoga/psfp
on 659e174 help sign in
100 lines 3.3 kB history raw
1// Generated by purs version 0.13.6
2"use strict";
3var Control_Applicative = require("../Control.Applicative/index.js");
4var Control_Apply = require("../Control.Apply/index.js");
5var Control_Bind = require("../Control.Bind/index.js");
6var Control_Category = require("../Control.Category/index.js");
7var Data_Function = require("../Data.Function/index.js");
8var Data_Functor = require("../Data.Functor/index.js");
9var Nothing = (function () {
10 function Nothing() {
12 };
13 Nothing.value = new Nothing();
14 return Nothing;
15})();
16var Just = (function () {
17 function Just(value0) {
18 this.value0 = value0;
19 };
20 Just.create = function (value0) {
21 return new Just(value0);
22 };
23 return Just;
24})();
25var maybe = function (v) {
26 return function (v1) {
27 return function (v2) {
28 if (v2 instanceof Nothing) {
29 return v;
30 };
31 if (v2 instanceof Just) {
32 return v1(v2.value0);
33 };
34 throw new Error("Failed pattern match at Data.Maybe (line 217, column 1 - line 217, column 51): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
35 };
36 };
37};
38var isNothing = maybe(true)(Data_Function["const"](false));
39var isJust = maybe(false)(Data_Function["const"](true));
40var functorMaybe = new Data_Functor.Functor(function (v) {
41 return function (v1) {
42 if (v1 instanceof Just) {
43 return new Just(v(v1.value0));
44 };
45 return Nothing.value;
46 };
47});
48var fromMaybe = function (a) {
49 return maybe(a)(Control_Category.identity(Control_Category.categoryFn));
50};
51var fromJust = function (dictPartial) {
52 return function (v) {
53 if (v instanceof Just) {
54 return v.value0;
55 };
56 throw new Error("Failed pattern match at Data.Maybe (line 268, column 1 - line 268, column 46): " + [ v.constructor.name ]);
57 };
58};
59var applyMaybe = new Control_Apply.Apply(function ($dollar__unused) {
60 return functorMaybe;
61}, function (v) {
62 return function (v1) {
63 if (v instanceof Just) {
64 return Data_Functor.map(functorMaybe)(v.value0)(v1);
65 };
66 if (v instanceof Nothing) {
67 return Nothing.value;
68 };
69 throw new Error("Failed pattern match at Data.Maybe (line 67, column 1 - line 69, column 30): " + [ v.constructor.name, v1.constructor.name ]);
70 };
71});
72var bindMaybe = new Control_Bind.Bind(function ($dollar__unused) {
73 return applyMaybe;
74}, function (v) {
75 return function (v1) {
76 if (v instanceof Just) {
77 return v1(v.value0);
78 };
79 if (v instanceof Nothing) {
80 return Nothing.value;
81 };
82 throw new Error("Failed pattern match at Data.Maybe (line 125, column 1 - line 127, column 28): " + [ v.constructor.name, v1.constructor.name ]);
83 };
84});
85var applicativeMaybe = new Control_Applicative.Applicative(function ($dollar__unused) {
86 return applyMaybe;
87}, Just.create);
88module.exports = {
89 Nothing: Nothing,
90 Just: Just,
91 maybe: maybe,
92 fromMaybe: fromMaybe,
93 isJust: isJust,
94 isNothing: isNothing,
95 fromJust: fromJust,
96 functorMaybe: functorMaybe,
97 applyMaybe: applyMaybe,
98 applicativeMaybe: applicativeMaybe,
99 bindMaybe: bindMaybe
100};