git.iko.soy/rowtype-yoga/psfp
on fb93bc9 help sign in
75 lines 2.7 kB history raw
1// Generated by purs version 0.13.6
2"use strict";
3var Data_Foldable = require("../Data.Foldable/index.js");
4var Data_FunctorWithIndex = require("../Data.FunctorWithIndex/index.js");
5var Data_Monoid = require("../Data.Monoid/index.js");
6var Data_Semigroup = require("../Data.Semigroup/index.js");
7var Tuple = (function () {
8 function Tuple(value0, value1) {
9 this.value0 = value0;
10 this.value1 = value1;
11 };
12 Tuple.create = function (value0) {
13 return function (value1) {
14 return new Tuple(value0, value1);
15 };
16 };
17 return Tuple;
18})();
19var FoldableWithIndex = function (Foldable0, foldMapWithIndex, foldlWithIndex, foldrWithIndex) {
20 this.Foldable0 = Foldable0;
21 this.foldMapWithIndex = foldMapWithIndex;
22 this.foldlWithIndex = foldlWithIndex;
23 this.foldrWithIndex = foldrWithIndex;
24};
25var foldrWithIndex = function (dict) {
26 return dict.foldrWithIndex;
27};
28var foldMapWithIndexDefaultR = function (dictFoldableWithIndex) {
29 return function (dictMonoid) {
30 return function (f) {
31 return foldrWithIndex(dictFoldableWithIndex)(function (i) {
32 return function (x) {
33 return function (acc) {
34 return Data_Semigroup.append(dictMonoid.Semigroup0())(f(i)(x))(acc);
35 };
36 };
37 })(Data_Monoid.mempty(dictMonoid));
38 };
39 };
40};
41var foldableWithIndexArray = new FoldableWithIndex(function ($dollar__unused) {
42 return Data_Foldable.foldableArray;
43}, function (dictMonoid) {
44 return foldMapWithIndexDefaultR(foldableWithIndexArray)(dictMonoid);
45}, function (f) {
46 return function (z) {
47 var $166 = Data_Foldable.foldl(Data_Foldable.foldableArray)(function (y) {
48 return function (v) {
49 return f(v.value0)(y)(v.value1);
50 };
51 })(z);
52 var $167 = Data_FunctorWithIndex.mapWithIndex(Data_FunctorWithIndex.functorWithIndexArray)(Tuple.create);
53 return function ($168) {
54 return $166($167($168));
55 };
56 };
57}, function (f) {
58 return function (z) {
59 var $169 = Data_Foldable.foldr(Data_Foldable.foldableArray)(function (v) {
60 return function (y) {
61 return f(v.value0)(v.value1)(y);
62 };
63 })(z);
64 var $170 = Data_FunctorWithIndex.mapWithIndex(Data_FunctorWithIndex.functorWithIndexArray)(Tuple.create);
65 return function ($171) {
66 return $169($170($171));
67 };
68 };
69});
70module.exports = {
71 FoldableWithIndex: FoldableWithIndex,
72 foldrWithIndex: foldrWithIndex,
73 foldMapWithIndexDefaultR: foldMapWithIndexDefaultR,
74 foldableWithIndexArray: foldableWithIndexArray
75};