git.iko.soy/purestack-dev/purescript-plum
on master help sign in
Monad construction
2907b12iko
plum/index.js+449−306
@@ -23,9 +23,6 @@
23 }
23 }
24 };
24 };
25
25
26− // output/Data.Boolean/index.js
27− var otherwise = true;
28−
29 // output/Data.Function/index.js
26 // output/Data.Function/index.js
30 var flip = function(f) {
27 var flip = function(f) {
31 return function(b) {
28 return function(b) {
@@ -34,11 +31,6 @@
34 };
31 };
35 };
32 };
36 };
33 };
37− var $$const = function(a) {
38− return function(v) {
39− return a;
40− };
41− };
42
34
43 // output/Data.Functor/foreign.js
35 // output/Data.Functor/foreign.js
44 var arrayMap = function(f) {
36 var arrayMap = function(f) {
@@ -55,6 +47,15 @@
55 // output/Data.Unit/foreign.js
47 // output/Data.Unit/foreign.js
56 var unit = void 0;
48 var unit = void 0;
57
49
50+ // output/Type.Proxy/index.js
51+ var $$Proxy = /* @__PURE__ */ function() {
52+ function $$Proxy2() {
53+ }
54+ ;
55+ $$Proxy2.value = new $$Proxy2();
56+ return $$Proxy2;
57+ }();
58+
58 // output/Data.Functor/index.js
59 // output/Data.Functor/index.js
59 var map = function(dict) {
60 var map = function(dict) {
60 return dict.map;
61 return dict.map;
@@ -82,52 +83,6 @@
82 };
83 };
83 };
84 };
84
85
85− // output/Data.Array/foreign.js
86− var rangeImpl = function(start2, end) {
87− var step2 = start2 > end ? -1 : 1;
88− var result = new Array(step2 * (end - start2) + 1);
89− var i = start2, n = 0;
90− while (i !== end) {
91− result[n++] = i;
92− i += step2;
93− }
94− result[n] = i;
95− return result;
96− };
97− var replicateFill = function(count, value12) {
98− if (count < 1) {
99− return [];
100− }
101− var result = new Array(count);
102− return result.fill(value12);
103− };
104− var replicatePolyfill = function(count, value12) {
105− var result = [];
106− var n = 0;
107− for (var i = 0; i < count; i++) {
108− result[n++] = value12;
109− }
110− return result;
111− };
112− var replicateImpl = typeof Array.prototype.fill === "function" ? replicateFill : replicatePolyfill;
113−
114− // output/Data.Semigroup/foreign.js
115− var concatArray = function(xs) {
116− return function(ys) {
117− if (xs.length === 0) return ys;
118− if (ys.length === 0) return xs;
119− return xs.concat(ys);
120− };
121− };
122−
123− // output/Data.Semigroup/index.js
124− var semigroupArray = {
125− append: concatArray
126− };
127− var append = function(dict) {
128− return dict.append;
129− };
130−
131 // output/Control.Bind/foreign.js
86 // output/Control.Bind/foreign.js
132 var arrayBind = typeof Array.prototype.flatMap === "function" ? function(arr) {
87 var arrayBind = typeof Array.prototype.flatMap === "function" ? function(arr) {
133 return function(f) {
88 return function(f) {
@@ -149,179 +104,178 @@
149 };
104 };
150
105
151 // output/Control.Bind/index.js
106 // output/Control.Bind/index.js
107+ var discard = function(dict) {
108+ return dict.discard;
109+ };
152 var bind = function(dict) {
110 var bind = function(dict) {
153 return dict.bind;
111 return dict.bind;
154 };
112 };
155 var bindFlipped = function(dictBind) {
113 var bindFlipped = function(dictBind) {
156 return flip(bind(dictBind));
114 return flip(bind(dictBind));
157 };
115 };
158−
116+ var discardUnit = {
159− // output/Control.Monad/index.js
117+ discard: function(dictBind) {
160− var ap = function(dictMonad) {
118+ return bind(dictBind);
161− var bind3 = bind(dictMonad.Bind1());
162− var pure3 = pure(dictMonad.Applicative0());
163− return function(f) {
164− return function(a) {
165− return bind3(f)(function(f$prime) {
166− return bind3(a)(function(a$prime) {
167− return pure3(f$prime(a$prime));
168− });
169− });
170− };
171− };
119+ }
172 };
120 };
173
121
174− // output/Data.Bounded/foreign.js
122+ // output/Data.Symbol/index.js
175− var topInt = 2147483647;
123+ var reflectSymbol = function(dict) {
176− var bottomInt = -2147483648;
124+ return dict.reflectSymbol;
177− var topChar = String.fromCharCode(65535);
125+ };
178− var bottomChar = String.fromCharCode(0);
179− var topNumber = Number.POSITIVE_INFINITY;
180− var bottomNumber = Number.NEGATIVE_INFINITY;
181
126
182− // output/Data.Ord/foreign.js
127+ // output/Record.Unsafe/foreign.js
183− var unsafeCompareImpl = function(lt) {
128+ var unsafeGet = function(label4) {
184− return function(eq2) {
129+ return function(rec) {
185− return function(gt) {
130+ return rec[label4];
131+ };
132+ };
133+ var unsafeSet = function(label4) {
186− return function(x) {
134+ return function(value12) {
187− return function(y) {
135+ return function(rec) {
188− return x < y ? lt : x === y ? eq2 : gt;
136+ var copy = {};
137+ for (var key in rec) {
138+ if ({}.hasOwnProperty.call(rec, key)) {
139+ copy[key] = rec[key];
189− };
140+ }
190− };
141+ }
142+ copy[label4] = value12;
143+ return copy;
191 };
144 };
192 };
145 };
193 };
146 };
194− var ordIntImpl = unsafeCompareImpl;
195
147
196− // output/Data.Eq/foreign.js
148+ // output/Data.Semigroup/foreign.js
197− var refEq = function(r1) {
149+ var concatArray = function(xs) {
198− return function(r2) {
150+ return function(ys) {
199− return r1 === r2;
151+ if (xs.length === 0) return ys;
152+ if (ys.length === 0) return xs;
153+ return xs.concat(ys);
200 };
154 };
201 };
155 };
202− var eqIntImpl = refEq;
203−
204− // output/Data.Eq/index.js
205− var eqInt = {
206− eq: eqIntImpl
207− };
208
156
209− // output/Data.Ordering/index.js
157+ // output/Data.Semigroup/index.js
210− var LT = /* @__PURE__ */ function() {
158+ var semigroupUnit = {
211− function LT2() {
159+ append: function(v) {
212− }
213− ;
214− LT2.value = new LT2();
215− return LT2;
160+ return function(v1) {
216− }();
217− var GT = /* @__PURE__ */ function() {
218− function GT2() {
219− }
220− ;
221− GT2.value = new GT2();
222− return GT2;
161+ return unit;
223− }();
162+ };
224− var EQ = /* @__PURE__ */ function() {
225− function EQ2() {
226 }
163 }
227− ;
228− EQ2.value = new EQ2();
229− return EQ2;
230− }();
231−
232− // output/Data.Ord/index.js
233− var ordInt = /* @__PURE__ */ function() {
234− return {
235− compare: ordIntImpl(LT.value)(EQ.value)(GT.value),
236− Eq0: function() {
237− return eqInt;
238− }
239− };
240− }();
241−
242− // output/Data.Bounded/index.js
243− var top = function(dict) {
244− return dict.top;
245 };
164 };
246− var boundedInt = {
165+ var semigroupRecordNil = {
247− top: topInt,
166+ appendRecord: function(v) {
248− bottom: bottomInt,
167+ return function(v1) {
249− Ord0: function() {
168+ return function(v2) {
250− return ordInt;
169+ return {};
170+ };
171+ };
251 }
172 }
252 };
173 };
253− var bottom = function(dict) {
174+ var semigroupArray = {
254− return dict.bottom;
175+ append: concatArray
255− };
256−
257− // output/Data.Show/foreign.js
258− var showIntImpl = function(n) {
259− return n.toString();
260− };
261− var showNumberImpl = function(n) {
262− var str = n.toString();
263− return isNaN(str + ".0") ? str : str + ".0";
264 };
176 };
265−
177+ var appendRecord = function(dict) {
266− // output/Data.Show/index.js
178+ return dict.appendRecord;
267− var showNumber = {
268− show: showNumberImpl
269 };
179 };
270− var showInt = {
180+ var semigroupRecord = function() {
271− show: showIntImpl
181+ return function(dictSemigroupRecord) {
182+ return {
183+ append: appendRecord(dictSemigroupRecord)($$Proxy.value)
184+ };
185+ };
272 };
186 };
273− var show = function(dict) {
187+ var append = function(dict) {
274− return dict.show;
188+ return dict.append;
275 };
189 };
276−
190+ var semigroupRecordCons = function(dictIsSymbol) {
277− // output/Data.Maybe/index.js
191+ var reflectSymbol2 = reflectSymbol(dictIsSymbol);
278− var identity2 = /* @__PURE__ */ identity(categoryFn);
279− var Nothing = /* @__PURE__ */ function() {
280− function Nothing2() {
281− }
282− ;
283− Nothing2.value = new Nothing2();
284− return Nothing2;
285− }();
286− var Just = /* @__PURE__ */ function() {
192+ return function() {
287− function Just2(value0) {
193+ return function(dictSemigroupRecord) {
288− this.value0 = value0;
194+ var appendRecord1 = appendRecord(dictSemigroupRecord);
289− }
290− ;
291− Just2.create = function(value0) {
292− return new Just2(value0);
293− };
294− return Just2;
295− }();
296− var maybe = function(v) {
297− return function(v1) {
195+ return function(dictSemigroup) {
298− return function(v2) {
196+ var append12 = append(dictSemigroup);
299− if (v2 instanceof Nothing) {
300− return v;
301− }
302− ;
303− if (v2 instanceof Just) {
304− return v1(v2.value0);
197+ return {
305− }
198+ appendRecord: function(v) {
306− ;
199+ return function(ra) {
307− throw new Error("Failed pattern match at Data.Maybe (line 237, column 1 - line 237, column 51): " + [v.constructor.name, v1.constructor.name, v2.constructor.name]);
200+ return function(rb) {
201+ var tail = appendRecord1($$Proxy.value)(ra)(rb);
202+ var key = reflectSymbol2($$Proxy.value);
203+ var insert = unsafeSet(key);
204+ var get = unsafeGet(key);
205+ return insert(append12(get(ra))(get(rb)))(tail);
206+ };
207+ };
208+ }
209+ };
210+ };
308 };
211 };
309 };
212 };
310 };
213 };
311− var fromMaybe = function(a) {
312− return maybe(a)(identity2);
313− };
314
214
315 // output/Data.Monoid/index.js
215 // output/Data.Monoid/index.js
216+ var semigroupRecord2 = /* @__PURE__ */ semigroupRecord();
217+ var monoidUnit = {
218+ mempty: unit,
219+ Semigroup0: function() {
220+ return semigroupUnit;
221+ }
222+ };
223+ var monoidRecordNil = {
224+ memptyRecord: function(v) {
225+ return {};
226+ },
227+ SemigroupRecord0: function() {
228+ return semigroupRecordNil;
229+ }
230+ };
316 var monoidArray = {
231 var monoidArray = {
317 mempty: [],
232 mempty: [],
318 Semigroup0: function() {
233 Semigroup0: function() {
319 return semigroupArray;
234 return semigroupArray;
320 }
235 }
321 };
236 };
237+ var memptyRecord = function(dict) {
238+ return dict.memptyRecord;
239+ };
240+ var monoidRecord = function() {
241+ return function(dictMonoidRecord) {
242+ var semigroupRecord1 = semigroupRecord2(dictMonoidRecord.SemigroupRecord0());
243+ return {
244+ mempty: memptyRecord(dictMonoidRecord)($$Proxy.value),
245+ Semigroup0: function() {
246+ return semigroupRecord1;
247+ }
248+ };
249+ };
250+ };
322 var mempty = function(dict) {
251 var mempty = function(dict) {
323 return dict.mempty;
252 return dict.mempty;
324 };
253 };
254+ var monoidRecordCons = function(dictIsSymbol) {
255+ var reflectSymbol2 = reflectSymbol(dictIsSymbol);
256+ var semigroupRecordCons3 = semigroupRecordCons(dictIsSymbol)();
257+ return function(dictMonoid) {
258+ var mempty12 = mempty(dictMonoid);
259+ var Semigroup0 = dictMonoid.Semigroup0();
260+ return function() {
261+ return function(dictMonoidRecord) {
262+ var memptyRecord1 = memptyRecord(dictMonoidRecord);
263+ var semigroupRecordCons1 = semigroupRecordCons3(dictMonoidRecord.SemigroupRecord0())(Semigroup0);
264+ return {
265+ memptyRecord: function(v) {
266+ var tail = memptyRecord1($$Proxy.value);
267+ var key = reflectSymbol2($$Proxy.value);
268+ var insert = unsafeSet(key);
269+ return insert(mempty12)(tail);
270+ },
271+ SemigroupRecord0: function() {
272+ return semigroupRecordCons1;
273+ }
274+ };
275+ };
276+ };
277+ };
278+ };
325
279
326 // output/Effect/foreign.js
280 // output/Effect/foreign.js
327 var pureE = function(a) {
281 var pureE = function(a) {
@@ -337,6 +291,21 @@
337 };
291 };
338 };
292 };
339
293
294+ // output/Control.Monad/index.js
295+ var ap = function(dictMonad) {
296+ var bind3 = bind(dictMonad.Bind1());
297+ var pure3 = pure(dictMonad.Applicative0());
298+ return function(f) {
299+ return function(a) {
300+ return bind3(f)(function(f$prime) {
301+ return bind3(a)(function(a$prime) {
302+ return pure3(f$prime(a$prime));
303+ });
304+ });
305+ };
306+ };
307+ };
308+
340 // output/Effect/index.js
309 // output/Effect/index.js
341 var $runtime_lazy = function(name14, moduleName, init) {
310 var $runtime_lazy = function(name14, moduleName, init) {
342 var state2 = 0;
311 var state2 = 0;
@@ -385,6 +354,88 @@
385 });
354 });
386 var functorEffect = /* @__PURE__ */ $lazy_functorEffect(20);
355 var functorEffect = /* @__PURE__ */ $lazy_functorEffect(20);
387
356
357+ // output/Data.Array/foreign.js
358+ var replicateFill = function(count, value12) {
359+ if (count < 1) {
360+ return [];
361+ }
362+ var result = new Array(count);
363+ return result.fill(value12);
364+ };
365+ var replicatePolyfill = function(count, value12) {
366+ var result = [];
367+ var n = 0;
368+ for (var i = 0; i < count; i++) {
369+ result[n++] = value12;
370+ }
371+ return result;
372+ };
373+ var replicateImpl = typeof Array.prototype.fill === "function" ? replicateFill : replicatePolyfill;
374+
375+ // output/Data.Bounded/foreign.js
376+ var topChar = String.fromCharCode(65535);
377+ var bottomChar = String.fromCharCode(0);
378+ var topNumber = Number.POSITIVE_INFINITY;
379+ var bottomNumber = Number.NEGATIVE_INFINITY;
380+
381+ // output/Data.Show/foreign.js
382+ var showIntImpl = function(n) {
383+ return n.toString();
384+ };
385+ var showNumberImpl = function(n) {
386+ var str = n.toString();
387+ return isNaN(str + ".0") ? str : str + ".0";
388+ };
389+
390+ // output/Data.Show/index.js
391+ var showNumber = {
392+ show: showNumberImpl
393+ };
394+ var showInt = {
395+ show: showIntImpl
396+ };
397+ var show = function(dict) {
398+ return dict.show;
399+ };
400+
401+ // output/Data.Maybe/index.js
402+ var identity2 = /* @__PURE__ */ identity(categoryFn);
403+ var Nothing = /* @__PURE__ */ function() {
404+ function Nothing2() {
405+ }
406+ ;
407+ Nothing2.value = new Nothing2();
408+ return Nothing2;
409+ }();
410+ var Just = /* @__PURE__ */ function() {
411+ function Just2(value0) {
412+ this.value0 = value0;
413+ }
414+ ;
415+ Just2.create = function(value0) {
416+ return new Just2(value0);
417+ };
418+ return Just2;
419+ }();
420+ var maybe = function(v) {
421+ return function(v1) {
422+ return function(v2) {
423+ if (v2 instanceof Nothing) {
424+ return v;
425+ }
426+ ;
427+ if (v2 instanceof Just) {
428+ return v1(v2.value0);
429+ }
430+ ;
431+ throw new Error("Failed pattern match at Data.Maybe (line 237, column 1 - line 237, column 51): " + [v.constructor.name, v1.constructor.name, v2.constructor.name]);
432+ };
433+ };
434+ };
435+ var fromMaybe = function(a) {
436+ return maybe(a)(identity2);
437+ };
438+
388 // output/Effect.Ref/foreign.js
439 // output/Effect.Ref/foreign.js
389 var _new = function(val) {
440 var _new = function(val) {
390 return function() {
441 return function() {
@@ -527,13 +578,13 @@
527 var foldr2 = foldr(dictFoldable);
578 var foldr2 = foldr(dictFoldable);
528 return function(dictMonoid) {
579 return function(dictMonoid) {
529 var append3 = append(dictMonoid.Semigroup0());
580 var append3 = append(dictMonoid.Semigroup0());
530− var mempty3 = mempty(dictMonoid);
581+ var mempty5 = mempty(dictMonoid);
531 return function(f) {
582 return function(f) {
532 return foldr2(function(x) {
583 return foldr2(function(x) {
533 return function(acc) {
584 return function(acc) {
534 return append3(f(x))(acc);
585 return append3(f(x))(acc);
535 };
586 };
536− })(mempty3);
587+ })(mempty5);
537 };
588 };
538 };
589 };
539 };
590 };
@@ -559,10 +610,15 @@
559
610
560 // output/Data.Array/index.js
611 // output/Data.Array/index.js
561 var foldMap1 = /* @__PURE__ */ foldMap(foldableArray);
612 var foldMap1 = /* @__PURE__ */ foldMap(foldableArray);
562− var range2 = /* @__PURE__ */ runFn2(rangeImpl);
613+ var append2 = /* @__PURE__ */ append(semigroupArray);
563 var foldMap2 = function(dictMonoid) {
614 var foldMap2 = function(dictMonoid) {
564 return foldMap1(dictMonoid);
615 return foldMap1(dictMonoid);
565 };
616 };
617+ var cons = function(x) {
618+ return function(xs) {
619+ return append2([x])(xs);
620+ };
621+ };
566
622
567 // output/Maquette/foreign.js
623 // output/Maquette/foreign.js
568 var NAMESPACE_W3 = "http://www.w3.org/";
624 var NAMESPACE_W3 = "http://www.w3.org/";
@@ -1178,10 +1234,10 @@
1178 } else if (properties && (typeof properties === "string" || properties.vnodeSelector) || children && (typeof children === "string" || children.vnodeSelector)) {
1234 } else if (properties && (typeof properties === "string" || properties.vnodeSelector) || children && (typeof children === "string" || children.vnodeSelector)) {
1179 throw new Error("h called with invalid arguments");
1235 throw new Error("h called with invalid arguments");
1180 }
1236 }
1181− var text5;
1237+ var text6;
1182 var flattenedChildren;
1238 var flattenedChildren;
1183 if (children && children.length === 1 && typeof children[0] === "string") {
1239 if (children && children.length === 1 && typeof children[0] === "string") {
1184− text5 = children[0];
1240+ text6 = children[0];
1185 } else if (children) {
1241 } else if (children) {
1186 flattenedChildren = [];
1242 flattenedChildren = [];
1187 appendChildren(selector, children, flattenedChildren);
1243 appendChildren(selector, children, flattenedChildren);
@@ -1193,7 +1249,7 @@
1193 vnodeSelector: selector,
1249 vnodeSelector: selector,
1194 properties,
1250 properties,
1195 children: flattenedChildren,
1251 children: flattenedChildren,
1196− text: text5 === "" ? void 0 : text5,
1252+ text: text6 === "" ? void 0 : text6,
1197 domNode: null
1253 domNode: null
1198 };
1254 };
1199 }
1255 }
@@ -1344,51 +1400,6 @@
1344 var string = unsafeCoerce2;
1400 var string = unsafeCoerce2;
1345 var h2 = _h;
1401 var h2 = _h;
1346
1402
1347− // output/Data.Int/foreign.js
1348− var fromNumberImpl = function(just) {
1349− return function(nothing) {
1350− return function(n) {
1351− return (n | 0) === n ? just(n) : nothing;
1352− };
1353− };
1354− };
1355− var toNumber = function(n) {
1356− return n;
1357− };
1358−
1359− // output/Data.Number/foreign.js
1360− var isFiniteImpl = isFinite;
1361− var round = Math.round;
1362−
1363− // output/Data.Int/index.js
1364− var top2 = /* @__PURE__ */ top(boundedInt);
1365− var bottom2 = /* @__PURE__ */ bottom(boundedInt);
1366− var fromNumber = /* @__PURE__ */ function() {
1367− return fromNumberImpl(Just.create)(Nothing.value);
1368− }();
1369− var unsafeClamp = function(x) {
1370− if (!isFiniteImpl(x)) {
1371− return 0;
1372− }
1373− ;
1374− if (x >= toNumber(top2)) {
1375− return top2;
1376− }
1377− ;
1378− if (x <= toNumber(bottom2)) {
1379− return bottom2;
1380− }
1381− ;
1382− if (otherwise) {
1383− return fromMaybe(0)(fromNumber(x));
1384− }
1385− ;
1386− throw new Error("Failed pattern match at Data.Int (line 72, column 1 - line 72, column 29): " + [x.constructor.name]);
1387− };
1388− var round2 = function($37) {
1389− return unsafeClamp(round($37));
1390− };
1391−
1392 // output/Foreign.Object/foreign.js
1403 // output/Foreign.Object/foreign.js
1393 function _copyST(m) {
1404 function _copyST(m) {
1394 return function() {
1405 return function() {
@@ -1516,10 +1527,31 @@
1516 var unsafeUnion = /* @__PURE__ */ runFn2(unsafeUnionFn);
1527 var unsafeUnion = /* @__PURE__ */ runFn2(unsafeUnionFn);
1517
1528
1518 // output/Plum.View/index.js
1529 // output/Plum.View/index.js
1530+ var semigroupRecord3 = /* @__PURE__ */ semigroupRecord();
1531+ var childrenIsSymbol = {
1532+ reflectSymbol: function() {
1533+ return "children";
1534+ }
1535+ };
1536+ var meatIsSymbol = {
1537+ reflectSymbol: function() {
1538+ return "meat";
1539+ }
1540+ };
1541+ var nervesIsSymbol = {
1542+ reflectSymbol: function() {
1543+ return "nerves";
1544+ }
1545+ };
1546+ var semigroupRecordCons2 = /* @__PURE__ */ semigroupRecordCons(childrenIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(meatIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(nervesIsSymbol)()(semigroupRecordNil)(semigroupArray))(semigroupArray));
1519 var show2 = /* @__PURE__ */ show(showInt);
1547 var show2 = /* @__PURE__ */ show(showInt);
1520 var show1 = /* @__PURE__ */ show(showNumber);
1548 var show1 = /* @__PURE__ */ show(showNumber);
1549+ var monoidRecord2 = /* @__PURE__ */ monoidRecord();
1550+ var monoidRecordCons2 = /* @__PURE__ */ monoidRecordCons(childrenIsSymbol);
1551+ var monoidRecordCons1 = /* @__PURE__ */ monoidRecordCons(meatIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(nervesIsSymbol)(monoidArray)()(monoidRecordNil));
1552+ var mempty2 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidRecord2(/* @__PURE__ */ monoidRecordCons2(monoidArray)()(monoidRecordCons1)));
1521 var append1 = /* @__PURE__ */ append(semigroupArray);
1553 var append1 = /* @__PURE__ */ append(semigroupArray);
1522− var mempty2 = /* @__PURE__ */ mempty(monoidArray);
1554+ var mempty1 = /* @__PURE__ */ mempty(monoidArray);
1523 var map2 = /* @__PURE__ */ map(functorArray);
1555 var map2 = /* @__PURE__ */ map(functorArray);
1524 var Px = /* @__PURE__ */ function() {
1556 var Px = /* @__PURE__ */ function() {
1525 function Px2(value0) {
1557 function Px2(value0) {
@@ -1761,6 +1793,19 @@
1761 };
1793 };
1762 return Clip2;
1794 return Clip2;
1763 }();
1795 }();
1796+ var UI = /* @__PURE__ */ function() {
1797+ function UI2(value0, value1) {
1798+ this.value0 = value0;
1799+ this.value1 = value1;
1800+ }
1801+ ;
1802+ UI2.create = function(value0) {
1803+ return function(value1) {
1804+ return new UI2(value0, value1);
1805+ };
1806+ };
1807+ return UI2;
1808+ }();
1764 var Column = /* @__PURE__ */ function() {
1809 var Column = /* @__PURE__ */ function() {
1765 function Column2(value0) {
1810 function Column2(value0) {
1766 this.value0 = value0;
1811 this.value0 = value0;
@@ -1843,6 +1888,39 @@
1843 };
1888 };
1844 return Download2;
1889 return Download2;
1845 }();
1890 }();
1891+ var Image2 = /* @__PURE__ */ function() {
1892+ function Image3(value0, value1) {
1893+ this.value0 = value0;
1894+ this.value1 = value1;
1895+ }
1896+ ;
1897+ Image3.create = function(value0) {
1898+ return function(value1) {
1899+ return new Image3(value0, value1);
1900+ };
1901+ };
1902+ return Image3;
1903+ }();
1904+ var None = /* @__PURE__ */ function() {
1905+ function None3() {
1906+ }
1907+ ;
1908+ None3.value = new None3();
1909+ return None3;
1910+ }();
1911+ var semigroupUIWith = function(dictSemigroup) {
1912+ var append3 = append(semigroupRecord3(semigroupRecordCons2(dictSemigroup)));
1913+ return function(dictSemigroup1) {
1914+ var append4 = append(dictSemigroup1);
1915+ return {
1916+ append: function(v) {
1917+ return function(v1) {
1918+ return new UI(append3(v.value0)(v1.value0), append4(v.value1)(v1.value1));
1919+ };
1920+ }
1921+ };
1922+ };
1923+ };
1846 var semigroupSkin = {
1924 var semigroupSkin = {
1847 append: function(v) {
1925 append: function(v) {
1848 return function(v1) {
1926 return function(v1) {
@@ -1850,12 +1928,12 @@
1850 };
1928 };
1851 }
1929 }
1852 };
1930 };
1853− var append2 = /* @__PURE__ */ append(semigroupSkin);
1931+ var append22 = /* @__PURE__ */ append(semigroupSkin);
1854 var semigroupMutation = {
1932 var semigroupMutation = {
1855 append: function(v) {
1933 append: function(v) {
1856 return function(v1) {
1934 return function(v1) {
1857 return {
1935 return {
1858− extraSkin: append2(v.extraSkin)(v1.extraSkin)
1936+ extraSkin: append22(v.extraSkin)(v1.extraSkin)
1859 };
1937 };
1860 };
1938 };
1861 }
1939 }
@@ -1865,32 +1943,82 @@
1865 return "rgba(" + (show2(v.r) + ("," + (show2(v.g) + ("," + (show2(v.b) + ("," + (show1(v.a) + ")")))))));
1943 return "rgba(" + (show2(v.r) + ("," + (show2(v.g) + ("," + (show2(v.b) + ("," + (show1(v.a) + ")")))))));
1866 }
1944 }
1867 };
1945 };
1946+ var monoidUIWith = function(dictMonoid) {
1947+ var mempty42 = mempty(monoidRecord2(monoidRecordCons2(dictMonoid)()(monoidRecordCons1)));
1948+ var semigroupUIWith1 = semigroupUIWith(dictMonoid.Semigroup0());
1949+ return function(dictMonoid1) {
1950+ var semigroupUIWith2 = semigroupUIWith1(dictMonoid1.Semigroup0());
1951+ return {
1952+ mempty: new UI(mempty42, mempty(dictMonoid1)),
1953+ Semigroup0: function() {
1954+ return semigroupUIWith2;
1955+ }
1956+ };
1957+ };
1958+ };
1868 var monoidSkin = {
1959 var monoidSkin = {
1869 mempty: empty2,
1960 mempty: empty2,
1870 Semigroup0: function() {
1961 Semigroup0: function() {
1871 return semigroupSkin;
1962 return semigroupSkin;
1872 }
1963 }
1873 };
1964 };
1874− var mempty1 = /* @__PURE__ */ mempty(monoidSkin);
1965+ var mempty22 = /* @__PURE__ */ mempty(monoidSkin);
1875 var foldMap3 = /* @__PURE__ */ foldMap2(monoidSkin);
1966 var foldMap3 = /* @__PURE__ */ foldMap2(monoidSkin);
1876 var monoidMutation = {
1967 var monoidMutation = {
1877 mempty: {
1968 mempty: {
1878− extraSkin: mempty1
1969+ extraSkin: mempty22
1879 },
1970 },
1880 Semigroup0: function() {
1971 Semigroup0: function() {
1881 return semigroupMutation;
1972 return semigroupMutation;
1882 }
1973 }
1883 };
1974 };
1884− var mempty22 = /* @__PURE__ */ mempty(monoidMutation);
1975+ var mempty3 = /* @__PURE__ */ mempty(monoidMutation);
1885− var view = function(nerves) {
1976+ var functorUIWith = {
1886− return function(meat) {
1977+ map: function(f) {
1887− return function(bones) {
1978+ return function(v) {
1888− return {
1979+ return new UI(v.value0, f(v.value1));
1889− nerves,
1890− meat,
1891− bones
1892− };
1893 };
1980 };
1981+ }
1982+ };
1983+ var applyUIWith = function(dictMonoid) {
1984+ var append3 = append(semigroupRecord3(semigroupRecordCons2(dictMonoid.Semigroup0())));
1985+ return {
1986+ apply: function(v) {
1987+ return function(v1) {
1988+ return new UI(append3(v.value0)(v1.value0), v.value1(v1.value1));
1989+ };
1990+ },
1991+ Functor0: function() {
1992+ return functorUIWith;
1993+ }
1994+ };
1995+ };
1996+ var bindUIWith = function(dictMonoid) {
1997+ var append3 = append(semigroupRecord3(semigroupRecordCons2(dictMonoid.Semigroup0())));
1998+ var applyUIWith1 = applyUIWith(dictMonoid);
1999+ return {
2000+ bind: function(v) {
2001+ return function(f) {
2002+ var v1 = f(v.value1);
2003+ return new UI(append3(v.value0)(v1.value0), v1.value1);
2004+ };
2005+ },
2006+ Apply0: function() {
2007+ return applyUIWith1;
2008+ }
2009+ };
2010+ };
2011+ var text = function(s) {
2012+ return function(v) {
2013+ return new UI({
2014+ nerves: mempty2.nerves,
2015+ meat: mempty2.meat,
2016+ children: [{
2017+ meat: v.value0.meat,
2018+ nerves: v.value0.nerves,
2019+ bones: new Text(s)
2020+ }]
2021+ }, v.value1);
1894 };
2022 };
1895 };
2023 };
1896 var sk = function(key) {
2024 var sk = function(key) {
@@ -1898,18 +2026,6 @@
1898 return singleton2(key)(val);
2026 return singleton2(key)(val);
1899 };
2027 };
1900 };
2028 };
1901− var rgb = function(r) {
1902− return function(g) {
1903− return function(b) {
1904− return {
1905− r: round2(r * 255),
1906− g: round2(g * 255),
1907− b: round2(b * 255),
1908− a: 1
1909− };
1910− };
1911− };
1912− };
1913 var render = function(dict) {
2029 var render = function(dict) {
1914 return dict.render;
2030 return dict.render;
1915 };
2031 };
@@ -1936,7 +2052,7 @@
1936 return "min(" + (show2(v.value0) + ("px," + (render(renderableLength)(v.value1) + ")")));
2052 return "min(" + (show2(v.value0) + ("px," + (render(renderableLength)(v.value1) + ")")));
1937 }
2053 }
1938 ;
2054 ;
1939− throw new Error("Failed pattern match at Plum.View (line 131, column 12 - line 136, column 62): " + [v.constructor.name]);
2055+ throw new Error("Failed pattern match at Plum.View (line 258, column 12 - line 263, column 62): " + [v.constructor.name]);
1940 }
2056 }
1941 };
2057 };
1942 var render2 = /* @__PURE__ */ render(renderableLength);
2058 var render2 = /* @__PURE__ */ render(renderableLength);
@@ -1952,11 +2068,11 @@
1952 ;
2068 ;
1953 if (v instanceof Align) {
2069 if (v instanceof Align) {
1954 if (ctx instanceof Generic) {
2070 if (ctx instanceof Generic) {
1955− return mempty1;
2071+ return mempty22;
1956 }
2072 }
1957 ;
2073 ;
1958 if (ctx instanceof Span) {
2074 if (ctx instanceof Span) {
1959− return mempty1;
2075+ return mempty22;
1960 }
2076 }
1961 ;
2077 ;
1962 if (ctx instanceof Grid) {
2078 if (ctx instanceof Grid) {
@@ -1969,7 +2085,7 @@
1969 return "align-items";
2085 return "align-items";
1970 }
2086 }
1971 ;
2087 ;
1972− throw new Error("Failed pattern match at Plum.View (line 88, column 9 - line 90, column 29): " + [v.value0.constructor.name]);
2088+ throw new Error("Failed pattern match at Plum.View (line 215, column 9 - line 217, column 29): " + [v.value0.constructor.name]);
1973 }())(function() {
2089 }())(function() {
1974 if (v.value1 instanceof Start) {
2090 if (v.value1 instanceof Start) {
1975 return "start";
2091 return "start";
@@ -1983,7 +2099,7 @@
1983 return "end";
2099 return "end";
1984 }
2100 }
1985 ;
2101 ;
1986− throw new Error("Failed pattern match at Plum.View (line 92, column 9 - line 95, column 23): " + [v.value1.constructor.name]);
2102+ throw new Error("Failed pattern match at Plum.View (line 219, column 9 - line 222, column 23): " + [v.value1.constructor.name]);
1987 }());
2103 }());
1988 }
2104 }
1989 ;
2105 ;
@@ -2006,7 +2122,7 @@
2006 return "justify-content";
2122 return "justify-content";
2007 }
2123 }
2008 ;
2124 ;
2009− throw new Error("Failed pattern match at Plum.View (line 99, column 9 - line 103, column 38): " + [v1.constructor.name]);
2125+ throw new Error("Failed pattern match at Plum.View (line 226, column 9 - line 230, column 38): " + [v1.constructor.name]);
2010 }())(function() {
2126 }())(function() {
2011 if (v.value1 instanceof Start) {
2127 if (v.value1 instanceof Start) {
2012 return "flex-start";
2128 return "flex-start";
@@ -2020,11 +2136,11 @@
2020 return "flex-end";
2136 return "flex-end";
2021 }
2137 }
2022 ;
2138 ;
2023− throw new Error("Failed pattern match at Plum.View (line 105, column 9 - line 108, column 28): " + [v.value1.constructor.name]);
2139+ throw new Error("Failed pattern match at Plum.View (line 232, column 9 - line 235, column 28): " + [v.value1.constructor.name]);
2024 }());
2140 }());
2025 }
2141 }
2026 ;
2142 ;
2027− throw new Error("Failed pattern match at Plum.View (line 84, column 26 - line 109, column 8): " + [ctx.constructor.name]);
2143+ throw new Error("Failed pattern match at Plum.View (line 211, column 26 - line 236, column 8): " + [ctx.constructor.name]);
2028 }
2144 }
2029 ;
2145 ;
2030 if (v instanceof Width) {
2146 if (v instanceof Width) {
@@ -2040,7 +2156,7 @@
2040 return sk("flex-wrap")("wrap");
2156 return sk("flex-wrap")("wrap");
2041 }
2157 }
2042 ;
2158 ;
2043− return mempty1;
2159+ return mempty22;
2044 }
2160 }
2045 ;
2161 ;
2046 if (v instanceof BackgroundColor) {
2162 if (v instanceof BackgroundColor) {
@@ -2056,7 +2172,7 @@
2056 return sk("justify-content")("space-between");
2172 return sk("justify-content")("space-between");
2057 }
2173 }
2058 ;
2174 ;
2059− return mempty1;
2175+ return mempty22;
2060 }
2176 }
2061 ;
2177 ;
2062 if (v instanceof Opacity) {
2178 if (v instanceof Opacity) {
@@ -2079,24 +2195,24 @@
2079 return sk("overflow-y")("hidden");
2195 return sk("overflow-y")("hidden");
2080 }
2196 }
2081 ;
2197 ;
2082− throw new Error("Failed pattern match at Plum.View (line 81, column 12 - line 125, column 37): " + [v.constructor.name]);
2198+ throw new Error("Failed pattern match at Plum.View (line 208, column 12 - line 252, column 37): " + [v.constructor.name]);
2083 };
2199 };
2084 };
2200 };
2085− var hWith = function(el) {
2201+ var hWith = function(elem2) {
2086 return function(props) {
2202 return function(props) {
2087 return function(v) {
2203 return function(v) {
2088 return function(children) {
2204 return function(children) {
2089− return h2(el)(unsafeUnion(props)({
2205+ return h2(elem2)(unsafeUnion(props)({
2090 styles: v
2206 styles: v
2091 }))(children);
2207 }))(children);
2092 };
2208 };
2093 };
2209 };
2094 };
2210 };
2095 };
2211 };
2096− var h3 = function(el) {
2212+ var h3 = function(elem2) {
2097 return function(v) {
2213 return function(v) {
2098 return function(children) {
2214 return function(children) {
2099− return h2(el)({
2215+ return h2(elem2)({
2100 styles: v
2216 styles: v
2101 })(children);
2217 })(children);
2102 };
2218 };
@@ -2108,9 +2224,9 @@
2108 var widthFill = [new Width(Fill.value), new Height(Fill.value)];
2224 var widthFill = [new Width(Fill.value), new Height(Fill.value)];
2109 var alignCenter = [new Align(X.value, Center.value), new Align(Y.value, Center.value)];
2225 var alignCenter = [new Align(X.value, Center.value), new Align(Y.value, Center.value)];
2110 var skn = function(ctx) {
2226 var skn = function(ctx) {
2111− return append2(foldMap3(skin(ctx))(append1(v1.meat)(append1(function() {
2227+ return append22(foldMap3(skin(ctx))(append1(v1.meat)(append1(function() {
2112 if (ctx instanceof Span) {
2228 if (ctx instanceof Span) {
2113− return mempty2;
2229+ return mempty1;
2114 }
2230 }
2115 ;
2231 ;
2116 if (ctx instanceof Grid) {
2232 if (ctx instanceof Grid) {
@@ -2125,7 +2241,7 @@
2125 return widthFill;
2241 return widthFill;
2126 }
2242 }
2127 ;
2243 ;
2128− throw new Error("Failed pattern match at Plum.View (line 181, column 16 - line 185, column 35): " + [ctx.constructor.name]);
2244+ throw new Error("Failed pattern match at Plum.View (line 310, column 16 - line 314, column 35): " + [ctx.constructor.name]);
2129 }())(function() {
2245 }())(function() {
2130 if (ctx instanceof Grid) {
2246 if (ctx instanceof Grid) {
2131 return alignCenter;
2247 return alignCenter;
@@ -2136,14 +2252,14 @@
2136 }
2252 }
2137 ;
2253 ;
2138 if (ctx instanceof Span) {
2254 if (ctx instanceof Span) {
2139− return mempty2;
2255+ return mempty1;
2140 }
2256 }
2141 ;
2257 ;
2142 if (ctx instanceof Generic) {
2258 if (ctx instanceof Generic) {
2143 return alignCenter;
2259 return alignCenter;
2144 }
2260 }
2145 ;
2261 ;
2146− throw new Error("Failed pattern match at Plum.View (line 186, column 16 - line 190, column 37): " + [ctx.constructor.name]);
2262+ throw new Error("Failed pattern match at Plum.View (line 315, column 16 - line 319, column 37): " + [ctx.constructor.name]);
2147 }()))))(v.extraSkin);
2263 }()))))(v.extraSkin);
2148 };
2264 };
2149 if (v1.bones instanceof Text) {
2265 if (v1.bones instanceof Text) {
@@ -2151,21 +2267,21 @@
2151 }
2267 }
2152 ;
2268 ;
2153 if (v1.bones instanceof Wrapper) {
2269 if (v1.bones instanceof Wrapper) {
2154− return h3("div")(append2(skn(new Flexbox(X.value)))(append2(sk("display")("flex"))(sk("flex-direction")("row"))))([growSkin(fire)(mempty22)(v1.bones.value0)]);
2270+ return h3("div")(append22(skn(new Flexbox(X.value)))(append22(sk("display")("flex"))(sk("flex-direction")("row"))))([growSkin(fire)(mempty3)(v1.bones.value0)]);
2155 }
2271 }
2156 ;
2272 ;
2157 if (v1.bones instanceof Stack) {
2273 if (v1.bones instanceof Stack) {
2158− return h3("div")(append2(skn(Grid.value))(sk("display")("grid")))(map2(growSkin(fire)({
2274+ return h3("div")(append22(skn(Grid.value))(sk("display")("grid")))(map2(growSkin(fire)({
2159− extraSkin: append2(sk("grid-row")("1"))(sk("grid-column")("1"))
2275+ extraSkin: append22(sk("grid-row")("1"))(sk("grid-column")("1"))
2160 }))(v1.bones.value0));
2276 }))(v1.bones.value0));
2161 }
2277 }
2162 ;
2278 ;
2163 if (v1.bones instanceof Row) {
2279 if (v1.bones instanceof Row) {
2164− return h3("div")(append2(skn(new Flexbox(X.value)))(append2(sk("display")("flex"))(sk("flex-direction")("row"))))(map2(growSkin(fire)(mempty22))(v1.bones.value0));
2280+ return h3("div")(append22(skn(new Flexbox(X.value)))(append22(sk("display")("flex"))(sk("flex-direction")("row"))))(map2(growSkin(fire)(mempty3))(v1.bones.value0));
2165 }
2281 }
2166 ;
2282 ;
2167 if (v1.bones instanceof Column) {
2283 if (v1.bones instanceof Column) {
2168− return h3("div")(append2(skn(new Flexbox(Y.value)))(append2(sk("display")("flex"))(sk("flex-direction")("column"))))(map2(growSkin(fire)(mempty22))(v1.bones.value0));
2284+ return h3("div")(append22(skn(new Flexbox(Y.value)))(append22(sk("display")("flex"))(sk("flex-direction")("column"))))(map2(growSkin(fire)(mempty3))(v1.bones.value0));
2169 }
2285 }
2170 ;
2286 ;
2171 if (v1.bones instanceof Link) {
2287 if (v1.bones instanceof Link) {
@@ -2179,25 +2295,47 @@
2179 ;
2295 ;
2180 return "_self";
2296 return "_self";
2181 }()
2297 }()
2182− })(append2(skn(new Flexbox(X.value)))(append2(sk("display")("flex"))(sk("flex-direction")("row"))))([growSkin(fire)(mempty22)(v1.bones.value2)]);
2298+ })(append22(skn(new Flexbox(X.value)))(append22(sk("display")("flex"))(sk("flex-direction")("row"))))([growSkin(fire)(mempty3)(v1.bones.value2)]);
2183 }
2299 }
2184 ;
2300 ;
2185 if (v1.bones instanceof Download) {
2301 if (v1.bones instanceof Download) {
2186 return hWith("a")({
2302 return hWith("a")({
2187 href: v1.bones.value0,
2303 href: v1.bones.value0,
2188 download: fromMaybe("")(v1.bones.value1.filename)
2304 download: fromMaybe("")(v1.bones.value1.filename)
2189− })(append2(skn(new Flexbox(X.value)))(append2(sk("display")("flex"))(sk("flex-direction")("row"))))([growSkin(fire)(mempty22)(v1.bones.value2)]);
2305+ })(append22(skn(new Flexbox(X.value)))(append22(sk("display")("flex"))(sk("flex-direction")("row"))))([growSkin(fire)(mempty3)(v1.bones.value2)]);
2306+ }
2307+ ;
2308+ if (v1.bones instanceof Image2) {
2309+ return hWith("img")({
2310+ src: v1.bones.value0,
2311+ alt: v1.bones.value1.description
2312+ })(skn(Generic.value))([]);
2190 }
2313 }
2191 ;
2314 ;
2315+ if (v1.bones instanceof None) {
2316+ return h3("div")(mempty22)([]);
2317+ }
2318+ ;
2192− throw new Error("Failed pattern match at Plum.View (line 193, column 5 - line 215, column 39): " + [v1.bones.constructor.name]);
2319+ throw new Error("Failed pattern match at Plum.View (line 322, column 5 - line 346, column 32): " + [v1.bones.constructor.name]);
2193 };
2320 };
2194 };
2321 };
2195 };
2322 };
2196 var grow = function(fire) {
2323 var grow = function(fire) {
2197 return function(v) {
2324 return function(v) {
2198− return growSkin(fire)(mempty22)(v);
2325+ return growSkin(fire)(mempty3)(v);
2199 };
2326 };
2200 };
2327 };
2328+ var column = function(v) {
2329+ return new UI({
2330+ nerves: mempty2.nerves,
2331+ meat: mempty2.meat,
2332+ children: [{
2333+ meat: v.value0.meat,
2334+ nerves: v.value0.nerves,
2335+ bones: new Column(v.value0.children)
2336+ }]
2337+ }, v.value1);
2338+ };
2201
2339
2202 // output/Web.DOM.NonElementParentNode/foreign.js
2340 // output/Web.DOM.NonElementParentNode/foreign.js
2203 function _getElementById(id) {
2341 function _getElementById(id) {
@@ -2245,34 +2383,38 @@
2245
2383
2246 // output/Plum/index.js
2384 // output/Plum/index.js
2247 var bind2 = /* @__PURE__ */ bind(bindEffect);
2385 var bind2 = /* @__PURE__ */ bind(bindEffect);
2386+ var map4 = /* @__PURE__ */ map(functorArray);
2248 var outerStyle = "html,body{height:100%;padding:0;margin:0;}";
2387 var outerStyle = "html,body{height:100%;padding:0;margin:0;}";
2249 var run3 = function(id) {
2388 var run3 = function(id) {
2250 return function(plum2) {
2389 return function(plum2) {
2251 return function __do() {
2390 return function __do() {
2252 var modelRef = bind2(plum2.init)($$new)();
2391 var modelRef = bind2(plum2.init)($$new)();
2253 var v = bind2(bind2(windowImpl)(document2))(function() {
2392 var v = bind2(bind2(windowImpl)(document2))(function() {
2254− var $6 = getElementById(id);
2393+ var $12 = getElementById(id);
2255− return function($7) {
2394+ return function($13) {
2256− return $6(toNonElementParentNode($7));
2395+ return $12(toNonElementParentNode($13));
2257 };
2396 };
2258 }())();
2397 }())();
2259 if (v instanceof Just) {
2398 if (v instanceof Just) {
2260 var projector = createProjector();
2399 var projector = createProjector();
2261 return replace(projector)(v.value0)(function __do2() {
2400 return replace(projector)(v.value0)(function __do2() {
2262 var model = read(modelRef)();
2401 var model = read(modelRef)();
2263− var el = grow(function(msg) {
2402+ var el = map4(grow(function(msg) {
2264 return function __do3() {
2403 return function __do3() {
2265 var m = read(modelRef)();
2404 var m = read(modelRef)();
2266 var m_ = plum2.update(msg)(m)();
2405 var m_ = plum2.update(msg)(m)();
2267 return write(m_)(modelRef)();
2406 return write(m_)(modelRef)();
2268 };
2407 };
2408+ }))(function() {
2269− })(plum2.view(model));
2409+ var v1 = plum2.view(model);
2410+ return v1.value0.children;
2411+ }());
2270 return h2("div")({
2412 return h2("div")({
2271 styles: {
2413 styles: {
2272 height: "100%",
2414 height: "100%",
2273 width: "100%"
2415 width: "100%"
2274 }
2416 }
2275− })([h2("style")({})([string(outerStyle)]), el]);
2417+ })(cons(h2("style")({})([string(outerStyle)]))(el));
2276 })();
2418 })();
2277 }
2419 }
2278 ;
2420 ;
@@ -2280,22 +2422,23 @@
2280 return unit;
2422 return unit;
2281 }
2423 }
2282 ;
2424 ;
2283− throw new Error("Failed pattern match at Plum (line 25, column 92 - line 39, column 25): " + [v.constructor.name]);
2425+ throw new Error("Failed pattern match at Plum (line 26, column 92 - line 42, column 25): " + [v.constructor.name]);
2284 };
2426 };
2285 };
2427 };
2286 };
2428 };
2287
2429
2288 // output/Main/index.js
2430 // output/Main/index.js
2289 var pure2 = /* @__PURE__ */ pure(applicativeEffect);
2431 var pure2 = /* @__PURE__ */ pure(applicativeEffect);
2290− var map4 = /* @__PURE__ */ map(functorArray);
2432+ var discard2 = /* @__PURE__ */ discard(discardUnit)(/* @__PURE__ */ bindUIWith(monoidArray));
2433+ var mempty4 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidUIWith(monoidUnit)(monoidUnit));
2291 var plum = {
2434 var plum = {
2292 init: /* @__PURE__ */ pure2({
2435 init: /* @__PURE__ */ pure2({
2293 text: "Test"
2436 text: "Test"
2294 }),
2437 }),
2295 view: function(model) {
2438 view: function(model) {
2296− return view([])([])(new Column([view([])([])(new Link("https://iko.soy", {
2439+ return column(discard2(text("hi")(mempty4))(function() {
2297− newTab: false
2440+ return text("hello")(mempty4);
2298− }, view([])([])(new Text("my website")))), view([])([])(new Row(map4($$const(view([])([new BackgroundColor(rgb(1)(0)(0))])(new Text("hello"))))(range2(1)(100))))]));
2441+ }));
2299 },
2442 },
2300 update: function(msg) {
2443 update: function(msg) {
2301 return function(model) {
2444 return function(model) {
plum/src/Main.purs+5−8
@@ -5,7 +5,7 @@ import Prelude
5import Data.Array as Array
5import Data.Array as Array
6import Effect (Effect)
6import Effect (Effect)
7import Plum as Plum
7import Plum as Plum
8−import Plum.View (Bones(..), Meat(..), rgb, view)
8+import Plum.View
9
9
10main :: Effect Unit
10main :: Effect Unit
11main = do
11main = do
@@ -16,13 +16,10 @@ type Model = { text :: String }
16plum :: Plum.Plum Unit Model
16plum :: Plum.Plum Unit Model
17plum =
17plum =
18 { init: pure { text: "Test" }
18 { init: pure { text: "Test" }
19− , view: \model ->
19+ , view: \model -> do
20− view [] []
20+ column $ do
21− ( Column
21+ text "hi" mempty
22− [ view [] [] (Link "https://iko.soy" { newTab: false } $ view [] [] (Text "my website"))
22+ text "hello" mempty
23− , view [] [] (Row $ Array.range 1 100 # map (const $ view [] [ BackgroundColor (rgb 1.0 0.0 0.0) ] (Text "hello")))
24− ]
25− )
26 , update: \msg model -> case msg of
23 , update: \msg model -> case msg of
27 _ -> pure { text: "Button pressed" }
24 _ -> pure { text: "Button pressed" }
28 }
25 }
plum/src/Plum.purs+16−10
@@ -2,12 +2,12 @@ module Plum (Plum, run) where
2
2
3import Prelude
3import Prelude
4
4
5+import Data.Array ((:))
5import Data.Maybe (Maybe(..))
6import Data.Maybe (Maybe(..))
6import Effect (Effect)
7import Effect (Effect)
7import Effect.Ref as Ref
8import Effect.Ref as Ref
8−import Maquette (h)
9import Maquette as Maquette
9import Maquette as Maquette
10−import Plum.View (View, grow)
10+import Plum.View (UI, UIWith(..), grow)
11import Web.DOM.NonElementParentNode (getElementById) as Web
11import Web.DOM.NonElementParentNode (getElementById) as Web
12import Web.HTML (window) as Web
12import Web.HTML (window) as Web
13import Web.HTML.HTMLDocument (toNonElementParentNode) as Web
13import Web.HTML.HTMLDocument (toNonElementParentNode) as Web
@@ -16,7 +16,7 @@ import Web.HTML.Window (document) as Web
16type Plum msg model =
16type Plum msg model =
17 { init :: Effect model
17 { init :: Effect model
18 , update :: msg -> model -> Effect model
18 , update :: msg -> model -> Effect model
19− , view :: model -> View msg
19+ , view :: model -> UI msg Unit
20 }
20 }
21
21
22run :: forall msg model. String -> Plum msg model -> Effect Unit
22run :: forall msg model. String -> Plum msg model -> Effect Unit
@@ -28,14 +28,20 @@ run id plum = do
28 Maquette.replace projector element do
28 Maquette.replace projector element do
29 model <- Ref.read modelRef
29 model <- Ref.read modelRef
30 let
30 let
31+ el = map
31− el = grow
32+ ( grow
32− ( \msg -> do
33+ ( \msg -> do
33− m <- Ref.read modelRef
34+ m <- Ref.read modelRef
34− m_ <- plum.update msg m
35+ m_ <- plum.update msg m
35− Ref.write m_ modelRef
36+ Ref.write m_ modelRef
37+ Maquette.scheduleRender projector
38+ )
36 )
39 )
37− (plum.view model)
40+ (let UI { children } _ = plum.view model in children)
41+ pure $ Maquette.h
42+ "div"
43+ { styles: { height: "100%", width: "100%" } }
38− pure $ Maquette.h "div" { styles: { height: "100%", width: "100%" } } [ Maquette.h "style" {} [ Maquette.string outerStyle ], el ]
44+ (Maquette.h "style" {} [ Maquette.string outerStyle ] : el)
39 Nothing -> pure unit
45 Nothing -> pure unit
40
46
41outerStyle :: String
47outerStyle :: String
plum/src/Plum/View.purs+143−3
@@ -13,13 +13,28 @@ module Plum.View
13 , rgba255
13 , rgba255
14 , rgb
14 , rgb
15 , rgba
15 , rgba
16+ , UI
17+ , UIWith(..)
18+ , UIViewWith
19+ , column
20+ , row
21+ , stack
22+ , text
23+ , link
24+ , newTabLink
25+ , el
26+ , download
27+ , downloadAs
28+ , image
29+ , spacing
30+ , explain
16 ) where
31 ) where
17
32
18import Prelude
33import Prelude
19
34
20import Data.Array as Array
35import Data.Array as Array
21import Data.Int as Int
36import Data.Int as Int
22−import Data.Maybe (Maybe)
37+import Data.Maybe (Maybe(..))
23import Data.Maybe as Maybe
38import Data.Maybe as Maybe
24import Data.Tuple.Nested ((/\))
39import Data.Tuple.Nested ((/\))
25import Effect (Effect)
40import Effect (Effect)
@@ -30,11 +45,122 @@ import Maquette as Maquette
30import Record as Record
45import Record as Record
31import Record.Unsafe.Union as Record
46import Record.Unsafe.Union as Record
32
47
48+type UIViewWith children msg = { nerves :: Array (Nerve msg), meat :: Array Meat, children :: children }
49+
50+type UIView msg = UIViewWith (Array (View msg)) msg
51+
52+data UIWith children msg a = UI (UIViewWith children msg) a
53+
54+instance (Semigroup children, Semigroup a) => Semigroup (UIWith children msg a) where
55+ append (UI v a) (UI v' a') = UI (v <> v') (a <> a')
56+
57+instance (Monoid children, Monoid a) => Monoid (UIWith children msg a) where
58+ mempty = UI mempty mempty
59+
60+type UI msg a = UIWith (Array (View msg)) msg a
61+
62+instance Functor (UIWith children msg) where
63+ map f (UI v a) = UI v $ f a
64+
65+instance Monoid children => Apply (UIWith children msg) where
66+ apply (UI views f) (UI views' a) = UI (views <> views') (f a)
67+
68+instance Monoid children => Applicative (UIWith children msg) where
69+ pure = UI mempty
70+
71+instance Monoid children => Bind (UIWith children msg) where
72+ bind (UI views a) f =
73+ let
74+ UI views' b = f a
75+ in
76+ UI (views <> views') b
77+
78+instance Monoid children => Monad (UIWith children msg)
79+
80+column :: forall msg a. UI msg a -> UI msg a
81+column (UI { nerves, meat, children } a) =
82+ UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Column children } ] } a
83+
84+row :: forall msg a. UI msg a -> UI msg a
85+row (UI { nerves, meat, children } a) =
86+ UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Row children } ] } a
87+
88+stack :: forall msg a. UI msg a -> UI msg a
89+stack (UI { nerves, meat, children } a) =
90+ UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Stack children } ] } a
91+
92+text :: forall msg. String -> UIWith Unit msg Unit -> UI msg Unit
93+text s (UI { nerves, meat } a) = UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Text s } ] } a
94+
95+link :: forall msg a. String -> UI msg a -> UI msg a
96+link url (UI { nerves, meat, children } a) = UI
97+ (mempty :: UIView msg)
98+ { children =
99+ [ { meat
100+ , nerves
101+ , bones: Link url { newTab: false } (Maybe.fromMaybe none $ Array.head children)
102+ }
103+ ]
104+ }
105+ a
106+
107+el :: forall msg a. UI msg a -> UI msg a
108+el (UI { nerves, meat, children } a) = UI
109+ (mempty :: UIView msg)
110+ { children =
111+ [ { meat
112+ , nerves
113+ , bones: Wrapper (Maybe.fromMaybe none $ Array.head children)
114+ }
115+ ]
116+ }
117+ a
118+
119+newTabLink :: forall msg a. String -> UI msg a -> UI msg a
120+newTabLink url (UI { nerves, meat, children } a) = UI
121+ (mempty :: UIView msg)
122+ { children =
123+ [ { meat
124+ , nerves
125+ , bones: Link url { newTab: true } (Maybe.fromMaybe none $ Array.head children)
126+ }
127+ ]
128+ }
129+ a
130+
131+download :: forall msg a. String -> UI msg a -> UI msg a
132+download url (UI { nerves, meat, children } a) = UI
133+ (mempty :: UIView msg)
134+ { children =
135+ [ { meat
136+ , nerves
137+ , bones: Download url { filename: Nothing } (Maybe.fromMaybe none $ Array.head children)
138+ }
139+ ]
140+ }
141+ a
142+
143+downloadAs :: forall msg a. String -> { filename :: String } -> UI msg a -> UI msg a
144+downloadAs url { filename } (UI { nerves, meat, children } a) = UI
145+ (mempty :: UIView msg)
146+ { children =
147+ [ { meat
148+ , nerves
149+ , bones: Download url { filename: Just filename } (Maybe.fromMaybe none $ Array.head children)
150+ }
151+ ]
152+ }
153+ a
154+
155+image :: forall msg a. String -> { description :: String } -> UIWith Unit msg a -> UI msg a
156+image url description (UI { nerves, meat } a) =
157+ UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Image url description } ] } a
158+
33h :: String -> Skin -> Array VNode -> VNode
159h :: String -> Skin -> Array VNode -> VNode
34−h el (Skin styles) children = Maquette.h el { styles } children
160+h elem (Skin styles) children = Maquette.h elem { styles } children
35
161
36hWith :: forall props. String -> Record props -> Skin -> Array VNode -> VNode
162hWith :: forall props. String -> Record props -> Skin -> Array VNode -> VNode
37−hWith el props (Skin styles) children = Maquette.h el (Record.unsafeUnion props { styles }) children
163+hWith elem props (Skin styles) children = Maquette.h elem (Record.unsafeUnion props { styles }) children
38
164
39data Length = Px Int | Fill | Fit | Max Int Length | Min Int Length
165data Length = Px Int | Fill | Fit | Max Int Length | Min Int Length
40
166
@@ -42,6 +168,15 @@ data Alignment = Start | Center | End
42
168
43data Direction = X | Y
169data Direction = X | Y
44
170
171+meat :: forall ch msg a. Monoid ch => Monoid a => Meat -> UIWith ch msg a
172+meat m = UI (mempty :: UIViewWith ch msg) { meat = [ m ] } mempty
173+
174+spacing :: forall ch msg a. Monoid ch => Monoid a => { x :: Int, y :: Int } -> UIWith ch msg a
175+spacing { x, y } = meat $ Spacing x y
176+
177+explain :: forall ch msg a. Monoid ch => Monoid a => UIWith ch msg a
178+explain = meat Explain
179+
45data Meat
180data Meat
46 = Spacing Int Int
181 = Spacing Int Int
47 | Explain
182 | Explain
@@ -61,6 +196,9 @@ data Nerve msg = OnClick msg
61
196
62type View msg = { nerves :: Array (Nerve msg), meat :: Array Meat, bones :: Bones msg }
197type View msg = { nerves :: Array (Nerve msg), meat :: Array Meat, bones :: Bones msg }
63
198
199+none :: forall msg. View msg
200+none = { nerves: [], meat: [], bones: None }
201+
64view :: forall msg. Array (Nerve msg) -> Array Meat -> Bones msg -> View msg
202view :: forall msg. Array (Nerve msg) -> Array Meat -> Bones msg -> View msg
65view nerves meat bones = { nerves, meat, bones }
203view nerves meat bones = { nerves, meat, bones }
66
204
@@ -162,6 +300,7 @@ data Bones msg
162 | Link String { newTab :: Boolean } (View msg)
300 | Link String { newTab :: Boolean } (View msg)
163 | Download String { filename :: Maybe String } (View msg)
301 | Download String { filename :: Maybe String } (View msg)
164 | Image String { description :: String }
302 | Image String { description :: String }
303+ | None
165
304
166newtype Mutation = Mutation { extraSkin :: Skin }
305newtype Mutation = Mutation { extraSkin :: Skin }
167
306
@@ -215,6 +354,7 @@ growSkin fire (Mutation mutation) { meat, bones } =
215 (skn (Flexbox X) <> sk "display" "flex" <> sk "flex-direction" "row")
354 (skn (Flexbox X) <> sk "display" "flex" <> sk "flex-direction" "row")
216 [ growSkin fire mempty child ]
355 [ growSkin fire mempty child ]
217 Image src { description } -> hWith "img" { src, alt: description } (skn Generic) []
356 Image src { description } -> hWith "img" { src, alt: description } (skn Generic) []
357+ None -> h "div" mempty []
218
358
219grow :: forall msg. (msg -> Effect Unit) -> View msg -> VNode
359grow :: forall msg. (msg -> Effect Unit) -> View msg -> VNode
220grow fire v = growSkin fire mempty v
360grow fire v = growSkin fire mempty v