mirror of
https://github.com/rowtype-yoga/ry-blocks.git
synced 2024-08-18 01:30:31 +03:00
rip (#4)
* Port Storybook * Remove extrablatt * Improve cluster * Magic Johnson * Remove mentions of Plumage And delete some unnecessary stuff * Hä * I have changed the code files * Reexports for typeahead * Bring Select back * Fix dark mode of select * Move out react-aria * Export select properly * Make select work I guess
This commit is contained in:
parent
12380cadc4
commit
8049bd80dc
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 45 KiB |
@ -1,7 +0,0 @@
|
||||
module.exports = {
|
||||
core: {
|
||||
builder: "webpack5",
|
||||
},
|
||||
stories: ["../output/**/*.Story/index.js"],
|
||||
addons: [],
|
||||
}
|
10
.storybook/main.ts
Normal file
10
.storybook/main.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { indexer } from './purescript-indexer'
|
||||
|
||||
export default {
|
||||
staticDirs: ['../assets'],
|
||||
addons: ["@storybook/addon-essentials", "@storybook/addon-interactions"],
|
||||
stories: ["../output/Story.*/index.js"],
|
||||
framework: "@storybook/react-webpack5",
|
||||
storyIndexers: [{ test: /..\/output\/.*/, indexer }],
|
||||
disableTelemetry: true,
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
import { addons } from '@storybook/addons';
|
||||
import rowtypeYogaTheme from './rowtype-yoga-theme';
|
||||
|
||||
addons.setConfig({
|
||||
theme: rowtypeYogaTheme,
|
||||
isToolshown: false,
|
||||
});
|
@ -1,2 +1,6 @@
|
||||
<link href="https://rsms.me/inter/inter.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/victormono@latest/dist/index.min.css">
|
||||
<style>
|
||||
#storybook-root {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
27
.storybook/purescript-indexer-ts.ts
Normal file
27
.storybook/purescript-indexer-ts.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { promises } from "fs"
|
||||
import { loadCsf, CsfFile, CsfOptions } from '@storybook/csf-tools';
|
||||
|
||||
export const adjustSourceForStorybook = (source: string): string => {
|
||||
// regex for var $$default = unsafeCoerce({ ... })
|
||||
// we need to remove the unsafeCoerce part so that the parser can read
|
||||
// the info about the story
|
||||
const defaultVariableRecordRegex = /^var \$\$default =[^\{]+\{((?:.*\n)+?)(^\}\);)/gm;
|
||||
// $ has a special meaning so to produce two dollar signs we need $$$$
|
||||
const replacement = "var $$$$default = { $1 };";
|
||||
return source.replace(defaultVariableRecordRegex, replacement);
|
||||
}
|
||||
|
||||
export const justLoad = async (fileName: string, opts: CsfOptions): Promise<string> => {
|
||||
const fileContent: string = await promises.readFile(fileName, 'utf-8');
|
||||
const fixedFileContent: string = adjustSourceForStorybook(fileContent);
|
||||
return fixedFileContent;
|
||||
}
|
||||
|
||||
export const indexer = async (fileName: string, opts: CsfOptions): Promise<CsfFile> => {
|
||||
console.log("File name: ", fileName);
|
||||
const fileContent: string = await promises.readFile(fileName, 'utf-8');
|
||||
const fixedFileContent: string = adjustSourceForStorybook(fileContent);
|
||||
const parseResult: CsfFile = loadCsf(fixedFileContent, { ...opts, fileName }).parse();
|
||||
parseResult._stories
|
||||
return parseResult
|
||||
}
|
11
.storybook/purescript-indexer/.gitignore
vendored
Normal file
11
.storybook/purescript-indexer/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/.pulp-cache/
|
||||
/output/
|
||||
/generated-docs/
|
||||
/.psc-package/
|
||||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago
|
||||
/dist/
|
1862
.storybook/purescript-indexer/output-es/Ansi.Codes/index.js
Normal file
1862
.storybook/purescript-indexer/output-es/Ansi.Codes/index.js
Normal file
File diff suppressed because it is too large
Load Diff
18
.storybook/purescript-indexer/output-es/Ansi.Output/index.js
Normal file
18
.storybook/purescript-indexer/output-es/Ansi.Output/index.js
Normal file
@ -0,0 +1,18 @@
|
||||
// | Convenience functions to simplify outputting ANSI escape codes to
|
||||
// | terminals.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Ansi$dCodes from "../Ansi.Codes/index.js";
|
||||
import * as Data$dList$dTypes from "../Data.List.Types/index.js";
|
||||
import * as Data$dNonEmpty from "../Data.NonEmpty/index.js";
|
||||
const withGraphics = params => text => Ansi$dCodes.escapeCodeToString(Ansi$dCodes.$EscapeCode("Graphics", params)) + (
|
||||
text + Ansi$dCodes.escapeCodeToString(Ansi$dCodes.$EscapeCode("Graphics", Data$dNonEmpty.$NonEmpty(Ansi$dCodes.Reset, Data$dList$dTypes.Nil)))
|
||||
);
|
||||
const underline = /* #__PURE__ */ Data$dNonEmpty.$NonEmpty(/* #__PURE__ */ Ansi$dCodes.$GraphicsParam("PMode", Ansi$dCodes.Underline), Data$dList$dTypes.Nil);
|
||||
const strikethrough = /* #__PURE__ */ Data$dNonEmpty.$NonEmpty(/* #__PURE__ */ Ansi$dCodes.$GraphicsParam("PMode", Ansi$dCodes.Strikethrough), Data$dList$dTypes.Nil);
|
||||
const italic = /* #__PURE__ */ Data$dNonEmpty.$NonEmpty(/* #__PURE__ */ Ansi$dCodes.$GraphicsParam("PMode", Ansi$dCodes.Italic), Data$dList$dTypes.Nil);
|
||||
const inverse = /* #__PURE__ */ Data$dNonEmpty.$NonEmpty(/* #__PURE__ */ Ansi$dCodes.$GraphicsParam("PMode", Ansi$dCodes.Inverse), Data$dList$dTypes.Nil);
|
||||
const foreground = c => Data$dNonEmpty.$NonEmpty(Ansi$dCodes.$GraphicsParam("PForeground", c), Data$dList$dTypes.Nil);
|
||||
const dim = /* #__PURE__ */ Data$dNonEmpty.$NonEmpty(/* #__PURE__ */ Ansi$dCodes.$GraphicsParam("PMode", Ansi$dCodes.Dim), Data$dList$dTypes.Nil);
|
||||
const bold = /* #__PURE__ */ Data$dNonEmpty.$NonEmpty(/* #__PURE__ */ Ansi$dCodes.$GraphicsParam("PMode", Ansi$dCodes.Bold), Data$dList$dTypes.Nil);
|
||||
const background = c => Data$dNonEmpty.$NonEmpty(Ansi$dCodes.$GraphicsParam("PBackground", c), Data$dList$dTypes.Nil);
|
||||
export {background, bold, dim, foreground, inverse, italic, strikethrough, underline, withGraphics};
|
@ -0,0 +1,6 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import * as Data$dSemigroup from "../Data.Semigroup/index.js";
|
||||
const altArray = {alt: Data$dSemigroup.concatArray, Functor0: () => Data$dFunctor.functorArray};
|
||||
const alt = dict => dict.alt;
|
||||
export {alt, altArray};
|
@ -0,0 +1,14 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dApplicative from "../Control.Applicative/index.js";
|
||||
import * as Control$dPlus from "../Control.Plus/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const guard = dictAlternative => {
|
||||
const pure = dictAlternative.Applicative0().pure;
|
||||
const empty = dictAlternative.Plus1().empty;
|
||||
return v => {
|
||||
if (v) { return pure(Data$dUnit.unit); }
|
||||
return empty;
|
||||
};
|
||||
};
|
||||
const alternativeArray = {Applicative0: () => Control$dApplicative.applicativeArray, Plus1: () => Control$dPlus.plusArray};
|
||||
export {alternativeArray, guard};
|
@ -0,0 +1,22 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dApply from "../Control.Apply/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import * as Type$dProxy from "../Type.Proxy/index.js";
|
||||
const pure = dict => dict.pure;
|
||||
const unless = dictApplicative => v => v1 => {
|
||||
if (!v) { return v1; }
|
||||
if (v) { return dictApplicative.pure(Data$dUnit.unit); }
|
||||
$runtime.fail();
|
||||
};
|
||||
const when = dictApplicative => v => v1 => {
|
||||
if (v) { return v1; }
|
||||
return dictApplicative.pure(Data$dUnit.unit);
|
||||
};
|
||||
const liftA1 = dictApplicative => {
|
||||
const apply = dictApplicative.Apply0().apply;
|
||||
return f => a => apply(dictApplicative.pure(f))(a);
|
||||
};
|
||||
const applicativeProxy = {pure: v => Type$dProxy.Proxy, Apply0: () => Control$dApply.applyProxy};
|
||||
const applicativeFn = {pure: x => v => x, Apply0: () => Control$dApply.applyFn};
|
||||
const applicativeArray = {pure: x => [x], Apply0: () => Control$dApply.applyArray};
|
||||
export {applicativeArray, applicativeFn, applicativeProxy, liftA1, pure, unless, when};
|
@ -0,0 +1,15 @@
|
||||
export const arrayApply = function (fs) {
|
||||
return function (xs) {
|
||||
var l = fs.length;
|
||||
var k = xs.length;
|
||||
var result = new Array(l*k);
|
||||
var n = 0;
|
||||
for (var i = 0; i < l; i++) {
|
||||
var f = fs[i];
|
||||
for (var j = 0; j < k; j++) {
|
||||
result[n++] = f(xs[j]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
@ -0,0 +1,36 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dFunction from "../Data.Function/index.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import * as Type$dProxy from "../Type.Proxy/index.js";
|
||||
import {arrayApply} from "./foreign.js";
|
||||
const identity = x => x;
|
||||
const applyProxy = {apply: v => v1 => Type$dProxy.Proxy, Functor0: () => Data$dFunctor.functorProxy};
|
||||
const applyFn = {apply: f => g => x => f(x)(g(x)), Functor0: () => Data$dFunctor.functorFn};
|
||||
const applyArray = {apply: arrayApply, Functor0: () => Data$dFunctor.functorArray};
|
||||
const apply = dict => dict.apply;
|
||||
const applyFirst = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return a => b => dictApply.apply(map(Data$dFunction.const)(a))(b);
|
||||
};
|
||||
const applySecond = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return a => b => dictApply.apply(map(v => identity)(a))(b);
|
||||
};
|
||||
const lift2 = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return f => a => b => dictApply.apply(map(f)(a))(b);
|
||||
};
|
||||
const lift3 = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return f => a => b => c => dictApply.apply(dictApply.apply(map(f)(a))(b))(c);
|
||||
};
|
||||
const lift4 = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return f => a => b => c => d => dictApply.apply(dictApply.apply(dictApply.apply(map(f)(a))(b))(c))(d);
|
||||
};
|
||||
const lift5 = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return f => a => b => c => d => e => dictApply.apply(dictApply.apply(dictApply.apply(dictApply.apply(map(f)(a))(b))(c))(d))(e);
|
||||
};
|
||||
export {apply, applyArray, applyFirst, applyFn, applyProxy, applySecond, identity, lift2, lift3, lift4, lift5};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,6 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dBiapply from "../Control.Biapply/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const bipure = dict => dict.bipure;
|
||||
const biapplicativeTuple = {bipure: Data$dTuple.Tuple, Biapply0: () => Control$dBiapply.biapplyTuple};
|
||||
export {biapplicativeTuple, bipure};
|
@ -0,0 +1,24 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dBifunctor from "../Data.Bifunctor/index.js";
|
||||
import * as Data$dFunction from "../Data.Function/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const identity = x => x;
|
||||
const biapplyTuple = {biapply: v => v1 => Data$dTuple.$Tuple(v._1(v1._1), v._2(v1._2)), Bifunctor0: () => Data$dBifunctor.bifunctorTuple};
|
||||
const biapply = dict => dict.biapply;
|
||||
const biapplyFirst = dictBiapply => {
|
||||
const bimap = dictBiapply.Bifunctor0().bimap;
|
||||
return a => b => dictBiapply.biapply(bimap(v => identity)(v => identity)(a))(b);
|
||||
};
|
||||
const biapplySecond = dictBiapply => {
|
||||
const bimap = dictBiapply.Bifunctor0().bimap;
|
||||
return a => b => dictBiapply.biapply(bimap(Data$dFunction.const)(Data$dFunction.const)(a))(b);
|
||||
};
|
||||
const bilift2 = dictBiapply => {
|
||||
const bimap = dictBiapply.Bifunctor0().bimap;
|
||||
return f => g => a => b => dictBiapply.biapply(bimap(f)(g)(a))(b);
|
||||
};
|
||||
const bilift3 = dictBiapply => {
|
||||
const bimap = dictBiapply.Bifunctor0().bimap;
|
||||
return f => g => a => b => c => dictBiapply.biapply(dictBiapply.biapply(bimap(f)(g)(a))(b))(c);
|
||||
};
|
||||
export {biapply, biapplyFirst, biapplySecond, biapplyTuple, bilift2, bilift3, identity};
|
@ -0,0 +1,9 @@
|
||||
export const 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;
|
||||
};
|
||||
};
|
@ -0,0 +1,22 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dApply from "../Control.Apply/index.js";
|
||||
import * as Type$dProxy from "../Type.Proxy/index.js";
|
||||
import {arrayBind} from "./foreign.js";
|
||||
const identity = x => x;
|
||||
const discard = dict => dict.discard;
|
||||
const bindProxy = {bind: v => v1 => Type$dProxy.Proxy, Apply0: () => Control$dApply.applyProxy};
|
||||
const bindFn = {bind: m => f => x => f(m(x))(x), Apply0: () => Control$dApply.applyFn};
|
||||
const bindArray = {bind: arrayBind, Apply0: () => Control$dApply.applyArray};
|
||||
const bind = dict => dict.bind;
|
||||
const bindFlipped = dictBind => b => a => dictBind.bind(a)(b);
|
||||
const composeKleisliFlipped = dictBind => f => g => a => dictBind.bind(g(a))(f);
|
||||
const composeKleisli = dictBind => f => g => a => dictBind.bind(f(a))(g);
|
||||
const discardProxy = {discard: dictBind => dictBind.bind};
|
||||
const discardUnit = {discard: dictBind => dictBind.bind};
|
||||
const ifM = dictBind => cond => t => f => dictBind.bind(cond)(cond$p => {
|
||||
if (cond$p) { return t; }
|
||||
return f;
|
||||
});
|
||||
const join = dictBind => m => dictBind.bind(m)(identity);
|
||||
export {bind, bindArray, bindFlipped, bindFn, bindProxy, composeKleisli, composeKleisliFlipped, discard, discardProxy, discardUnit, identity, ifM, join};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,5 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dSemigroupoid from "../Control.Semigroupoid/index.js";
|
||||
const identity = dict => dict.identity;
|
||||
const categoryFn = {identity: x => x, Semigroupoid0: () => Control$dSemigroupoid.semigroupoidFn};
|
||||
export {categoryFn, identity};
|
@ -0,0 +1,30 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dComonad$dCofree from "../Control.Comonad.Cofree/index.js";
|
||||
import * as Control$dComonad$dEnv$dTrans from "../Control.Comonad.Env.Trans/index.js";
|
||||
import * as Control$dComonad$dStore$dTrans from "../Control.Comonad.Store.Trans/index.js";
|
||||
import * as Control$dComonad$dTraced$dTrans from "../Control.Comonad.Traced.Trans/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const unwrapCofree = dict => dict.unwrapCofree;
|
||||
const comonadCofreeTracedT = dictFunctor => dictComonadCofree => {
|
||||
const Functor0 = dictComonadCofree.Functor0();
|
||||
const comonadTracedT = Control$dComonad$dTraced$dTrans.comonadTracedT(dictComonadCofree.Comonad1());
|
||||
return dictMonoid => {
|
||||
const comonadTracedT1 = comonadTracedT(dictMonoid);
|
||||
return {unwrapCofree: v => Functor0.map(Control$dComonad$dTraced$dTrans.TracedT)(dictComonadCofree.unwrapCofree(v)), Functor0: () => Functor0, Comonad1: () => comonadTracedT1};
|
||||
};
|
||||
};
|
||||
const comonadCofreeStoreT = dictFunctor => dictComonadCofree => {
|
||||
const Functor0 = dictComonadCofree.Functor0();
|
||||
const comonadStoreT = Control$dComonad$dStore$dTrans.comonadStoreT(dictComonadCofree.Comonad1());
|
||||
return {unwrapCofree: v => Functor0.map(x => Data$dTuple.$Tuple(x, v._2))(dictComonadCofree.unwrapCofree(v._1)), Functor0: () => Functor0, Comonad1: () => comonadStoreT};
|
||||
};
|
||||
const comonadCofreeEnvT = dictFunctor => dictComonadCofree => {
|
||||
const Functor0 = dictComonadCofree.Functor0();
|
||||
const comonadEnvT = Control$dComonad$dEnv$dTrans.comonadEnvT(dictComonadCofree.Comonad1());
|
||||
return {unwrapCofree: v => Functor0.map(x => Data$dTuple.$Tuple(v._1, x))(dictComonadCofree.unwrapCofree(v._2)), Functor0: () => Functor0, Comonad1: () => comonadEnvT};
|
||||
};
|
||||
const comonadCofreeCofree = dictFunctor => {
|
||||
const extendCofree1 = Control$dComonad$dCofree.extendCofree(dictFunctor);
|
||||
return {unwrapCofree: Control$dComonad$dCofree.tail, Functor0: () => dictFunctor, Comonad1: () => ({extract: Control$dComonad$dCofree.head, Extend0: () => extendCofree1})};
|
||||
};
|
||||
export {comonadCofreeCofree, comonadCofreeEnvT, comonadCofreeStoreT, comonadCofreeTracedT, unwrapCofree};
|
@ -0,0 +1,223 @@
|
||||
// | The _cofree comonad_ for a `Functor`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dFree from "../Control.Monad.Free/index.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Control$dMonad$dState$dTrans from "../Control.Monad.State.Trans/index.js";
|
||||
import * as Data$dIdentity from "../Data.Identity/index.js";
|
||||
import * as Data$dLazy from "../Data.Lazy/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const identity = x => x;
|
||||
const state = /* #__PURE__ */ (() => Control$dMonad$dState$dTrans.monadStateStateT(Data$dIdentity.monadIdentity).state)();
|
||||
const monadRecStateT = /* #__PURE__ */ Control$dMonad$dState$dTrans.monadRecStateT(Control$dMonad$dRec$dClass.monadRecIdentity);
|
||||
const tail = v => Data$dLazy.force(v)._2;
|
||||
const mkCofree = a => t => Data$dLazy.defer(v => Data$dTuple.$Tuple(a, t));
|
||||
const lazyCofree = {defer: k => Data$dLazy.defer(v => Data$dLazy.force(k(Data$dUnit.unit)))};
|
||||
const hoistCofree = dictFunctor => nat => v => {
|
||||
const $3 = Data$dTuple.functorTuple.map((() => {
|
||||
const $3 = dictFunctor.map(hoistCofree(dictFunctor)(nat));
|
||||
return x => nat($3(x));
|
||||
})());
|
||||
return Data$dLazy.defer(v$1 => $3(Data$dLazy.force(v)));
|
||||
};
|
||||
const head = v => Data$dLazy.force(v)._1;
|
||||
const functorCofree = dictFunctor => (
|
||||
{
|
||||
map: f => {
|
||||
const loop = v => Data$dLazy.defer(v$1 => {
|
||||
const $5 = Data$dLazy.force(v);
|
||||
return Data$dTuple.$Tuple(f($5._1), dictFunctor.map(loop)($5._2));
|
||||
});
|
||||
return loop;
|
||||
}
|
||||
}
|
||||
);
|
||||
const functorWithIndexCofree = dictFunctor => {
|
||||
const functorCofree1 = functorCofree(dictFunctor);
|
||||
return {
|
||||
mapWithIndex: f => {
|
||||
const loop = n => v => Data$dLazy.defer(v$1 => {
|
||||
const $7 = Data$dLazy.force(v);
|
||||
return Data$dTuple.$Tuple(f(n)($7._1), dictFunctor.map(loop(n + 1 | 0))($7._2));
|
||||
});
|
||||
return loop(0);
|
||||
},
|
||||
Functor0: () => functorCofree1
|
||||
};
|
||||
};
|
||||
const foldableCofree = dictFoldable => (
|
||||
{
|
||||
foldr: f => {
|
||||
const go = fa => b => f(Data$dLazy.force(fa)._1)(dictFoldable.foldr(go)(b)(Data$dLazy.force(fa)._2));
|
||||
return b => a => go(a)(b);
|
||||
},
|
||||
foldl: f => {
|
||||
const go = b => fa => dictFoldable.foldl(go)(f(b)(Data$dLazy.force(fa)._1))(Data$dLazy.force(fa)._2);
|
||||
return go;
|
||||
},
|
||||
foldMap: dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
const foldMap1 = dictFoldable.foldMap(dictMonoid);
|
||||
return f => {
|
||||
const go = fa => append(f(Data$dLazy.force(fa)._1))(foldMap1(go)(Data$dLazy.force(fa)._2));
|
||||
return go;
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
const traversableCofree = dictTraversable => {
|
||||
const functorCofree1 = functorCofree(dictTraversable.Functor0());
|
||||
const foldableCofree1 = foldableCofree(dictTraversable.Foldable1());
|
||||
return {
|
||||
sequence: dictApplicative => traversableCofree(dictTraversable).traverse(dictApplicative)(identity),
|
||||
traverse: dictApplicative => {
|
||||
const Apply0 = dictApplicative.Apply0();
|
||||
const map2 = Apply0.Functor0().map;
|
||||
const traverse1 = dictTraversable.traverse(dictApplicative);
|
||||
return f => {
|
||||
const loop = ta => Apply0.apply(map2(mkCofree)(f(Data$dLazy.force(ta)._1)))(traverse1(loop)(Data$dLazy.force(ta)._2));
|
||||
return loop;
|
||||
};
|
||||
},
|
||||
Functor0: () => functorCofree1,
|
||||
Foldable1: () => foldableCofree1
|
||||
};
|
||||
};
|
||||
const extendCofree = dictFunctor => {
|
||||
const functorCofree1 = functorCofree(dictFunctor);
|
||||
return {
|
||||
extend: f => {
|
||||
const loop = v => Data$dLazy.defer(v$1 => Data$dTuple.$Tuple(f(v), dictFunctor.map(loop)(Data$dLazy.force(v)._2)));
|
||||
return loop;
|
||||
},
|
||||
Functor0: () => functorCofree1
|
||||
};
|
||||
};
|
||||
const eqCofree = dictEq1 => dictEq => (
|
||||
{eq: x => y => dictEq.eq(Data$dLazy.force(x)._1)(Data$dLazy.force(y)._1) && dictEq1.eq1(eqCofree(dictEq1)(dictEq))(Data$dLazy.force(x)._2)(Data$dLazy.force(y)._2)}
|
||||
);
|
||||
const ordCofree = dictOrd1 => {
|
||||
const eqCofree1 = eqCofree(dictOrd1.Eq10());
|
||||
return dictOrd => {
|
||||
const eqCofree2 = eqCofree1(dictOrd.Eq0());
|
||||
return {
|
||||
compare: x => y => {
|
||||
const v = dictOrd.compare(Data$dLazy.force(x)._1)(Data$dLazy.force(y)._1);
|
||||
if (v.tag === "EQ") { return dictOrd1.compare1(ordCofree(dictOrd1)(dictOrd))(Data$dLazy.force(x)._2)(Data$dLazy.force(y)._2); }
|
||||
return v;
|
||||
},
|
||||
Eq0: () => eqCofree2
|
||||
};
|
||||
};
|
||||
};
|
||||
const eq1Cofree = dictEq1 => ({eq1: dictEq => eqCofree(dictEq1)(dictEq).eq});
|
||||
const ord1Cofree = dictOrd1 => {
|
||||
const ordCofree1 = ordCofree(dictOrd1);
|
||||
const $2 = dictOrd1.Eq10();
|
||||
const eq1Cofree1 = {eq1: dictEq => eqCofree($2)(dictEq).eq};
|
||||
return {compare1: dictOrd => ordCofree1(dictOrd).compare, Eq10: () => eq1Cofree1};
|
||||
};
|
||||
const deferCofree = x => Data$dLazy.defer(x);
|
||||
const semigroupCofree = dictApply => {
|
||||
const map2 = dictApply.Functor0().map;
|
||||
return dictSemigroup => (
|
||||
{
|
||||
append: x => y => Data$dLazy.defer(v => Data$dTuple.$Tuple(
|
||||
dictSemigroup.append(Data$dLazy.force(x)._1)(Data$dLazy.force(y)._1),
|
||||
dictApply.apply(map2(semigroupCofree(dictApply)(dictSemigroup).append)(Data$dLazy.force(x)._2))(Data$dLazy.force(y)._2)
|
||||
))
|
||||
}
|
||||
);
|
||||
};
|
||||
const monoidCofree = dictApplicative => {
|
||||
const semigroupCofree1 = semigroupCofree(dictApplicative.Apply0());
|
||||
return dictMonoid => {
|
||||
const semigroupCofree2 = semigroupCofree1(dictMonoid.Semigroup0());
|
||||
return {
|
||||
mempty: Data$dLazy.defer(v => Data$dTuple.$Tuple(dictMonoid.mempty, dictApplicative.pure(monoidCofree(dictApplicative)(dictMonoid).mempty))),
|
||||
Semigroup0: () => semigroupCofree2
|
||||
};
|
||||
};
|
||||
};
|
||||
const comonadCofree = dictFunctor => {
|
||||
const extendCofree1 = extendCofree(dictFunctor);
|
||||
return {extract: head, Extend0: () => extendCofree1};
|
||||
};
|
||||
const explore = dictFunctor => {
|
||||
const runFreeM = Control$dMonad$dFree.runFreeM(dictFunctor)(monadRecStateT);
|
||||
return dictFunctor1 => pair => m => w => {
|
||||
const v = runFreeM(ff => state(cof => pair(dictFunctor.map(Data$dTuple.Tuple)(ff))(Data$dLazy.force(cof)._2)))(m)(w);
|
||||
return v._1(Data$dLazy.force(v._2)._1);
|
||||
};
|
||||
};
|
||||
const exploreM = dictFunctor => dictFunctor1 => dictMonadRec => {
|
||||
const map3 = dictMonadRec.Monad0().Bind1().Apply0().Functor0().map;
|
||||
const runFreeM1 = Control$dMonad$dFree.runFreeM(dictFunctor)(Control$dMonad$dState$dTrans.monadRecStateT(dictMonadRec));
|
||||
return pair => m => w => map3(v => v._1(Data$dLazy.force(v._2)._1))(runFreeM1(ff => cof => pair(dictFunctor.map(Data$dTuple.Tuple)(ff))(Data$dLazy.force(cof)._2))(m)(w));
|
||||
};
|
||||
const buildCofree = dictFunctor => k => s => Data$dLazy.defer(v => {
|
||||
const $4 = k(s);
|
||||
return Data$dTuple.$Tuple($4._1, dictFunctor.map(buildCofree(dictFunctor)(k))($4._2));
|
||||
});
|
||||
const monadCofree = dictAlternative => ({Applicative0: () => applicativeCofree(dictAlternative), Bind1: () => bindCofree(dictAlternative)});
|
||||
const bindCofree = dictAlternative => {
|
||||
const Alt0 = dictAlternative.Plus1().Alt0();
|
||||
const map2 = Alt0.Functor0().map;
|
||||
return {
|
||||
bind: fa => f => {
|
||||
const loop = fa$p => {
|
||||
const fh = f(Data$dLazy.force(fa$p)._1);
|
||||
const $8 = Data$dLazy.force(fh)._1;
|
||||
const $9 = Alt0.alt(Data$dLazy.force(fh)._2)(map2(loop)(Data$dLazy.force(fa$p)._2));
|
||||
return Data$dLazy.defer(v => Data$dTuple.$Tuple($8, $9));
|
||||
};
|
||||
return loop(fa);
|
||||
},
|
||||
Apply0: () => applyCofree(dictAlternative)
|
||||
};
|
||||
};
|
||||
const applyCofree = dictAlternative => {
|
||||
const functorCofree1 = functorCofree(dictAlternative.Plus1().Alt0().Functor0());
|
||||
return {
|
||||
apply: (() => {
|
||||
const bind = bindCofree(dictAlternative).bind;
|
||||
const pure = applicativeCofree(dictAlternative).pure;
|
||||
return f => a => bind(f)(f$p => bind(a)(a$p => pure(f$p(a$p))));
|
||||
})(),
|
||||
Functor0: () => functorCofree1
|
||||
};
|
||||
};
|
||||
const applicativeCofree = dictAlternative => {
|
||||
const empty = dictAlternative.Plus1().empty;
|
||||
return {pure: a => Data$dLazy.defer(v => Data$dTuple.$Tuple(a, empty)), Apply0: () => applyCofree(dictAlternative)};
|
||||
};
|
||||
export {
|
||||
applicativeCofree,
|
||||
applyCofree,
|
||||
bindCofree,
|
||||
buildCofree,
|
||||
comonadCofree,
|
||||
deferCofree,
|
||||
eq1Cofree,
|
||||
eqCofree,
|
||||
explore,
|
||||
exploreM,
|
||||
extendCofree,
|
||||
foldableCofree,
|
||||
functorCofree,
|
||||
functorWithIndexCofree,
|
||||
head,
|
||||
hoistCofree,
|
||||
identity,
|
||||
lazyCofree,
|
||||
mkCofree,
|
||||
monadCofree,
|
||||
monadRecStateT,
|
||||
monoidCofree,
|
||||
ord1Cofree,
|
||||
ordCofree,
|
||||
semigroupCofree,
|
||||
state,
|
||||
tail,
|
||||
traversableCofree
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
// | This module defines the `ComonadEnv` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dComonad$dEnv$dTrans from "../Control.Comonad.Env.Trans/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const local = dict => dict.local;
|
||||
const comonadAskTuple = {ask: Data$dTuple.fst, Comonad0: () => Data$dTuple.comonadTuple};
|
||||
const comonadEnvTuple = {local: f => v => Data$dTuple.$Tuple(f(v._1), v._2), ComonadAsk0: () => comonadAskTuple};
|
||||
const comonadAskEnvT = dictComonad => {
|
||||
const comonadEnvT = Control$dComonad$dEnv$dTrans.comonadEnvT(dictComonad);
|
||||
return {ask: v => v._1, Comonad0: () => comonadEnvT};
|
||||
};
|
||||
const comonadEnvEnvT = dictComonad => {
|
||||
const comonadEnvT = Control$dComonad$dEnv$dTrans.comonadEnvT(dictComonad);
|
||||
return {local: f => v => Data$dTuple.$Tuple(f(v._1), v._2), ComonadAsk0: () => ({ask: v => v._1, Comonad0: () => comonadEnvT})};
|
||||
};
|
||||
const ask = dict => dict.ask;
|
||||
const asks = dictComonadAsk => f => x => f(dictComonadAsk.ask(x));
|
||||
export {ask, asks, comonadAskEnvT, comonadAskTuple, comonadEnvEnvT, comonadEnvTuple, local};
|
@ -0,0 +1,112 @@
|
||||
// | This module defines the environment comonad transformer, `EnvT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const EnvT = x => x;
|
||||
const withEnvT = f => v => Data$dTuple.$Tuple(f(v._1), v._2);
|
||||
const runEnvT = v => v;
|
||||
const newtypeEnvT = {Coercible0: () => undefined};
|
||||
const mapEnvT = f => v => Data$dTuple.$Tuple(v._1, f(v._2));
|
||||
const functorEnvT = dictFunctor => ({map: f => v => Data$dTuple.$Tuple(v._1, dictFunctor.map(f)(v._2))});
|
||||
const functorWithIndexEnvT = dictFunctorWithIndex => {
|
||||
const $1 = dictFunctorWithIndex.Functor0();
|
||||
const functorEnvT1 = {map: f => v => Data$dTuple.$Tuple(v._1, $1.map(f)(v._2))};
|
||||
return {mapWithIndex: f => v => Data$dTuple.$Tuple(v._1, dictFunctorWithIndex.mapWithIndex(f)(v._2)), Functor0: () => functorEnvT1};
|
||||
};
|
||||
const foldableEnvT = dictFoldable => (
|
||||
{
|
||||
foldl: fn => a => v => dictFoldable.foldl(fn)(a)(v._2),
|
||||
foldr: fn => a => v => dictFoldable.foldr(fn)(a)(v._2),
|
||||
foldMap: dictMonoid => {
|
||||
const foldMap1 = dictFoldable.foldMap(dictMonoid);
|
||||
return fn => v => foldMap1(fn)(v._2);
|
||||
}
|
||||
}
|
||||
);
|
||||
const foldableWithIndexEnvT = dictFoldableWithIndex => {
|
||||
const $1 = dictFoldableWithIndex.Foldable0();
|
||||
const foldableEnvT1 = {
|
||||
foldl: fn => a => v => $1.foldl(fn)(a)(v._2),
|
||||
foldr: fn => a => v => $1.foldr(fn)(a)(v._2),
|
||||
foldMap: dictMonoid => {
|
||||
const foldMap1 = $1.foldMap(dictMonoid);
|
||||
return fn => v => foldMap1(fn)(v._2);
|
||||
}
|
||||
};
|
||||
return {
|
||||
foldlWithIndex: f => a => v => dictFoldableWithIndex.foldlWithIndex(f)(a)(v._2),
|
||||
foldrWithIndex: f => a => v => dictFoldableWithIndex.foldrWithIndex(f)(a)(v._2),
|
||||
foldMapWithIndex: dictMonoid => {
|
||||
const foldMapWithIndex1 = dictFoldableWithIndex.foldMapWithIndex(dictMonoid);
|
||||
return f => v => foldMapWithIndex1(f)(v._2);
|
||||
},
|
||||
Foldable0: () => foldableEnvT1
|
||||
};
|
||||
};
|
||||
const traversableEnvT = dictTraversable => {
|
||||
const $1 = dictTraversable.Functor0();
|
||||
const functorEnvT1 = {map: f => v => Data$dTuple.$Tuple(v._1, $1.map(f)(v._2))};
|
||||
const $3 = dictTraversable.Foldable1();
|
||||
const foldableEnvT1 = {
|
||||
foldl: fn => a => v => $3.foldl(fn)(a)(v._2),
|
||||
foldr: fn => a => v => $3.foldr(fn)(a)(v._2),
|
||||
foldMap: dictMonoid => {
|
||||
const foldMap1 = $3.foldMap(dictMonoid);
|
||||
return fn => v => foldMap1(fn)(v._2);
|
||||
}
|
||||
};
|
||||
return {
|
||||
sequence: dictApplicative => {
|
||||
const map1 = dictApplicative.Apply0().Functor0().map;
|
||||
const sequence1 = dictTraversable.sequence(dictApplicative);
|
||||
return v => map1(Data$dTuple.Tuple(v._1))(sequence1(v._2));
|
||||
},
|
||||
traverse: dictApplicative => {
|
||||
const map1 = dictApplicative.Apply0().Functor0().map;
|
||||
const traverse1 = dictTraversable.traverse(dictApplicative);
|
||||
return f => v => map1(Data$dTuple.Tuple(v._1))(traverse1(f)(v._2));
|
||||
},
|
||||
Functor0: () => functorEnvT1,
|
||||
Foldable1: () => foldableEnvT1
|
||||
};
|
||||
};
|
||||
const traversableWithIndexEnvT = dictTraversableWithIndex => {
|
||||
const functorWithIndexEnvT1 = functorWithIndexEnvT(dictTraversableWithIndex.FunctorWithIndex0());
|
||||
const foldableWithIndexEnvT1 = foldableWithIndexEnvT(dictTraversableWithIndex.FoldableWithIndex1());
|
||||
const traversableEnvT1 = traversableEnvT(dictTraversableWithIndex.Traversable2());
|
||||
return {
|
||||
traverseWithIndex: dictApplicative => {
|
||||
const map1 = dictApplicative.Apply0().Functor0().map;
|
||||
const traverseWithIndex1 = dictTraversableWithIndex.traverseWithIndex(dictApplicative);
|
||||
return f => v => map1(Data$dTuple.Tuple(v._1))(traverseWithIndex1(f)(v._2));
|
||||
},
|
||||
FunctorWithIndex0: () => functorWithIndexEnvT1,
|
||||
FoldableWithIndex1: () => foldableWithIndexEnvT1,
|
||||
Traversable2: () => traversableEnvT1
|
||||
};
|
||||
};
|
||||
const extendEnvT = dictExtend => {
|
||||
const Functor0 = dictExtend.Functor0();
|
||||
const functorEnvT1 = {map: f => v => Data$dTuple.$Tuple(v._1, Functor0.map(f)(v._2))};
|
||||
return {extend: f => v => Data$dTuple.$Tuple(v._1, Functor0.map(f)(dictExtend.extend(Data$dTuple.Tuple(v._1))(v._2))), Functor0: () => functorEnvT1};
|
||||
};
|
||||
const comonadTransEnvT = {lower: dictComonad => v => v._2};
|
||||
const comonadEnvT = dictComonad => {
|
||||
const extendEnvT1 = extendEnvT(dictComonad.Extend0());
|
||||
return {extract: v => dictComonad.extract(v._2), Extend0: () => extendEnvT1};
|
||||
};
|
||||
export {
|
||||
EnvT,
|
||||
comonadEnvT,
|
||||
comonadTransEnvT,
|
||||
extendEnvT,
|
||||
foldableEnvT,
|
||||
foldableWithIndexEnvT,
|
||||
functorEnvT,
|
||||
functorWithIndexEnvT,
|
||||
mapEnvT,
|
||||
newtypeEnvT,
|
||||
runEnvT,
|
||||
traversableEnvT,
|
||||
traversableWithIndexEnvT,
|
||||
withEnvT
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// | This module defines the `Env` comonad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dComonad$dEnv$dTrans from "../Control.Comonad.Env.Trans/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const withEnv = Control$dComonad$dEnv$dTrans.withEnvT;
|
||||
const runEnv = v => Data$dTuple.$Tuple(v._1, v._2);
|
||||
const mapEnv = f => v => Data$dTuple.$Tuple(v._1, f(v._2));
|
||||
const env = e => a => Data$dTuple.$Tuple(e, a);
|
||||
export {env, mapEnv, runEnv, withEnv};
|
@ -0,0 +1,56 @@
|
||||
// | This module defines the `ComonadStore` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dComonad$dEnv$dTrans from "../Control.Comonad.Env.Trans/index.js";
|
||||
import * as Control$dComonad$dStore$dTrans from "../Control.Comonad.Store.Trans/index.js";
|
||||
import * as Control$dComonad$dTraced$dTrans from "../Control.Comonad.Traced.Trans/index.js";
|
||||
import * as Control$dExtend from "../Control.Extend/index.js";
|
||||
const pos = dict => dict.pos;
|
||||
const peek = dict => dict.peek;
|
||||
const peeks = dictComonadStore => f => x => dictComonadStore.peek(f(dictComonadStore.pos(x)))(x);
|
||||
const seeks = dictComonadStore => {
|
||||
const duplicate = dictComonadStore.Comonad0().Extend0().extend(Control$dExtend.identity);
|
||||
return f => x => {
|
||||
const $4 = duplicate(x);
|
||||
return dictComonadStore.peek(f(dictComonadStore.pos($4)))($4);
|
||||
};
|
||||
};
|
||||
const seek = dictComonadStore => {
|
||||
const duplicate = dictComonadStore.Comonad0().Extend0().extend(Control$dExtend.identity);
|
||||
return s => {
|
||||
const $3 = dictComonadStore.peek(s);
|
||||
return x => $3(duplicate(x));
|
||||
};
|
||||
};
|
||||
const experiment = dictComonadStore => dictFunctor => f => x => dictFunctor.map(a => dictComonadStore.peek(a)(x))(f(dictComonadStore.pos(x)));
|
||||
const comonadStoreTracedT = dictComonadStore => {
|
||||
const Comonad0 = dictComonadStore.Comonad0();
|
||||
const comonadTracedT = Control$dComonad$dTraced$dTrans.comonadTracedT(Comonad0);
|
||||
return dictMonoid => {
|
||||
const map = Comonad0.Extend0().Functor0().map;
|
||||
const comonadTracedT1 = comonadTracedT(dictMonoid);
|
||||
return {
|
||||
pos: x => dictComonadStore.pos(map(f => f(dictMonoid.mempty))(x)),
|
||||
peek: s => {
|
||||
const $7 = dictComonadStore.peek(s);
|
||||
return x => $7(map(f => f(dictMonoid.mempty))(x));
|
||||
},
|
||||
Comonad0: () => comonadTracedT1
|
||||
};
|
||||
};
|
||||
};
|
||||
const comonadStoreStoreT = dictComonad => {
|
||||
const comonadStoreT = Control$dComonad$dStore$dTrans.comonadStoreT(dictComonad);
|
||||
return {pos: v => v._2, peek: s => v => dictComonad.extract(v._1)(s), Comonad0: () => comonadStoreT};
|
||||
};
|
||||
const comonadStoreEnvT = dictComonadStore => {
|
||||
const comonadEnvT = Control$dComonad$dEnv$dTrans.comonadEnvT(dictComonadStore.Comonad0());
|
||||
return {
|
||||
pos: x => dictComonadStore.pos(x._2),
|
||||
peek: s => {
|
||||
const $3 = dictComonadStore.peek(s);
|
||||
return x => $3(x._2);
|
||||
},
|
||||
Comonad0: () => comonadEnvT
|
||||
};
|
||||
};
|
||||
export {comonadStoreEnvT, comonadStoreStoreT, comonadStoreTracedT, experiment, peek, peeks, pos, seek, seeks};
|
@ -0,0 +1,22 @@
|
||||
// | This module defines the store comonad transformer, `StoreT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const StoreT = x => x;
|
||||
const runStoreT = v => v;
|
||||
const newtypeStoreT = {Coercible0: () => undefined};
|
||||
const functorStoreT = dictFunctor => ({map: f => v => Data$dTuple.$Tuple(dictFunctor.map(h => x => f(h(x)))(v._1), v._2)});
|
||||
const extendStoreT = dictExtend => {
|
||||
const functorStoreT1 = functorStoreT(dictExtend.Functor0());
|
||||
return {extend: f => v => Data$dTuple.$Tuple(dictExtend.extend(w$p => s$p => f(Data$dTuple.$Tuple(w$p, s$p)))(v._1), v._2), Functor0: () => functorStoreT1};
|
||||
};
|
||||
const comonadTransStoreT = {
|
||||
lower: dictComonad => {
|
||||
const map = dictComonad.Extend0().Functor0().map;
|
||||
return v => map(v1 => v1(v._2))(v._1);
|
||||
}
|
||||
};
|
||||
const comonadStoreT = dictComonad => {
|
||||
const extendStoreT1 = extendStoreT(dictComonad.Extend0());
|
||||
return {extract: v => dictComonad.extract(v._1)(v._2), Extend0: () => extendStoreT1};
|
||||
};
|
||||
export {StoreT, comonadStoreT, comonadTransStoreT, extendStoreT, functorStoreT, newtypeStoreT, runStoreT};
|
@ -0,0 +1,6 @@
|
||||
// | This module defines the `Store` comonad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const store = f => x => Data$dTuple.$Tuple(f, x);
|
||||
const runStore = v => Data$dTuple.$Tuple(v._1, v._2);
|
||||
export {runStore, store};
|
@ -0,0 +1,20 @@
|
||||
// | This module defines the `ComonadTraced` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dComonad$dTraced$dTrans from "../Control.Comonad.Traced.Trans/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const track = dict => dict.track;
|
||||
const tracks = dictComonadTraced => {
|
||||
const extract = dictComonadTraced.Comonad0().extract;
|
||||
return f => w => dictComonadTraced.track(f(extract(w)))(w);
|
||||
};
|
||||
const listens = dictFunctor => f => v => dictFunctor.map(g => t => Data$dTuple.$Tuple(g(t), f(t)))(v);
|
||||
const listen = dictFunctor => v => dictFunctor.map(f => t => Data$dTuple.$Tuple(f(t), t))(v);
|
||||
const comonadTracedTracedT = dictComonad => {
|
||||
const comonadTracedT = Control$dComonad$dTraced$dTrans.comonadTracedT(dictComonad);
|
||||
return dictMonoid => {
|
||||
const comonadTracedT1 = comonadTracedT(dictMonoid);
|
||||
return {track: t => v => dictComonad.extract(v)(t), Comonad0: () => comonadTracedT1};
|
||||
};
|
||||
};
|
||||
const censor = dictFunctor => f => v => dictFunctor.map(v1 => x => v1(f(x)))(v);
|
||||
export {censor, comonadTracedTracedT, listen, listens, track, tracks};
|
@ -0,0 +1,30 @@
|
||||
// | This module defines the cowriter comonad transformer, `TracedT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const TracedT = x => x;
|
||||
const runTracedT = v => v;
|
||||
const newtypeTracedT = {Coercible0: () => undefined};
|
||||
const functorTracedT = dictFunctor => ({map: f => v => dictFunctor.map(g => t => f(g(t)))(v)});
|
||||
const extendTracedT = dictExtend => {
|
||||
const Functor0 = dictExtend.Functor0();
|
||||
const functorTracedT1 = {map: f => v => Functor0.map(g => t => f(g(t)))(v)};
|
||||
return dictSemigroup => ({extend: f => v => dictExtend.extend(w$p => t => f(Functor0.map(h => t$p => h(dictSemigroup.append(t)(t$p)))(w$p)))(v), Functor0: () => functorTracedT1});
|
||||
};
|
||||
const comonadTransTracedT = dictMonoid => (
|
||||
{
|
||||
lower: dictComonad => {
|
||||
const map = dictComonad.Extend0().Functor0().map;
|
||||
return v => map(f => f(dictMonoid.mempty))(v);
|
||||
}
|
||||
}
|
||||
);
|
||||
const comonadTracedT = dictComonad => {
|
||||
const $1 = dictComonad.Extend0();
|
||||
const Functor0 = $1.Functor0();
|
||||
const functorTracedT1 = {map: f => v => Functor0.map(g => t => f(g(t)))(v)};
|
||||
return dictMonoid => {
|
||||
const $5 = dictMonoid.Semigroup0();
|
||||
const extendTracedT2 = {extend: f => v => $1.extend(w$p => t => f(Functor0.map(h => t$p => h($5.append(t)(t$p)))(w$p)))(v), Functor0: () => functorTracedT1};
|
||||
return {extract: v => dictComonad.extract(v)(dictMonoid.mempty), Extend0: () => extendTracedT2};
|
||||
};
|
||||
};
|
||||
export {TracedT, comonadTracedT, comonadTransTracedT, extendTracedT, functorTracedT, newtypeTracedT, runTracedT};
|
@ -0,0 +1,5 @@
|
||||
// | This module defines the `Traced` comonad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const traced = x => x;
|
||||
const runTraced = v => v;
|
||||
export {runTraced, traced};
|
@ -0,0 +1,4 @@
|
||||
// | This module defines the `ComonadTrans` type class of _comonad transformers_.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const lower = dict => dict.lower;
|
||||
export {lower};
|
@ -0,0 +1,3 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
const extract = dict => dict.extract;
|
||||
export {extract};
|
@ -0,0 +1,7 @@
|
||||
export const arrayExtend = function(f) {
|
||||
return function(xs) {
|
||||
return xs.map(function (_, i, xs) {
|
||||
return f(xs.slice(i));
|
||||
});
|
||||
};
|
||||
};
|
@ -0,0 +1,13 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import {arrayExtend} from "./foreign.js";
|
||||
const identity = x => x;
|
||||
const extendFn = dictSemigroup => ({extend: f => g => w => f(w$p => g(dictSemigroup.append(w)(w$p))), Functor0: () => Data$dFunctor.functorFn});
|
||||
const extendArray = {extend: arrayExtend, Functor0: () => Data$dFunctor.functorArray};
|
||||
const extend = dict => dict.extend;
|
||||
const extendFlipped = dictExtend => w => f => dictExtend.extend(f)(w);
|
||||
const duplicate = dictExtend => dictExtend.extend(identity);
|
||||
const composeCoKleisliFlipped = dictExtend => f => g => w => f(dictExtend.extend(g)(w));
|
||||
const composeCoKleisli = dictExtend => f => g => w => g(dictExtend.extend(f)(w));
|
||||
export {composeCoKleisli, composeCoKleisliFlipped, duplicate, extend, extendArray, extendFlipped, extendFn, identity};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,11 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const lazyUnit = {defer: v => Data$dUnit.unit};
|
||||
const lazyFn = {defer: f => x => f(Data$dUnit.unit)(x)};
|
||||
const defer = dict => dict.defer;
|
||||
const fix = dictLazy => f => {
|
||||
const go$lazy = $runtime.binding(() => dictLazy.defer(v => f(go$lazy())));
|
||||
const go = go$lazy();
|
||||
return go;
|
||||
};
|
||||
export {defer, fix, lazyFn, lazyUnit};
|
@ -0,0 +1,4 @@
|
||||
// | This module defines the `MonadCont` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const callCC = dict => dict.callCC;
|
||||
export {callCC};
|
@ -0,0 +1,113 @@
|
||||
// | This module defines the CPS monad transformer.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const ContT = x => x;
|
||||
const withContT = f => v => k => v(f(k));
|
||||
const runContT = v => k => v(k);
|
||||
const newtypeContT = {Coercible0: () => undefined};
|
||||
const monadTransContT = {lift: dictMonad => dictMonad.Bind1().bind};
|
||||
const mapContT = f => v => k => f(v(k));
|
||||
const functorContT = dictFunctor => ({map: f => v => k => v(a => k(f(a)))});
|
||||
const applyContT = dictApply => {
|
||||
const functorContT1 = {map: f => v => k => v(a => k(f(a)))};
|
||||
return {apply: v => v1 => k => v(g => v1(a => k(g(a)))), Functor0: () => functorContT1};
|
||||
};
|
||||
const bindContT = dictBind => {
|
||||
const functorContT1 = {map: f => v => k => v(a => k(f(a)))};
|
||||
const applyContT1 = {apply: v => v1 => k => v(g => v1(a => k(g(a)))), Functor0: () => functorContT1};
|
||||
return {bind: v => k => k$p => v(a => k(a)(k$p)), Apply0: () => applyContT1};
|
||||
};
|
||||
const semigroupContT = dictApply => dictSemigroup => (
|
||||
{
|
||||
append: a => b => k => a(a$1 => {
|
||||
const $6 = dictSemigroup.append(a$1);
|
||||
return b(a$2 => k($6(a$2)));
|
||||
})
|
||||
}
|
||||
);
|
||||
const applicativeContT = dictApplicative => {
|
||||
const functorContT1 = {map: f => v => k => v(a => k(f(a)))};
|
||||
const applyContT1 = {apply: v => v1 => k => v(g => v1(a => k(g(a)))), Functor0: () => functorContT1};
|
||||
return {pure: a => k => k(a), Apply0: () => applyContT1};
|
||||
};
|
||||
const monadContT = dictMonad => {
|
||||
const functorContT1 = {map: f => v => k => v(a => k(f(a)))};
|
||||
const applyContT1 = {apply: v => v1 => k => v(g => v1(a => k(g(a)))), Functor0: () => functorContT1};
|
||||
const applicativeContT1 = {pure: a => k => k(a), Apply0: () => applyContT1};
|
||||
const functorContT1$1 = {map: f => v => k => v(a => k(f(a)))};
|
||||
const applyContT1$1 = {apply: v => v1 => k => v(g => v1(a => k(g(a)))), Functor0: () => functorContT1$1};
|
||||
const bindContT1 = {bind: v => k => k$p => v(a => k(a)(k$p)), Apply0: () => applyContT1$1};
|
||||
return {Applicative0: () => applicativeContT1, Bind1: () => bindContT1};
|
||||
};
|
||||
const monadAskContT = dictMonadAsk => {
|
||||
const Monad0 = dictMonadAsk.Monad0();
|
||||
const monadContT1 = monadContT(Monad0);
|
||||
return {ask: Monad0.Bind1().bind(dictMonadAsk.ask), Monad0: () => monadContT1};
|
||||
};
|
||||
const monadReaderContT = dictMonadReader => {
|
||||
const MonadAsk0 = dictMonadReader.MonadAsk0();
|
||||
const bind = MonadAsk0.Monad0().Bind1().bind;
|
||||
const monadAskContT1 = monadAskContT(MonadAsk0);
|
||||
return {
|
||||
local: f => v => k => bind(MonadAsk0.ask)(r => dictMonadReader.local(f)(v((() => {
|
||||
const $8 = dictMonadReader.local(v$1 => r);
|
||||
return x => $8(k(x));
|
||||
})()))),
|
||||
MonadAsk0: () => monadAskContT1
|
||||
};
|
||||
};
|
||||
const monadContContT = dictMonad => {
|
||||
const monadContT1 = monadContT(dictMonad);
|
||||
return {callCC: f => k => f(a => v1 => k(a))(k), Monad0: () => monadContT1};
|
||||
};
|
||||
const monadEffectContT = dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadContT1 = monadContT(Monad0);
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $3 = Monad0.Bind1().bind;
|
||||
return x => $3(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadContT1
|
||||
};
|
||||
};
|
||||
const monadStateContT = dictMonadState => {
|
||||
const Monad0 = dictMonadState.Monad0();
|
||||
const monadContT1 = monadContT(Monad0);
|
||||
return {
|
||||
state: (() => {
|
||||
const $3 = Monad0.Bind1().bind;
|
||||
return x => $3(dictMonadState.state(x));
|
||||
})(),
|
||||
Monad0: () => monadContT1
|
||||
};
|
||||
};
|
||||
const monoidContT = dictApplicative => dictMonoid => {
|
||||
const $2 = dictMonoid.Semigroup0();
|
||||
const semigroupContT2 = {
|
||||
append: a => b => k => a(a$1 => {
|
||||
const $7 = $2.append(a$1);
|
||||
return b(a$2 => k($7(a$2)));
|
||||
})
|
||||
};
|
||||
return {mempty: k => k(dictMonoid.mempty), Semigroup0: () => semigroupContT2};
|
||||
};
|
||||
export {
|
||||
ContT,
|
||||
applicativeContT,
|
||||
applyContT,
|
||||
bindContT,
|
||||
functorContT,
|
||||
mapContT,
|
||||
monadAskContT,
|
||||
monadContContT,
|
||||
monadContT,
|
||||
monadEffectContT,
|
||||
monadReaderContT,
|
||||
monadStateContT,
|
||||
monadTransContT,
|
||||
monoidContT,
|
||||
newtypeContT,
|
||||
runContT,
|
||||
semigroupContT,
|
||||
withContT
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
// | This module defines the `Cont`inuation monad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const withCont = f => v => k => v(f(x => k(x)));
|
||||
const runCont = cc => k => cc(x => k(x));
|
||||
const mapCont = f => v => k => f(v(k));
|
||||
const cont = f => c => f(x => c(x));
|
||||
export {cont, mapCont, runCont, withCont};
|
@ -0,0 +1,90 @@
|
||||
// | This module defines the `MonadError` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import * as Effect from "../Effect/index.js";
|
||||
import * as Effect$dException from "../Effect.Exception/index.js";
|
||||
const throwError = dict => dict.throwError;
|
||||
const monadThrowMaybe = {throwError: v => Data$dMaybe.Nothing, Monad0: () => Data$dMaybe.monadMaybe};
|
||||
const monadThrowEither = {throwError: Data$dEither.Left, Monad0: () => Data$dEither.monadEither};
|
||||
const monadThrowEffect = {throwError: Effect$dException.throwException, Monad0: () => Effect.monadEffect};
|
||||
const monadErrorMaybe = {
|
||||
catchError: v => v1 => {
|
||||
if (v.tag === "Nothing") { return v1(Data$dUnit.unit); }
|
||||
if (v.tag === "Just") { return Data$dMaybe.$Maybe("Just", v._1); }
|
||||
$runtime.fail();
|
||||
},
|
||||
MonadThrow0: () => monadThrowMaybe
|
||||
};
|
||||
const monadErrorEither = {
|
||||
catchError: v => v1 => {
|
||||
if (v.tag === "Left") { return v1(v._1); }
|
||||
if (v.tag === "Right") { return Data$dEither.$Either("Right", v._1); }
|
||||
$runtime.fail();
|
||||
},
|
||||
MonadThrow0: () => monadThrowEither
|
||||
};
|
||||
const monadErrorEffect = {catchError: b => a => Effect$dException.catchException(a)(b), MonadThrow0: () => monadThrowEffect};
|
||||
const liftMaybe = dictMonadThrow => {
|
||||
const pure = dictMonadThrow.Monad0().Applicative0().pure;
|
||||
return error => {
|
||||
const $3 = dictMonadThrow.throwError(error);
|
||||
return v2 => {
|
||||
if (v2.tag === "Nothing") { return $3; }
|
||||
if (v2.tag === "Just") { return pure(v2._1); }
|
||||
$runtime.fail();
|
||||
};
|
||||
};
|
||||
};
|
||||
const liftEither = dictMonadThrow => {
|
||||
const $1 = dictMonadThrow.Monad0().Applicative0().pure;
|
||||
return v2 => {
|
||||
if (v2.tag === "Left") { return dictMonadThrow.throwError(v2._1); }
|
||||
if (v2.tag === "Right") { return $1(v2._1); }
|
||||
$runtime.fail();
|
||||
};
|
||||
};
|
||||
const catchError = dict => dict.catchError;
|
||||
const catchJust = dictMonadError => {
|
||||
const throwError1 = dictMonadError.MonadThrow0().throwError;
|
||||
return p => act => handler => dictMonadError.catchError(act)(e => {
|
||||
const v = p(e);
|
||||
if (v.tag === "Nothing") { return throwError1(e); }
|
||||
if (v.tag === "Just") { return handler(v._1); }
|
||||
$runtime.fail();
|
||||
});
|
||||
};
|
||||
const $$try = dictMonadError => {
|
||||
const Monad0 = dictMonadError.MonadThrow0().Monad0();
|
||||
const map = Monad0.Bind1().Apply0().Functor0().map;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
return a => dictMonadError.catchError(map(Data$dEither.Right)(a))(x => pure(Data$dEither.$Either("Left", x)));
|
||||
};
|
||||
const withResource = dictMonadError => {
|
||||
const MonadThrow0 = dictMonadError.MonadThrow0();
|
||||
const Monad0 = MonadThrow0.Monad0();
|
||||
const Bind1 = Monad0.Bind1();
|
||||
const try1 = $$try(dictMonadError);
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
return acquire => release => kleisli => Bind1.bind(acquire)(resource => Bind1.bind(try1(kleisli(resource)))(result => Bind1.bind(release(resource))(() => {
|
||||
if (result.tag === "Left") { return MonadThrow0.throwError(result._1); }
|
||||
if (result.tag === "Right") { return pure(result._1); }
|
||||
$runtime.fail();
|
||||
})));
|
||||
};
|
||||
export {
|
||||
catchError,
|
||||
catchJust,
|
||||
liftEither,
|
||||
liftMaybe,
|
||||
monadErrorEffect,
|
||||
monadErrorEither,
|
||||
monadErrorMaybe,
|
||||
monadThrowEffect,
|
||||
monadThrowEither,
|
||||
monadThrowMaybe,
|
||||
throwError,
|
||||
$$try as try,
|
||||
withResource
|
||||
};
|
@ -0,0 +1,252 @@
|
||||
// | This module defines the _exception monad transformer_ `ExceptT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const identity = x => x;
|
||||
const ExceptT = x => x;
|
||||
const withExceptT = dictFunctor => f => v => dictFunctor.map(v2 => {
|
||||
if (v2.tag === "Right") { return Data$dEither.$Either("Right", v2._1); }
|
||||
if (v2.tag === "Left") { return Data$dEither.$Either("Left", f(v2._1)); }
|
||||
$runtime.fail();
|
||||
})(v);
|
||||
const runExceptT = v => v;
|
||||
const newtypeExceptT = {Coercible0: () => undefined};
|
||||
const monadTransExceptT = {
|
||||
lift: dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return m => bind(m)(a => pure(Data$dEither.$Either("Right", a)));
|
||||
}
|
||||
};
|
||||
const mapExceptT = f => v => f(v);
|
||||
const functorExceptT = dictFunctor => ({map: f => dictFunctor.map(Data$dEither.functorEither.map(f))});
|
||||
const except = dictApplicative => x => dictApplicative.pure(x);
|
||||
const monadExceptT = dictMonad => ({Applicative0: () => applicativeExceptT(dictMonad), Bind1: () => bindExceptT(dictMonad)});
|
||||
const bindExceptT = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return {
|
||||
bind: v => k => bind(v)(v2 => {
|
||||
if (v2.tag === "Left") { return pure(Data$dEither.$Either("Left", v2._1)); }
|
||||
if (v2.tag === "Right") { return k(v2._1); }
|
||||
$runtime.fail();
|
||||
}),
|
||||
Apply0: () => applyExceptT(dictMonad)
|
||||
};
|
||||
};
|
||||
const applyExceptT = dictMonad => {
|
||||
const $1 = dictMonad.Bind1().Apply0().Functor0();
|
||||
const functorExceptT1 = {map: f => $1.map(Data$dEither.functorEither.map(f))};
|
||||
return {
|
||||
apply: (() => {
|
||||
const bind = bindExceptT(dictMonad).bind;
|
||||
const pure = applicativeExceptT(dictMonad).pure;
|
||||
return f => a => bind(f)(f$p => bind(a)(a$p => pure(f$p(a$p))));
|
||||
})(),
|
||||
Functor0: () => functorExceptT1
|
||||
};
|
||||
};
|
||||
const applicativeExceptT = dictMonad => (
|
||||
{
|
||||
pure: (() => {
|
||||
const $1 = dictMonad.Applicative0().pure;
|
||||
return x => $1(Data$dEither.$Either("Right", x));
|
||||
})(),
|
||||
Apply0: () => applyExceptT(dictMonad)
|
||||
}
|
||||
);
|
||||
const semigroupExceptT = dictMonad => {
|
||||
const $1 = applyExceptT(dictMonad);
|
||||
const map = $1.Functor0().map;
|
||||
return dictSemigroup => ({append: a => b => $1.apply(map(dictSemigroup.append)(a))(b)});
|
||||
};
|
||||
const monadAskExceptT = dictMonadAsk => {
|
||||
const Monad0 = dictMonadAsk.Monad0();
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(Monad0), Bind1: () => bindExceptT(Monad0)};
|
||||
return {ask: monadTransExceptT.lift(Monad0)(dictMonadAsk.ask), Monad0: () => monadExceptT1};
|
||||
};
|
||||
const monadReaderExceptT = dictMonadReader => {
|
||||
const monadAskExceptT1 = monadAskExceptT(dictMonadReader.MonadAsk0());
|
||||
return {local: f => dictMonadReader.local(f), MonadAsk0: () => monadAskExceptT1};
|
||||
};
|
||||
const monadContExceptT = dictMonadCont => {
|
||||
const $1 = dictMonadCont.Monad0();
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT($1), Bind1: () => bindExceptT($1)};
|
||||
return {callCC: f => dictMonadCont.callCC(c => f(a => c(Data$dEither.$Either("Right", a)))), Monad0: () => monadExceptT1};
|
||||
};
|
||||
const monadEffectExceptT = dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(Monad0), Bind1: () => bindExceptT(Monad0)};
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $3 = monadTransExceptT.lift(Monad0);
|
||||
return x => $3(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadExceptT1
|
||||
};
|
||||
};
|
||||
const monadRecExceptT = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(Monad0), Bind1: () => bindExceptT(Monad0)};
|
||||
return {
|
||||
tailRecM: f => dictMonadRec.tailRecM(a => bind(f(a))(m$p => pure((() => {
|
||||
if (m$p.tag === "Left") { return Control$dMonad$dRec$dClass.$Step("Done", Data$dEither.$Either("Left", m$p._1)); }
|
||||
if (m$p.tag === "Right") {
|
||||
if (m$p._1.tag === "Loop") { return Control$dMonad$dRec$dClass.$Step("Loop", m$p._1._1); }
|
||||
if (m$p._1.tag === "Done") { return Control$dMonad$dRec$dClass.$Step("Done", Data$dEither.$Either("Right", m$p._1._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
})()))),
|
||||
Monad0: () => monadExceptT1
|
||||
};
|
||||
};
|
||||
const monadStateExceptT = dictMonadState => {
|
||||
const Monad0 = dictMonadState.Monad0();
|
||||
const lift1 = monadTransExceptT.lift(Monad0);
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(Monad0), Bind1: () => bindExceptT(Monad0)};
|
||||
return {state: f => lift1(dictMonadState.state(f)), Monad0: () => monadExceptT1};
|
||||
};
|
||||
const monadTellExceptT = dictMonadTell => {
|
||||
const Monad1 = dictMonadTell.Monad1();
|
||||
const Semigroup0 = dictMonadTell.Semigroup0();
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(Monad1), Bind1: () => bindExceptT(Monad1)};
|
||||
return {
|
||||
tell: (() => {
|
||||
const $4 = monadTransExceptT.lift(Monad1);
|
||||
return x => $4(dictMonadTell.tell(x));
|
||||
})(),
|
||||
Semigroup0: () => Semigroup0,
|
||||
Monad1: () => monadExceptT1
|
||||
};
|
||||
};
|
||||
const monadWriterExceptT = dictMonadWriter => {
|
||||
const MonadTell1 = dictMonadWriter.MonadTell1();
|
||||
const Monad1 = MonadTell1.Monad1();
|
||||
const bind = Monad1.Bind1().bind;
|
||||
const pure = Monad1.Applicative0().pure;
|
||||
const Monoid0 = dictMonadWriter.Monoid0();
|
||||
const monadTellExceptT1 = monadTellExceptT(MonadTell1);
|
||||
return {
|
||||
listen: v => bind(dictMonadWriter.listen(v))(v$1 => pure((() => {
|
||||
if (v$1._1.tag === "Left") { return Data$dEither.$Either("Left", v$1._1._1); }
|
||||
if (v$1._1.tag === "Right") { return Data$dEither.$Either("Right", Data$dTuple.$Tuple(v$1._1._1, v$1._2)); }
|
||||
$runtime.fail();
|
||||
})())),
|
||||
pass: v => dictMonadWriter.pass(bind(v)(a => pure((() => {
|
||||
if (a.tag === "Left") { return Data$dTuple.$Tuple(Data$dEither.$Either("Left", a._1), identity); }
|
||||
if (a.tag === "Right") { return Data$dTuple.$Tuple(Data$dEither.$Either("Right", a._1._1), a._1._2); }
|
||||
$runtime.fail();
|
||||
})()))),
|
||||
Monoid0: () => Monoid0,
|
||||
MonadTell1: () => monadTellExceptT1
|
||||
};
|
||||
};
|
||||
const monadThrowExceptT = dictMonad => {
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(dictMonad), Bind1: () => bindExceptT(dictMonad)};
|
||||
return {
|
||||
throwError: (() => {
|
||||
const $2 = dictMonad.Applicative0().pure;
|
||||
return x => $2(Data$dEither.$Either("Left", x));
|
||||
})(),
|
||||
Monad0: () => monadExceptT1
|
||||
};
|
||||
};
|
||||
const monadErrorExceptT = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadThrowExceptT1 = monadThrowExceptT(dictMonad);
|
||||
return {
|
||||
catchError: v => k => bind(v)(v2 => {
|
||||
if (v2.tag === "Left") { return k(v2._1); }
|
||||
if (v2.tag === "Right") { return pure(Data$dEither.$Either("Right", v2._1)); }
|
||||
$runtime.fail();
|
||||
}),
|
||||
MonadThrow0: () => monadThrowExceptT1
|
||||
};
|
||||
};
|
||||
const monoidExceptT = dictMonad => {
|
||||
const pure = applicativeExceptT(dictMonad).pure;
|
||||
const semigroupExceptT1 = semigroupExceptT(dictMonad);
|
||||
return dictMonoid => {
|
||||
const semigroupExceptT2 = semigroupExceptT1(dictMonoid.Semigroup0());
|
||||
return {mempty: pure(dictMonoid.mempty), Semigroup0: () => semigroupExceptT2};
|
||||
};
|
||||
};
|
||||
const altExceptT = dictSemigroup => dictMonad => {
|
||||
const Bind1 = dictMonad.Bind1();
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const $4 = Bind1.Apply0().Functor0();
|
||||
const functorExceptT1 = {map: f => $4.map(Data$dEither.functorEither.map(f))};
|
||||
return {
|
||||
alt: v => v1 => Bind1.bind(v)(rm => {
|
||||
if (rm.tag === "Right") { return pure(Data$dEither.$Either("Right", rm._1)); }
|
||||
if (rm.tag === "Left") {
|
||||
return Bind1.bind(v1)(rn => {
|
||||
if (rn.tag === "Right") { return pure(Data$dEither.$Either("Right", rn._1)); }
|
||||
if (rn.tag === "Left") { return pure(Data$dEither.$Either("Left", dictSemigroup.append(rm._1)(rn._1))); }
|
||||
$runtime.fail();
|
||||
});
|
||||
}
|
||||
$runtime.fail();
|
||||
}),
|
||||
Functor0: () => functorExceptT1
|
||||
};
|
||||
};
|
||||
const plusExceptT = dictMonoid => {
|
||||
const altExceptT1 = altExceptT(dictMonoid.Semigroup0());
|
||||
return dictMonad => {
|
||||
const altExceptT2 = altExceptT1(dictMonad);
|
||||
return {empty: monadThrowExceptT(dictMonad).throwError(dictMonoid.mempty), Alt0: () => altExceptT2};
|
||||
};
|
||||
};
|
||||
const alternativeExceptT = dictMonoid => {
|
||||
const plusExceptT1 = plusExceptT(dictMonoid);
|
||||
return dictMonad => {
|
||||
const applicativeExceptT1 = applicativeExceptT(dictMonad);
|
||||
const plusExceptT2 = plusExceptT1(dictMonad);
|
||||
return {Applicative0: () => applicativeExceptT1, Plus1: () => plusExceptT2};
|
||||
};
|
||||
};
|
||||
const monadPlusExceptT = dictMonoid => {
|
||||
const alternativeExceptT1 = alternativeExceptT(dictMonoid);
|
||||
return dictMonad => {
|
||||
const monadExceptT1 = {Applicative0: () => applicativeExceptT(dictMonad), Bind1: () => bindExceptT(dictMonad)};
|
||||
const alternativeExceptT2 = alternativeExceptT1(dictMonad);
|
||||
return {Monad0: () => monadExceptT1, Alternative1: () => alternativeExceptT2};
|
||||
};
|
||||
};
|
||||
export {
|
||||
ExceptT,
|
||||
altExceptT,
|
||||
alternativeExceptT,
|
||||
applicativeExceptT,
|
||||
applyExceptT,
|
||||
bindExceptT,
|
||||
except,
|
||||
functorExceptT,
|
||||
identity,
|
||||
mapExceptT,
|
||||
monadAskExceptT,
|
||||
monadContExceptT,
|
||||
monadEffectExceptT,
|
||||
monadErrorExceptT,
|
||||
monadExceptT,
|
||||
monadPlusExceptT,
|
||||
monadReaderExceptT,
|
||||
monadRecExceptT,
|
||||
monadStateExceptT,
|
||||
monadTellExceptT,
|
||||
monadThrowExceptT,
|
||||
monadTransExceptT,
|
||||
monadWriterExceptT,
|
||||
monoidExceptT,
|
||||
newtypeExceptT,
|
||||
plusExceptT,
|
||||
runExceptT,
|
||||
semigroupExceptT,
|
||||
withExceptT
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dExcept$dTrans from "../Control.Monad.Except.Trans/index.js";
|
||||
import * as Data$dIdentity from "../Data.Identity/index.js";
|
||||
const withExcept = /* #__PURE__ */ Control$dMonad$dExcept$dTrans.withExceptT(Data$dIdentity.functorIdentity);
|
||||
const runExcept = x => x;
|
||||
const mapExcept = f => v => f(v);
|
||||
export {mapExcept, runExcept, withExcept};
|
@ -0,0 +1,46 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dBind from "../Control.Bind/index.js";
|
||||
import * as Control$dMonad$dExcept$dTrans from "../Control.Monad.Except.Trans/index.js";
|
||||
import * as Control$dMonad$dFree from "../Control.Monad.Free/index.js";
|
||||
import * as Control$dMonad$dMaybe$dTrans from "../Control.Monad.Maybe.Trans/index.js";
|
||||
import * as Control$dMonad$dReader$dTrans from "../Control.Monad.Reader.Trans/index.js";
|
||||
import * as Control$dMonad$dState$dTrans from "../Control.Monad.State.Trans/index.js";
|
||||
import * as Control$dMonad$dWriter$dTrans from "../Control.Monad.Writer.Trans/index.js";
|
||||
import * as Data$dCatList from "../Data.CatList/index.js";
|
||||
import * as Data$dCatQueue from "../Data.CatQueue/index.js";
|
||||
import * as Data$dList$dTypes from "../Data.List.Types/index.js";
|
||||
const wrapFree = dict => dict.wrapFree;
|
||||
const monadFreeWriterT = dictFunctor => dictMonadFree => {
|
||||
const Monad0 = dictMonadFree.Monad0();
|
||||
return dictMonoid => {
|
||||
const monadWriterT = Control$dMonad$dWriter$dTrans.monadWriterT(dictMonoid)(Monad0);
|
||||
return {wrapFree: f => dictMonadFree.wrapFree(dictFunctor.map(Control$dMonad$dWriter$dTrans.runWriterT)(f)), Monad0: () => monadWriterT};
|
||||
};
|
||||
};
|
||||
const monadFreeStateT = dictFunctor => dictMonadFree => {
|
||||
const $2 = dictMonadFree.Monad0();
|
||||
const monadStateT = {Applicative0: () => Control$dMonad$dState$dTrans.applicativeStateT($2), Bind1: () => Control$dMonad$dState$dTrans.bindStateT($2)};
|
||||
return {wrapFree: f => s => dictMonadFree.wrapFree(dictFunctor.map(st => st(s))(f)), Monad0: () => monadStateT};
|
||||
};
|
||||
const monadFreeReaderT = dictFunctor => dictMonadFree => {
|
||||
const monadReaderT = Control$dMonad$dReader$dTrans.monadReaderT(dictMonadFree.Monad0());
|
||||
return {wrapFree: f => r => dictMonadFree.wrapFree(dictFunctor.map(rt => rt(r))(f)), Monad0: () => monadReaderT};
|
||||
};
|
||||
const monadFreeMaybeT = dictFunctor => dictMonadFree => {
|
||||
const $2 = dictMonadFree.Monad0();
|
||||
const monadMaybeT = {Applicative0: () => Control$dMonad$dMaybe$dTrans.applicativeMaybeT($2), Bind1: () => Control$dMonad$dMaybe$dTrans.bindMaybeT($2)};
|
||||
return {wrapFree: f => dictMonadFree.wrapFree(dictFunctor.map(Control$dMonad$dMaybe$dTrans.runMaybeT)(f)), Monad0: () => monadMaybeT};
|
||||
};
|
||||
const monadFreeFree = {
|
||||
wrapFree: x => Control$dMonad$dFree.$Free(
|
||||
Control$dMonad$dFree.$FreeView("Bind", x, x$1 => Control$dMonad$dFree.$Free(Control$dMonad$dFree.$FreeView("Return", x$1), Data$dCatList.CatNil)),
|
||||
Data$dCatList.link(Data$dCatList.CatNil)(Data$dCatList.$CatList("CatCons", Control$dBind.identity, Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)))
|
||||
),
|
||||
Monad0: () => Control$dMonad$dFree.freeMonad
|
||||
};
|
||||
const monadFreeExceptT = dictFunctor => dictMonadFree => {
|
||||
const $2 = dictMonadFree.Monad0();
|
||||
const monadExceptT = {Applicative0: () => Control$dMonad$dExcept$dTrans.applicativeExceptT($2), Bind1: () => Control$dMonad$dExcept$dTrans.bindExceptT($2)};
|
||||
return {wrapFree: f => dictMonadFree.wrapFree(dictFunctor.map(Control$dMonad$dExcept$dTrans.runExceptT)(f)), Monad0: () => monadExceptT};
|
||||
};
|
||||
export {monadFreeExceptT, monadFreeFree, monadFreeMaybeT, monadFreeReaderT, monadFreeStateT, monadFreeWriterT, wrapFree};
|
@ -0,0 +1,319 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dBind from "../Control.Bind/index.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dCatList from "../Data.CatList/index.js";
|
||||
import * as Data$dCatQueue from "../Data.CatQueue/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dList$dTypes from "../Data.List.Types/index.js";
|
||||
import * as Data$dOrdering from "../Data.Ordering/index.js";
|
||||
import * as Unsafe$dCoerce from "../Unsafe.Coerce/index.js";
|
||||
const $Free = (_1, _2) => ({tag: "Free", _1, _2});
|
||||
const $FreeView = (tag, _1, _2) => ({tag, _1, _2});
|
||||
const identity = x => x;
|
||||
const Free = value0 => value1 => $Free(value0, value1);
|
||||
const Return = value0 => $FreeView("Return", value0);
|
||||
const Bind = value0 => value1 => $FreeView("Bind", value0, value1);
|
||||
const toView = toView$a0$copy => {
|
||||
let toView$a0 = toView$a0$copy, toView$c = true, toView$r;
|
||||
while (toView$c) {
|
||||
const v = toView$a0;
|
||||
if (v._1.tag === "Return") {
|
||||
const v2 = Data$dCatList.uncons(v._2);
|
||||
if (v2.tag === "Nothing") {
|
||||
toView$c = false;
|
||||
toView$r = $FreeView("Return", v._1._1);
|
||||
continue;
|
||||
}
|
||||
if (v2.tag === "Just") {
|
||||
toView$a0 = (() => {
|
||||
const $2 = v2._1._1(v._1._1);
|
||||
return $Free($2._1, Data$dCatList.link($2._2)(v2._1._2));
|
||||
})();
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
}
|
||||
if (v._1.tag === "Bind") {
|
||||
toView$c = false;
|
||||
toView$r = $FreeView(
|
||||
"Bind",
|
||||
v._1._1,
|
||||
a => {
|
||||
const $2 = v._1._2(a);
|
||||
return $Free($2._1, Data$dCatList.link($2._2)(v._2));
|
||||
}
|
||||
);
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return toView$r;
|
||||
};
|
||||
const runFreeM = dictFunctor => dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const map2 = Monad0.Bind1().Apply0().Functor0().map;
|
||||
const pure1 = Monad0.Applicative0().pure;
|
||||
return k => dictMonadRec.tailRecM(f => {
|
||||
const v = toView(f);
|
||||
if (v.tag === "Return") { return map2(Control$dMonad$dRec$dClass.Done)(pure1(v._1)); }
|
||||
if (v.tag === "Bind") { return map2(Control$dMonad$dRec$dClass.Loop)(k(dictFunctor.map(v._2)(v._1))); }
|
||||
$runtime.fail();
|
||||
});
|
||||
};
|
||||
const runFree = dictFunctor => k => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const f = go$a0;
|
||||
const v = toView(f);
|
||||
if (v.tag === "Return") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Bind") {
|
||||
go$a0 = k(dictFunctor.map(v._2)(v._1));
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go;
|
||||
};
|
||||
const resume$p = k => j => f => {
|
||||
const v = toView(f);
|
||||
if (v.tag === "Return") { return j(v._1); }
|
||||
if (v.tag === "Bind") { return k(v._1)(v._2); }
|
||||
$runtime.fail();
|
||||
};
|
||||
const resume = dictFunctor => resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right);
|
||||
const wrap = f => $Free($FreeView("Bind", f, Unsafe$dCoerce.unsafeCoerce), Data$dCatList.CatNil);
|
||||
const suspendF = dictApplicative => f => $Free($FreeView("Bind", dictApplicative.pure(f), Unsafe$dCoerce.unsafeCoerce), Data$dCatList.CatNil);
|
||||
const freeMonad = {Applicative0: () => freeApplicative, Bind1: () => freeBind};
|
||||
const freeFunctor = {map: k => f => freeBind.bind(f)(x => freeApplicative.pure(k(x)))};
|
||||
const freeBind = {
|
||||
bind: v => k => $Free(v._1, Data$dCatList.link(v._2)(Data$dCatList.$CatList("CatCons", k, Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)))),
|
||||
Apply0: () => freeApply
|
||||
};
|
||||
const freeApply = {
|
||||
apply: f => a => $Free(
|
||||
f._1,
|
||||
Data$dCatList.link(f._2)(Data$dCatList.$CatList(
|
||||
"CatCons",
|
||||
f$p => $Free(
|
||||
a._1,
|
||||
Data$dCatList.link(a._2)(Data$dCatList.$CatList("CatCons", a$p => freeApplicative.pure(f$p(a$p)), Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)))
|
||||
),
|
||||
Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)
|
||||
))
|
||||
),
|
||||
Functor0: () => freeFunctor
|
||||
};
|
||||
const freeApplicative = {pure: x => $Free($FreeView("Return", x), Data$dCatList.CatNil), Apply0: () => freeApply};
|
||||
const semigroupFree = dictSemigroup => (
|
||||
{
|
||||
append: a => b => freeApply.apply($Free(
|
||||
a._1,
|
||||
Data$dCatList.link(a._2)(Data$dCatList.$CatList(
|
||||
"CatCons",
|
||||
x => $Free($FreeView("Return", dictSemigroup.append(x)), Data$dCatList.CatNil),
|
||||
Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)
|
||||
))
|
||||
))(b)
|
||||
}
|
||||
);
|
||||
const freeMonadRec = {
|
||||
tailRecM: k => a => {
|
||||
const $2 = k(a);
|
||||
return $Free(
|
||||
$2._1,
|
||||
Data$dCatList.link($2._2)(Data$dCatList.$CatList(
|
||||
"CatCons",
|
||||
v => {
|
||||
if (v.tag === "Loop") { return freeMonadRec.tailRecM(k)(v._1); }
|
||||
if (v.tag === "Done") { return $Free($FreeView("Return", v._1), Data$dCatList.CatNil); }
|
||||
$runtime.fail();
|
||||
},
|
||||
Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)
|
||||
))
|
||||
);
|
||||
},
|
||||
Monad0: () => freeMonad
|
||||
};
|
||||
const liftF = f => $Free($FreeView("Bind", f, x => $Free($FreeView("Return", x), Data$dCatList.CatNil)), Data$dCatList.CatNil);
|
||||
const freeMonadTrans = {lift: dictMonad => liftF};
|
||||
const monoidFree = dictMonoid => {
|
||||
const semigroupFree1 = semigroupFree(dictMonoid.Semigroup0());
|
||||
return {mempty: $Free($FreeView("Return", dictMonoid.mempty), Data$dCatList.CatNil), Semigroup0: () => semigroupFree1};
|
||||
};
|
||||
const substFree = k => {
|
||||
const go = f => {
|
||||
const v = toView(f);
|
||||
if (v.tag === "Return") { return $Free($FreeView("Return", v._1), Data$dCatList.CatNil); }
|
||||
if (v.tag === "Bind") {
|
||||
const $4 = k(v._1);
|
||||
return $Free($4._1, Data$dCatList.link($4._2)(Data$dCatList.$CatList("CatCons", x => go(v._2(x)), Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil))));
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go;
|
||||
};
|
||||
const hoistFree = k => substFree(x => $Free($FreeView("Bind", k(x), x$1 => $Free($FreeView("Return", x$1), Data$dCatList.CatNil)), Data$dCatList.CatNil));
|
||||
const foldableFree = dictFunctor => dictFoldable => (
|
||||
{
|
||||
foldMap: dictMonoid => {
|
||||
const foldMap1 = dictFoldable.foldMap(dictMonoid);
|
||||
return f => {
|
||||
const go = x => {
|
||||
const $7 = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(x);
|
||||
if ($7.tag === "Left") { return foldMap1(go)($7._1); }
|
||||
if ($7.tag === "Right") { return f($7._1); }
|
||||
$runtime.fail();
|
||||
};
|
||||
return go;
|
||||
};
|
||||
},
|
||||
foldl: f => {
|
||||
const go = r => x => {
|
||||
const $6 = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(x);
|
||||
if ($6.tag === "Left") { return dictFoldable.foldl(go)(r)($6._1); }
|
||||
if ($6.tag === "Right") { return f(r)($6._1); }
|
||||
$runtime.fail();
|
||||
};
|
||||
return go;
|
||||
},
|
||||
foldr: f => {
|
||||
const go = r => x => {
|
||||
const $6 = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(x);
|
||||
if ($6.tag === "Left") { return dictFoldable.foldr(b => a => go(a)(b))(r)($6._1); }
|
||||
if ($6.tag === "Right") { return f($6._1)(r); }
|
||||
$runtime.fail();
|
||||
};
|
||||
return go;
|
||||
}
|
||||
}
|
||||
);
|
||||
const traversableFree = dictTraversable => {
|
||||
const Functor0 = dictTraversable.Functor0();
|
||||
const foldableFree1 = foldableFree(Functor0)(dictTraversable.Foldable1());
|
||||
return {
|
||||
traverse: dictApplicative => {
|
||||
const map1 = dictApplicative.Apply0().Functor0().map;
|
||||
const traverse1 = dictTraversable.traverse(dictApplicative);
|
||||
return f => {
|
||||
const go = x => {
|
||||
const $9 = resume$p(g => i => Data$dEither.$Either("Left", Functor0.map(i)(g)))(Data$dEither.Right)(x);
|
||||
if ($9.tag === "Left") {
|
||||
return map1(x$1 => $Free(
|
||||
$FreeView("Bind", x$1, x$2 => $Free($FreeView("Return", x$2), Data$dCatList.CatNil)),
|
||||
Data$dCatList.link(Data$dCatList.CatNil)(Data$dCatList.$CatList(
|
||||
"CatCons",
|
||||
Control$dBind.identity,
|
||||
Data$dCatQueue.$CatQueue(Data$dList$dTypes.Nil, Data$dList$dTypes.Nil)
|
||||
))
|
||||
))(traverse1(go)($9._1));
|
||||
}
|
||||
if ($9.tag === "Right") { return map1(freeApplicative.pure)(f($9._1)); }
|
||||
$runtime.fail();
|
||||
};
|
||||
return go;
|
||||
};
|
||||
},
|
||||
sequence: dictApplicative => tma => traversableFree(dictTraversable).traverse(dictApplicative)(identity)(tma),
|
||||
Functor0: () => freeFunctor,
|
||||
Foldable1: () => foldableFree1
|
||||
};
|
||||
};
|
||||
const foldFree = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const map1 = Monad0.Bind1().Apply0().Functor0().map;
|
||||
const pure1 = Monad0.Applicative0().pure;
|
||||
return k => dictMonadRec.tailRecM(f => {
|
||||
const v = toView(f);
|
||||
if (v.tag === "Return") { return map1(Control$dMonad$dRec$dClass.Done)(pure1(v._1)); }
|
||||
if (v.tag === "Bind") { return map1(x => Control$dMonad$dRec$dClass.$Step("Loop", v._2(x)))(k(v._1)); }
|
||||
$runtime.fail();
|
||||
});
|
||||
};
|
||||
const eqFree = dictFunctor => dictEq1 => dictEq => (
|
||||
{
|
||||
eq: x => y => {
|
||||
const v = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(y);
|
||||
const v1 = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(x);
|
||||
if (v1.tag === "Left") {
|
||||
if (v.tag === "Left") { return dictEq1.eq1(eqFree(dictFunctor)(dictEq1)(dictEq))(v1._1)(v._1); }
|
||||
return false;
|
||||
}
|
||||
if (v1.tag === "Right") {
|
||||
if (v.tag === "Right") { return dictEq.eq(v1._1)(v._1); }
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
const ordFree = dictFunctor => dictOrd1 => {
|
||||
const eqFree2 = eqFree(dictFunctor)(dictOrd1.Eq10());
|
||||
return dictOrd => {
|
||||
const eqFree3 = eqFree2(dictOrd.Eq0());
|
||||
return {
|
||||
compare: x => y => {
|
||||
const v = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(y);
|
||||
const v1 = resume$p(g => i => Data$dEither.$Either("Left", dictFunctor.map(i)(g)))(Data$dEither.Right)(x);
|
||||
if (v1.tag === "Left") {
|
||||
if (v.tag === "Left") { return dictOrd1.compare1(ordFree(dictFunctor)(dictOrd1)(dictOrd))(v1._1)(v._1); }
|
||||
return Data$dOrdering.LT;
|
||||
}
|
||||
if (v.tag === "Left") { return Data$dOrdering.GT; }
|
||||
if (v1.tag === "Right") {
|
||||
if (v.tag === "Right") { return dictOrd.compare(v1._1)(v._1); }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
},
|
||||
Eq0: () => eqFree3
|
||||
};
|
||||
};
|
||||
};
|
||||
const eq1Free = dictFunctor => dictEq1 => ({eq1: dictEq => eqFree(dictFunctor)(dictEq1)(dictEq).eq});
|
||||
const ord1Free = dictFunctor => dictOrd1 => {
|
||||
const ordFree2 = ordFree(dictFunctor)(dictOrd1);
|
||||
const $3 = dictOrd1.Eq10();
|
||||
const eq1Free2 = {eq1: dictEq => eqFree(dictFunctor)($3)(dictEq).eq};
|
||||
return {compare1: dictOrd => ordFree2(dictOrd).compare, Eq10: () => eq1Free2};
|
||||
};
|
||||
export {
|
||||
$Free,
|
||||
$FreeView,
|
||||
Bind,
|
||||
Free,
|
||||
Return,
|
||||
eq1Free,
|
||||
eqFree,
|
||||
foldFree,
|
||||
foldableFree,
|
||||
freeApplicative,
|
||||
freeApply,
|
||||
freeBind,
|
||||
freeFunctor,
|
||||
freeMonad,
|
||||
freeMonadRec,
|
||||
freeMonadTrans,
|
||||
hoistFree,
|
||||
identity,
|
||||
liftF,
|
||||
monoidFree,
|
||||
ord1Free,
|
||||
ordFree,
|
||||
resume,
|
||||
resume$p,
|
||||
runFree,
|
||||
runFreeM,
|
||||
semigroupFree,
|
||||
substFree,
|
||||
suspendF,
|
||||
toView,
|
||||
traversableFree,
|
||||
wrap
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
const sized = dict => dict.sized;
|
||||
const resize = dict => dict.resize;
|
||||
const chooseInt = dict => dict.chooseInt;
|
||||
const chooseFloat = dict => dict.chooseFloat;
|
||||
const chooseBool = dict => dict.chooseBool;
|
||||
export {chooseBool, chooseFloat, chooseInt, resize, sized};
|
@ -0,0 +1,50 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dGen from "../Control.Monad.Gen/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dIdentity from "../Data.Identity/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dNonEmpty from "../Data.NonEmpty/index.js";
|
||||
import * as Data$dOrd from "../Data.Ord/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const max = x => y => {
|
||||
const v = Data$dOrd.ordInt.compare(x)(y);
|
||||
if (v.tag === "LT") { return y; }
|
||||
if (v.tag === "EQ") { return x; }
|
||||
if (v.tag === "GT") { return x; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const genTuple = dictApply => {
|
||||
const map = dictApply.Functor0().map;
|
||||
return a => b => dictApply.apply(map(Data$dTuple.Tuple)(a))(b);
|
||||
};
|
||||
const genNonEmpty = dictMonadRec => dictMonadGen => {
|
||||
const Apply0 = dictMonadGen.Monad0().Bind1().Apply0();
|
||||
const map = Apply0.Functor0().map;
|
||||
const unfoldable1 = Control$dMonad$dGen.unfoldable(dictMonadRec)(dictMonadGen);
|
||||
return dictUnfoldable => {
|
||||
const unfoldable2 = unfoldable1(dictUnfoldable);
|
||||
return gen => Apply0.apply(map(Data$dNonEmpty.NonEmpty)(gen))(dictMonadGen.resize(x => max(0)(x - 1 | 0))(unfoldable2(gen)));
|
||||
};
|
||||
};
|
||||
const genMaybe$p = dictMonadGen => {
|
||||
const Monad0 = dictMonadGen.Monad0();
|
||||
const Bind1 = Monad0.Bind1();
|
||||
const map = Bind1.Apply0().Functor0().map;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
return bias => gen => Bind1.bind(dictMonadGen.chooseFloat(0.0)(1.0))(n => {
|
||||
if (n < bias) { return map(Data$dMaybe.Just)(gen); }
|
||||
return pure(Data$dMaybe.Nothing);
|
||||
});
|
||||
};
|
||||
const genMaybe = dictMonadGen => genMaybe$p(dictMonadGen)(0.75);
|
||||
const genIdentity = dictFunctor => dictFunctor.map(Data$dIdentity.Identity);
|
||||
const genEither$p = dictMonadGen => {
|
||||
const Bind1 = dictMonadGen.Monad0().Bind1();
|
||||
const map = Bind1.Apply0().Functor0().map;
|
||||
return bias => genA => genB => Bind1.bind(dictMonadGen.chooseFloat(0.0)(1.0))(n => {
|
||||
if (n < bias) { return map(Data$dEither.Left)(genA); }
|
||||
return map(Data$dEither.Right)(genB);
|
||||
});
|
||||
};
|
||||
const genEither = dictMonadGen => genEither$p(dictMonadGen)(0.5);
|
||||
export {genEither, genEither$p, genIdentity, genMaybe, genMaybe$p, genNonEmpty, genTuple, max};
|
@ -0,0 +1,130 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dSemigroup$dLast from "../Data.Semigroup.Last/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const $LL = (tag, _1, _2) => ({tag, _1, _2});
|
||||
const monoidAdditive = /* #__PURE__ */ (() => {
|
||||
const semigroupAdditive1 = {append: v => v1 => v + v1};
|
||||
return {mempty: 0.0, Semigroup0: () => semigroupAdditive1};
|
||||
})();
|
||||
const Cons = value0 => value1 => $LL("Cons", value0, value1);
|
||||
const Nil = /* #__PURE__ */ $LL("Nil");
|
||||
const unfoldable = dictMonadRec => dictMonadGen => {
|
||||
const Monad0 = dictMonadGen.Monad0();
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const Bind1 = Monad0.Bind1();
|
||||
const map = Bind1.Apply0().Functor0().map;
|
||||
return dictUnfoldable => gen => map(dictUnfoldable.unfoldr(v => {
|
||||
if (v.tag === "Nil") { return Data$dMaybe.Nothing; }
|
||||
if (v.tag === "Cons") { return Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(v._1, v._2)); }
|
||||
$runtime.fail();
|
||||
}))(dictMonadGen.sized((() => {
|
||||
const $8 = dictMonadRec.tailRecM(v => {
|
||||
if (v._2 <= 0) { return pure(Control$dMonad$dRec$dClass.$Step("Done", v._1)); }
|
||||
return Bind1.bind(gen)(x => pure(Control$dMonad$dRec$dClass.$Step("Loop", Data$dTuple.$Tuple($LL("Cons", x, v._1), v._2 - 1 | 0))));
|
||||
});
|
||||
const $9 = Data$dTuple.Tuple(Nil);
|
||||
return x => $8($9(x));
|
||||
})()));
|
||||
};
|
||||
const semigroupFreqSemigroup = {
|
||||
append: v => v1 => pos => {
|
||||
const v2 = v(pos);
|
||||
if (v2._1.tag === "Just") { return v1(v2._1._1); }
|
||||
return v2;
|
||||
}
|
||||
};
|
||||
const fromIndex = dictFoldable1 => {
|
||||
const foldMap1 = dictFoldable1.foldMap1(Data$dSemigroup$dLast.semigroupLast);
|
||||
const foldr = dictFoldable1.Foldable0().foldr;
|
||||
return i => xs => {
|
||||
const go = go$a0$copy => go$a1$copy => {
|
||||
let go$a0 = go$a0$copy, go$a1 = go$a1$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0, v1 = go$a1;
|
||||
if (v1.tag === "Cons") {
|
||||
if (v1._2.tag === "Nil") {
|
||||
go$c = false;
|
||||
go$r = v1._1;
|
||||
continue;
|
||||
}
|
||||
if (v <= 0) {
|
||||
go$c = false;
|
||||
go$r = v1._1;
|
||||
continue;
|
||||
}
|
||||
go$a0 = v - 1 | 0;
|
||||
go$a1 = v1._2;
|
||||
continue;
|
||||
}
|
||||
if (v1.tag === "Nil") {
|
||||
go$c = false;
|
||||
go$r = foldMap1(Data$dSemigroup$dLast.Last)(xs);
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go(i)(foldr(Cons)(Nil)(xs));
|
||||
};
|
||||
};
|
||||
const oneOf = dictMonadGen => {
|
||||
const bind = dictMonadGen.Monad0().Bind1().bind;
|
||||
return dictFoldable1 => {
|
||||
const length = dictFoldable1.Foldable0().foldl(c => v => 1 + c | 0)(0);
|
||||
const fromIndex1 = fromIndex(dictFoldable1);
|
||||
return xs => bind(dictMonadGen.chooseInt(0)(length(xs) - 1 | 0))(n => fromIndex1(n)(xs));
|
||||
};
|
||||
};
|
||||
const freqSemigroup = v => pos => {
|
||||
if (pos >= v._1) { return Data$dTuple.$Tuple(Data$dMaybe.$Maybe("Just", pos - v._1), v._2); }
|
||||
return Data$dTuple.$Tuple(Data$dMaybe.Nothing, v._2);
|
||||
};
|
||||
const frequency = dictMonadGen => {
|
||||
const bind = dictMonadGen.Monad0().Bind1().bind;
|
||||
return dictFoldable1 => {
|
||||
const foldMap = dictFoldable1.Foldable0().foldMap(monoidAdditive);
|
||||
const foldMap1 = dictFoldable1.foldMap1(semigroupFreqSemigroup);
|
||||
return xs => bind(dictMonadGen.chooseFloat(0.0)(foldMap(Data$dTuple.fst)(xs)))((() => {
|
||||
const $6 = foldMap1(freqSemigroup)(xs);
|
||||
return x => $6(x)._2;
|
||||
})());
|
||||
};
|
||||
};
|
||||
const filtered = dictMonadRec => dictMonadGen => {
|
||||
const $2 = dictMonadGen.Monad0().Bind1().Apply0().Functor0();
|
||||
return gen => dictMonadRec.tailRecM(v => $2.map(a => {
|
||||
if (a.tag === "Nothing") { return Control$dMonad$dRec$dClass.$Step("Loop", Data$dUnit.unit); }
|
||||
if (a.tag === "Just") { return Control$dMonad$dRec$dClass.$Step("Done", a._1); }
|
||||
$runtime.fail();
|
||||
})(gen))(Data$dUnit.unit);
|
||||
};
|
||||
const suchThat = dictMonadRec => dictMonadGen => {
|
||||
const filtered2 = filtered(dictMonadRec)(dictMonadGen);
|
||||
const $3 = dictMonadGen.Monad0().Bind1().Apply0().Functor0();
|
||||
return gen => pred => filtered2($3.map(a => {
|
||||
if (pred(a)) { return Data$dMaybe.$Maybe("Just", a); }
|
||||
return Data$dMaybe.Nothing;
|
||||
})(gen));
|
||||
};
|
||||
const elements = dictMonadGen => {
|
||||
const Monad0 = dictMonadGen.Monad0();
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
return dictFoldable1 => {
|
||||
const length = dictFoldable1.Foldable0().foldl(c => v => 1 + c | 0)(0);
|
||||
const fromIndex1 = fromIndex(dictFoldable1);
|
||||
return xs => bind(dictMonadGen.chooseInt(0)(length(xs) - 1 | 0))(n => pure(fromIndex1(n)(xs)));
|
||||
};
|
||||
};
|
||||
const choose = dictMonadGen => {
|
||||
const bind = dictMonadGen.Monad0().Bind1().bind;
|
||||
return genA => genB => bind(dictMonadGen.chooseBool)(v => {
|
||||
if (v) { return genA; }
|
||||
return genB;
|
||||
});
|
||||
};
|
||||
export {$LL, Cons, Nil, choose, elements, filtered, freqSemigroup, frequency, fromIndex, monoidAdditive, oneOf, semigroupFreqSemigroup, suchThat, unfoldable};
|
@ -0,0 +1,78 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
const IdentityT = x => x;
|
||||
const traversableIdentityT = dictTraversable => dictTraversable;
|
||||
const runIdentityT = v => v;
|
||||
const plusIdentityT = dictPlus => dictPlus;
|
||||
const newtypeIdentityT = {Coercible0: () => undefined};
|
||||
const monadWriterIdentityT = dictMonadWriter => dictMonadWriter;
|
||||
const monadTransIdentityT = {lift: dictMonad => IdentityT};
|
||||
const monadThrowIdentityT = dictMonadThrow => dictMonadThrow;
|
||||
const monadTellIdentityT = dictMonadTell => dictMonadTell;
|
||||
const monadStateIdentityT = dictMonadState => dictMonadState;
|
||||
const monadRecIdentityT = dictMonadRec => dictMonadRec;
|
||||
const monadReaderIdentityT = dictMonadReader => dictMonadReader;
|
||||
const monadPlusIdentityT = dictMonadPlus => dictMonadPlus;
|
||||
const monadIdentityT = dictMonad => dictMonad;
|
||||
const monadErrorIdentityT = dictMonadError => dictMonadError;
|
||||
const monadEffectIdentityT = dictMonadEffect => dictMonadEffect;
|
||||
const monadContIdentityT = dictMonadCont => dictMonadCont;
|
||||
const monadAskIdentityT = dictMonadAsk => dictMonadAsk;
|
||||
const mapIdentityT = f => v => f(v);
|
||||
const functorIdentityT = dictFunctor => dictFunctor;
|
||||
const foldableIdentityT = dictFoldable => dictFoldable;
|
||||
const eqIdentityT = dictEq1 => dictEq => {
|
||||
const eq11 = dictEq1.eq1(dictEq);
|
||||
return {eq: x => y => eq11(x)(y)};
|
||||
};
|
||||
const ordIdentityT = dictOrd1 => {
|
||||
const $1 = dictOrd1.Eq10();
|
||||
return dictOrd => {
|
||||
const compare11 = dictOrd1.compare1(dictOrd);
|
||||
const eq11 = $1.eq1(dictOrd.Eq0());
|
||||
const eqIdentityT2 = {eq: x => y => eq11(x)(y)};
|
||||
return {compare: x => y => compare11(x)(y), Eq0: () => eqIdentityT2};
|
||||
};
|
||||
};
|
||||
const eq1IdentityT = dictEq1 => ({eq1: dictEq => dictEq1.eq1(dictEq)});
|
||||
const ord1IdentityT = dictOrd1 => {
|
||||
const $1 = dictOrd1.Eq10();
|
||||
const eq1IdentityT1 = {eq1: dictEq => $1.eq1(dictEq)};
|
||||
return {compare1: dictOrd => dictOrd1.compare1(dictOrd), Eq10: () => eq1IdentityT1};
|
||||
};
|
||||
const bindIdentityT = dictBind => dictBind;
|
||||
const applyIdentityT = dictApply => dictApply;
|
||||
const applicativeIdentityT = dictApplicative => dictApplicative;
|
||||
const alternativeIdentityT = dictAlternative => dictAlternative;
|
||||
const altIdentityT = dictAlt => dictAlt;
|
||||
export {
|
||||
IdentityT,
|
||||
altIdentityT,
|
||||
alternativeIdentityT,
|
||||
applicativeIdentityT,
|
||||
applyIdentityT,
|
||||
bindIdentityT,
|
||||
eq1IdentityT,
|
||||
eqIdentityT,
|
||||
foldableIdentityT,
|
||||
functorIdentityT,
|
||||
mapIdentityT,
|
||||
monadAskIdentityT,
|
||||
monadContIdentityT,
|
||||
monadEffectIdentityT,
|
||||
monadErrorIdentityT,
|
||||
monadIdentityT,
|
||||
monadPlusIdentityT,
|
||||
monadReaderIdentityT,
|
||||
monadRecIdentityT,
|
||||
monadStateIdentityT,
|
||||
monadTellIdentityT,
|
||||
monadThrowIdentityT,
|
||||
monadTransIdentityT,
|
||||
monadWriterIdentityT,
|
||||
newtypeIdentityT,
|
||||
ord1IdentityT,
|
||||
ordIdentityT,
|
||||
plusIdentityT,
|
||||
runIdentityT,
|
||||
traversableIdentityT
|
||||
};
|
@ -0,0 +1,509 @@
|
||||
// | This module defines the list monad transformer, `ListT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dLazy from "../Data.Lazy/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const $Step = (tag, _1, _2) => ({tag, _1, _2});
|
||||
const identity = x => x;
|
||||
const Yield = value0 => value1 => $Step("Yield", value0, value1);
|
||||
const Skip = value0 => $Step("Skip", value0);
|
||||
const Done = /* #__PURE__ */ $Step("Done");
|
||||
const ListT = x => x;
|
||||
const wrapLazy = dictApplicative => v => dictApplicative.pure($Step("Skip", v));
|
||||
const wrapEffect = dictFunctor => v => dictFunctor.map(x => $Step("Skip", Data$dLazy.defer(v$1 => x)))(v);
|
||||
const unfold = dictMonad => {
|
||||
const map2 = dictMonad.Bind1().Apply0().Functor0().map;
|
||||
return f => z => map2(v => {
|
||||
if (v.tag === "Just") { return $Step("Yield", v._1._2, Data$dLazy.defer(v1 => unfold(dictMonad)(f)(v._1._1))); }
|
||||
if (v.tag === "Nothing") { return Done; }
|
||||
$runtime.fail();
|
||||
})(f(z));
|
||||
};
|
||||
const uncons = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
return v => bind(v)(v1 => {
|
||||
if (v1.tag === "Yield") { return pure1(Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(v1._1, Data$dLazy.force(v1._2)))); }
|
||||
if (v1.tag === "Skip") { return uncons(dictMonad)(Data$dLazy.force(v1._1)); }
|
||||
if (v1.tag === "Done") { return pure1(Data$dMaybe.Nothing); }
|
||||
$runtime.fail();
|
||||
});
|
||||
};
|
||||
const tail = dictMonad => {
|
||||
const map2 = dictMonad.Bind1().Apply0().Functor0().map;
|
||||
const uncons1 = uncons(dictMonad);
|
||||
return l => map2(Data$dMaybe.functorMaybe.map(Data$dTuple.snd))(uncons1(l));
|
||||
};
|
||||
const takeWhile = dictApplicative => {
|
||||
const $1 = dictApplicative.Apply0().Functor0();
|
||||
return f => v => $1.map(v$1 => {
|
||||
if (v$1.tag === "Yield") {
|
||||
if (f(v$1._1)) {
|
||||
return $Step(
|
||||
"Yield",
|
||||
v$1._1,
|
||||
(() => {
|
||||
const $5 = takeWhile(dictApplicative)(f);
|
||||
return Data$dLazy.defer(v$2 => $5(Data$dLazy.force(v$1._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
return Done;
|
||||
}
|
||||
if (v$1.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $5 = takeWhile(dictApplicative)(f);
|
||||
return Data$dLazy.defer(v$2 => $5(Data$dLazy.force(v$1._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v);
|
||||
};
|
||||
const scanl = dictMonad => {
|
||||
const map2 = dictMonad.Bind1().Apply0().Functor0().map;
|
||||
const unfold1 = unfold(dictMonad);
|
||||
return f => b => l => unfold1(v => map2(v1 => {
|
||||
if (v1.tag === "Yield") { return Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(Data$dTuple.$Tuple(f(v._1)(v1._1), Data$dLazy.force(v1._2)), v._1)); }
|
||||
if (v1.tag === "Skip") { return Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(Data$dTuple.$Tuple(v._1, Data$dLazy.force(v1._1)), v._1)); }
|
||||
if (v1.tag === "Done") { return Data$dMaybe.Nothing; }
|
||||
$runtime.fail();
|
||||
})(v._2))(Data$dTuple.$Tuple(b, l));
|
||||
};
|
||||
const prepend$p = dictApplicative => h => t => dictApplicative.pure($Step("Yield", h, t));
|
||||
const prepend = dictApplicative => h => t => dictApplicative.pure($Step("Yield", h, Data$dLazy.defer(v => t)));
|
||||
const nil = dictApplicative => dictApplicative.pure(Done);
|
||||
const singleton = dictApplicative => {
|
||||
const nil1 = dictApplicative.pure(Done);
|
||||
return a => dictApplicative.pure($Step("Yield", a, Data$dLazy.defer(v => nil1)));
|
||||
};
|
||||
const take = dictApplicative => {
|
||||
const nil1 = dictApplicative.pure(Done);
|
||||
const $2 = dictApplicative.Apply0().Functor0();
|
||||
return v => v1 => {
|
||||
if (v === 0) { return nil1; }
|
||||
return $2.map(v2 => {
|
||||
if (v2.tag === "Yield") {
|
||||
return $Step(
|
||||
"Yield",
|
||||
v2._1,
|
||||
(() => {
|
||||
const $6 = take(dictApplicative)(v - 1 | 0);
|
||||
return Data$dLazy.defer(v$1 => $6(Data$dLazy.force(v2._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v2.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $6 = take(dictApplicative)(v);
|
||||
return Data$dLazy.defer(v$1 => $6(Data$dLazy.force(v2._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v2.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v1);
|
||||
};
|
||||
};
|
||||
const zipWith$p = dictMonad => {
|
||||
const Applicative0 = dictMonad.Applicative0();
|
||||
const nil1 = Applicative0.pure(Done);
|
||||
const Bind1 = dictMonad.Bind1();
|
||||
const Functor0 = Bind1.Apply0().Functor0();
|
||||
const uncons1 = uncons(dictMonad);
|
||||
return f => fa => fb => Functor0.map(x => $Step("Skip", Data$dLazy.defer(v => x)))(Bind1.bind(uncons1(fa))(ua => Bind1.bind(uncons1(fb))(ub => {
|
||||
if (ub.tag === "Nothing") { return Applicative0.pure(nil1); }
|
||||
if (ua.tag === "Nothing") { return Applicative0.pure(nil1); }
|
||||
if (ua.tag === "Just") {
|
||||
if (ub.tag === "Just") {
|
||||
return Functor0.map((() => {
|
||||
const $11 = Data$dLazy.defer(v2 => zipWith$p(dictMonad)(f)(ua._1._2)(ub._1._2));
|
||||
return a => Applicative0.pure($Step("Yield", a, $11));
|
||||
})())(f(ua._1._1)(ub._1._1));
|
||||
}
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
})));
|
||||
};
|
||||
const zipWith = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
const zipWith$p1 = zipWith$p(dictMonad);
|
||||
return f => zipWith$p1(a => b => pure1(f(a)(b)));
|
||||
};
|
||||
const newtypeListT = {Coercible0: () => undefined};
|
||||
const mapMaybe = dictFunctor => f => v => dictFunctor.map(v$1 => {
|
||||
if (v$1.tag === "Yield") {
|
||||
const $4 = f(v$1._1);
|
||||
if ($4.tag === "Just") {
|
||||
return $Step(
|
||||
"Yield",
|
||||
$4._1,
|
||||
(() => {
|
||||
const $5 = mapMaybe(dictFunctor)(f);
|
||||
return Data$dLazy.defer(v$2 => $5(Data$dLazy.force(v$1._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $5 = mapMaybe(dictFunctor)(f);
|
||||
return Data$dLazy.defer(v$2 => $5(Data$dLazy.force(v$1._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $4 = mapMaybe(dictFunctor)(f);
|
||||
return Data$dLazy.defer(v$2 => $4(Data$dLazy.force(v$1._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v);
|
||||
const iterate = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
const unfold1 = unfold(dictMonad);
|
||||
return f => a => unfold1(x => pure1(Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(f(x), x))))(a);
|
||||
};
|
||||
const repeat = dictMonad => iterate(dictMonad)(identity);
|
||||
const head = dictMonad => {
|
||||
const map2 = dictMonad.Bind1().Apply0().Functor0().map;
|
||||
const uncons1 = uncons(dictMonad);
|
||||
return l => map2(Data$dMaybe.functorMaybe.map(Data$dTuple.fst))(uncons1(l));
|
||||
};
|
||||
const functorListT = dictFunctor => (
|
||||
{
|
||||
map: f => v => dictFunctor.map(v$1 => {
|
||||
if (v$1.tag === "Yield") {
|
||||
return $Step(
|
||||
"Yield",
|
||||
f(v$1._1),
|
||||
(() => {
|
||||
const $4 = functorListT(dictFunctor).map(f);
|
||||
return Data$dLazy.defer(v$2 => $4(Data$dLazy.force(v$1._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $4 = functorListT(dictFunctor).map(f);
|
||||
return Data$dLazy.defer(v$2 => $4(Data$dLazy.force(v$1._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v)
|
||||
}
|
||||
);
|
||||
const fromEffect = dictApplicative => {
|
||||
const map2 = dictApplicative.Apply0().Functor0().map;
|
||||
const nil1 = dictApplicative.pure(Done);
|
||||
return fa => map2((() => {
|
||||
const $4 = Data$dLazy.defer(v => nil1);
|
||||
return a => $Step("Yield", a, $4);
|
||||
})())(fa);
|
||||
};
|
||||
const monadTransListT = {lift: dictMonad => fromEffect(dictMonad.Applicative0())};
|
||||
const foldlRec$p = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const pure1 = Monad0.Applicative0().pure;
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const uncons1 = uncons(Monad0);
|
||||
return f => a => b => dictMonadRec.tailRecM(o => bind(uncons1(o.b))(v => {
|
||||
if (v.tag === "Nothing") { return pure1(Control$dMonad$dRec$dClass.$Step("Done", o.a)); }
|
||||
if (v.tag === "Just") { return bind(f(o.a)(v._1._1))(b$p => pure1(Control$dMonad$dRec$dClass.$Step("Loop", {a: b$p, b: v._1._2}))); }
|
||||
$runtime.fail();
|
||||
}))({a: a, b: b});
|
||||
};
|
||||
const runListTRec = dictMonadRec => {
|
||||
const pure1 = dictMonadRec.Monad0().Applicative0().pure;
|
||||
return foldlRec$p(dictMonadRec)(v => v1 => pure1(Data$dUnit.unit))(Data$dUnit.unit);
|
||||
};
|
||||
const foldlRec = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const pure1 = Monad0.Applicative0().pure;
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const uncons1 = uncons(Monad0);
|
||||
return f => a => b => dictMonadRec.tailRecM(o => bind(uncons1(o.b))(v => {
|
||||
if (v.tag === "Nothing") { return pure1(Control$dMonad$dRec$dClass.$Step("Done", o.a)); }
|
||||
if (v.tag === "Just") { return pure1(Control$dMonad$dRec$dClass.$Step("Loop", {a: f(o.a)(v._1._1), b: v._1._2})); }
|
||||
$runtime.fail();
|
||||
}))({a: a, b: b});
|
||||
};
|
||||
const foldl$p = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const uncons1 = uncons(dictMonad);
|
||||
return f => {
|
||||
const loop = b => l => bind(uncons1(l))(v => {
|
||||
if (v.tag === "Nothing") { return pure1(b); }
|
||||
if (v.tag === "Just") { return bind(f(b)(v._1._1))(a => loop(a)(v._1._2)); }
|
||||
$runtime.fail();
|
||||
});
|
||||
return loop;
|
||||
};
|
||||
};
|
||||
const runListT = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
return foldl$p(dictMonad)(v => v1 => pure1(Data$dUnit.unit))(Data$dUnit.unit);
|
||||
};
|
||||
const foldl = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const uncons1 = uncons(dictMonad);
|
||||
return f => {
|
||||
const loop = b => l => bind(uncons1(l))(v => {
|
||||
if (v.tag === "Nothing") { return pure1(b); }
|
||||
if (v.tag === "Just") { return loop(f(b)(v._1._1))(v._1._2); }
|
||||
$runtime.fail();
|
||||
});
|
||||
return loop;
|
||||
};
|
||||
};
|
||||
const filter = dictFunctor => f => v => dictFunctor.map(v$1 => {
|
||||
if (v$1.tag === "Yield") {
|
||||
const $4 = filter(dictFunctor)(f);
|
||||
const s$p = Data$dLazy.defer(v$2 => $4(Data$dLazy.force(v$1._2)));
|
||||
if (f(v$1._1)) { return $Step("Yield", v$1._1, s$p); }
|
||||
return $Step("Skip", s$p);
|
||||
}
|
||||
if (v$1.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $4 = filter(dictFunctor)(f);
|
||||
return Data$dLazy.defer(v$2 => $4(Data$dLazy.force(v$1._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v);
|
||||
const dropWhile = dictApplicative => {
|
||||
const $1 = dictApplicative.Apply0().Functor0();
|
||||
return f => v => $1.map(v$1 => {
|
||||
if (v$1.tag === "Yield") {
|
||||
if (f(v$1._1)) {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $5 = dropWhile(dictApplicative)(f);
|
||||
return Data$dLazy.defer(v$2 => $5(Data$dLazy.force(v$1._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
return $Step("Yield", v$1._1, v$1._2);
|
||||
}
|
||||
if (v$1.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $5 = dropWhile(dictApplicative)(f);
|
||||
return Data$dLazy.defer(v$2 => $5(Data$dLazy.force(v$1._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v$1.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v);
|
||||
};
|
||||
const drop = dictApplicative => {
|
||||
const $1 = dictApplicative.Apply0().Functor0();
|
||||
return v => v1 => {
|
||||
if (v === 0) { return v1; }
|
||||
return $1.map(v2 => {
|
||||
if (v2.tag === "Yield") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $5 = drop(dictApplicative)(v - 1 | 0);
|
||||
return Data$dLazy.defer(v$1 => $5(Data$dLazy.force(v2._2)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v2.tag === "Skip") {
|
||||
return $Step(
|
||||
"Skip",
|
||||
(() => {
|
||||
const $5 = drop(dictApplicative)(v);
|
||||
return Data$dLazy.defer(v$1 => $5(Data$dLazy.force(v2._1)));
|
||||
})()
|
||||
);
|
||||
}
|
||||
if (v2.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(v1);
|
||||
};
|
||||
};
|
||||
const cons = dictApplicative => lh => t => dictApplicative.pure($Step("Yield", Data$dLazy.force(lh), t));
|
||||
const unfoldable1ListT = dictMonad => {
|
||||
const Applicative0 = dictMonad.Applicative0();
|
||||
const singleton1 = singleton(Applicative0);
|
||||
return {
|
||||
unfoldr1: f => b => {
|
||||
const go = v => {
|
||||
if (v._2.tag === "Nothing") { return singleton1(v._1); }
|
||||
if (v._2.tag === "Just") { return Applicative0.pure($Step("Yield", Data$dLazy.force(Data$dLazy.defer(v$1 => v._1)), Data$dLazy.defer(v1 => go(f(v._2._1))))); }
|
||||
$runtime.fail();
|
||||
};
|
||||
return go(f(b));
|
||||
}
|
||||
};
|
||||
};
|
||||
const unfoldableListT = dictMonad => {
|
||||
const Applicative0 = dictMonad.Applicative0();
|
||||
const nil1 = Applicative0.pure(Done);
|
||||
const unfoldable1ListT1 = unfoldable1ListT(dictMonad);
|
||||
return {
|
||||
unfoldr: f => b => {
|
||||
const go = v => {
|
||||
if (v.tag === "Nothing") { return nil1; }
|
||||
if (v.tag === "Just") { return Applicative0.pure($Step("Yield", Data$dLazy.force(Data$dLazy.defer(v$1 => v._1._1)), Data$dLazy.defer(v1 => go(f(v._1._2))))); }
|
||||
$runtime.fail();
|
||||
};
|
||||
return go(f(b));
|
||||
},
|
||||
Unfoldable10: () => unfoldable1ListT1
|
||||
};
|
||||
};
|
||||
const semigroupListT = dictApplicative => ({append: concat(dictApplicative)});
|
||||
const concat = dictApplicative => {
|
||||
const $1 = dictApplicative.Apply0().Functor0();
|
||||
return x => y => $1.map(v => {
|
||||
if (v.tag === "Yield") { return $Step("Yield", v._1, Data$dLazy.defer(v$1 => concat(dictApplicative)(Data$dLazy.force(v._2))(y))); }
|
||||
if (v.tag === "Skip") { return $Step("Skip", Data$dLazy.defer(v$1 => concat(dictApplicative)(Data$dLazy.force(v._1))(y))); }
|
||||
if (v.tag === "Done") { return $Step("Skip", Data$dLazy.defer(v$1 => y)); }
|
||||
$runtime.fail();
|
||||
})(x);
|
||||
};
|
||||
const monoidListT = dictApplicative => {
|
||||
const semigroupListT1 = {append: concat(dictApplicative)};
|
||||
return {mempty: dictApplicative.pure(Done), Semigroup0: () => semigroupListT1};
|
||||
};
|
||||
const catMaybes = dictFunctor => mapMaybe(dictFunctor)(identity);
|
||||
const monadListT = dictMonad => ({Applicative0: () => applicativeListT(dictMonad), Bind1: () => bindListT(dictMonad)});
|
||||
const bindListT = dictMonad => {
|
||||
const append = concat(dictMonad.Applicative0());
|
||||
const $2 = dictMonad.Bind1().Apply0().Functor0();
|
||||
return {
|
||||
bind: fa => f => $2.map(v => {
|
||||
if (v.tag === "Yield") { return $Step("Skip", Data$dLazy.defer(v$1 => append(f(v._1))(bindListT(dictMonad).bind(Data$dLazy.force(v._2))(f)))); }
|
||||
if (v.tag === "Skip") { return $Step("Skip", Data$dLazy.defer(v$1 => bindListT(dictMonad).bind(Data$dLazy.force(v._1))(f))); }
|
||||
if (v.tag === "Done") { return Done; }
|
||||
$runtime.fail();
|
||||
})(fa),
|
||||
Apply0: () => applyListT(dictMonad)
|
||||
};
|
||||
};
|
||||
const applyListT = dictMonad => {
|
||||
const functorListT1 = functorListT(dictMonad.Bind1().Apply0().Functor0());
|
||||
return {
|
||||
apply: (() => {
|
||||
const bind = bindListT(dictMonad).bind;
|
||||
const pure = applicativeListT(dictMonad).pure;
|
||||
return f => a => bind(f)(f$p => bind(a)(a$p => pure(f$p(a$p))));
|
||||
})(),
|
||||
Functor0: () => functorListT1
|
||||
};
|
||||
};
|
||||
const applicativeListT = dictMonad => ({pure: singleton(dictMonad.Applicative0()), Apply0: () => applyListT(dictMonad)});
|
||||
const monadEffectListT = dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadListT1 = {Applicative0: () => ({pure: singleton(Monad0.Applicative0()), Apply0: () => applyListT(Monad0)}), Bind1: () => bindListT(Monad0)};
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $3 = fromEffect(Monad0.Applicative0());
|
||||
return x => $3(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadListT1
|
||||
};
|
||||
};
|
||||
const altListT = dictApplicative => {
|
||||
const functorListT1 = functorListT(dictApplicative.Apply0().Functor0());
|
||||
return {alt: concat(dictApplicative), Functor0: () => functorListT1};
|
||||
};
|
||||
const plusListT = dictMonad => {
|
||||
const Applicative0 = dictMonad.Applicative0();
|
||||
const altListT1 = altListT(Applicative0);
|
||||
return {empty: Applicative0.pure(Done), Alt0: () => altListT1};
|
||||
};
|
||||
const alternativeListT = dictMonad => {
|
||||
const applicativeListT1 = {pure: singleton(dictMonad.Applicative0()), Apply0: () => applyListT(dictMonad)};
|
||||
const plusListT1 = plusListT(dictMonad);
|
||||
return {Applicative0: () => applicativeListT1, Plus1: () => plusListT1};
|
||||
};
|
||||
const monadPlusListT = dictMonad => {
|
||||
const monadListT1 = {Applicative0: () => ({pure: singleton(dictMonad.Applicative0()), Apply0: () => applyListT(dictMonad)}), Bind1: () => bindListT(dictMonad)};
|
||||
const alternativeListT1 = alternativeListT(dictMonad);
|
||||
return {Monad0: () => monadListT1, Alternative1: () => alternativeListT1};
|
||||
};
|
||||
export {
|
||||
$Step,
|
||||
Done,
|
||||
ListT,
|
||||
Skip,
|
||||
Yield,
|
||||
altListT,
|
||||
alternativeListT,
|
||||
applicativeListT,
|
||||
applyListT,
|
||||
bindListT,
|
||||
catMaybes,
|
||||
concat,
|
||||
cons,
|
||||
drop,
|
||||
dropWhile,
|
||||
filter,
|
||||
foldl,
|
||||
foldl$p,
|
||||
foldlRec,
|
||||
foldlRec$p,
|
||||
fromEffect,
|
||||
functorListT,
|
||||
head,
|
||||
identity,
|
||||
iterate,
|
||||
mapMaybe,
|
||||
monadEffectListT,
|
||||
monadListT,
|
||||
monadPlusListT,
|
||||
monadTransListT,
|
||||
monoidListT,
|
||||
newtypeListT,
|
||||
nil,
|
||||
plusListT,
|
||||
prepend,
|
||||
prepend$p,
|
||||
repeat,
|
||||
runListT,
|
||||
runListTRec,
|
||||
scanl,
|
||||
semigroupListT,
|
||||
singleton,
|
||||
tail,
|
||||
take,
|
||||
takeWhile,
|
||||
uncons,
|
||||
unfold,
|
||||
unfoldable1ListT,
|
||||
unfoldableListT,
|
||||
wrapEffect,
|
||||
wrapLazy,
|
||||
zipWith,
|
||||
zipWith$p
|
||||
};
|
@ -0,0 +1,214 @@
|
||||
// | This module defines the `MaybeT` monad transformer.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const identity = x => x;
|
||||
const MaybeT = x => x;
|
||||
const runMaybeT = v => v;
|
||||
const newtypeMaybeT = {Coercible0: () => undefined};
|
||||
const monadTransMaybeT = {
|
||||
lift: dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return x => bind(x)(a$p => pure(Data$dMaybe.$Maybe("Just", a$p)));
|
||||
}
|
||||
};
|
||||
const mapMaybeT = f => v => f(v);
|
||||
const functorMaybeT = dictFunctor => ({map: f => v => dictFunctor.map(Data$dMaybe.functorMaybe.map(f))(v)});
|
||||
const monadMaybeT = dictMonad => ({Applicative0: () => applicativeMaybeT(dictMonad), Bind1: () => bindMaybeT(dictMonad)});
|
||||
const bindMaybeT = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return {
|
||||
bind: v => f => bind(v)(v1 => {
|
||||
if (v1.tag === "Nothing") { return pure(Data$dMaybe.Nothing); }
|
||||
if (v1.tag === "Just") { return f(v1._1); }
|
||||
$runtime.fail();
|
||||
}),
|
||||
Apply0: () => applyMaybeT(dictMonad)
|
||||
};
|
||||
};
|
||||
const applyMaybeT = dictMonad => {
|
||||
const $1 = dictMonad.Bind1().Apply0().Functor0();
|
||||
const functorMaybeT1 = {map: f => v => $1.map(Data$dMaybe.functorMaybe.map(f))(v)};
|
||||
return {
|
||||
apply: (() => {
|
||||
const bind = bindMaybeT(dictMonad).bind;
|
||||
const pure = applicativeMaybeT(dictMonad).pure;
|
||||
return f => a => bind(f)(f$p => bind(a)(a$p => pure(f$p(a$p))));
|
||||
})(),
|
||||
Functor0: () => functorMaybeT1
|
||||
};
|
||||
};
|
||||
const applicativeMaybeT = dictMonad => (
|
||||
{
|
||||
pure: (() => {
|
||||
const $1 = dictMonad.Applicative0().pure;
|
||||
return x => $1(Data$dMaybe.$Maybe("Just", x));
|
||||
})(),
|
||||
Apply0: () => applyMaybeT(dictMonad)
|
||||
}
|
||||
);
|
||||
const semigroupMaybeT = dictMonad => {
|
||||
const $1 = applyMaybeT(dictMonad);
|
||||
const map = $1.Functor0().map;
|
||||
return dictSemigroup => ({append: a => b => $1.apply(map(dictSemigroup.append)(a))(b)});
|
||||
};
|
||||
const monadAskMaybeT = dictMonadAsk => {
|
||||
const Monad0 = dictMonadAsk.Monad0();
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(Monad0), Bind1: () => bindMaybeT(Monad0)};
|
||||
return {ask: monadTransMaybeT.lift(Monad0)(dictMonadAsk.ask), Monad0: () => monadMaybeT1};
|
||||
};
|
||||
const monadReaderMaybeT = dictMonadReader => {
|
||||
const monadAskMaybeT1 = monadAskMaybeT(dictMonadReader.MonadAsk0());
|
||||
return {local: f => dictMonadReader.local(f), MonadAsk0: () => monadAskMaybeT1};
|
||||
};
|
||||
const monadContMaybeT = dictMonadCont => {
|
||||
const $1 = dictMonadCont.Monad0();
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT($1), Bind1: () => bindMaybeT($1)};
|
||||
return {callCC: f => dictMonadCont.callCC(c => f(a => c(Data$dMaybe.$Maybe("Just", a)))), Monad0: () => monadMaybeT1};
|
||||
};
|
||||
const monadEffectMaybe = dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(Monad0), Bind1: () => bindMaybeT(Monad0)};
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $3 = monadTransMaybeT.lift(Monad0);
|
||||
return x => $3(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadMaybeT1
|
||||
};
|
||||
};
|
||||
const monadRecMaybeT = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(Monad0), Bind1: () => bindMaybeT(Monad0)};
|
||||
return {
|
||||
tailRecM: f => dictMonadRec.tailRecM(a => bind(f(a))(m$p => pure((() => {
|
||||
if (m$p.tag === "Nothing") { return Control$dMonad$dRec$dClass.$Step("Done", Data$dMaybe.Nothing); }
|
||||
if (m$p.tag === "Just") {
|
||||
if (m$p._1.tag === "Loop") { return Control$dMonad$dRec$dClass.$Step("Loop", m$p._1._1); }
|
||||
if (m$p._1.tag === "Done") { return Control$dMonad$dRec$dClass.$Step("Done", Data$dMaybe.$Maybe("Just", m$p._1._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
})()))),
|
||||
Monad0: () => monadMaybeT1
|
||||
};
|
||||
};
|
||||
const monadStateMaybeT = dictMonadState => {
|
||||
const Monad0 = dictMonadState.Monad0();
|
||||
const lift1 = monadTransMaybeT.lift(Monad0);
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(Monad0), Bind1: () => bindMaybeT(Monad0)};
|
||||
return {state: f => lift1(dictMonadState.state(f)), Monad0: () => monadMaybeT1};
|
||||
};
|
||||
const monadTellMaybeT = dictMonadTell => {
|
||||
const Monad1 = dictMonadTell.Monad1();
|
||||
const Semigroup0 = dictMonadTell.Semigroup0();
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(Monad1), Bind1: () => bindMaybeT(Monad1)};
|
||||
return {
|
||||
tell: (() => {
|
||||
const $4 = monadTransMaybeT.lift(Monad1);
|
||||
return x => $4(dictMonadTell.tell(x));
|
||||
})(),
|
||||
Semigroup0: () => Semigroup0,
|
||||
Monad1: () => monadMaybeT1
|
||||
};
|
||||
};
|
||||
const monadWriterMaybeT = dictMonadWriter => {
|
||||
const MonadTell1 = dictMonadWriter.MonadTell1();
|
||||
const Monad1 = MonadTell1.Monad1();
|
||||
const bind = Monad1.Bind1().bind;
|
||||
const pure = Monad1.Applicative0().pure;
|
||||
const Monoid0 = dictMonadWriter.Monoid0();
|
||||
const monadTellMaybeT1 = monadTellMaybeT(MonadTell1);
|
||||
return {
|
||||
listen: v => bind(dictMonadWriter.listen(v))(v$1 => pure((() => {
|
||||
if (v$1._1.tag === "Just") { return Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(v$1._1._1, v$1._2)); }
|
||||
return Data$dMaybe.Nothing;
|
||||
})())),
|
||||
pass: v => dictMonadWriter.pass(bind(v)(a => pure((() => {
|
||||
if (a.tag === "Nothing") { return Data$dTuple.$Tuple(Data$dMaybe.Nothing, identity); }
|
||||
if (a.tag === "Just") { return Data$dTuple.$Tuple(Data$dMaybe.$Maybe("Just", a._1._1), a._1._2); }
|
||||
$runtime.fail();
|
||||
})()))),
|
||||
Monoid0: () => Monoid0,
|
||||
MonadTell1: () => monadTellMaybeT1
|
||||
};
|
||||
};
|
||||
const monadThrowMaybeT = dictMonadThrow => {
|
||||
const Monad0 = dictMonadThrow.Monad0();
|
||||
const lift1 = monadTransMaybeT.lift(Monad0);
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(Monad0), Bind1: () => bindMaybeT(Monad0)};
|
||||
return {throwError: e => lift1(dictMonadThrow.throwError(e)), Monad0: () => monadMaybeT1};
|
||||
};
|
||||
const monadErrorMaybeT = dictMonadError => {
|
||||
const monadThrowMaybeT1 = monadThrowMaybeT(dictMonadError.MonadThrow0());
|
||||
return {catchError: v => h => dictMonadError.catchError(v)(a => h(a)), MonadThrow0: () => monadThrowMaybeT1};
|
||||
};
|
||||
const monoidMaybeT = dictMonad => {
|
||||
const pure = applicativeMaybeT(dictMonad).pure;
|
||||
const semigroupMaybeT1 = semigroupMaybeT(dictMonad);
|
||||
return dictMonoid => {
|
||||
const semigroupMaybeT2 = semigroupMaybeT1(dictMonoid.Semigroup0());
|
||||
return {mempty: pure(dictMonoid.mempty), Semigroup0: () => semigroupMaybeT2};
|
||||
};
|
||||
};
|
||||
const altMaybeT = dictMonad => {
|
||||
const Bind1 = dictMonad.Bind1();
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const $3 = Bind1.Apply0().Functor0();
|
||||
const functorMaybeT1 = {map: f => v => $3.map(Data$dMaybe.functorMaybe.map(f))(v)};
|
||||
return {
|
||||
alt: v => v1 => Bind1.bind(v)(m => {
|
||||
if (m.tag === "Nothing") { return v1; }
|
||||
return pure(m);
|
||||
}),
|
||||
Functor0: () => functorMaybeT1
|
||||
};
|
||||
};
|
||||
const plusMaybeT = dictMonad => {
|
||||
const altMaybeT1 = altMaybeT(dictMonad);
|
||||
return {empty: dictMonad.Applicative0().pure(Data$dMaybe.Nothing), Alt0: () => altMaybeT1};
|
||||
};
|
||||
const alternativeMaybeT = dictMonad => {
|
||||
const applicativeMaybeT1 = applicativeMaybeT(dictMonad);
|
||||
const plusMaybeT1 = plusMaybeT(dictMonad);
|
||||
return {Applicative0: () => applicativeMaybeT1, Plus1: () => plusMaybeT1};
|
||||
};
|
||||
const monadPlusMaybeT = dictMonad => {
|
||||
const monadMaybeT1 = {Applicative0: () => applicativeMaybeT(dictMonad), Bind1: () => bindMaybeT(dictMonad)};
|
||||
const alternativeMaybeT1 = alternativeMaybeT(dictMonad);
|
||||
return {Monad0: () => monadMaybeT1, Alternative1: () => alternativeMaybeT1};
|
||||
};
|
||||
export {
|
||||
MaybeT,
|
||||
altMaybeT,
|
||||
alternativeMaybeT,
|
||||
applicativeMaybeT,
|
||||
applyMaybeT,
|
||||
bindMaybeT,
|
||||
functorMaybeT,
|
||||
identity,
|
||||
mapMaybeT,
|
||||
monadAskMaybeT,
|
||||
monadContMaybeT,
|
||||
monadEffectMaybe,
|
||||
monadErrorMaybeT,
|
||||
monadMaybeT,
|
||||
monadPlusMaybeT,
|
||||
monadReaderMaybeT,
|
||||
monadRecMaybeT,
|
||||
monadStateMaybeT,
|
||||
monadTellMaybeT,
|
||||
monadThrowMaybeT,
|
||||
monadTransMaybeT,
|
||||
monadWriterMaybeT,
|
||||
monoidMaybeT,
|
||||
newtypeMaybeT,
|
||||
plusMaybeT,
|
||||
runMaybeT,
|
||||
semigroupMaybeT
|
||||
};
|
@ -0,0 +1,240 @@
|
||||
// | This module defines the reader-writer-state monad transformer, `RWST`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const $RWSResult = (_1, _2, _3) => ({tag: "RWSResult", _1, _2, _3});
|
||||
const RWSResult = value0 => value1 => value2 => $RWSResult(value0, value1, value2);
|
||||
const RWST = x => x;
|
||||
const withRWST = f => m => r => s => {
|
||||
const $4 = f(r)(s);
|
||||
return m($4._1)($4._2);
|
||||
};
|
||||
const runRWST = v => v;
|
||||
const newtypeRWST = {Coercible0: () => undefined};
|
||||
const monadTransRWST = dictMonoid => (
|
||||
{
|
||||
lift: dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return m => v => s => bind(m)(a => pure($RWSResult(s, a, dictMonoid.mempty)));
|
||||
}
|
||||
}
|
||||
);
|
||||
const mapRWST = f => v => r => s => f(v(r)(s));
|
||||
const lazyRWST = {defer: f => r => s => f(Data$dUnit.unit)(r)(s)};
|
||||
const functorRWST = dictFunctor => ({map: f => v => r => s => dictFunctor.map(v1 => $RWSResult(v1._1, f(v1._2), v1._3))(v(r)(s))});
|
||||
const execRWST = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return v => r => s => bind(v(r)(s))(v1 => pure(Data$dTuple.$Tuple(v1._1, v1._3)));
|
||||
};
|
||||
const evalRWST = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return v => r => s => bind(v(r)(s))(v1 => pure(Data$dTuple.$Tuple(v1._2, v1._3)));
|
||||
};
|
||||
const applyRWST = dictBind => {
|
||||
const Functor0 = dictBind.Apply0().Functor0();
|
||||
const functorRWST1 = functorRWST(Functor0);
|
||||
return dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
return {
|
||||
apply: v => v1 => r => s => dictBind.bind(v(r)(s))(v2 => Functor0.map(v3 => $RWSResult(v3._1, v2._2(v3._2), append(v2._3)(v3._3)))(v1(r)(v2._1))),
|
||||
Functor0: () => functorRWST1
|
||||
};
|
||||
};
|
||||
};
|
||||
const bindRWST = dictBind => {
|
||||
const $1 = dictBind.Apply0().Functor0();
|
||||
const applyRWST1 = applyRWST(dictBind);
|
||||
return dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
const applyRWST2 = applyRWST1(dictMonoid);
|
||||
return {bind: v => f => r => s => dictBind.bind(v(r)(s))(v1 => $1.map(v3 => $RWSResult(v3._1, v3._2, append(v1._3)(v3._3)))(f(v1._2)(r)(v1._1))), Apply0: () => applyRWST2};
|
||||
};
|
||||
};
|
||||
const semigroupRWST = dictBind => {
|
||||
const applyRWST1 = applyRWST(dictBind);
|
||||
return dictMonoid => {
|
||||
const $3 = applyRWST1(dictMonoid);
|
||||
const map = $3.Functor0().map;
|
||||
return dictSemigroup => ({append: a => b => $3.apply(map(dictSemigroup.append)(a))(b)});
|
||||
};
|
||||
};
|
||||
const applicativeRWST = dictMonad => {
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const applyRWST1 = applyRWST(dictMonad.Bind1());
|
||||
return dictMonoid => {
|
||||
const applyRWST2 = applyRWST1(dictMonoid);
|
||||
return {pure: a => v => s => pure($RWSResult(s, a, dictMonoid.mempty)), Apply0: () => applyRWST2};
|
||||
};
|
||||
};
|
||||
const monadRWST = dictMonad => {
|
||||
const applicativeRWST1 = applicativeRWST(dictMonad);
|
||||
const bindRWST1 = bindRWST(dictMonad.Bind1());
|
||||
return dictMonoid => {
|
||||
const applicativeRWST2 = applicativeRWST1(dictMonoid);
|
||||
const bindRWST2 = bindRWST1(dictMonoid);
|
||||
return {Applicative0: () => applicativeRWST2, Bind1: () => bindRWST2};
|
||||
};
|
||||
};
|
||||
const monadAskRWST = dictMonad => {
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadRWST1 = monadRWST(dictMonad);
|
||||
return dictMonoid => {
|
||||
const monadRWST2 = monadRWST1(dictMonoid);
|
||||
return {ask: r => s => pure($RWSResult(s, r, dictMonoid.mempty)), Monad0: () => monadRWST2};
|
||||
};
|
||||
};
|
||||
const monadReaderRWST = dictMonad => {
|
||||
const monadAskRWST1 = monadAskRWST(dictMonad);
|
||||
return dictMonoid => {
|
||||
const monadAskRWST2 = monadAskRWST1(dictMonoid);
|
||||
return {local: f => m => r => s => m(f(r))(s), MonadAsk0: () => monadAskRWST2};
|
||||
};
|
||||
};
|
||||
const monadEffectRWS = dictMonoid => {
|
||||
const lift = monadTransRWST(dictMonoid).lift;
|
||||
return dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadRWST1 = monadRWST(Monad0)(dictMonoid);
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $5 = lift(Monad0);
|
||||
return x => $5(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadRWST1
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadRecRWST = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const monadRWST1 = monadRWST(Monad0);
|
||||
return dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
const monadRWST2 = monadRWST1(dictMonoid);
|
||||
return {
|
||||
tailRecM: k => a => r => s => dictMonadRec.tailRecM(v => bind(k(v._2)(r)(v._1))(v2 => pure((() => {
|
||||
if (v2._2.tag === "Loop") { return Control$dMonad$dRec$dClass.$Step("Loop", $RWSResult(v2._1, v2._2._1, append(v._3)(v2._3))); }
|
||||
if (v2._2.tag === "Done") { return Control$dMonad$dRec$dClass.$Step("Done", $RWSResult(v2._1, v2._2._1, append(v._3)(v2._3))); }
|
||||
$runtime.fail();
|
||||
})())))($RWSResult(s, a, dictMonoid.mempty)),
|
||||
Monad0: () => monadRWST2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadStateRWST = dictMonad => {
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadRWST1 = monadRWST(dictMonad);
|
||||
return dictMonoid => {
|
||||
const monadRWST2 = monadRWST1(dictMonoid);
|
||||
return {
|
||||
state: f => v => s => {
|
||||
const v1 = f(s);
|
||||
return pure($RWSResult(v1._2, v1._1, dictMonoid.mempty));
|
||||
},
|
||||
Monad0: () => monadRWST2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadTellRWST = dictMonad => {
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadRWST1 = monadRWST(dictMonad);
|
||||
return dictMonoid => {
|
||||
const Semigroup0 = dictMonoid.Semigroup0();
|
||||
const monadRWST2 = monadRWST1(dictMonoid);
|
||||
return {tell: w => v => s => pure($RWSResult(s, Data$dUnit.unit, w)), Semigroup0: () => Semigroup0, Monad1: () => monadRWST2};
|
||||
};
|
||||
};
|
||||
const monadWriterRWST = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadTellRWST1 = monadTellRWST(dictMonad);
|
||||
return dictMonoid => {
|
||||
const monadTellRWST2 = monadTellRWST1(dictMonoid);
|
||||
return {
|
||||
listen: m => r => s => bind(m(r)(s))(v => pure($RWSResult(v._1, Data$dTuple.$Tuple(v._2, v._3), v._3))),
|
||||
pass: m => r => s => bind(m(r)(s))(v => pure($RWSResult(v._1, v._2._1, v._2._2(v._3)))),
|
||||
Monoid0: () => dictMonoid,
|
||||
MonadTell1: () => monadTellRWST2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadThrowRWST = dictMonadThrow => {
|
||||
const Monad0 = dictMonadThrow.Monad0();
|
||||
const monadRWST1 = monadRWST(Monad0);
|
||||
return dictMonoid => {
|
||||
const lift = monadTransRWST(dictMonoid).lift(Monad0);
|
||||
const monadRWST2 = monadRWST1(dictMonoid);
|
||||
return {throwError: e => lift(dictMonadThrow.throwError(e)), Monad0: () => monadRWST2};
|
||||
};
|
||||
};
|
||||
const monadErrorRWST = dictMonadError => {
|
||||
const monadThrowRWST1 = monadThrowRWST(dictMonadError.MonadThrow0());
|
||||
return dictMonoid => {
|
||||
const monadThrowRWST2 = monadThrowRWST1(dictMonoid);
|
||||
return {catchError: m => h => r => s => dictMonadError.catchError(m(r)(s))(e => h(e)(r)(s)), MonadThrow0: () => monadThrowRWST2};
|
||||
};
|
||||
};
|
||||
const monoidRWST = dictMonad => {
|
||||
const applicativeRWST1 = applicativeRWST(dictMonad);
|
||||
const semigroupRWST1 = semigroupRWST(dictMonad.Bind1());
|
||||
return dictMonoid => {
|
||||
const pure = applicativeRWST1(dictMonoid).pure;
|
||||
const semigroupRWST2 = semigroupRWST1(dictMonoid);
|
||||
return dictMonoid1 => {
|
||||
const semigroupRWST3 = semigroupRWST2(dictMonoid1.Semigroup0());
|
||||
return {mempty: pure(dictMonoid1.mempty), Semigroup0: () => semigroupRWST3};
|
||||
};
|
||||
};
|
||||
};
|
||||
const altRWST = dictAlt => {
|
||||
const functorRWST1 = functorRWST(dictAlt.Functor0());
|
||||
return {alt: v => v1 => r => s => dictAlt.alt(v(r)(s))(v1(r)(s)), Functor0: () => functorRWST1};
|
||||
};
|
||||
const plusRWST = dictPlus => {
|
||||
const altRWST1 = altRWST(dictPlus.Alt0());
|
||||
return {empty: v => v1 => dictPlus.empty, Alt0: () => altRWST1};
|
||||
};
|
||||
const alternativeRWST = dictMonoid => dictAlternative => {
|
||||
const plusRWST1 = plusRWST(dictAlternative.Plus1());
|
||||
return dictMonad => {
|
||||
const applicativeRWST1 = applicativeRWST(dictMonad)(dictMonoid);
|
||||
return {Applicative0: () => applicativeRWST1, Plus1: () => plusRWST1};
|
||||
};
|
||||
};
|
||||
export {
|
||||
$RWSResult,
|
||||
RWSResult,
|
||||
RWST,
|
||||
altRWST,
|
||||
alternativeRWST,
|
||||
applicativeRWST,
|
||||
applyRWST,
|
||||
bindRWST,
|
||||
evalRWST,
|
||||
execRWST,
|
||||
functorRWST,
|
||||
lazyRWST,
|
||||
mapRWST,
|
||||
monadAskRWST,
|
||||
monadEffectRWS,
|
||||
monadErrorRWST,
|
||||
monadRWST,
|
||||
monadReaderRWST,
|
||||
monadRecRWST,
|
||||
monadStateRWST,
|
||||
monadTellRWST,
|
||||
monadThrowRWST,
|
||||
monadTransRWST,
|
||||
monadWriterRWST,
|
||||
monoidRWST,
|
||||
newtypeRWST,
|
||||
plusRWST,
|
||||
runRWST,
|
||||
semigroupRWST,
|
||||
withRWST
|
||||
};
|
@ -0,0 +1,13 @@
|
||||
// | This module defines the `RWS` monad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRWS$dTrans from "../Control.Monad.RWS.Trans/index.js";
|
||||
import * as Data$dIdentity from "../Data.Identity/index.js";
|
||||
const execRWST = /* #__PURE__ */ Control$dMonad$dRWS$dTrans.execRWST(Data$dIdentity.monadIdentity);
|
||||
const evalRWST = /* #__PURE__ */ Control$dMonad$dRWS$dTrans.evalRWST(Data$dIdentity.monadIdentity);
|
||||
const withRWS = Control$dMonad$dRWS$dTrans.withRWST;
|
||||
const rws = f => r => s => f(r)(s);
|
||||
const runRWS = m => r => s => m(r)(s);
|
||||
const mapRWS = f => v => r => s => f(v(r)(s));
|
||||
const execRWS = m => r => s => execRWST(m)(r)(s);
|
||||
const evalRWS = m => r => s => evalRWST(m)(r)(s);
|
||||
export {evalRWS, evalRWST, execRWS, execRWST, mapRWS, runRWS, rws, withRWS};
|
@ -0,0 +1,12 @@
|
||||
// | This module defines the `MonadReader` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad from "../Control.Monad/index.js";
|
||||
const monadAskFun = {ask: x => x, Monad0: () => Control$dMonad.monadFn};
|
||||
const monadReaderFun = {local: f => g => x => g(f(x)), MonadAsk0: () => monadAskFun};
|
||||
const local = dict => dict.local;
|
||||
const ask = dict => dict.ask;
|
||||
const asks = dictMonadAsk => {
|
||||
const map = dictMonadAsk.Monad0().Bind1().Apply0().Functor0().map;
|
||||
return f => map(f)(dictMonadAsk.ask);
|
||||
};
|
||||
export {ask, asks, local, monadAskFun, monadReaderFun};
|
@ -0,0 +1,293 @@
|
||||
// | This module defines the reader monad transformer, `ReaderT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const ReaderT = x => x;
|
||||
const withReaderT = f => v => x => v(f(x));
|
||||
const runReaderT = v => v;
|
||||
const newtypeReaderT = {Coercible0: () => undefined};
|
||||
const monadTransReaderT = {lift: dictMonad => x => v => x};
|
||||
const mapReaderT = f => v => x => f(v(x));
|
||||
const functorReaderT = dictFunctor => (
|
||||
{
|
||||
map: x => {
|
||||
const $2 = dictFunctor.map(x);
|
||||
return v => x$1 => $2(v(x$1));
|
||||
}
|
||||
}
|
||||
);
|
||||
const distributiveReaderT = dictDistributive => {
|
||||
const $1 = dictDistributive.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $3 = $1.map(x);
|
||||
return v => x$1 => $3(v(x$1));
|
||||
}
|
||||
};
|
||||
return {
|
||||
distribute: dictFunctor => {
|
||||
const collect1 = dictDistributive.collect(dictFunctor);
|
||||
return a => e => collect1(r => r(e))(a);
|
||||
},
|
||||
collect: dictFunctor => f => {
|
||||
const $5 = distributiveReaderT(dictDistributive).distribute(dictFunctor);
|
||||
const $6 = dictFunctor.map(f);
|
||||
return x => $5($6(x));
|
||||
},
|
||||
Functor0: () => functorReaderT1
|
||||
};
|
||||
};
|
||||
const applyReaderT = dictApply => {
|
||||
const $1 = dictApply.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $3 = $1.map(x);
|
||||
return v => x$1 => $3(v(x$1));
|
||||
}
|
||||
};
|
||||
return {apply: v => v1 => r => dictApply.apply(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
};
|
||||
const bindReaderT = dictBind => {
|
||||
const $1 = dictBind.Apply0();
|
||||
const $2 = $1.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $4 = $2.map(x);
|
||||
return v => x$1 => $4(v(x$1));
|
||||
}
|
||||
};
|
||||
const applyReaderT1 = {apply: v => v1 => r => $1.apply(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
return {bind: v => k => r => dictBind.bind(v(r))(a => k(a)(r)), Apply0: () => applyReaderT1};
|
||||
};
|
||||
const semigroupReaderT = dictApply => {
|
||||
const $1 = dictApply.Functor0();
|
||||
return dictSemigroup => (
|
||||
{
|
||||
append: a => b => {
|
||||
const $5 = $1.map(dictSemigroup.append);
|
||||
return r => dictApply.apply($5(a(r)))(b(r));
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
const applicativeReaderT = dictApplicative => {
|
||||
const $1 = dictApplicative.Apply0();
|
||||
const $2 = $1.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $4 = $2.map(x);
|
||||
return v => x$1 => $4(v(x$1));
|
||||
}
|
||||
};
|
||||
const applyReaderT1 = {apply: v => v1 => r => $1.apply(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
return {
|
||||
pure: x => {
|
||||
const $6 = dictApplicative.pure(x);
|
||||
return v => $6;
|
||||
},
|
||||
Apply0: () => applyReaderT1
|
||||
};
|
||||
};
|
||||
const monadReaderT = dictMonad => {
|
||||
const $1 = dictMonad.Applicative0();
|
||||
const $2 = $1.Apply0();
|
||||
const $3 = $2.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $5 = $3.map(x);
|
||||
return v => x$1 => $5(v(x$1));
|
||||
}
|
||||
};
|
||||
const applyReaderT1 = {apply: v => v1 => r => $2.apply(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
const applicativeReaderT1 = {
|
||||
pure: x => {
|
||||
const $7 = $1.pure(x);
|
||||
return v => $7;
|
||||
},
|
||||
Apply0: () => applyReaderT1
|
||||
};
|
||||
const bindReaderT1 = bindReaderT(dictMonad.Bind1());
|
||||
return {Applicative0: () => applicativeReaderT1, Bind1: () => bindReaderT1};
|
||||
};
|
||||
const monadAskReaderT = dictMonad => {
|
||||
const monadReaderT1 = monadReaderT(dictMonad);
|
||||
return {ask: dictMonad.Applicative0().pure, Monad0: () => monadReaderT1};
|
||||
};
|
||||
const monadReaderReaderT = dictMonad => {
|
||||
const monadReaderT1 = monadReaderT(dictMonad);
|
||||
const monadAskReaderT1 = {ask: dictMonad.Applicative0().pure, Monad0: () => monadReaderT1};
|
||||
return {local: withReaderT, MonadAsk0: () => monadAskReaderT1};
|
||||
};
|
||||
const monadContReaderT = dictMonadCont => {
|
||||
const monadReaderT1 = monadReaderT(dictMonadCont.Monad0());
|
||||
return {
|
||||
callCC: f => r => dictMonadCont.callCC(c => f(x => {
|
||||
const $6 = c(x);
|
||||
return v => $6;
|
||||
})(r)),
|
||||
Monad0: () => monadReaderT1
|
||||
};
|
||||
};
|
||||
const monadEffectReader = dictMonadEffect => {
|
||||
const monadReaderT1 = monadReaderT(dictMonadEffect.Monad0());
|
||||
return {
|
||||
liftEffect: x => {
|
||||
const $3 = dictMonadEffect.liftEffect(x);
|
||||
return v => $3;
|
||||
},
|
||||
Monad0: () => monadReaderT1
|
||||
};
|
||||
};
|
||||
const monadRecReaderT = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const $2 = Monad0.Bind1();
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const monadReaderT1 = monadReaderT(Monad0);
|
||||
return {tailRecM: k => a => r => dictMonadRec.tailRecM(a$p => $2.bind(k(a$p)(r))(pure))(a), Monad0: () => monadReaderT1};
|
||||
};
|
||||
const monadStateReaderT = dictMonadState => {
|
||||
const monadReaderT1 = monadReaderT(dictMonadState.Monad0());
|
||||
return {
|
||||
state: x => {
|
||||
const $3 = dictMonadState.state(x);
|
||||
return v => $3;
|
||||
},
|
||||
Monad0: () => monadReaderT1
|
||||
};
|
||||
};
|
||||
const monadTellReaderT = dictMonadTell => {
|
||||
const Semigroup0 = dictMonadTell.Semigroup0();
|
||||
const monadReaderT1 = monadReaderT(dictMonadTell.Monad1());
|
||||
return {
|
||||
tell: x => {
|
||||
const $4 = dictMonadTell.tell(x);
|
||||
return v => $4;
|
||||
},
|
||||
Semigroup0: () => Semigroup0,
|
||||
Monad1: () => monadReaderT1
|
||||
};
|
||||
};
|
||||
const monadWriterReaderT = dictMonadWriter => {
|
||||
const Monoid0 = dictMonadWriter.Monoid0();
|
||||
const monadTellReaderT1 = monadTellReaderT(dictMonadWriter.MonadTell1());
|
||||
return {listen: v => x => dictMonadWriter.listen(v(x)), pass: v => x => dictMonadWriter.pass(v(x)), Monoid0: () => Monoid0, MonadTell1: () => monadTellReaderT1};
|
||||
};
|
||||
const monadThrowReaderT = dictMonadThrow => {
|
||||
const monadReaderT1 = monadReaderT(dictMonadThrow.Monad0());
|
||||
return {
|
||||
throwError: x => {
|
||||
const $3 = dictMonadThrow.throwError(x);
|
||||
return v => $3;
|
||||
},
|
||||
Monad0: () => monadReaderT1
|
||||
};
|
||||
};
|
||||
const monadErrorReaderT = dictMonadError => {
|
||||
const monadThrowReaderT1 = monadThrowReaderT(dictMonadError.MonadThrow0());
|
||||
return {catchError: v => h => r => dictMonadError.catchError(v(r))(e => h(e)(r)), MonadThrow0: () => monadThrowReaderT1};
|
||||
};
|
||||
const monoidReaderT = dictApplicative => {
|
||||
const $1 = dictApplicative.Apply0();
|
||||
const $2 = $1.Functor0();
|
||||
return dictMonoid => {
|
||||
const $4 = dictMonoid.Semigroup0();
|
||||
const semigroupReaderT2 = {
|
||||
append: a => b => {
|
||||
const $7 = $2.map($4.append);
|
||||
return r => $1.apply($7(a(r)))(b(r));
|
||||
}
|
||||
};
|
||||
return {
|
||||
mempty: (() => {
|
||||
const $6 = dictApplicative.pure(dictMonoid.mempty);
|
||||
return v => $6;
|
||||
})(),
|
||||
Semigroup0: () => semigroupReaderT2
|
||||
};
|
||||
};
|
||||
};
|
||||
const altReaderT = dictAlt => {
|
||||
const $1 = dictAlt.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $3 = $1.map(x);
|
||||
return v => x$1 => $3(v(x$1));
|
||||
}
|
||||
};
|
||||
return {alt: v => v1 => r => dictAlt.alt(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
};
|
||||
const plusReaderT = dictPlus => {
|
||||
const $1 = dictPlus.Alt0();
|
||||
const $2 = $1.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $4 = $2.map(x);
|
||||
return v => x$1 => $4(v(x$1));
|
||||
}
|
||||
};
|
||||
const altReaderT1 = {alt: v => v1 => r => $1.alt(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
return {empty: v => dictPlus.empty, Alt0: () => altReaderT1};
|
||||
};
|
||||
const alternativeReaderT = dictAlternative => {
|
||||
const $1 = dictAlternative.Applicative0();
|
||||
const $2 = $1.Apply0();
|
||||
const $3 = $2.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $5 = $3.map(x);
|
||||
return v => x$1 => $5(v(x$1));
|
||||
}
|
||||
};
|
||||
const applyReaderT1 = {apply: v => v1 => r => $2.apply(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
const applicativeReaderT1 = {
|
||||
pure: x => {
|
||||
const $7 = $1.pure(x);
|
||||
return v => $7;
|
||||
},
|
||||
Apply0: () => applyReaderT1
|
||||
};
|
||||
const $7 = dictAlternative.Plus1();
|
||||
const $8 = $7.Alt0();
|
||||
const $9 = $8.Functor0();
|
||||
const functorReaderT1$1 = {
|
||||
map: x => {
|
||||
const $11 = $9.map(x);
|
||||
return v => x$1 => $11(v(x$1));
|
||||
}
|
||||
};
|
||||
const altReaderT1 = {alt: v => v1 => r => $8.alt(v(r))(v1(r)), Functor0: () => functorReaderT1$1};
|
||||
return {Applicative0: () => applicativeReaderT1, Plus1: () => ({empty: v => $7.empty, Alt0: () => altReaderT1})};
|
||||
};
|
||||
const monadPlusReaderT = dictMonadPlus => {
|
||||
const monadReaderT1 = monadReaderT(dictMonadPlus.Monad0());
|
||||
const alternativeReaderT1 = alternativeReaderT(dictMonadPlus.Alternative1());
|
||||
return {Monad0: () => monadReaderT1, Alternative1: () => alternativeReaderT1};
|
||||
};
|
||||
export {
|
||||
ReaderT,
|
||||
altReaderT,
|
||||
alternativeReaderT,
|
||||
applicativeReaderT,
|
||||
applyReaderT,
|
||||
bindReaderT,
|
||||
distributiveReaderT,
|
||||
functorReaderT,
|
||||
mapReaderT,
|
||||
monadAskReaderT,
|
||||
monadContReaderT,
|
||||
monadEffectReader,
|
||||
monadErrorReaderT,
|
||||
monadPlusReaderT,
|
||||
monadReaderReaderT,
|
||||
monadReaderT,
|
||||
monadRecReaderT,
|
||||
monadStateReaderT,
|
||||
monadTellReaderT,
|
||||
monadThrowReaderT,
|
||||
monadTransReaderT,
|
||||
monadWriterReaderT,
|
||||
monoidReaderT,
|
||||
newtypeReaderT,
|
||||
plusReaderT,
|
||||
runReaderT,
|
||||
semigroupReaderT,
|
||||
withReaderT
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
// | This module defines the `Reader` monad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dReader$dTrans from "../Control.Monad.Reader.Trans/index.js";
|
||||
const withReader = Control$dMonad$dReader$dTrans.withReaderT;
|
||||
const runReader = v => x => v(x);
|
||||
const mapReader = f => v => x => f(v(x));
|
||||
export {mapReader, runReader, withReader};
|
@ -0,0 +1,270 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad from "../Control.Monad/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dIdentity from "../Data.Identity/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import * as Effect from "../Effect/index.js";
|
||||
import * as Effect$dRef from "../Effect.Ref/index.js";
|
||||
const $Step = (tag, _1) => ({tag, _1});
|
||||
const Loop = value0 => $Step("Loop", value0);
|
||||
const Done = value0 => $Step("Done", value0);
|
||||
const tailRecM = dict => dict.tailRecM;
|
||||
const tailRecM2 = dictMonadRec => f => a => b => dictMonadRec.tailRecM(o => f(o.a)(o.b))({a: a, b: b});
|
||||
const tailRecM3 = dictMonadRec => f => a => b => c => dictMonadRec.tailRecM(o => f(o.a)(o.b)(o.c))({a: a, b: b, c: c});
|
||||
const untilJust = dictMonadRec => {
|
||||
const $1 = dictMonadRec.Monad0().Bind1().Apply0().Functor0();
|
||||
return m => dictMonadRec.tailRecM(v => $1.map(v1 => {
|
||||
if (v1.tag === "Nothing") { return $Step("Loop", Data$dUnit.unit); }
|
||||
if (v1.tag === "Just") { return $Step("Done", v1._1); }
|
||||
$runtime.fail();
|
||||
})(m))(Data$dUnit.unit);
|
||||
};
|
||||
const whileJust = dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
return dictMonadRec => {
|
||||
const $3 = dictMonadRec.Monad0().Bind1().Apply0().Functor0();
|
||||
return m => dictMonadRec.tailRecM(v => $3.map(v1 => {
|
||||
if (v1.tag === "Nothing") { return $Step("Done", v); }
|
||||
if (v1.tag === "Just") { return $Step("Loop", append(v)(v1._1)); }
|
||||
$runtime.fail();
|
||||
})(m))(dictMonoid.mempty);
|
||||
};
|
||||
};
|
||||
const tailRec = f => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = f(v._1);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return x => go(f(x));
|
||||
};
|
||||
const tailRec2 = f => a => b => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = f(v._1.a)(v._1.b);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go(f(a)(b));
|
||||
};
|
||||
const tailRec3 = f => a => b => c => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = f(v._1.a)(v._1.b)(v._1.c);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go(f(a)(b)(c));
|
||||
};
|
||||
const monadRecMaybe = {
|
||||
tailRecM: f => a0 => {
|
||||
const $2 = v => {
|
||||
if (v.tag === "Nothing") { return $Step("Done", Data$dMaybe.Nothing); }
|
||||
if (v.tag === "Just") {
|
||||
if (v._1.tag === "Loop") { return $Step("Loop", f(v._1._1)); }
|
||||
if (v._1.tag === "Done") { return $Step("Done", Data$dMaybe.$Maybe("Just", v._1._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = $2(v._1);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go($2(f(a0)));
|
||||
},
|
||||
Monad0: () => Data$dMaybe.monadMaybe
|
||||
};
|
||||
const monadRecIdentity = {
|
||||
tailRecM: f => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = f(v._1);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return x => go(f(x));
|
||||
},
|
||||
Monad0: () => Data$dIdentity.monadIdentity
|
||||
};
|
||||
const monadRecFunction = {
|
||||
tailRecM: f => a0 => e => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = f(v._1)(e);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go(f(a0)(e));
|
||||
},
|
||||
Monad0: () => Control$dMonad.monadFn
|
||||
};
|
||||
const monadRecEither = {
|
||||
tailRecM: f => a0 => {
|
||||
const $2 = v => {
|
||||
if (v.tag === "Left") { return $Step("Done", Data$dEither.$Either("Left", v._1)); }
|
||||
if (v.tag === "Right") {
|
||||
if (v._1.tag === "Loop") { return $Step("Loop", f(v._1._1)); }
|
||||
if (v._1.tag === "Done") { return $Step("Done", Data$dEither.$Either("Right", v._1._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const v = go$a0;
|
||||
if (v.tag === "Loop") {
|
||||
go$a0 = $2(v._1);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Done") {
|
||||
go$c = false;
|
||||
go$r = v._1;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go($2(f(a0)));
|
||||
},
|
||||
Monad0: () => Data$dEither.monadEither
|
||||
};
|
||||
const monadRecEffect = {
|
||||
tailRecM: f => a => {
|
||||
const $2 = Effect.bindE(f(a))(Effect$dRef._new);
|
||||
return () => {
|
||||
const r = $2();
|
||||
Effect.untilE(() => {
|
||||
const v = r.value;
|
||||
if (v.tag === "Loop") {
|
||||
const e = f(v._1)();
|
||||
r.value = e;
|
||||
return false;
|
||||
}
|
||||
if (v.tag === "Done") { return true; }
|
||||
$runtime.fail();
|
||||
})();
|
||||
const a$p = r.value;
|
||||
return (() => {
|
||||
if (a$p.tag === "Done") { return a$p._1; }
|
||||
$runtime.fail();
|
||||
})();
|
||||
};
|
||||
},
|
||||
Monad0: () => Effect.monadEffect
|
||||
};
|
||||
const loop3 = a => b => c => $Step("Loop", {a: a, b: b, c: c});
|
||||
const loop2 = a => b => $Step("Loop", {a: a, b: b});
|
||||
const functorStep = {
|
||||
map: f => m => {
|
||||
if (m.tag === "Loop") { return $Step("Loop", m._1); }
|
||||
if (m.tag === "Done") { return $Step("Done", f(m._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
};
|
||||
const forever = dictMonadRec => {
|
||||
const $1 = dictMonadRec.Monad0().Bind1().Apply0().Functor0();
|
||||
return ma => dictMonadRec.tailRecM(u => $1.map(v => $Step("Loop", u))(ma))(Data$dUnit.unit);
|
||||
};
|
||||
const bifunctorStep = {
|
||||
bimap: v => v1 => v2 => {
|
||||
if (v2.tag === "Loop") { return $Step("Loop", v(v2._1)); }
|
||||
if (v2.tag === "Done") { return $Step("Done", v1(v2._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
};
|
||||
export {
|
||||
$Step,
|
||||
Done,
|
||||
Loop,
|
||||
bifunctorStep,
|
||||
forever,
|
||||
functorStep,
|
||||
loop2,
|
||||
loop3,
|
||||
monadRecEffect,
|
||||
monadRecEither,
|
||||
monadRecFunction,
|
||||
monadRecIdentity,
|
||||
monadRecMaybe,
|
||||
tailRec,
|
||||
tailRec2,
|
||||
tailRec3,
|
||||
tailRecM,
|
||||
tailRecM2,
|
||||
tailRecM3,
|
||||
untilJust,
|
||||
whileJust
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dST$dInternal from "../Control.Monad.ST.Internal/index.js";
|
||||
import * as Effect from "../Effect/index.js";
|
||||
import * as Unsafe$dCoerce from "../Unsafe.Coerce/index.js";
|
||||
const monadSTST = {liftST: x => x, Monad0: () => Control$dMonad$dST$dInternal.monadST};
|
||||
const monadSTEffect = {liftST: Unsafe$dCoerce.unsafeCoerce, Monad0: () => Effect.monadEffect};
|
||||
const liftST = dict => dict.liftST;
|
||||
export {liftST, monadSTEffect, monadSTST};
|
@ -0,0 +1,4 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Unsafe$dCoerce from "../Unsafe.Coerce/index.js";
|
||||
const toEffect = Unsafe$dCoerce.unsafeCoerce;
|
||||
export {toEffect};
|
@ -0,0 +1,90 @@
|
||||
export const map_ = function (f) {
|
||||
return function (a) {
|
||||
return function () {
|
||||
return f(a());
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const pure_ = function (a) {
|
||||
return function () {
|
||||
return a;
|
||||
};
|
||||
};
|
||||
|
||||
export const bind_ = function (a) {
|
||||
return function (f) {
|
||||
return function () {
|
||||
return f(a())();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const run = function (f) {
|
||||
return f();
|
||||
};
|
||||
|
||||
function whileST(f) {
|
||||
return function (a) {
|
||||
return function () {
|
||||
while (f()) {
|
||||
a();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
export { whileST as while };
|
||||
|
||||
function forST(lo) {
|
||||
return function (hi) {
|
||||
return function (f) {
|
||||
return function () {
|
||||
for (var i = lo; i < hi; i++) {
|
||||
f(i)();
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
export { forST as for };
|
||||
|
||||
export const foreach = function (as) {
|
||||
return function (f) {
|
||||
return function () {
|
||||
for (var i = 0, l = as.length; i < l; i++) {
|
||||
f(as[i])();
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
function newSTRef(val) {
|
||||
return function () {
|
||||
return { value: val };
|
||||
};
|
||||
}
|
||||
export { newSTRef as new };
|
||||
|
||||
export const read = function (ref) {
|
||||
return function () {
|
||||
return ref.value;
|
||||
};
|
||||
};
|
||||
|
||||
export const modifyImpl = function (f) {
|
||||
return function (ref) {
|
||||
return function () {
|
||||
var t = f(ref.value);
|
||||
ref.value = t.state;
|
||||
return t.value;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const write = function (a) {
|
||||
return function (ref) {
|
||||
return function () {
|
||||
return ref.value = a; // eslint-disable-line no-return-assign
|
||||
};
|
||||
};
|
||||
};
|
@ -0,0 +1,69 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import {bind_, for as $$for, foreach, map_, modifyImpl, new as $$new, pure_, read, run, while as $$while, write} from "./foreign.js";
|
||||
const modify$p = modifyImpl;
|
||||
const modify = f => modifyImpl(s => {
|
||||
const s$p = f(s);
|
||||
return {state: s$p, value: s$p};
|
||||
});
|
||||
const functorST = {map: map_};
|
||||
const monadST = {Applicative0: () => applicativeST, Bind1: () => bindST};
|
||||
const bindST = {bind: bind_, Apply0: () => applyST};
|
||||
const applyST = {
|
||||
apply: f => a => () => {
|
||||
const f$p = f();
|
||||
const a$p = a();
|
||||
return applicativeST.pure(f$p(a$p))();
|
||||
},
|
||||
Functor0: () => functorST
|
||||
};
|
||||
const applicativeST = {pure: pure_, Apply0: () => applyST};
|
||||
const semigroupST = dictSemigroup => (
|
||||
{
|
||||
append: a => b => () => {
|
||||
const $3 = a();
|
||||
const a$p = b();
|
||||
return dictSemigroup.append($3)(a$p);
|
||||
}
|
||||
}
|
||||
);
|
||||
const monadRecST = {
|
||||
tailRecM: f => a => {
|
||||
const $2 = bind_(f(a))($$new);
|
||||
return () => {
|
||||
const r = $2();
|
||||
$$while(() => {
|
||||
const $4 = r.value;
|
||||
return $4.tag === "Loop";
|
||||
})(() => {
|
||||
const v = r.value;
|
||||
if (v.tag === "Loop") {
|
||||
const e = f(v._1)();
|
||||
r.value = e;
|
||||
return Data$dUnit.unit;
|
||||
}
|
||||
if (v.tag === "Done") { return Data$dUnit.unit; }
|
||||
$runtime.fail();
|
||||
})();
|
||||
const $5 = r.value;
|
||||
return (() => {
|
||||
if ($5.tag === "Done") { return $5._1; }
|
||||
$runtime.fail();
|
||||
})();
|
||||
};
|
||||
},
|
||||
Monad0: () => monadST
|
||||
};
|
||||
const monoidST = dictMonoid => {
|
||||
const $1 = dictMonoid.Semigroup0();
|
||||
const semigroupST1 = {
|
||||
append: a => b => () => {
|
||||
const $4 = a();
|
||||
const a$p = b();
|
||||
return $1.append($4)(a$p);
|
||||
}
|
||||
};
|
||||
return {mempty: () => dictMonoid.mempty, Semigroup0: () => semigroupST1};
|
||||
};
|
||||
export {applicativeST, applyST, bindST, functorST, modify, modify$p, monadRecST, monadST, monoidST, semigroupST};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,2 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
export {};
|
@ -0,0 +1,229 @@
|
||||
export const mkSTFn1 = function mkSTFn1(fn) {
|
||||
return function(x) {
|
||||
return fn(x)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn2 = function mkSTFn2(fn) {
|
||||
return function(a, b) {
|
||||
return fn(a)(b)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn3 = function mkSTFn3(fn) {
|
||||
return function(a, b, c) {
|
||||
return fn(a)(b)(c)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn4 = function mkSTFn4(fn) {
|
||||
return function(a, b, c, d) {
|
||||
return fn(a)(b)(c)(d)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn5 = function mkSTFn5(fn) {
|
||||
return function(a, b, c, d, e) {
|
||||
return fn(a)(b)(c)(d)(e)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn6 = function mkSTFn6(fn) {
|
||||
return function(a, b, c, d, e, f) {
|
||||
return fn(a)(b)(c)(d)(e)(f)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn7 = function mkSTFn7(fn) {
|
||||
return function(a, b, c, d, e, f, g) {
|
||||
return fn(a)(b)(c)(d)(e)(f)(g)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn8 = function mkSTFn8(fn) {
|
||||
return function(a, b, c, d, e, f, g, h) {
|
||||
return fn(a)(b)(c)(d)(e)(f)(g)(h)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn9 = function mkSTFn9(fn) {
|
||||
return function(a, b, c, d, e, f, g, h, i) {
|
||||
return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)();
|
||||
};
|
||||
};
|
||||
|
||||
export const mkSTFn10 = function mkSTFn10(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)();
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn1 = function runSTFn1(fn) {
|
||||
return function(a) {
|
||||
return function() {
|
||||
return fn(a);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn2 = function runSTFn2(fn) {
|
||||
return function(a) {
|
||||
return function(b) {
|
||||
return function() {
|
||||
return fn(a, b);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn3 = function runSTFn3(fn) {
|
||||
return function(a) {
|
||||
return function(b) {
|
||||
return function(c) {
|
||||
return function() {
|
||||
return fn(a, b, c);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn4 = function runSTFn4(fn) {
|
||||
return function(a) {
|
||||
return function(b) {
|
||||
return function(c) {
|
||||
return function(d) {
|
||||
return function() {
|
||||
return fn(a, b, c, d);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn5 = function runSTFn5(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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn6 = function runSTFn6(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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn7 = function runSTFn7(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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn8 = function runSTFn8(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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn9 = function runSTFn9(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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const runSTFn10 = function runSTFn10(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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -0,0 +1,40 @@
|
||||
// | This module defines types for STf uncurried functions, as well as
|
||||
// | functions for converting back and forth between them.
|
||||
// |
|
||||
// | The general naming scheme for functions and types in this module is as
|
||||
// | follows:
|
||||
// |
|
||||
// | * `STFn{N}` means, an uncurried function which accepts N arguments and
|
||||
// | performs some STs. The first N arguments are the actual function's
|
||||
// | argument. The last type argument is the return type.
|
||||
// | * `runSTFn{N}` takes an `STFn` of N arguments, and converts it into
|
||||
// | the normal PureScript form: a curried function which returns an ST
|
||||
// | action.
|
||||
// | * `mkSTFn{N}` is the inverse of `runSTFn{N}`. It can be useful for
|
||||
// | callbacks.
|
||||
// |
|
||||
import * as $runtime from "../runtime.js";
|
||||
import {
|
||||
mkSTFn1,
|
||||
mkSTFn10,
|
||||
mkSTFn2,
|
||||
mkSTFn3,
|
||||
mkSTFn4,
|
||||
mkSTFn5,
|
||||
mkSTFn6,
|
||||
mkSTFn7,
|
||||
mkSTFn8,
|
||||
mkSTFn9,
|
||||
runSTFn1,
|
||||
runSTFn10,
|
||||
runSTFn2,
|
||||
runSTFn3,
|
||||
runSTFn4,
|
||||
runSTFn5,
|
||||
runSTFn6,
|
||||
runSTFn7,
|
||||
runSTFn8,
|
||||
runSTFn9
|
||||
} from "./foreign.js";
|
||||
export {};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,2 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
export {};
|
@ -0,0 +1,14 @@
|
||||
// | This module defines the `MonadState` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const state = dict => dict.state;
|
||||
const put = dictMonadState => s => dictMonadState.state(v => Data$dTuple.$Tuple(Data$dUnit.unit, s));
|
||||
const modify_ = dictMonadState => f => dictMonadState.state(s => Data$dTuple.$Tuple(Data$dUnit.unit, f(s)));
|
||||
const modify = dictMonadState => f => dictMonadState.state(s => {
|
||||
const s$p = f(s);
|
||||
return Data$dTuple.$Tuple(s$p, s$p);
|
||||
});
|
||||
const gets = dictMonadState => f => dictMonadState.state(s => Data$dTuple.$Tuple(f(s), s));
|
||||
const $$get = dictMonadState => dictMonadState.state(s => Data$dTuple.$Tuple(s, s));
|
||||
export {$$get as get, gets, modify, modify_, put, state};
|
@ -0,0 +1,194 @@
|
||||
// | This module defines the state monad transformer, `StateT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const StateT = x => x;
|
||||
const withStateT = f => v => x => v(f(x));
|
||||
const runStateT = v => v;
|
||||
const newtypeStateT = {Coercible0: () => undefined};
|
||||
const monadTransStateT = {
|
||||
lift: dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return m => s => bind(m)(x => pure(Data$dTuple.$Tuple(x, s)));
|
||||
}
|
||||
};
|
||||
const mapStateT = f => v => x => f(v(x));
|
||||
const lazyStateT = {defer: f => s => f(Data$dUnit.unit)(s)};
|
||||
const functorStateT = dictFunctor => ({map: f => v => s => dictFunctor.map(v1 => Data$dTuple.$Tuple(f(v1._1), v1._2))(v(s))});
|
||||
const execStateT = dictFunctor => v => s => dictFunctor.map(Data$dTuple.snd)(v(s));
|
||||
const evalStateT = dictFunctor => v => s => dictFunctor.map(Data$dTuple.fst)(v(s));
|
||||
const monadStateT = dictMonad => ({Applicative0: () => applicativeStateT(dictMonad), Bind1: () => bindStateT(dictMonad)});
|
||||
const bindStateT = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
return {bind: v => f => s => bind(v(s))(v1 => f(v1._1)(v1._2)), Apply0: () => applyStateT(dictMonad)};
|
||||
};
|
||||
const applyStateT = dictMonad => {
|
||||
const functorStateT1 = functorStateT(dictMonad.Bind1().Apply0().Functor0());
|
||||
return {
|
||||
apply: (() => {
|
||||
const bind = bindStateT(dictMonad).bind;
|
||||
const pure = applicativeStateT(dictMonad).pure;
|
||||
return f => a => bind(f)(f$p => bind(a)(a$p => pure(f$p(a$p))));
|
||||
})(),
|
||||
Functor0: () => functorStateT1
|
||||
};
|
||||
};
|
||||
const applicativeStateT = dictMonad => {
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return {pure: a => s => pure(Data$dTuple.$Tuple(a, s)), Apply0: () => applyStateT(dictMonad)};
|
||||
};
|
||||
const semigroupStateT = dictMonad => {
|
||||
const $1 = applyStateT(dictMonad);
|
||||
const map = $1.Functor0().map;
|
||||
return dictSemigroup => ({append: a => b => $1.apply(map(dictSemigroup.append)(a))(b)});
|
||||
};
|
||||
const monadAskStateT = dictMonadAsk => {
|
||||
const Monad0 = dictMonadAsk.Monad0();
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(Monad0), Bind1: () => bindStateT(Monad0)};
|
||||
return {ask: monadTransStateT.lift(Monad0)(dictMonadAsk.ask), Monad0: () => monadStateT1};
|
||||
};
|
||||
const monadReaderStateT = dictMonadReader => {
|
||||
const monadAskStateT1 = monadAskStateT(dictMonadReader.MonadAsk0());
|
||||
return {
|
||||
local: x => {
|
||||
const $3 = dictMonadReader.local(x);
|
||||
return v => x$1 => $3(v(x$1));
|
||||
},
|
||||
MonadAsk0: () => monadAskStateT1
|
||||
};
|
||||
};
|
||||
const monadContStateT = dictMonadCont => {
|
||||
const $1 = dictMonadCont.Monad0();
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT($1), Bind1: () => bindStateT($1)};
|
||||
return {callCC: f => s => dictMonadCont.callCC(c => f(a => s$p => c(Data$dTuple.$Tuple(a, s$p)))(s)), Monad0: () => monadStateT1};
|
||||
};
|
||||
const monadEffectState = dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(Monad0), Bind1: () => bindStateT(Monad0)};
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $3 = monadTransStateT.lift(Monad0);
|
||||
return x => $3(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadStateT1
|
||||
};
|
||||
};
|
||||
const monadRecStateT = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(Monad0), Bind1: () => bindStateT(Monad0)};
|
||||
return {
|
||||
tailRecM: f => a => s => dictMonadRec.tailRecM(v => bind(f(v._1)(v._2))(v2 => pure((() => {
|
||||
if (v2._1.tag === "Loop") { return Control$dMonad$dRec$dClass.$Step("Loop", Data$dTuple.$Tuple(v2._1._1, v2._2)); }
|
||||
if (v2._1.tag === "Done") { return Control$dMonad$dRec$dClass.$Step("Done", Data$dTuple.$Tuple(v2._1._1, v2._2)); }
|
||||
$runtime.fail();
|
||||
})())))(Data$dTuple.$Tuple(a, s)),
|
||||
Monad0: () => monadStateT1
|
||||
};
|
||||
};
|
||||
const monadStateStateT = dictMonad => {
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(dictMonad), Bind1: () => bindStateT(dictMonad)};
|
||||
return {state: f => x => pure(f(x)), Monad0: () => monadStateT1};
|
||||
};
|
||||
const monadTellStateT = dictMonadTell => {
|
||||
const Monad1 = dictMonadTell.Monad1();
|
||||
const Semigroup0 = dictMonadTell.Semigroup0();
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(Monad1), Bind1: () => bindStateT(Monad1)};
|
||||
return {
|
||||
tell: (() => {
|
||||
const $4 = monadTransStateT.lift(Monad1);
|
||||
return x => $4(dictMonadTell.tell(x));
|
||||
})(),
|
||||
Semigroup0: () => Semigroup0,
|
||||
Monad1: () => monadStateT1
|
||||
};
|
||||
};
|
||||
const monadWriterStateT = dictMonadWriter => {
|
||||
const MonadTell1 = dictMonadWriter.MonadTell1();
|
||||
const Monad1 = MonadTell1.Monad1();
|
||||
const bind = Monad1.Bind1().bind;
|
||||
const pure = Monad1.Applicative0().pure;
|
||||
const Monoid0 = dictMonadWriter.Monoid0();
|
||||
const monadTellStateT1 = monadTellStateT(MonadTell1);
|
||||
return {
|
||||
listen: m => s => bind(dictMonadWriter.listen(m(s)))(v => pure(Data$dTuple.$Tuple(Data$dTuple.$Tuple(v._1._1, v._2), v._1._2))),
|
||||
pass: m => s => dictMonadWriter.pass(bind(m(s))(v => pure(Data$dTuple.$Tuple(Data$dTuple.$Tuple(v._1._1, v._2), v._1._2)))),
|
||||
Monoid0: () => Monoid0,
|
||||
MonadTell1: () => monadTellStateT1
|
||||
};
|
||||
};
|
||||
const monadThrowStateT = dictMonadThrow => {
|
||||
const Monad0 = dictMonadThrow.Monad0();
|
||||
const lift1 = monadTransStateT.lift(Monad0);
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(Monad0), Bind1: () => bindStateT(Monad0)};
|
||||
return {throwError: e => lift1(dictMonadThrow.throwError(e)), Monad0: () => monadStateT1};
|
||||
};
|
||||
const monadErrorStateT = dictMonadError => {
|
||||
const monadThrowStateT1 = monadThrowStateT(dictMonadError.MonadThrow0());
|
||||
return {catchError: v => h => s => dictMonadError.catchError(v(s))(e => h(e)(s)), MonadThrow0: () => monadThrowStateT1};
|
||||
};
|
||||
const monoidStateT = dictMonad => {
|
||||
const pure = applicativeStateT(dictMonad).pure;
|
||||
const semigroupStateT1 = semigroupStateT(dictMonad);
|
||||
return dictMonoid => {
|
||||
const semigroupStateT2 = semigroupStateT1(dictMonoid.Semigroup0());
|
||||
return {mempty: pure(dictMonoid.mempty), Semigroup0: () => semigroupStateT2};
|
||||
};
|
||||
};
|
||||
const altStateT = dictMonad => dictAlt => {
|
||||
const functorStateT1 = functorStateT(dictAlt.Functor0());
|
||||
return {alt: v => v1 => s => dictAlt.alt(v(s))(v1(s)), Functor0: () => functorStateT1};
|
||||
};
|
||||
const plusStateT = dictMonad => dictPlus => {
|
||||
const altStateT2 = altStateT(dictMonad)(dictPlus.Alt0());
|
||||
return {empty: v => dictPlus.empty, Alt0: () => altStateT2};
|
||||
};
|
||||
const alternativeStateT = dictMonad => {
|
||||
const applicativeStateT1 = applicativeStateT(dictMonad);
|
||||
return dictAlternative => {
|
||||
const plusStateT2 = plusStateT(dictMonad)(dictAlternative.Plus1());
|
||||
return {Applicative0: () => applicativeStateT1, Plus1: () => plusStateT2};
|
||||
};
|
||||
};
|
||||
const monadPlusStateT = dictMonadPlus => {
|
||||
const Monad0 = dictMonadPlus.Monad0();
|
||||
const monadStateT1 = {Applicative0: () => applicativeStateT(Monad0), Bind1: () => bindStateT(Monad0)};
|
||||
const alternativeStateT1 = alternativeStateT(Monad0)(dictMonadPlus.Alternative1());
|
||||
return {Monad0: () => monadStateT1, Alternative1: () => alternativeStateT1};
|
||||
};
|
||||
export {
|
||||
StateT,
|
||||
altStateT,
|
||||
alternativeStateT,
|
||||
applicativeStateT,
|
||||
applyStateT,
|
||||
bindStateT,
|
||||
evalStateT,
|
||||
execStateT,
|
||||
functorStateT,
|
||||
lazyStateT,
|
||||
mapStateT,
|
||||
monadAskStateT,
|
||||
monadContStateT,
|
||||
monadEffectState,
|
||||
monadErrorStateT,
|
||||
monadPlusStateT,
|
||||
monadReaderStateT,
|
||||
monadRecStateT,
|
||||
monadStateStateT,
|
||||
monadStateT,
|
||||
monadTellStateT,
|
||||
monadThrowStateT,
|
||||
monadTransStateT,
|
||||
monadWriterStateT,
|
||||
monoidStateT,
|
||||
newtypeStateT,
|
||||
plusStateT,
|
||||
runStateT,
|
||||
semigroupStateT,
|
||||
withStateT
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// | This module defines the `State` monad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dState$dTrans from "../Control.Monad.State.Trans/index.js";
|
||||
const withState = Control$dMonad$dState$dTrans.withStateT;
|
||||
const runState = v => x => v(x);
|
||||
const mapState = f => v => x => f(v(x));
|
||||
const execState = v => s => v(s)._2;
|
||||
const evalState = v => s => v(s)._1;
|
||||
export {evalState, execState, mapState, runState, withState};
|
@ -0,0 +1,11 @@
|
||||
// | A _trampoline_ monad, which can be used at the bottom of
|
||||
// | a monad transformer stack to avoid stack overflows in large
|
||||
// | monadic computations.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dFree from "../Control.Monad.Free/index.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const runTrampoline = /* #__PURE__ */ Control$dMonad$dFree.runFree(Data$dFunctor.functorFn)(v => v(Data$dUnit.unit));
|
||||
const done = /* #__PURE__ */ (() => Control$dMonad$dFree.freeApplicative.pure)();
|
||||
const delay = Control$dMonad$dFree.liftF;
|
||||
export {delay, done, runTrampoline};
|
@ -0,0 +1,4 @@
|
||||
// | This module defines the `MonadTrans` type class of _monad transformers_.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const lift = dict => dict.lift;
|
||||
export {lift};
|
@ -0,0 +1,19 @@
|
||||
// | This module defines the `MonadWriter` type class and its instances.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const tell = dict => dict.tell;
|
||||
const pass = dict => dict.pass;
|
||||
const listen = dict => dict.listen;
|
||||
const listens = dictMonadWriter => {
|
||||
const Monad1 = dictMonadWriter.MonadTell1().Monad1();
|
||||
const bind = Monad1.Bind1().bind;
|
||||
const pure = Monad1.Applicative0().pure;
|
||||
return f => m => bind(dictMonadWriter.listen(m))(v => pure(Data$dTuple.$Tuple(v._1, f(v._2))));
|
||||
};
|
||||
const censor = dictMonadWriter => {
|
||||
const Monad1 = dictMonadWriter.MonadTell1().Monad1();
|
||||
const bind = Monad1.Bind1().bind;
|
||||
const pure = Monad1.Applicative0().pure;
|
||||
return f => m => dictMonadWriter.pass(bind(m)(a => pure(Data$dTuple.$Tuple(a, f))));
|
||||
};
|
||||
export {censor, listen, listens, pass, tell};
|
@ -0,0 +1,231 @@
|
||||
// | This module defines the writer monad transformer, `WriterT`.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const WriterT = x => x;
|
||||
const runWriterT = v => v;
|
||||
const newtypeWriterT = {Coercible0: () => undefined};
|
||||
const monadTransWriterT = dictMonoid => (
|
||||
{
|
||||
lift: dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return m => bind(m)(a => pure(Data$dTuple.$Tuple(a, dictMonoid.mempty)));
|
||||
}
|
||||
}
|
||||
);
|
||||
const mapWriterT = f => v => f(v);
|
||||
const functorWriterT = dictFunctor => ({map: f => dictFunctor.map(v => Data$dTuple.$Tuple(f(v._1), v._2))});
|
||||
const execWriterT = dictFunctor => v => dictFunctor.map(Data$dTuple.snd)(v);
|
||||
const applyWriterT = dictSemigroup => dictApply => {
|
||||
const Functor0 = dictApply.Functor0();
|
||||
const functorWriterT1 = functorWriterT(Functor0);
|
||||
return {apply: v => v1 => dictApply.apply(Functor0.map(v3 => v4 => Data$dTuple.$Tuple(v3._1(v4._1), dictSemigroup.append(v3._2)(v4._2)))(v))(v1), Functor0: () => functorWriterT1};
|
||||
};
|
||||
const bindWriterT = dictSemigroup => dictBind => {
|
||||
const Apply0 = dictBind.Apply0();
|
||||
const map = Apply0.Functor0().map;
|
||||
const applyWriterT2 = applyWriterT(dictSemigroup)(Apply0);
|
||||
return {bind: v => k => dictBind.bind(v)(v1 => map(v3 => Data$dTuple.$Tuple(v3._1, dictSemigroup.append(v1._2)(v3._2)))(k(v1._1))), Apply0: () => applyWriterT2};
|
||||
};
|
||||
const semigroupWriterT = dictApply => dictSemigroup => {
|
||||
const $2 = applyWriterT(dictSemigroup)(dictApply);
|
||||
const map = $2.Functor0().map;
|
||||
return dictSemigroup1 => ({append: a => b => $2.apply(map(dictSemigroup1.append)(a))(b)});
|
||||
};
|
||||
const applicativeWriterT = dictMonoid => {
|
||||
const applyWriterT1 = applyWriterT(dictMonoid.Semigroup0());
|
||||
return dictApplicative => {
|
||||
const applyWriterT2 = applyWriterT1(dictApplicative.Apply0());
|
||||
return {pure: a => dictApplicative.pure(Data$dTuple.$Tuple(a, dictMonoid.mempty)), Apply0: () => applyWriterT2};
|
||||
};
|
||||
};
|
||||
const monadWriterT = dictMonoid => {
|
||||
const applicativeWriterT1 = applicativeWriterT(dictMonoid);
|
||||
const bindWriterT1 = bindWriterT(dictMonoid.Semigroup0());
|
||||
return dictMonad => {
|
||||
const applicativeWriterT2 = applicativeWriterT1(dictMonad.Applicative0());
|
||||
const bindWriterT2 = bindWriterT1(dictMonad.Bind1());
|
||||
return {Applicative0: () => applicativeWriterT2, Bind1: () => bindWriterT2};
|
||||
};
|
||||
};
|
||||
const monadAskWriterT = dictMonoid => {
|
||||
const lift = monadTransWriterT(dictMonoid).lift;
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonadAsk => {
|
||||
const Monad0 = dictMonadAsk.Monad0();
|
||||
const monadWriterT2 = monadWriterT1(Monad0);
|
||||
return {ask: lift(Monad0)(dictMonadAsk.ask), Monad0: () => monadWriterT2};
|
||||
};
|
||||
};
|
||||
const monadReaderWriterT = dictMonoid => {
|
||||
const monadAskWriterT1 = monadAskWriterT(dictMonoid);
|
||||
return dictMonadReader => {
|
||||
const monadAskWriterT2 = monadAskWriterT1(dictMonadReader.MonadAsk0());
|
||||
return {local: f => dictMonadReader.local(f), MonadAsk0: () => monadAskWriterT2};
|
||||
};
|
||||
};
|
||||
const monadContWriterT = dictMonoid => {
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonadCont => {
|
||||
const monadWriterT2 = monadWriterT1(dictMonadCont.Monad0());
|
||||
return {callCC: f => dictMonadCont.callCC(c => f(a => c(Data$dTuple.$Tuple(a, dictMonoid.mempty)))), Monad0: () => monadWriterT2};
|
||||
};
|
||||
};
|
||||
const monadEffectWriter = dictMonoid => {
|
||||
const lift = monadTransWriterT(dictMonoid).lift;
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const monadWriterT2 = monadWriterT1(Monad0);
|
||||
return {
|
||||
liftEffect: (() => {
|
||||
const $6 = lift(Monad0);
|
||||
return x => $6(dictMonadEffect.liftEffect(x));
|
||||
})(),
|
||||
Monad0: () => monadWriterT2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadRecWriterT = dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const bind = Monad0.Bind1().bind;
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const monadWriterT2 = monadWriterT1(Monad0);
|
||||
return {
|
||||
tailRecM: f => a => dictMonadRec.tailRecM(v => bind(f(v._1))(v2 => pure((() => {
|
||||
if (v2._1.tag === "Loop") { return Control$dMonad$dRec$dClass.$Step("Loop", Data$dTuple.$Tuple(v2._1._1, append(v._2)(v2._2))); }
|
||||
if (v2._1.tag === "Done") { return Control$dMonad$dRec$dClass.$Step("Done", Data$dTuple.$Tuple(v2._1._1, append(v._2)(v2._2))); }
|
||||
$runtime.fail();
|
||||
})())))(Data$dTuple.$Tuple(a, dictMonoid.mempty)),
|
||||
Monad0: () => monadWriterT2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadStateWriterT = dictMonoid => {
|
||||
const lift = monadTransWriterT(dictMonoid).lift;
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonadState => {
|
||||
const Monad0 = dictMonadState.Monad0();
|
||||
const lift1 = lift(Monad0);
|
||||
const monadWriterT2 = monadWriterT1(Monad0);
|
||||
return {state: f => lift1(dictMonadState.state(f)), Monad0: () => monadWriterT2};
|
||||
};
|
||||
};
|
||||
const monadTellWriterT = dictMonoid => {
|
||||
const Semigroup0 = dictMonoid.Semigroup0();
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonad => {
|
||||
const monadWriterT2 = monadWriterT1(dictMonad);
|
||||
return {
|
||||
tell: (() => {
|
||||
const $5 = dictMonad.Applicative0().pure;
|
||||
const $6 = Data$dTuple.Tuple(Data$dUnit.unit);
|
||||
return x => $5($6(x));
|
||||
})(),
|
||||
Semigroup0: () => Semigroup0,
|
||||
Monad1: () => monadWriterT2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadWriterWriterT = dictMonoid => {
|
||||
const monadTellWriterT1 = monadTellWriterT(dictMonoid);
|
||||
return dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
const monadTellWriterT2 = monadTellWriterT1(dictMonad);
|
||||
return {
|
||||
listen: v => bind(v)(v1 => pure(Data$dTuple.$Tuple(Data$dTuple.$Tuple(v1._1, v1._2), v1._2))),
|
||||
pass: v => bind(v)(v1 => pure(Data$dTuple.$Tuple(v1._1._1, v1._1._2(v1._2)))),
|
||||
Monoid0: () => dictMonoid,
|
||||
MonadTell1: () => monadTellWriterT2
|
||||
};
|
||||
};
|
||||
};
|
||||
const monadThrowWriterT = dictMonoid => {
|
||||
const lift = monadTransWriterT(dictMonoid).lift;
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
return dictMonadThrow => {
|
||||
const Monad0 = dictMonadThrow.Monad0();
|
||||
const lift1 = lift(Monad0);
|
||||
const monadWriterT2 = monadWriterT1(Monad0);
|
||||
return {throwError: e => lift1(dictMonadThrow.throwError(e)), Monad0: () => monadWriterT2};
|
||||
};
|
||||
};
|
||||
const monadErrorWriterT = dictMonoid => {
|
||||
const monadThrowWriterT1 = monadThrowWriterT(dictMonoid);
|
||||
return dictMonadError => {
|
||||
const monadThrowWriterT2 = monadThrowWriterT1(dictMonadError.MonadThrow0());
|
||||
return {catchError: v => h => dictMonadError.catchError(v)(e => h(e)), MonadThrow0: () => monadThrowWriterT2};
|
||||
};
|
||||
};
|
||||
const monoidWriterT = dictApplicative => {
|
||||
const semigroupWriterT1 = semigroupWriterT(dictApplicative.Apply0());
|
||||
return dictMonoid => {
|
||||
const pure = applicativeWriterT(dictMonoid)(dictApplicative).pure;
|
||||
const semigroupWriterT2 = semigroupWriterT1(dictMonoid.Semigroup0());
|
||||
return dictMonoid1 => {
|
||||
const semigroupWriterT3 = semigroupWriterT2(dictMonoid1.Semigroup0());
|
||||
return {mempty: pure(dictMonoid1.mempty), Semigroup0: () => semigroupWriterT3};
|
||||
};
|
||||
};
|
||||
};
|
||||
const altWriterT = dictAlt => {
|
||||
const functorWriterT1 = functorWriterT(dictAlt.Functor0());
|
||||
return {alt: v => v1 => dictAlt.alt(v)(v1), Functor0: () => functorWriterT1};
|
||||
};
|
||||
const plusWriterT = dictPlus => {
|
||||
const altWriterT1 = altWriterT(dictPlus.Alt0());
|
||||
return {empty: dictPlus.empty, Alt0: () => altWriterT1};
|
||||
};
|
||||
const alternativeWriterT = dictMonoid => {
|
||||
const applicativeWriterT1 = applicativeWriterT(dictMonoid);
|
||||
return dictAlternative => {
|
||||
const applicativeWriterT2 = applicativeWriterT1(dictAlternative.Applicative0());
|
||||
const $4 = dictAlternative.Plus1();
|
||||
const altWriterT1 = altWriterT($4.Alt0());
|
||||
return {Applicative0: () => applicativeWriterT2, Plus1: () => ({empty: $4.empty, Alt0: () => altWriterT1})};
|
||||
};
|
||||
};
|
||||
const monadPlusWriterT = dictMonoid => {
|
||||
const monadWriterT1 = monadWriterT(dictMonoid);
|
||||
const alternativeWriterT1 = alternativeWriterT(dictMonoid);
|
||||
return dictMonadPlus => {
|
||||
const monadWriterT2 = monadWriterT1(dictMonadPlus.Monad0());
|
||||
const alternativeWriterT2 = alternativeWriterT1(dictMonadPlus.Alternative1());
|
||||
return {Monad0: () => monadWriterT2, Alternative1: () => alternativeWriterT2};
|
||||
};
|
||||
};
|
||||
export {
|
||||
WriterT,
|
||||
altWriterT,
|
||||
alternativeWriterT,
|
||||
applicativeWriterT,
|
||||
applyWriterT,
|
||||
bindWriterT,
|
||||
execWriterT,
|
||||
functorWriterT,
|
||||
mapWriterT,
|
||||
monadAskWriterT,
|
||||
monadContWriterT,
|
||||
monadEffectWriter,
|
||||
monadErrorWriterT,
|
||||
monadPlusWriterT,
|
||||
monadReaderWriterT,
|
||||
monadRecWriterT,
|
||||
monadStateWriterT,
|
||||
monadTellWriterT,
|
||||
monadThrowWriterT,
|
||||
monadTransWriterT,
|
||||
monadWriterT,
|
||||
monadWriterWriterT,
|
||||
monoidWriterT,
|
||||
newtypeWriterT,
|
||||
plusWriterT,
|
||||
runWriterT,
|
||||
semigroupWriterT
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
// | This module defines the `Writer` monad.
|
||||
import * as $runtime from "../runtime.js";
|
||||
const writer = x => x;
|
||||
const runWriter = x => x;
|
||||
const mapWriter = f => v => f(v);
|
||||
const execWriter = m => m._2;
|
||||
export {execWriter, mapWriter, runWriter, writer};
|
@ -0,0 +1,35 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dApplicative from "../Control.Applicative/index.js";
|
||||
import * as Control$dBind from "../Control.Bind/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const whenM = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const $2 = dictMonad.Applicative0();
|
||||
return mb => m => bind(mb)(b => {
|
||||
if (b) { return m; }
|
||||
return $2.pure(Data$dUnit.unit);
|
||||
});
|
||||
};
|
||||
const unlessM = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const $2 = dictMonad.Applicative0();
|
||||
return mb => m => bind(mb)(b => {
|
||||
if (!b) { return m; }
|
||||
if (b) { return $2.pure(Data$dUnit.unit); }
|
||||
$runtime.fail();
|
||||
});
|
||||
};
|
||||
const monadProxy = {Applicative0: () => Control$dApplicative.applicativeProxy, Bind1: () => Control$dBind.bindProxy};
|
||||
const monadFn = {Applicative0: () => Control$dApplicative.applicativeFn, Bind1: () => Control$dBind.bindFn};
|
||||
const monadArray = {Applicative0: () => Control$dApplicative.applicativeArray, Bind1: () => Control$dBind.bindArray};
|
||||
const liftM1 = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return f => a => bind(a)(a$p => pure(f(a$p)));
|
||||
};
|
||||
const ap = dictMonad => {
|
||||
const bind = dictMonad.Bind1().bind;
|
||||
const pure = dictMonad.Applicative0().pure;
|
||||
return f => a => bind(f)(f$p => bind(a)(a$p => pure(f$p(a$p))));
|
||||
};
|
||||
export {ap, liftM1, monadArray, monadFn, monadProxy, unlessM, whenM};
|
@ -0,0 +1,5 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dAlternative from "../Control.Alternative/index.js";
|
||||
import * as Control$dMonad from "../Control.Monad/index.js";
|
||||
const monadPlusArray = {Monad0: () => Control$dMonad.monadArray, Alternative1: () => Control$dAlternative.alternativeArray};
|
||||
export {monadPlusArray};
|
@ -0,0 +1,168 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dCont$dTrans from "../Control.Monad.Cont.Trans/index.js";
|
||||
import * as Control$dMonad$dExcept$dTrans from "../Control.Monad.Except.Trans/index.js";
|
||||
import * as Control$dMonad$dMaybe$dTrans from "../Control.Monad.Maybe.Trans/index.js";
|
||||
import * as Control$dMonad$dReader$dTrans from "../Control.Monad.Reader.Trans/index.js";
|
||||
import * as Control$dMonad$dWriter$dTrans from "../Control.Monad.Writer.Trans/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dFunctor$dCompose from "../Data.Functor.Compose/index.js";
|
||||
import * as Data$dFunctor$dCostar from "../Data.Functor.Costar/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dProfunctor$dStar from "../Data.Profunctor.Star/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const ParCont = x => x;
|
||||
const sequential = dict => dict.sequential;
|
||||
const parallel = dict => dict.parallel;
|
||||
const newtypeParCont = {Coercible0: () => undefined};
|
||||
const monadParWriterT = dictMonoid => {
|
||||
const monadWriterT = Control$dMonad$dWriter$dTrans.monadWriterT(dictMonoid);
|
||||
const applicativeWriterT = Control$dMonad$dWriter$dTrans.applicativeWriterT(dictMonoid);
|
||||
return dictParallel => {
|
||||
const monadWriterT1 = monadWriterT(dictParallel.Monad0());
|
||||
const applicativeWriterT1 = applicativeWriterT(dictParallel.Applicative1());
|
||||
return {parallel: v => dictParallel.parallel(v), sequential: v => dictParallel.sequential(v), Monad0: () => monadWriterT1, Applicative1: () => applicativeWriterT1};
|
||||
};
|
||||
};
|
||||
const monadParStar = dictParallel => {
|
||||
const monadStar = Data$dProfunctor$dStar.monadStar(dictParallel.Monad0());
|
||||
const $2 = dictParallel.Applicative1();
|
||||
const $3 = $2.Apply0();
|
||||
const $4 = $3.Functor0();
|
||||
const functorStar1 = {
|
||||
map: f => v => {
|
||||
const $7 = $4.map(f);
|
||||
return x => $7(v(x));
|
||||
}
|
||||
};
|
||||
const applyStar1 = {apply: v => v1 => a => $3.apply(v(a))(v1(a)), Functor0: () => functorStar1};
|
||||
const applicativeStar = {pure: a => v => $2.pure(a), Apply0: () => applyStar1};
|
||||
return {parallel: v => x => dictParallel.parallel(v(x)), sequential: v => x => dictParallel.sequential(v(x)), Monad0: () => monadStar, Applicative1: () => applicativeStar};
|
||||
};
|
||||
const monadParReaderT = dictParallel => {
|
||||
const monadReaderT = Control$dMonad$dReader$dTrans.monadReaderT(dictParallel.Monad0());
|
||||
const $2 = dictParallel.Applicative1();
|
||||
const $3 = $2.Apply0();
|
||||
const $4 = $3.Functor0();
|
||||
const functorReaderT1 = {
|
||||
map: x => {
|
||||
const $6 = $4.map(x);
|
||||
return v => x$1 => $6(v(x$1));
|
||||
}
|
||||
};
|
||||
const applyReaderT1 = {apply: v => v1 => r => $3.apply(v(r))(v1(r)), Functor0: () => functorReaderT1};
|
||||
const applicativeReaderT = {
|
||||
pure: x => {
|
||||
const $8 = $2.pure(x);
|
||||
return v => $8;
|
||||
},
|
||||
Apply0: () => applyReaderT1
|
||||
};
|
||||
return {parallel: v => x => dictParallel.parallel(v(x)), sequential: v => x => dictParallel.sequential(v(x)), Monad0: () => monadReaderT, Applicative1: () => applicativeReaderT};
|
||||
};
|
||||
const monadParMaybeT = dictParallel => {
|
||||
const $1 = dictParallel.Monad0();
|
||||
const monadMaybeT = {Applicative0: () => Control$dMonad$dMaybe$dTrans.applicativeMaybeT($1), Bind1: () => Control$dMonad$dMaybe$dTrans.bindMaybeT($1)};
|
||||
const applicativeCompose = Data$dFunctor$dCompose.applicativeCompose(dictParallel.Applicative1())(Data$dMaybe.applicativeMaybe);
|
||||
return {parallel: v => dictParallel.parallel(v), sequential: v => dictParallel.sequential(v), Monad0: () => monadMaybeT, Applicative1: () => applicativeCompose};
|
||||
};
|
||||
const monadParExceptT = dictParallel => {
|
||||
const $1 = dictParallel.Monad0();
|
||||
const monadExceptT = {Applicative0: () => Control$dMonad$dExcept$dTrans.applicativeExceptT($1), Bind1: () => Control$dMonad$dExcept$dTrans.bindExceptT($1)};
|
||||
const applicativeCompose = Data$dFunctor$dCompose.applicativeCompose(dictParallel.Applicative1())(Data$dEither.applicativeEither);
|
||||
return {parallel: v => dictParallel.parallel(v), sequential: v => dictParallel.sequential(v), Monad0: () => monadExceptT, Applicative1: () => applicativeCompose};
|
||||
};
|
||||
const monadParCostar = dictParallel => (
|
||||
{
|
||||
parallel: v => x => v(dictParallel.sequential(x)),
|
||||
sequential: v => x => v(dictParallel.parallel(x)),
|
||||
Monad0: () => Data$dFunctor$dCostar.monadCostar,
|
||||
Applicative1: () => Data$dFunctor$dCostar.applicativeCostar
|
||||
}
|
||||
);
|
||||
const monadParParCont = dictMonadEffect => {
|
||||
const monadContT = Control$dMonad$dCont$dTrans.monadContT(dictMonadEffect.Monad0());
|
||||
return {parallel: ParCont, sequential: v => v, Monad0: () => monadContT, Applicative1: () => applicativeParCont(dictMonadEffect)};
|
||||
};
|
||||
const functorParCont = dictMonadEffect => (
|
||||
{
|
||||
map: f => {
|
||||
const $2 = monadParParCont(dictMonadEffect).parallel;
|
||||
const $3 = monadParParCont(dictMonadEffect).sequential;
|
||||
return x => $2((() => {
|
||||
const $5 = $3(x);
|
||||
return k => $5(a => k(f(a)));
|
||||
})());
|
||||
}
|
||||
}
|
||||
);
|
||||
const applyParCont = dictMonadEffect => {
|
||||
const Bind1 = dictMonadEffect.Monad0().Bind1();
|
||||
return {
|
||||
apply: v => v1 => k => Bind1.bind(dictMonadEffect.liftEffect(() => ({value: Data$dMaybe.Nothing})))(ra => Bind1.bind(dictMonadEffect.liftEffect(() => (
|
||||
{value: Data$dMaybe.Nothing}
|
||||
)))(rb => Bind1.bind(v(a => Bind1.bind(dictMonadEffect.liftEffect(() => rb.value))(mb => {
|
||||
if (mb.tag === "Nothing") { return dictMonadEffect.liftEffect(() => ra.value = Data$dMaybe.$Maybe("Just", a)); }
|
||||
if (mb.tag === "Just") { return k(a(mb._1)); }
|
||||
$runtime.fail();
|
||||
})))(() => v1(b => Bind1.bind(dictMonadEffect.liftEffect(() => ra.value))(ma => {
|
||||
if (ma.tag === "Nothing") { return dictMonadEffect.liftEffect(() => rb.value = Data$dMaybe.$Maybe("Just", b)); }
|
||||
if (ma.tag === "Just") { return k(ma._1(b)); }
|
||||
$runtime.fail();
|
||||
}))))),
|
||||
Functor0: () => functorParCont(dictMonadEffect)
|
||||
};
|
||||
};
|
||||
const applicativeParCont = dictMonadEffect => (
|
||||
{
|
||||
pure: (() => {
|
||||
const $1 = monadParParCont(dictMonadEffect).parallel;
|
||||
return x => $1(k => k(x));
|
||||
})(),
|
||||
Apply0: () => applyParCont(dictMonadEffect)
|
||||
}
|
||||
);
|
||||
const altParCont = dictMonadEffect => {
|
||||
const Monad0 = dictMonadEffect.Monad0();
|
||||
const Bind1 = Monad0.Bind1();
|
||||
const pure = Monad0.Applicative0().pure;
|
||||
const functorParCont1 = functorParCont(dictMonadEffect);
|
||||
return {
|
||||
alt: v => v1 => k => Bind1.bind(dictMonadEffect.liftEffect(() => ({value: false})))(done => Bind1.bind(v(a => Bind1.bind(dictMonadEffect.liftEffect(() => done.value))(b => {
|
||||
if (b) { return pure(Data$dUnit.unit); }
|
||||
return Bind1.bind(dictMonadEffect.liftEffect(() => done.value = true))(() => k(a));
|
||||
})))(() => v1(a => Bind1.bind(dictMonadEffect.liftEffect(() => done.value))(b => {
|
||||
if (b) { return pure(Data$dUnit.unit); }
|
||||
return Bind1.bind(dictMonadEffect.liftEffect(() => done.value = true))(() => k(a));
|
||||
})))),
|
||||
Functor0: () => functorParCont1
|
||||
};
|
||||
};
|
||||
const plusParCont = dictMonadEffect => {
|
||||
const pure = dictMonadEffect.Monad0().Applicative0().pure;
|
||||
const altParCont1 = altParCont(dictMonadEffect);
|
||||
return {empty: v => pure(Data$dUnit.unit), Alt0: () => altParCont1};
|
||||
};
|
||||
const alternativeParCont = dictMonadEffect => {
|
||||
const applicativeParCont1 = applicativeParCont(dictMonadEffect);
|
||||
const plusParCont1 = plusParCont(dictMonadEffect);
|
||||
return {Applicative0: () => applicativeParCont1, Plus1: () => plusParCont1};
|
||||
};
|
||||
export {
|
||||
ParCont,
|
||||
altParCont,
|
||||
alternativeParCont,
|
||||
applicativeParCont,
|
||||
applyParCont,
|
||||
functorParCont,
|
||||
monadParCostar,
|
||||
monadParExceptT,
|
||||
monadParMaybeT,
|
||||
monadParParCont,
|
||||
monadParReaderT,
|
||||
monadParStar,
|
||||
monadParWriterT,
|
||||
newtypeParCont,
|
||||
parallel,
|
||||
plusParCont,
|
||||
sequential
|
||||
};
|
@ -0,0 +1,59 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dFoldable from "../Data.Foldable/index.js";
|
||||
const identity = x => x;
|
||||
const parTraverse_ = dictParallel => {
|
||||
const traverse_ = Data$dFoldable.traverse_(dictParallel.Applicative1());
|
||||
return dictFoldable => {
|
||||
const traverse_1 = traverse_(dictFoldable);
|
||||
return f => {
|
||||
const $5 = traverse_1(x => dictParallel.parallel(f(x)));
|
||||
return x => dictParallel.sequential($5(x));
|
||||
};
|
||||
};
|
||||
};
|
||||
const parTraverse = dictParallel => {
|
||||
const Applicative1 = dictParallel.Applicative1();
|
||||
return dictTraversable => {
|
||||
const traverse = dictTraversable.traverse(Applicative1);
|
||||
return f => {
|
||||
const $5 = traverse(x => dictParallel.parallel(f(x)));
|
||||
return x => dictParallel.sequential($5(x));
|
||||
};
|
||||
};
|
||||
};
|
||||
const parSequence_ = dictParallel => {
|
||||
const parTraverse_1 = parTraverse_(dictParallel);
|
||||
return dictFoldable => parTraverse_1(dictFoldable)(identity);
|
||||
};
|
||||
const parSequence = dictParallel => {
|
||||
const Applicative1 = dictParallel.Applicative1();
|
||||
return dictTraversable => {
|
||||
const $3 = dictTraversable.traverse(Applicative1)(x => dictParallel.parallel(x));
|
||||
return x => dictParallel.sequential($3(x));
|
||||
};
|
||||
};
|
||||
const parOneOfMap = dictParallel => dictAlternative => {
|
||||
const Plus1 = dictAlternative.Plus1();
|
||||
return dictFoldable => {
|
||||
const alt = Plus1.Alt0().alt;
|
||||
return dictFunctor => f => {
|
||||
const $7 = dictFoldable.foldr(x => alt(dictParallel.parallel(f(x))))(Plus1.empty);
|
||||
return x => dictParallel.sequential($7(x));
|
||||
};
|
||||
};
|
||||
};
|
||||
const parOneOf = dictParallel => dictAlternative => {
|
||||
const Plus1 = dictAlternative.Plus1();
|
||||
return dictFoldable => {
|
||||
const alt = Plus1.Alt0().alt;
|
||||
return dictFunctor => {
|
||||
const $6 = dictFoldable.foldr(x => alt(dictParallel.parallel(x)))(Plus1.empty);
|
||||
return x => dictParallel.sequential($6(x));
|
||||
};
|
||||
};
|
||||
};
|
||||
const parApply = dictParallel => {
|
||||
const apply = dictParallel.Applicative1().Apply0().apply;
|
||||
return mf => ma => dictParallel.sequential(apply(dictParallel.parallel(mf))(dictParallel.parallel(ma)));
|
||||
};
|
||||
export {identity, parApply, parOneOf, parOneOfMap, parSequence, parSequence_, parTraverse, parTraverse_};
|
@ -0,0 +1,5 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dAlt from "../Control.Alt/index.js";
|
||||
const plusArray = {empty: [], Alt0: () => Control$dAlt.altArray};
|
||||
const empty = dict => dict.empty;
|
||||
export {empty, plusArray};
|
@ -0,0 +1,24 @@
|
||||
export function promise(f) {
|
||||
return function () {
|
||||
return new Promise(function (success, error) {
|
||||
var succF = function (s) { return function() { return success(s); } };
|
||||
var failF = function (s) { return function() { return error(s); } };
|
||||
|
||||
// This indicates the aff was wrong?
|
||||
try { f(succF)(failF)(); }
|
||||
catch (e) {
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function thenImpl(promise) {
|
||||
return function(errCB) {
|
||||
return function(succCB) {
|
||||
return function() {
|
||||
promise.then(succCB, errCB);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dExcept$dTrans from "../Control.Monad.Except.Trans/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dIdentity from "../Data.Identity/index.js";
|
||||
import * as Data$dList$dTypes from "../Data.List.Types/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import * as Effect$dAff from "../Effect.Aff/index.js";
|
||||
import * as Effect$dException from "../Effect.Exception/index.js";
|
||||
import * as Foreign from "../Foreign/index.js";
|
||||
import {promise, thenImpl} from "./foreign.js";
|
||||
const alt = /* #__PURE__ */ (() => Control$dMonad$dExcept$dTrans.altExceptT(Data$dList$dTypes.semigroupNonEmptyList)(Data$dIdentity.monadIdentity).alt)();
|
||||
const unsafeReadTagged = /* #__PURE__ */ Foreign.unsafeReadTagged(Data$dIdentity.monadIdentity);
|
||||
const readString = /* #__PURE__ */ Foreign.unsafeReadTagged(Data$dIdentity.monadIdentity)("String");
|
||||
const toAff$p = customCoerce => p => Effect$dAff.makeAff(cb => {
|
||||
const $3 = thenImpl(p)($3 => cb(Data$dEither.$Either("Left", customCoerce($3)))())(x => cb(Data$dEither.$Either("Right", x))());
|
||||
return () => {
|
||||
$3();
|
||||
return Effect$dAff.nonCanceler;
|
||||
};
|
||||
});
|
||||
const fromAff = aff => promise(succ => err => {
|
||||
const $3 = Effect$dAff.runAff(v2 => {
|
||||
if (v2.tag === "Left") { return err(v2._1); }
|
||||
if (v2.tag === "Right") { return succ(v2._1); }
|
||||
$runtime.fail();
|
||||
})(aff);
|
||||
return () => {
|
||||
$3();
|
||||
return Data$dUnit.unit;
|
||||
};
|
||||
});
|
||||
const coerce = fn => {
|
||||
const $1 = alt(unsafeReadTagged("Error")(fn))((() => {
|
||||
const $1 = readString(fn);
|
||||
if ($1.tag === "Left") { return Data$dEither.$Either("Left", $1._1); }
|
||||
if ($1.tag === "Right") { return Data$dEither.$Either("Right", Effect$dException.error($1._1)); }
|
||||
$runtime.fail();
|
||||
})());
|
||||
if ($1.tag === "Left") { return Effect$dException.error("Promise failed, couldn't extract JS Error or String"); }
|
||||
if ($1.tag === "Right") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const toAff = /* #__PURE__ */ toAff$p(coerce);
|
||||
const toAffE = f => Effect$dAff._bind(Effect$dAff._liftEffect(f))(toAff$p(coerce));
|
||||
export {alt, coerce, fromAff, readString, toAff, toAff$p, toAffE, unsafeReadTagged};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,5 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
const semigroupoidFn = {compose: f => g => x => f(g(x))};
|
||||
const compose = dict => dict.compose;
|
||||
const composeFlipped = dictSemigroupoid => f => g => dictSemigroupoid.compose(g)(f);
|
||||
export {compose, composeFlipped, semigroupoidFn};
|
@ -0,0 +1,85 @@
|
||||
export const foldr1Impl = function (f) {
|
||||
return function (xs) {
|
||||
var acc = xs[xs.length - 1];
|
||||
for (var i = xs.length - 2; i >= 0; i--) {
|
||||
acc = f(xs[i])(acc);
|
||||
}
|
||||
return acc;
|
||||
};
|
||||
};
|
||||
|
||||
export const foldl1Impl = function (f) {
|
||||
return function (xs) {
|
||||
var acc = xs[0];
|
||||
var len = xs.length;
|
||||
for (var i = 1; i < len; i++) {
|
||||
acc = f(acc)(xs[i]);
|
||||
}
|
||||
return acc;
|
||||
};
|
||||
};
|
||||
|
||||
export const traverse1Impl = function () {
|
||||
function Cont(fn) {
|
||||
this.fn = fn;
|
||||
}
|
||||
|
||||
var emptyList = {};
|
||||
|
||||
var ConsCell = function (head, tail) {
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
};
|
||||
|
||||
function finalCell(head) {
|
||||
return new ConsCell(head, emptyList);
|
||||
}
|
||||
|
||||
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 (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 () {
|
||||
var built = go(buildFrom(last, acc), currentLen - 1, xs);
|
||||
return built;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return function (array) {
|
||||
var acc = map(finalCell)(f(array[array.length - 1]));
|
||||
var result = go(acc, array.length - 1, array);
|
||||
while (result instanceof Cont) {
|
||||
result = result.fn();
|
||||
}
|
||||
|
||||
return map(listToArray)(result);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}();
|
@ -0,0 +1,87 @@
|
||||
// | This module exports the `NonEmptyArray` constructor.
|
||||
// |
|
||||
// | It is **NOT** intended for public use and is **NOT** versioned.
|
||||
// |
|
||||
// | Its content may change **in any way**, **at any time** and
|
||||
// | **without notice**.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dAlt from "../Control.Alt/index.js";
|
||||
import * as Control$dApplicative from "../Control.Applicative/index.js";
|
||||
import * as Control$dApply from "../Control.Apply/index.js";
|
||||
import * as Control$dBind from "../Control.Bind/index.js";
|
||||
import * as Control$dMonad from "../Control.Monad/index.js";
|
||||
import * as Data$dEq from "../Data.Eq/index.js";
|
||||
import * as Data$dFoldable from "../Data.Foldable/index.js";
|
||||
import * as Data$dFoldableWithIndex from "../Data.FoldableWithIndex/index.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import * as Data$dFunctorWithIndex from "../Data.FunctorWithIndex/index.js";
|
||||
import * as Data$dOrd from "../Data.Ord/index.js";
|
||||
import * as Data$dSemigroup from "../Data.Semigroup/index.js";
|
||||
import * as Data$dSemigroup$dTraversable from "../Data.Semigroup.Traversable/index.js";
|
||||
import * as Data$dShow from "../Data.Show/index.js";
|
||||
import * as Data$dTraversable from "../Data.Traversable/index.js";
|
||||
import * as Data$dTraversableWithIndex from "../Data.TraversableWithIndex/index.js";
|
||||
import * as Data$dUnfoldable1 from "../Data.Unfoldable1/index.js";
|
||||
import {foldl1Impl, foldr1Impl, traverse1Impl} from "./foreign.js";
|
||||
const NonEmptyArray = x => x;
|
||||
const unfoldable1NonEmptyArray = Data$dUnfoldable1.unfoldable1Array;
|
||||
const traversableWithIndexNonEmptyArray = Data$dTraversableWithIndex.traversableWithIndexArray;
|
||||
const traversableNonEmptyArray = Data$dTraversable.traversableArray;
|
||||
const showNonEmptyArray = dictShow => {
|
||||
const show = Data$dShow.showArrayImpl(dictShow.show);
|
||||
return {show: v => "(NonEmptyArray " + (show(v) + ")")};
|
||||
};
|
||||
const semigroupNonEmptyArray = Data$dSemigroup.semigroupArray;
|
||||
const ordNonEmptyArray = dictOrd => Data$dOrd.ordArray(dictOrd);
|
||||
const ord1NonEmptyArray = Data$dOrd.ord1Array;
|
||||
const monadNonEmptyArray = Control$dMonad.monadArray;
|
||||
const functorWithIndexNonEmptyArray = Data$dFunctorWithIndex.functorWithIndexArray;
|
||||
const functorNonEmptyArray = Data$dFunctor.functorArray;
|
||||
const foldableWithIndexNonEmptyArray = Data$dFoldableWithIndex.foldableWithIndexArray;
|
||||
const foldableNonEmptyArray = Data$dFoldable.foldableArray;
|
||||
const foldable1NonEmptyArray = {
|
||||
foldMap1: dictSemigroup => f => {
|
||||
const $2 = Data$dFunctor.arrayMap(f);
|
||||
const $3 = foldable1NonEmptyArray.foldl1(dictSemigroup.append);
|
||||
return x => $3($2(x));
|
||||
},
|
||||
foldr1: foldr1Impl,
|
||||
foldl1: foldl1Impl,
|
||||
Foldable0: () => Data$dFoldable.foldableArray
|
||||
};
|
||||
const traversable1NonEmptyArray = {
|
||||
traverse1: dictApply => traverse1Impl(dictApply.apply)(dictApply.Functor0().map),
|
||||
sequence1: dictApply => traversable1NonEmptyArray.traverse1(dictApply)(Data$dSemigroup$dTraversable.identity),
|
||||
Foldable10: () => foldable1NonEmptyArray,
|
||||
Traversable1: () => Data$dTraversable.traversableArray
|
||||
};
|
||||
const eqNonEmptyArray = dictEq => ({eq: Data$dEq.eqArrayImpl(dictEq.eq)});
|
||||
const eq1NonEmptyArray = Data$dEq.eq1Array;
|
||||
const bindNonEmptyArray = Control$dBind.bindArray;
|
||||
const applyNonEmptyArray = Control$dApply.applyArray;
|
||||
const applicativeNonEmptyArray = Control$dApplicative.applicativeArray;
|
||||
const altNonEmptyArray = Control$dAlt.altArray;
|
||||
export {
|
||||
NonEmptyArray,
|
||||
altNonEmptyArray,
|
||||
applicativeNonEmptyArray,
|
||||
applyNonEmptyArray,
|
||||
bindNonEmptyArray,
|
||||
eq1NonEmptyArray,
|
||||
eqNonEmptyArray,
|
||||
foldable1NonEmptyArray,
|
||||
foldableNonEmptyArray,
|
||||
foldableWithIndexNonEmptyArray,
|
||||
functorNonEmptyArray,
|
||||
functorWithIndexNonEmptyArray,
|
||||
monadNonEmptyArray,
|
||||
ord1NonEmptyArray,
|
||||
ordNonEmptyArray,
|
||||
semigroupNonEmptyArray,
|
||||
showNonEmptyArray,
|
||||
traversable1NonEmptyArray,
|
||||
traversableNonEmptyArray,
|
||||
traversableWithIndexNonEmptyArray,
|
||||
unfoldable1NonEmptyArray
|
||||
};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,303 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dBind from "../Control.Bind/index.js";
|
||||
import * as Control$dMonad$dST$dInternal from "../Control.Monad.ST.Internal/index.js";
|
||||
import * as Data$dArray from "../Data.Array/index.js";
|
||||
import * as Data$dArray$dNonEmpty$dInternal from "../Data.Array.NonEmpty.Internal/index.js";
|
||||
import * as Data$dArray$dST from "../Data.Array.ST/index.js";
|
||||
import * as Data$dFoldable from "../Data.Foldable/index.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dNonEmpty from "../Data.NonEmpty/index.js";
|
||||
import * as Data$dOrd from "../Data.Ord/index.js";
|
||||
import * as Data$dSemigroup from "../Data.Semigroup/index.js";
|
||||
import * as Data$dSemigroup$dFoldable from "../Data.Semigroup.Foldable/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const max = x => y => {
|
||||
const v = Data$dOrd.ordInt.compare(x)(y);
|
||||
if (v.tag === "LT") { return y; }
|
||||
if (v.tag === "EQ") { return x; }
|
||||
if (v.tag === "GT") { return x; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const intercalate1 = dictSemigroup => {
|
||||
const foldMap12 = Data$dArray$dNonEmpty$dInternal.foldable1NonEmptyArray.foldMap1({append: v => v1 => j => dictSemigroup.append(v(j))(dictSemigroup.append(j)(v1(j)))});
|
||||
return a => foldable => foldMap12(x => v => x)(foldable)(a);
|
||||
};
|
||||
const transpose = x => Data$dArray.transpose(x);
|
||||
const toArray = v => v;
|
||||
const unionBy$p = eq => xs => x => Data$dArray.unionBy(eq)(xs)(x);
|
||||
const union$p = dictEq => unionBy$p(dictEq.eq);
|
||||
const unionBy = eq => xs => x => Data$dArray.unionBy(eq)(xs)(x);
|
||||
const union = dictEq => unionBy(dictEq.eq);
|
||||
const unzip = x => {
|
||||
const $1 = Data$dArray.unzip(x);
|
||||
return Data$dTuple.$Tuple($1._1, $1._2);
|
||||
};
|
||||
const updateAt = i => x => Data$dArray.updateAt(i)(x);
|
||||
const zip = xs => ys => Data$dArray.zip(xs)(ys);
|
||||
const zipWith = f => xs => ys => Data$dArray.zipWith(f)(xs)(ys);
|
||||
const zipWithA = dictApplicative => Data$dArray.zipWithA(dictApplicative);
|
||||
const splitAt = i => xs => Data$dArray.splitAt(i)(xs);
|
||||
const some = dictAlternative => Data$dArray.some(dictAlternative);
|
||||
const snoc$p = xs => x => Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(Data$dArray$dST.pushAll([x]))(xs));
|
||||
const snoc = xs => x => Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(Data$dArray$dST.pushAll([x]))(xs));
|
||||
const singleton = x => [x];
|
||||
const replicate = i => x => Data$dArray.replicate(max(1)(i))(x);
|
||||
const range = x => y => Data$dArray.range(x)(y);
|
||||
const modifyAt = i => f => x => Data$dArray.modifyAt(i)(f)(x);
|
||||
const intersectBy$p = eq => xs => Data$dArray.intersectBy(eq)(xs);
|
||||
const intersectBy = eq => xs => x => Data$dArray.intersectBy(eq)(xs)(x);
|
||||
const intersect$p = dictEq => intersectBy$p(dictEq.eq);
|
||||
const intersect = dictEq => intersectBy(dictEq.eq);
|
||||
const intercalate = dictSemigroup => intercalate1(dictSemigroup);
|
||||
const insertAt = i => x => Data$dArray.insertAt(i)(x);
|
||||
const fromFoldable1 = dictFoldable1 => Data$dArray.fromFoldableImpl(dictFoldable1.Foldable0().foldr);
|
||||
const fromArray = xs => {
|
||||
if (xs.length > 0) { return Data$dMaybe.$Maybe("Just", xs); }
|
||||
return Data$dMaybe.Nothing;
|
||||
};
|
||||
const fromFoldable = dictFoldable => {
|
||||
const $1 = Data$dArray.fromFoldableImpl(dictFoldable.foldr);
|
||||
return x => {
|
||||
const $3 = $1(x);
|
||||
if ($3.length > 0) { return Data$dMaybe.$Maybe("Just", $3); }
|
||||
return Data$dMaybe.Nothing;
|
||||
};
|
||||
};
|
||||
const transpose$p = x => {
|
||||
const $1 = Data$dArray.transpose(x);
|
||||
if ($1.length > 0) { return Data$dMaybe.$Maybe("Just", $1); }
|
||||
return Data$dMaybe.Nothing;
|
||||
};
|
||||
const foldr1 = Data$dArray$dNonEmpty$dInternal.foldr1Impl;
|
||||
const foldl1 = Data$dArray$dNonEmpty$dInternal.foldl1Impl;
|
||||
const foldMap1 = dictSemigroup => Data$dArray$dNonEmpty$dInternal.foldable1NonEmptyArray.foldMap1(dictSemigroup);
|
||||
const fold1 = dictSemigroup => Data$dArray$dNonEmpty$dInternal.foldable1NonEmptyArray.foldMap1(dictSemigroup)(Data$dSemigroup$dFoldable.identity);
|
||||
const difference$p = dictEq => Data$dFoldable.foldrArray(Data$dArray.delete(dictEq));
|
||||
const cons$p = x => xs => Data$dSemigroup.concatArray([x])(xs);
|
||||
const fromNonEmpty = v => Data$dSemigroup.concatArray([v._1])(v._2);
|
||||
const concatMap = b => a => Control$dBind.arrayBind(a)(b);
|
||||
const concat = /* #__PURE__ */ (() => {
|
||||
const $0 = Data$dFunctor.arrayMap(toArray);
|
||||
return x => Data$dArray.concat($0(x));
|
||||
})();
|
||||
const appendArray = xs => ys => Data$dSemigroup.concatArray(xs)(ys);
|
||||
const alterAt = i => f => x => Data$dArray.alterAt(i)(f)(x);
|
||||
const head = x => {
|
||||
const $1 = Data$dArray.index(x)(0);
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const init = x => {
|
||||
const $1 = Data$dArray.init(x);
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const last = x => {
|
||||
const $1 = Data$dArray.index(x)(x.length - 1 | 0);
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const tail = x => {
|
||||
const $1 = Data$dArray.tail(x);
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const uncons = x => {
|
||||
const $1 = Data$dArray.uncons(x);
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const toNonEmpty = x => {
|
||||
const $1 = Data$dArray.uncons(x);
|
||||
const $2 = (() => {
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
})();
|
||||
return Data$dNonEmpty.$NonEmpty($2.head, $2.tail);
|
||||
};
|
||||
const unsnoc = x => {
|
||||
const $1 = Data$dArray.unsnoc(x);
|
||||
if ($1.tag === "Just") { return $1._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const all = p => Data$dArray.all(p);
|
||||
const any = p => Data$dArray.any(p);
|
||||
const catMaybes = x => Data$dArray.mapMaybe(x$1 => x$1)(x);
|
||||
const $$delete = dictEq => x => x$1 => Data$dArray.deleteBy(dictEq.eq)(x)(x$1);
|
||||
const deleteAt = i => Data$dArray.deleteAt(i);
|
||||
const deleteBy = f => x => x$1 => Data$dArray.deleteBy(f)(x)(x$1);
|
||||
const difference = dictEq => Data$dFoldable.foldrArray(Data$dArray.delete(dictEq));
|
||||
const drop = i => x => {
|
||||
if (i < 1) { return x; }
|
||||
return Data$dArray.slice(i)(x.length)(x);
|
||||
};
|
||||
const dropEnd = i => x => Data$dArray.dropEnd(i)(x);
|
||||
const dropWhile = f => x => Data$dArray.span(f)(x).rest;
|
||||
const elem = dictEq => x => x$1 => Data$dArray.elem(dictEq)(x)(x$1);
|
||||
const elemIndex = dictEq => x => Data$dArray.findIndex(v => dictEq.eq(v)(x));
|
||||
const elemLastIndex = dictEq => x => Data$dArray.findLastIndex(v => dictEq.eq(v)(x));
|
||||
const filter = f => Data$dArray.filter(f);
|
||||
const filterA = dictApplicative => Data$dArray.filterA(dictApplicative);
|
||||
const find = p => x => {
|
||||
const $2 = Data$dArray.findIndex(p)(x);
|
||||
if ($2.tag === "Just") { return Data$dMaybe.$Maybe("Just", x[$2._1]); }
|
||||
return Data$dMaybe.Nothing;
|
||||
};
|
||||
const findIndex = p => Data$dArray.findIndex(p);
|
||||
const findLastIndex = x => Data$dArray.findLastIndex(x);
|
||||
const findMap = p => Data$dArray.findMap(p);
|
||||
const foldM = dictMonad => Data$dArray.foldM(dictMonad);
|
||||
const foldRecM = dictMonadRec => Data$dArray.foldRecM(dictMonadRec);
|
||||
const index = x => Data$dArray.index(x);
|
||||
const length = x => x.length;
|
||||
const mapMaybe = f => x => Data$dArray.mapMaybe(f)(x);
|
||||
const notElem = dictEq => x => x$1 => Data$dArray.notElem(dictEq)(x)(x$1);
|
||||
const partition = f => Data$dArray.partition(f);
|
||||
const slice = start => end => Data$dArray.slice(start)(end);
|
||||
const span = f => x => Data$dArray.span(f)(x);
|
||||
const take = i => x => {
|
||||
if (i < 1) { return []; }
|
||||
return Data$dArray.slice(0)(i)(x);
|
||||
};
|
||||
const takeEnd = i => x => Data$dArray.takeEnd(i)(x);
|
||||
const takeWhile = f => x => Data$dArray.span(f)(x).init;
|
||||
const toUnfoldable = dictUnfoldable => x => Data$dArray.toUnfoldable(dictUnfoldable)(x);
|
||||
const cons = x => x$1 => Data$dSemigroup.concatArray([x])(x$1);
|
||||
const group = dictEq => x => Data$dArray.groupBy(dictEq.eq)(x);
|
||||
const groupAllBy = op => Data$dArray.groupAllBy(op);
|
||||
const groupAll = dictOrd => Data$dArray.groupAllBy(dictOrd.compare);
|
||||
const groupBy = op => x => Data$dArray.groupBy(op)(x);
|
||||
const insert = dictOrd => x => x$1 => Data$dArray.insertBy(dictOrd.compare)(x)(x$1);
|
||||
const insertBy = f => x => x$1 => Data$dArray.insertBy(f)(x)(x$1);
|
||||
const intersperse = x => x$1 => Data$dArray.intersperse(x)(x$1);
|
||||
const mapWithIndex = f => x => Data$dArray.zipWith(f)(Data$dArray.range(0)(x.length - 1 | 0))(x);
|
||||
const modifyAtIndices = dictFoldable => Data$dArray.modifyAtIndices(dictFoldable);
|
||||
const nub = dictOrd => x => Data$dArray.nubBy(dictOrd.compare)(x);
|
||||
const nubBy = f => x => Data$dArray.nubBy(f)(x);
|
||||
const nubByEq = f => x => Data$dArray.nubByEq(f)(x);
|
||||
const nubEq = dictEq => x => Data$dArray.nubByEq(dictEq.eq)(x);
|
||||
const reverse = x => Data$dArray.reverse(x);
|
||||
const scanl = f => x => Data$dArray.scanl(f)(x);
|
||||
const scanr = f => x => Data$dArray.scanr(f)(x);
|
||||
const sort = dictOrd => x => Data$dArray.sortBy(dictOrd.compare)(x);
|
||||
const sortBy = f => Data$dArray.sortBy(f);
|
||||
const sortWith = dictOrd => f => Data$dArray.sortWith(dictOrd)(f);
|
||||
const updateAtIndices = dictFoldable => Data$dArray.updateAtIndices(dictFoldable);
|
||||
const unsafeIndex = () => x => $2 => x[$2];
|
||||
const toUnfoldable1 = dictUnfoldable1 => xs => {
|
||||
const len = xs.length;
|
||||
return dictUnfoldable1.unfoldr1(i => Data$dTuple.$Tuple(
|
||||
xs[i],
|
||||
(() => {
|
||||
if (i < (len - 1 | 0)) { return Data$dMaybe.$Maybe("Just", i + 1 | 0); }
|
||||
return Data$dMaybe.Nothing;
|
||||
})()
|
||||
))(0);
|
||||
};
|
||||
export {
|
||||
all,
|
||||
alterAt,
|
||||
any,
|
||||
appendArray,
|
||||
catMaybes,
|
||||
concat,
|
||||
concatMap,
|
||||
cons,
|
||||
cons$p,
|
||||
$$delete as delete,
|
||||
deleteAt,
|
||||
deleteBy,
|
||||
difference,
|
||||
difference$p,
|
||||
drop,
|
||||
dropEnd,
|
||||
dropWhile,
|
||||
elem,
|
||||
elemIndex,
|
||||
elemLastIndex,
|
||||
filter,
|
||||
filterA,
|
||||
find,
|
||||
findIndex,
|
||||
findLastIndex,
|
||||
findMap,
|
||||
fold1,
|
||||
foldM,
|
||||
foldMap1,
|
||||
foldRecM,
|
||||
foldl1,
|
||||
foldr1,
|
||||
fromArray,
|
||||
fromFoldable,
|
||||
fromFoldable1,
|
||||
fromNonEmpty,
|
||||
group,
|
||||
groupAll,
|
||||
groupAllBy,
|
||||
groupBy,
|
||||
head,
|
||||
index,
|
||||
init,
|
||||
insert,
|
||||
insertAt,
|
||||
insertBy,
|
||||
intercalate,
|
||||
intercalate1,
|
||||
intersect,
|
||||
intersect$p,
|
||||
intersectBy,
|
||||
intersectBy$p,
|
||||
intersperse,
|
||||
last,
|
||||
length,
|
||||
mapMaybe,
|
||||
mapWithIndex,
|
||||
max,
|
||||
modifyAt,
|
||||
modifyAtIndices,
|
||||
notElem,
|
||||
nub,
|
||||
nubBy,
|
||||
nubByEq,
|
||||
nubEq,
|
||||
partition,
|
||||
range,
|
||||
replicate,
|
||||
reverse,
|
||||
scanl,
|
||||
scanr,
|
||||
singleton,
|
||||
slice,
|
||||
snoc,
|
||||
snoc$p,
|
||||
some,
|
||||
sort,
|
||||
sortBy,
|
||||
sortWith,
|
||||
span,
|
||||
splitAt,
|
||||
tail,
|
||||
take,
|
||||
takeEnd,
|
||||
takeWhile,
|
||||
toArray,
|
||||
toNonEmpty,
|
||||
toUnfoldable,
|
||||
toUnfoldable1,
|
||||
transpose,
|
||||
transpose$p,
|
||||
uncons,
|
||||
union,
|
||||
union$p,
|
||||
unionBy,
|
||||
unionBy$p,
|
||||
unsafeIndex,
|
||||
unsnoc,
|
||||
unzip,
|
||||
updateAt,
|
||||
updateAtIndices,
|
||||
zip,
|
||||
zipWith,
|
||||
zipWithA
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
// | Partial helper functions for working with immutable arrays.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dArray from "../Data.Array/index.js";
|
||||
const tail = () => xs => Data$dArray.slice(1)(xs.length)(xs);
|
||||
const last = () => xs => xs[(xs.length - 1 | 0)];
|
||||
const init = () => xs => Data$dArray.slice(0)(xs.length - 1 | 0)(xs);
|
||||
const head = () => xs => xs[0];
|
||||
export {head, init, last, tail};
|
@ -0,0 +1,74 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dST$dInternal from "../Control.Monad.ST.Internal/index.js";
|
||||
import * as Data$dArray$dST from "../Data.Array.ST/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const $Iterator = (_1, _2) => ({tag: "Iterator", _1, _2});
|
||||
const Iterator = value0 => value1 => $Iterator(value0, value1);
|
||||
const peek = v => () => {
|
||||
const i = v._2.value;
|
||||
return v._1(i);
|
||||
};
|
||||
const next = v => () => {
|
||||
const i = v._2.value;
|
||||
const $2 = v._2.value;
|
||||
v._2.value = $2 + 1 | 0;
|
||||
return v._1(i);
|
||||
};
|
||||
const pushWhile = p => iter => array => () => {
|
||||
const $$break = {value: false};
|
||||
return Control$dMonad$dST$dInternal.while(() => {
|
||||
const $4 = $$break.value;
|
||||
return !$4;
|
||||
})(() => {
|
||||
const i = iter._2.value;
|
||||
const mx = iter._1(i);
|
||||
if (mx.tag === "Just") {
|
||||
if (p(mx._1)) {
|
||||
Data$dArray$dST.pushAll([mx._1])(array)();
|
||||
iter._2.value;
|
||||
const $8 = iter._2.value;
|
||||
iter._2.value = $8 + 1 | 0;
|
||||
return Data$dUnit.unit;
|
||||
}
|
||||
$$break.value = true;
|
||||
return Data$dUnit.unit;
|
||||
}
|
||||
$$break.value = true;
|
||||
return Data$dUnit.unit;
|
||||
})();
|
||||
};
|
||||
const pushAll = /* #__PURE__ */ pushWhile(v => true);
|
||||
const iterator = f => {
|
||||
const $1 = Iterator(f);
|
||||
return () => {
|
||||
const $2 = {value: 0};
|
||||
return $1($2);
|
||||
};
|
||||
};
|
||||
const iterate = iter => f => () => {
|
||||
const $$break = {value: false};
|
||||
return Control$dMonad$dST$dInternal.while(() => {
|
||||
const $3 = $$break.value;
|
||||
return !$3;
|
||||
})(() => {
|
||||
const i = iter._2.value;
|
||||
const $4 = iter._2.value;
|
||||
iter._2.value = $4 + 1 | 0;
|
||||
const mx = iter._1(i);
|
||||
if (mx.tag === "Just") { return f(mx._1)(); }
|
||||
if (mx.tag === "Nothing") {
|
||||
$$break.value = true;
|
||||
return Data$dUnit.unit;
|
||||
}
|
||||
$runtime.fail();
|
||||
})();
|
||||
};
|
||||
const exhausted = /* #__PURE__ */ (() => {
|
||||
const $0 = Control$dMonad$dST$dInternal.map_(Data$dMaybe.isNothing);
|
||||
return x => $0(() => {
|
||||
const i = x._2.value;
|
||||
return x._1(i);
|
||||
});
|
||||
})();
|
||||
export {$Iterator, Iterator, exhausted, iterate, iterator, next, peek, pushAll, pushWhile};
|
@ -0,0 +1,17 @@
|
||||
export const peekImpl = function (i) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return xs[i];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const pokeImpl = function (i) {
|
||||
return function (a) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
xs[i] = a;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// | Partial functions for working with mutable arrays using the `ST` effect.
|
||||
// |
|
||||
// | This module is particularly helpful when performance is very important.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import {peekImpl, pokeImpl} from "./foreign.js";
|
||||
const poke = () => pokeImpl;
|
||||
const peek = () => peekImpl;
|
||||
export {peek, poke};
|
||||
export * from "./foreign.js";
|
160
.storybook/purescript-indexer/output-es/Data.Array.ST/foreign.js
Normal file
160
.storybook/purescript-indexer/output-es/Data.Array.ST/foreign.js
Normal file
@ -0,0 +1,160 @@
|
||||
function newSTArray () {
|
||||
return [];
|
||||
}
|
||||
export { newSTArray as new };
|
||||
|
||||
export const peekImpl = function (just) {
|
||||
return function (nothing) {
|
||||
return function (i) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return i >= 0 && i < xs.length ? just(xs[i]) : nothing;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const poke = function (i) {
|
||||
return function (a) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
var ret = i >= 0 && i < xs.length;
|
||||
if (ret) xs[i] = a;
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const popImpl = function (just) {
|
||||
return function (nothing) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return xs.length > 0 ? just(xs.pop()) : nothing;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const pushAll = function (as) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return xs.push.apply(xs, as);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const shiftImpl = function (just) {
|
||||
return function (nothing) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return xs.length > 0 ? just(xs.shift()) : nothing;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const unshiftAll = function (as) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return xs.unshift.apply(xs, as);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const splice = function (i) {
|
||||
return function (howMany) {
|
||||
return function (bs) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
return xs.splice.apply(xs, [i, howMany].concat(bs));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const unsafeFreeze = function (xs) {
|
||||
return function () {
|
||||
return xs;
|
||||
};
|
||||
};
|
||||
|
||||
export const unsafeThaw = function (xs) {
|
||||
return function () {
|
||||
return xs;
|
||||
};
|
||||
};
|
||||
|
||||
function copyImpl(xs) {
|
||||
return function () {
|
||||
return xs.slice();
|
||||
};
|
||||
}
|
||||
|
||||
export const freeze = copyImpl;
|
||||
|
||||
export const thaw = copyImpl;
|
||||
|
||||
export const sortByImpl = (function () {
|
||||
function mergeFromTo(compare, fromOrdering, xs1, xs2, from, to) {
|
||||
var mid;
|
||||
var i;
|
||||
var j;
|
||||
var k;
|
||||
var x;
|
||||
var y;
|
||||
var c;
|
||||
|
||||
mid = from + ((to - from) >> 1);
|
||||
if (mid - from > 1) mergeFromTo(compare, fromOrdering, xs2, xs1, from, mid);
|
||||
if (to - mid > 1) mergeFromTo(compare, fromOrdering, xs2, xs1, mid, to);
|
||||
|
||||
i = from;
|
||||
j = mid;
|
||||
k = from;
|
||||
while (i < mid && j < to) {
|
||||
x = xs2[i];
|
||||
y = xs2[j];
|
||||
c = fromOrdering(compare(x)(y));
|
||||
if (c > 0) {
|
||||
xs1[k++] = y;
|
||||
++j;
|
||||
}
|
||||
else {
|
||||
xs1[k++] = x;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
while (i < mid) {
|
||||
xs1[k++] = xs2[i++];
|
||||
}
|
||||
while (j < to) {
|
||||
xs1[k++] = xs2[j++];
|
||||
}
|
||||
}
|
||||
|
||||
return function (compare) {
|
||||
return function (fromOrdering) {
|
||||
return function (xs) {
|
||||
return function () {
|
||||
if (xs.length < 2) return xs;
|
||||
|
||||
mergeFromTo(compare, fromOrdering, xs, xs.slice(0), 0, xs.length);
|
||||
|
||||
return xs;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
})();
|
||||
|
||||
export const 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;
|
||||
};
|
||||
};
|
@ -0,0 +1,40 @@
|
||||
// | 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.
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dMonad$dST$dInternal from "../Control.Monad.ST.Internal/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import {freeze, new as $$new, peekImpl, poke, popImpl, pushAll, shiftImpl, sortByImpl, splice, thaw, toAssocArray, unsafeFreeze, unsafeThaw, unshiftAll} from "./foreign.js";
|
||||
const withArray = f => xs => {
|
||||
const $2 = thaw(xs);
|
||||
return () => {
|
||||
const result = $2();
|
||||
f(result)();
|
||||
return unsafeFreeze(result)();
|
||||
};
|
||||
};
|
||||
const unshift = a => unshiftAll([a]);
|
||||
const sortBy = comp => sortByImpl(comp)(v => {
|
||||
if (v.tag === "GT") { return 1; }
|
||||
if (v.tag === "EQ") { return 0; }
|
||||
if (v.tag === "LT") { return -1; }
|
||||
$runtime.fail();
|
||||
});
|
||||
const sortWith = dictOrd => f => sortBy(x => y => dictOrd.compare(f(x))(f(y)));
|
||||
const sort = dictOrd => sortBy(dictOrd.compare);
|
||||
const shift = /* #__PURE__ */ shiftImpl(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const run = st => Control$dMonad$dST$dInternal.run(Control$dMonad$dST$dInternal.bind_(st)(unsafeFreeze));
|
||||
const push = a => pushAll([a]);
|
||||
const pop = /* #__PURE__ */ popImpl(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const peek = /* #__PURE__ */ peekImpl(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const modify = i => f => xs => {
|
||||
const $3 = peek(i)(xs);
|
||||
return () => {
|
||||
const entry = $3();
|
||||
if (entry.tag === "Just") { return poke(i)(f(entry._1))(xs)(); }
|
||||
if (entry.tag === "Nothing") { return false; }
|
||||
$runtime.fail();
|
||||
};
|
||||
};
|
||||
export {modify, peek, pop, push, run, shift, sort, sortBy, sortWith, unshift, withArray};
|
||||
export * from "./foreign.js";
|
386
.storybook/purescript-indexer/output-es/Data.Array/foreign.js
Normal file
386
.storybook/purescript-indexer/output-es/Data.Array/foreign.js
Normal file
@ -0,0 +1,386 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Array creation --------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const range = function (start) {
|
||||
return function (end) {
|
||||
var step = start > end ? -1 : 1;
|
||||
var result = new Array(step * (end - start) + 1);
|
||||
var i = start, n = 0;
|
||||
while (i !== end) {
|
||||
result[n++] = i;
|
||||
i += step;
|
||||
}
|
||||
result[n] = i;
|
||||
return result;
|
||||
};
|
||||
};
|
||||
|
||||
var replicateFill = 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.
|
||||
export const replicate = typeof Array.prototype.fill === "function" ? replicateFill : replicatePolyfill;
|
||||
|
||||
export const fromFoldableImpl = (function () {
|
||||
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 ------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const length = function (xs) {
|
||||
return xs.length;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Non-indexed reads -----------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const unconsImpl = function (empty) {
|
||||
return function (next) {
|
||||
return function (xs) {
|
||||
return xs.length === 0 ? empty({}) : next(xs[0])(xs.slice(1));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Indexed operations ----------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const indexImpl = function (just) {
|
||||
return function (nothing) {
|
||||
return function (xs) {
|
||||
return function (i) {
|
||||
return i < 0 || i >= xs.length ? nothing : just(xs[i]);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const findMapImpl = function (nothing) {
|
||||
return function (isJust) {
|
||||
return function (f) {
|
||||
return function (xs) {
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
var result = f(xs[i]);
|
||||
if (isJust(result)) return result;
|
||||
}
|
||||
return nothing;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const _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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const _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);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const _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 -------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const reverse = function (l) {
|
||||
return l.slice().reverse();
|
||||
};
|
||||
|
||||
export const 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;
|
||||
};
|
||||
|
||||
export const filter = function (f) {
|
||||
return function (xs) {
|
||||
return xs.filter(f);
|
||||
};
|
||||
};
|
||||
|
||||
export const 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 };
|
||||
};
|
||||
};
|
||||
|
||||
export const scanl = function (f) {
|
||||
return function (b) {
|
||||
return function (xs) {
|
||||
var len = xs.length;
|
||||
var acc = b;
|
||||
var out = new Array(len);
|
||||
for (var i = 0; i < len; i++) {
|
||||
acc = f(acc)(xs[i]);
|
||||
out[i] = acc;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const scanr = function (f) {
|
||||
return function (b) {
|
||||
return function (xs) {
|
||||
var len = xs.length;
|
||||
var acc = b;
|
||||
var out = new Array(len);
|
||||
for (var i = len - 1; i >= 0; i--) {
|
||||
acc = f(xs[i])(acc);
|
||||
out[i] = acc;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Sorting ---------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const sortByImpl = (function () {
|
||||
function mergeFromTo(compare, fromOrdering, xs1, xs2, from, to) {
|
||||
var mid;
|
||||
var i;
|
||||
var j;
|
||||
var k;
|
||||
var x;
|
||||
var y;
|
||||
var c;
|
||||
|
||||
mid = from + ((to - from) >> 1);
|
||||
if (mid - from > 1) mergeFromTo(compare, fromOrdering, xs2, xs1, from, mid);
|
||||
if (to - mid > 1) mergeFromTo(compare, fromOrdering, xs2, xs1, mid, to);
|
||||
|
||||
i = from;
|
||||
j = mid;
|
||||
k = from;
|
||||
while (i < mid && j < to) {
|
||||
x = xs2[i];
|
||||
y = xs2[j];
|
||||
c = fromOrdering(compare(x)(y));
|
||||
if (c > 0) {
|
||||
xs1[k++] = y;
|
||||
++j;
|
||||
}
|
||||
else {
|
||||
xs1[k++] = x;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
while (i < mid) {
|
||||
xs1[k++] = xs2[i++];
|
||||
}
|
||||
while (j < to) {
|
||||
xs1[k++] = xs2[j++];
|
||||
}
|
||||
}
|
||||
|
||||
return function (compare) {
|
||||
return function (fromOrdering) {
|
||||
return function (xs) {
|
||||
var out;
|
||||
|
||||
if (xs.length < 2) return xs;
|
||||
|
||||
out = xs.slice(0);
|
||||
mergeFromTo(compare, fromOrdering, out, xs.slice(0), 0, xs.length);
|
||||
|
||||
return out;
|
||||
};
|
||||
};
|
||||
};
|
||||
})();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Subarrays -------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const slice = function (s) {
|
||||
return function (e) {
|
||||
return function (l) {
|
||||
return l.slice(s, e);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Zipping ---------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Folding ---------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const any = function (p) {
|
||||
return function (xs) {
|
||||
var len = xs.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (p(xs[i])) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
export const all = function (p) {
|
||||
return function (xs) {
|
||||
var len = xs.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (!p(xs[i])) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Partial ---------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export const unsafeIndexImpl = function (xs) {
|
||||
return function (n) {
|
||||
return xs[n];
|
||||
};
|
||||
};
|
519
.storybook/purescript-indexer/output-es/Data.Array/index.js
Normal file
519
.storybook/purescript-indexer/output-es/Data.Array/index.js
Normal file
@ -0,0 +1,519 @@
|
||||
// | 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 STAI.iterate over an array and accumulate effects.
|
||||
// |
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dBind from "../Control.Bind/index.js";
|
||||
import * as Control$dMonad$dRec$dClass from "../Control.Monad.Rec.Class/index.js";
|
||||
import * as Control$dMonad$dST$dInternal from "../Control.Monad.ST.Internal/index.js";
|
||||
import * as Data$dArray$dST from "../Data.Array.ST/index.js";
|
||||
import * as Data$dArray$dST$dIterator from "../Data.Array.ST.Iterator/index.js";
|
||||
import * as Data$dFoldable from "../Data.Foldable/index.js";
|
||||
import * as Data$dFunctor from "../Data.Functor/index.js";
|
||||
import * as Data$dMaybe from "../Data.Maybe/index.js";
|
||||
import * as Data$dOrd from "../Data.Ord/index.js";
|
||||
import * as Data$dSemigroup from "../Data.Semigroup/index.js";
|
||||
import * as Data$dTraversable from "../Data.Traversable/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import {
|
||||
_deleteAt,
|
||||
_insertAt,
|
||||
_updateAt,
|
||||
all,
|
||||
any,
|
||||
concat,
|
||||
filter,
|
||||
findIndexImpl,
|
||||
findLastIndexImpl,
|
||||
findMapImpl,
|
||||
fromFoldableImpl,
|
||||
indexImpl,
|
||||
length,
|
||||
partition,
|
||||
range,
|
||||
replicate,
|
||||
reverse,
|
||||
scanl,
|
||||
scanr,
|
||||
slice,
|
||||
sortByImpl,
|
||||
unconsImpl,
|
||||
unsafeIndexImpl,
|
||||
zipWith
|
||||
} from "./foreign.js";
|
||||
const traverse_ = /* #__PURE__ */ Data$dFoldable.traverse_(Control$dMonad$dST$dInternal.applicativeST);
|
||||
const intercalate1 = dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
return sep => xs => Data$dFoldable.foldlArray(v => v1 => {
|
||||
if (v.init) { return {init: false, acc: v1}; }
|
||||
return {init: false, acc: append(v.acc)(append(sep)(v1))};
|
||||
})({init: true, acc: dictMonoid.mempty})(xs).acc;
|
||||
};
|
||||
const zipWithA = dictApplicative => {
|
||||
const sequence1 = Data$dTraversable.traversableArray.traverse(dictApplicative)(Data$dTraversable.identity);
|
||||
return f => xs => ys => sequence1(zipWith(f)(xs)(ys));
|
||||
};
|
||||
const zip = /* #__PURE__ */ zipWith(Data$dTuple.Tuple);
|
||||
const updateAtIndices = dictFoldable => {
|
||||
const traverse_1 = traverse_(dictFoldable);
|
||||
return us => xs => Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(res => traverse_1(v => Data$dArray$dST.poke(v._1)(v._2)(res))(us))(xs));
|
||||
};
|
||||
const updateAt = /* #__PURE__ */ _updateAt(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const unsafeIndex = () => unsafeIndexImpl;
|
||||
const uncons = /* #__PURE__ */ unconsImpl(v => Data$dMaybe.Nothing)(x => xs => Data$dMaybe.$Maybe("Just", {head: x, tail: xs}));
|
||||
const toUnfoldable = dictUnfoldable => xs => {
|
||||
const len = xs.length;
|
||||
return dictUnfoldable.unfoldr(i => {
|
||||
if (i < len) { return Data$dMaybe.$Maybe("Just", Data$dTuple.$Tuple(xs[i], i + 1 | 0)); }
|
||||
return Data$dMaybe.Nothing;
|
||||
})(0);
|
||||
};
|
||||
const take = n => xs => {
|
||||
if (n < 1) { return []; }
|
||||
return slice(0)(n)(xs);
|
||||
};
|
||||
const tail = /* #__PURE__ */ unconsImpl(v => Data$dMaybe.Nothing)(v => xs => Data$dMaybe.$Maybe("Just", xs));
|
||||
const splitAt = v => v1 => {
|
||||
if (v <= 0) { return {before: [], after: v1}; }
|
||||
return {before: slice(0)(v)(v1), after: slice(v)(v1.length)(v1)};
|
||||
};
|
||||
const sortBy = comp => sortByImpl(comp)(v => {
|
||||
if (v.tag === "GT") { return 1; }
|
||||
if (v.tag === "EQ") { return 0; }
|
||||
if (v.tag === "LT") { return -1; }
|
||||
$runtime.fail();
|
||||
});
|
||||
const sortWith = dictOrd => f => sortBy(x => y => dictOrd.compare(f(x))(f(y)));
|
||||
const sort = dictOrd => xs => sortBy(dictOrd.compare)(xs);
|
||||
const snoc = xs => x => Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(Data$dArray$dST.pushAll([x]))(xs));
|
||||
const singleton = a => [a];
|
||||
const $$null = xs => xs.length === 0;
|
||||
const nubByEq = eq2 => xs => Control$dMonad$dST$dInternal.run(() => {
|
||||
const arr = Data$dArray$dST.new();
|
||||
Control$dMonad$dST$dInternal.foreach(xs)(x => {
|
||||
const $4 = any(v => eq2(v)(x));
|
||||
return () => {
|
||||
const $5 = Data$dArray$dST.unsafeFreeze(arr)();
|
||||
if (!$4($5)) {
|
||||
Data$dArray$dST.pushAll([x])(arr)();
|
||||
return Data$dUnit.unit;
|
||||
}
|
||||
return Data$dUnit.unit;
|
||||
};
|
||||
})();
|
||||
return Data$dArray$dST.unsafeFreeze(arr)();
|
||||
});
|
||||
const nubEq = dictEq => nubByEq(dictEq.eq);
|
||||
const modifyAtIndices = dictFoldable => {
|
||||
const traverse_1 = traverse_(dictFoldable);
|
||||
return is => f => xs => Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(res => traverse_1(i => Data$dArray$dST.modify(i)(f)(res))(is))(xs));
|
||||
};
|
||||
const mapWithIndex = f => xs => zipWith(f)(range(0)(xs.length - 1 | 0))(xs);
|
||||
const intersperse = a => arr => {
|
||||
const v = arr.length;
|
||||
if (v < 2) { return arr; }
|
||||
return Control$dMonad$dST$dInternal.run(Control$dMonad$dST$dInternal.bind_(() => {
|
||||
const out = Data$dArray$dST.new();
|
||||
Data$dArray$dST.pushAll([arr[0]])(out)();
|
||||
Control$dMonad$dST$dInternal.for(1)(v)(idx => {
|
||||
const $6 = Data$dArray$dST.pushAll([a])(out);
|
||||
return () => {
|
||||
$6();
|
||||
Data$dArray$dST.pushAll([arr[idx]])(out)();
|
||||
return Data$dUnit.unit;
|
||||
};
|
||||
})();
|
||||
return out;
|
||||
})(Data$dArray$dST.unsafeFreeze));
|
||||
};
|
||||
const intercalate = dictMonoid => intercalate1(dictMonoid);
|
||||
const insertAt = /* #__PURE__ */ _insertAt(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const init = xs => {
|
||||
if (xs.length === 0) { return Data$dMaybe.Nothing; }
|
||||
return Data$dMaybe.$Maybe("Just", slice(0)(xs.length - 1 | 0)(xs));
|
||||
};
|
||||
const index = /* #__PURE__ */ indexImpl(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const last = xs => index(xs)(xs.length - 1 | 0);
|
||||
const unsnoc = xs => Data$dMaybe.applyMaybe.apply((() => {
|
||||
const $1 = init(xs);
|
||||
if ($1.tag === "Just") { return Data$dMaybe.$Maybe("Just", v1 => ({init: $1._1, last: v1})); }
|
||||
return Data$dMaybe.Nothing;
|
||||
})())(index(xs)(xs.length - 1 | 0));
|
||||
const modifyAt = i => f => xs => {
|
||||
const $3 = index(xs)(i);
|
||||
if ($3.tag === "Nothing") { return Data$dMaybe.Nothing; }
|
||||
if ($3.tag === "Just") { return updateAt(i)(f($3._1))(xs); }
|
||||
$runtime.fail();
|
||||
};
|
||||
const span = p => arr => {
|
||||
const go = go$a0$copy => {
|
||||
let go$a0 = go$a0$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const i = go$a0;
|
||||
const v = index(arr)(i);
|
||||
if (v.tag === "Just") {
|
||||
if (p(v._1)) {
|
||||
go$a0 = i + 1 | 0;
|
||||
continue;
|
||||
}
|
||||
go$c = false;
|
||||
go$r = Data$dMaybe.$Maybe("Just", i);
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Nothing") {
|
||||
go$c = false;
|
||||
go$r = Data$dMaybe.Nothing;
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
const breakIndex = go(0);
|
||||
if (breakIndex.tag === "Just") {
|
||||
if (breakIndex._1 === 0) { return {init: [], rest: arr}; }
|
||||
return {init: slice(0)(breakIndex._1)(arr), rest: slice(breakIndex._1)(arr.length)(arr)};
|
||||
}
|
||||
if (breakIndex.tag === "Nothing") { return {init: arr, rest: []}; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const takeWhile = p => xs => span(p)(xs).init;
|
||||
const unzip = xs => Control$dMonad$dST$dInternal.run(() => {
|
||||
const fsts = Data$dArray$dST.new();
|
||||
const snds = Data$dArray$dST.new();
|
||||
const $3 = {value: 0};
|
||||
Data$dArray$dST$dIterator.iterate(Data$dArray$dST$dIterator.$Iterator(v => index(xs)(v), $3))(v => () => {
|
||||
Data$dArray$dST.pushAll([v._1])(fsts)();
|
||||
Data$dArray$dST.pushAll([v._2])(snds)();
|
||||
return Data$dUnit.unit;
|
||||
})();
|
||||
const fsts$p = Data$dArray$dST.unsafeFreeze(fsts)();
|
||||
const snds$p = Data$dArray$dST.unsafeFreeze(snds)();
|
||||
return Data$dTuple.$Tuple(fsts$p, snds$p);
|
||||
});
|
||||
const head = xs => index(xs)(0);
|
||||
const nubBy = comp => xs => {
|
||||
const indexedAndSorted = sortBy(x => y => comp(x._2)(y._2))(zipWith(Data$dTuple.Tuple)(range(0)(xs.length - 1 | 0))(xs));
|
||||
const v = index(indexedAndSorted)(0);
|
||||
if (v.tag === "Nothing") { return []; }
|
||||
if (v.tag === "Just") {
|
||||
return Data$dFunctor.arrayMap(Data$dTuple.snd)(sortWith(Data$dOrd.ordInt)(Data$dTuple.fst)(Control$dMonad$dST$dInternal.run((() => {
|
||||
const $4 = Data$dArray$dST.unsafeThaw([v._1]);
|
||||
return () => {
|
||||
const result = $4();
|
||||
Control$dMonad$dST$dInternal.foreach(indexedAndSorted)(v1 => () => {
|
||||
const $7 = Data$dArray$dST.unsafeFreeze(result)();
|
||||
const $8 = index($7)($7.length - 1 | 0);
|
||||
const $9 = comp((() => {
|
||||
if ($8.tag === "Just") { return $8._1._2; }
|
||||
$runtime.fail();
|
||||
})())(v1._2);
|
||||
if ($9.tag === "LT" || ($9.tag === "GT" || !($9.tag === "EQ"))) {
|
||||
Data$dArray$dST.pushAll([v1])(result)();
|
||||
return Data$dUnit.unit;
|
||||
}
|
||||
return Data$dUnit.unit;
|
||||
})();
|
||||
return Data$dArray$dST.unsafeFreeze(result)();
|
||||
};
|
||||
})())));
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
const nub = dictOrd => nubBy(dictOrd.compare);
|
||||
const groupBy = op => xs => Control$dMonad$dST$dInternal.run(() => {
|
||||
const result = Data$dArray$dST.new();
|
||||
const $3 = {value: 0};
|
||||
const iter = Data$dArray$dST$dIterator.$Iterator(v => index(xs)(v), $3);
|
||||
Data$dArray$dST$dIterator.iterate(iter)(x => () => {
|
||||
const sub1 = Data$dArray$dST.new();
|
||||
Data$dArray$dST.pushAll([x])(sub1)();
|
||||
Data$dArray$dST$dIterator.pushWhile(op(x))(iter)(sub1)();
|
||||
const grp = Data$dArray$dST.unsafeFreeze(sub1)();
|
||||
Data$dArray$dST.pushAll([grp])(result)();
|
||||
return Data$dUnit.unit;
|
||||
})();
|
||||
return Data$dArray$dST.unsafeFreeze(result)();
|
||||
});
|
||||
const groupAllBy = cmp => {
|
||||
const $1 = groupBy(x => y => cmp(x)(y).tag === "EQ");
|
||||
const $2 = sortBy(cmp);
|
||||
return x => $1($2(x));
|
||||
};
|
||||
const groupAll = dictOrd => groupAllBy(dictOrd.compare);
|
||||
const group = dictEq => xs => groupBy(dictEq.eq)(xs);
|
||||
const fromFoldable = dictFoldable => fromFoldableImpl(dictFoldable.foldr);
|
||||
const foldr = Data$dFoldable.foldrArray;
|
||||
const foldl = Data$dFoldable.foldlArray;
|
||||
const transpose = xs => {
|
||||
const go = go$a0$copy => go$a1$copy => {
|
||||
let go$a0 = go$a0$copy, go$a1 = go$a1$copy, go$c = true, go$r;
|
||||
while (go$c) {
|
||||
const idx = go$a0, allArrays = go$a1;
|
||||
const v = Data$dFoldable.foldlArray(acc => nextArr => {
|
||||
const $6 = index(nextArr)(idx);
|
||||
if ($6.tag === "Nothing") { return acc; }
|
||||
if ($6.tag === "Just") {
|
||||
return Data$dMaybe.$Maybe(
|
||||
"Just",
|
||||
(() => {
|
||||
if (acc.tag === "Nothing") { return [$6._1]; }
|
||||
if (acc.tag === "Just") { return Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(Data$dArray$dST.pushAll([$6._1]))(acc._1)); }
|
||||
$runtime.fail();
|
||||
})()
|
||||
);
|
||||
}
|
||||
$runtime.fail();
|
||||
})(Data$dMaybe.Nothing)(xs);
|
||||
if (v.tag === "Nothing") {
|
||||
go$c = false;
|
||||
go$r = allArrays;
|
||||
continue;
|
||||
}
|
||||
if (v.tag === "Just") {
|
||||
go$a0 = idx + 1 | 0;
|
||||
go$a1 = Control$dMonad$dST$dInternal.run(Data$dArray$dST.withArray(Data$dArray$dST.pushAll([v._1]))(allArrays));
|
||||
continue;
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
return go$r;
|
||||
};
|
||||
return go(0)([]);
|
||||
};
|
||||
const foldRecM = dictMonadRec => {
|
||||
const Monad0 = dictMonadRec.Monad0();
|
||||
const pure1 = Monad0.Applicative0().pure;
|
||||
const bind1 = Monad0.Bind1().bind;
|
||||
return f => b => array => dictMonadRec.tailRecM(o => {
|
||||
if (o.b >= array.length) { return pure1(Control$dMonad$dRec$dClass.$Step("Done", o.a)); }
|
||||
return bind1(f(o.a)(array[o.b]))(res$p => pure1(Control$dMonad$dRec$dClass.$Step("Loop", {a: res$p, b: o.b + 1 | 0})));
|
||||
})({a: b, b: 0});
|
||||
};
|
||||
const foldMap = dictMonoid => Data$dFoldable.foldableArray.foldMap(dictMonoid);
|
||||
const foldM = dictMonad => {
|
||||
const pure1 = dictMonad.Applicative0().pure;
|
||||
const bind1 = dictMonad.Bind1().bind;
|
||||
return f => b => unconsImpl(v => pure1(b))(a => as => bind1(f(b)(a))(b$p => foldM(dictMonad)(f)(b$p)(as)));
|
||||
};
|
||||
const fold = dictMonoid => Data$dFoldable.foldableArray.foldMap(dictMonoid)(Data$dFoldable.identity);
|
||||
const findMap = /* #__PURE__ */ findMapImpl(Data$dMaybe.Nothing)(Data$dMaybe.isJust);
|
||||
const findLastIndex = /* #__PURE__ */ findLastIndexImpl(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const insertBy = cmp => x => ys => {
|
||||
const $3 = insertAt((() => {
|
||||
const $3 = findLastIndex(y => cmp(x)(y).tag === "GT")(ys);
|
||||
if ($3.tag === "Nothing") { return 0; }
|
||||
if ($3.tag === "Just") { return $3._1 + 1 | 0; }
|
||||
$runtime.fail();
|
||||
})())(x)(ys);
|
||||
if ($3.tag === "Just") { return $3._1; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const insert = dictOrd => insertBy(dictOrd.compare);
|
||||
const findIndex = /* #__PURE__ */ findIndexImpl(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const intersectBy = eq2 => xs => ys => filter(x => {
|
||||
const $4 = findIndex(eq2(x))(ys);
|
||||
if ($4.tag === "Nothing") { return false; }
|
||||
if ($4.tag === "Just") { return true; }
|
||||
$runtime.fail();
|
||||
})(xs);
|
||||
const intersect = dictEq => intersectBy(dictEq.eq);
|
||||
const find = f => xs => {
|
||||
const $2 = findIndex(f)(xs);
|
||||
if ($2.tag === "Just") { return Data$dMaybe.$Maybe("Just", xs[$2._1]); }
|
||||
return Data$dMaybe.Nothing;
|
||||
};
|
||||
const elemLastIndex = dictEq => x => findLastIndex(v => dictEq.eq(v)(x));
|
||||
const elemIndex = dictEq => x => findIndex(v => dictEq.eq(v)(x));
|
||||
const notElem = dictEq => a => arr => {
|
||||
const $3 = findIndex(v => dictEq.eq(v)(a))(arr);
|
||||
if ($3.tag === "Nothing") { return true; }
|
||||
if ($3.tag === "Just") { return false; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const elem = dictEq => a => arr => {
|
||||
const $3 = findIndex(v => dictEq.eq(v)(a))(arr);
|
||||
if ($3.tag === "Nothing") { return false; }
|
||||
if ($3.tag === "Just") { return true; }
|
||||
$runtime.fail();
|
||||
};
|
||||
const dropWhile = p => xs => span(p)(xs).rest;
|
||||
const dropEnd = n => xs => {
|
||||
const $2 = xs.length - n | 0;
|
||||
if ($2 < 1) { return []; }
|
||||
return slice(0)($2)(xs);
|
||||
};
|
||||
const drop = n => xs => {
|
||||
if (n < 1) { return xs; }
|
||||
return slice(n)(xs.length)(xs);
|
||||
};
|
||||
const takeEnd = n => xs => {
|
||||
const $2 = xs.length - n | 0;
|
||||
if ($2 < 1) { return xs; }
|
||||
return slice($2)(xs.length)(xs);
|
||||
};
|
||||
const deleteAt = /* #__PURE__ */ _deleteAt(Data$dMaybe.Just)(Data$dMaybe.Nothing);
|
||||
const deleteBy = v => v1 => v2 => {
|
||||
if (v2.length === 0) { return []; }
|
||||
const $3 = findIndex(v(v1))(v2);
|
||||
if ($3.tag === "Nothing") { return v2; }
|
||||
if ($3.tag === "Just") {
|
||||
const $4 = deleteAt($3._1)(v2);
|
||||
if ($4.tag === "Just") { return $4._1; }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
const unionBy = eq2 => xs => ys => Data$dSemigroup.concatArray(xs)(Data$dFoldable.foldlArray(b => a => deleteBy(eq2)(a)(b))(nubByEq(eq2)(ys))(xs));
|
||||
const union = dictEq => unionBy(dictEq.eq);
|
||||
const $$delete = dictEq => deleteBy(dictEq.eq);
|
||||
const difference = dictEq => Data$dFoldable.foldrArray($$delete(dictEq));
|
||||
const cons = x => xs => Data$dSemigroup.concatArray([x])(xs);
|
||||
const some = dictAlternative => {
|
||||
const apply1 = dictAlternative.Applicative0().Apply0().apply;
|
||||
const map3 = dictAlternative.Plus1().Alt0().Functor0().map;
|
||||
return dictLazy => v => apply1(map3(cons)(v))(dictLazy.defer(v1 => many(dictAlternative)(dictLazy)(v)));
|
||||
};
|
||||
const many = dictAlternative => {
|
||||
const alt = dictAlternative.Plus1().Alt0().alt;
|
||||
const pure1 = dictAlternative.Applicative0().pure;
|
||||
return dictLazy => v => alt(some(dictAlternative)(dictLazy)(v))(pure1([]));
|
||||
};
|
||||
const concatMap = b => a => Control$dBind.arrayBind(a)(b);
|
||||
const mapMaybe = f => concatMap(x => {
|
||||
const $2 = f(x);
|
||||
if ($2.tag === "Nothing") { return []; }
|
||||
if ($2.tag === "Just") { return [$2._1]; }
|
||||
$runtime.fail();
|
||||
});
|
||||
const filterA = dictApplicative => {
|
||||
const traverse1 = Data$dTraversable.traversableArray.traverse(dictApplicative);
|
||||
const map3 = dictApplicative.Apply0().Functor0().map;
|
||||
return p => {
|
||||
const $4 = traverse1(x => map3(Data$dTuple.Tuple(x))(p(x)));
|
||||
const $5 = map3(mapMaybe(v => {
|
||||
if (v._2) { return Data$dMaybe.$Maybe("Just", v._1); }
|
||||
return Data$dMaybe.Nothing;
|
||||
}));
|
||||
return x => $5($4(x));
|
||||
};
|
||||
};
|
||||
const catMaybes = /* #__PURE__ */ mapMaybe(x => x);
|
||||
const alterAt = i => f => xs => {
|
||||
const $3 = index(xs)(i);
|
||||
if ($3.tag === "Nothing") { return Data$dMaybe.Nothing; }
|
||||
if ($3.tag === "Just") {
|
||||
const v = f($3._1);
|
||||
if (v.tag === "Nothing") { return deleteAt(i)(xs); }
|
||||
if (v.tag === "Just") { return updateAt(i)(v._1)(xs); }
|
||||
$runtime.fail();
|
||||
}
|
||||
$runtime.fail();
|
||||
};
|
||||
export {
|
||||
alterAt,
|
||||
catMaybes,
|
||||
concatMap,
|
||||
cons,
|
||||
$$delete as delete,
|
||||
deleteAt,
|
||||
deleteBy,
|
||||
difference,
|
||||
drop,
|
||||
dropEnd,
|
||||
dropWhile,
|
||||
elem,
|
||||
elemIndex,
|
||||
elemLastIndex,
|
||||
filterA,
|
||||
find,
|
||||
findIndex,
|
||||
findLastIndex,
|
||||
findMap,
|
||||
fold,
|
||||
foldM,
|
||||
foldMap,
|
||||
foldRecM,
|
||||
foldl,
|
||||
foldr,
|
||||
fromFoldable,
|
||||
group,
|
||||
groupAll,
|
||||
groupAllBy,
|
||||
groupBy,
|
||||
head,
|
||||
index,
|
||||
init,
|
||||
insert,
|
||||
insertAt,
|
||||
insertBy,
|
||||
intercalate,
|
||||
intercalate1,
|
||||
intersect,
|
||||
intersectBy,
|
||||
intersperse,
|
||||
last,
|
||||
many,
|
||||
mapMaybe,
|
||||
mapWithIndex,
|
||||
modifyAt,
|
||||
modifyAtIndices,
|
||||
notElem,
|
||||
nub,
|
||||
nubBy,
|
||||
nubByEq,
|
||||
nubEq,
|
||||
$$null as null,
|
||||
singleton,
|
||||
snoc,
|
||||
some,
|
||||
sort,
|
||||
sortBy,
|
||||
sortWith,
|
||||
span,
|
||||
splitAt,
|
||||
tail,
|
||||
take,
|
||||
takeEnd,
|
||||
takeWhile,
|
||||
toUnfoldable,
|
||||
transpose,
|
||||
traverse_,
|
||||
uncons,
|
||||
union,
|
||||
unionBy,
|
||||
unsafeIndex,
|
||||
unsnoc,
|
||||
unzip,
|
||||
updateAt,
|
||||
updateAtIndices,
|
||||
zip,
|
||||
zipWithA
|
||||
};
|
||||
export * from "./foreign.js";
|
@ -0,0 +1,2 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
export {};
|
158
.storybook/purescript-indexer/output-es/Data.Bifoldable/index.js
Normal file
158
.storybook/purescript-indexer/output-es/Data.Bifoldable/index.js
Normal file
@ -0,0 +1,158 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Control$dApply from "../Control.Apply/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
const identity = x => x;
|
||||
const monoidEndo = /* #__PURE__ */ (() => {
|
||||
const semigroupEndo1 = {append: v => v1 => x => v(v1(x))};
|
||||
return {mempty: x => x, Semigroup0: () => semigroupEndo1};
|
||||
})();
|
||||
const monoidDual = /* #__PURE__ */ (() => {
|
||||
const $0 = monoidEndo.Semigroup0();
|
||||
const semigroupDual1 = {append: v => v1 => $0.append(v1)(v)};
|
||||
return {mempty: monoidEndo.mempty, Semigroup0: () => semigroupDual1};
|
||||
})();
|
||||
const bifoldr = dict => dict.bifoldr;
|
||||
const bitraverse_ = dictBifoldable => dictApplicative => {
|
||||
const $2 = dictApplicative.Apply0();
|
||||
const map = $2.Functor0().map;
|
||||
return f => g => dictBifoldable.bifoldr(x => {
|
||||
const $7 = f(x);
|
||||
return b => $2.apply(map(v => Control$dApply.identity)($7))(b);
|
||||
})(x => {
|
||||
const $7 = g(x);
|
||||
return b => $2.apply(map(v => Control$dApply.identity)($7))(b);
|
||||
})(dictApplicative.pure(Data$dUnit.unit));
|
||||
};
|
||||
const bifor_ = dictBifoldable => dictApplicative => {
|
||||
const bitraverse_2 = bitraverse_(dictBifoldable)(dictApplicative);
|
||||
return t => f => g => bitraverse_2(f)(g)(t);
|
||||
};
|
||||
const bisequence_ = dictBifoldable => dictApplicative => bitraverse_(dictBifoldable)(dictApplicative)(identity)(identity);
|
||||
const bifoldl = dict => dict.bifoldl;
|
||||
const bifoldableTuple = {
|
||||
bifoldMap: dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
return f => g => v => append(f(v._1))(g(v._2));
|
||||
},
|
||||
bifoldr: f => g => z => v => f(v._1)(g(v._2)(z)),
|
||||
bifoldl: f => g => z => v => g(f(z)(v._1))(v._2)
|
||||
};
|
||||
const bifoldableJoker = dictFoldable => (
|
||||
{
|
||||
bifoldr: v => r => u => v1 => dictFoldable.foldr(r)(u)(v1),
|
||||
bifoldl: v => r => u => v1 => dictFoldable.foldl(r)(u)(v1),
|
||||
bifoldMap: dictMonoid => {
|
||||
const foldMap1 = dictFoldable.foldMap(dictMonoid);
|
||||
return v => r => v1 => foldMap1(r)(v1);
|
||||
}
|
||||
}
|
||||
);
|
||||
const bifoldableEither = {
|
||||
bifoldr: v => v1 => v2 => v3 => {
|
||||
if (v3.tag === "Left") { return v(v3._1)(v2); }
|
||||
if (v3.tag === "Right") { return v1(v3._1)(v2); }
|
||||
$runtime.fail();
|
||||
},
|
||||
bifoldl: v => v1 => v2 => v3 => {
|
||||
if (v3.tag === "Left") { return v(v2)(v3._1); }
|
||||
if (v3.tag === "Right") { return v1(v2)(v3._1); }
|
||||
$runtime.fail();
|
||||
},
|
||||
bifoldMap: dictMonoid => v => v1 => v2 => {
|
||||
if (v2.tag === "Left") { return v(v2._1); }
|
||||
if (v2.tag === "Right") { return v1(v2._1); }
|
||||
$runtime.fail();
|
||||
}
|
||||
};
|
||||
const bifoldableConst = {bifoldr: f => v => z => v1 => f(v1)(z), bifoldl: f => v => z => v1 => f(z)(v1), bifoldMap: dictMonoid => f => v => v1 => f(v1)};
|
||||
const bifoldableClown = dictFoldable => (
|
||||
{
|
||||
bifoldr: l => v => u => v1 => dictFoldable.foldr(l)(u)(v1),
|
||||
bifoldl: l => v => u => v1 => dictFoldable.foldl(l)(u)(v1),
|
||||
bifoldMap: dictMonoid => {
|
||||
const foldMap1 = dictFoldable.foldMap(dictMonoid);
|
||||
return l => v => v1 => foldMap1(l)(v1);
|
||||
}
|
||||
}
|
||||
);
|
||||
const bifoldMapDefaultR = dictBifoldable => dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
return f => g => dictBifoldable.bifoldr(x => append(f(x)))(x => append(g(x)))(dictMonoid.mempty);
|
||||
};
|
||||
const bifoldMapDefaultL = dictBifoldable => dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
return f => g => dictBifoldable.bifoldl(m => a => append(m)(f(a)))(m => b => append(m)(g(b)))(dictMonoid.mempty);
|
||||
};
|
||||
const bifoldMap = dict => dict.bifoldMap;
|
||||
const bifoldableFlip = dictBifoldable => (
|
||||
{
|
||||
bifoldr: r => l => u => v => dictBifoldable.bifoldr(l)(r)(u)(v),
|
||||
bifoldl: r => l => u => v => dictBifoldable.bifoldl(l)(r)(u)(v),
|
||||
bifoldMap: dictMonoid => {
|
||||
const bifoldMap2 = dictBifoldable.bifoldMap(dictMonoid);
|
||||
return r => l => v => bifoldMap2(l)(r)(v);
|
||||
}
|
||||
}
|
||||
);
|
||||
const bifoldlDefault = dictBifoldable => {
|
||||
const bifoldMap1 = dictBifoldable.bifoldMap(monoidDual);
|
||||
return f => g => z => p => bifoldMap1(x => a => f(a)(x))(x => a => g(a)(x))(p)(z);
|
||||
};
|
||||
const bifoldrDefault = dictBifoldable => {
|
||||
const bifoldMap1 = dictBifoldable.bifoldMap(monoidEndo);
|
||||
return f => g => z => p => bifoldMap1(x => f(x))(x => g(x))(p)(z);
|
||||
};
|
||||
const bifoldableProduct2 = dictBifoldable => dictBifoldable1 => (
|
||||
{
|
||||
bifoldr: l => r => u => m => bifoldrDefault(bifoldableProduct2(dictBifoldable)(dictBifoldable1))(l)(r)(u)(m),
|
||||
bifoldl: l => r => u => m => bifoldlDefault(bifoldableProduct2(dictBifoldable)(dictBifoldable1))(l)(r)(u)(m),
|
||||
bifoldMap: dictMonoid => {
|
||||
const append = dictMonoid.Semigroup0().append;
|
||||
const bifoldMap3 = dictBifoldable.bifoldMap(dictMonoid);
|
||||
const bifoldMap4 = dictBifoldable1.bifoldMap(dictMonoid);
|
||||
return l => r => v => append(bifoldMap3(l)(r)(v._1))(bifoldMap4(l)(r)(v._2));
|
||||
}
|
||||
}
|
||||
);
|
||||
const bifold = dictBifoldable => dictMonoid => dictBifoldable.bifoldMap(dictMonoid)(identity)(identity);
|
||||
const biany = dictBifoldable => dictBooleanAlgebra => {
|
||||
const bifoldMap2 = dictBifoldable.bifoldMap((() => {
|
||||
const $2 = dictBooleanAlgebra.HeytingAlgebra0();
|
||||
const semigroupDisj1 = {append: v => v1 => $2.disj(v)(v1)};
|
||||
return {mempty: $2.ff, Semigroup0: () => semigroupDisj1};
|
||||
})());
|
||||
return p => q => bifoldMap2(x => p(x))(x => q(x));
|
||||
};
|
||||
const biall = dictBifoldable => dictBooleanAlgebra => {
|
||||
const bifoldMap2 = dictBifoldable.bifoldMap((() => {
|
||||
const $2 = dictBooleanAlgebra.HeytingAlgebra0();
|
||||
const semigroupConj1 = {append: v => v1 => $2.conj(v)(v1)};
|
||||
return {mempty: $2.tt, Semigroup0: () => semigroupConj1};
|
||||
})());
|
||||
return p => q => bifoldMap2(x => p(x))(x => q(x));
|
||||
};
|
||||
export {
|
||||
biall,
|
||||
biany,
|
||||
bifold,
|
||||
bifoldMap,
|
||||
bifoldMapDefaultL,
|
||||
bifoldMapDefaultR,
|
||||
bifoldableClown,
|
||||
bifoldableConst,
|
||||
bifoldableEither,
|
||||
bifoldableFlip,
|
||||
bifoldableJoker,
|
||||
bifoldableProduct2,
|
||||
bifoldableTuple,
|
||||
bifoldl,
|
||||
bifoldlDefault,
|
||||
bifoldr,
|
||||
bifoldrDefault,
|
||||
bifor_,
|
||||
bisequence_,
|
||||
bitraverse_,
|
||||
identity,
|
||||
monoidDual,
|
||||
monoidEndo
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
const Join = x => x;
|
||||
const showJoin = dictShow => ({show: v => "(Join " + (dictShow.show(v) + ")")});
|
||||
const ordJoin = dictOrd => dictOrd;
|
||||
const newtypeJoin = {Coercible0: () => undefined};
|
||||
const eqJoin = dictEq => dictEq;
|
||||
const bifunctorJoin = dictBifunctor => ({map: f => v => dictBifunctor.bimap(f)(f)(v)});
|
||||
const biapplyJoin = dictBiapply => {
|
||||
const $1 = dictBiapply.Bifunctor0();
|
||||
const bifunctorJoin1 = {map: f => v => $1.bimap(f)(f)(v)};
|
||||
return {apply: v => v1 => dictBiapply.biapply(v)(v1), Functor0: () => bifunctorJoin1};
|
||||
};
|
||||
const biapplicativeJoin = dictBiapplicative => {
|
||||
const $1 = dictBiapplicative.Biapply0();
|
||||
const $2 = $1.Bifunctor0();
|
||||
const bifunctorJoin1 = {map: f => v => $2.bimap(f)(f)(v)};
|
||||
const biapplyJoin1 = {apply: v => v1 => $1.biapply(v)(v1), Functor0: () => bifunctorJoin1};
|
||||
return {pure: a => dictBiapplicative.bipure(a)(a), Apply0: () => biapplyJoin1};
|
||||
};
|
||||
export {Join, biapplicativeJoin, biapplyJoin, bifunctorJoin, eqJoin, newtypeJoin, ordJoin, showJoin};
|
@ -0,0 +1,17 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const identity = x => x;
|
||||
const bimap = dict => dict.bimap;
|
||||
const lmap = dictBifunctor => f => dictBifunctor.bimap(f)(identity);
|
||||
const rmap = dictBifunctor => dictBifunctor.bimap(identity);
|
||||
const bifunctorTuple = {bimap: f => g => v => Data$dTuple.$Tuple(f(v._1), g(v._2))};
|
||||
const bifunctorEither = {
|
||||
bimap: v => v1 => v2 => {
|
||||
if (v2.tag === "Left") { return Data$dEither.$Either("Left", v(v2._1)); }
|
||||
if (v2.tag === "Right") { return Data$dEither.$Either("Right", v1(v2._1)); }
|
||||
$runtime.fail();
|
||||
}
|
||||
};
|
||||
const bifunctorConst = {bimap: f => v => v1 => f(v1)};
|
||||
export {bifunctorConst, bifunctorEither, bifunctorTuple, bimap, identity, lmap, rmap};
|
@ -0,0 +1,210 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dBifoldable from "../Data.Bifoldable/index.js";
|
||||
import * as Data$dBifunctor from "../Data.Bifunctor/index.js";
|
||||
import * as Data$dConst from "../Data.Const/index.js";
|
||||
import * as Data$dEither from "../Data.Either/index.js";
|
||||
import * as Data$dFunctor$dClown from "../Data.Functor.Clown/index.js";
|
||||
import * as Data$dFunctor$dFlip from "../Data.Functor.Flip/index.js";
|
||||
import * as Data$dFunctor$dJoker from "../Data.Functor.Joker/index.js";
|
||||
import * as Data$dFunctor$dProduct2 from "../Data.Functor.Product2/index.js";
|
||||
import * as Data$dTuple from "../Data.Tuple/index.js";
|
||||
const identity = x => x;
|
||||
const bitraverse = dict => dict.bitraverse;
|
||||
const lfor = dictBitraversable => dictApplicative => {
|
||||
const bitraverse2 = dictBitraversable.bitraverse(dictApplicative);
|
||||
return t => f => bitraverse2(f)(dictApplicative.pure)(t);
|
||||
};
|
||||
const ltraverse = dictBitraversable => dictApplicative => {
|
||||
const bitraverse2 = dictBitraversable.bitraverse(dictApplicative);
|
||||
return f => bitraverse2(f)(dictApplicative.pure);
|
||||
};
|
||||
const rfor = dictBitraversable => dictApplicative => {
|
||||
const bitraverse2 = dictBitraversable.bitraverse(dictApplicative);
|
||||
return t => f => bitraverse2(dictApplicative.pure)(f)(t);
|
||||
};
|
||||
const rtraverse = dictBitraversable => dictApplicative => dictBitraversable.bitraverse(dictApplicative)(dictApplicative.pure);
|
||||
const bitraversableTuple = {
|
||||
bitraverse: dictApplicative => {
|
||||
const Apply0 = dictApplicative.Apply0();
|
||||
const map = Apply0.Functor0().map;
|
||||
return f => g => v => Apply0.apply(map(Data$dTuple.Tuple)(f(v._1)))(g(v._2));
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const Apply0 = dictApplicative.Apply0();
|
||||
const map = Apply0.Functor0().map;
|
||||
return v => Apply0.apply(map(Data$dTuple.Tuple)(v._1))(v._2);
|
||||
},
|
||||
Bifunctor0: () => Data$dBifunctor.bifunctorTuple,
|
||||
Bifoldable1: () => Data$dBifoldable.bifoldableTuple
|
||||
};
|
||||
const bitraversableJoker = dictTraversable => {
|
||||
const $1 = dictTraversable.Functor0();
|
||||
const bifunctorJoker = {bimap: v => g => v1 => $1.map(g)(v1)};
|
||||
const $3 = dictTraversable.Foldable1();
|
||||
const bifoldableJoker = {
|
||||
bifoldr: v => r => u => v1 => $3.foldr(r)(u)(v1),
|
||||
bifoldl: v => r => u => v1 => $3.foldl(r)(u)(v1),
|
||||
bifoldMap: dictMonoid => {
|
||||
const foldMap1 = $3.foldMap(dictMonoid);
|
||||
return v => r => v1 => foldMap1(r)(v1);
|
||||
}
|
||||
};
|
||||
return {
|
||||
bitraverse: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
const traverse1 = dictTraversable.traverse(dictApplicative);
|
||||
return v => r => v1 => map(Data$dFunctor$dJoker.Joker)(traverse1(r)(v1));
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
const sequence1 = dictTraversable.sequence(dictApplicative);
|
||||
return v => map(Data$dFunctor$dJoker.Joker)(sequence1(v));
|
||||
},
|
||||
Bifunctor0: () => bifunctorJoker,
|
||||
Bifoldable1: () => bifoldableJoker
|
||||
};
|
||||
};
|
||||
const bitraversableEither = {
|
||||
bitraverse: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
return v => v1 => v2 => {
|
||||
if (v2.tag === "Left") { return map(Data$dEither.Left)(v(v2._1)); }
|
||||
if (v2.tag === "Right") { return map(Data$dEither.Right)(v1(v2._1)); }
|
||||
$runtime.fail();
|
||||
};
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
return v => {
|
||||
if (v.tag === "Left") { return map(Data$dEither.Left)(v._1); }
|
||||
if (v.tag === "Right") { return map(Data$dEither.Right)(v._1); }
|
||||
$runtime.fail();
|
||||
};
|
||||
},
|
||||
Bifunctor0: () => Data$dBifunctor.bifunctorEither,
|
||||
Bifoldable1: () => Data$dBifoldable.bifoldableEither
|
||||
};
|
||||
const bitraversableConst = {
|
||||
bitraverse: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
return f => v => v1 => map(Data$dConst.Const)(f(v1));
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
return v => map(Data$dConst.Const)(v);
|
||||
},
|
||||
Bifunctor0: () => Data$dBifunctor.bifunctorConst,
|
||||
Bifoldable1: () => Data$dBifoldable.bifoldableConst
|
||||
};
|
||||
const bitraversableClown = dictTraversable => {
|
||||
const $1 = dictTraversable.Functor0();
|
||||
const bifunctorClown = {bimap: f => v => v1 => $1.map(f)(v1)};
|
||||
const $3 = dictTraversable.Foldable1();
|
||||
const bifoldableClown = {
|
||||
bifoldr: l => v => u => v1 => $3.foldr(l)(u)(v1),
|
||||
bifoldl: l => v => u => v1 => $3.foldl(l)(u)(v1),
|
||||
bifoldMap: dictMonoid => {
|
||||
const foldMap1 = $3.foldMap(dictMonoid);
|
||||
return l => v => v1 => foldMap1(l)(v1);
|
||||
}
|
||||
};
|
||||
return {
|
||||
bitraverse: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
const traverse1 = dictTraversable.traverse(dictApplicative);
|
||||
return l => v => v1 => map(Data$dFunctor$dClown.Clown)(traverse1(l)(v1));
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
const sequence1 = dictTraversable.sequence(dictApplicative);
|
||||
return v => map(Data$dFunctor$dClown.Clown)(sequence1(v));
|
||||
},
|
||||
Bifunctor0: () => bifunctorClown,
|
||||
Bifoldable1: () => bifoldableClown
|
||||
};
|
||||
};
|
||||
const bisequenceDefault = dictBitraversable => dictApplicative => dictBitraversable.bitraverse(dictApplicative)(identity)(identity);
|
||||
const bisequence = dict => dict.bisequence;
|
||||
const bitraversableFlip = dictBitraversable => {
|
||||
const $1 = dictBitraversable.Bifunctor0();
|
||||
const bifunctorFlip = {bimap: f => g => v => $1.bimap(g)(f)(v)};
|
||||
const $3 = dictBitraversable.Bifoldable1();
|
||||
const bifoldableFlip = {
|
||||
bifoldr: r => l => u => v => $3.bifoldr(l)(r)(u)(v),
|
||||
bifoldl: r => l => u => v => $3.bifoldl(l)(r)(u)(v),
|
||||
bifoldMap: dictMonoid => {
|
||||
const bifoldMap2 = $3.bifoldMap(dictMonoid);
|
||||
return r => l => v => bifoldMap2(l)(r)(v);
|
||||
}
|
||||
};
|
||||
return {
|
||||
bitraverse: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
const bitraverse2 = dictBitraversable.bitraverse(dictApplicative);
|
||||
return r => l => v => map(Data$dFunctor$dFlip.Flip)(bitraverse2(l)(r)(v));
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const map = dictApplicative.Apply0().Functor0().map;
|
||||
const bisequence2 = dictBitraversable.bisequence(dictApplicative);
|
||||
return v => map(Data$dFunctor$dFlip.Flip)(bisequence2(v));
|
||||
},
|
||||
Bifunctor0: () => bifunctorFlip,
|
||||
Bifoldable1: () => bifoldableFlip
|
||||
};
|
||||
};
|
||||
const bitraversableProduct2 = dictBitraversable => {
|
||||
const bifunctorProduct2 = Data$dFunctor$dProduct2.bifunctorProduct2(dictBitraversable.Bifunctor0());
|
||||
const bifoldableProduct2 = Data$dBifoldable.bifoldableProduct2(dictBitraversable.Bifoldable1());
|
||||
return dictBitraversable1 => {
|
||||
const bifunctorProduct21 = bifunctorProduct2(dictBitraversable1.Bifunctor0());
|
||||
const bifoldableProduct21 = bifoldableProduct2(dictBitraversable1.Bifoldable1());
|
||||
return {
|
||||
bitraverse: dictApplicative => {
|
||||
const Apply0 = dictApplicative.Apply0();
|
||||
const map = Apply0.Functor0().map;
|
||||
const bitraverse3 = dictBitraversable.bitraverse(dictApplicative);
|
||||
const bitraverse4 = dictBitraversable1.bitraverse(dictApplicative);
|
||||
return l => r => v => Apply0.apply(map(Data$dFunctor$dProduct2.Product2)(bitraverse3(l)(r)(v._1)))(bitraverse4(l)(r)(v._2));
|
||||
},
|
||||
bisequence: dictApplicative => {
|
||||
const Apply0 = dictApplicative.Apply0();
|
||||
const map = Apply0.Functor0().map;
|
||||
const bisequence3 = dictBitraversable.bisequence(dictApplicative);
|
||||
const bisequence4 = dictBitraversable1.bisequence(dictApplicative);
|
||||
return v => Apply0.apply(map(Data$dFunctor$dProduct2.Product2)(bisequence3(v._1)))(bisequence4(v._2));
|
||||
},
|
||||
Bifunctor0: () => bifunctorProduct21,
|
||||
Bifoldable1: () => bifoldableProduct21
|
||||
};
|
||||
};
|
||||
};
|
||||
const bitraverseDefault = dictBitraversable => {
|
||||
const bimap = dictBitraversable.Bifunctor0().bimap;
|
||||
return dictApplicative => {
|
||||
const bisequence2 = dictBitraversable.bisequence(dictApplicative);
|
||||
return f => g => t => bisequence2(bimap(f)(g)(t));
|
||||
};
|
||||
};
|
||||
const bifor = dictBitraversable => dictApplicative => {
|
||||
const bitraverse2 = dictBitraversable.bitraverse(dictApplicative);
|
||||
return t => f => g => bitraverse2(f)(g)(t);
|
||||
};
|
||||
export {
|
||||
bifor,
|
||||
bisequence,
|
||||
bisequenceDefault,
|
||||
bitraversableClown,
|
||||
bitraversableConst,
|
||||
bitraversableEither,
|
||||
bitraversableFlip,
|
||||
bitraversableJoker,
|
||||
bitraversableProduct2,
|
||||
bitraversableTuple,
|
||||
bitraverse,
|
||||
bitraverseDefault,
|
||||
identity,
|
||||
lfor,
|
||||
ltraverse,
|
||||
rfor,
|
||||
rtraverse
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
const otherwise = true;
|
||||
export {otherwise};
|
@ -0,0 +1,39 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dHeytingAlgebra from "../Data.HeytingAlgebra/index.js";
|
||||
import * as Type$dProxy from "../Type.Proxy/index.js";
|
||||
const booleanAlgebraUnit = {HeytingAlgebra0: () => Data$dHeytingAlgebra.heytingAlgebraUnit};
|
||||
const booleanAlgebraRecordNil = {HeytingAlgebraRecord0: () => Data$dHeytingAlgebra.heytingAlgebraRecordNil};
|
||||
const booleanAlgebraRecordCons = dictIsSymbol => () => dictBooleanAlgebraRecord => {
|
||||
const heytingAlgebraRecordCons1 = Data$dHeytingAlgebra.heytingAlgebraRecordCons(dictIsSymbol)()(dictBooleanAlgebraRecord.HeytingAlgebraRecord0());
|
||||
return dictBooleanAlgebra => {
|
||||
const heytingAlgebraRecordCons2 = heytingAlgebraRecordCons1(dictBooleanAlgebra.HeytingAlgebra0());
|
||||
return {HeytingAlgebraRecord0: () => heytingAlgebraRecordCons2};
|
||||
};
|
||||
};
|
||||
const booleanAlgebraRecord = () => dictBooleanAlgebraRecord => {
|
||||
const $2 = dictBooleanAlgebraRecord.HeytingAlgebraRecord0();
|
||||
const heytingAlgebraRecord1 = {
|
||||
ff: $2.ffRecord(Type$dProxy.Proxy)(Type$dProxy.Proxy),
|
||||
tt: $2.ttRecord(Type$dProxy.Proxy)(Type$dProxy.Proxy),
|
||||
conj: $2.conjRecord(Type$dProxy.Proxy),
|
||||
disj: $2.disjRecord(Type$dProxy.Proxy),
|
||||
implies: $2.impliesRecord(Type$dProxy.Proxy),
|
||||
not: $2.notRecord(Type$dProxy.Proxy)
|
||||
};
|
||||
return {HeytingAlgebra0: () => heytingAlgebraRecord1};
|
||||
};
|
||||
const booleanAlgebraProxy = {HeytingAlgebra0: () => Data$dHeytingAlgebra.heytingAlgebraProxy};
|
||||
const booleanAlgebraFn = dictBooleanAlgebra => {
|
||||
const $1 = dictBooleanAlgebra.HeytingAlgebra0();
|
||||
const heytingAlgebraFunction = {
|
||||
ff: v => $1.ff,
|
||||
tt: v => $1.tt,
|
||||
implies: f => g => a => $1.implies(f(a))(g(a)),
|
||||
conj: f => g => a => $1.conj(f(a))(g(a)),
|
||||
disj: f => g => a => $1.disj(f(a))(g(a)),
|
||||
not: f => a => $1.not(f(a))
|
||||
};
|
||||
return {HeytingAlgebra0: () => heytingAlgebraFunction};
|
||||
};
|
||||
const booleanAlgebraBoolean = {HeytingAlgebra0: () => Data$dHeytingAlgebra.heytingAlgebraBoolean};
|
||||
export {booleanAlgebraBoolean, booleanAlgebraFn, booleanAlgebraProxy, booleanAlgebraRecord, booleanAlgebraRecordCons, booleanAlgebraRecordNil, booleanAlgebraUnit};
|
@ -0,0 +1,34 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dGeneric$dRep from "../Data.Generic.Rep/index.js";
|
||||
const genericTopNoArguments = {"genericTop'": Data$dGeneric$dRep.NoArguments};
|
||||
const genericTopArgument = dictBounded => ({"genericTop'": dictBounded.top});
|
||||
const genericTop$p = dict => dict["genericTop'"];
|
||||
const genericTopConstructor = dictGenericTop => ({"genericTop'": dictGenericTop["genericTop'"]});
|
||||
const genericTopProduct = dictGenericTop => dictGenericTop1 => ({"genericTop'": Data$dGeneric$dRep.$Product(dictGenericTop["genericTop'"], dictGenericTop1["genericTop'"])});
|
||||
const genericTopSum = dictGenericTop => ({"genericTop'": Data$dGeneric$dRep.$Sum("Inr", dictGenericTop["genericTop'"])});
|
||||
const genericTop = dictGeneric => dictGenericTop => dictGeneric.to(dictGenericTop["genericTop'"]);
|
||||
const genericBottomNoArguments = {"genericBottom'": Data$dGeneric$dRep.NoArguments};
|
||||
const genericBottomArgument = dictBounded => ({"genericBottom'": dictBounded.bottom});
|
||||
const genericBottom$p = dict => dict["genericBottom'"];
|
||||
const genericBottomConstructor = dictGenericBottom => ({"genericBottom'": dictGenericBottom["genericBottom'"]});
|
||||
const genericBottomProduct = dictGenericBottom => dictGenericBottom1 => (
|
||||
{"genericBottom'": Data$dGeneric$dRep.$Product(dictGenericBottom["genericBottom'"], dictGenericBottom1["genericBottom'"])}
|
||||
);
|
||||
const genericBottomSum = dictGenericBottom => ({"genericBottom'": Data$dGeneric$dRep.$Sum("Inl", dictGenericBottom["genericBottom'"])});
|
||||
const genericBottom = dictGeneric => dictGenericBottom => dictGeneric.to(dictGenericBottom["genericBottom'"]);
|
||||
export {
|
||||
genericBottom,
|
||||
genericBottom$p,
|
||||
genericBottomArgument,
|
||||
genericBottomConstructor,
|
||||
genericBottomNoArguments,
|
||||
genericBottomProduct,
|
||||
genericBottomSum,
|
||||
genericTop,
|
||||
genericTop$p,
|
||||
genericTopArgument,
|
||||
genericTopConstructor,
|
||||
genericTopNoArguments,
|
||||
genericTopProduct,
|
||||
genericTopSum
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
export const topInt = 2147483647;
|
||||
export const bottomInt = -2147483648;
|
||||
|
||||
export const topChar = String.fromCharCode(65535);
|
||||
export const bottomChar = String.fromCharCode(0);
|
||||
|
||||
export const topNumber = Number.POSITIVE_INFINITY;
|
||||
export const bottomNumber = Number.NEGATIVE_INFINITY;
|
@ -0,0 +1,72 @@
|
||||
import * as $runtime from "../runtime.js";
|
||||
import * as Data$dOrd from "../Data.Ord/index.js";
|
||||
import * as Data$dOrdering from "../Data.Ordering/index.js";
|
||||
import * as Data$dUnit from "../Data.Unit/index.js";
|
||||
import * as Record$dUnsafe from "../Record.Unsafe/index.js";
|
||||
import * as Type$dProxy from "../Type.Proxy/index.js";
|
||||
import {bottomChar, bottomInt, bottomNumber, topChar, topInt, topNumber} from "./foreign.js";
|
||||
const topRecord = dict => dict.topRecord;
|
||||
const top = dict => dict.top;
|
||||
const boundedUnit = {top: Data$dUnit.unit, bottom: Data$dUnit.unit, Ord0: () => Data$dOrd.ordUnit};
|
||||
const boundedRecordNil = {topRecord: v => v1 => ({}), bottomRecord: v => v1 => ({}), OrdRecord0: () => Data$dOrd.ordRecordNil};
|
||||
const boundedProxy = {bottom: Type$dProxy.Proxy, top: Type$dProxy.Proxy, Ord0: () => Data$dOrd.ordProxy};
|
||||
const boundedOrdering = {top: Data$dOrdering.GT, bottom: Data$dOrdering.LT, Ord0: () => Data$dOrd.ordOrdering};
|
||||
const boundedNumber = {top: topNumber, bottom: bottomNumber, Ord0: () => Data$dOrd.ordNumber};
|
||||
const boundedInt = {top: 2147483647, bottom: -2147483648, Ord0: () => Data$dOrd.ordInt};
|
||||
const boundedChar = {top: "", bottom: "\u0000", Ord0: () => Data$dOrd.ordChar};
|
||||
const boundedBoolean = {top: true, bottom: false, Ord0: () => Data$dOrd.ordBoolean};
|
||||
const bottomRecord = dict => dict.bottomRecord;
|
||||
const boundedRecord = () => dictBoundedRecord => {
|
||||
const ordRecord1 = Data$dOrd.ordRecord()(dictBoundedRecord.OrdRecord0());
|
||||
return {
|
||||
top: dictBoundedRecord.topRecord(Type$dProxy.Proxy)(Type$dProxy.Proxy),
|
||||
bottom: dictBoundedRecord.bottomRecord(Type$dProxy.Proxy)(Type$dProxy.Proxy),
|
||||
Ord0: () => ordRecord1
|
||||
};
|
||||
};
|
||||
const bottom = dict => dict.bottom;
|
||||
const boundedRecordCons = dictIsSymbol => dictBounded => {
|
||||
const Ord0 = dictBounded.Ord0();
|
||||
return () => () => dictBoundedRecord => {
|
||||
const $6 = dictBoundedRecord.OrdRecord0();
|
||||
const $7 = $6.EqRecord0();
|
||||
const $8 = Ord0.Eq0();
|
||||
const eqRowCons2 = {
|
||||
eqRecord: v => ra => rb => {
|
||||
const $$get = Record$dUnsafe.unsafeGet(dictIsSymbol.reflectSymbol(Type$dProxy.Proxy));
|
||||
return $8.eq($$get(ra))($$get(rb)) && $7.eqRecord(Type$dProxy.Proxy)(ra)(rb);
|
||||
}
|
||||
};
|
||||
const ordRecordCons = {
|
||||
compareRecord: v => ra => rb => {
|
||||
const key = dictIsSymbol.reflectSymbol(Type$dProxy.Proxy);
|
||||
const left = Ord0.compare(Record$dUnsafe.unsafeGet(key)(ra))(Record$dUnsafe.unsafeGet(key)(rb));
|
||||
if (left.tag === "LT" || (left.tag === "GT" || !(left.tag === "EQ"))) { return left; }
|
||||
return $6.compareRecord(Type$dProxy.Proxy)(ra)(rb);
|
||||
},
|
||||
EqRecord0: () => eqRowCons2
|
||||
};
|
||||
return {
|
||||
topRecord: v => rowProxy => Record$dUnsafe.unsafeSet(dictIsSymbol.reflectSymbol(Type$dProxy.Proxy))(dictBounded.top)(dictBoundedRecord.topRecord(Type$dProxy.Proxy)(rowProxy)),
|
||||
bottomRecord: v => rowProxy => Record$dUnsafe.unsafeSet(dictIsSymbol.reflectSymbol(Type$dProxy.Proxy))(dictBounded.bottom)(dictBoundedRecord.bottomRecord(Type$dProxy.Proxy)(rowProxy)),
|
||||
OrdRecord0: () => ordRecordCons
|
||||
};
|
||||
};
|
||||
};
|
||||
export {
|
||||
bottom,
|
||||
bottomRecord,
|
||||
boundedBoolean,
|
||||
boundedChar,
|
||||
boundedInt,
|
||||
boundedNumber,
|
||||
boundedOrdering,
|
||||
boundedProxy,
|
||||
boundedRecord,
|
||||
boundedRecordCons,
|
||||
boundedRecordNil,
|
||||
boundedUnit,
|
||||
top,
|
||||
topRecord
|
||||
};
|
||||
export * from "./foreign.js";
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user