git.iko.soy/rowtype-yoga/psfp
on 65bcaa6 help sign in
134 lines 5.6 kB history raw
1// Generated by purs version 0.13.6
2"use strict";
3var Control_Alt = require("../Control.Alt/index.js");
4var Control_Applicative = require("../Control.Applicative/index.js");
5var Control_Apply = require("../Control.Apply/index.js");
6var Control_Bind = require("../Control.Bind/index.js");
7var Control_Monad = require("../Control.Monad/index.js");
8var Control_Monad_Error_Class = require("../Control.Monad.Error.Class/index.js");
9var Data_Either = require("../Data.Either/index.js");
10var Data_Functor = require("../Data.Functor/index.js");
11var Data_Semigroup = require("../Data.Semigroup/index.js");
12var ExceptT = function (x) {
13 return x;
14};
15var withExceptT = function (dictFunctor) {
16 return function (f) {
17 return function (v) {
18 var mapLeft = function (v1) {
19 return function (v2) {
20 if (v2 instanceof Data_Either.Right) {
21 return new Data_Either.Right(v2.value0);
22 };
23 if (v2 instanceof Data_Either.Left) {
24 return new Data_Either.Left(v1(v2.value0));
25 };
26 throw new Error("Failed pattern match at Control.Monad.Except.Trans (line 42, column 3 - line 42, column 32): " + [ v1.constructor.name, v2.constructor.name ]);
27 };
28 };
29 return ExceptT(Data_Functor.map(dictFunctor)(mapLeft(f))(v));
30 };
31 };
32};
33var runExceptT = function (v) {
34 return v;
35};
36var mapExceptT = function (f) {
37 return function (v) {
38 return f(v);
39 };
40};
41var functorExceptT = function (dictFunctor) {
42 return new Data_Functor.Functor(function (f) {
43 return mapExceptT(Data_Functor.map(dictFunctor)(Data_Functor.map(Data_Either.functorEither)(f)));
44 });
45};
46var monadExceptT = function (dictMonad) {
47 return new Control_Monad.Monad(function ($dollar__unused) {
48 return applicativeExceptT(dictMonad);
49 }, function ($dollar__unused) {
50 return bindExceptT(dictMonad);
51 });
52};
53var bindExceptT = function (dictMonad) {
54 return new Control_Bind.Bind(function ($dollar__unused) {
55 return applyExceptT(dictMonad);
56 }, function (v) {
57 return function (k) {
58 return Control_Bind.bind(dictMonad.Bind1())(v)(Data_Either.either((function () {
59 var $106 = Control_Applicative.pure(dictMonad.Applicative0());
60 return function ($107) {
61 return $106(Data_Either.Left.create($107));
62 };
63 })())(function (a) {
64 var v1 = k(a);
65 return v1;
66 }));
67 };
68 });
69};
70var applyExceptT = function (dictMonad) {
71 return new Control_Apply.Apply(function ($dollar__unused) {
72 return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0());
73 }, Control_Monad.ap(monadExceptT(dictMonad)));
74};
75var applicativeExceptT = function (dictMonad) {
76 return new Control_Applicative.Applicative(function ($dollar__unused) {
77 return applyExceptT(dictMonad);
78 }, (function () {
79 var $108 = Control_Applicative.pure(dictMonad.Applicative0());
80 return function ($109) {
81 return ExceptT($108(Data_Either.Right.create($109)));
82 };
83 })());
84};
85var monadThrowExceptT = function (dictMonad) {
86 return new Control_Monad_Error_Class.MonadThrow(function ($dollar__unused) {
87 return monadExceptT(dictMonad);
88 }, (function () {
89 var $110 = Control_Applicative.pure(dictMonad.Applicative0());
90 return function ($111) {
91 return ExceptT($110(Data_Either.Left.create($111)));
92 };
93 })());
94};
95var altExceptT = function (dictSemigroup) {
96 return function (dictMonad) {
97 return new Control_Alt.Alt(function ($dollar__unused) {
98 return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0());
99 }, function (v) {
100 return function (v1) {
101 return Control_Bind.bind(dictMonad.Bind1())(v)(function (rm) {
102 if (rm instanceof Data_Either.Right) {
103 return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(rm.value0));
104 };
105 if (rm instanceof Data_Either.Left) {
106 return Control_Bind.bind(dictMonad.Bind1())(v1)(function (rn) {
107 if (rn instanceof Data_Either.Right) {
108 return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(rn.value0));
109 };
110 if (rn instanceof Data_Either.Left) {
111 return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Left(Data_Semigroup.append(dictSemigroup)(rm.value0)(rn.value0)));
112 };
113 throw new Error("Failed pattern match at Control.Monad.Except.Trans (line 86, column 9 - line 88, column 49): " + [ rn.constructor.name ]);
114 });
115 };
116 throw new Error("Failed pattern match at Control.Monad.Except.Trans (line 82, column 5 - line 88, column 49): " + [ rm.constructor.name ]);
117 });
118 };
119 });
120 };
121};
122module.exports = {
123 ExceptT: ExceptT,
124 runExceptT: runExceptT,
125 withExceptT: withExceptT,
126 mapExceptT: mapExceptT,
127 functorExceptT: functorExceptT,
128 applyExceptT: applyExceptT,
129 applicativeExceptT: applicativeExceptT,
130 bindExceptT: bindExceptT,
131 monadExceptT: monadExceptT,
132 altExceptT: altExceptT,
133 monadThrowExceptT: monadThrowExceptT
134};