From 1f20521f032d8029f29eae326dd393dececfcb7f Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 20 Jul 2017 17:26:48 +0400 Subject: [PATCH 01/72] drag not working version --- bower.json | 28 + example/example.js | 9983 ++++++++++++++++++++++++ example/index.html | 74 + example/src/Main.purs | 54 + package.json | 12 + src/ColorPicker/Halogen/Component.purs | 187 + 6 files changed, 10338 insertions(+) create mode 100644 bower.json create mode 100644 example/example.js create mode 100644 example/index.html create mode 100644 example/src/Main.purs create mode 100644 package.json create mode 100644 src/ColorPicker/Halogen/Component.purs diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..a94c67e --- /dev/null +++ b/bower.json @@ -0,0 +1,28 @@ +{ + "name": "purescript-colorpicker-halogen", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git://github.com/slamdata/purescript-colorpicker-halogen.git" + }, + "authors": [ + "Irakli Safareli " + ], + "ignore": [ + "**/.*", + "bower_components", + "node_modules", + "output", + "tests", + "tmp", + "bower.json", + "package.json", + "example" + ], + "dependencies": { + "purescript-colors": "^3.0.0", + "purescript-halogen": "^2.1.0", + "purescript-halogen-css": "^6.0.0", + "purescript-dom-classy": "^2.1.0" + } +} diff --git a/example/example.js b/example/example.js new file mode 100644 index 0000000..ca1e0f4 --- /dev/null +++ b/example/example.js @@ -0,0 +1,9983 @@ +// Generated by psc-bundle 0.11.6 +var PS = {}; +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Semigroupoid = function (compose) { + this.compose = compose; + }; + var semigroupoidFn = new Semigroupoid(function (f) { + return function (g) { + return function (x) { + return f(g(x)); + }; + }; + }); + var compose = function (dict) { + return dict.compose; + }; + exports["Semigroupoid"] = Semigroupoid; + exports["compose"] = compose; + exports["semigroupoidFn"] = semigroupoidFn; +})(PS["Control.Semigroupoid"] = PS["Control.Semigroupoid"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Category = function (Semigroupoid0, id) { + this.Semigroupoid0 = Semigroupoid0; + this.id = id; + }; + var id = function (dict) { + return dict.id; + }; + var categoryFn = new Category(function () { + return Control_Semigroupoid.semigroupoidFn; + }, function (x) { + return x; + }); + exports["Category"] = Category; + exports["id"] = id; + exports["categoryFn"] = categoryFn; +})(PS["Control.Category"] = PS["Control.Category"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Prelude = PS["Prelude"]; + var IsString = function (fromString) { + this.fromString = fromString; + }; + var fromString = function (dict) { + return dict.fromString; + }; + exports["IsString"] = IsString; + exports["fromString"] = fromString; +})(PS["CSS.String"] = PS["CSS.String"] || {}); +(function(exports) { + "use strict"; + + exports.arrayApply = function (fs) { + return function (xs) { + var result = []; + var n = 0; + for (var i = 0, l = fs.length; i < l; i++) { + for (var j = 0, k = xs.length; j < k; j++) { + result[n++] = fs[i](xs[j]); + } + } + return result; + }; + }; +})(PS["Control.Apply"] = PS["Control.Apply"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var flip = function (f) { + return function (b) { + return function (a) { + return f(a)(b); + }; + }; + }; + var $$const = function (a) { + return function (v) { + return a; + }; + }; + var applyFlipped = function (x) { + return function (f) { + return f(x); + }; + }; + exports["applyFlipped"] = applyFlipped; + exports["const"] = $$const; + exports["flip"] = flip; +})(PS["Data.Function"] = PS["Data.Function"] || {}); +(function(exports) { + "use strict"; + + exports.arrayMap = function (f) { + return function (arr) { + var l = arr.length; + var result = new Array(l); + for (var i = 0; i < l; i++) { + result[i] = f(arr[i]); + } + return result; + }; + }; +})(PS["Data.Functor"] = PS["Data.Functor"] || {}); +(function(exports) { + "use strict"; + + exports.unit = {}; +})(PS["Data.Unit"] = PS["Data.Unit"] || {}); +(function(exports) { + "use strict"; + + exports.showNumberImpl = function (n) { + var str = n.toString(); + return isNaN(str + ".0") ? str : str + ".0"; + }; +})(PS["Data.Show"] = PS["Data.Show"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Show"]; + var Show = function (show) { + this.show = show; + }; + var showNumber = new Show($foreign.showNumberImpl); + var show = function (dict) { + return dict.show; + }; + exports["Show"] = Show; + exports["show"] = show; + exports["showNumber"] = showNumber; +})(PS["Data.Show"] = PS["Data.Show"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Unit"]; + var Data_Show = PS["Data.Show"]; + exports["unit"] = $foreign.unit; +})(PS["Data.Unit"] = PS["Data.Unit"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Functor"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Function = PS["Data.Function"]; + var Data_Unit = PS["Data.Unit"]; + var Functor = function (map) { + this.map = map; + }; + var map = function (dict) { + return dict.map; + }; + var $$void = function (dictFunctor) { + return map(dictFunctor)(Data_Function["const"](Data_Unit.unit)); + }; + var voidLeft = function (dictFunctor) { + return function (f) { + return function (x) { + return map(dictFunctor)(Data_Function["const"](x))(f); + }; + }; + }; + var functorFn = new Functor(Control_Semigroupoid.compose(Control_Semigroupoid.semigroupoidFn)); + var functorArray = new Functor($foreign.arrayMap); + exports["Functor"] = Functor; + exports["map"] = map; + exports["void"] = $$void; + exports["voidLeft"] = voidLeft; + exports["functorFn"] = functorFn; + exports["functorArray"] = functorArray; +})(PS["Data.Functor"] = PS["Data.Functor"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Apply = function (Functor0, apply) { + this.Functor0 = Functor0; + this.apply = apply; + }; + var applyArray = new Apply(function () { + return Data_Functor.functorArray; + }, $foreign.arrayApply); + var apply = function (dict) { + return dict.apply; + }; + var applySecond = function (dictApply) { + return function (a) { + return function (b) { + return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"](Control_Category.id(Control_Category.categoryFn)))(a))(b); + }; + }; + }; + var lift2 = function (dictApply) { + return function (f) { + return function (a) { + return function (b) { + return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b); + }; + }; + }; + }; + exports["Apply"] = Apply; + exports["apply"] = apply; + exports["applySecond"] = applySecond; + exports["lift2"] = lift2; + exports["applyArray"] = applyArray; +})(PS["Control.Apply"] = PS["Control.Apply"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Apply = PS["Control.Apply"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Unit = PS["Data.Unit"]; + var Applicative = function (Apply0, pure) { + this.Apply0 = Apply0; + this.pure = pure; + }; + var pure = function (dict) { + return dict.pure; + }; + var when = function (dictApplicative) { + return function (v) { + return function (v1) { + if (v) { + return v1; + }; + if (!v) { + return pure(dictApplicative)(Data_Unit.unit); + }; + throw new Error("Failed pattern match at Control.Applicative line 57, column 1 - line 57, column 63: " + [ v.constructor.name, v1.constructor.name ]); + }; + }; + }; + var liftA1 = function (dictApplicative) { + return function (f) { + return function (a) { + return Control_Apply.apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a); + }; + }; + }; + exports["Applicative"] = Applicative; + exports["liftA1"] = liftA1; + exports["pure"] = pure; + exports["when"] = when; +})(PS["Control.Applicative"] = PS["Control.Applicative"] || {}); +(function(exports) { + "use strict"; + + exports.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; + }; + }; +})(PS["Control.Bind"] = PS["Control.Bind"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Bind"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Unit = PS["Data.Unit"]; + var Bind = function (Apply0, bind) { + this.Apply0 = Apply0; + this.bind = bind; + }; + var Discard = function (discard) { + this.discard = discard; + }; + var discard = function (dict) { + return dict.discard; + }; + var bindArray = new Bind(function () { + return Control_Apply.applyArray; + }, $foreign.arrayBind); + var bind = function (dict) { + return dict.bind; + }; + var bindFlipped = function (dictBind) { + return Data_Function.flip(bind(dictBind)); + }; + var composeKleisliFlipped = function (dictBind) { + return function (f) { + return function (g) { + return function (a) { + return bindFlipped(dictBind)(f)(g(a)); + }; + }; + }; + }; + var discardUnit = new Discard(function (dictBind) { + return bind(dictBind); + }); + exports["Bind"] = Bind; + exports["Discard"] = Discard; + exports["bind"] = bind; + exports["bindFlipped"] = bindFlipped; + exports["composeKleisliFlipped"] = composeKleisliFlipped; + exports["discard"] = discard; + exports["bindArray"] = bindArray; + exports["discardUnit"] = discardUnit; +})(PS["Control.Bind"] = PS["Control.Bind"] || {}); +(function(exports) { + "use strict"; + + exports.fromFoldableImpl = (function () { + // jshint maxparams: 2 + 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 ------------------------------------------------------------------ + //------------------------------------------------------------------------------ + + exports.length = function (xs) { + return xs.length; + }; +})(PS["Data.Array"] = PS["Data.Array"] || {}); +(function(exports) { + "use strict"; + + exports.concatArray = function (xs) { + return function (ys) { + if (xs.length === 0) return ys; + if (ys.length === 0) return xs; + return xs.concat(ys); + }; + }; +})(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Semigroup"]; + var Data_Unit = PS["Data.Unit"]; + var Data_Void = PS["Data.Void"]; + var Semigroup = function (append) { + this.append = append; + }; + var semigroupArray = new Semigroup($foreign.concatArray); + var append = function (dict) { + return dict.append; + }; + var semigroupFn = function (dictSemigroup) { + return new Semigroup(function (f) { + return function (g) { + return function (x) { + return append(dictSemigroup)(f(x))(g(x)); + }; + }; + }); + }; + exports["Semigroup"] = Semigroup; + exports["append"] = append; + exports["semigroupFn"] = semigroupFn; + exports["semigroupArray"] = semigroupArray; +})(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Functor = PS["Data.Functor"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Alt = function (Functor0, alt) { + this.Functor0 = Functor0; + this.alt = alt; + }; + var alt = function (dict) { + return dict.alt; + }; + exports["Alt"] = Alt; + exports["alt"] = alt; +})(PS["Control.Alt"] = PS["Control.Alt"] || {}); +(function(exports) { + "use strict"; + + exports.pureE = function (a) { + return function () { + return a; + }; + }; + + exports.bindE = function (a) { + return function (f) { + return function () { + return f(a())(); + }; + }; + }; + + exports.runPure = function (f) { + return f(); + }; + + exports.foreachE = function (as) { + return function (f) { + return function () { + for (var i = 0, l = as.length; i < l; i++) { + f(as[i])(); + } + }; + }; + }; +})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Unit = PS["Data.Unit"]; + var Monad = function (Applicative0, Bind1) { + this.Applicative0 = Applicative0; + this.Bind1 = Bind1; + }; + var ap = function (dictMonad) { + return function (f) { + return function (a) { + return Control_Bind.bind(dictMonad.Bind1())(f)(function (v) { + return Control_Bind.bind(dictMonad.Bind1())(a)(function (v1) { + return Control_Applicative.pure(dictMonad.Applicative0())(v(v1)); + }); + }); + }; + }; + }; + exports["Monad"] = Monad; + exports["ap"] = ap; +})(PS["Control.Monad"] = PS["Control.Monad"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Eff"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad = PS["Control.Monad"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Unit = PS["Data.Unit"]; + var monadEff = new Control_Monad.Monad(function () { + return applicativeEff; + }, function () { + return bindEff; + }); + var bindEff = new Control_Bind.Bind(function () { + return applyEff; + }, $foreign.bindE); + var applyEff = new Control_Apply.Apply(function () { + return functorEff; + }, Control_Monad.ap(monadEff)); + var applicativeEff = new Control_Applicative.Applicative(function () { + return applyEff; + }, $foreign.pureE); + var functorEff = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEff)); + exports["functorEff"] = functorEff; + exports["applyEff"] = applyEff; + exports["applicativeEff"] = applicativeEff; + exports["bindEff"] = bindEff; + exports["monadEff"] = monadEff; + exports["foreachE"] = $foreign.foreachE; + exports["runPure"] = $foreign.runPure; +})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}); +(function(exports) { + "use strict"; + + exports.unsafeCoerceEff = function (f) { + return f; + }; +})(PS["Control.Monad.Eff.Unsafe"] = PS["Control.Monad.Eff.Unsafe"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Eff.Unsafe"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + exports["unsafeCoerceEff"] = $foreign.unsafeCoerceEff; +})(PS["Control.Monad.Eff.Unsafe"] = PS["Control.Monad.Eff.Unsafe"] || {}); +(function(exports) { + "use strict"; + + exports.newSTRef = function (val) { + return function () { + return { value: val }; + }; + }; + + exports.readSTRef = function (ref) { + return function () { + return ref.value; + }; + }; +})(PS["Control.Monad.ST"] = PS["Control.Monad.ST"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.ST"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + exports["newSTRef"] = $foreign.newSTRef; + exports["readSTRef"] = $foreign.readSTRef; +})(PS["Control.Monad.ST"] = PS["Control.Monad.ST"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Bifunctor = function (bimap) { + this.bimap = bimap; + }; + var bimap = function (dict) { + return dict.bimap; + }; + var rmap = function (dictBifunctor) { + return bimap(dictBifunctor)(Control_Category.id(Control_Category.categoryFn)); + }; + exports["Bifunctor"] = Bifunctor; + exports["bimap"] = bimap; + exports["rmap"] = rmap; +})(PS["Data.Bifunctor"] = PS["Data.Bifunctor"] || {}); +(function(exports) { + "use strict"; + + exports.topInt = 2147483647; + exports.bottomInt = -2147483648; +})(PS["Data.Bounded"] = PS["Data.Bounded"] || {}); +(function(exports) { + "use strict"; + + exports.refEq = function (r1) { + return function (r2) { + return r1 === r2; + }; + }; +})(PS["Data.Eq"] = PS["Data.Eq"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Eq"]; + var Data_Unit = PS["Data.Unit"]; + var Data_Void = PS["Data.Void"]; + var Eq = function (eq) { + this.eq = eq; + }; + var eqVoid = new Eq(function (v) { + return function (v1) { + return true; + }; + }); + var eqString = new Eq($foreign.refEq); + var eqNumber = new Eq($foreign.refEq); + var eqInt = new Eq($foreign.refEq); + var eq = function (dict) { + return dict.eq; + }; + exports["Eq"] = Eq; + exports["eq"] = eq; + exports["eqInt"] = eqInt; + exports["eqNumber"] = eqNumber; + exports["eqString"] = eqString; + exports["eqVoid"] = eqVoid; +})(PS["Data.Eq"] = PS["Data.Eq"] || {}); +(function(exports) { + "use strict"; + + exports.unsafeCompareImpl = function (lt) { + return function (eq) { + return function (gt) { + return function (x) { + return function (y) { + return x < y ? lt : x === y ? eq : gt; + }; + }; + }; + }; + }; +})(PS["Data.Ord.Unsafe"] = PS["Data.Ord.Unsafe"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Eq = PS["Data.Eq"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var LT = (function () { + function LT() { + + }; + LT.value = new LT(); + return LT; + })(); + var GT = (function () { + function GT() { + + }; + GT.value = new GT(); + return GT; + })(); + var EQ = (function () { + function EQ() { + + }; + EQ.value = new EQ(); + return EQ; + })(); + exports["LT"] = LT; + exports["GT"] = GT; + exports["EQ"] = EQ; +})(PS["Data.Ordering"] = PS["Data.Ordering"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Ord.Unsafe"]; + var Data_Ordering = PS["Data.Ordering"]; + var unsafeCompare = $foreign.unsafeCompareImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value); + exports["unsafeCompare"] = unsafeCompare; +})(PS["Data.Ord.Unsafe"] = PS["Data.Ord.Unsafe"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Ord"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Ord_Unsafe = PS["Data.Ord.Unsafe"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Unit = PS["Data.Unit"]; + var Data_Void = PS["Data.Void"]; + var Ord = function (Eq0, compare) { + this.Eq0 = Eq0; + this.compare = compare; + }; + var ordVoid = new Ord(function () { + return Data_Eq.eqVoid; + }, function (v) { + return function (v1) { + return Data_Ordering.EQ.value; + }; + }); + var ordNumber = new Ord(function () { + return Data_Eq.eqNumber; + }, Data_Ord_Unsafe.unsafeCompare); + var ordInt = new Ord(function () { + return Data_Eq.eqInt; + }, Data_Ord_Unsafe.unsafeCompare); + var compare = function (dict) { + return dict.compare; + }; + var max = function (dictOrd) { + return function (x) { + return function (y) { + var v = compare(dictOrd)(x)(y); + if (v instanceof Data_Ordering.LT) { + return y; + }; + if (v instanceof Data_Ordering.EQ) { + return x; + }; + if (v instanceof Data_Ordering.GT) { + return x; + }; + throw new Error("Failed pattern match at Data.Ord line 123, column 3 - line 126, column 12: " + [ v.constructor.name ]); + }; + }; + }; + var min = function (dictOrd) { + return function (x) { + return function (y) { + var v = compare(dictOrd)(x)(y); + if (v instanceof Data_Ordering.LT) { + return x; + }; + if (v instanceof Data_Ordering.EQ) { + return x; + }; + if (v instanceof Data_Ordering.GT) { + return y; + }; + throw new Error("Failed pattern match at Data.Ord line 114, column 3 - line 117, column 12: " + [ v.constructor.name ]); + }; + }; + }; + var clamp = function (dictOrd) { + return function (low) { + return function (hi) { + return function (x) { + return min(dictOrd)(hi)(max(dictOrd)(low)(x)); + }; + }; + }; + }; + exports["Ord"] = Ord; + exports["clamp"] = clamp; + exports["compare"] = compare; + exports["max"] = max; + exports["min"] = min; + exports["ordInt"] = ordInt; + exports["ordNumber"] = ordNumber; + exports["ordVoid"] = ordVoid; +})(PS["Data.Ord"] = PS["Data.Ord"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Bounded"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Unit = PS["Data.Unit"]; + var Bounded = function (Ord0, bottom, top) { + this.Ord0 = Ord0; + this.bottom = bottom; + this.top = top; + }; + var top = function (dict) { + return dict.top; + }; + var boundedInt = new Bounded(function () { + return Data_Ord.ordInt; + }, $foreign.bottomInt, $foreign.topInt); + var bottom = function (dict) { + return dict.bottom; + }; + exports["Bounded"] = Bounded; + exports["bottom"] = bottom; + exports["top"] = top; + exports["boundedInt"] = boundedInt; +})(PS["Data.Bounded"] = PS["Data.Bounded"] || {}); +(function(exports) { + "use strict"; + + exports.foldrArray = function (f) { + return function (init) { + return function (xs) { + var acc = init; + var len = xs.length; + for (var i = len - 1; i >= 0; i--) { + acc = f(xs[i])(acc); + } + return acc; + }; + }; + }; + + exports.foldlArray = function (f) { + return function (init) { + return function (xs) { + var acc = init; + var len = xs.length; + for (var i = 0; i < len; i++) { + acc = f(acc)(xs[i]); + } + return acc; + }; + }; + }; +})(PS["Data.Foldable"] = PS["Data.Foldable"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Data_Functor = PS["Data.Functor"]; + var Plus = function (Alt0, empty) { + this.Alt0 = Alt0; + this.empty = empty; + }; + var empty = function (dict) { + return dict.empty; + }; + exports["Plus"] = Plus; + exports["empty"] = empty; +})(PS["Control.Plus"] = PS["Control.Plus"] || {}); +(function(exports) { + "use strict"; + + exports.boolConj = function (b1) { + return function (b2) { + return b1 && b2; + }; + }; + + exports.boolDisj = function (b1) { + return function (b2) { + return b1 || b2; + }; + }; + + exports.boolNot = function (b) { + return !b; + }; +})(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.HeytingAlgebra"]; + var Data_Unit = PS["Data.Unit"]; + var HeytingAlgebra = function (conj, disj, ff, implies, not, tt) { + this.conj = conj; + this.disj = disj; + this.ff = ff; + this.implies = implies; + this.not = not; + this.tt = tt; + }; + var tt = function (dict) { + return dict.tt; + }; + var not = function (dict) { + return dict.not; + }; + var implies = function (dict) { + return dict.implies; + }; + var ff = function (dict) { + return dict.ff; + }; + var disj = function (dict) { + return dict.disj; + }; + var heytingAlgebraBoolean = new HeytingAlgebra($foreign.boolConj, $foreign.boolDisj, false, function (a) { + return function (b) { + return disj(heytingAlgebraBoolean)(not(heytingAlgebraBoolean)(a))(b); + }; + }, $foreign.boolNot, true); + var conj = function (dict) { + return dict.conj; + }; + var heytingAlgebraFunction = function (dictHeytingAlgebra) { + return new HeytingAlgebra(function (f) { + return function (g) { + return function (a) { + return conj(dictHeytingAlgebra)(f(a))(g(a)); + }; + }; + }, function (f) { + return function (g) { + return function (a) { + return disj(dictHeytingAlgebra)(f(a))(g(a)); + }; + }; + }, function (v) { + return ff(dictHeytingAlgebra); + }, function (f) { + return function (g) { + return function (a) { + return implies(dictHeytingAlgebra)(f(a))(g(a)); + }; + }; + }, function (f) { + return function (a) { + return not(dictHeytingAlgebra)(f(a)); + }; + }, function (v) { + return tt(dictHeytingAlgebra); + }); + }; + exports["HeytingAlgebra"] = HeytingAlgebra; + exports["conj"] = conj; + exports["disj"] = disj; + exports["ff"] = ff; + exports["implies"] = implies; + exports["not"] = not; + exports["tt"] = tt; + exports["heytingAlgebraBoolean"] = heytingAlgebraBoolean; + exports["heytingAlgebraFunction"] = heytingAlgebraFunction; +})(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var otherwise = true; + exports["otherwise"] = otherwise; +})(PS["Data.Boolean"] = PS["Data.Boolean"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Eq = PS["Data.Eq"]; + var Data_EuclideanRing = PS["Data.EuclideanRing"]; + var Data_Function = PS["Data.Function"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Monoid = function (Semigroup0, mempty) { + this.Semigroup0 = Semigroup0; + this.mempty = mempty; + }; + var monoidArray = new Monoid(function () { + return Data_Semigroup.semigroupArray; + }, [ ]); + var mempty = function (dict) { + return dict.mempty; + }; + var monoidFn = function (dictMonoid) { + return new Monoid(function () { + return Data_Semigroup.semigroupFn(dictMonoid.Semigroup0()); + }, Data_Function["const"](mempty(dictMonoid))); + }; + exports["Monoid"] = Monoid; + exports["mempty"] = mempty; + exports["monoidFn"] = monoidFn; + exports["monoidArray"] = monoidArray; +})(PS["Data.Monoid"] = PS["Data.Monoid"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Monad = PS["Control.Monad"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Plus = PS["Control.Plus"]; + var Data_Bounded = PS["Data.Bounded"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Nothing = (function () { + function Nothing() { + + }; + Nothing.value = new Nothing(); + return Nothing; + })(); + var Just = (function () { + function Just(value0) { + this.value0 = value0; + }; + Just.create = function (value0) { + return new Just(value0); + }; + return Just; + })(); + var maybe = function (v) { + return function (v1) { + return function (v2) { + if (v2 instanceof Nothing) { + return v; + }; + if (v2 instanceof Just) { + return v1(v2.value0); + }; + throw new Error("Failed pattern match at Data.Maybe line 219, column 1 - line 219, column 51: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); + }; + }; + }; + var isNothing = maybe(true)(Data_Function["const"](false)); + var isJust = maybe(false)(Data_Function["const"](true)); + var functorMaybe = new Data_Functor.Functor(function (v) { + return function (v1) { + if (v1 instanceof Just) { + return new Just(v(v1.value0)); + }; + return Nothing.value; + }; + }); + var fromMaybe = function (a) { + return maybe(a)(Control_Category.id(Control_Category.categoryFn)); + }; + exports["Nothing"] = Nothing; + exports["Just"] = Just; + exports["fromMaybe"] = fromMaybe; + exports["isJust"] = isJust; + exports["isNothing"] = isNothing; + exports["maybe"] = maybe; + exports["functorMaybe"] = functorMaybe; +})(PS["Data.Maybe"] = PS["Data.Maybe"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Prelude = PS["Prelude"]; + var Newtype = function (unwrap, wrap) { + this.unwrap = unwrap; + this.wrap = wrap; + }; + var wrap = function (dict) { + return dict.wrap; + }; + var unwrap = function (dict) { + return dict.unwrap; + }; + var under = function (dictNewtype) { + return function (dictNewtype1) { + return function (v) { + return function (f) { + return function ($55) { + return unwrap(dictNewtype1)(f(wrap(dictNewtype)($55))); + }; + }; + }; + }; + }; + exports["Newtype"] = Newtype; + exports["under"] = under; + exports["unwrap"] = unwrap; + exports["wrap"] = wrap; +})(PS["Data.Newtype"] = PS["Data.Newtype"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Monad = PS["Control.Monad"]; + var Data_Bounded = PS["Data.Bounded"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Prelude = PS["Prelude"]; + var First = function (x) { + return x; + }; + var semigroupFirst = new Data_Semigroup.Semigroup(function (v) { + return function (v1) { + if (v instanceof Data_Maybe.Just) { + return v; + }; + return v1; + }; + }); + var newtypeFirst = new Data_Newtype.Newtype(function (n) { + return n; + }, First); + var monoidFirst = new Data_Monoid.Monoid(function () { + return semigroupFirst; + }, Data_Maybe.Nothing.value); + exports["First"] = First; + exports["newtypeFirst"] = newtypeFirst; + exports["semigroupFirst"] = semigroupFirst; + exports["monoidFirst"] = monoidFirst; +})(PS["Data.Maybe.First"] = PS["Data.Maybe.First"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Foldable"]; + var Control_Alt = PS["Control.Alt"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Plus = PS["Control.Plus"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Maybe_First = PS["Data.Maybe.First"]; + var Data_Maybe_Last = PS["Data.Maybe.Last"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Monoid_Additive = PS["Data.Monoid.Additive"]; + var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; + var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; + var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; + var Data_Monoid_Endo = PS["Data.Monoid.Endo"]; + var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Foldable = function (foldMap, foldl, foldr) { + this.foldMap = foldMap; + this.foldl = foldl; + this.foldr = foldr; + }; + var foldr = function (dict) { + return dict.foldr; + }; + var traverse_ = function (dictApplicative) { + return function (dictFoldable) { + return function (f) { + return foldr(dictFoldable)(function ($181) { + return Control_Apply.applySecond(dictApplicative.Apply0())(f($181)); + })(Control_Applicative.pure(dictApplicative)(Data_Unit.unit)); + }; + }; + }; + var for_ = function (dictApplicative) { + return function (dictFoldable) { + return Data_Function.flip(traverse_(dictApplicative)(dictFoldable)); + }; + }; + var sequence_ = function (dictApplicative) { + return function (dictFoldable) { + return traverse_(dictApplicative)(dictFoldable)(Control_Category.id(Control_Category.categoryFn)); + }; + }; + var foldl = function (dict) { + return dict.foldl; + }; + var foldableMaybe = new Foldable(function (dictMonoid) { + return function (f) { + return function (v) { + if (v instanceof Data_Maybe.Nothing) { + return Data_Monoid.mempty(dictMonoid); + }; + if (v instanceof Data_Maybe.Just) { + return f(v.value0); + }; + throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ f.constructor.name, v.constructor.name ]); + }; + }; + }, function (v) { + return function (z) { + return function (v1) { + if (v1 instanceof Data_Maybe.Nothing) { + return z; + }; + if (v1 instanceof Data_Maybe.Just) { + return v(z)(v1.value0); + }; + throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); + }; + }; + }, function (v) { + return function (z) { + return function (v1) { + if (v1 instanceof Data_Maybe.Nothing) { + return z; + }; + if (v1 instanceof Data_Maybe.Just) { + return v(v1.value0)(z); + }; + throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); + }; + }; + }); + var foldMapDefaultR = function (dictFoldable) { + return function (dictMonoid) { + return function (f) { + return foldr(dictFoldable)(function (x) { + return function (acc) { + return Data_Semigroup.append(dictMonoid.Semigroup0())(f(x))(acc); + }; + })(Data_Monoid.mempty(dictMonoid)); + }; + }; + }; + var foldableArray = new Foldable(function (dictMonoid) { + return foldMapDefaultR(foldableArray)(dictMonoid); + }, $foreign.foldlArray, $foreign.foldrArray); + var foldMap = function (dict) { + return dict.foldMap; + }; + exports["Foldable"] = Foldable; + exports["foldMap"] = foldMap; + exports["foldMapDefaultR"] = foldMapDefaultR; + exports["foldl"] = foldl; + exports["foldr"] = foldr; + exports["for_"] = for_; + exports["sequence_"] = sequence_; + exports["traverse_"] = traverse_; + exports["foldableArray"] = foldableArray; + exports["foldableMaybe"] = foldableMaybe; +})(PS["Data.Foldable"] = PS["Data.Foldable"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Monad = PS["Control.Monad"]; + var Data_Bifoldable = PS["Data.Bifoldable"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Bitraversable = PS["Data.Bitraversable"]; + var Data_Bounded = PS["Data.Bounded"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Prelude = PS["Prelude"]; + var Left = (function () { + function Left(value0) { + this.value0 = value0; + }; + Left.create = function (value0) { + return new Left(value0); + }; + return Left; + })(); + var Right = (function () { + function Right(value0) { + this.value0 = value0; + }; + Right.create = function (value0) { + return new Right(value0); + }; + return Right; + })(); + var functorEither = new Data_Functor.Functor(function (v) { + return function (v1) { + if (v1 instanceof Left) { + return new Left(v1.value0); + }; + if (v1 instanceof Right) { + return new Right(v(v1.value0)); + }; + throw new Error("Failed pattern match at Data.Either line 36, column 1 - line 36, column 45: " + [ v.constructor.name, v1.constructor.name ]); + }; + }); + var foldableEither = new Data_Foldable.Foldable(function (dictMonoid) { + return function (f) { + return function (v) { + if (v instanceof Left) { + return Data_Monoid.mempty(dictMonoid); + }; + if (v instanceof Right) { + return f(v.value0); + }; + throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ f.constructor.name, v.constructor.name ]); + }; + }; + }, function (v) { + return function (z) { + return function (v1) { + if (v1 instanceof Left) { + return z; + }; + if (v1 instanceof Right) { + return v(z)(v1.value0); + }; + throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); + }; + }; + }, function (v) { + return function (z) { + return function (v1) { + if (v1 instanceof Left) { + return z; + }; + if (v1 instanceof Right) { + return v(v1.value0)(z); + }; + throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); + }; + }; + }); + var eqEither = function (dictEq) { + return function (dictEq1) { + return new Data_Eq.Eq(function (x) { + return function (y) { + if (x instanceof Left && y instanceof Left) { + return Data_Eq.eq(dictEq)(x.value0)(y.value0); + }; + if (x instanceof Right && y instanceof Right) { + return Data_Eq.eq(dictEq1)(x.value0)(y.value0); + }; + return false; + }; + }); + }; + }; + var ordEither = function (dictOrd) { + return function (dictOrd1) { + return new Data_Ord.Ord(function () { + return eqEither(dictOrd.Eq0())(dictOrd1.Eq0()); + }, function (x) { + return function (y) { + if (x instanceof Left && y instanceof Left) { + return Data_Ord.compare(dictOrd)(x.value0)(y.value0); + }; + if (x instanceof Left) { + return Data_Ordering.LT.value; + }; + if (y instanceof Left) { + return Data_Ordering.GT.value; + }; + if (x instanceof Right && y instanceof Right) { + return Data_Ord.compare(dictOrd1)(x.value0)(y.value0); + }; + throw new Error("Failed pattern match at Data.Either line 176, column 8 - line 176, column 64: " + [ x.constructor.name, y.constructor.name ]); + }; + }); + }; + }; + var either = function (v) { + return function (v1) { + return function (v2) { + if (v2 instanceof Left) { + return v(v2.value0); + }; + if (v2 instanceof Right) { + return v1(v2.value0); + }; + throw new Error("Failed pattern match at Data.Either line 229, column 1 - line 229, column 64: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); + }; + }; + }; + var bifunctorEither = new Data_Bifunctor.Bifunctor(function (v) { + return function (v1) { + return function (v2) { + if (v2 instanceof Left) { + return new Left(v(v2.value0)); + }; + if (v2 instanceof Right) { + return new Right(v1(v2.value0)); + }; + throw new Error("Failed pattern match at Data.Either line 43, column 1 - line 43, column 45: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); + }; + }; + }); + var applyEither = new Control_Apply.Apply(function () { + return functorEither; + }, function (v) { + return function (v1) { + if (v instanceof Left) { + return new Left(v.value0); + }; + if (v instanceof Right) { + return Data_Functor.map(functorEither)(v.value0)(v1); + }; + throw new Error("Failed pattern match at Data.Either line 79, column 1 - line 79, column 41: " + [ v.constructor.name, v1.constructor.name ]); + }; + }); + exports["Left"] = Left; + exports["Right"] = Right; + exports["either"] = either; + exports["functorEither"] = functorEither; + exports["bifunctorEither"] = bifunctorEither; + exports["applyEither"] = applyEither; + exports["eqEither"] = eqEither; + exports["ordEither"] = ordEither; + exports["foldableEither"] = foldableEither; +})(PS["Data.Either"] = PS["Data.Either"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Comonad = PS["Control.Comonad"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Lazy = PS["Control.Lazy"]; + var Control_Monad = PS["Control.Monad"]; + var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; + var Data_Bounded = PS["Data.Bounded"]; + var Data_CommutativeRing = PS["Data.CommutativeRing"]; + var Data_Eq = PS["Data.Eq"]; + var Data_EuclideanRing = PS["Data.EuclideanRing"]; + var Data_Field = PS["Data.Field"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Prelude = PS["Prelude"]; + var Identity = function (x) { + return x; + }; + var newtypeIdentity = new Data_Newtype.Newtype(function (n) { + return n; + }, Identity); + var functorIdentity = new Data_Functor.Functor(function (f) { + return function (v) { + return f(v); + }; + }); + var applyIdentity = new Control_Apply.Apply(function () { + return functorIdentity; + }, function (v) { + return function (v1) { + return v(v1); + }; + }); + var bindIdentity = new Control_Bind.Bind(function () { + return applyIdentity; + }, function (v) { + return function (f) { + return f(v); + }; + }); + var applicativeIdentity = new Control_Applicative.Applicative(function () { + return applyIdentity; + }, Identity); + var monadIdentity = new Control_Monad.Monad(function () { + return applicativeIdentity; + }, function () { + return bindIdentity; + }); + exports["Identity"] = Identity; + exports["newtypeIdentity"] = newtypeIdentity; + exports["functorIdentity"] = functorIdentity; + exports["applyIdentity"] = applyIdentity; + exports["applicativeIdentity"] = applicativeIdentity; + exports["bindIdentity"] = bindIdentity; + exports["monadIdentity"] = monadIdentity; +})(PS["Data.Identity"] = PS["Data.Identity"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; + var Control_Monad_ST = PS["Control.Monad.ST"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Either = PS["Data.Either"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Unit = PS["Data.Unit"]; + var Partial_Unsafe = PS["Partial.Unsafe"]; + var Prelude = PS["Prelude"]; + var Loop = (function () { + function Loop(value0) { + this.value0 = value0; + }; + Loop.create = function (value0) { + return new Loop(value0); + }; + return Loop; + })(); + var Done = (function () { + function Done(value0) { + this.value0 = value0; + }; + Done.create = function (value0) { + return new Done(value0); + }; + return Done; + })(); + var MonadRec = function (Monad0, tailRecM) { + this.Monad0 = Monad0; + this.tailRecM = tailRecM; + }; + var tailRecM = function (dict) { + return dict.tailRecM; + }; + var tailRecEff = function (f) { + return function (a) { + var fromDone = function (v) { + var __unused = function (dictPartial1) { + return function ($dollar16) { + return $dollar16; + }; + }; + return __unused()((function () { + if (v instanceof Done) { + return v.value0; + }; + throw new Error("Failed pattern match at Control.Monad.Rec.Class line 141, column 28 - line 141, column 42: " + [ v.constructor.name ]); + })()); + }; + var f$prime = function ($52) { + return Control_Monad_Eff_Unsafe.unsafeCoerceEff(f($52)); + }; + return function __do() { + var v = Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Control_Monad_ST.newSTRef)(f$prime(a))(); + (function () { + while (!(function __do() { + var v1 = v.value; + if (v1 instanceof Loop) { + var v2 = f$prime(v1.value0)(); + var v3 = v.value = v2; + return false; + }; + if (v1 instanceof Done) { + return true; + }; + throw new Error("Failed pattern match at Control.Monad.Rec.Class line 130, column 5 - line 135, column 26: " + [ v1.constructor.name ]); + })()) { + + }; + return {}; + })(); + return Data_Functor.map(Control_Monad_Eff.functorEff)(fromDone)(Control_Monad_ST.readSTRef(v))(); + }; + }; + }; + var monadRecEff = new MonadRec(function () { + return Control_Monad_Eff.monadEff; + }, tailRecEff); + exports["Loop"] = Loop; + exports["Done"] = Done; + exports["MonadRec"] = MonadRec; + exports["tailRecM"] = tailRecM; + exports["monadRecEff"] = monadRecEff; +})(PS["Control.Monad.Rec.Class"] = PS["Control.Monad.Rec.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Control_Plus = PS["Control.Plus"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Prelude = PS["Prelude"]; + var NonEmpty = (function () { + function NonEmpty(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + NonEmpty.create = function (value0) { + return function (value1) { + return new NonEmpty(value0, value1); + }; + }; + return NonEmpty; + })(); + var singleton = function (dictPlus) { + return function (a) { + return new NonEmpty(a, Control_Plus.empty(dictPlus)); + }; + }; + var functorNonEmpty = function (dictFunctor) { + return new Data_Functor.Functor(function (f) { + return function (v) { + return new NonEmpty(f(v.value0), Data_Functor.map(dictFunctor)(f)(v.value1)); + }; + }); + }; + exports["NonEmpty"] = NonEmpty; + exports["singleton"] = singleton; + exports["functorNonEmpty"] = functorNonEmpty; +})(PS["Data.NonEmpty"] = PS["Data.NonEmpty"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Biapplicative = PS["Control.Biapplicative"]; + var Control_Biapply = PS["Control.Biapply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Comonad = PS["Control.Comonad"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Lazy = PS["Control.Lazy"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifoldable = PS["Data.Bifoldable"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Bitraversable = PS["Data.Bitraversable"]; + var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; + var Data_Bounded = PS["Data.Bounded"]; + var Data_CommutativeRing = PS["Data.CommutativeRing"]; + var Data_Distributive = PS["Data.Distributive"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Maybe_First = PS["Data.Maybe.First"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Type_Equality = PS["Type.Equality"]; + var Tuple = (function () { + function Tuple(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Tuple.create = function (value0) { + return function (value1) { + return new Tuple(value0, value1); + }; + }; + return Tuple; + })(); + var snd = function (v) { + return v.value1; + }; + var lookup = function (dictFoldable) { + return function (dictEq) { + return function (a) { + return function ($264) { + return Data_Newtype.unwrap(Data_Maybe_First.newtypeFirst)(Data_Foldable.foldMap(dictFoldable)(Data_Maybe_First.monoidFirst)(function (v) { + var $146 = Data_Eq.eq(dictEq)(a)(v.value0); + if ($146) { + return new Data_Maybe.Just(v.value1); + }; + return Data_Maybe.Nothing.value; + })($264)); + }; + }; + }; + }; + var functorTuple = new Data_Functor.Functor(function (f) { + return function (v) { + return new Tuple(v.value0, f(v.value1)); + }; + }); + var fst = function (v) { + return v.value0; + }; + exports["Tuple"] = Tuple; + exports["fst"] = fst; + exports["lookup"] = lookup; + exports["snd"] = snd; + exports["functorTuple"] = functorTuple; +})(PS["Data.Tuple"] = PS["Data.Tuple"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Array"]; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Lazy = PS["Control.Lazy"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_ST = PS["Control.Monad.ST"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Array_ST = PS["Data.Array.ST"]; + var Data_Array_ST_Iterator = PS["Data.Array.ST.Iterator"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var Partial_Unsafe = PS["Partial.Unsafe"]; + var Prelude = PS["Prelude"]; + var singleton = function (a) { + return [ a ]; + }; + var fromFoldable = function (dictFoldable) { + return $foreign.fromFoldableImpl(Data_Foldable.foldr(dictFoldable)); + }; + var concatMap = Data_Function.flip(Control_Bind.bind(Control_Bind.bindArray)); + var mapMaybe = function (f) { + return concatMap(function ($94) { + return Data_Maybe.maybe([ ])(singleton)(f($94)); + }); + }; + exports["concatMap"] = concatMap; + exports["fromFoldable"] = fromFoldable; + exports["mapMaybe"] = mapMaybe; + exports["singleton"] = singleton; + exports["length"] = $foreign.length; +})(PS["Data.Array"] = PS["Data.Array"] || {}); +(function(exports) { + "use strict"; + + // module Data.Int + + exports.fromNumberImpl = function (just) { + return function (nothing) { + return function (n) { + /* jshint bitwise: false */ + return (n | 0) === n ? just(n) : nothing; + }; + }; + }; + + exports.toNumber = function (n) { + return n; + }; +})(PS["Data.Int"] = PS["Data.Int"] || {}); +(function(exports) { + /* globals exports */ + "use strict"; + + exports.infinity = Infinity; +})(PS["Global"] = PS["Global"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Global"]; + exports["infinity"] = $foreign.infinity; +})(PS["Global"] = PS["Global"] || {}); +(function(exports) { + "use strict"; + + // module Math + + exports.abs = Math.abs; + + exports.remainder = function (n) { + return function (m) { + return n % m; + }; + }; + + exports.round = Math.round; +})(PS["Math"] = PS["Math"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Math"]; + exports["abs"] = $foreign.abs; + exports["remainder"] = $foreign.remainder; + exports["round"] = $foreign.round; +})(PS["Math"] = PS["Math"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Int"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Bounded = PS["Data.Bounded"]; + var Data_Eq = PS["Data.Eq"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Int_Bits = PS["Data.Int.Bits"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Show = PS["Data.Show"]; + var Global = PS["Global"]; + var $$Math = PS["Math"]; + var Prelude = PS["Prelude"]; + var fromNumber = $foreign.fromNumberImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); + var unsafeClamp = function (x) { + if (x === Global.infinity) { + return 0; + }; + if (x === -Global.infinity) { + return 0; + }; + if (x >= $foreign.toNumber(Data_Bounded.top(Data_Bounded.boundedInt))) { + return Data_Bounded.top(Data_Bounded.boundedInt); + }; + if (x <= $foreign.toNumber(Data_Bounded.bottom(Data_Bounded.boundedInt))) { + return Data_Bounded.bottom(Data_Bounded.boundedInt); + }; + if (Data_Boolean.otherwise) { + return Data_Maybe.fromMaybe(0)(fromNumber(x)); + }; + throw new Error("Failed pattern match at Data.Int line 64, column 1 - line 64, column 29: " + [ x.constructor.name ]); + }; + var round = function ($13) { + return unsafeClamp($$Math.round($13)); + }; + exports["fromNumber"] = fromNumber; + exports["round"] = round; + exports["toNumber"] = $foreign.toNumber; +})(PS["Data.Int"] = PS["Data.Int"] || {}); +(function(exports) { + "use strict"; + + exports.joinWith = function (s) { + return function (xs) { + return xs.join(s); + }; + }; +})(PS["Data.String"] = PS["Data.String"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.String"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_String_Unsafe = PS["Data.String.Unsafe"]; + var Prelude = PS["Prelude"]; + exports["joinWith"] = $foreign.joinWith; +})(PS["Data.String"] = PS["Data.String"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Array = PS["Data.Array"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_EuclideanRing = PS["Data.EuclideanRing"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Int = PS["Data.Int"]; + var Data_Int_Bits = PS["Data.Int.Bits"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_String = PS["Data.String"]; + var Data_String_Regex = PS["Data.String.Regex"]; + var $$Math = PS["Math"]; + var Partial_Unsafe = PS["Partial.Unsafe"]; + var Prelude = PS["Prelude"]; + var HSLA = (function () { + function HSLA(value0, value1, value2, value3) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + }; + HSLA.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return new HSLA(value0, value1, value2, value3); + }; + }; + }; + }; + return HSLA; + })(); + var toRGBA$prime = function (v) { + var h$prime = v.value0 / 60.0; + var chr = (1.0 - $$Math.abs(2.0 * v.value2 - 1.0)) * v.value1; + var m = v.value2 - chr / 2.0; + var x = chr * (1.0 - $$Math.abs($$Math.remainder(h$prime)(2.0) - 1.0)); + var col = (function () { + if (h$prime < 1.0) { + return { + r: chr, + g: x, + b: 0.0 + }; + }; + if (1.0 <= h$prime && h$prime < 2.0) { + return { + r: x, + g: chr, + b: 0.0 + }; + }; + if (2.0 <= h$prime && h$prime < 3.0) { + return { + r: 0.0, + g: chr, + b: x + }; + }; + if (3.0 <= h$prime && h$prime < 4.0) { + return { + r: 0.0, + g: x, + b: chr + }; + }; + if (4.0 <= h$prime && h$prime < 5.0) { + return { + r: x, + g: 0.0, + b: chr + }; + }; + if (Data_Boolean.otherwise) { + return { + r: chr, + g: 0.0, + b: x + }; + }; + throw new Error("Failed pattern match at Color line 301, column 5 - line 306, column 61: " + [ ]); + })(); + return { + r: col.r + m, + g: col.g + m, + b: col.b + m, + a: v.value3 + }; + }; + var toHSLA = function (v) { + return { + h: v.value0, + s: v.value1, + l: v.value2, + a: v.value3 + }; + }; + var modPos = function (x) { + return function (y) { + return $$Math.remainder($$Math.remainder(x)(y) + y)(y); + }; + }; + var hsla = function (h) { + return function (s) { + return function (l) { + return function (a) { + var s$prime = Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(s); + var l$prime = Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(l); + var h$prime = modPos(h)(360.0); + var a$prime = Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(a); + return new HSLA(h$prime, s$prime, l$prime, a$prime); + }; + }; + }; + }; + var hsl = function (h) { + return function (s) { + return function (l) { + return hsla(h)(s)(l)(1.0); + }; + }; + }; + var white = hsl(0.0)(0.0)(1.0); + var cssStringHSLA = function (v) { + var toString = function (n) { + return Data_Show.show(Data_Show.showNumber)(Data_Int.toNumber(Data_Int.round(100.0 * n)) / 100.0); + }; + var saturation = toString(v.value1 * 100.0) + "%"; + var lightness = toString(v.value2 * 100.0) + "%"; + var hue = toString(v.value0); + var alpha = Data_Show.show(Data_Show.showNumber)(v.value3); + var $72 = v.value3 === 1.0; + if ($72) { + return "hsl(" + (hue + (", " + (saturation + (", " + (lightness + ")"))))); + }; + return "hsla(" + (hue + (", " + (saturation + (", " + (lightness + (", " + (alpha + ")"))))))); + }; + var brightness = function (col) { + var c = toRGBA$prime(col); + return (299.0 * c.r + 587.0 * c.g + 114.0 * c.b) / 1000.0; + }; + var isLight = function (c) { + return brightness(c) > 0.5; + }; + var black = hsl(0.0)(0.0)(0.0); + exports["black"] = black; + exports["brightness"] = brightness; + exports["cssStringHSLA"] = cssStringHSLA; + exports["hsl"] = hsl; + exports["hsla"] = hsla; + exports["isLight"] = isLight; + exports["toHSLA"] = toHSLA; + exports["white"] = white; +})(PS["Color"] = PS["Color"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Prelude = PS["Prelude"]; + var Profunctor = function (dimap) { + this.dimap = dimap; + }; + var profunctorFn = new Profunctor(function (a2b) { + return function (c2d) { + return function (b2c) { + return function ($9) { + return c2d(b2c(a2b($9))); + }; + }; + }; + }); + var dimap = function (dict) { + return dict.dimap; + }; + var rmap = function (dictProfunctor) { + return function (b2c) { + return dimap(dictProfunctor)(Control_Category.id(Control_Category.categoryFn))(b2c); + }; + }; + exports["Profunctor"] = Profunctor; + exports["dimap"] = dimap; + exports["rmap"] = rmap; + exports["profunctorFn"] = profunctorFn; +})(PS["Data.Profunctor"] = PS["Data.Profunctor"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Data_Tuple = PS["Data.Tuple"]; + var Prelude = PS["Prelude"]; + var Strong = function (Profunctor0, first, second) { + this.Profunctor0 = Profunctor0; + this.first = first; + this.second = second; + }; + var strongFn = new Strong(function () { + return Data_Profunctor.profunctorFn; + }, function (a2b) { + return function (v) { + return new Data_Tuple.Tuple(a2b(v.value0), v.value1); + }; + }, Data_Functor.map(Data_Tuple.functorTuple)); + var second = function (dict) { + return dict.second; + }; + var first = function (dict) { + return dict.first; + }; + exports["Strong"] = Strong; + exports["first"] = first; + exports["second"] = second; + exports["strongFn"] = strongFn; +})(PS["Data.Profunctor.Strong"] = PS["Data.Profunctor.Strong"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_String = PS["CSS.String"]; + var Color = PS["Color"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Generic = PS["Data.Generic"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Profunctor_Strong = PS["Data.Profunctor.Strong"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Prefixed = (function () { + function Prefixed(value0) { + this.value0 = value0; + }; + Prefixed.create = function (value0) { + return new Prefixed(value0); + }; + return Prefixed; + })(); + var Plain = (function () { + function Plain(value0) { + this.value0 = value0; + }; + Plain.create = function (value0) { + return new Plain(value0); + }; + return Plain; + })(); + var Value = function (x) { + return x; + }; + var Key = function (x) { + return x; + }; + var Val = function (value) { + this.value = value; + }; + var value = function (dict) { + return dict.value; + }; + var semigroupPrefixed = new Data_Semigroup.Semigroup(function (v) { + return function (v1) { + if (v instanceof Plain && v1 instanceof Plain) { + return Plain.create(v.value0 + v1.value0); + }; + if (v instanceof Plain && v1 instanceof Prefixed) { + return Prefixed.create(Data_Functor.map(Data_Functor.functorArray)(Data_Profunctor_Strong.second(Data_Profunctor_Strong.strongFn)(function (v2) { + return v.value0 + v2; + }))(v1.value0)); + }; + if (v instanceof Prefixed && v1 instanceof Plain) { + return Prefixed.create(Data_Functor.map(Data_Functor.functorArray)(Data_Profunctor_Strong.second(Data_Profunctor_Strong.strongFn)(function (v2) { + return v1.value0 + v2; + }))(v.value0)); + }; + if (v instanceof Prefixed && v1 instanceof Prefixed) { + return Prefixed.create(Data_Semigroup.append(Data_Semigroup.semigroupArray)(v.value0)(v1.value0)); + }; + throw new Error("Failed pattern match at CSS.Property line 25, column 1 - line 25, column 49: " + [ v.constructor.name, v1.constructor.name ]); + }; + }); + var semigroupValue = new Data_Semigroup.Semigroup(function (v) { + return function (v1) { + return Value(Data_Semigroup.append(semigroupPrefixed)(v)(v1)); + }; + }); + var isStringPrefixed = new CSS_String.IsString(Plain.create); + var isStringValue = new CSS_String.IsString(function ($145) { + return Value(CSS_String.fromString(isStringPrefixed)($145)); + }); + var valColor = new Val(function ($147) { + return CSS_String.fromString(isStringValue)(Color.cssStringHSLA($147)); + }); + var valNumber = new Val(function ($150) { + return CSS_String.fromString(isStringValue)(Data_Show.show(Data_Show.showNumber)($150)); + }); + var isStringKey = new CSS_String.IsString(function ($151) { + return Key(CSS_String.fromString(isStringPrefixed)($151)); + }); + var cast = function (v) { + return v; + }; + exports["Key"] = Key; + exports["Prefixed"] = Prefixed; + exports["Plain"] = Plain; + exports["Value"] = Value; + exports["Val"] = Val; + exports["cast"] = cast; + exports["value"] = value; + exports["isStringPrefixed"] = isStringPrefixed; + exports["semigroupPrefixed"] = semigroupPrefixed; + exports["isStringKey"] = isStringKey; + exports["isStringValue"] = isStringValue; + exports["semigroupValue"] = semigroupValue; + exports["valNumber"] = valNumber; + exports["valColor"] = valColor; +})(PS["CSS.Property"] = PS["CSS.Property"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Common = PS["CSS.Common"]; + var CSS_Property = PS["CSS.Property"]; + var CSS_String = PS["CSS.String"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Generic = PS["Data.Generic"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var valSize = new CSS_Property.Val(function (v) { + return v; + }); + var pct = function (i) { + return Data_Semigroup.append(CSS_Property.semigroupValue)(CSS_Property.value(CSS_Property.valNumber)(i))(CSS_String.fromString(CSS_Property.isStringValue)("%")); + }; + exports["pct"] = pct; + exports["valSize"] = valSize; +})(PS["CSS.Size"] = PS["CSS.Size"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Data_Function = PS["Data.Function"]; + var Data_Tuple = PS["Data.Tuple"]; + var Prelude = PS["Prelude"]; + var MonadTell = function (Monad0, tell) { + this.Monad0 = Monad0; + this.tell = tell; + }; + var tell = function (dict) { + return dict.tell; + }; + exports["MonadTell"] = MonadTell; + exports["tell"] = tell; +})(PS["Control.Monad.Writer.Class"] = PS["Control.Monad.Writer.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var MonadEff = function (Monad0, liftEff) { + this.Monad0 = Monad0; + this.liftEff = liftEff; + }; + var monadEffEff = new MonadEff(function () { + return Control_Monad_Eff.monadEff; + }, Control_Category.id(Control_Category.categoryFn)); + var liftEff = function (dict) { + return dict.liftEff; + }; + exports["MonadEff"] = MonadEff; + exports["liftEff"] = liftEff; + exports["monadEffEff"] = monadEffEff; +})(PS["Control.Monad.Eff.Class"] = PS["Control.Monad.Eff.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var MonadThrow = function (Monad0, throwError) { + this.Monad0 = Monad0; + this.throwError = throwError; + }; + var throwError = function (dict) { + return dict.throwError; + }; + exports["MonadThrow"] = MonadThrow; + exports["throwError"] = throwError; +})(PS["Control.Monad.Error.Class"] = PS["Control.Monad.Error.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var MonadState = function (Monad0, state) { + this.Monad0 = Monad0; + this.state = state; + }; + var state = function (dict) { + return dict.state; + }; + var modify = function (dictMonadState) { + return function (f) { + return state(dictMonadState)(function (s) { + return new Data_Tuple.Tuple(Data_Unit.unit, f(s)); + }); + }; + }; + var get = function (dictMonadState) { + return state(dictMonadState)(function (s) { + return new Data_Tuple.Tuple(s, s); + }); + }; + exports["MonadState"] = MonadState; + exports["get"] = get; + exports["modify"] = modify; + exports["state"] = state; +})(PS["Control.Monad.State.Class"] = PS["Control.Monad.State.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Prelude = PS["Prelude"]; + var MonadTrans = function (lift) { + this.lift = lift; + }; + var lift = function (dict) { + return dict.lift; + }; + exports["MonadTrans"] = MonadTrans; + exports["lift"] = lift; +})(PS["Control.Monad.Trans.Class"] = PS["Control.Monad.Trans.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; + var Control_MonadPlus = PS["Control.MonadPlus"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Plus = PS["Control.Plus"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var WriterT = function (x) { + return x; + }; + var runWriterT = function (v) { + return v; + }; + var mapWriterT = function (f) { + return function (v) { + return f(v); + }; + }; + var functorWriterT = function (dictFunctor) { + return new Data_Functor.Functor(function (f) { + return mapWriterT(Data_Functor.map(dictFunctor)(function (v) { + return new Data_Tuple.Tuple(f(v.value0), v.value1); + })); + }); + }; + var applyWriterT = function (dictSemigroup) { + return function (dictApply) { + return new Control_Apply.Apply(function () { + return functorWriterT(dictApply.Functor0()); + }, function (v) { + return function (v1) { + var k = function (v3) { + return function (v4) { + return new Data_Tuple.Tuple(v3.value0(v4.value0), Data_Semigroup.append(dictSemigroup)(v3.value1)(v4.value1)); + }; + }; + return Control_Apply.apply(dictApply)(Data_Functor.map(dictApply.Functor0())(k)(v))(v1); + }; + }); + }; + }; + var bindWriterT = function (dictSemigroup) { + return function (dictBind) { + return new Control_Bind.Bind(function () { + return applyWriterT(dictSemigroup)(dictBind.Apply0()); + }, function (v) { + return function (k) { + return WriterT(Control_Bind.bind(dictBind)(v)(function (v1) { + var v2 = k(v1.value0); + return Data_Functor.map((dictBind.Apply0()).Functor0())(function (v3) { + return new Data_Tuple.Tuple(v3.value0, Data_Semigroup.append(dictSemigroup)(v1.value1)(v3.value1)); + })(v2); + })); + }; + }); + }; + }; + var applicativeWriterT = function (dictMonoid) { + return function (dictApplicative) { + return new Control_Applicative.Applicative(function () { + return applyWriterT(dictMonoid.Semigroup0())(dictApplicative.Apply0()); + }, function (a) { + return WriterT(Control_Applicative.pure(dictApplicative)(new Data_Tuple.Tuple(a, Data_Monoid.mempty(dictMonoid)))); + }); + }; + }; + var monadWriterT = function (dictMonoid) { + return function (dictMonad) { + return new Control_Monad.Monad(function () { + return applicativeWriterT(dictMonoid)(dictMonad.Applicative0()); + }, function () { + return bindWriterT(dictMonoid.Semigroup0())(dictMonad.Bind1()); + }); + }; + }; + var monadTellWriterT = function (dictMonoid) { + return function (dictMonad) { + return new Control_Monad_Writer_Class.MonadTell(function () { + return monadWriterT(dictMonoid)(dictMonad); + }, function ($124) { + return WriterT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Tuple.Tuple.create(Data_Unit.unit)($124))); + }); + }; + }; + exports["WriterT"] = WriterT; + exports["mapWriterT"] = mapWriterT; + exports["runWriterT"] = runWriterT; + exports["functorWriterT"] = functorWriterT; + exports["applyWriterT"] = applyWriterT; + exports["applicativeWriterT"] = applicativeWriterT; + exports["bindWriterT"] = bindWriterT; + exports["monadWriterT"] = monadWriterT; + exports["monadTellWriterT"] = monadTellWriterT; +})(PS["Control.Monad.Writer.Trans"] = PS["Control.Monad.Writer.Trans"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; + var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Tuple = PS["Data.Tuple"]; + var Prelude = PS["Prelude"]; + var runWriter = function ($1) { + return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(Control_Monad_Writer_Trans.runWriterT($1)); + }; + var execWriter = function (m) { + return Data_Tuple.snd(runWriter(m)); + }; + exports["execWriter"] = execWriter; + exports["runWriter"] = runWriter; +})(PS["Control.Monad.Writer"] = PS["Control.Monad.Writer"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Property = PS["CSS.Property"]; + var CSS_Selector = PS["CSS.Selector"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Writer = PS["Control.Monad.Writer"]; + var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; + var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Array = PS["Data.Array"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Generic = PS["Data.Generic"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Profunctor_Strong = PS["Data.Profunctor.Strong"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Property = (function () { + function Property(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Property.create = function (value0) { + return function (value1) { + return new Property(value0, value1); + }; + }; + return Property; + })(); + var S = function (x) { + return x; + }; + var runS = function (v) { + return Control_Monad_Writer.execWriter(v); + }; + var rule = function ($438) { + return S(Control_Monad_Writer_Class.tell(Control_Monad_Writer_Trans.monadTellWriterT(Data_Monoid.monoidArray)(Data_Identity.monadIdentity))(Data_Array.singleton($438))); + }; + var key = function (dictVal) { + return function (k) { + return function (v) { + return rule(new Property(CSS_Property.cast(k), CSS_Property.value(dictVal)(v))); + }; + }; + }; + var functorStyleM = new Data_Functor.Functor(function (f) { + return function (v) { + return S(Data_Functor.map(Control_Monad_Writer_Trans.functorWriterT(Data_Identity.functorIdentity))(f)(v)); + }; + }); + var applyStyleM = new Control_Apply.Apply(function () { + return functorStyleM; + }, function (v) { + return function (v1) { + return S(Control_Apply.apply(Control_Monad_Writer_Trans.applyWriterT(Data_Semigroup.semigroupArray)(Data_Identity.applyIdentity))(v)(v1)); + }; + }); + var bindStyleM = new Control_Bind.Bind(function () { + return applyStyleM; + }, function (v) { + return function (f) { + return S(Control_Bind.bind(Control_Monad_Writer_Trans.bindWriterT(Data_Semigroup.semigroupArray)(Data_Identity.bindIdentity))(v)(function ($442) { + return (function (v1) { + return v1; + })(f($442)); + })); + }; + }); + exports["Property"] = Property; + exports["S"] = S; + exports["key"] = key; + exports["rule"] = rule; + exports["runS"] = runS; + exports["functorStyleM"] = functorStyleM; + exports["applyStyleM"] = applyStyleM; + exports["bindStyleM"] = bindStyleM; +})(PS["CSS.Stylesheet"] = PS["CSS.Stylesheet"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Box = PS["CSS.Box"]; + var CSS_Color = PS["CSS.Color"]; + var CSS_Common = PS["CSS.Common"]; + var CSS_Property = PS["CSS.Property"]; + var CSS_Size = PS["CSS.Size"]; + var CSS_String = PS["CSS.String"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Generic = PS["Data.Generic"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var backgroundColor = CSS_Stylesheet.key(CSS_Property.valColor)(CSS_String.fromString(CSS_Property.isStringKey)("background-color")); + exports["backgroundColor"] = backgroundColor; +})(PS["CSS.Background"] = PS["CSS.Background"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Color = PS["CSS.Color"]; + var CSS_Property = PS["CSS.Property"]; + var CSS_Size = PS["CSS.Size"]; + var CSS_String = PS["CSS.String"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Control_Apply = PS["Control.Apply"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Generic = PS["Data.Generic"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Tuple_Nested = PS["Data.Tuple.Nested"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var borderColor = CSS_Stylesheet.key(CSS_Property.valColor)(CSS_String.fromString(CSS_Property.isStringKey)("border-color")); + exports["borderColor"] = borderColor; +})(PS["CSS.Border"] = PS["CSS.Border"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Common = PS["CSS.Common"]; + var CSS_Property = PS["CSS.Property"]; + var CSS_String = PS["CSS.String"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Control_Apply = PS["Control.Apply"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Generic = PS["Data.Generic"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Show = PS["Data.Show"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Display = function (x) { + return x; + }; + var valDisplay = new CSS_Property.Val(function (v) { + return v; + }); + var displayNone = Display(CSS_String.fromString(CSS_Property.isStringValue)("none")); + var display = CSS_Stylesheet.key(valDisplay)(CSS_String.fromString(CSS_Property.isStringKey)("display")); + exports["Display"] = Display; + exports["display"] = display; + exports["displayNone"] = displayNone; + exports["valDisplay"] = valDisplay; +})(PS["CSS.Display"] = PS["CSS.Display"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Property = PS["CSS.Property"]; + var CSS_Size = PS["CSS.Size"]; + var CSS_String = PS["CSS.String"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Data_Function = PS["Data.Function"]; + var Data_Tuple_Nested = PS["Data.Tuple.Nested"]; + var top = CSS_Stylesheet.key(CSS_Size.valSize)(CSS_String.fromString(CSS_Property.isStringKey)("top")); + exports["top"] = top; +})(PS["CSS.Geometry"] = PS["CSS.Geometry"] || {}); +(function(exports) { + "use strict"; + + exports.warn = function (s) { + return function () { + console.warn(s); + return {}; + }; + }; +})(PS["Control.Monad.Eff.Console"] = PS["Control.Monad.Eff.Console"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Eff.Console"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Data_Show = PS["Data.Show"]; + var Data_Unit = PS["Data.Unit"]; + exports["warn"] = $foreign.warn; +})(PS["Control.Monad.Eff.Console"] = PS["Control.Monad.Eff.Console"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Property = PS["CSS.Property"]; + var CSS_Selector = PS["CSS.Selector"]; + var CSS_String = PS["CSS.String"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Console = PS["Control.Monad.Eff.Console"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Array = PS["Data.Array"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Generic = PS["Data.Generic"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_These = PS["Data.These"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var collect$prime = function (v) { + return function (v1) { + if (v instanceof CSS_Property.Plain && v1 instanceof CSS_Property.Plain) { + return [ new Data_Either.Right(new Data_Tuple.Tuple(v.value0, v1.value0)) ]; + }; + if (v instanceof CSS_Property.Prefixed && v1 instanceof CSS_Property.Plain) { + return Data_Functor.map(Data_Functor.functorArray)(function (v3) { + return Data_Either.Right.create(new Data_Tuple.Tuple(v3.value0 + v3.value1, v1.value0)); + })(v.value0); + }; + if (v instanceof CSS_Property.Plain && v1 instanceof CSS_Property.Prefixed) { + return Data_Functor.map(Data_Functor.functorArray)(function (v2) { + return Data_Either.Right.create(new Data_Tuple.Tuple(v.value0, v2.value0 + v2.value1)); + })(v1.value0); + }; + if (v instanceof CSS_Property.Prefixed && v1 instanceof CSS_Property.Prefixed) { + return Data_Functor.map(Data_Functor.functorArray)(function (v2) { + return Data_Maybe.maybe(new Data_Either.Left(v2.value0 + v2.value1))(function ($189) { + return Data_Either.Right.create(Data_Tuple.Tuple.create(v2.value0 + v2.value1)((function (v3) { + return v2.value0 + v3; + })($189))); + })(Data_Tuple.lookup(Data_Foldable.foldableArray)(Data_Eq.eqString)(v2.value0)(v1.value0)); + })(v.value0); + }; + throw new Error("Failed pattern match at CSS.Render line 161, column 1 - line 161, column 80: " + [ v.constructor.name, v1.constructor.name ]); + }; + }; + var collect = function (v) { + return collect$prime(v.value0)(v.value1); + }; + exports["collect"] = collect; +})(PS["CSS.Render"] = PS["CSS.Render"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; + var Control_MonadPlus = PS["Control.MonadPlus"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Plus = PS["Control.Plus"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Tuple = PS["Data.Tuple"]; + var Prelude = PS["Prelude"]; + var ExceptT = function (x) { + return x; + }; + var runExceptT = function (v) { + return v; + }; + var mapExceptT = function (f) { + return function (v) { + return f(v); + }; + }; + var functorExceptT = function (dictFunctor) { + return new Data_Functor.Functor(function (f) { + return mapExceptT(Data_Functor.map(dictFunctor)(Data_Functor.map(Data_Either.functorEither)(f))); + }); + }; + var except = function (dictApplicative) { + return function ($96) { + return ExceptT(Control_Applicative.pure(dictApplicative)($96)); + }; + }; + var monadExceptT = function (dictMonad) { + return new Control_Monad.Monad(function () { + return applicativeExceptT(dictMonad); + }, function () { + return bindExceptT(dictMonad); + }); + }; + var bindExceptT = function (dictMonad) { + return new Control_Bind.Bind(function () { + return applyExceptT(dictMonad); + }, function (v) { + return function (k) { + return Control_Bind.bind(dictMonad.Bind1())(v)(Data_Either.either(function ($97) { + return Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Left.create($97)); + })(function (a) { + var v1 = k(a); + return v1; + })); + }; + }); + }; + var applyExceptT = function (dictMonad) { + return new Control_Apply.Apply(function () { + return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0()); + }, Control_Monad.ap(monadExceptT(dictMonad))); + }; + var applicativeExceptT = function (dictMonad) { + return new Control_Applicative.Applicative(function () { + return applyExceptT(dictMonad); + }, function ($98) { + return ExceptT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Right.create($98))); + }); + }; + var monadThrowExceptT = function (dictMonad) { + return new Control_Monad_Error_Class.MonadThrow(function () { + return monadExceptT(dictMonad); + }, function ($102) { + return ExceptT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Left.create($102))); + }); + }; + exports["ExceptT"] = ExceptT; + exports["except"] = except; + exports["mapExceptT"] = mapExceptT; + exports["runExceptT"] = runExceptT; + exports["functorExceptT"] = functorExceptT; + exports["applyExceptT"] = applyExceptT; + exports["applicativeExceptT"] = applicativeExceptT; + exports["bindExceptT"] = bindExceptT; + exports["monadExceptT"] = monadExceptT; + exports["monadThrowExceptT"] = monadThrowExceptT; +})(PS["Control.Monad.Except.Trans"] = PS["Control.Monad.Except.Trans"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Newtype = PS["Data.Newtype"]; + var Prelude = PS["Prelude"]; + var runExcept = function ($0) { + return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(Control_Monad_Except_Trans.runExceptT($0)); + }; + exports["runExcept"] = runExcept; +})(PS["Control.Monad.Except"] = PS["Control.Monad.Except"] || {}); +(function(exports) { + "use strict"; + + exports.toForeign = function (value) { + return value; + }; + + exports.unsafeFromForeign = function (value) { + return value; + }; + + exports.typeOf = function (value) { + return typeof value; + }; + + exports.tagOf = function (value) { + return Object.prototype.toString.call(value).slice(8, -1); + }; +})(PS["Data.Foreign"] = PS["Data.Foreign"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Comonad = PS["Control.Comonad"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Monad = PS["Control.Monad"]; + var Control_MonadPlus = PS["Control.MonadPlus"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Plus = PS["Control.Plus"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semigroup_Foldable = PS["Data.Semigroup.Foldable"]; + var Data_Semigroup_Traversable = PS["Data.Semigroup.Traversable"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var Prelude = PS["Prelude"]; + var Nil = (function () { + function Nil() { + + }; + Nil.value = new Nil(); + return Nil; + })(); + var Cons = (function () { + function Cons(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Cons.create = function (value0) { + return function (value1) { + return new Cons(value0, value1); + }; + }; + return Cons; + })(); + var NonEmptyList = function (x) { + return x; + }; + var foldableList = new Data_Foldable.Foldable(function (dictMonoid) { + return function (f) { + return Data_Foldable.foldl(foldableList)(function (acc) { + return function ($143) { + return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f($143)); + }; + })(Data_Monoid.mempty(dictMonoid)); + }; + }, function (f) { + var go = function ($copy_b) { + return function ($copy_v) { + var $tco_var_b = $copy_b; + var $tco_done = false; + var $tco_result; + function $tco_loop(b, v) { + if (v instanceof Nil) { + $tco_done = true; + return b; + }; + if (v instanceof Cons) { + $tco_var_b = f(b)(v.value0); + $copy_v = v.value1; + return; + }; + throw new Error("Failed pattern match at Data.List.Types line 78, column 12 - line 80, column 30: " + [ v.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_b, $copy_v); + }; + return $tco_result; + }; + }; + return go; + }, function (f) { + return function (b) { + var rev = function ($copy_acc) { + return function ($copy_v) { + var $tco_var_acc = $copy_acc; + var $tco_done = false; + var $tco_result; + function $tco_loop(acc, v) { + if (v instanceof Nil) { + $tco_done = true; + return acc; + }; + if (v instanceof Cons) { + $tco_var_acc = new Cons(v.value0, acc); + $copy_v = v.value1; + return; + }; + throw new Error("Failed pattern match at Data.List.Types line 73, column 15 - line 75, column 33: " + [ v.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_acc, $copy_v); + }; + return $tco_result; + }; + }; + return function ($144) { + return Data_Foldable.foldl(foldableList)(Data_Function.flip(f))(b)(rev(Nil.value)($144)); + }; + }; + }); + var functorList = new Data_Functor.Functor(function (f) { + return Data_Foldable.foldr(foldableList)(function (x) { + return function (acc) { + return new Cons(f(x), acc); + }; + })(Nil.value); + }); + var functorNonEmptyList = Data_NonEmpty.functorNonEmpty(functorList); + var semigroupList = new Data_Semigroup.Semigroup(function (xs) { + return function (ys) { + return Data_Foldable.foldr(foldableList)(Cons.create)(ys)(xs); + }; + }); + var applyList = new Control_Apply.Apply(function () { + return functorList; + }, function (v) { + return function (v1) { + if (v instanceof Nil) { + return Nil.value; + }; + if (v instanceof Cons) { + return Data_Semigroup.append(semigroupList)(Data_Functor.map(functorList)(v.value0)(v1))(Control_Apply.apply(applyList)(v.value1)(v1)); + }; + throw new Error("Failed pattern match at Data.List.Types line 94, column 1 - line 94, column 33: " + [ v.constructor.name, v1.constructor.name ]); + }; + }); + var applyNonEmptyList = new Control_Apply.Apply(function () { + return functorNonEmptyList; + }, function (v) { + return function (v1) { + return new Data_NonEmpty.NonEmpty(v.value0(v1.value0), Data_Semigroup.append(semigroupList)(Control_Apply.apply(applyList)(v.value1)(new Cons(v1.value0, Nil.value)))(Control_Apply.apply(applyList)(new Cons(v.value0, v.value1))(v1.value1))); + }; + }); + var applicativeList = new Control_Applicative.Applicative(function () { + return applyList; + }, function (a) { + return new Cons(a, Nil.value); + }); + var altList = new Control_Alt.Alt(function () { + return functorList; + }, Data_Semigroup.append(semigroupList)); + var plusList = new Control_Plus.Plus(function () { + return altList; + }, Nil.value); + var applicativeNonEmptyList = new Control_Applicative.Applicative(function () { + return applyNonEmptyList; + }, function ($149) { + return NonEmptyList(Data_NonEmpty.singleton(plusList)($149)); + }); + exports["Nil"] = Nil; + exports["Cons"] = Cons; + exports["NonEmptyList"] = NonEmptyList; + exports["semigroupList"] = semigroupList; + exports["functorList"] = functorList; + exports["foldableList"] = foldableList; + exports["applyList"] = applyList; + exports["applicativeList"] = applicativeList; + exports["altList"] = altList; + exports["plusList"] = plusList; + exports["functorNonEmptyList"] = functorNonEmptyList; + exports["applyNonEmptyList"] = applyNonEmptyList; + exports["applicativeNonEmptyList"] = applicativeNonEmptyList; +})(PS["Data.List.Types"] = PS["Data.List.Types"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Lazy = PS["Control.Lazy"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var reverse = (function () { + var go = function ($copy_acc) { + return function ($copy_v) { + var $tco_var_acc = $copy_acc; + var $tco_done = false; + var $tco_result; + function $tco_loop(acc, v) { + if (v instanceof Data_List_Types.Nil) { + $tco_done = true; + return acc; + }; + if (v instanceof Data_List_Types.Cons) { + $tco_var_acc = new Data_List_Types.Cons(v.value0, acc); + $copy_v = v.value1; + return; + }; + throw new Error("Failed pattern match at Data.List line 365, column 3 - line 365, column 19: " + [ acc.constructor.name, v.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_acc, $copy_v); + }; + return $tco_result; + }; + }; + return go(Data_List_Types.Nil.value); + })(); + var $$null = function (v) { + if (v instanceof Data_List_Types.Nil) { + return true; + }; + return false; + }; + exports["null"] = $$null; + exports["reverse"] = reverse; +})(PS["Data.List"] = PS["Data.List"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_NonEmpty = PS["Data.NonEmpty"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semigroup_Foldable = PS["Data.Semigroup.Foldable"]; + var Data_Semigroup_Traversable = PS["Data.Semigroup.Traversable"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var Partial_Unsafe = PS["Partial.Unsafe"]; + var Prelude = PS["Prelude"]; + var singleton = function ($160) { + return Data_List_Types.NonEmptyList(Data_NonEmpty.singleton(Data_List_Types.plusList)($160)); + }; + exports["singleton"] = singleton; +})(PS["Data.List.NonEmpty"] = PS["Data.List.NonEmpty"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Foreign"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Except = PS["Control.Monad.Except"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Int = PS["Data.Int"]; + var Data_List_NonEmpty = PS["Data.List.NonEmpty"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_String = PS["Data.String"]; + var Prelude = PS["Prelude"]; + var TypeMismatch = (function () { + function TypeMismatch(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + TypeMismatch.create = function (value0) { + return function (value1) { + return new TypeMismatch(value0, value1); + }; + }; + return TypeMismatch; + })(); + var fail = function ($121) { + return Control_Monad_Error_Class.throwError(Control_Monad_Except_Trans.monadThrowExceptT(Data_Identity.monadIdentity))(Data_List_NonEmpty.singleton($121)); + }; + var unsafeReadTagged = function (tag) { + return function (value) { + if ($foreign.tagOf(value) === tag) { + return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))($foreign.unsafeFromForeign(value)); + }; + if (Data_Boolean.otherwise) { + return fail(new TypeMismatch(tag, $foreign.tagOf(value))); + }; + throw new Error("Failed pattern match at Data.Foreign line 104, column 1 - line 104, column 55: " + [ tag.constructor.name, value.constructor.name ]); + }; + }; + exports["TypeMismatch"] = TypeMismatch; + exports["fail"] = fail; + exports["unsafeReadTagged"] = unsafeReadTagged; + exports["toForeign"] = $foreign.toForeign; + exports["typeOf"] = $foreign.typeOf; +})(PS["Data.Foreign"] = PS["Data.Foreign"] || {}); +(function(exports) { + "use strict"; + + // module Unsafe.Coerce + + exports.unsafeCoerce = function (x) { + return x; + }; +})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Unsafe.Coerce"]; + exports["unsafeCoerce"] = $foreign.unsafeCoerce; +})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Monad_Except = PS["Control.Monad.Except"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function = PS["Data.Function"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var fromAny = function (f) { + return function ($0) { + return Data_Either.either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create)(Control_Monad_Except.runExcept(Unsafe_Coerce.unsafeCoerce(f)($0))); + }; + }; + exports["fromAny"] = fromAny; +})(PS["DOM.Classy.Util"] = PS["DOM.Classy.Util"] || {}); +(function(exports) { + "use strict"; + + exports.target = function (e) { + return e.target; + }; +})(PS["DOM.Event.Event"] = PS["DOM.Event.Event"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Event.Types"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Identity = PS["Data.Identity"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var touchEventToEvent = Unsafe_Coerce.unsafeCoerce; + var readTouchEvent = Data_Foreign.unsafeReadTagged("TouchEvent"); + var readMouseEvent = Data_Foreign.unsafeReadTagged("MouseEvent"); + var mouseEventToEvent = Unsafe_Coerce.unsafeCoerce; + exports["mouseEventToEvent"] = mouseEventToEvent; + exports["readMouseEvent"] = readMouseEvent; + exports["readTouchEvent"] = readTouchEvent; + exports["touchEventToEvent"] = touchEventToEvent; +})(PS["DOM.Event.Types"] = PS["DOM.Event.Types"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_Util_FFI = PS["DOM.Util.FFI"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var elementToNode = Unsafe_Coerce.unsafeCoerce; + exports["elementToNode"] = elementToNode; +})(PS["DOM.Node.Types"] = PS["DOM.Node.Types"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Event.Event"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Event_EventPhase = PS["DOM.Event.EventPhase"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Enum = PS["Data.Enum"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + exports["target"] = $foreign.target; +})(PS["DOM.Event.Event"] = PS["DOM.Event.Event"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Classy_Util = PS["DOM.Classy.Util"]; + var DOM_Event_Event = PS["DOM.Event.Event"]; + var DOM_Event_EventPhase = PS["DOM.Event.EventPhase"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_HTML_Event_Types = PS["DOM.HTML.Event.Types"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var DOM_Websocket_Event_Types = PS["DOM.Websocket.Event.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + var IsEvent = function (fromEvent, toEvent) { + this.fromEvent = fromEvent; + this.toEvent = toEvent; + }; + var toEvent = function (dict) { + return dict.toEvent; + }; + var target = function (dictIsEvent) { + return function ($15) { + return DOM_Event_Event.target(toEvent(dictIsEvent)($15)); + }; + }; + var isEventTouchEvent = new IsEvent(DOM_Classy_Util.fromAny(DOM_Event_Types.readTouchEvent), DOM_Event_Types.touchEventToEvent); + var isEventMouseEvent = new IsEvent(DOM_Classy_Util.fromAny(DOM_Event_Types.readMouseEvent), DOM_Event_Types.mouseEventToEvent); + var fromEvent = function (dict) { + return dict.fromEvent; + }; + exports["IsEvent"] = IsEvent; + exports["fromEvent"] = fromEvent; + exports["target"] = target; + exports["toEvent"] = toEvent; + exports["isEventMouseEvent"] = isEventMouseEvent; + exports["isEventTouchEvent"] = isEventTouchEvent; +})(PS["DOM.Classy.Event"] = PS["DOM.Classy.Event"] || {}); +(function(exports) { + "use strict"; + + exports._readHTMLElement = function (failure) { + return function (success) { + return function (value) { + var tag = Object.prototype.toString.call(value); + if (tag.indexOf("[object HTML") === 0 && tag.indexOf("Element]") === tag.length - 8) { + return success(value); + } else { + return failure(tag); + } + }; + }; + }; +})(PS["DOM.HTML.Types"] = PS["DOM.HTML.Types"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.HTML.Types"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Either = PS["Data.Either"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Identity = PS["Data.Identity"]; + var Data_List_Types = PS["Data.List.Types"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var windowToEventTarget = Unsafe_Coerce.unsafeCoerce; + var readHTMLElement = $foreign._readHTMLElement(function ($0) { + return Control_Monad_Except_Trans.except(Data_Identity.applicativeIdentity)(Data_Either.Left.create(Control_Applicative.pure(Data_List_Types.applicativeNonEmptyList)(Data_Foreign.TypeMismatch.create("HTMLElement")($0)))); + })(function ($1) { + return Control_Monad_Except_Trans.except(Data_Identity.applicativeIdentity)(Data_Either.Right.create($1)); + }); + var htmlElementToNode = Unsafe_Coerce.unsafeCoerce; + var htmlDocumentToParentNode = Unsafe_Coerce.unsafeCoerce; + var htmlDocumentToDocument = Unsafe_Coerce.unsafeCoerce; + exports["htmlDocumentToDocument"] = htmlDocumentToDocument; + exports["htmlDocumentToParentNode"] = htmlDocumentToParentNode; + exports["htmlElementToNode"] = htmlElementToNode; + exports["readHTMLElement"] = readHTMLElement; + exports["windowToEventTarget"] = windowToEventTarget; +})(PS["DOM.HTML.Types"] = PS["DOM.HTML.Types"] || {}); +(function(exports) { + "use strict"; + + var getEffProp = function (name) { + return function (node) { + return function () { + return node[name]; + }; + }; + }; + + exports._parentNode = getEffProp("parentNode"); + + exports._nextSibling = getEffProp("nextSibling"); + + exports.insertBefore = function (node1) { + return function (node2) { + return function (parent) { + return function () { + return parent.insertBefore(node1, node2); + }; + }; + }; + }; + + exports.appendChild = function (node) { + return function (parent) { + return function () { + return parent.appendChild(node); + }; + }; + }; + + exports.removeChild = function (node) { + return function (parent) { + return function () { + return parent.removeChild(node); + }; + }; + }; +})(PS["DOM.Node.Node"] = PS["DOM.Node.Node"] || {}); +(function(exports) { + "use strict"; + + exports["null"] = null; + + exports.nullable = function (a, r, f) { + return a == null ? r : f(a); + }; + + exports.notNull = function (x) { + return x; + }; +})(PS["Data.Nullable"] = PS["Data.Nullable"] || {}); +(function(exports) { + "use strict"; + + exports.runFn4 = function (fn) { + return function (a) { + return function (b) { + return function (c) { + return function (d) { + return fn(a, b, c, d); + }; + }; + }; + }; + }; +})(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Function.Uncurried"]; + var Data_Unit = PS["Data.Unit"]; + exports["runFn4"] = $foreign.runFn4; +})(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.Nullable"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Show = PS["Data.Show"]; + var Prelude = PS["Prelude"]; + var toNullable = Data_Maybe.maybe($foreign["null"])($foreign.notNull); + var toMaybe = function (n) { + return $foreign.nullable(n, Data_Maybe.Nothing.value, Data_Maybe.Just.create); + }; + exports["toMaybe"] = toMaybe; + exports["toNullable"] = toNullable; +})(PS["Data.Nullable"] = PS["Data.Nullable"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Node.Node"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Node_NodeType = PS["DOM.Node.NodeType"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Enum = PS["Data.Enum"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Nullable = PS["Data.Nullable"]; + var Prelude = PS["Prelude"]; + var parentNode = function ($2) { + return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Nullable.toMaybe)($foreign._parentNode($2)); + }; + var nextSibling = function ($6) { + return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Nullable.toMaybe)($foreign._nextSibling($6)); + }; + exports["nextSibling"] = nextSibling; + exports["parentNode"] = parentNode; + exports["appendChild"] = $foreign.appendChild; + exports["insertBefore"] = $foreign.insertBefore; + exports["removeChild"] = $foreign.removeChild; +})(PS["DOM.Node.Node"] = PS["DOM.Node.Node"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Classy_Util = PS["DOM.Classy.Util"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_Node_Node = PS["DOM.Node.Node"]; + var DOM_Node_NodeType = PS["DOM.Node.NodeType"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var IsNode = function (fromNode, toNode) { + this.fromNode = fromNode; + this.toNode = toNode; + }; + var toNode = function (dict) { + return dict.toNode; + }; + var isNodeHTMLElement = new IsNode(DOM_Classy_Util.fromAny(DOM_HTML_Types.readHTMLElement), Unsafe_Coerce.unsafeCoerce); + var fromNode = function (dict) { + return dict.fromNode; + }; + exports["IsNode"] = IsNode; + exports["fromNode"] = fromNode; + exports["toNode"] = toNode; + exports["isNodeHTMLElement"] = isNodeHTMLElement; +})(PS["DOM.Classy.Node"] = PS["DOM.Classy.Node"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Classy_Node = PS["DOM.Classy.Node"]; + var DOM_Classy_Util = PS["DOM.Classy.Util"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_Node_Element = PS["DOM.Node.Element"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var IsElement = function (IsNode0, fromElement, toElement) { + this.IsNode0 = IsNode0; + this.fromElement = fromElement; + this.toElement = toElement; + }; + var toElement = function (dict) { + return dict.toElement; + }; + var isElementHTMLElement = new IsElement(function () { + return DOM_Classy_Node.isNodeHTMLElement; + }, DOM_Classy_Util.fromAny(DOM_HTML_Types.readHTMLElement), Unsafe_Coerce.unsafeCoerce); + var fromElement = function (dict) { + return dict.fromElement; + }; + exports["IsElement"] = IsElement; + exports["fromElement"] = fromElement; + exports["toElement"] = toElement; + exports["isElementHTMLElement"] = isElementHTMLElement; +})(PS["DOM.Classy.Element"] = PS["DOM.Classy.Element"] || {}); +(function(exports) { + "use strict"; + + // - CSSOM --------------------------------------------------------------------- + + exports.getBoundingClientRect = function (el) { + return function () { + return el.getBoundingClientRect(); + }; + }; +})(PS["DOM.HTML.HTMLElement"] = PS["DOM.HTML.HTMLElement"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.HTML.HTMLElement"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Nullable = PS["Data.Nullable"]; + var Prelude = PS["Prelude"]; + exports["getBoundingClientRect"] = $foreign.getBoundingClientRect; +})(PS["DOM.HTML.HTMLElement"] = PS["DOM.HTML.HTMLElement"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Classy_Element = PS["DOM.Classy.Element"]; + var DOM_Classy_Util = PS["DOM.Classy.Util"]; + var DOM_HTML_HTMLElement = PS["DOM.HTML.HTMLElement"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var IsHTMLElement = function (IsElement0, fromHTMLElement, toHTMLElement) { + this.IsElement0 = IsElement0; + this.fromHTMLElement = fromHTMLElement; + this.toHTMLElement = toHTMLElement; + }; + var toHTMLElement = function (dict) { + return dict.toHTMLElement; + }; + var isHTMLElementHTMLElement = new IsHTMLElement(function () { + return DOM_Classy_Element.isElementHTMLElement; + }, Data_Maybe.Just.create, Control_Category.id(Control_Category.categoryFn)); + var getBoundingClientRect = function (dictIsHTMLElement) { + return function ($45) { + return DOM_HTML_HTMLElement.getBoundingClientRect(toHTMLElement(dictIsHTMLElement)($45)); + }; + }; + var fromHTMLElement = function (dict) { + return dict.fromHTMLElement; + }; + exports["IsHTMLElement"] = IsHTMLElement; + exports["fromHTMLElement"] = fromHTMLElement; + exports["getBoundingClientRect"] = getBoundingClientRect; + exports["toHTMLElement"] = toHTMLElement; + exports["isHTMLElementHTMLElement"] = isHTMLElementHTMLElement; +})(PS["DOM.Classy.HTMLElement"] = PS["DOM.Classy.HTMLElement"] || {}); +(function(exports) { + "use strict"; + + exports.clientX = function (e) { + return e.clientX; + }; + + exports.clientY = function (e) { + return e.clientY; + }; +})(PS["DOM.Event.MouseEvent"] = PS["DOM.Event.MouseEvent"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Event.MouseEvent"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Nullable = PS["Data.Nullable"]; + var Prelude = PS["Prelude"]; + exports["clientX"] = $foreign.clientX; + exports["clientY"] = $foreign.clientY; +})(PS["DOM.Event.MouseEvent"] = PS["DOM.Event.MouseEvent"] || {}); +(function(exports) { + "use strict"; + + exports.clientX = function (t) { + return t.clientX; + }; + + exports.clientY = function (t) { + return t.clientY; + }; + + exports._item = function (i) { + return function(l) { + return l.item(i); + }; + }; + + exports.touches = function (e) { + return e.touches; + }; +})(PS["DOM.Event.TouchEvent"] = PS["DOM.Event.TouchEvent"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Event.TouchEvent"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Nullable = PS["Data.Nullable"]; + var Prelude = PS["Prelude"]; + var item = function (i) { + return function ($0) { + return Data_Nullable.toMaybe($foreign._item(i)($0)); + }; + }; + exports["item"] = item; + exports["clientX"] = $foreign.clientX; + exports["clientY"] = $foreign.clientY; + exports["touches"] = $foreign.touches; +})(PS["DOM.Event.TouchEvent"] = PS["DOM.Event.TouchEvent"] || {}); +(function(exports) { + "use strict"; + + // Alias require to prevent webpack or browserify from actually requiring. + var req = typeof module === "undefined" ? undefined : module.require; + var util = req === undefined ? undefined : req("util"); + + exports.traceAny = function () { + return function (x) { + return function (k) { + // node only recurses two levels into an object before printing + // "[object]" for further objects when using console.log() + if (util !== undefined) { + console.log(util.inspect(x, { depth: null, colors: true })); + } else { + console.log(x); + } + return k({}); + }; + }; + }; +})(PS["Debug.Trace"] = PS["Debug.Trace"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Debug.Trace"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Show = PS["Data.Show"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var DebugWarning = {}; + var warn = function (dictWarn) { + return DebugWarning; + }; + var traceAnyA = function (dictDebugWarning) { + return function (dictApplicative) { + return function (s) { + return $foreign.traceAny(dictDebugWarning)(s)(function (v) { + return Control_Applicative.pure(dictApplicative)(Data_Unit.unit); + }); + }; + }; + }; + exports["DebugWarning"] = DebugWarning; + exports["traceAnyA"] = traceAnyA; + exports["warn"] = warn; +})(PS["Debug.Trace"] = PS["Debug.Trace"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Eq = PS["Data.Eq"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + var OrdBox = (function () { + function OrdBox(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + OrdBox.create = function (value0) { + return function (value1) { + return function (value2) { + return new OrdBox(value0, value1, value2); + }; + }; + }; + return OrdBox; + })(); + var unOrdBox = function (v) { + return v.value2; + }; + var mkOrdBox = function (dictOrd) { + return OrdBox.create(Data_Eq.eq(dictOrd.Eq0()))(Data_Ord.compare(dictOrd)); + }; + var eqOrdBox = new Data_Eq.Eq(function (v) { + return function (v1) { + return v.value0(v.value2)(v1.value2); + }; + }); + var ordOrdBox = new Data_Ord.Ord(function () { + return eqOrdBox; + }, function (v) { + return function (v1) { + return v.value1(v.value2)(v1.value2); + }; + }); + exports["mkOrdBox"] = mkOrdBox; + exports["unOrdBox"] = unOrdBox; + exports["eqOrdBox"] = eqOrdBox; + exports["ordOrdBox"] = ordOrdBox; +})(PS["Halogen.Data.OrdBox"] = PS["Halogen.Data.OrdBox"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + var RefUpdate = (function () { + function RefUpdate(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + RefUpdate.create = function (value0) { + return function (value1) { + return function (value2) { + return new RefUpdate(value0, value1, value2); + }; + }; + }; + return RefUpdate; + })(); + var Query = (function () { + function Query(value0) { + this.value0 = value0; + }; + Query.create = function (value0) { + return new Query(value0); + }; + return Query; + })(); + var bifunctorInputF = new Data_Bifunctor.Bifunctor(function (f) { + return function (g) { + return function (v) { + if (v instanceof RefUpdate) { + return new RefUpdate(v.value0, v.value1, f(v.value2)); + }; + if (v instanceof Query) { + return new Query(g(v.value0)); + }; + throw new Error("Failed pattern match at Halogen.Query.InputF line 21, column 15 - line 23, column 27: " + [ v.constructor.name ]); + }; + }; + }); + var functorInputF = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorInputF)); + exports["RefUpdate"] = RefUpdate; + exports["Query"] = Query; + exports["bifunctorInputF"] = bifunctorInputF; + exports["functorInputF"] = functorInputF; +})(PS["Halogen.Query.InputF"] = PS["Halogen.Query.InputF"] || {}); +(function(exports) { + "use strict"; + + exports.newRef = function (val) { + return function () { + return { value: val }; + }; + }; + + exports.readRef = function (ref) { + return function () { + return ref.value; + }; + }; + + exports["modifyRef'"] = function (ref) { + return function (f) { + return function () { + var t = f(ref.value); + ref.value = t.state; + return t.value; + }; + }; + }; + + exports.writeRef = function (ref) { + return function (val) { + return function () { + ref.value = val; + return {}; + }; + }; + }; +})(PS["Control.Monad.Eff.Ref"] = PS["Control.Monad.Eff.Ref"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Eff.Ref"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var modifyRef = function (ref) { + return function (f) { + return $foreign["modifyRef'"](ref)(function (s) { + return { + state: f(s), + value: Data_Unit.unit + }; + }); + }; + }; + exports["modifyRef"] = modifyRef; + exports["modifyRef'"] = $foreign["modifyRef'"]; + exports["newRef"] = $foreign.newRef; + exports["readRef"] = $foreign.readRef; + exports["writeRef"] = $foreign.writeRef; +})(PS["Control.Monad.Eff.Ref"] = PS["Control.Monad.Eff.Ref"] || {}); +(function(exports) { + "use strict"; + + exports.eventListener = function (fn) { + return function (event) { + return fn(event)(); + }; + }; + + exports.addEventListener = function (type) { + return function (listener) { + return function (useCapture) { + return function (target) { + return function () { + target.addEventListener(type, listener, useCapture); + return {}; + }; + }; + }; + }; + }; +})(PS["DOM.Event.EventTarget"] = PS["DOM.Event.EventTarget"] || {}); +(function(exports) { + "use strict"; + + exports.error = function (msg) { + return new Error(msg); + }; + + exports.throwException = function (e) { + return function () { + throw e; + }; + }; +})(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Eff.Exception"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Show = PS["Data.Show"]; + var Prelude = PS["Prelude"]; + var $$throw = function ($1) { + return $foreign.throwException($foreign.error($1)); + }; + exports["throw"] = $$throw; + exports["error"] = $foreign.error; + exports["throwException"] = $foreign.throwException; +})(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Event.EventTarget"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var DOM = PS["DOM"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var Prelude = PS["Prelude"]; + exports["addEventListener"] = $foreign.addEventListener; + exports["eventListener"] = $foreign.eventListener; +})(PS["DOM.Event.EventTarget"] = PS["DOM.Event.EventTarget"] || {}); +(function(exports) { + "use strict"; + + exports._copyEff = function (m) { + return function () { + var r = {}; + for (var k in m) { + if (hasOwnProperty.call(m, k)) { + r[k] = m[k]; + } + } + return r; + }; + }; + + exports.empty = {}; + + exports.runST = function (f) { + return f; + }; + + exports._foldM = function (bind) { + return function (f) { + return function (mz) { + return function (m) { + var acc = mz; + function g(k) { + return function (z) { + return f(z)(k)(m[k]); + }; + } + for (var k in m) { + if (hasOwnProperty.call(m, k)) { + acc = bind(acc)(g(k)); + } + } + return acc; + }; + }; + }; + }; + + exports._lookup = function (no, yes, k, m) { + return k in m ? yes(m[k]) : no; + }; + + function toArrayWithKey(f) { + return function (m) { + var r = []; + for (var k in m) { + if (hasOwnProperty.call(m, k)) { + r.push(f(k)(m[k])); + } + } + return r; + }; + } +})(PS["Data.StrMap"] = PS["Data.StrMap"] || {}); +(function(exports) { + "use strict"; + + exports["new"] = function () { + return {}; + }; + + exports.poke = function (m) { + return function (k) { + return function (v) { + return function () { + m[k] = v; + return m; + }; + }; + }; + }; + + exports["delete"] = function (m) { + return function (k) { + return function () { + delete m[k]; + return m; + }; + }; + }; +})(PS["Data.StrMap.ST"] = PS["Data.StrMap.ST"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.StrMap.ST"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_ST = PS["Control.Monad.ST"]; + var Data_Maybe = PS["Data.Maybe"]; + exports["delete"] = $foreign["delete"]; + exports["new"] = $foreign["new"]; + exports["poke"] = $foreign.poke; +})(PS["Data.StrMap.ST"] = PS["Data.StrMap.ST"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Data.StrMap"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_ST = PS["Control.Monad.ST"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Array = PS["Data.Array"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_StrMap_ST = PS["Data.StrMap.ST"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var Prelude = PS["Prelude"]; + var thawST = $foreign._copyEff; + var pureST = function (f) { + return Control_Monad_Eff.runPure($foreign.runST(f)); + }; + var mutate = function (f) { + return function (m) { + return pureST(function __do() { + var v = thawST(m)(); + var v1 = f(v)(); + return v; + }); + }; + }; + var lookup = Data_Function_Uncurried.runFn4($foreign._lookup)(Data_Maybe.Nothing.value)(Data_Maybe.Just.create); + var insert = function (k) { + return function (v) { + return mutate(function (s) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_StrMap_ST.poke(s)(k)(v)); + }); + }; + }; + var fromFoldable = function (dictFoldable) { + return function (l) { + return pureST(function __do() { + var v = Data_StrMap_ST["new"](); + Control_Monad_Eff.foreachE(Data_Array.fromFoldable(dictFoldable)(l))(function (v1) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_StrMap_ST.poke(v)(v1.value0)(v1.value1)); + })(); + return v; + }); + }; + }; + var fold = $foreign._foldM(Data_Function.applyFlipped); + var foldMap = function (dictMonoid) { + return function (f) { + return fold(function (acc) { + return function (k) { + return function (v) { + return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f(k)(v)); + }; + }; + })(Data_Monoid.mempty(dictMonoid)); + }; + }; + var $$delete = function (k) { + return mutate(function (s) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_StrMap_ST["delete"](s)(k)); + }); + }; + var alter = function (f) { + return function (k) { + return function (m) { + var v = f(lookup(k)(m)); + if (v instanceof Data_Maybe.Nothing) { + return $$delete(k)(m); + }; + if (v instanceof Data_Maybe.Just) { + return insert(k)(v.value0)(m); + }; + throw new Error("Failed pattern match at Data.StrMap line 198, column 15 - line 200, column 25: " + [ v.constructor.name ]); + }; + }; + }; + exports["alter"] = alter; + exports["fold"] = fold; + exports["foldMap"] = foldMap; + exports["fromFoldable"] = fromFoldable; + exports["insert"] = insert; + exports["lookup"] = lookup; + exports["pureST"] = pureST; + exports["thawST"] = thawST; + exports["empty"] = $foreign.empty; +})(PS["Data.StrMap"] = PS["Data.StrMap"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Data_Void = PS["Data.Void"]; + var Prelude = PS["Prelude"]; + var Step = (function () { + function Step(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + Step.create = function (value0) { + return function (value1) { + return function (value2) { + return new Step(value0, value1, value2); + }; + }; + }; + return Step; + })(); + var step = function (v) { + return v.value1; + }; + var halt = function (v) { + return v.value2; + }; + var extract = function (v) { + return v.value0; + }; + exports["Step"] = Step; + exports["extract"] = extract; + exports["halt"] = halt; + exports["step"] = step; +})(PS["Halogen.VDom.Machine"] = PS["Halogen.VDom.Machine"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Generic = PS["Data.Generic"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var ElemSpec = (function () { + function ElemSpec(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + ElemSpec.create = function (value0) { + return function (value1) { + return function (value2) { + return new ElemSpec(value0, value1, value2); + }; + }; + }; + return ElemSpec; + })(); + var Text = (function () { + function Text(value0) { + this.value0 = value0; + }; + Text.create = function (value0) { + return new Text(value0); + }; + return Text; + })(); + var Elem = (function () { + function Elem(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Elem.create = function (value0) { + return function (value1) { + return new Elem(value0, value1); + }; + }; + return Elem; + })(); + var Keyed = (function () { + function Keyed(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Keyed.create = function (value0) { + return function (value1) { + return new Keyed(value0, value1); + }; + }; + return Keyed; + })(); + var Widget = (function () { + function Widget(value0) { + this.value0 = value0; + }; + Widget.create = function (value0) { + return new Widget(value0); + }; + return Widget; + })(); + var Grafted = (function () { + function Grafted(value0) { + this.value0 = value0; + }; + Grafted.create = function (value0) { + return new Grafted(value0); + }; + return Grafted; + })(); + var Graft = (function () { + function Graft(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + Graft.create = function (value0) { + return function (value1) { + return function (value2) { + return new Graft(value0, value1, value2); + }; + }; + }; + return Graft; + })(); + var unGraft = function (f) { + return function ($124) { + return f(Unsafe_Coerce.unsafeCoerce($124)); + }; + }; + var graft = Unsafe_Coerce.unsafeCoerce; + var functorElemSpec = new Data_Functor.Functor(function (f) { + return function (v) { + return new ElemSpec(v.value0, v.value1, f(v.value2)); + }; + }); + var eqElemName = Data_Eq.eqString; + var bifunctorGraft = new Data_Bifunctor.Bifunctor(function (f) { + return function (g) { + return unGraft(function (v) { + return graft(new Graft(function ($126) { + return f(v.value0($126)); + }, function ($127) { + return g(v.value1($127)); + }, v.value2)); + }); + }; + }); + var bifunctorVDom = new Data_Bifunctor.Bifunctor(function (f) { + return function (g) { + return function (v) { + if (v instanceof Text) { + return new Text(v.value0); + }; + if (v instanceof Grafted) { + return new Grafted(Data_Bifunctor.bimap(bifunctorGraft)(f)(g)(v.value0)); + }; + return new Grafted(graft(new Graft(f, g, v))); + }; + }; + }); + var runGraft = unGraft(function (v) { + var go = function (v2) { + if (v2 instanceof Text) { + return new Text(v2.value0); + }; + if (v2 instanceof Elem) { + return new Elem(Data_Functor.map(functorElemSpec)(v.value0)(v2.value0), Data_Functor.map(Data_Functor.functorArray)(go)(v2.value1)); + }; + if (v2 instanceof Keyed) { + return new Keyed(Data_Functor.map(functorElemSpec)(v.value0)(v2.value0), Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Data_Tuple.functorTuple)(go))(v2.value1)); + }; + if (v2 instanceof Widget) { + return new Widget(v.value1(v2.value0)); + }; + if (v2 instanceof Grafted) { + return new Grafted(Data_Bifunctor.bimap(bifunctorGraft)(v.value0)(v.value1)(v2.value0)); + }; + throw new Error("Failed pattern match at Halogen.VDom.Types line 75, column 7 - line 75, column 27: " + [ v2.constructor.name ]); + }; + return go(v.value2); + }); + exports["ElemSpec"] = ElemSpec; + exports["Graft"] = Graft; + exports["Text"] = Text; + exports["Elem"] = Elem; + exports["Keyed"] = Keyed; + exports["Widget"] = Widget; + exports["Grafted"] = Grafted; + exports["graft"] = graft; + exports["runGraft"] = runGraft; + exports["unGraft"] = unGraft; + exports["bifunctorVDom"] = bifunctorVDom; + exports["bifunctorGraft"] = bifunctorGraft; + exports["functorElemSpec"] = functorElemSpec; + exports["eqElemName"] = eqElemName; +})(PS["Halogen.VDom.Types"] = PS["Halogen.VDom.Types"] || {}); +(function(exports) { + "use strict"; + + exports.unsafeGetAny = function (key, obj) { + return obj[key]; + }; + + exports.unsafeHasAny = function (key, obj) { + return obj.hasOwnProperty(key); + }; + + exports.unsafeSetAny = function (key, val, obj) { + return function () { + obj[key] = val; + }; + }; + + exports.forE = function (a, f) { + return function () { + var b = []; + for (var i = 0; i < a.length; i++) { + b.push(f(i, a[i])()); + } + return b; + }; + }; + + exports.forInE = function (o, f) { + return function () { + var ks = Object.keys(o); + for (var i = 0; i < ks.length; i++) { + var k = ks[i]; + f(k, o[k])(); + } + }; + }; + + exports.diffWithIxE = function (a1, a2, f1, f2, f3) { + return function () { + var a3 = []; + var l1 = a1.length; + var l2 = a2.length; + var i = 0; + while (1) { + if (i < l1) { + if (i < l2) { + a3.push(f1(i, a1[i], a2[i])()); + } else { + f2(i, a1[i])(); + } + } else if (i < l2) { + a3.push(f3(i, a2[i])()); + } else { + break; + } + i++; + } + return a3; + }; + }; + + exports.strMapWithIxE = function (as, fk, f) { + return function () { + var o = {}; + for (var i = 0; i < as.length; i++) { + var a = as[i]; + var k = fk(a); + o[k] = f(k, i, a)(); + } + return o; + }; + }; + + exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { + return function () { + var o2 = {}; + for (var i = 0; i < as.length; i++) { + var a = as[i]; + var k = fk(a); + if (o1.hasOwnProperty(k)) { + o2[k] = f1(k, i, o1[k], a)(); + } else { + o2[k] = f3(k, i, a)(); + } + } + for (var k in o1) { + if (k in o2) { + continue; + } + f2(k, o1[k])(); + } + return o2; + }; + }; + + exports.refEq = function (a, b) { + return a === b; + }; + + exports.createTextNode = function (s, doc) { + return function () { + return doc.createTextNode(s); + }; + }; + + exports.setTextContent = function (s, n) { + return function () { + n.textContent = s; + }; + }; + + exports.createElement = function (ns, name, doc) { + return function () { + if (ns != null) { + return doc.createElementNS(ns, name); + } else { + return doc.createElement(name) + } + }; + }; + + exports.insertChildIx = function (i, a, b) { + return function () { + var n = b.childNodes.item(i) || null; + if (n !== a) { + b.insertBefore(a, n); + } + }; + }; + + exports.removeChild = function (a, b) { + return function () { + if (b && a.parentNode === b) { + b.removeChild(a); + } + }; + }; + + exports.unsafeParent = function (a) { + return a.parentNode; + }; + + exports.setAttribute = function (ns, attr, val, el) { + return function () { + if (ns != null) { + el.setAttributeNS(ns, attr, val); + } else { + el.setAttribute(attr, val); + } + }; + }; + + exports.removeAttribute = function (ns, attr, el) { + return function () { + if (ns != null) { + el.removeAttributeNS(ns, attr); + } else { + el.removeAttribute(attr); + } + }; + }; + + exports.addEventListener = function (ev, listener, el) { + return function () { + el.addEventListener(ev, listener, false); + }; + }; + + exports.removeEventListener = function (ev, listener, el) { + return function () { + el.removeEventListener(ev, listener, false); + }; + }; + + exports.jsUndefined = void 0; +})(PS["Halogen.VDom.Util"] = PS["Halogen.VDom.Util"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Halogen.VDom.Util"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var DOM = PS["DOM"]; + var DOM_Event_EventTarget = PS["DOM.Event.EventTarget"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Nullable = PS["Data.Nullable"]; + var Data_StrMap = PS["Data.StrMap"]; + var Data_StrMap_ST = PS["Data.StrMap.ST"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var unsafeLookup = $foreign.unsafeGetAny; + var unsafeFreeze = Unsafe_Coerce.unsafeCoerce; + var pokeMutMap = $foreign.unsafeSetAny; + var newMutMap = Unsafe_Coerce.unsafeCoerce(Data_StrMap_ST["new"]); + var effUnit = Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit); + var effPure = Control_Applicative.pure(Control_Monad_Eff.applicativeEff); + exports["effPure"] = effPure; + exports["effUnit"] = effUnit; + exports["newMutMap"] = newMutMap; + exports["pokeMutMap"] = pokeMutMap; + exports["unsafeFreeze"] = unsafeFreeze; + exports["unsafeLookup"] = unsafeLookup; + exports["addEventListener"] = $foreign.addEventListener; + exports["createElement"] = $foreign.createElement; + exports["createTextNode"] = $foreign.createTextNode; + exports["diffWithIxE"] = $foreign.diffWithIxE; + exports["diffWithKeyAndIxE"] = $foreign.diffWithKeyAndIxE; + exports["forE"] = $foreign.forE; + exports["forInE"] = $foreign.forInE; + exports["insertChildIx"] = $foreign.insertChildIx; + exports["jsUndefined"] = $foreign.jsUndefined; + exports["refEq"] = $foreign.refEq; + exports["removeAttribute"] = $foreign.removeAttribute; + exports["removeChild"] = $foreign.removeChild; + exports["removeEventListener"] = $foreign.removeEventListener; + exports["setAttribute"] = $foreign.setAttribute; + exports["setTextContent"] = $foreign.setTextContent; + exports["strMapWithIxE"] = $foreign.strMapWithIxE; + exports["unsafeGetAny"] = $foreign.unsafeGetAny; + exports["unsafeHasAny"] = $foreign.unsafeHasAny; + exports["unsafeParent"] = $foreign.unsafeParent; + exports["unsafeSetAny"] = $foreign.unsafeSetAny; +})(PS["Halogen.VDom.Util"] = PS["Halogen.VDom.Util"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var DOM = PS["DOM"]; + var DOM_Event_EventTarget = PS["DOM.Event.EventTarget"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Nullable = PS["Data.Nullable"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_StrMap = PS["Data.StrMap"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_VDom = PS["Halogen.VDom"]; + var Halogen_VDom_Machine = PS["Halogen.VDom.Machine"]; + var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; + var Halogen_VDom_Util = PS["Halogen.VDom.Util"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var Created = (function () { + function Created(value0) { + this.value0 = value0; + }; + Created.create = function (value0) { + return new Created(value0); + }; + return Created; + })(); + var Removed = (function () { + function Removed(value0) { + this.value0 = value0; + }; + Removed.create = function (value0) { + return new Removed(value0); + }; + return Removed; + })(); + var Attribute = (function () { + function Attribute(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + Attribute.create = function (value0) { + return function (value1) { + return function (value2) { + return new Attribute(value0, value1, value2); + }; + }; + }; + return Attribute; + })(); + var Property = (function () { + function Property(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Property.create = function (value0) { + return function (value1) { + return new Property(value0, value1); + }; + }; + return Property; + })(); + var Handler = (function () { + function Handler(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Handler.create = function (value0) { + return function (value1) { + return new Handler(value0, value1); + }; + }; + return Handler; + })(); + var Ref = (function () { + function Ref(value0) { + this.value0 = value0; + }; + Ref.create = function (value0) { + return new Ref(value0); + }; + return Ref; + })(); + var unsafeGetProperty = Halogen_VDom_Util.unsafeGetAny; + var setProperty = Halogen_VDom_Util.unsafeSetAny; + var removeProperty = function (key, el) { + var v = Data_Foreign.typeOf(Halogen_VDom_Util.unsafeGetAny(key, el)); + if (v === "string") { + return Halogen_VDom_Util.unsafeSetAny(key, "", el); + }; + return Halogen_VDom_Util.unsafeSetAny(key, Halogen_VDom_Util.jsUndefined, el); + }; + var propToStrKey = function (v) { + if (v instanceof Attribute && v.value0 instanceof Data_Maybe.Just) { + return "attr/" + (v.value0.value0 + (":" + v.value1)); + }; + if (v instanceof Attribute) { + return "attr/:" + v.value1; + }; + if (v instanceof Property) { + return "prop/" + v.value0; + }; + if (v instanceof Handler) { + return "handler/" + v.value0; + }; + if (v instanceof Ref) { + return "ref"; + }; + throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 179, column 16 - line 186, column 1: " + [ v.constructor.name ]); + }; + var propFromString = Unsafe_Coerce.unsafeCoerce; + var functorProp = new Data_Functor.Functor(function (f) { + return function (v) { + if (v instanceof Handler) { + return new Handler(v.value0, Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v.value1)); + }; + if (v instanceof Ref) { + return new Ref(Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v.value0)); + }; + return Unsafe_Coerce.unsafeCoerce(v); + }; + }); + var buildProp = function (emit) { + return function (el) { + var removeProp = function (prevEvents) { + return function (v, v1) { + if (v1 instanceof Attribute) { + return Halogen_VDom_Util.removeAttribute(Data_Nullable.toNullable(v1.value0), v1.value1, el); + }; + if (v1 instanceof Property) { + return removeProperty(v1.value0, el); + }; + if (v1 instanceof Handler) { + var handler = Halogen_VDom_Util.unsafeLookup(v1.value0, prevEvents); + return Halogen_VDom_Util.removeEventListener(v1.value0, Data_Tuple.fst(handler), el); + }; + if (v1 instanceof Ref) { + return Halogen_VDom_Util.effUnit; + }; + throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 166, column 5 - line 176, column 21: " + [ v1.constructor.name ]); + }; + }; + var mbEmit = Data_Maybe.maybe(Halogen_VDom_Util.effUnit)(emit); + var done = function (ps) { + var v = Data_StrMap.lookup("ref")(ps); + if (v instanceof Data_Maybe.Just && v.value0 instanceof Ref) { + return mbEmit(v.value0.value0(new Removed(el))); + }; + return Halogen_VDom_Util.effUnit; + }; + var diffProp = function (prevEvents, events) { + return function (v, v1, v11, v2) { + if (v11 instanceof Attribute && v2 instanceof Attribute) { + var v3 = v11.value2 !== v2.value2; + if (v3) { + return function __do() { + Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el)(); + return v2; + }; + }; + return Halogen_VDom_Util.effPure(v2); + }; + if (v11 instanceof Property && v2 instanceof Property) { + var v4 = Halogen_VDom_Util.refEq(v11.value1, v2.value1); + if (v4) { + return Halogen_VDom_Util.effPure(v2); + }; + if (v2.value0 === "value") { + var elVal = unsafeGetProperty("value", el); + var v5 = !Halogen_VDom_Util.refEq(elVal, v2.value1); + if (v5) { + return function __do() { + setProperty(v2.value0, v2.value1, el)(); + return v2; + }; + }; + return Halogen_VDom_Util.effPure(v2); + }; + return function __do() { + setProperty(v2.value0, v2.value1, el)(); + return v2; + }; + }; + if (v11 instanceof Handler && v2 instanceof Handler) { + var handler = Halogen_VDom_Util.unsafeLookup(v2.value0, prevEvents); + return function __do() { + Control_Monad_Eff_Ref.writeRef(Data_Tuple.snd(handler))(v2.value1)(); + Halogen_VDom_Util.pokeMutMap(v2.value0, handler, events)(); + return v2; + }; + }; + return Halogen_VDom_Util.effPure(v2); + }; + }; + var applyProp = function (events) { + return function (v, v1, v2) { + if (v2 instanceof Attribute) { + return function __do() { + Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el)(); + return v2; + }; + }; + if (v2 instanceof Property) { + return function __do() { + setProperty(v2.value0, v2.value1, el)(); + return v2; + }; + }; + if (v2 instanceof Handler) { + var v3 = Halogen_VDom_Util.unsafeGetAny(v2.value0, events); + if (Halogen_VDom_Util.unsafeHasAny(v2.value0, events)) { + return function __do() { + Control_Monad_Eff_Ref.writeRef(Data_Tuple.snd(v3))(v2.value1)(); + return v2; + }; + }; + return function __do() { + var v4 = Control_Monad_Eff_Ref.newRef(v2.value1)(); + var listener = DOM_Event_EventTarget.eventListener(function (ev) { + return function __do() { + var v5 = Control_Monad_Eff_Ref.readRef(v4)(); + return mbEmit(v5(ev))(); + }; + }); + Halogen_VDom_Util.pokeMutMap(v2.value0, new Data_Tuple.Tuple(listener, v4), events)(); + Halogen_VDom_Util.addEventListener(v2.value0, listener, el)(); + return v2; + }; + }; + if (v2 instanceof Ref) { + return function __do() { + mbEmit(v2.value0(new Created(el)))(); + return v2; + }; + }; + throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 107, column 5 - line 130, column 15: " + [ v2.constructor.name ]); + }; + }; + var patch = function (prevEvents, ps1) { + return function (ps2) { + return function __do() { + var v = Halogen_VDom_Util.newMutMap(); + var onThis = removeProp(prevEvents); + var onThese = diffProp(prevEvents, v); + var onThat = applyProp(v); + var v1 = Halogen_VDom_Util.diffWithKeyAndIxE(ps1, ps2, propToStrKey, onThese, onThis, onThat)(); + return new Halogen_VDom_Machine.Step(Data_Unit.unit, patch(Halogen_VDom_Util.unsafeFreeze(v), v1), done(v1)); + }; + }; + }; + var render = function (ps1) { + return function __do() { + var v = Halogen_VDom_Util.newMutMap(); + var v1 = Halogen_VDom_Util.strMapWithIxE(ps1, propToStrKey, applyProp(v))(); + return new Halogen_VDom_Machine.Step(Data_Unit.unit, patch(Halogen_VDom_Util.unsafeFreeze(v), v1), done(v1)); + }; + }; + return render; + }; + }; + exports["Created"] = Created; + exports["Removed"] = Removed; + exports["Attribute"] = Attribute; + exports["Property"] = Property; + exports["Handler"] = Handler; + exports["Ref"] = Ref; + exports["buildProp"] = buildProp; + exports["propFromString"] = propFromString; + exports["functorProp"] = functorProp; +})(PS["Halogen.VDom.DOM.Prop"] = PS["Halogen.VDom.DOM.Prop"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Apply = PS["Control.Apply"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_HTML_Indexed_ButtonType = PS["DOM.HTML.Indexed.ButtonType"]; + var DOM_HTML_Indexed_CrossOriginValue = PS["DOM.HTML.Indexed.CrossOriginValue"]; + var DOM_HTML_Indexed_DirValue = PS["DOM.HTML.Indexed.DirValue"]; + var DOM_HTML_Indexed_FormMethod = PS["DOM.HTML.Indexed.FormMethod"]; + var DOM_HTML_Indexed_InputType = PS["DOM.HTML.Indexed.InputType"]; + var DOM_HTML_Indexed_KindValue = PS["DOM.HTML.Indexed.KindValue"]; + var DOM_HTML_Indexed_MenuType = PS["DOM.HTML.Indexed.MenuType"]; + var DOM_HTML_Indexed_MenuitemType = PS["DOM.HTML.Indexed.MenuitemType"]; + var DOM_HTML_Indexed_OnOff = PS["DOM.HTML.Indexed.OnOff"]; + var DOM_HTML_Indexed_OrderedListType = PS["DOM.HTML.Indexed.OrderedListType"]; + var DOM_HTML_Indexed_PreloadValue = PS["DOM.HTML.Indexed.PreloadValue"]; + var DOM_HTML_Indexed_ScopeValue = PS["DOM.HTML.Indexed.ScopeValue"]; + var DOM_HTML_Indexed_StepValue = PS["DOM.HTML.Indexed.StepValue"]; + var DOM_HTML_Indexed_WrapValue = PS["DOM.HTML.Indexed.WrapValue"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Generic = PS["Data.Generic"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_MediaType = PS["Data.MediaType"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Halogen_VDom = PS["Halogen.VDom"]; + var Halogen_VDom_DOM_Prop = PS["Halogen.VDom.DOM.Prop"]; + var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var HTML = function (x) { + return x; + }; + var ClassName = function (x) { + return x; + }; + var IsProp = function (toPropValue) { + this.toPropValue = toPropValue; + }; + var toPropValue = function (dict) { + return dict.toPropValue; + }; + var text = function ($54) { + return HTML(Halogen_VDom_Types.Text.create($54)); + }; + var stringIsProp = new IsProp(Halogen_VDom_DOM_Prop.propFromString); + var slot = function ($56) { + return HTML(Halogen_VDom_Types.Widget.create($56)); + }; + var prop = function (dictIsProp) { + return function (v) { + return function ($59) { + return Halogen_VDom_DOM_Prop.Property.create(v)(toPropValue(dictIsProp)($59)); + }; + }; + }; + var newtypeClassName = new Data_Newtype.Newtype(function (n) { + return n; + }, ClassName); + var handler = Halogen_VDom_DOM_Prop.Handler.create; + var element = function (ns) { + return Unsafe_Coerce.unsafeCoerce(function (name) { + return function (props) { + return function (children) { + return new Halogen_VDom_Types.Elem(new Halogen_VDom_Types.ElemSpec(ns, name, props), children); + }; + }; + }); + }; + var bifunctorHTML = new Data_Bifunctor.Bifunctor(function (f) { + return function (g) { + return function (v) { + return Data_Bifunctor.bimap(Halogen_VDom_Types.bifunctorVDom)(Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Halogen_VDom_DOM_Prop.functorProp)(Data_Functor.map(Halogen_Query_InputF.functorInputF)(g))))(f)(v); + }; + }; + }); + var attr = function (ns) { + return function (v) { + return Halogen_VDom_DOM_Prop.Attribute.create(ns)(v); + }; + }; + exports["ClassName"] = ClassName; + exports["HTML"] = HTML; + exports["IsProp"] = IsProp; + exports["attr"] = attr; + exports["element"] = element; + exports["handler"] = handler; + exports["prop"] = prop; + exports["slot"] = slot; + exports["text"] = text; + exports["toPropValue"] = toPropValue; + exports["bifunctorHTML"] = bifunctorHTML; + exports["stringIsProp"] = stringIsProp; + exports["newtypeClassName"] = newtypeClassName; +})(PS["Halogen.HTML.Core"] = PS["Halogen.HTML.Core"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var runExists = Unsafe_Coerce.unsafeCoerce; + var mkExists = Unsafe_Coerce.unsafeCoerce; + exports["mkExists"] = mkExists; + exports["runExists"] = runExists; +})(PS["Data.Exists"] = PS["Data.Exists"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Const = PS["Data.Const"]; + var Data_Exists = PS["Data.Exists"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var ApF = (function () { + function ApF(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + ApF.create = function (value0) { + return function (value1) { + return new ApF(value0, value1); + }; + }; + return ApF; + })(); + var Pure = (function () { + function Pure(value0) { + this.value0 = value0; + }; + Pure.create = function (value0) { + return new Pure(value0); + }; + return Pure; + })(); + var Ap = (function () { + function Ap(value0) { + this.value0 = value0; + }; + Ap.create = function (value0) { + return new Ap(value0); + }; + return Ap; + })(); + var retractFreeAp = function (dictApplicative) { + return function (v) { + if (v instanceof Pure) { + return Control_Applicative.pure(dictApplicative)(v.value0); + }; + if (v instanceof Ap) { + return Data_Exists.runExists(function (v1) { + return Control_Apply.apply(dictApplicative.Apply0())(retractFreeAp(dictApplicative)(v1.value1(Data_Unit.unit)))(v1.value0(Data_Unit.unit)); + })(v.value0); + }; + throw new Error("Failed pattern match at Control.Applicative.Free line 32, column 1 - line 32, column 64: " + [ v.constructor.name ]); + }; + }; + var ap = function (v) { + return function (k) { + return new Ap(Data_Exists.mkExists(new ApF(v, k))); + }; + }; + var hoistFreeAp = function (k) { + return function (v) { + if (v instanceof Pure) { + return new Pure(v.value0); + }; + if (v instanceof Ap) { + return Data_Exists.runExists(function (v1) { + return ap(function (v3) { + return k(v1.value0(Data_Unit.unit)); + })(function (v3) { + return hoistFreeAp(k)(v1.value1(Data_Unit.unit)); + }); + })(v.value0); + }; + throw new Error("Failed pattern match at Control.Applicative.Free line 44, column 1 - line 44, column 66: " + [ k.constructor.name, v.constructor.name ]); + }; + }; + exports["hoistFreeAp"] = hoistFreeAp; + exports["retractFreeAp"] = retractFreeAp; +})(PS["Control.Applicative.Free"] = PS["Control.Applicative.Free"] || {}); +(function(exports) { + /* globals setTimeout, clearTimeout, setImmediate, clearImmediate */ + "use strict"; + + exports._cancelWith = function (nonCanceler, aff, canceler1) { + return function (success, error) { + var canceler2 = aff(success, error); + + return function (e) { + return function (success, error) { + var cancellations = 0; + var result = false; + var errored = false; + + var s = function (bool) { + cancellations = cancellations + 1; + result = result || bool; + + if (cancellations === 2 && !errored) { + success(result); + } + }; + + var f = function (err) { + if (!errored) { + errored = true; + error(err); + } + }; + + canceler2(e)(s, f); + canceler1(e)(s, f); + + return nonCanceler; + }; + }; + }; + }; + + exports._forkAff = function (nonCanceler, aff) { + var voidF = function () {}; + + return function (success) { + var canceler = aff(voidF, voidF); + success(canceler); + return nonCanceler; + }; + }; + + exports._forkAll = function (nonCanceler, foldl, affs) { + var voidF = function () {}; + + return function (success) { + var cancelers = foldl(function (acc) { + return function (aff) { + acc.push(aff(voidF, voidF)); + return acc; + }; + })([])(affs); + + var canceler = function (e) { + return function (success, error) { + var cancellations = 0; + var result = false; + var errored = false; + + var s = function (bool) { + cancellations = cancellations + 1; + result = result || bool; + + if (cancellations === cancelers.length && !errored) { + success(result); + } + }; + + var f = function (err) { + if (!errored) { + errored = true; + error(err); + } + }; + + for (var i = 0; i < cancelers.length; i++) { + cancelers[i](e)(s, f); + } + + return nonCanceler; + }; + }; + + success(canceler); + return nonCanceler; + }; + }; + + exports._makeAff = function (cb) { + return function (success, error) { + try { + return cb(function (e) { + return function () { + error(e); + }; + })(function (v) { + return function () { + success(v); + }; + })(); + } catch (err) { + error(err); + } + }; + }; + + exports._pure = function (nonCanceler, v) { + return function (success) { + success(v); + return nonCanceler; + }; + }; + + exports._throwError = function (nonCanceler, e) { + return function (success, error) { + error(e); + return nonCanceler; + }; + }; + + exports._fmap = function (f, aff) { + return function (success, error) { + return aff(function (v) { + success(f(v)); + }, error); + }; + }; + + exports._bind = function (alwaysCanceler, aff, f) { + return function (success, error) { + var canceler1, canceler2; + + var isCanceled = false; + var requestCancel = false; + + var onCanceler = function () {}; + + canceler1 = aff(function (v) { + if (requestCancel) { + isCanceled = true; + + return alwaysCanceler; + } else { + canceler2 = f(v)(success, error); + + onCanceler(canceler2); + + return canceler2; + } + }, error); + + return function (e) { + return function (s, f) { + requestCancel = true; + + if (canceler2 !== undefined) { + return canceler2(e)(s, f); + } else { + return canceler1(e)(function (bool) { + if (bool || isCanceled) { + s(true); + } else { + onCanceler = function (canceler) { + canceler(e)(s, f); + }; + } + }, f); + } + }; + }; + }; + }; + + exports._attempt = function (Left, Right, aff) { + return function (success) { + return aff(function (v) { + success(Right(v)); + }, function (e) { + success(Left(e)); + }); + }; + }; + + exports._runAff = function (errorT, successT, aff) { + // If errorT or successT throw, and an Aff is comprised only of synchronous + // effects, then it's possible for makeAff/liftEff to accidentally catch + // it, which may end up rerunning the Aff depending on error recovery + // behavior. To mitigate this, we observe synchronicity using mutation. If + // an Aff is observed to be synchronous, we let the stack reset and run the + // handlers outside of the normal callback flow. + return function () { + var status = 0; + var result, success; + + var canceler = aff(function (v) { + if (status === 2) { + successT(v)(); + } else { + status = 1; + result = v; + success = true; + } + }, function (e) { + if (status === 2) { + errorT(e)(); + } else { + status = 1; + result = e; + success = false; + } + }); + + if (status === 1) { + if (success) { + successT(result)(); + } else { + errorT(result)(); + } + } else { + status = 2; + } + + return canceler; + }; + }; + + exports._liftEff = function (nonCanceler, e) { + return function (success, error) { + var result; + try { + result = e(); + } catch (err) { + error(err); + return nonCanceler; + } + + success(result); + return nonCanceler; + }; + }; + + exports._tailRecM = function (isLeft, f, a) { + return function (success, error) { + return function go (acc) { + var result, status, canceler; + + // Observes synchronous effects using a flag. + // status = 0 (unresolved status) + // status = 1 (synchronous effect) + // status = 2 (asynchronous effect) + + var csuccess = function (v) { + // If the status is still unresolved, we have observed a + // synchronous effect. Otherwise, the status will be `2`. + if (status === 0) { + // Store the result for further synchronous processing. + result = v; + status = 1; + } else { + // When we have observed an asynchronous effect, we use normal + // recursion. This is safe because we will be on a new stack. + if (isLeft(v)) { + go(v.value0); + } else { + success(v.value0); + } + } + }; + + while (true) { + status = 0; + canceler = f(acc)(csuccess, error); + + // If the status has already resolved to `1` by our Aff handler, then + // we have observed a synchronous effect. Otherwise it will still be + // `0`. + if (status === 1) { + // When we have observed a synchronous effect, we merely swap out the + // accumulator and continue the loop, preserving stack. + if (isLeft(result)) { + acc = result.value0; + continue; + } else { + success(result.value0); + } + } else { + // If the status has not resolved yet, then we have observed an + // asynchronous effect. + status = 2; + } + return canceler; + } + + }(a); + }; + }; +})(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}); +(function(exports) { + "use strict"; + + exports._makeVar = function (nonCanceler) { + return function (success) { + success({ + consumers: [], + producers: [], + error: undefined + }); + return nonCanceler; + }; + }; + + exports._takeVar = function (nonCanceler, avar) { + return function (success, error) { + if (avar.error !== undefined) { + error(avar.error); + } else if (avar.producers.length > 0) { + avar.producers.shift()(success, error); + } else { + avar.consumers.push({ peek: false, success: success, error: error }); + } + + return nonCanceler; + }; + }; + + exports._peekVar = function (nonCanceler, avar) { + return function (success, error) { + if (avar.error !== undefined) { + error(avar.error); + } else if (avar.producers.length > 0) { + avar.producers[0](success, error); + } else { + avar.consumers.push({ peek: true, success: success, error: error }); + } + return nonCanceler; + }; + }; + + exports._putVar = function (nonCanceler, avar, a) { + return function (success, error) { + if (avar.error !== undefined) { + error(avar.error); + } else { + var shouldQueue = true; + var consumers = []; + var consumer; + + while (true) { + consumer = avar.consumers.shift(); + if (consumer) { + consumers.push(consumer); + if (consumer.peek) { + continue; + } else { + shouldQueue = false; + } + } + break; + } + + if (shouldQueue) { + avar.producers.push(function (success) { + success(a); + return nonCanceler; + }); + } + + for (var i = 0; i < consumers.length; i++) { + consumers[i].success(a); + } + + success({}); + } + + return nonCanceler; + }; + }; + + exports._killVar = function (nonCanceler, avar, e) { + return function (success, error) { + if (avar.error !== undefined) { + error(avar.error); + } else { + avar.error = e; + while (avar.consumers.length) { + avar.consumers.shift().error(e); + } + success({}); + } + + return nonCanceler; + }; + }; +})(PS["Control.Monad.Aff.Internal"] = PS["Control.Monad.Aff.Internal"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Aff.Internal"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + exports["_killVar"] = $foreign._killVar; + exports["_makeVar"] = $foreign._makeVar; + exports["_peekVar"] = $foreign._peekVar; + exports["_putVar"] = $foreign._putVar; + exports["_takeVar"] = $foreign._takeVar; +})(PS["Control.Monad.Aff.Internal"] = PS["Control.Monad.Aff.Internal"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Cont_Trans = PS["Control.Monad.Cont.Trans"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Monad_Maybe_Trans = PS["Control.Monad.Maybe.Trans"]; + var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; + var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; + var Control_Plus = PS["Control.Plus"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Functor_Compose = PS["Data.Functor.Compose"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Parallel = function (Applicative1, Monad0, parallel, sequential) { + this.Applicative1 = Applicative1; + this.Monad0 = Monad0; + this.parallel = parallel; + this.sequential = sequential; + }; + var sequential = function (dict) { + return dict.sequential; + }; + var parallel = function (dict) { + return dict.parallel; + }; + exports["Parallel"] = Parallel; + exports["parallel"] = parallel; + exports["sequential"] = sequential; +})(PS["Control.Parallel.Class"] = PS["Control.Parallel.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Control.Monad.Aff"]; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Aff_Internal = PS["Control.Monad.Aff.Internal"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_MonadPlus = PS["Control.MonadPlus"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Parallel = PS["Control.Parallel"]; + var Control_Parallel_Class = PS["Control.Parallel.Class"]; + var Control_Plus = PS["Control.Plus"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Time_Duration = PS["Data.Time.Duration"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var ParAff = function (x) { + return x; + }; + var runAff = function (ex) { + return function (f) { + return function (aff) { + return $foreign._runAff(ex, f, aff); + }; + }; + }; + var makeAff$prime = function (h) { + return $foreign._makeAff(h); + }; + var functorAff = new Data_Functor.Functor(function (f) { + return function (fa) { + return $foreign._fmap(f, fa); + }; + }); + var functorParAff = functorAff; + var fromAVBox = Unsafe_Coerce.unsafeCoerce; + var cancel = function (v) { + return v; + }; + var attempt = function (aff) { + return $foreign._attempt(Data_Either.Left.create, Data_Either.Right.create, aff); + }; + var applyAff = new Control_Apply.Apply(function () { + return functorAff; + }, function (ff) { + return function (fa) { + return $foreign._bind(alwaysCanceler, ff, function (f) { + return Data_Functor.map(functorAff)(f)(fa); + }); + }; + }); + var applicativeAff = new Control_Applicative.Applicative(function () { + return applyAff; + }, function (v) { + return $foreign._pure(nonCanceler, v); + }); + var nonCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(false)); + var alwaysCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(true)); + var cancelWith = function (aff) { + return function (c) { + return $foreign._cancelWith(nonCanceler, aff, c); + }; + }; + var forkAff = function (aff) { + return $foreign._forkAff(nonCanceler, aff); + }; + var forkAll = function (dictFoldable) { + return function (affs) { + return $foreign._forkAll(nonCanceler, Data_Foldable.foldl(dictFoldable), affs); + }; + }; + var killVar = function (q) { + return function (e) { + return fromAVBox(Control_Monad_Aff_Internal._killVar(nonCanceler, q, e)); + }; + }; + var makeAff = function (h) { + return makeAff$prime(function (e) { + return function (a) { + return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Function["const"](nonCanceler))(h(e)(a)); + }; + }); + }; + var makeVar = fromAVBox(Control_Monad_Aff_Internal._makeVar(nonCanceler)); + var putVar = function (q) { + return function (a) { + return fromAVBox(Control_Monad_Aff_Internal._putVar(nonCanceler, q, a)); + }; + }; + var takeVar = function (q) { + return fromAVBox(Control_Monad_Aff_Internal._takeVar(nonCanceler, q)); + }; + var semigroupCanceler = new Data_Semigroup.Semigroup(function (v) { + return function (v1) { + return function (e) { + return Control_Apply.apply(applyAff)(Data_Functor.map(functorAff)(Data_HeytingAlgebra.disj(Data_HeytingAlgebra.heytingAlgebraBoolean))(v(e)))(v1(e)); + }; + }; + }); + var bindAff = new Control_Bind.Bind(function () { + return applyAff; + }, function (fa) { + return function (f) { + return $foreign._bind(alwaysCanceler, fa, f); + }; + }); + var applyParAff = new Control_Apply.Apply(function () { + return functorParAff; + }, function (v) { + return function (v1) { + var putOrKill = function (v2) { + return Data_Either.either(killVar(v2))(putVar(v2)); + }; + return Control_Bind.bind(bindAff)(makeVar)(function (v2) { + return Control_Bind.bind(bindAff)(makeVar)(function (v3) { + return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(putOrKill(v2))(attempt(v))))(function (v4) { + return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(putOrKill(v3))(attempt(v1))))(function (v5) { + return cancelWith(Control_Apply.apply(applyAff)(takeVar(v2))(takeVar(v3)))(Data_Semigroup.append(semigroupCanceler)(v4)(v5)); + }); + }); + }); + }); + }; + }); + var applicativeParAff = new Control_Applicative.Applicative(function () { + return applyParAff; + }, function ($56) { + return ParAff(Control_Applicative.pure(applicativeAff)($56)); + }); + var monadAff = new Control_Monad.Monad(function () { + return applicativeAff; + }, function () { + return bindAff; + }); + var monadEffAff = new Control_Monad_Eff_Class.MonadEff(function () { + return monadAff; + }, function (eff) { + return $foreign._liftEff(nonCanceler, eff); + }); + var monadRecAff = new Control_Monad_Rec_Class.MonadRec(function () { + return monadAff; + }, function (f) { + return function (a) { + var isLoop = function (v) { + if (v instanceof Control_Monad_Rec_Class.Loop) { + return true; + }; + return false; + }; + return $foreign._tailRecM(isLoop, f, a); + }; + }); + var monadThrowAff = new Control_Monad_Error_Class.MonadThrow(function () { + return monadAff; + }, function (e) { + return $foreign._throwError(nonCanceler, e); + }); + var parallelParAff = new Control_Parallel_Class.Parallel(function () { + return applicativeParAff; + }, function () { + return monadAff; + }, ParAff, function (v) { + return v; + }); + exports["ParAff"] = ParAff; + exports["attempt"] = attempt; + exports["cancel"] = cancel; + exports["cancelWith"] = cancelWith; + exports["forkAff"] = forkAff; + exports["forkAll"] = forkAll; + exports["makeAff"] = makeAff; + exports["nonCanceler"] = nonCanceler; + exports["runAff"] = runAff; + exports["functorAff"] = functorAff; + exports["applyAff"] = applyAff; + exports["applicativeAff"] = applicativeAff; + exports["bindAff"] = bindAff; + exports["monadAff"] = monadAff; + exports["monadEffAff"] = monadEffAff; + exports["monadThrowAff"] = monadThrowAff; + exports["monadRecAff"] = monadRecAff; + exports["semigroupCanceler"] = semigroupCanceler; + exports["functorParAff"] = functorParAff; + exports["applyParAff"] = applyParAff; + exports["applicativeParAff"] = applicativeParAff; + exports["parallelParAff"] = parallelParAff; +})(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Functor = PS["Data.Functor"]; + var Prelude = PS["Prelude"]; + var MonadFork = function (Monad0, fork) { + this.Monad0 = Monad0; + this.fork = fork; + }; + var monadForkAff = new MonadFork(function () { + return Control_Monad_Aff.monadAff; + }, function ($3) { + return Data_Functor.map(Control_Monad_Aff.functorAff)(Control_Monad_Aff.cancel)(Control_Monad_Aff.forkAff($3)); + }); + var fork = function (dict) { + return dict.fork; + }; + exports["MonadFork"] = MonadFork; + exports["fork"] = fork; + exports["monadForkAff"] = monadForkAff; +})(PS["Control.Monad.Fork.Class"] = PS["Control.Monad.Fork.Class"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_Tuple = PS["Data.Tuple"]; + var CatQueue = (function () { + function CatQueue(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + CatQueue.create = function (value0) { + return function (value1) { + return new CatQueue(value0, value1); + }; + }; + return CatQueue; + })(); + var uncons = function ($copy_v) { + var $tco_done = false; + var $tco_result; + function $tco_loop(v) { + if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) { + $tco_done = true; + return Data_Maybe.Nothing.value; + }; + if (v.value0 instanceof Data_List_Types.Nil) { + $copy_v = new CatQueue(Data_List.reverse(v.value1), Data_List_Types.Nil.value); + return; + }; + if (v.value0 instanceof Data_List_Types.Cons) { + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0.value0, new CatQueue(v.value0.value1, v.value1))); + }; + throw new Error("Failed pattern match at Data.CatQueue line 50, column 1 - line 50, column 63: " + [ v.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($copy_v); + }; + return $tco_result; + }; + var snoc = function (v) { + return function (a) { + return new CatQueue(v.value0, new Data_List_Types.Cons(a, v.value1)); + }; + }; + var $$null = function (v) { + if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) { + return true; + }; + return false; + }; + var empty = new CatQueue(Data_List_Types.Nil.value, Data_List_Types.Nil.value); + exports["CatQueue"] = CatQueue; + exports["empty"] = empty; + exports["null"] = $$null; + exports["snoc"] = snoc; + exports["uncons"] = uncons; +})(PS["Data.CatQueue"] = PS["Data.CatQueue"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Alt = PS["Control.Alt"]; + var Control_Alternative = PS["Control.Alternative"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad = PS["Control.Monad"]; + var Control_MonadPlus = PS["Control.MonadPlus"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Plus = PS["Control.Plus"]; + var Data_CatQueue = PS["Data.CatQueue"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_NaturalTransformation = PS["Data.NaturalTransformation"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var CatNil = (function () { + function CatNil() { + + }; + CatNil.value = new CatNil(); + return CatNil; + })(); + var CatCons = (function () { + function CatCons(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + CatCons.create = function (value0) { + return function (value1) { + return new CatCons(value0, value1); + }; + }; + return CatCons; + })(); + var link = function (v) { + return function (cat) { + if (v instanceof CatNil) { + return cat; + }; + if (v instanceof CatCons) { + return new CatCons(v.value0, Data_CatQueue.snoc(v.value1)(cat)); + }; + throw new Error("Failed pattern match at Data.CatList line 110, column 1 - line 110, column 54: " + [ v.constructor.name, cat.constructor.name ]); + }; + }; + var foldr = function (k) { + return function (b) { + return function (q) { + var foldl = function ($copy_v) { + return function ($copy_c) { + return function ($copy_v1) { + var $tco_var_v = $copy_v; + var $tco_var_c = $copy_c; + var $tco_done = false; + var $tco_result; + function $tco_loop(v, c, v1) { + if (v1 instanceof Data_List_Types.Nil) { + $tco_done = true; + return c; + }; + if (v1 instanceof Data_List_Types.Cons) { + $tco_var_v = v; + $tco_var_c = v(c)(v1.value0); + $copy_v1 = v1.value1; + return; + }; + throw new Error("Failed pattern match at Data.CatList line 125, column 3 - line 125, column 59: " + [ v.constructor.name, c.constructor.name, v1.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_v, $tco_var_c, $copy_v1); + }; + return $tco_result; + }; + }; + }; + var go = function ($copy_xs) { + return function ($copy_ys) { + var $tco_var_xs = $copy_xs; + var $tco_done = false; + var $tco_result; + function $tco_loop(xs, ys) { + var v = Data_CatQueue.uncons(xs); + if (v instanceof Data_Maybe.Nothing) { + $tco_done = true; + return foldl(function (x) { + return function (i) { + return i(x); + }; + })(b)(ys); + }; + if (v instanceof Data_Maybe.Just) { + $tco_var_xs = v.value0.value1; + $copy_ys = new Data_List_Types.Cons(k(v.value0.value0), ys); + return; + }; + throw new Error("Failed pattern match at Data.CatList line 121, column 14 - line 123, column 67: " + [ v.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_xs, $copy_ys); + }; + return $tco_result; + }; + }; + return go(q)(Data_List_Types.Nil.value); + }; + }; + }; + var uncons = function (v) { + if (v instanceof CatNil) { + return Data_Maybe.Nothing.value; + }; + if (v instanceof CatCons) { + return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, (function () { + var $41 = Data_CatQueue["null"](v.value1); + if ($41) { + return CatNil.value; + }; + return foldr(link)(CatNil.value)(v.value1); + })())); + }; + throw new Error("Failed pattern match at Data.CatList line 101, column 1 - line 101, column 61: " + [ v.constructor.name ]); + }; + var empty = CatNil.value; + var append = function (v) { + return function (v1) { + if (v1 instanceof CatNil) { + return v; + }; + if (v instanceof CatNil) { + return v1; + }; + return link(v)(v1); + }; + }; + var semigroupCatList = new Data_Semigroup.Semigroup(append); + var snoc = function (cat) { + return function (a) { + return append(cat)(new CatCons(a, Data_CatQueue.empty)); + }; + }; + exports["CatNil"] = CatNil; + exports["CatCons"] = CatCons; + exports["append"] = append; + exports["empty"] = empty; + exports["snoc"] = snoc; + exports["uncons"] = uncons; + exports["semigroupCatList"] = semigroupCatList; +})(PS["Data.CatList"] = PS["Data.CatList"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_CatList = PS["Data.CatList"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var Free = (function () { + function Free(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Free.create = function (value0) { + return function (value1) { + return new Free(value0, value1); + }; + }; + return Free; + })(); + var Return = (function () { + function Return(value0) { + this.value0 = value0; + }; + Return.create = function (value0) { + return new Return(value0); + }; + return Return; + })(); + var Bind = (function () { + function Bind(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Bind.create = function (value0) { + return function (value1) { + return new Bind(value0, value1); + }; + }; + return Bind; + })(); + var toView = function ($copy_v) { + var $tco_done = false; + var $tco_result; + function $tco_loop(v) { + var runExpF = function (v2) { + return v2; + }; + var concatF = function (v2) { + return function (r) { + return new Free(v2.value0, Data_Semigroup.append(Data_CatList.semigroupCatList)(v2.value1)(r)); + }; + }; + if (v.value0 instanceof Return) { + var v2 = Data_CatList.uncons(v.value1); + if (v2 instanceof Data_Maybe.Nothing) { + $tco_done = true; + return new Return(Unsafe_Coerce.unsafeCoerce(v.value0.value0)); + }; + if (v2 instanceof Data_Maybe.Just) { + $copy_v = Unsafe_Coerce.unsafeCoerce(concatF(runExpF(v2.value0.value0)(v.value0.value0))(v2.value0.value1)); + return; + }; + throw new Error("Failed pattern match at Control.Monad.Free line 215, column 7 - line 219, column 64: " + [ v2.constructor.name ]); + }; + if (v.value0 instanceof Bind) { + $tco_done = true; + return new Bind(v.value0.value0, function (a) { + return Unsafe_Coerce.unsafeCoerce(concatF(v.value0.value1(a))(v.value1)); + }); + }; + throw new Error("Failed pattern match at Control.Monad.Free line 213, column 3 - line 221, column 56: " + [ v.value0.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($copy_v); + }; + return $tco_result; + }; + var fromView = function (f) { + return new Free(Unsafe_Coerce.unsafeCoerce(f), Data_CatList.empty); + }; + var freeMonad = new Control_Monad.Monad(function () { + return freeApplicative; + }, function () { + return freeBind; + }); + var freeFunctor = new Data_Functor.Functor(function (k) { + return function (f) { + return Control_Bind.bindFlipped(freeBind)(function ($118) { + return Control_Applicative.pure(freeApplicative)(k($118)); + })(f); + }; + }); + var freeBind = new Control_Bind.Bind(function () { + return freeApply; + }, function (v) { + return function (k) { + return new Free(v.value0, Data_CatList.snoc(v.value1)(Unsafe_Coerce.unsafeCoerce(k))); + }; + }); + var freeApply = new Control_Apply.Apply(function () { + return freeFunctor; + }, Control_Monad.ap(freeMonad)); + var freeApplicative = new Control_Applicative.Applicative(function () { + return freeApply; + }, function ($119) { + return fromView(Return.create($119)); + }); + var liftF = function (f) { + return fromView(new Bind(Unsafe_Coerce.unsafeCoerce(f), function ($120) { + return Control_Applicative.pure(freeApplicative)(Unsafe_Coerce.unsafeCoerce($120)); + })); + }; + var foldFree = function (dictMonadRec) { + return function (k) { + var go = function (f) { + var v = toView(f); + if (v instanceof Return) { + return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(v.value0)); + }; + if (v instanceof Bind) { + return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(function ($127) { + return Control_Monad_Rec_Class.Loop.create(v.value1($127)); + })(k(v.value0)); + }; + throw new Error("Failed pattern match at Control.Monad.Free line 146, column 10 - line 148, column 37: " + [ v.constructor.name ]); + }; + return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); + }; + }; + exports["foldFree"] = foldFree; + exports["liftF"] = liftF; + exports["freeFunctor"] = freeFunctor; + exports["freeBind"] = freeBind; + exports["freeApplicative"] = freeApplicative; + exports["freeApply"] = freeApply; + exports["freeMonad"] = freeMonad; +})(PS["Control.Monad.Free"] = PS["Control.Monad.Free"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Comonad = PS["Control.Comonad"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Exists = PS["Data.Exists"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + var unCoyoneda = function (f) { + return function (v) { + return Data_Exists.runExists(function (v1) { + return f(v1.value0)(v1.value1); + })(v); + }; + }; + exports["unCoyoneda"] = unCoyoneda; +})(PS["Data.Coyoneda"] = PS["Data.Coyoneda"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Either = PS["Data.Either"]; + var Data_Exists = PS["Data.Exists"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Bound = (function () { + function Bound(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Bound.create = function (value0) { + return function (value1) { + return new Bound(value0, value1); + }; + }; + return Bound; + })(); + var FreeT = (function () { + function FreeT(value0) { + this.value0 = value0; + }; + FreeT.create = function (value0) { + return new FreeT(value0); + }; + return FreeT; + })(); + var Bind = (function () { + function Bind(value0) { + this.value0 = value0; + }; + Bind.create = function (value0) { + return new Bind(value0); + }; + return Bind; + })(); + var monadTransFreeT = function (dictFunctor) { + return new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { + return function (ma) { + return new FreeT(function (v) { + return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Either.Left.create)(ma); + }); + }; + }); + }; + var freeT = FreeT.create; + var bound = function (m) { + return function (f) { + return new Bind(Data_Exists.mkExists(new Bound(m, f))); + }; + }; + var functorFreeT = function (dictFunctor) { + return function (dictFunctor1) { + return new Data_Functor.Functor(function (f) { + return function (v) { + if (v instanceof FreeT) { + return new FreeT(function (v1) { + return Data_Functor.map(dictFunctor1)(Data_Bifunctor.bimap(Data_Either.bifunctorEither)(f)(Data_Functor.map(dictFunctor)(Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f))))(v.value0(Data_Unit.unit)); + }); + }; + if (v instanceof Bind) { + return Data_Exists.runExists(function (v1) { + return bound(v1.value0)(function ($104) { + return Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f)(v1.value1($104)); + }); + })(v.value0); + }; + throw new Error("Failed pattern match at Control.Monad.Free.Trans line 58, column 1 - line 58, column 71: " + [ f.constructor.name, v.constructor.name ]); + }; + }); + }; + }; + var monadFreeT = function (dictFunctor) { + return function (dictMonad) { + return new Control_Monad.Monad(function () { + return applicativeFreeT(dictFunctor)(dictMonad); + }, function () { + return bindFreeT(dictFunctor)(dictMonad); + }); + }; + }; + var bindFreeT = function (dictFunctor) { + return function (dictMonad) { + return new Control_Bind.Bind(function () { + return applyFreeT(dictFunctor)(dictMonad); + }, function (v) { + return function (f) { + if (v instanceof Bind) { + return Data_Exists.runExists(function (v1) { + return bound(v1.value0)(function (x) { + return bound(function (v2) { + return v1.value1(x); + })(f); + }); + })(v.value0); + }; + return bound(function (v1) { + return v; + })(f); + }; + }); + }; + }; + var applyFreeT = function (dictFunctor) { + return function (dictMonad) { + return new Control_Apply.Apply(function () { + return functorFreeT(dictFunctor)(((dictMonad.Bind1()).Apply0()).Functor0()); + }, Control_Monad.ap(monadFreeT(dictFunctor)(dictMonad))); + }; + }; + var applicativeFreeT = function (dictFunctor) { + return function (dictMonad) { + return new Control_Applicative.Applicative(function () { + return applyFreeT(dictFunctor)(dictMonad); + }, function (a) { + return new FreeT(function (v) { + return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Left(a)); + }); + }); + }; + }; + var liftFreeT = function (dictFunctor) { + return function (dictMonad) { + return function (fa) { + return new FreeT(function (v) { + return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(Data_Functor.map(dictFunctor)(Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad)))(fa))); + }); + }; + }; + }; + var resume = function (dictFunctor) { + return function (dictMonadRec) { + var go = function (v) { + if (v instanceof FreeT) { + return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(v.value0(Data_Unit.unit)); + }; + if (v instanceof Bind) { + return Data_Exists.runExists(function (v1) { + var v2 = v1.value0(Data_Unit.unit); + if (v2 instanceof FreeT) { + return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(v2.value0(Data_Unit.unit))(function (v3) { + if (v3 instanceof Data_Either.Left) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop(v1.value1(v3.value0))); + }; + if (v3 instanceof Data_Either.Right) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(new Data_Either.Right(Data_Functor.map(dictFunctor)(function (h) { + return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(h)(v1.value1); + })(v3.value0)))); + }; + throw new Error("Failed pattern match at Control.Monad.Free.Trans line 53, column 20 - line 55, column 67: " + [ v3.constructor.name ]); + }); + }; + if (v2 instanceof Bind) { + return Data_Exists.runExists(function (v3) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop(Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(v3.value0(Data_Unit.unit))(function (z) { + return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(v3.value1(z))(v1.value1); + }))); + })(v2.value0); + }; + throw new Error("Failed pattern match at Control.Monad.Free.Trans line 51, column 5 - line 56, column 98: " + [ v2.constructor.name ]); + })(v.value0); + }; + throw new Error("Failed pattern match at Control.Monad.Free.Trans line 48, column 3 - line 48, column 75: " + [ v.constructor.name ]); + }; + return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); + }; + }; + var runFreeT = function (dictFunctor) { + return function (dictMonadRec) { + return function (interp) { + var go = function (v) { + if (v instanceof Data_Either.Left) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(v.value0)); + }; + if (v instanceof Data_Either.Right) { + return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Loop.create)(interp(v.value0)); + }; + throw new Error("Failed pattern match at Control.Monad.Free.Trans line 127, column 3 - line 127, column 63: " + [ v.constructor.name ]); + }; + return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(Control_Bind.composeKleisliFlipped((dictMonadRec.Monad0()).Bind1())(go)(resume(dictFunctor)(dictMonadRec))); + }; + }; + }; + var monadRecFreeT = function (dictFunctor) { + return function (dictMonad) { + return new Control_Monad_Rec_Class.MonadRec(function () { + return monadFreeT(dictFunctor)(dictMonad); + }, function (f) { + var go = function (s) { + return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonad))(f(s))(function (v) { + if (v instanceof Control_Monad_Rec_Class.Loop) { + return go(v.value0); + }; + if (v instanceof Control_Monad_Rec_Class.Done) { + return Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad))(v.value0); + }; + throw new Error("Failed pattern match at Control.Monad.Free.Trans line 81, column 15 - line 83, column 25: " + [ v.constructor.name ]); + }); + }; + return go; + }); + }; + }; + exports["freeT"] = freeT; + exports["liftFreeT"] = liftFreeT; + exports["resume"] = resume; + exports["runFreeT"] = runFreeT; + exports["functorFreeT"] = functorFreeT; + exports["applyFreeT"] = applyFreeT; + exports["applicativeFreeT"] = applicativeFreeT; + exports["bindFreeT"] = bindFreeT; + exports["monadFreeT"] = monadFreeT; + exports["monadTransFreeT"] = monadTransFreeT; + exports["monadRecFreeT"] = monadRecFreeT; +})(PS["Control.Monad.Free.Trans"] = PS["Control.Monad.Free.Trans"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Except = PS["Control.Monad.Except"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Parallel = PS["Control.Parallel"]; + var Control_Parallel_Class = PS["Control.Parallel.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Either = PS["Data.Either"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Emit = (function () { + function Emit(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Emit.create = function (value0) { + return function (value1) { + return new Emit(value0, value1); + }; + }; + return Emit; + })(); + var runProcess = function (dictMonadRec) { + return Control_Monad_Free_Trans.runFreeT(Data_Identity.functorIdentity)(dictMonadRec)(function ($186) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($186)); + }); + }; + var profunctorAwait = new Data_Profunctor.Profunctor(function (f) { + return function (g) { + return function (v) { + return Data_Profunctor.dimap(Data_Profunctor.profunctorFn)(f)(g)(v); + }; + }; + }); + var loop = function (dictFunctor) { + return function (dictMonad) { + return function (me) { + return Control_Monad_Rec_Class.tailRecM(Control_Monad_Free_Trans.monadRecFreeT(dictFunctor)(dictMonad))(function (v) { + return Data_Functor.map(Control_Monad_Free_Trans.functorFreeT(dictFunctor)(((dictMonad.Bind1()).Apply0()).Functor0()))(Data_Maybe.maybe(new Control_Monad_Rec_Class.Loop(Data_Unit.unit))(Control_Monad_Rec_Class.Done.create))(me); + })(Data_Unit.unit); + }; + }; + }; + var fuseWithL = function (dictFunctor) { + return function (dictFunctor1) { + return function (dictFunctor2) { + return function (dictMonadRec) { + return function (zap) { + return function (fs) { + return function (gs) { + var go = function (v) { + return Control_Monad_Except_Trans.runExceptT(Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(dictMonadRec.Monad0()))(Control_Monad_Except_Trans.ExceptT(Control_Monad_Free_Trans.resume(dictFunctor)(dictMonadRec)(v.value0)))(function (v1) { + return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(dictMonadRec.Monad0()))(Control_Monad_Except_Trans.ExceptT(Control_Monad_Free_Trans.resume(dictFunctor1)(dictMonadRec)(v.value1)))(function (v2) { + return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonadRec.Monad0()))(Data_Functor.map(dictFunctor2)(function (t) { + return Control_Monad_Free_Trans.freeT(function (v3) { + return go(t); + }); + })(zap(Data_Tuple.Tuple.create)(v1)(v2))); + }); + })); + }; + return Control_Monad_Free_Trans.freeT(function (v) { + return go(new Data_Tuple.Tuple(fs, gs)); + }); + }; + }; + }; + }; + }; + }; + }; + var fuseWith = function (dictFunctor) { + return function (dictFunctor1) { + return function (dictFunctor2) { + return function (dictMonadRec) { + return function (dictParallel) { + return function (zap) { + return function (fs) { + return function (gs) { + var go = function (v) { + return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(Control_Parallel_Class.sequential(dictParallel)(Control_Apply.apply((dictParallel.Applicative1()).Apply0())(Data_Functor.map(((dictParallel.Applicative1()).Apply0()).Functor0())(Control_Apply.lift2(Data_Either.applyEither)(zap(Data_Tuple.Tuple.create)))(Control_Parallel_Class.parallel(dictParallel)(Control_Monad_Free_Trans.resume(dictFunctor)(dictMonadRec)(v.value0))))(Control_Parallel_Class.parallel(dictParallel)(Control_Monad_Free_Trans.resume(dictFunctor1)(dictMonadRec)(v.value1)))))(function (v1) { + if (v1 instanceof Data_Either.Left) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Data_Either.Left(v1.value0)); + }; + if (v1 instanceof Data_Either.Right) { + return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Data_Either.Right(Data_Functor.map(dictFunctor2)(function (t) { + return Control_Monad_Free_Trans.freeT(function (v2) { + return go(t); + }); + })(v1.value0))); + }; + throw new Error("Failed pattern match at Control.Coroutine line 80, column 5 - line 82, column 63: " + [ v1.constructor.name ]); + }); + }; + return Control_Monad_Free_Trans.freeT(function (v) { + return go(new Data_Tuple.Tuple(fs, gs)); + }); + }; + }; + }; + }; + }; + }; + }; + }; + var functorAwait = new Data_Functor.Functor(Data_Profunctor.rmap(profunctorAwait)); + var bifunctorEmit = new Data_Bifunctor.Bifunctor(function (f) { + return function (g) { + return function (v) { + return new Emit(f(v.value0), g(v.value1)); + }; + }; + }); + var functorEmit = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorEmit)); + var connect = function (dictMonadRec) { + return function (dictParallel) { + return fuseWith(functorEmit)(functorAwait)(Data_Identity.functorIdentity)(dictMonadRec)(dictParallel)(function (f) { + return function (v) { + return function (v1) { + return f(v.value1)(v1(v.value0)); + }; + }; + }); + }; + }; + var emit = function (dictMonad) { + return function (o) { + return Control_Monad_Free_Trans.liftFreeT(functorEmit)(dictMonad)(new Emit(o, Data_Unit.unit)); + }; + }; + var producer = function (dictMonad) { + return function (recv) { + return loop(functorEmit)(dictMonad)(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(functorEmit)(dictMonad))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(functorEmit))(dictMonad)(recv))(function (v) { + if (v instanceof Data_Either.Left) { + return Data_Functor.voidLeft(Control_Monad_Free_Trans.functorFreeT(functorEmit)(((dictMonad.Bind1()).Apply0()).Functor0()))(emit(dictMonad)(v.value0))(Data_Maybe.Nothing.value); + }; + if (v instanceof Data_Either.Right) { + return Control_Applicative.pure(Control_Monad_Free_Trans.applicativeFreeT(functorEmit)(dictMonad))(new Data_Maybe.Just(v.value0)); + }; + throw new Error("Failed pattern match at Control.Coroutine line 126, column 3 - line 128, column 29: " + [ v.constructor.name ]); + })); + }; + }; + var pullFrom = function (dictMonadRec) { + return fuseWithL(functorAwait)(functorEmit)(Data_Identity.functorIdentity)(dictMonadRec)(function (f) { + return function (v) { + return function (v1) { + return Control_Applicative.pure(Data_Identity.applicativeIdentity)(f(v(v1.value0))(v1.value1)); + }; + }; + }); + }; + var $$await = function (dictMonad) { + return Control_Monad_Free_Trans.liftFreeT(functorAwait)(dictMonad)(Control_Category.id(Control_Category.categoryFn)); + }; + exports["Emit"] = Emit; + exports["await"] = $$await; + exports["connect"] = connect; + exports["emit"] = emit; + exports["fuseWith"] = fuseWith; + exports["fuseWithL"] = fuseWithL; + exports["loop"] = loop; + exports["producer"] = producer; + exports["pullFrom"] = pullFrom; + exports["runProcess"] = runProcess; + exports["bifunctorEmit"] = bifunctorEmit; + exports["functorEmit"] = functorEmit; + exports["profunctorAwait"] = profunctorAwait; + exports["functorAwait"] = functorAwait; +})(PS["Control.Coroutine"] = PS["Control.Coroutine"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Aff_Internal = PS["Control.Monad.Aff.Internal"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Function = PS["Data.Function"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Maybe = PS["Data.Maybe"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var fromAVBox = Unsafe_Coerce.unsafeCoerce; + var killVar = function (q) { + return function (e) { + return fromAVBox(Control_Monad_Aff_Internal._killVar(Control_Monad_Aff.nonCanceler, q, e)); + }; + }; + var makeVar = fromAVBox(Control_Monad_Aff_Internal._makeVar(Control_Monad_Aff.nonCanceler)); + var peekVar = function (q) { + return fromAVBox(Control_Monad_Aff_Internal._peekVar(Control_Monad_Aff.nonCanceler, q)); + }; + var putVar = function (q) { + return function (a) { + return fromAVBox(Control_Monad_Aff_Internal._putVar(Control_Monad_Aff.nonCanceler, q, a)); + }; + }; + var takeVar = function (q) { + return fromAVBox(Control_Monad_Aff_Internal._takeVar(Control_Monad_Aff.nonCanceler, q)); + }; + exports["killVar"] = killVar; + exports["makeVar"] = makeVar; + exports["peekVar"] = peekVar; + exports["putVar"] = putVar; + exports["takeVar"] = takeVar; +})(PS["Control.Monad.Aff.AVar"] = PS["Control.Monad.Aff.AVar"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Coroutine = PS["Control.Coroutine"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"]; + var Control_Monad_Aff_Class = PS["Control.Monad.Aff.Class"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var Listening = (function () { + function Listening() { + + }; + Listening.value = new Listening(); + return Listening; + })(); + var Done = (function () { + function Done() { + + }; + Done.value = new Done(); + return Done; + })(); + var unEventSource = function (v) { + return v; + }; + var eqSubscribeStatus = new Data_Eq.Eq(function (x) { + return function (y) { + if (x instanceof Listening && y instanceof Listening) { + return true; + }; + if (x instanceof Done && y instanceof Done) { + return true; + }; + return false; + }; + }); + exports["Listening"] = Listening; + exports["Done"] = Done; + exports["unEventSource"] = unEventSource; + exports["eqSubscribeStatus"] = eqSubscribeStatus; +})(PS["Halogen.Query.EventSource"] = PS["Halogen.Query.EventSource"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var unFork = Unsafe_Coerce.unsafeCoerce; + exports["unFork"] = unFork; +})(PS["Halogen.Query.ForkF"] = PS["Halogen.Query.ForkF"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Applicative_Free = PS["Control.Applicative.Free"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad = PS["Control.Monad"]; + var Control_Monad_Aff_Class = PS["Control.Monad.Aff.Class"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Fork = PS["Control.Monad.Fork"]; + var Control_Monad_Fork_Class = PS["Control.Monad.Fork.Class"]; + var Control_Monad_Free = PS["Control.Monad.Free"]; + var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; + var Control_Parallel_Class = PS["Control.Parallel.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Coyoneda = PS["Data.Coyoneda"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_Query_EventSource = PS["Halogen.Query.EventSource"]; + var Halogen_Query_ForkF = PS["Halogen.Query.ForkF"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Prelude = PS["Prelude"]; + var HalogenM = function (x) { + return x; + }; + var State = (function () { + function State(value0) { + this.value0 = value0; + }; + State.create = function (value0) { + return new State(value0); + }; + return State; + })(); + var Subscribe = (function () { + function Subscribe(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Subscribe.create = function (value0) { + return function (value1) { + return new Subscribe(value0, value1); + }; + }; + return Subscribe; + })(); + var Lift = (function () { + function Lift(value0) { + this.value0 = value0; + }; + Lift.create = function (value0) { + return new Lift(value0); + }; + return Lift; + })(); + var Halt = (function () { + function Halt(value0) { + this.value0 = value0; + }; + Halt.create = function (value0) { + return new Halt(value0); + }; + return Halt; + })(); + var GetSlots = (function () { + function GetSlots(value0) { + this.value0 = value0; + }; + GetSlots.create = function (value0) { + return new GetSlots(value0); + }; + return GetSlots; + })(); + var CheckSlot = (function () { + function CheckSlot(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + CheckSlot.create = function (value0) { + return function (value1) { + return new CheckSlot(value0, value1); + }; + }; + return CheckSlot; + })(); + var ChildQuery = (function () { + function ChildQuery(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + ChildQuery.create = function (value0) { + return function (value1) { + return new ChildQuery(value0, value1); + }; + }; + return ChildQuery; + })(); + var Raise = (function () { + function Raise(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + Raise.create = function (value0) { + return function (value1) { + return new Raise(value0, value1); + }; + }; + return Raise; + })(); + var Par = (function () { + function Par(value0) { + this.value0 = value0; + }; + Par.create = function (value0) { + return new Par(value0); + }; + return Par; + })(); + var Fork = (function () { + function Fork(value0) { + this.value0 = value0; + }; + Fork.create = function (value0) { + return new Fork(value0); + }; + return Fork; + })(); + var GetRef = (function () { + function GetRef(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + GetRef.create = function (value0) { + return function (value1) { + return new GetRef(value0, value1); + }; + }; + return GetRef; + })(); + var functorHalogenM = new Data_Functor.Functor(function (f) { + return function (v) { + return Data_Functor.map(Control_Monad_Free.freeFunctor)(f)(v); + }; + }); + var applyHalogenM = new Control_Apply.Apply(function () { + return functorHalogenM; + }, function (v) { + return function (v1) { + return Control_Apply.apply(Control_Monad_Free.freeApply)(v)(v1); + }; + }); + var bindHalogenM = new Control_Bind.Bind(function () { + return applyHalogenM; + }, function (v) { + return function (f) { + return Control_Bind.bind(Control_Monad_Free.freeBind)(v)(function (x) { + var v1 = f(x); + return v1; + }); + }; + }); + var applicativeHalogenM = new Control_Applicative.Applicative(function () { + return applyHalogenM; + }, function (a) { + return Control_Applicative.pure(Control_Monad_Free.freeApplicative)(a); + }); + var monadHalogenM = new Control_Monad.Monad(function () { + return applicativeHalogenM; + }, function () { + return bindHalogenM; + }); + var monadEffHalogenM = function (dictMonadEff) { + return new Control_Monad_Eff_Class.MonadEff(function () { + return monadHalogenM; + }, function (eff) { + return HalogenM(Control_Monad_Free.liftF(Lift.create(Control_Monad_Eff_Class.liftEff(dictMonadEff)(eff)))); + }); + }; + var monadStateHalogenM = new Control_Monad_State_Class.MonadState(function () { + return monadHalogenM; + }, function ($70) { + return HalogenM(Control_Monad_Free.liftF(State.create($70))); + }); + exports["State"] = State; + exports["Subscribe"] = Subscribe; + exports["Lift"] = Lift; + exports["Halt"] = Halt; + exports["GetSlots"] = GetSlots; + exports["CheckSlot"] = CheckSlot; + exports["ChildQuery"] = ChildQuery; + exports["Raise"] = Raise; + exports["Par"] = Par; + exports["Fork"] = Fork; + exports["GetRef"] = GetRef; + exports["HalogenM"] = HalogenM; + exports["functorHalogenM"] = functorHalogenM; + exports["applyHalogenM"] = applyHalogenM; + exports["applicativeHalogenM"] = applicativeHalogenM; + exports["bindHalogenM"] = bindHalogenM; + exports["monadHalogenM"] = monadHalogenM; + exports["monadEffHalogenM"] = monadEffHalogenM; + exports["monadStateHalogenM"] = monadStateHalogenM; +})(PS["Halogen.Query.HalogenM"] = PS["Halogen.Query.HalogenM"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Const = PS["Data.Const"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var ComponentSlot = (function () { + function ComponentSlot(value0, value1, value2, value3, value4, value5) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + }; + ComponentSlot.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return function (value4) { + return function (value5) { + return new ComponentSlot(value0, value1, value2, value3, value4, value5); + }; + }; + }; + }; + }; + }; + return ComponentSlot; + })(); + var unComponentSlot = function (f) { + return function (cs) { + var v = Unsafe_Coerce.unsafeCoerce(cs); + return f(v.value0)(v.value1)(v.value2)(v.value3)(v.value4)(v.value5); + }; + }; + var unComponent = Unsafe_Coerce.unsafeCoerce; + var mkComponentSlot = Unsafe_Coerce.unsafeCoerce(ComponentSlot.create); + var mkComponent = Unsafe_Coerce.unsafeCoerce; + var parentComponent = function (dictOrd) { + return function (spec) { + return mkComponent({ + initialState: spec.initialState, + render: spec.render, + "eval": spec["eval"], + receiver: spec.receiver, + initializer: Data_Maybe.Nothing.value, + finalizer: Data_Maybe.Nothing.value, + mkOrdBox: Halogen_Data_OrdBox.mkOrdBox(dictOrd) + }); + }; + }; + var lifecycleComponent = function (dictBifunctor) { + return function (spec) { + return mkComponent({ + initialState: spec.initialState, + render: Unsafe_Coerce.unsafeCoerce(spec.render), + "eval": spec["eval"], + receiver: spec.receiver, + initializer: spec.initializer, + finalizer: spec.finalizer, + mkOrdBox: Halogen_Data_OrdBox.mkOrdBox(Data_Ord.ordVoid) + }); + }; + }; + var component = function (dictBifunctor) { + return function (spec) { + return lifecycleComponent(dictBifunctor)({ + initialState: spec.initialState, + render: spec.render, + "eval": spec["eval"], + receiver: spec.receiver, + initializer: Data_Maybe.Nothing.value, + finalizer: Data_Maybe.Nothing.value + }); + }; + }; + exports["component"] = component; + exports["lifecycleComponent"] = lifecycleComponent; + exports["mkComponent"] = mkComponent; + exports["mkComponentSlot"] = mkComponentSlot; + exports["parentComponent"] = parentComponent; + exports["unComponent"] = unComponent; + exports["unComponentSlot"] = unComponentSlot; +})(PS["Halogen.Component"] = PS["Halogen.Component"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Prelude = PS["Prelude"]; + var Choice = function (Profunctor0, left, right) { + this.Profunctor0 = Profunctor0; + this.left = left; + this.right = right; + }; + var right = function (dict) { + return dict.right; + }; + var left = function (dict) { + return dict.left; + }; + exports["Choice"] = Choice; + exports["left"] = left; + exports["right"] = right; +})(PS["Data.Profunctor.Choice"] = PS["Data.Profunctor.Choice"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Const = PS["Data.Const"]; + var Data_Either = PS["Data.Either"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Lens_Internal_Wander = PS["Data.Lens.Internal.Wander"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; + var Data_Profunctor_Cochoice = PS["Data.Profunctor.Cochoice"]; + var Data_Profunctor_Strong = PS["Data.Profunctor.Strong"]; + var Data_Tuple = PS["Data.Tuple"]; + var Prelude = PS["Prelude"]; + var Forget = function (x) { + return x; + }; + var profunctorForget = new Data_Profunctor.Profunctor(function (f) { + return function (v) { + return function (v1) { + return function ($25) { + return v1(f($25)); + }; + }; + }; + }); + var newtypeForget = new Data_Newtype.Newtype(function (n) { + return n; + }, Forget); + var choiceForget = function (dictMonoid) { + return new Data_Profunctor_Choice.Choice(function () { + return profunctorForget; + }, function (v) { + return Data_Either.either(v)(Data_Monoid.mempty(Data_Monoid.monoidFn(dictMonoid))); + }, function (v) { + return Data_Either.either(Data_Monoid.mempty(Data_Monoid.monoidFn(dictMonoid)))(v); + }); + }; + exports["Forget"] = Forget; + exports["newtypeForget"] = newtypeForget; + exports["profunctorForget"] = profunctorForget; + exports["choiceForget"] = choiceForget; +})(PS["Data.Lens.Internal.Forget"] = PS["Data.Lens.Internal.Forget"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Lens_Internal_Forget = PS["Data.Lens.Internal.Forget"]; + var Data_Lens_Internal_Indexed = PS["Data.Lens.Internal.Indexed"]; + var Data_Lens_Types = PS["Data.Lens.Types"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Maybe_First = PS["Data.Maybe.First"]; + var Data_Maybe_Last = PS["Data.Maybe.Last"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Monoid_Additive = PS["Data.Monoid.Additive"]; + var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; + var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; + var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; + var Data_Monoid_Endo = PS["Data.Monoid.Endo"]; + var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Prelude = PS["Prelude"]; + var foldMapOf = Data_Newtype.under(Data_Lens_Internal_Forget.newtypeForget)(Data_Lens_Internal_Forget.newtypeForget)(Data_Lens_Internal_Forget.Forget); + var preview = function (p) { + return function ($62) { + return Data_Newtype.unwrap(Data_Maybe_First.newtypeFirst)(foldMapOf(p)(function ($63) { + return Data_Maybe_First.First(Data_Maybe.Just.create($63)); + })($62)); + }; + }; + exports["foldMapOf"] = foldMapOf; + exports["preview"] = preview; +})(PS["Data.Lens.Fold"] = PS["Data.Lens.Fold"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Either = PS["Data.Either"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; + var Data_Profunctor_Costrong = PS["Data.Profunctor.Costrong"]; + var Data_Tuple = PS["Data.Tuple"]; + var Tagged = function (x) { + return x; + }; + var taggedProfunctor = new Data_Profunctor.Profunctor(function (v) { + return function (g) { + return function (v1) { + return g(v1); + }; + }; + }); + var taggedChoice = new Data_Profunctor_Choice.Choice(function () { + return taggedProfunctor; + }, function (v) { + return new Data_Either.Left(v); + }, function (v) { + return new Data_Either.Right(v); + }); + var newtypeTagged = new Data_Newtype.Newtype(function (n) { + return n; + }, Tagged); + exports["Tagged"] = Tagged; + exports["newtypeTagged"] = newtypeTagged; + exports["taggedProfunctor"] = taggedProfunctor; + exports["taggedChoice"] = taggedChoice; +})(PS["Data.Lens.Internal.Tagged"] = PS["Data.Lens.Internal.Tagged"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_MonadPlus = PS["Control.MonadPlus"]; + var Control_MonadZero = PS["Control.MonadZero"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Lens_Internal_Market = PS["Data.Lens.Internal.Market"]; + var Data_Lens_Internal_Tagged = PS["Data.Lens.Internal.Tagged"]; + var Data_Lens_Types = PS["Data.Lens.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Profunctor = PS["Data.Profunctor"]; + var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; + var Prelude = PS["Prelude"]; + var review = Data_Newtype.under(Data_Lens_Internal_Tagged.newtypeTagged)(Data_Lens_Internal_Tagged.newtypeTagged)(Data_Lens_Internal_Tagged.Tagged); + var prism = function (to) { + return function (fro) { + return function (dictChoice) { + return function (pab) { + return Data_Profunctor.dimap(dictChoice.Profunctor0())(fro)(Data_Either.either(Control_Category.id(Control_Category.categoryFn))(Control_Category.id(Control_Category.categoryFn)))(Data_Profunctor_Choice.right(dictChoice)(Data_Profunctor.rmap(dictChoice.Profunctor0())(to)(pab))); + }; + }; + }; + }; + var prism$prime = function (to) { + return function (fro) { + return function (dictChoice) { + return prism(to)(function (s) { + return Data_Maybe.maybe(new Data_Either.Left(s))(Data_Either.Right.create)(fro(s)); + })(dictChoice); + }; + }; + }; + exports["prism"] = prism; + exports["prism'"] = prism$prime; + exports["review"] = review; +})(PS["Data.Lens.Prism"] = PS["Data.Lens.Prism"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Either = PS["Data.Either"]; + var Data_Void = PS["Data.Void"]; + var in1 = Data_Either.Left.create; + var at1 = function (b) { + return function (f) { + return function (y) { + if (y instanceof Data_Either.Left) { + return f(y.value0); + }; + return b; + }; + }; + }; + exports["at1"] = at1; + exports["in1"] = in1; +})(PS["Data.Either.Nested"] = PS["Data.Either.Nested"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Comonad = PS["Control.Comonad"]; + var Control_Extend = PS["Control.Extend"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Bifunctor = PS["Data.Bifunctor"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Prelude = PS["Prelude"]; + var left = function (fa) { + return new Data_Either.Left(fa); + }; + exports["left"] = left; +})(PS["Data.Functor.Coproduct"] = PS["Data.Functor.Coproduct"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Const = PS["Data.Const"]; + var Data_Either = PS["Data.Either"]; + var Data_Functor_Coproduct = PS["Data.Functor.Coproduct"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Void = PS["Data.Void"]; + var Prelude = PS["Prelude"]; + var in1 = Data_Functor_Coproduct.left; + var at1 = function (b) { + return function (f) { + return function (y) { + if (y instanceof Data_Either.Left) { + return f(y.value0); + }; + return b; + }; + }; + }; + exports["at1"] = at1; + exports["in1"] = in1; +})(PS["Data.Functor.Coproduct.Nested"] = PS["Data.Functor.Coproduct.Nested"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Data_Either = PS["Data.Either"]; + var Data_Either_Nested = PS["Data.Either.Nested"]; + var Data_Functor_Coproduct = PS["Data.Functor.Coproduct"]; + var Data_Functor_Coproduct_Nested = PS["Data.Functor.Coproduct.Nested"]; + var Data_Lens = PS["Data.Lens"]; + var Data_Lens_Prism = PS["Data.Lens.Prism"]; + var Data_Maybe = PS["Data.Maybe"]; + var _Either1 = function (dictChoice) { + return Data_Lens_Prism["prism'"](Data_Either_Nested.in1)(Data_Either_Nested.at1(Data_Maybe.Nothing.value)(Data_Maybe.Just.create))(dictChoice); + }; + var _Coproduct1 = function (dictChoice) { + return Data_Lens_Prism["prism'"](Data_Functor_Coproduct_Nested.in1)(Data_Functor_Coproduct_Nested.at1(Data_Maybe.Nothing.value)(Data_Maybe.Just.create))(dictChoice); + }; + exports["_Coproduct1"] = _Coproduct1; + exports["_Either1"] = _Either1; +})(PS["Halogen.Data.Prism"] = PS["Halogen.Data.Prism"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Lens = PS["Data.Lens"]; + var Data_Lens_Fold = PS["Data.Lens.Fold"]; + var Data_Lens_Internal_Forget = PS["Data.Lens.Internal.Forget"]; + var Data_Lens_Internal_Tagged = PS["Data.Lens.Internal.Tagged"]; + var Data_Lens_Prism = PS["Data.Lens.Prism"]; + var Data_Lens_Prism_Coproduct = PS["Data.Lens.Prism.Coproduct"]; + var Data_Lens_Prism_Either = PS["Data.Lens.Prism.Either"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Maybe_First = PS["Data.Maybe.First"]; + var Halogen_Data_Prism = PS["Halogen.Data.Prism"]; + var Prelude = PS["Prelude"]; + var ChildPath = (function () { + function ChildPath(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + ChildPath.create = function (value0) { + return function (value1) { + return new ChildPath(value0, value1); + }; + }; + return ChildPath; + })(); + var prjQuery = function (v) { + return Data_Lens_Fold.preview(v.value0(Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst))); + }; + var injSlot = function (v) { + return Data_Lens_Prism.review(v.value1(Data_Lens_Internal_Tagged.taggedChoice)); + }; + var injQuery = function (v) { + return Data_Lens_Prism.review(v.value0(Data_Lens_Internal_Tagged.taggedChoice)); + }; + var cp1 = new ChildPath(function (dictChoice) { + return Halogen_Data_Prism._Coproduct1(dictChoice); + }, function (dictChoice) { + return Halogen_Data_Prism._Either1(dictChoice); + }); + exports["ChildPath"] = ChildPath; + exports["cp1"] = cp1; + exports["injQuery"] = injQuery; + exports["injSlot"] = injSlot; + exports["prjQuery"] = prjQuery; +})(PS["Halogen.Component.ChildPath"] = PS["Halogen.Component.ChildPath"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_HTML_Indexed = PS["DOM.HTML.Indexed"]; + var DOM_HTML_Indexed_ButtonType = PS["DOM.HTML.Indexed.ButtonType"]; + var DOM_HTML_Indexed_FormMethod = PS["DOM.HTML.Indexed.FormMethod"]; + var DOM_HTML_Indexed_InputType = PS["DOM.HTML.Indexed.InputType"]; + var DOM_HTML_Indexed_MenuType = PS["DOM.HTML.Indexed.MenuType"]; + var DOM_HTML_Indexed_MenuitemType = PS["DOM.HTML.Indexed.MenuitemType"]; + var DOM_HTML_Indexed_OnOff = PS["DOM.HTML.Indexed.OnOff"]; + var DOM_HTML_Indexed_OrderedListType = PS["DOM.HTML.Indexed.OrderedListType"]; + var DOM_HTML_Indexed_PreloadValue = PS["DOM.HTML.Indexed.PreloadValue"]; + var DOM_HTML_Indexed_StepValue = PS["DOM.HTML.Indexed.StepValue"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_MediaType = PS["Data.MediaType"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_String = PS["Data.String"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var prop = function (dictIsProp) { + return Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.prop(dictIsProp)); + }; + var value = prop(Halogen_HTML_Core.stringIsProp)("value"); + var classes = function ($8) { + return prop(Halogen_HTML_Core.stringIsProp)("className")(Data_String.joinWith(" ")(Data_Functor.map(Data_Functor.functorArray)(Data_Newtype.unwrap(Halogen_HTML_Core.newtypeClassName))($8))); + }; + var attr = Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.attr(Data_Maybe.Nothing.value)); + exports["attr"] = attr; + exports["classes"] = classes; + exports["prop"] = prop; + exports["value"] = value; +})(PS["Halogen.HTML.Properties"] = PS["Halogen.HTML.Properties"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_HTML_Indexed = PS["DOM.HTML.Indexed"]; + var Data_Function = PS["Data.Function"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Tuple = PS["Data.Tuple"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Halogen_VDom = PS["Halogen.VDom"]; + var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var element = Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.element(Data_Maybe.Nothing.value)); + var h1 = element("h1"); + var h1_ = h1([ ]); + var div = element("div"); + var div_ = div([ ]); + exports["div"] = div; + exports["div_"] = div_; + exports["element"] = element; + exports["h1"] = h1; + exports["h1_"] = h1_; +})(PS["Halogen.HTML.Elements"] = PS["Halogen.HTML.Elements"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Halogen_Component = PS["Halogen.Component"]; + var Halogen_Component_ChildPath = PS["Halogen.Component.ChildPath"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; + var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; + var Prelude = PS["Prelude"]; + var slot$prime = function (i) { + return function (p) { + return function (component) { + return function (input) { + return function (outputQuery) { + var pq = Halogen_Component_ChildPath.prjQuery(i); + var f = function ($2) { + return Data_Functor.map(Data_Maybe.functorMaybe)(Halogen_Component_ChildPath.injQuery(i))(Halogen_Component.unComponent(function (v) { + return v.receiver; + })(component)($2)); + }; + return Halogen_HTML_Core.slot(Halogen_Component.mkComponentSlot(Halogen_Component_ChildPath.injSlot(i)(p))(component)(input)(f)(outputQuery)(pq)); + }; + }; + }; + }; + }; + var slot = function (p) { + return function (component) { + return function (input) { + return function (outputQuery) { + var f = Halogen_Component.unComponent(function (v) { + return v.receiver; + })(component); + return Halogen_HTML_Core.slot(Halogen_Component.mkComponentSlot(p)(component)(input)(f)(outputQuery)(Data_Maybe.Just.create)); + }; + }; + }; + }; + exports["slot"] = slot; + exports["slot'"] = slot$prime; +})(PS["Halogen.HTML"] = PS["Halogen.HTML"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var CSS_Property = PS["CSS.Property"]; + var CSS_Render = PS["CSS.Render"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Array = PS["Data.Array"]; + var Data_Either = PS["Data.Either"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_MediaType = PS["Data.MediaType"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_StrMap = PS["Data.StrMap"]; + var Data_String = PS["Data.String"]; + var Data_Tuple = PS["Data.Tuple"]; + var Halogen_HTML = PS["Halogen.HTML"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; + var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; + var Prelude = PS["Prelude"]; + var style = (function () { + var toString = function ($4) { + return Data_String.joinWith("; ")(Data_StrMap.foldMap(Data_Monoid.monoidArray)(function (key) { + return function (val) { + return [ key + (": " + val) ]; + }; + })($4)); + }; + var rights = Data_Array.concatMap(Data_Foldable.foldMap(Data_Either.foldableEither)(Data_Monoid.monoidArray)(Data_Array.singleton)); + var property = function (v) { + if (v instanceof CSS_Stylesheet.Property) { + return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, v.value1)); + }; + return Data_Maybe.Nothing.value; + }; + var rules = function (rs) { + var properties = Control_Bind.bind(Control_Bind.bindArray)(Data_Array.mapMaybe(property)(rs))(function ($5) { + return rights(CSS_Render.collect($5)); + }); + return Data_StrMap.fromFoldable(Data_Foldable.foldableArray)(properties); + }; + return function ($6) { + return Halogen_HTML_Properties.attr("style")(toString(rules(CSS_Stylesheet.runS($6)))); + }; + })(); + exports["style"] = style; +})(PS["Halogen.HTML.CSS"] = PS["Halogen.HTML.CSS"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var touchstart = "touchstart"; + var touchmove = "touchmove"; + var touchend = "touchend"; + var mouseup = "mouseup"; + var mousemove = "mousemove"; + var mousedown = "mousedown"; + var load = "load"; + exports["load"] = load; + exports["mousedown"] = mousedown; + exports["mousemove"] = mousemove; + exports["mouseup"] = mouseup; + exports["touchend"] = touchend; + exports["touchmove"] = touchmove; + exports["touchstart"] = touchstart; +})(PS["DOM.HTML.Event.EventTypes"] = PS["DOM.HTML.Event.EventTypes"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Apply = PS["Control.Apply"]; + var Control_Category = PS["Control.Category"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_List = PS["Data.List"]; + var Data_List_Lazy = PS["Data.List.Lazy"]; + var Data_List_Lazy_Types = PS["Data.List.Lazy.Types"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Monoid = PS["Data.Monoid"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Ordering = PS["Data.Ordering"]; + var Data_Semigroup = PS["Data.Semigroup"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Show = PS["Data.Show"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unfoldable = PS["Data.Unfoldable"]; + var Partial_Unsafe = PS["Partial.Unsafe"]; + var Prelude = PS["Prelude"]; + var Leaf = (function () { + function Leaf() { + + }; + Leaf.value = new Leaf(); + return Leaf; + })(); + var Two = (function () { + function Two(value0, value1, value2, value3) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + }; + Two.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return new Two(value0, value1, value2, value3); + }; + }; + }; + }; + return Two; + })(); + var Three = (function () { + function Three(value0, value1, value2, value3, value4, value5, value6) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + this.value6 = value6; + }; + Three.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return function (value4) { + return function (value5) { + return function (value6) { + return new Three(value0, value1, value2, value3, value4, value5, value6); + }; + }; + }; + }; + }; + }; + }; + return Three; + })(); + var TwoLeft = (function () { + function TwoLeft(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + TwoLeft.create = function (value0) { + return function (value1) { + return function (value2) { + return new TwoLeft(value0, value1, value2); + }; + }; + }; + return TwoLeft; + })(); + var TwoRight = (function () { + function TwoRight(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + TwoRight.create = function (value0) { + return function (value1) { + return function (value2) { + return new TwoRight(value0, value1, value2); + }; + }; + }; + return TwoRight; + })(); + var ThreeLeft = (function () { + function ThreeLeft(value0, value1, value2, value3, value4, value5) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + }; + ThreeLeft.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return function (value4) { + return function (value5) { + return new ThreeLeft(value0, value1, value2, value3, value4, value5); + }; + }; + }; + }; + }; + }; + return ThreeLeft; + })(); + var ThreeMiddle = (function () { + function ThreeMiddle(value0, value1, value2, value3, value4, value5) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + }; + ThreeMiddle.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return function (value4) { + return function (value5) { + return new ThreeMiddle(value0, value1, value2, value3, value4, value5); + }; + }; + }; + }; + }; + }; + return ThreeMiddle; + })(); + var ThreeRight = (function () { + function ThreeRight(value0, value1, value2, value3, value4, value5) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + this.value4 = value4; + this.value5 = value5; + }; + ThreeRight.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return function (value4) { + return function (value5) { + return new ThreeRight(value0, value1, value2, value3, value4, value5); + }; + }; + }; + }; + }; + }; + return ThreeRight; + })(); + var KickUp = (function () { + function KickUp(value0, value1, value2, value3) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + this.value3 = value3; + }; + KickUp.create = function (value0) { + return function (value1) { + return function (value2) { + return function (value3) { + return new KickUp(value0, value1, value2, value3); + }; + }; + }; + }; + return KickUp; + })(); + var values = function (v) { + if (v instanceof Leaf) { + return Data_List_Types.Nil.value; + }; + if (v instanceof Two) { + return Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value2))(values(v.value3))); + }; + if (v instanceof Three) { + return Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value2))(Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value3))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value5))(values(v.value6))))); + }; + throw new Error("Failed pattern match at Data.Map line 553, column 1 - line 553, column 40: " + [ v.constructor.name ]); + }; + var lookup = function (dictOrd) { + return function (k) { + var comp = Data_Ord.compare(dictOrd); + var go = function ($copy_v) { + var $tco_done = false; + var $tco_result; + function $tco_loop(v) { + if (v instanceof Leaf) { + $tco_done = true; + return Data_Maybe.Nothing.value; + }; + if (v instanceof Two) { + var v2 = comp(k)(v.value1); + if (v2 instanceof Data_Ordering.EQ) { + $tco_done = true; + return new Data_Maybe.Just(v.value2); + }; + if (v2 instanceof Data_Ordering.LT) { + $copy_v = v.value0; + return; + }; + $copy_v = v.value3; + return; + }; + if (v instanceof Three) { + var v3 = comp(k)(v.value1); + if (v3 instanceof Data_Ordering.EQ) { + $tco_done = true; + return new Data_Maybe.Just(v.value2); + }; + var v4 = comp(k)(v.value4); + if (v4 instanceof Data_Ordering.EQ) { + $tco_done = true; + return new Data_Maybe.Just(v.value5); + }; + if (v3 instanceof Data_Ordering.LT) { + $copy_v = v.value0; + return; + }; + if (v4 instanceof Data_Ordering.GT) { + $copy_v = v.value6; + return; + }; + $copy_v = v.value3; + return; + }; + throw new Error("Failed pattern match at Data.Map line 162, column 5 - line 162, column 22: " + [ v.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($copy_v); + }; + return $tco_result; + }; + return go; + }; + }; + var member = function (dictOrd) { + return function (k) { + return function (m) { + return Data_Maybe.isJust(lookup(dictOrd)(k)(m)); + }; + }; + }; + var keys = function (v) { + if (v instanceof Leaf) { + return Data_List_Types.Nil.value; + }; + if (v instanceof Two) { + return Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value1))(keys(v.value3))); + }; + if (v instanceof Three) { + return Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value1))(Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value3))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value4))(keys(v.value6))))); + }; + throw new Error("Failed pattern match at Data.Map line 547, column 1 - line 547, column 38: " + [ v.constructor.name ]); + }; + var functorMap = new Data_Functor.Functor(function (v) { + return function (v1) { + if (v1 instanceof Leaf) { + return Leaf.value; + }; + if (v1 instanceof Two) { + return new Two(Data_Functor.map(functorMap)(v)(v1.value0), v1.value1, v(v1.value2), Data_Functor.map(functorMap)(v)(v1.value3)); + }; + if (v1 instanceof Three) { + return new Three(Data_Functor.map(functorMap)(v)(v1.value0), v1.value1, v(v1.value2), Data_Functor.map(functorMap)(v)(v1.value3), v1.value4, v(v1.value5), Data_Functor.map(functorMap)(v)(v1.value6)); + }; + throw new Error("Failed pattern match at Data.Map line 87, column 1 - line 87, column 39: " + [ v.constructor.name, v1.constructor.name ]); + }; + }); + var fromZipper = function ($copy_dictOrd) { + return function ($copy_v) { + return function ($copy_tree) { + var $tco_var_dictOrd = $copy_dictOrd; + var $tco_var_v = $copy_v; + var $tco_done = false; + var $tco_result; + function $tco_loop(dictOrd, v, tree) { + if (v instanceof Data_List_Types.Nil) { + $tco_done = true; + return tree; + }; + if (v instanceof Data_List_Types.Cons) { + if (v.value0 instanceof TwoLeft) { + $tco_var_dictOrd = dictOrd; + $tco_var_v = v.value1; + $copy_tree = new Two(tree, v.value0.value0, v.value0.value1, v.value0.value2); + return; + }; + if (v.value0 instanceof TwoRight) { + $tco_var_dictOrd = dictOrd; + $tco_var_v = v.value1; + $copy_tree = new Two(v.value0.value0, v.value0.value1, v.value0.value2, tree); + return; + }; + if (v.value0 instanceof ThreeLeft) { + $tco_var_dictOrd = dictOrd; + $tco_var_v = v.value1; + $copy_tree = new Three(tree, v.value0.value0, v.value0.value1, v.value0.value2, v.value0.value3, v.value0.value4, v.value0.value5); + return; + }; + if (v.value0 instanceof ThreeMiddle) { + $tco_var_dictOrd = dictOrd; + $tco_var_v = v.value1; + $copy_tree = new Three(v.value0.value0, v.value0.value1, v.value0.value2, tree, v.value0.value3, v.value0.value4, v.value0.value5); + return; + }; + if (v.value0 instanceof ThreeRight) { + $tco_var_dictOrd = dictOrd; + $tco_var_v = v.value1; + $copy_tree = new Three(v.value0.value0, v.value0.value1, v.value0.value2, v.value0.value3, v.value0.value4, v.value0.value5, tree); + return; + }; + throw new Error("Failed pattern match at Data.Map line 376, column 3 - line 381, column 88: " + [ v.value0.constructor.name ]); + }; + throw new Error("Failed pattern match at Data.Map line 373, column 1 - line 373, column 80: " + [ v.constructor.name, tree.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_dictOrd, $tco_var_v, $copy_tree); + }; + return $tco_result; + }; + }; + }; + var insert = function (dictOrd) { + return function (k) { + return function (v) { + var up = function ($copy_v1) { + return function ($copy_v2) { + var $tco_var_v1 = $copy_v1; + var $tco_done = false; + var $tco_result; + function $tco_loop(v1, v2) { + if (v1 instanceof Data_List_Types.Nil) { + $tco_done = true; + return new Two(v2.value0, v2.value1, v2.value2, v2.value3); + }; + if (v1 instanceof Data_List_Types.Cons) { + if (v1.value0 instanceof TwoLeft) { + $tco_done = true; + return fromZipper(dictOrd)(v1.value1)(new Three(v2.value0, v2.value1, v2.value2, v2.value3, v1.value0.value0, v1.value0.value1, v1.value0.value2)); + }; + if (v1.value0 instanceof TwoRight) { + $tco_done = true; + return fromZipper(dictOrd)(v1.value1)(new Three(v1.value0.value0, v1.value0.value1, v1.value0.value2, v2.value0, v2.value1, v2.value2, v2.value3)); + }; + if (v1.value0 instanceof ThreeLeft) { + $tco_var_v1 = v1.value1; + $copy_v2 = new KickUp(new Two(v2.value0, v2.value1, v2.value2, v2.value3), v1.value0.value0, v1.value0.value1, new Two(v1.value0.value2, v1.value0.value3, v1.value0.value4, v1.value0.value5)); + return; + }; + if (v1.value0 instanceof ThreeMiddle) { + $tco_var_v1 = v1.value1; + $copy_v2 = new KickUp(new Two(v1.value0.value0, v1.value0.value1, v1.value0.value2, v2.value0), v2.value1, v2.value2, new Two(v2.value3, v1.value0.value3, v1.value0.value4, v1.value0.value5)); + return; + }; + if (v1.value0 instanceof ThreeRight) { + $tco_var_v1 = v1.value1; + $copy_v2 = new KickUp(new Two(v1.value0.value0, v1.value0.value1, v1.value0.value2, v1.value0.value3), v1.value0.value4, v1.value0.value5, new Two(v2.value0, v2.value1, v2.value2, v2.value3)); + return; + }; + throw new Error("Failed pattern match at Data.Map line 412, column 5 - line 417, column 108: " + [ v1.value0.constructor.name, v2.constructor.name ]); + }; + throw new Error("Failed pattern match at Data.Map line 409, column 3 - line 409, column 56: " + [ v1.constructor.name, v2.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_v1, $copy_v2); + }; + return $tco_result; + }; + }; + var comp = Data_Ord.compare(dictOrd); + var down = function ($copy_ctx) { + return function ($copy_v1) { + var $tco_var_ctx = $copy_ctx; + var $tco_done = false; + var $tco_result; + function $tco_loop(ctx, v1) { + if (v1 instanceof Leaf) { + $tco_done = true; + return up(ctx)(new KickUp(Leaf.value, k, v, Leaf.value)); + }; + if (v1 instanceof Two) { + var v2 = comp(k)(v1.value1); + if (v2 instanceof Data_Ordering.EQ) { + $tco_done = true; + return fromZipper(dictOrd)(ctx)(new Two(v1.value0, k, v, v1.value3)); + }; + if (v2 instanceof Data_Ordering.LT) { + $tco_var_ctx = new Data_List_Types.Cons(new TwoLeft(v1.value1, v1.value2, v1.value3), ctx); + $copy_v1 = v1.value0; + return; + }; + $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(v1.value0, v1.value1, v1.value2), ctx); + $copy_v1 = v1.value3; + return; + }; + if (v1 instanceof Three) { + var v3 = comp(k)(v1.value1); + if (v3 instanceof Data_Ordering.EQ) { + $tco_done = true; + return fromZipper(dictOrd)(ctx)(new Three(v1.value0, k, v, v1.value3, v1.value4, v1.value5, v1.value6)); + }; + var v4 = comp(k)(v1.value4); + if (v4 instanceof Data_Ordering.EQ) { + $tco_done = true; + return fromZipper(dictOrd)(ctx)(new Three(v1.value0, v1.value1, v1.value2, v1.value3, k, v, v1.value6)); + }; + if (v3 instanceof Data_Ordering.LT) { + $tco_var_ctx = new Data_List_Types.Cons(new ThreeLeft(v1.value1, v1.value2, v1.value3, v1.value4, v1.value5, v1.value6), ctx); + $copy_v1 = v1.value0; + return; + }; + if (v3 instanceof Data_Ordering.GT && v4 instanceof Data_Ordering.LT) { + $tco_var_ctx = new Data_List_Types.Cons(new ThreeMiddle(v1.value0, v1.value1, v1.value2, v1.value4, v1.value5, v1.value6), ctx); + $copy_v1 = v1.value3; + return; + }; + $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(v1.value0, v1.value1, v1.value2, v1.value3, v1.value4, v1.value5), ctx); + $copy_v1 = v1.value6; + return; + }; + throw new Error("Failed pattern match at Data.Map line 392, column 3 - line 392, column 55: " + [ ctx.constructor.name, v1.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_ctx, $copy_v1); + }; + return $tco_result; + }; + }; + return down(Data_List_Types.Nil.value); + }; + }; + }; + var pop = function (dictOrd) { + return function (k) { + var up = function (ctxs) { + return function (tree) { + if (ctxs instanceof Data_List_Types.Nil) { + return tree; + }; + if (ctxs instanceof Data_List_Types.Cons) { + var __unused = function (dictPartial1) { + return function ($dollar51) { + return $dollar51; + }; + }; + return __unused()((function () { + if (ctxs.value0 instanceof TwoLeft && (ctxs.value0.value2 instanceof Leaf && tree instanceof Leaf)) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(Leaf.value, ctxs.value0.value0, ctxs.value0.value1, Leaf.value)); + }; + if (ctxs.value0 instanceof TwoRight && (ctxs.value0.value0 instanceof Leaf && tree instanceof Leaf)) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value)); + }; + if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Two) { + return up(ctxs.value1)(new Three(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0, ctxs.value0.value2.value1, ctxs.value0.value2.value2, ctxs.value0.value2.value3)); + }; + if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Two) { + return up(ctxs.value1)(new Three(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3, ctxs.value0.value1, ctxs.value0.value2, tree)); + }; + if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Three) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(new Two(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0), ctxs.value0.value2.value1, ctxs.value0.value2.value2, new Two(ctxs.value0.value2.value3, ctxs.value0.value2.value4, ctxs.value0.value2.value5, ctxs.value0.value2.value6))); + }; + if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Three) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(new Two(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3), ctxs.value0.value0.value4, ctxs.value0.value0.value5, new Two(ctxs.value0.value0.value6, ctxs.value0.value1, ctxs.value0.value2, tree))); + }; + if (ctxs.value0 instanceof ThreeLeft && (ctxs.value0.value2 instanceof Leaf && (ctxs.value0.value5 instanceof Leaf && tree instanceof Leaf))) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value0, ctxs.value0.value1, Leaf.value, ctxs.value0.value3, ctxs.value0.value4, Leaf.value)); + }; + if (ctxs.value0 instanceof ThreeMiddle && (ctxs.value0.value0 instanceof Leaf && (ctxs.value0.value5 instanceof Leaf && tree instanceof Leaf))) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value, ctxs.value0.value3, ctxs.value0.value4, Leaf.value)); + }; + if (ctxs.value0 instanceof ThreeRight && (ctxs.value0.value0 instanceof Leaf && (ctxs.value0.value3 instanceof Leaf && tree instanceof Leaf))) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value, ctxs.value0.value4, ctxs.value0.value5, Leaf.value)); + }; + if (ctxs.value0 instanceof ThreeLeft && ctxs.value0.value2 instanceof Two) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(new Three(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0, ctxs.value0.value2.value1, ctxs.value0.value2.value2, ctxs.value0.value2.value3), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); + }; + if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value0 instanceof Two) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(new Three(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3, ctxs.value0.value1, ctxs.value0.value2, tree), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); + }; + if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value5 instanceof Two) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Three(tree, ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5.value0, ctxs.value0.value5.value1, ctxs.value0.value5.value2, ctxs.value0.value5.value3))); + }; + if (ctxs.value0 instanceof ThreeRight && ctxs.value0.value3 instanceof Two) { + return fromZipper(dictOrd)(ctxs.value1)(new Two(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Three(ctxs.value0.value3.value0, ctxs.value0.value3.value1, ctxs.value0.value3.value2, ctxs.value0.value3.value3, ctxs.value0.value4, ctxs.value0.value5, tree))); + }; + if (ctxs.value0 instanceof ThreeLeft && ctxs.value0.value2 instanceof Three) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(new Two(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0), ctxs.value0.value2.value1, ctxs.value0.value2.value2, new Two(ctxs.value0.value2.value3, ctxs.value0.value2.value4, ctxs.value0.value2.value5, ctxs.value0.value2.value6), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); + }; + if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value0 instanceof Three) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(new Two(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3), ctxs.value0.value0.value4, ctxs.value0.value0.value5, new Two(ctxs.value0.value0.value6, ctxs.value0.value1, ctxs.value0.value2, tree), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); + }; + if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value5 instanceof Three) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Two(tree, ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5.value0), ctxs.value0.value5.value1, ctxs.value0.value5.value2, new Two(ctxs.value0.value5.value3, ctxs.value0.value5.value4, ctxs.value0.value5.value5, ctxs.value0.value5.value6))); + }; + if (ctxs.value0 instanceof ThreeRight && ctxs.value0.value3 instanceof Three) { + return fromZipper(dictOrd)(ctxs.value1)(new Three(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Two(ctxs.value0.value3.value0, ctxs.value0.value3.value1, ctxs.value0.value3.value2, ctxs.value0.value3.value3), ctxs.value0.value3.value4, ctxs.value0.value3.value5, new Two(ctxs.value0.value3.value6, ctxs.value0.value4, ctxs.value0.value5, tree))); + }; + throw new Error("Failed pattern match at Data.Map line 462, column 9 - line 479, column 136: " + [ ctxs.value0.constructor.name, tree.constructor.name ]); + })()); + }; + throw new Error("Failed pattern match at Data.Map line 459, column 5 - line 479, column 136: " + [ ctxs.constructor.name ]); + }; + }; + var removeMaxNode = function (ctx) { + return function (m) { + var __unused = function (dictPartial1) { + return function ($dollar53) { + return $dollar53; + }; + }; + return __unused()((function () { + if (m instanceof Two && (m.value0 instanceof Leaf && m.value3 instanceof Leaf)) { + return up(ctx)(Leaf.value); + }; + if (m instanceof Two) { + return removeMaxNode(new Data_List_Types.Cons(new TwoRight(m.value0, m.value1, m.value2), ctx))(m.value3); + }; + if (m instanceof Three && (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf))) { + return up(new Data_List_Types.Cons(new TwoRight(Leaf.value, m.value1, m.value2), ctx))(Leaf.value); + }; + if (m instanceof Three) { + return removeMaxNode(new Data_List_Types.Cons(new ThreeRight(m.value0, m.value1, m.value2, m.value3, m.value4, m.value5), ctx))(m.value6); + }; + throw new Error("Failed pattern match at Data.Map line 491, column 5 - line 495, column 107: " + [ m.constructor.name ]); + })()); + }; + }; + var maxNode = function (m) { + var __unused = function (dictPartial1) { + return function ($dollar55) { + return $dollar55; + }; + }; + return __unused()((function () { + if (m instanceof Two && m.value3 instanceof Leaf) { + return { + key: m.value1, + value: m.value2 + }; + }; + if (m instanceof Two) { + return maxNode(m.value3); + }; + if (m instanceof Three && m.value6 instanceof Leaf) { + return { + key: m.value4, + value: m.value5 + }; + }; + if (m instanceof Three) { + return maxNode(m.value6); + }; + throw new Error("Failed pattern match at Data.Map line 482, column 33 - line 486, column 45: " + [ m.constructor.name ]); + })()); + }; + var comp = Data_Ord.compare(dictOrd); + var down = function ($copy_ctx) { + return function ($copy_m) { + var $tco_var_ctx = $copy_ctx; + var $tco_done = false; + var $tco_result; + function $tco_loop(ctx, m) { + if (m instanceof Leaf) { + $tco_done = true; + return Data_Maybe.Nothing.value; + }; + if (m instanceof Two) { + var v = comp(k)(m.value1); + if (m.value3 instanceof Leaf && v instanceof Data_Ordering.EQ) { + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, up(ctx)(Leaf.value))); + }; + if (v instanceof Data_Ordering.EQ) { + var max = maxNode(m.value0); + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, removeMaxNode(new Data_List_Types.Cons(new TwoLeft(max.key, max.value, m.value3), ctx))(m.value0))); + }; + if (v instanceof Data_Ordering.LT) { + $tco_var_ctx = new Data_List_Types.Cons(new TwoLeft(m.value1, m.value2, m.value3), ctx); + $copy_m = m.value0; + return; + }; + $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(m.value0, m.value1, m.value2), ctx); + $copy_m = m.value3; + return; + }; + if (m instanceof Three) { + var leaves = (function () { + if (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf)) { + return true; + }; + return false; + })(); + var v = comp(k)(m.value4); + var v3 = comp(k)(m.value1); + if (leaves && v3 instanceof Data_Ordering.EQ) { + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, fromZipper(dictOrd)(ctx)(new Two(Leaf.value, m.value4, m.value5, Leaf.value)))); + }; + if (leaves && v instanceof Data_Ordering.EQ) { + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value5, fromZipper(dictOrd)(ctx)(new Two(Leaf.value, m.value1, m.value2, Leaf.value)))); + }; + if (v3 instanceof Data_Ordering.EQ) { + var max = maxNode(m.value0); + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, removeMaxNode(new Data_List_Types.Cons(new ThreeLeft(max.key, max.value, m.value3, m.value4, m.value5, m.value6), ctx))(m.value0))); + }; + if (v instanceof Data_Ordering.EQ) { + var max = maxNode(m.value3); + $tco_done = true; + return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value5, removeMaxNode(new Data_List_Types.Cons(new ThreeMiddle(m.value0, m.value1, m.value2, max.key, max.value, m.value6), ctx))(m.value3))); + }; + if (v3 instanceof Data_Ordering.LT) { + $tco_var_ctx = new Data_List_Types.Cons(new ThreeLeft(m.value1, m.value2, m.value3, m.value4, m.value5, m.value6), ctx); + $copy_m = m.value0; + return; + }; + if (v3 instanceof Data_Ordering.GT && v instanceof Data_Ordering.LT) { + $tco_var_ctx = new Data_List_Types.Cons(new ThreeMiddle(m.value0, m.value1, m.value2, m.value4, m.value5, m.value6), ctx); + $copy_m = m.value3; + return; + }; + $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(m.value0, m.value1, m.value2, m.value3, m.value4, m.value5), ctx); + $copy_m = m.value6; + return; + }; + throw new Error("Failed pattern match at Data.Map line 432, column 34 - line 455, column 80: " + [ m.constructor.name ]); + }; + while (!$tco_done) { + $tco_result = $tco_loop($tco_var_ctx, $copy_m); + }; + return $tco_result; + }; + }; + return down(Data_List_Types.Nil.value); + }; + }; + var foldableMap = new Data_Foldable.Foldable(function (dictMonoid) { + return function (f) { + return function (m) { + return Data_Foldable.foldMap(Data_List_Types.foldableList)(dictMonoid)(f)(values(m)); + }; + }; + }, function (f) { + return function (z) { + return function (m) { + return Data_Foldable.foldl(Data_List_Types.foldableList)(f)(z)(values(m)); + }; + }; + }, function (f) { + return function (z) { + return function (m) { + return Data_Foldable.foldr(Data_List_Types.foldableList)(f)(z)(values(m)); + }; + }; + }); + var empty = Leaf.value; + var $$delete = function (dictOrd) { + return function (k) { + return function (m) { + return Data_Maybe.maybe(m)(Data_Tuple.snd)(pop(dictOrd)(k)(m)); + }; + }; + }; + exports["delete"] = $$delete; + exports["empty"] = empty; + exports["insert"] = insert; + exports["keys"] = keys; + exports["lookup"] = lookup; + exports["member"] = member; + exports["pop"] = pop; + exports["values"] = values; + exports["functorMap"] = functorMap; + exports["foldableMap"] = foldableMap; +})(PS["Data.Map"] = PS["Data.Map"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Aff_Class = PS["Control.Monad.Aff.Class"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Except = PS["Control.Monad.Except"]; + var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Parallel = PS["Control.Parallel"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var Data_Either = PS["Data.Either"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Map = PS["Data.Map"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_Component_ChildPath = PS["Halogen.Component.ChildPath"]; + var Halogen_Query_EventSource = PS["Halogen.Query.EventSource"]; + var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Prelude = PS["Prelude"]; + var action = function (act) { + return act(Data_Unit.unit); + }; + exports["action"] = action; +})(PS["Halogen.Query"] = PS["Halogen.Query"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Except = PS["Control.Monad.Except"]; + var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM_Event_Event = PS["DOM.Event.Event"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_HTML_Event_EventTypes = PS["DOM.HTML.Event.EventTypes"]; + var DOM_HTML_Event_Types = PS["DOM.HTML.Event.Types"]; + var Data_Either = PS["Data.Either"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Foreign_Index = PS["Data.Foreign.Index"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Identity = PS["Data.Identity"]; + var Data_Maybe = PS["Data.Maybe"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; + var Halogen_Query = PS["Halogen.Query"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var touchHandler = Unsafe_Coerce.unsafeCoerce; + var mouseHandler = Unsafe_Coerce.unsafeCoerce; + var input_ = function (f) { + return function (v) { + return Data_Maybe.Just.create(Halogen_Query.action(f)); + }; + }; + var input = function (f) { + return function (x) { + return Data_Maybe.Just.create(Halogen_Query.action(f(x))); + }; + }; + var handler = function (et) { + return function ($1) { + return Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.handler)(et)(Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(Halogen_Query_InputF.Query.create))($1)); + }; + }; + var onMouseDown = function ($8) { + return handler(DOM_HTML_Event_EventTypes.mousedown)(mouseHandler($8)); + }; + var onMouseMove = function ($11) { + return handler(DOM_HTML_Event_EventTypes.mousemove)(mouseHandler($11)); + }; + var onMouseUp = function ($14) { + return handler(DOM_HTML_Event_EventTypes.mouseup)(mouseHandler($14)); + }; + var onTouchEnd = function ($16) { + return handler(DOM_HTML_Event_EventTypes.touchend)(touchHandler($16)); + }; + var onTouchMove = function ($19) { + return handler(DOM_HTML_Event_EventTypes.touchmove)(touchHandler($19)); + }; + var onTouchStart = function ($20) { + return handler(DOM_HTML_Event_EventTypes.touchstart)(touchHandler($20)); + }; + exports["handler"] = handler; + exports["input"] = input; + exports["input_"] = input_; + exports["onMouseDown"] = onMouseDown; + exports["onMouseMove"] = onMouseMove; + exports["onMouseUp"] = onMouseUp; + exports["onTouchEnd"] = onTouchEnd; + exports["onTouchMove"] = onTouchMove; + exports["onTouchStart"] = onTouchStart; +})(PS["Halogen.HTML.Events"] = PS["Halogen.HTML.Events"] || {}); +(function(exports) { + "use strict"; + var CSS = PS["CSS"]; + var CSS_Background = PS["CSS.Background"]; + var CSS_Border = PS["CSS.Border"]; + var CSS_Display = PS["CSS.Display"]; + var CSS_Geometry = PS["CSS.Geometry"]; + var CSS_Size = PS["CSS.Size"]; + var CSS_Stylesheet = PS["CSS.Stylesheet"]; + var Color = PS["Color"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Classy_Event = PS["DOM.Classy.Event"]; + var DOM_Classy_HTMLElement = PS["DOM.Classy.HTMLElement"]; + var DOM_Classy_Node = PS["DOM.Classy.Node"]; + var DOM_Event_MouseEvent = PS["DOM.Event.MouseEvent"]; + var DOM_Event_TouchEvent = PS["DOM.Event.TouchEvent"]; + var DOM_Event_Types = PS["DOM.Event.Types"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var Data_Either = PS["Data.Either"]; + var Data_EuclideanRing = PS["Data.EuclideanRing"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Int = PS["Data.Int"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ring = PS["Data.Ring"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Unit = PS["Data.Unit"]; + var Debug_Trace = PS["Debug.Trace"]; + var Halogen = PS["Halogen"]; + var Halogen_Component = PS["Halogen.Component"]; + var Halogen_HTML = PS["Halogen.HTML"]; + var Halogen_HTML_CSS = PS["Halogen.HTML.CSS"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; + var Halogen_HTML_Events = PS["Halogen.HTML.Events"]; + var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; + var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; + var $$Math = PS["Math"]; + var Prelude = PS["Prelude"]; + var NoOp = (function () { + function NoOp(value0) { + this.value0 = value0; + }; + NoOp.create = function (value0) { + return new NoOp(value0); + }; + return NoOp; + })(); + var StartUpdateColor = (function () { + function StartUpdateColor(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + StartUpdateColor.create = function (value0) { + return function (value1) { + return new StartUpdateColor(value0, value1); + }; + }; + return StartUpdateColor; + })(); + var EndUpdateColor = (function () { + function EndUpdateColor(value0) { + this.value0 = value0; + }; + EndUpdateColor.create = function (value0) { + return new EndUpdateColor(value0); + }; + return EndUpdateColor; + })(); + var UpdateColor = (function () { + function UpdateColor(value0, value1) { + this.value0 = value0; + this.value1 = value1; + }; + UpdateColor.create = function (value0) { + return function (value1) { + return new UpdateColor(value0, value1); + }; + }; + return UpdateColor; + })(); + var Idle = (function () { + function Idle() { + + }; + Idle.value = new Idle(); + return Idle; + })(); + var ColorDrag = (function () { + function ColorDrag() { + + }; + ColorDrag.value = new ColorDrag(); + return ColorDrag; + })(); + var positionInRect = function (v) { + return function (v1) { + return { + x: ((v.x - v1.left) / v1.width) * 100.0, + y: ((v.y - v1.top) / v1.height) * 100.0 + }; + }; + }; + + // data Condition = Idle | ColorDrag | HueDrag + var orDefault = Data_Maybe.fromMaybe(Color.hsl(180.0)(0.0)(0.0)); + var getHue = function ($52) { + return (function (v) { + return v.h; + })(Color.toHSLA($52)); + }; + var pureHue = function (c) { + return Color.hsl(getHue(c))(1.0)(0.5); + }; + var render = function (v) { + return Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker" ]) ])([ Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-color" ]), Halogen_HTML_CSS.style(CSS_Background.backgroundColor(pureHue(orDefault(v.color)))), Halogen_HTML_Events.onMouseDown(Halogen_HTML_Events.input(function ($53) { + return StartUpdateColor.create(Data_Either.Right.create($53)); + })), Halogen_HTML_Events.onMouseMove(Halogen_HTML_Events.input(function ($54) { + return UpdateColor.create(Data_Either.Right.create($54)); + })), Halogen_HTML_Events.onMouseUp(Halogen_HTML_Events.input_(EndUpdateColor.create)), Halogen_HTML_Events.onTouchStart(Halogen_HTML_Events.input(function ($55) { + return StartUpdateColor.create(Data_Either.Left.create($55)); + })), Halogen_HTML_Events.onTouchMove(Halogen_HTML_Events.input(function ($56) { + return UpdateColor.create(Data_Either.Left.create($56)); + })), Halogen_HTML_Events.onTouchEnd(Halogen_HTML_Events.input_(EndUpdateColor.create)) ])([ Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-saturation" ]) ])([ ]), Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-brightness" ]) ])([ ]), Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-sbSelector" ]), Halogen_HTML_CSS.style((function () { + if (v.color instanceof Data_Maybe.Nothing) { + return CSS_Display.display(CSS_Display.displayNone); + }; + if (v.color instanceof Data_Maybe.Just) { + return Control_Bind.discard(Control_Bind.discardUnit)(CSS_Stylesheet.bindStyleM)(CSS_Background.backgroundColor(v.color.value0))(function () { + return CSS_Border.borderColor((function () { + var $25 = Color.isLight(v.color.value0); + if ($25) { + return Color.black; + }; + return Color.white; + })()); + }); + }; + throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 121, column 24 - line 127, column 31: " + [ v.color.constructor.name ]); + })()) ])([ ]) ]), Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-hue" ]) ])([ Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-hSelector" ]), (function () { + var hue = getHue(orDefault(v.color)); + return Halogen_HTML_CSS.style(CSS_Geometry.top(CSS_Size.pct((hue / 360.0) * 100.0))); + })() ])([ ]) ]) ]); + }; + var applyRect = function (dictIsEvent) { + return function (e) { + return function (input) { + var elem = DOM_Classy_Node.fromNode(DOM_Classy_Node.isNodeHTMLElement)(DOM_Classy_Event.target(dictIsEvent)(e)); + var rect = Data_Functor.map(Data_Maybe.functorMaybe)(DOM_Classy_HTMLElement.getBoundingClientRect(DOM_Classy_HTMLElement.isHTMLElementHTMLElement))(elem); + if (rect instanceof Data_Maybe.Nothing) { + return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(input); + }; + if (rect instanceof Data_Maybe.Just) { + return Data_Functor.map(Control_Monad_Eff.functorEff)(positionInRect(input))(rect.value0); + }; + throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 82, column 5 - line 84, column 43: " + [ rect.constructor.name ]); + }; + }; + }; + var mouseEventToPosition = function (e) { + return applyRect(DOM_Classy_Event.isEventMouseEvent)(e)({ + x: Data_Int.toNumber(DOM_Event_MouseEvent.clientX(e)), + y: Data_Int.toNumber(DOM_Event_MouseEvent.clientY(e)) + }); + }; + var touchEventToPosition = function (e) { + var fstTouch = DOM_Event_TouchEvent.item(0)(DOM_Event_TouchEvent.touches(e)); + if (fstTouch instanceof Data_Maybe.Nothing) { + return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)({ + x: 0.0, + y: 0.0 + }); + }; + if (fstTouch instanceof Data_Maybe.Just) { + return applyRect(DOM_Classy_Event.isEventTouchEvent)(e)({ + x: Data_Int.toNumber(DOM_Event_TouchEvent.clientX(fstTouch.value0)), + y: Data_Int.toNumber(DOM_Event_TouchEvent.clientY(fstTouch.value0)) + }); + }; + throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 91, column 5 - line 95, column 42: " + [ fstTouch.constructor.name ]); + }; + var posFromEvent = Data_Either.either(touchEventToPosition)(mouseEventToPosition); + var $$eval = function (dictMonadEff) { + return function (v) { + if (v instanceof NoOp) { + return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value0); + }; + if (v instanceof StartUpdateColor) { + return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.modify(Halogen_Query_HalogenM.monadStateHalogenM)(function (v1) { + var $34 = {}; + for (var $35 in v1) { + if ({}.hasOwnProperty.call(v1, $35)) { + $34[$35] = v1[$35]; + }; + }; + $34.condition = ColorDrag.value; + return $34; + }))(function () { + return Control_Bind.bind(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_Eff_Class.liftEff(Halogen_Query_HalogenM.monadEffHalogenM(dictMonadEff))(posFromEvent(v.value0)))(function (v1) { + return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Debug_Trace.traceAnyA(Debug_Trace.warn())(Halogen_Query_HalogenM.applicativeHalogenM)(v1))(function () { + return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value1); + }); + }); + }); + }; + if (v instanceof EndUpdateColor) { + return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.modify(Halogen_Query_HalogenM.monadStateHalogenM)(function (v1) { + var $40 = {}; + for (var $41 in v1) { + if ({}.hasOwnProperty.call(v1, $41)) { + $40[$41] = v1[$41]; + }; + }; + $40.condition = Idle.value; + return $40; + }))(function () { + return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value0); + }); + }; + if (v instanceof UpdateColor) { + return Control_Bind.bind(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.get(Halogen_Query_HalogenM.monadStateHalogenM))(function (v1) { + return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)((function () { + if (v1.condition instanceof ColorDrag) { + return Control_Bind.bind(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_Eff_Class.liftEff(Halogen_Query_HalogenM.monadEffHalogenM(dictMonadEff))(posFromEvent(v.value0)))(function (v2) { + return Debug_Trace.traceAnyA(Debug_Trace.warn())(Halogen_Query_HalogenM.applicativeHalogenM)(v2); + }); + }; + return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Unit.unit); + })())(function () { + return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value1); + }); + }); + }; + throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 147, column 1 - line 147, column 60: " + [ v.constructor.name ]); + }; + }; + var picker = function (dictMonadEff) { + return Halogen_Component.component(Halogen_HTML_Core.bifunctorHTML)({ + initialState: Data_Function["const"]({ + color: Data_Maybe.Nothing.value, + condition: Idle.value + }), + render: render, + "eval": $$eval(dictMonadEff), + receiver: Data_Function["const"](Data_Maybe.Nothing.value) + }); + }; + exports["Idle"] = Idle; + exports["ColorDrag"] = ColorDrag; + exports["NoOp"] = NoOp; + exports["StartUpdateColor"] = StartUpdateColor; + exports["EndUpdateColor"] = EndUpdateColor; + exports["UpdateColor"] = UpdateColor; + exports["applyRect"] = applyRect; + exports["getHue"] = getHue; + exports["mouseEventToPosition"] = mouseEventToPosition; + exports["orDefault"] = orDefault; + exports["picker"] = picker; + exports["posFromEvent"] = posFromEvent; + exports["positionInRect"] = positionInRect; + exports["pureHue"] = pureHue; + exports["render"] = render; + exports["touchEventToPosition"] = touchEventToPosition; +})(PS["ColorPicker.Halogen.Component"] = PS["ColorPicker.Halogen.Component"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var unsafeCoerceAff = Unsafe_Coerce.unsafeCoerce; + exports["unsafeCoerceAff"] = unsafeCoerceAff; +})(PS["Control.Monad.Aff.Unsafe"] = PS["Control.Monad.Aff.Unsafe"] || {}); +(function(exports) { + /* global window */ + "use strict"; + + exports.window = function () { + return window; + }; +})(PS["DOM.HTML"] = PS["DOM.HTML"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.HTML"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var DOM = PS["DOM"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + exports["window"] = $foreign.window; +})(PS["DOM.HTML"] = PS["DOM.HTML"] || {}); +(function(exports) { + "use strict"; + + exports.document = function (window) { + return function () { + return window.document; + }; + }; +})(PS["DOM.HTML.Window"] = PS["DOM.HTML.Window"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.HTML.Window"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_WebStorage_Types = PS["DOM.WebStorage.Types"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Nullable = PS["Data.Nullable"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + exports["document"] = $foreign.document; +})(PS["DOM.HTML.Window"] = PS["DOM.HTML.Window"] || {}); +(function(exports) { + "use strict"; + + exports._querySelector = function (selector) { + return function (node) { + return function () { + return node.querySelector(selector); + }; + }; + }; +})(PS["DOM.Node.ParentNode"] = PS["DOM.Node.ParentNode"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["DOM.Node.ParentNode"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Newtype = PS["Data.Newtype"]; + var Data_Nullable = PS["Data.Nullable"]; + var Data_Ord = PS["Data.Ord"]; + var Prelude = PS["Prelude"]; + var querySelector = function (qs) { + return function ($3) { + return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Nullable.toMaybe)($foreign._querySelector(qs)($3)); + }; + }; + exports["querySelector"] = querySelector; +})(PS["DOM.Node.ParentNode"] = PS["DOM.Node.ParentNode"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Map = PS["Data.Map"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_StrMap = PS["Data.StrMap"]; + var Data_Traversable = PS["Data.Traversable"]; + var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; + var Halogen_Component = PS["Halogen.Component"]; + var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; + var Prelude = PS["Prelude"]; + var Unsafe_Coerce = PS["Unsafe.Coerce"]; + var unRenderStateX = Unsafe_Coerce.unsafeCoerce; + var unDriverStateX = Unsafe_Coerce.unsafeCoerce; + var renderStateX_ = function (dictApplicative) { + return function (f) { + return unDriverStateX(function (st) { + return Data_Foldable.traverse_(dictApplicative)(Data_Foldable.foldableMaybe)(f)(st.rendering); + }); + }; + }; + var mkRenderStateX = function (v) { + return Unsafe_Coerce.unsafeCoerce; + }; + var renderStateX = function (dictFunctor) { + return function (f) { + return unDriverStateX(function (st) { + return mkRenderStateX(st.prjQuery)(f(st.rendering)); + }); + }; + }; + var mkDriverStateXRef = Unsafe_Coerce.unsafeCoerce; + var initDriverState = function (component) { + return function (input) { + return function (handler) { + return function (prjQuery) { + return function (lchs) { + return function __do() { + var v = Control_Monad_Eff_Ref.newRef(Unsafe_Coerce.unsafeCoerce({}))(); + var v1 = Control_Monad_Eff_Ref.newRef(Data_Map.empty)(); + var v2 = Control_Monad_Eff_Ref.newRef(Data_Map.empty)(); + var v3 = Control_Monad_Eff_Ref.newRef(Data_Functor.voidLeft(Data_Maybe.functorMaybe)(component.initializer)(Data_List_Types.Nil.value))(); + var v4 = Control_Monad_Eff_Ref.newRef(new Data_Maybe.Just(Data_List_Types.Nil.value))(); + var v5 = Control_Monad_Eff_Ref.newRef(Data_Maybe.Nothing.value)(); + var v6 = Control_Monad_Eff_Ref.newRef(0)(); + var v7 = Control_Monad_Eff_Ref.newRef(new Data_Maybe.Just(Data_Map.empty))(); + var ds = { + component: component, + state: component.initialState(input), + refs: Data_StrMap.empty, + children: Data_Map.empty, + childrenIn: v1, + childrenOut: v2, + selfRef: v, + handler: handler, + pendingQueries: v3, + pendingOuts: v4, + pendingHandlers: v5, + rendering: Data_Maybe.Nothing.value, + prjQuery: prjQuery, + fresh: v6, + subscriptions: v7, + lifecycleHandlers: lchs + }; + Control_Monad_Eff_Ref.writeRef(v)(ds)(); + return mkDriverStateXRef(v); + }; + }; + }; + }; + }; + }; + exports["initDriverState"] = initDriverState; + exports["mkDriverStateXRef"] = mkDriverStateXRef; + exports["renderStateX"] = renderStateX; + exports["renderStateX_"] = renderStateX_; + exports["unDriverStateX"] = unDriverStateX; + exports["unRenderStateX"] = unRenderStateX; +})(PS["Halogen.Aff.Driver.State"] = PS["Halogen.Aff.Driver.State"] || {}); +(function(exports) { + "use strict"; + + exports.reallyUnsafeRefEq = function (a) { + return function (b) { + return a === b; + }; + }; +})(PS["Unsafe.Reference"] = PS["Unsafe.Reference"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var $foreign = PS["Unsafe.Reference"]; + var unsafeRefEq = $foreign.reallyUnsafeRefEq; + exports["unsafeRefEq"] = unsafeRefEq; +})(PS["Unsafe.Reference"] = PS["Unsafe.Reference"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Applicative_Free = PS["Control.Applicative.Free"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Coroutine = PS["Control.Coroutine"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"]; + var Control_Monad_Aff_Unsafe = PS["Control.Monad.Aff.Unsafe"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Fork = PS["Control.Monad.Fork"]; + var Control_Monad_Fork_Class = PS["Control.Monad.Fork.Class"]; + var Control_Monad_Free = PS["Control.Monad.Free"]; + var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; + var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; + var Control_Parallel = PS["Control.Parallel"]; + var Control_Parallel_Class = PS["Control.Parallel.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Boolean = PS["Data.Boolean"]; + var Data_Coyoneda = PS["Data.Coyoneda"]; + var Data_Either = PS["Data.Either"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Map = PS["Data.Map"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_StrMap = PS["Data.StrMap"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_Aff_Driver_State = PS["Halogen.Aff.Driver.State"]; + var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; + var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; + var Halogen_Query_EventSource = PS["Halogen.Query.EventSource"]; + var Halogen_Query_ForkF = PS["Halogen.Query.ForkF"]; + var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Prelude = PS["Prelude"]; + var Unsafe_Reference = PS["Unsafe.Reference"]; + var queuingHandler = function (handler) { + return function (ref) { + return function (message) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { + if (v instanceof Data_Maybe.Nothing) { + return handler(message); + }; + if (v instanceof Data_Maybe.Just) { + return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(ref)(new Data_Maybe.Just(new Data_List_Types.Cons(handler(message), v.value0)))); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 201, column 3 - line 205, column 57: " + [ v.constructor.name ]); + }); + }; + }; + }; + var parSequenceAff_ = function (v) { + if (v instanceof Data_List_Types.Nil) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(Data_Unit.unit); + }; + if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) { + return Data_Functor["void"](Control_Monad_Aff.functorAff)(v.value0); + }; + if (v instanceof Data_List_Types.Cons) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff_AVar.makeVar)(function (v1) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.newRef(v.value1)))(function (v2) { + var run = function (a) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff.attempt(a))(function (v3) { + if (v3 instanceof Data_Either.Left) { + return Control_Monad_Aff_AVar.putVar(v1)(new Data_Maybe.Just(v3.value0)); + }; + if (v3 instanceof Data_Either.Right) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v2)))(function (v4) { + if (v4 instanceof Data_List_Types.Nil) { + return Control_Monad_Aff_AVar.putVar(v1)(Data_Maybe.Nothing.value); + }; + if (v4 instanceof Data_List_Types.Cons) { + return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(v2)(v4.value1)); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 55, column 15 - line 57, column 57: " + [ v4.constructor.name ]); + }); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 51, column 23 - line 57, column 57: " + [ v3.constructor.name ]); + }); + }; + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(Data_Functor.map(Data_List_Types.functorList)(run)(v)))(function (v3) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff_AVar.peekVar(v1))(function (v4) { + if (v4 instanceof Data_Maybe.Nothing) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(Data_Unit.unit); + }; + if (v4 instanceof Data_Maybe.Just) { + return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(v4.value0); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 59, column 24 - line 61, column 33: " + [ v4.constructor.name ]); + }); + }); + }); + }); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 43, column 19 - line 61, column 33: " + [ v.constructor.name ]); + }; + var handleLifecycle = function (lchs) { + return function (f) { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(lchs)({ + initializers: Data_List_Types.Nil.value, + finalizers: Data_List_Types.Nil.value + })))(function () { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(f))(function (v) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(lchs)))(function (v1) { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(v1.finalizers)))(function () { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(parSequenceAff_(v1.initializers))(function () { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v); + }); + }); + }); + }); + }); + }; + }; + var $$eval = function (render) { + return function (r) { + var go = function (ref) { + return function (v) { + if (v instanceof Halogen_Query_HalogenM.State) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { + var v2 = v.value0(v1.state); + if (Unsafe_Reference.unsafeRefEq(v1.state)(v2.value1)) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v2.value0); + }; + if (Data_Boolean.otherwise) { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(ref)((function () { + var $61 = {}; + for (var $62 in v1) { + if ({}.hasOwnProperty.call(v1, $62)) { + $61[$62] = v1[$62]; + }; + }; + $61.state = v2.value1; + return $61; + })())))(function () { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(handleLifecycle(v1.lifecycleHandlers)(render(v1.lifecycleHandlers)(ref)))(function () { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v2.value0); + }); + }); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 106, column 7 - line 112, column 21: " + [ v2.constructor.name ]); + }); + }; + if (v instanceof Halogen_Query_HalogenM.Subscribe) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAff(Control_Bind.bind(Control_Monad_Aff.bindAff)(Halogen_Query_EventSource.unEventSource(v.value0))(function (v2) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref["modifyRef'"](v1.fresh)(function (i) { + return { + state: i + 1 | 0, + value: i + }; + })))(function (v3) { + var done$prime = Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v1.subscriptions)))(function (v4) { + return Control_Applicative.when(Control_Monad_Aff.applicativeAff)(Data_Maybe.maybe(false)(Data_Map.member(Data_Ord.ordInt)(v3))(v4))(Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(v2.done)(function () { + return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(v1.subscriptions)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map["delete"](Data_Ord.ordInt)(v3)))); + })); + }); + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(v1.subscriptions)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map.insert(Data_Ord.ordInt)(v3)(done$prime)))))(function () { + var consumer = Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Control_Coroutine["await"](Control_Monad_Aff.monadAff))(function (v4) { + return Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(Control_Coroutine.functorAwait))(Control_Monad_Aff.monadAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v1.subscriptions))))(function (v5) { + return Control_Applicative.when(Control_Monad_Free_Trans.applicativeFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Data_Maybe.isJust(v5))(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(Control_Coroutine.functorAwait))(Control_Monad_Aff.monadAff)(evalF(ref)(v4)))(function (v6) { + return Control_Applicative.when(Control_Monad_Free_Trans.applicativeFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Data_Eq.eq(Halogen_Query_EventSource.eqSubscribeStatus)(v6)(Halogen_Query_EventSource.Listening.value))(consumer); + })); + }); + }); + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Coroutine.runProcess(Control_Monad_Aff.monadRecAff)(Control_Coroutine.pullFrom(Control_Monad_Aff.monadRecAff)(consumer)(v2.producer)))(function () { + return done$prime; + }); + }); + }); + }))))(function () { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1); + }); + }); + }; + if (v instanceof Halogen_Query_HalogenM.Lift) { + return v.value0; + }; + if (v instanceof Halogen_Query_HalogenM.Halt) { + return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error(v.value0)); + }; + if (v instanceof Halogen_Query_HalogenM.GetSlots) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value0(Data_Functor.map(Data_List_Types.functorList)(Halogen_Data_OrdBox.unOrdBox)(Data_Map.keys(v1.children)))); + }); + }; + if (v instanceof Halogen_Query_HalogenM.CheckSlot) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1(Data_Map.member(Halogen_Data_OrdBox.ordOrdBox)(v1.component.mkOrdBox(v.value0))(v1.children))); + }); + }; + if (v instanceof Halogen_Query_HalogenM.ChildQuery) { + return evalChildQuery(ref)(v.value0)(v.value1); + }; + if (v instanceof Halogen_Query_HalogenM.Raise) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(queuingHandler(v1.handler)(v1.pendingOuts)(v.value0))(function () { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1); + }); + }); + }; + if (v instanceof Halogen_Query_HalogenM.Par) { + return Control_Parallel_Class.sequential(Control_Monad_Aff.parallelParAff)(Control_Applicative_Free.retractFreeAp(Control_Monad_Aff.applicativeParAff)(Control_Applicative_Free.hoistFreeAp(function ($128) { + return Control_Parallel_Class.parallel(Control_Monad_Aff.parallelParAff)(evalM(ref)($128)); + })(v.value0))); + }; + if (v instanceof Halogen_Query_HalogenM.Fork) { + return Halogen_Query_ForkF.unFork(function (v1) { + return Data_Functor.map(Control_Monad_Aff.functorAff)(function ($129) { + return v1.value1(Data_Functor.map(Data_Functor.functorFn)(Control_Monad_Aff_Unsafe.unsafeCoerceAff)($129)); + })(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff)(evalM(ref)(v1.value0))); + })(v.value0); + }; + if (v instanceof Halogen_Query_HalogenM.GetRef) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1(Data_StrMap.lookup(v.value0)(v1.refs))); + }); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 103, column 12 - line 158, column 34: " + [ v.constructor.name ]); + }; + }; + var evalM = function (ref) { + return function (v) { + return Control_Monad_Free.foldFree(Control_Monad_Aff.monadRecAff)(go(ref))(v); + }; + }; + var evalF = function (ref) { + return function (q) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { + var v1 = v["component"]["eval"](q); + return Control_Monad_Free.foldFree(Control_Monad_Aff.monadRecAff)(go(ref))(v1); + }); + }; + }; + var evalChildQuery = function (ref) { + return function (p) { + return Data_Coyoneda.unCoyoneda(function (k) { + return function (q) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { + var v1 = Data_Map.lookup(Halogen_Data_OrdBox.ordOrdBox)(v.component.mkOrdBox(p))(v.children); + if (v1 instanceof Data_Maybe.Just) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v1.value0)))(function (v2) { + return Halogen_Aff_Driver_State.unDriverStateX(function (ds) { + var v3 = ds.prjQuery(q); + if (v3 instanceof Data_Maybe.Just) { + return Data_Functor.map(Control_Monad_Aff.functorAff)(k)(evalF(ds.selfRef)(v3.value0)); + }; + if (v3 instanceof Data_Maybe.Nothing) { + return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error("Query projection failed for child query")); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 171, column 32 - line 173, column 82: " + [ v3.constructor.name ]); + })(v2); + }); + }; + if (v1 instanceof Data_Maybe.Nothing) { + return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error("Slot lookup failed for child query")); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 168, column 5 - line 174, column 73: " + [ v1.constructor.name ]); + }); + }; + }); + }; + }; + return function (v) { + if (v instanceof Halogen_Query_InputF.RefUpdate) { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(r)(function (v1) { + var $121 = {}; + for (var $122 in v1) { + if ({}.hasOwnProperty.call(v1, $122)) { + $121[$122] = v1[$122]; + }; + }; + $121.refs = Data_StrMap.alter(Data_Function["const"](v.value1))(v.value0)(v1.refs); + return $121; + })))(function () { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value2); + }); + }; + if (v instanceof Halogen_Query_InputF.Query) { + return evalF(r)(v.value0); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 89, column 3 - line 94, column 25: " + [ v.constructor.name ]); + }; + }; + }; + exports["eval"] = $$eval; + exports["handleLifecycle"] = handleLifecycle; + exports["parSequenceAff_"] = parSequenceAff_; + exports["queuingHandler"] = queuingHandler; +})(PS["Halogen.Aff.Driver.Eval"] = PS["Halogen.Aff.Driver.Eval"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Coroutine = PS["Control.Coroutine"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Console = PS["Control.Monad.Eff.Console"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; + var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var Data_Either = PS["Data.Either"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_List = PS["Data.List"]; + var Data_List_Types = PS["Data.List.Types"]; + var Data_Map = PS["Data.Map"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Semiring = PS["Data.Semiring"]; + var Data_Traversable = PS["Data.Traversable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen = PS["Halogen"]; + var Halogen_Aff_Driver_Eval = PS["Halogen.Aff.Driver.Eval"]; + var Halogen_Aff_Driver_State = PS["Halogen.Aff.Driver.State"]; + var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; + var Halogen_Component = PS["Halogen.Component"]; + var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Prelude = PS["Prelude"]; + var newLifecycleHandlers = Control_Monad_Eff_Ref.newRef({ + initializers: Data_List_Types.Nil.value, + finalizers: Data_List_Types.Nil.value + }); + var handleAff = function ($63) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(Control_Monad_Aff.runAff(Control_Monad_Eff_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit)))($63)); + }; + var runUI = function (renderSpec) { + return function (component) { + return function (i) { + var subscribe = function (fresh) { + return function (ref) { + return function (consumer) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff_AVar.makeVar)(function (v) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(function __do() { + var v1 = Control_Monad_Eff_Ref.readRef(fresh)(); + Control_Monad_Eff_Ref.modifyRef(fresh)(function (v2) { + return v2 + 1 | 0; + })(); + Control_Monad_Eff_Ref.modifyRef(ref)(Data_Map.insert(Data_Ord.ordInt)(v1)(v))(); + return v1; + }))(function (v1) { + var producer = Control_Coroutine.producer(Control_Monad_Aff.monadAff)(Data_Functor.map(Control_Monad_Aff.functorAff)(Data_Either.Left.create)(Control_Monad_Aff_AVar.takeVar(v))); + return Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAff(Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Coroutine.runProcess(Control_Monad_Aff.monadRecAff)(Control_Coroutine.connect(Control_Monad_Aff.monadRecAff)(Control_Monad_Aff.parallelParAff)(producer)(consumer)))(function () { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(ref)(Data_Map["delete"](Data_Ord.ordInt)(v1))))(function () { + return Control_Monad_Aff_AVar.killVar(v)(Control_Monad_Eff_Exception.error("ended")); + }); + }))); + }); + }); + }; + }; + }; + var rootHandler = function (ref) { + return function (message) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { + return Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAll(Data_Map.foldableMap)(Data_Functor.map(Data_Map.functorMap)(function ($$var) { + return Control_Monad_Aff_AVar.putVar($$var)(message); + })(v))); + }); + }; + }; + var handlePending = function (ref) { + return function __do() { + var v = Control_Monad_Eff_Ref.readRef(ref)(); + Control_Monad_Eff_Ref.writeRef(ref)(Data_Maybe.Nothing.value)(); + return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v)(function ($64) { + return handleAff(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(Data_List.reverse($64))); + })(); + }; + }; + var cleanupSubscriptions = function (v) { + return function __do() { + Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(function ($65) { + return handleAff(Control_Monad_Aff.forkAll(Data_Map.foldableMap)($65)); + }))(Control_Monad_Eff_Ref.readRef(v.subscriptions))(); + return Control_Monad_Eff_Ref.writeRef(v.subscriptions)(Data_Maybe.Nothing.value)(); + }; + }; + var squashChildInitializers = function (lchs) { + return function (preInits) { + return Halogen_Aff_Driver_State.unDriverStateX(function (st) { + var parentInitializer = Data_Functor.map(Data_Maybe.functorMaybe)(function ($66) { + return evalF(st.selfRef)(Halogen_Query_InputF.Query.create($66)); + })(st.component.initializer); + return Control_Monad_Eff_Ref.modifyRef(lchs)(function (handlers) { + return { + initializers: new Data_List_Types.Cons(Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Halogen_Aff_Driver_Eval.parSequenceAff_(Data_List.reverse(handlers.initializers)))(function () { + return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Data_Foldable.sequence_(Control_Monad_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(parentInitializer))(function () { + return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(function __do() { + handlePending(st.pendingQueries)(); + return handlePending(st.pendingOuts)(); + }); + }); + }), preInits), + finalizers: handlers.finalizers + }; + }); + }); + }; + }; + var runComponent = function (lchs) { + return function (handler) { + return function (j) { + return function (prjQuery) { + return Halogen_Component.unComponent(function (c) { + return function __do() { + var v = newLifecycleHandlers(); + var v1 = Halogen_Aff_Driver_State.initDriverState(c)(j)(handler)(prjQuery)(v)(); + var v2 = Control_Monad_Eff_Ref.readRef(lchs)(); + Control_Monad_Eff_Ref.writeRef(lchs)({ + initializers: Data_List_Types.Nil.value, + finalizers: v2.finalizers + })(); + Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Halogen_Aff_Driver_State.unDriverStateX(function ($67) { + return render(lchs)((function (v3) { + return v3.selfRef; + })($67)); + }))(Control_Monad_Eff_Ref.readRef(v1))(); + Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(squashChildInitializers(lchs)(v2.initializers))(Control_Monad_Eff_Ref.readRef(v1))(); + return v1; + }; + }); + }; + }; + }; + }; + var renderChild = function (lchs) { + return function (handler) { + return function (mkOrdBox) { + return function (childrenInRef) { + return function (childrenOutRef) { + return Halogen_Component.unComponentSlot(function (p) { + return function (ctor) { + return function (input) { + return function (inputQuery) { + return function (outputQuery) { + return function (prjQuery) { + var ordP = mkOrdBox(p); + return function __do() { + var v = Control_Monad_Eff_Ref.readRef(childrenInRef)(); + var v1 = (function () { + var v1 = Data_Map.pop(Halogen_Data_OrdBox.ordOrdBox)(ordP)(v); + if (v1 instanceof Data_Maybe.Just) { + return function __do() { + Control_Monad_Eff_Ref.writeRef(childrenInRef)(v1.value0.value1)(); + Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(inputQuery(input))(function (q) { + return function __do() { + var v2 = Control_Monad_Eff_Ref.readRef(v1.value0.value0)(); + return Halogen_Aff_Driver_State.unDriverStateX(function (st) { + return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(st.prjQuery(q))(function ($68) { + return handleAff(evalF(st.selfRef)(Halogen_Query_InputF.Query.create($68))); + }); + })(v2)(); + }; + })(); + return v1.value0.value0; + }; + }; + if (v1 instanceof Data_Maybe.Nothing) { + return runComponent(lchs)(function ($69) { + return Data_Maybe.maybe(Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(Data_Unit.unit))(handler)(outputQuery($69)); + })(input)(prjQuery)(ctor); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver line 260, column 14 - line 268, column 92: " + [ v1.constructor.name ]); + })()(); + var v2 = Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Map.member(Halogen_Data_OrdBox.ordOrdBox)(ordP))(Control_Monad_Eff_Ref.readRef(childrenOutRef))(); + Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v2)(Control_Monad_Eff_Unsafe.unsafeCoerceEff(Control_Monad_Eff_Console.warn("Halogen: Duplicate slot address was detected during rendering, unexpected results may occur")))(); + Control_Monad_Eff_Ref.modifyRef(childrenOutRef)(Data_Map.insert(Halogen_Data_OrdBox.ordOrdBox)(ordP)(v1))(); + return Control_Bind.bind(Control_Monad_Eff.bindEff)(Control_Monad_Eff_Ref.readRef(v1))(Halogen_Aff_Driver_State.renderStateX(Control_Monad_Eff.functorEff)(function (v3) { + if (v3 instanceof Data_Maybe.Nothing) { + return Control_Monad_Eff_Exception["throw"]("Halogen internal error: child was not initialized in renderChild"); + }; + if (v3 instanceof Data_Maybe.Just) { + return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(renderSpec.renderChild(v3.value0)); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver line 274, column 36 - line 276, column 50: " + [ v3.constructor.name ]); + }))(); + }; + }; + }; + }; + }; + }; + }); + }; + }; + }; + }; + }; + var render = function (lchs) { + return function ($$var) { + return function __do() { + var v = Control_Monad_Eff_Ref.readRef($$var)(); + var v1 = Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Maybe.isNothing)(Control_Monad_Eff_Ref.readRef(v.pendingHandlers))(); + Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v1)(Control_Monad_Eff_Ref.writeRef(v.pendingHandlers)(new Data_Maybe.Just(Data_List_Types.Nil.value)))(); + Control_Monad_Eff_Ref.writeRef(v.childrenOut)(Data_Map.empty)(); + Control_Monad_Eff_Ref.writeRef(v.childrenIn)(v.children)(); + var handler = Halogen_Aff_Driver_Eval.queuingHandler(function ($70) { + return Data_Functor["void"](Control_Monad_Aff.functorAff)(evalF(v.selfRef)($70)); + })(v.pendingHandlers); + var childHandler = Halogen_Aff_Driver_Eval.queuingHandler(function ($71) { + return handler(Halogen_Query_InputF.Query.create($71)); + })(v.pendingQueries); + var v2 = renderSpec.render(function ($72) { + return handleAff(handler($72)); + })(renderChild(lchs)(childHandler)(v.component.mkOrdBox)(v.childrenIn)(v.childrenOut))(v.component.render(v.state))(v.rendering)(); + var v3 = Control_Monad_Eff_Ref.readRef(v.childrenOut)(); + Control_Bind.bind(Control_Monad_Eff.bindEff)(Control_Monad_Eff_Ref.readRef(v.childrenIn))(Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Map.foldableMap)(function (childVar) { + return function __do() { + var v4 = Control_Monad_Eff_Ref.readRef(childVar)(); + Halogen_Aff_Driver_State.renderStateX_(Control_Monad_Eff.applicativeEff)(renderSpec.removeChild)(v4)(); + return finalize(lchs)(v4)(); + }; + }))(); + Control_Monad_Eff_Ref.modifyRef(v.selfRef)(function (v4) { + return { + rendering: new Data_Maybe.Just(v2), + children: v3, + component: v4.component, + state: v4.state, + refs: v4.refs, + childrenIn: v4.childrenIn, + childrenOut: v4.childrenOut, + selfRef: v4.selfRef, + handler: v4.handler, + pendingQueries: v4.pendingQueries, + pendingOuts: v4.pendingOuts, + pendingHandlers: v4.pendingHandlers, + prjQuery: v4.prjQuery, + fresh: v4.fresh, + subscriptions: v4.subscriptions, + lifecycleHandlers: v4.lifecycleHandlers + }; + })(); + return Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v1)(Data_Function.flip(Control_Monad_Rec_Class.tailRecM(Control_Monad_Rec_Class.monadRecEff))(Data_Unit.unit)(function (v4) { + return function __do() { + var v5 = Control_Monad_Eff_Ref.readRef(v.pendingHandlers)(); + Control_Monad_Eff_Ref.writeRef(v.pendingHandlers)(new Data_Maybe.Just(Data_List_Types.Nil.value))(); + Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(function ($73) { + return handleAff(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(Data_List.reverse($73))); + })(v5)(); + var v6 = Control_Monad_Eff_Ref.readRef(v.pendingHandlers)(); + var $57 = Data_Maybe.maybe(false)(Data_List["null"])(v6); + if ($57) { + return Data_Functor.voidLeft(Control_Monad_Eff.functorEff)(Control_Monad_Eff_Ref.writeRef(v.pendingHandlers)(Data_Maybe.Nothing.value))(new Control_Monad_Rec_Class.Done(Data_Unit.unit))(); + }; + return new Control_Monad_Rec_Class.Loop(Data_Unit.unit); + }; + }))(); + }; + }; + }; + var finalize = function (lchs) { + return Halogen_Aff_Driver_State.unDriverStateX(function (st) { + return function __do() { + cleanupSubscriptions(st)(); + Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(function ($74) { + return evalF(st.selfRef)(Halogen_Query_InputF.Query.create($74)); + })(st.component.finalizer))(function (f) { + return Control_Monad_Eff_Ref.modifyRef(lchs)(function (handlers) { + return { + initializers: handlers.initializers, + finalizers: new Data_List_Types.Cons(f, handlers.finalizers) + }; + }); + })(); + return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Map.foldableMap)(st.children)(Control_Bind.composeKleisliFlipped(Control_Monad_Eff.bindEff)(finalize(lchs))(Control_Monad_Eff_Ref.readRef))(); + }; + }); + }; + var evalF = function (ref) { + return Halogen_Aff_Driver_Eval["eval"](render)(ref); + }; + var evalDriver = function (ref) { + return function (prjQuery) { + return function (q) { + var v = prjQuery(q); + if (v instanceof Data_Maybe.Just) { + return evalF(ref)(new Halogen_Query_InputF.Query(v.value0)); + }; + if (v instanceof Data_Maybe.Nothing) { + return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Exception.throwException(Control_Monad_Eff_Exception.error("Halogen internal error: query projection failed in runUI'"))); + }; + throw new Error("Failed pattern match at Halogen.Aff.Driver line 138, column 5 - line 140, column 110: " + [ v.constructor.name ]); + }; + }; + }; + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(newLifecycleHandlers))(function (v) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.newRef(0)))(function (v1) { + return Halogen_Aff_Driver_Eval.handleLifecycle(v)(function __do() { + var v2 = Control_Monad_Eff_Ref.newRef(Data_Map.empty)(); + return Control_Bind.bind(Control_Monad_Eff.bindEff)(Control_Bind.bind(Control_Monad_Eff.bindEff)(runComponent(v)(rootHandler(v2))(i)(Data_Maybe.Just.create)(component))(Control_Monad_Eff_Ref.readRef))(Halogen_Aff_Driver_State.unDriverStateX(function (st) { + return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)({ + query: evalDriver(st.selfRef)(st.prjQuery), + subscribe: subscribe(v1)(v2) + }); + }))(); + }); + }); + }); + }; + }; + }; + exports["runUI"] = runUI; +})(PS["Halogen.Aff.Driver"] = PS["Halogen.Aff.Driver"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; + var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; + var Control_Monad_Except = PS["Control.Monad.Except"]; + var Control_Semigroupoid = PS["Control.Semigroupoid"]; + var DOM = PS["DOM"]; + var DOM_Event_EventTarget = PS["DOM.Event.EventTarget"]; + var DOM_HTML = PS["DOM.HTML"]; + var DOM_HTML_Event_EventTypes = PS["DOM.HTML.Event.EventTypes"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_HTML_Window = PS["DOM.HTML.Window"]; + var DOM_Node_ParentNode = PS["DOM.Node.ParentNode"]; + var Data_Either = PS["Data.Either"]; + var Data_Foreign = PS["Data.Foreign"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; + var Prelude = PS["Prelude"]; + var selectElement = function (query) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Control_Bind.composeKleisliFlipped(Control_Monad_Eff.bindEff)(function ($8) { + return DOM_Node_ParentNode.querySelector(query)(DOM_HTML_Types.htmlDocumentToParentNode($8)); + })(DOM_HTML_Window.document))(DOM_HTML.window)))(function (v) { + return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)((function () { + if (v instanceof Data_Maybe.Nothing) { + return Data_Maybe.Nothing.value; + }; + if (v instanceof Data_Maybe.Just) { + return Data_Either.either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create)(Control_Monad_Except.runExcept(DOM_HTML_Types.readHTMLElement(Data_Foreign.toForeign(v.value0)))); + }; + throw new Error("Failed pattern match at Halogen.Aff.Util line 53, column 8 - line 55, column 88: " + [ v.constructor.name ]); + })()); + }); + }; + var runHalogenAff = function ($9) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(Control_Monad_Aff.runAff(Control_Monad_Eff_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit)))($9)); + }; + var awaitLoad = Control_Monad_Aff.makeAff(function (v) { + return function (callback) { + return Control_Monad_Eff_Class.liftEff(Control_Monad_Eff_Class.monadEffEff)(function __do() { + var $10 = DOM_HTML.window(); + return DOM_Event_EventTarget.addEventListener(DOM_HTML_Event_EventTypes.load)(DOM_Event_EventTarget.eventListener(function (v1) { + return callback(Data_Unit.unit); + }))(false)(DOM_HTML_Types.windowToEventTarget($10))(); + }); + }; + }); + var awaitBody = Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(awaitLoad)(function () { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(selectElement("body"))(function (v) { + return Data_Maybe.maybe(Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error("Could not find body")))(Control_Applicative.pure(Control_Monad_Aff.applicativeAff))(v); + }); + }); + exports["awaitBody"] = awaitBody; + exports["awaitLoad"] = awaitLoad; + exports["runHalogenAff"] = runHalogenAff; + exports["selectElement"] = selectElement; +})(PS["Halogen.Aff.Util"] = PS["Halogen.Aff.Util"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var DOM = PS["DOM"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Array = PS["Data.Array"]; + var Data_Eq = PS["Data.Eq"]; + var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Nullable = PS["Data.Nullable"]; + var Data_Tuple = PS["Data.Tuple"]; + var Halogen_VDom_Machine = PS["Halogen.VDom.Machine"]; + var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; + var Halogen_VDom_Util = PS["Halogen.VDom.Util"]; + var Prelude = PS["Prelude"]; + var eqElemSpec = function (a, b) { + if (Data_Eq.eq(Halogen_VDom_Types.eqElemName)(a.value1)(b.value1)) { + if (a.value0 instanceof Data_Maybe.Just && (b.value0 instanceof Data_Maybe.Just && a.value0.value0 === b.value0.value0)) { + return true; + }; + if (a.value0 instanceof Data_Maybe.Nothing && b.value0 instanceof Data_Maybe.Nothing) { + return true; + }; + return false; + }; + return false; + }; + var buildWidget = function (v) { + var patch = function (v1) { + return function (v2) { + if (v2 instanceof Halogen_VDom_Types.Grafted) { + return patch(v1)(Halogen_VDom_Types.runGraft(v2.value0)); + }; + if (v2 instanceof Halogen_VDom_Types.Widget) { + return function __do() { + var v3 = v1.value1(v2.value0)(); + return new Halogen_VDom_Machine.Step(v3.value0, patch(v3), v3.value2); + }; + }; + return function __do() { + v1.value2(); + return buildVDom(v)(v2)(); + }; + }; + }; + var render = function (w) { + return function __do() { + var v1 = v.buildWidget(v)(w)(); + return new Halogen_VDom_Machine.Step(v1.value0, patch(v1), v1.value2); + }; + }; + return render; + }; + var buildVDom = function (spec) { + var render = function (v) { + if (v instanceof Halogen_VDom_Types.Text) { + return buildText(spec)(v.value0); + }; + if (v instanceof Halogen_VDom_Types.Elem) { + return buildElem(spec)(v.value0)(v.value1); + }; + if (v instanceof Halogen_VDom_Types.Keyed) { + return buildKeyed(spec)(v.value0)(v.value1); + }; + if (v instanceof Halogen_VDom_Types.Widget) { + return buildWidget(spec)(v.value0); + }; + if (v instanceof Halogen_VDom_Types.Grafted) { + return buildVDom(spec)(Halogen_VDom_Types.runGraft(v.value0)); + }; + throw new Error("Failed pattern match at Halogen.VDom.DOM line 58, column 12 - line 63, column 44: " + [ v.constructor.name ]); + }; + return render; + }; + var buildText = function (v) { + var done = function (node) { + return function __do() { + var v1 = Halogen_VDom_Util.unsafeParent(node); + return Halogen_VDom_Util.removeChild(node, v1)(); + }; + }; + var patch = function (node, s1) { + return function (v1) { + if (v1 instanceof Halogen_VDom_Types.Grafted) { + return patch(node, s1)(Halogen_VDom_Types.runGraft(v1.value0)); + }; + if (v1 instanceof Halogen_VDom_Types.Text) { + var res = new Halogen_VDom_Machine.Step(node, patch(node, v1.value0), done(node)); + var v2 = s1 === v1.value0; + if (v2) { + return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(res); + }; + return function __do() { + Halogen_VDom_Util.setTextContent(v1.value0, node)(); + return res; + }; + }; + return function __do() { + done(node)(); + return buildVDom(v)(v1)(); + }; + }; + }; + var render = function (s) { + return function __do() { + var v1 = Halogen_VDom_Util.createTextNode(s, v.document)(); + return new Halogen_VDom_Machine.Step(v1, patch(v1, s), done(v1)); + }; + }; + return render; + }; + var buildKeyed = function (v) { + var done = function (node, attrs, steps) { + return function __do() { + var v1 = Halogen_VDom_Util.unsafeParent(node); + Halogen_VDom_Util.removeChild(node, v1)(); + Halogen_VDom_Util.forInE(steps, function (v2, v3) { + return v3.value2; + })(); + return Halogen_VDom_Machine.halt(attrs)(); + }; + }; + var patch = function (node, attrs, v1, ch1, len1) { + return function (v2) { + if (v2 instanceof Halogen_VDom_Types.Grafted) { + return patch(node, attrs, v1, ch1, len1)(Halogen_VDom_Types.runGraft(v2.value0)); + }; + if (v2 instanceof Halogen_VDom_Types.Keyed && eqElemSpec(v1, v2.value0)) { + var v3 = Data_Array.length(v2.value1); + if (len1 === 0 && v3 === 0) { + return function __do() { + var v5 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); + return new Halogen_VDom_Machine.Step(node, patch(node, v5, v2.value0, ch1, 0), done(node, v5, ch1)); + }; + }; + var onThis = function (k, v5) { + return v5.value2; + }; + var onThese = function (k, ix$prime, v5, v6) { + return function __do() { + var v7 = v5.value1(v6.value1)(); + Halogen_VDom_Util.insertChildIx(ix$prime, v7.value0, node)(); + return v7; + }; + }; + var onThat = function (k, ix, v5) { + return function __do() { + var v6 = buildVDom(v)(v5.value1)(); + Halogen_VDom_Util.insertChildIx(ix, v6.value0, node)(); + return v6; + }; + }; + return function __do() { + var v5 = Halogen_VDom_Util.diffWithKeyAndIxE(ch1, v2.value1, Data_Tuple.fst, onThese, onThis, onThat)(); + var v6 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); + return new Halogen_VDom_Machine.Step(node, patch(node, v6, v2.value0, v5, v3), done(node, v6, v5)); + }; + }; + return function __do() { + done(node, attrs, ch1)(); + return buildVDom(v)(v2)(); + }; + }; + }; + var render = function (v1) { + return function (ch1) { + return function __do() { + var v2 = Halogen_VDom_Util.createElement(Data_Nullable.toNullable(v1.value0), v1.value1, v.document)(); + var node = DOM_Node_Types.elementToNode(v2); + var onChild = function (k, ix, v3) { + return function __do() { + var v4 = buildVDom(v)(v3.value1)(); + Halogen_VDom_Util.insertChildIx(ix, v4.value0, node)(); + return v4; + }; + }; + var v3 = Halogen_VDom_Util.strMapWithIxE(ch1, Data_Tuple.fst, onChild)(); + var v4 = v.buildAttributes(v2)(v1.value2)(); + return new Halogen_VDom_Machine.Step(node, patch(node, v4, v1, v3, Data_Array.length(ch1)), done(node, v4, v3)); + }; + }; + }; + return render; + }; + var buildElem = function (v) { + var done = function (node, attrs, steps) { + return function __do() { + var v1 = Halogen_VDom_Util.unsafeParent(node); + Halogen_VDom_Util.removeChild(node, v1)(); + Control_Monad_Eff.foreachE(steps)(Halogen_VDom_Machine.halt)(); + return Halogen_VDom_Machine.halt(attrs)(); + }; + }; + var patch = function (node, attrs, v1, ch1) { + return function (v2) { + if (v2 instanceof Halogen_VDom_Types.Grafted) { + return patch(node, attrs, v1, ch1)(Halogen_VDom_Types.runGraft(v2.value0)); + }; + if (v2 instanceof Halogen_VDom_Types.Elem && eqElemSpec(v1, v2.value0)) { + var v3 = Data_Array.length(v2.value1); + var v4 = Data_Array.length(ch1); + if (v4 === 0 && v3 === 0) { + return function __do() { + var v5 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); + return new Halogen_VDom_Machine.Step(node, patch(node, v5, v2.value0, ch1), done(node, v5, ch1)); + }; + }; + var onThis = function (ix, v5) { + return v5.value2; + }; + var onThese = function (ix, v5, vdom) { + return function __do() { + var v6 = v5.value1(vdom)(); + Halogen_VDom_Util.insertChildIx(ix, v6.value0, node)(); + return v6; + }; + }; + var onThat = function (ix, vdom) { + return function __do() { + var v5 = buildVDom(v)(vdom)(); + Halogen_VDom_Util.insertChildIx(ix, v5.value0, node)(); + return v5; + }; + }; + return function __do() { + var v5 = Halogen_VDom_Util.diffWithIxE(ch1, v2.value1, onThese, onThis, onThat)(); + var v6 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); + return new Halogen_VDom_Machine.Step(node, patch(node, v6, v2.value0, v5), done(node, v6, v5)); + }; + }; + return function __do() { + done(node, attrs, ch1)(); + return buildVDom(v)(v2)(); + }; + }; + }; + var render = function (v1) { + return function (ch1) { + return function __do() { + var v2 = Halogen_VDom_Util.createElement(Data_Nullable.toNullable(v1.value0), v1.value1, v.document)(); + var node = DOM_Node_Types.elementToNode(v2); + var onChild = function (ix, child) { + return function __do() { + var v3 = buildVDom(v)(child)(); + Halogen_VDom_Util.insertChildIx(ix, v3.value0, node)(); + return v3; + }; + }; + var v3 = Halogen_VDom_Util.forE(ch1, onChild)(); + var v4 = v.buildAttributes(v2)(v1.value2)(); + return new Halogen_VDom_Machine.Step(node, patch(node, v4, v1, v3), done(node, v4, v3)); + }; + }; + }; + return render; + }; + exports["buildElem"] = buildElem; + exports["buildKeyed"] = buildKeyed; + exports["buildText"] = buildText; + exports["buildVDom"] = buildVDom; + exports["buildWidget"] = buildWidget; +})(PS["Halogen.VDom.DOM"] = PS["Halogen.VDom.DOM"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Category = PS["Control.Category"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; + var DOM = PS["DOM"]; + var DOM_HTML = PS["DOM.HTML"]; + var DOM_HTML_Types = PS["DOM.HTML.Types"]; + var DOM_HTML_Window = PS["DOM.HTML.Window"]; + var DOM_Node_Node = PS["DOM.Node.Node"]; + var DOM_Node_Types = PS["DOM.Node.Types"]; + var Data_Foldable = PS["Data.Foldable"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor = PS["Data.Functor"]; + var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen_Aff_Driver = PS["Halogen.Aff.Driver"]; + var Halogen_Aff_Driver_State = PS["Halogen.Aff.Driver.State"]; + var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; + var Halogen_Component = PS["Halogen.Component"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; + var Halogen_VDom = PS["Halogen.VDom"]; + var Halogen_VDom_DOM = PS["Halogen.VDom.DOM"]; + var Halogen_VDom_DOM_Prop = PS["Halogen.VDom.DOM.Prop"]; + var Halogen_VDom_Machine = PS["Halogen.VDom.Machine"]; + var Prelude = PS["Prelude"]; + var Unsafe_Reference = PS["Unsafe.Reference"]; + var substInParent = function (v) { + return function (v1) { + return function (v2) { + if (v1 instanceof Data_Maybe.Just && v2 instanceof Data_Maybe.Just) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(DOM_Node_Node.insertBefore(v)(v1.value0)(v2.value0)); + }; + if (v1 instanceof Data_Maybe.Nothing && v2 instanceof Data_Maybe.Just) { + return Data_Functor["void"](Control_Monad_Eff.functorEff)(DOM_Node_Node.appendChild(v)(v2.value0)); + }; + return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit); + }; + }; + }; + var removeChild = function (v) { + return function __do() { + var v1 = DOM_Node_Node.parentNode(v.node)(); + return Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(function (pn) { + return DOM_Node_Node.removeChild(v.node)(pn); + })(v1)(); + }; + }; + var mkSpec = function (handler) { + return function (renderChildRef) { + return function (document) { + var getNode = Halogen_Aff_Driver_State.unRenderStateX(function (v) { + return v.node; + }); + var done = Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit); + var patch = function (slot) { + return function __do() { + var v = Control_Monad_Eff_Ref.readRef(renderChildRef)(); + var v1 = v(slot)(); + var node = getNode(v1); + return new Halogen_VDom_Machine.Step(node, patch, done); + }; + }; + var buildWidget = function (spec) { + return function (slot) { + return function __do() { + var v = Control_Monad_Eff_Ref.readRef(renderChildRef)(); + var v1 = v(slot)(); + var node = getNode(v1); + return new Halogen_VDom_Machine.Step(node, patch, done); + }; + }; + }; + var buildAttributes = Halogen_VDom_DOM_Prop.buildProp(handler); + return { + buildWidget: buildWidget, + buildAttributes: buildAttributes, + document: document + }; + }; + }; + }; + var renderSpec = function (document) { + return function (container) { + var render = function (handler) { + return function (child) { + return function (v) { + return function (v1) { + if (v1 instanceof Data_Maybe.Nothing) { + return function __do() { + var v2 = Control_Monad_Eff_Ref.newRef(child)(); + var spec = mkSpec(handler)(v2)(document); + var v3 = Halogen_VDom_DOM.buildVDom(spec)(v)(); + var node = Halogen_VDom_Machine.extract(v3); + Data_Functor["void"](Control_Monad_Eff.functorEff)(DOM_Node_Node.appendChild(node)(DOM_HTML_Types.htmlElementToNode(container)))(); + return { + machine: v3, + node: node, + renderChildRef: v2 + }; + }; + }; + if (v1 instanceof Data_Maybe.Just) { + return function __do() { + Control_Monad_Eff_Ref.writeRef(v1.value0.renderChildRef)(child)(); + var v2 = DOM_Node_Node.parentNode(v1.value0.node)(); + var v3 = DOM_Node_Node.nextSibling(v1.value0.node)(); + var v4 = Halogen_VDom_Machine.step(v1.value0.machine)(v)(); + var newNode = Halogen_VDom_Machine.extract(v4); + Control_Applicative.when(Control_Monad_Eff.applicativeEff)(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraBoolean)))(Unsafe_Reference.unsafeRefEq)(v1.value0.node)(newNode))(substInParent(newNode)(v3)(v2))(); + return { + machine: v4, + node: newNode, + renderChildRef: v1.value0.renderChildRef + }; + }; + }; + throw new Error("Failed pattern match at Halogen.VDom.Driver line 121, column 5 - line 137, column 80: " + [ v1.constructor.name ]); + }; + }; + }; + }; + return { + render: render, + renderChild: Control_Category.id(Control_Category.categoryFn), + removeChild: removeChild + }; + }; + }; + var runUI = function (component) { + return function (i) { + return function (element) { + return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Data_Functor.map(Control_Monad_Eff.functorEff)(DOM_HTML_Types.htmlDocumentToDocument)(Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(DOM_HTML_Window.document)(DOM_HTML.window))))(function (v) { + return Halogen_Aff_Driver.runUI(renderSpec(v)(element))(component)(i); + }); + }; + }; + }; + exports["runUI"] = runUI; +})(PS["Halogen.VDom.Driver"] = PS["Halogen.VDom.Driver"] || {}); +(function(exports) { + // Generated by purs version 0.11.6 + "use strict"; + var ColorPicker_Halogen_Component = PS["ColorPicker.Halogen.Component"]; + var Control_Applicative = PS["Control.Applicative"]; + var Control_Bind = PS["Control.Bind"]; + var Control_Monad_Aff = PS["Control.Monad.Aff"]; + var Control_Monad_Eff = PS["Control.Monad.Eff"]; + var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; + var Data_Either = PS["Data.Either"]; + var Data_Either_Nested = PS["Data.Either.Nested"]; + var Data_Function = PS["Data.Function"]; + var Data_Functor_Coproduct_Nested = PS["Data.Functor.Coproduct.Nested"]; + var Data_Maybe = PS["Data.Maybe"]; + var Data_Ord = PS["Data.Ord"]; + var Data_Unit = PS["Data.Unit"]; + var Halogen = PS["Halogen"]; + var Halogen_Aff = PS["Halogen.Aff"]; + var Halogen_Aff_Util = PS["Halogen.Aff.Util"]; + var Halogen_Component = PS["Halogen.Component"]; + var Halogen_Component_ChildPath = PS["Halogen.Component.ChildPath"]; + var Halogen_HTML = PS["Halogen.HTML"]; + var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; + var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; + var Halogen_HTML_Events = PS["Halogen.HTML.Events"]; + var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; + var Halogen_VDom_Driver = PS["Halogen.VDom.Driver"]; + var Prelude = PS["Prelude"]; + var HandleMsg = (function () { + function HandleMsg(value0, value1, value2) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + }; + HandleMsg.create = function (value0) { + return function (value1) { + return function (value2) { + return new HandleMsg(value0, value1, value2); + }; + }; + }; + return HandleMsg; + })(); + var $$eval = function (v) { + return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value2); + }; + var cpColor = Halogen_Component_ChildPath.cp1; + var render = function (dictMonadEff) { + return function (v) { + return Halogen_HTML_Elements.div_([ Halogen_HTML_Elements.h1_([ Halogen_HTML_Core.text("Picker 1") ]), Halogen_HTML["slot'"](cpColor)(0)(ColorPicker_Halogen_Component.picker(dictMonadEff))(Data_Unit.unit)(Halogen_HTML_Events.input(HandleMsg.create(0))) ]); + }; + }; + var example = function (dictMonadEff) { + return Halogen_Component.parentComponent(Data_Either.ordEither(Data_Ord.ordInt)(Data_Ord.ordVoid))({ + initialState: Data_Function["const"]({}), + render: render(dictMonadEff), + "eval": $$eval, + receiver: Data_Function["const"](Data_Maybe.Nothing.value) + }); + }; + var main = Halogen_Aff_Util.runHalogenAff(Control_Bind.bind(Control_Monad_Aff.bindAff)(Halogen_Aff_Util.awaitBody)(function (v) { + return Halogen_VDom_Driver.runUI(example(Control_Monad_Aff.monadEffAff))(Data_Unit.unit)(v); + })); + exports["HandleMsg"] = HandleMsg; + exports["cpColor"] = cpColor; + exports["eval"] = $$eval; + exports["example"] = example; + exports["main"] = main; + exports["render"] = render; +})(PS["Main"] = PS["Main"] || {}); +PS["Main"].main(); diff --git a/example/index.html b/example/index.html new file mode 100644 index 0000000..53aaf16 --- /dev/null +++ b/example/index.html @@ -0,0 +1,74 @@ + + + + Halogen Datepicker Example + + + + + + diff --git a/example/src/Main.purs b/example/src/Main.purs new file mode 100644 index 0000000..5dd9ccc --- /dev/null +++ b/example/src/Main.purs @@ -0,0 +1,54 @@ +module Main where + +import Prelude + +import ColorPicker.Halogen.Component as CPicker +import Control.Monad.Eff (Eff) +import Control.Monad.Eff.Class (class MonadEff) +import Data.Either.Nested as Either +import Data.Functor.Coproduct.Nested as Coproduct +import Data.Maybe (Maybe(..)) +import Halogen as H +import Halogen.Aff as HA +import Halogen.Component.ChildPath as CP +import Halogen.HTML as HH +import Halogen.HTML.Events as HE +import Halogen.VDom.Driver (runUI) + +main ∷ Eff (HA.HalogenEffects ()) Unit +main = HA.runHalogenAff do + body ← HA.awaitBody + runUI example unit body + +data Query a = HandleMsg ColorIdx CPicker.Message a + +type State = {} +type ColorIdx = Int +type ChildQuery = Coproduct.Coproduct1 CPicker.Query +type Slot = Either.Either1 ColorIdx + + +cpColor ∷ CP.ChildPath CPicker.Query ChildQuery ColorIdx Slot +cpColor = CP.cp1 + + +type HTML m = H.ParentHTML Query ChildQuery Slot m +type DSL m = H.ParentDSL State Query ChildQuery Slot Void m + + +example ∷ ∀ m r. MonadEff (CPicker.PickerEffects r) m => H.Component HH.HTML Query Unit Void m +example = H.parentComponent + { initialState: const {} + , render + , eval + , receiver: const Nothing + } + +render ∷ ∀ m r. MonadEff (CPicker.PickerEffects r) m => State → HTML m +render _ = HH.div_ + [ HH.h1_ [ HH.text "Picker 1" ] + , HH.slot' cpColor 0 CPicker.picker unit (HE.input (HandleMsg 0)) + ] + +eval ∷ ∀ m. Query ~> DSL m +eval (HandleMsg _ _ next) = pure next diff --git a/package.json b/package.json new file mode 100644 index 0000000..bed1a9c --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "private": true, + "scripts": { + "watch": "pulp --watch build --include example/src --to example/example.js", + "build": "pulp build --include example/src --to example/example.js" + }, + "devDependencies": { + "pulp": "^11.0.0", + "purescript": "^0.11.0", + "purescript-psa": "^0.5.0" + } +} diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs new file mode 100644 index 0000000..3ebaade --- /dev/null +++ b/src/ColorPicker/Halogen/Component.purs @@ -0,0 +1,187 @@ +module ColorPicker.Halogen.Component where + +import Debug.Trace +import Prelude + +import CSS as CSS +import Color as Color +import Control.Monad.Eff (Eff) +import Control.Monad.Eff.Class (class MonadEff) +import DOM (DOM) +import DOM.Classy.Event (class IsEvent, target) +import DOM.Classy.HTMLElement (getBoundingClientRect) +import DOM.Classy.Node (fromNode) +import DOM.Event.MouseEvent as MouseE +import DOM.Event.TouchEvent as TouchE +import DOM.Event.Types (MouseEvent, TouchEvent) +import DOM.HTML.Types (HTMLElement) +import Data.Either (Either(..), either) +import Data.Int (toNumber) +import Data.Maybe (Maybe(..), fromMaybe) +import Halogen as H +import Halogen.HTML as HH +import Halogen.HTML.CSS as HCSS +import Halogen.HTML.Events as HE +import Halogen.HTML.Properties as HP +import Math (abs) + +data Condition = Idle | ColorDrag | HueDrag + +type State = + { color ∷ Maybe Color.Color + , condition ∷ Condition + } + +type Message = Unit +data Query a + = NoOp a + | StartUpdateColor (Either TouchEvent MouseEvent) a + | EndUpdateColor a + | UpdateColor (Either TouchEvent MouseEvent) a + + +type HTML = H.ComponentHTML Query +type DSL m = H.ComponentDSL State Query Message m + +type PickerEffects r = (dom :: DOM | r) + + +picker ∷ ∀ m r. MonadEff (PickerEffects r) m ⇒ H.Component HH.HTML Query Unit Message m +picker = H.component + { initialState: const { color: Nothing, condition: Idle } + , render + , eval + , receiver: const Nothing + } + + +type Position = { x ∷ Number, y ∷ Number } + +positionInRect + ∷ ∀ r + . Position + → { left ∷ Number , width ∷ Number , top ∷ Number , height ∷ Number | r} + → Position +positionInRect { x, y } { left, width, top, height } = + { x: (x - left) / width * 100.0 + , y: (y - top) / height * 100.0 + } + +applyRect + ∷ ∀ event r + . IsEvent event + ⇒ event + → Position + → Eff (PickerEffects r) Position +applyRect e input = + let + elem ∷ Maybe HTMLElement + elem = fromNode $ target e + rect = getBoundingClientRect <$> elem + in + case rect of + Nothing → pure input + Just p -> positionInRect input <$> p + +touchEventToPosition ∷ ∀ r. TouchEvent → Eff (PickerEffects r) Position +touchEventToPosition e = + let + fstTouch = e # TouchE.touches # TouchE.item 0 + in + case fstTouch of + Nothing → pure {x: 0.0, y: 0.0} + Just t → applyRect e + { x: toNumber $ TouchE.clientX t + , y: toNumber $ TouchE.clientY t} + + +mouseEventToPosition ∷ ∀ r. MouseEvent → Eff (PickerEffects r) Position +mouseEventToPosition e = applyRect e + { x: toNumber $ MouseE.clientX e + , y: toNumber $ MouseE.clientY e} + +render ∷ State → HTML +render {color} = + HH.div + [ HP.classes [ HH.ClassName "ColorPicker"]] + [ HH.div + [ HP.classes [ HH.ClassName "ColorPicker-color"] + , HCSS.style $ CSS.backgroundColor $ pureHue $ orDefault color + , HE.onMouseDown $ HE.input (Right >>> StartUpdateColor) + , HE.onMouseMove $ HE.input (Right >>> UpdateColor) + , HE.onMouseUp $ HE.input_ EndUpdateColor + , HE.onTouchStart $ HE.input (Left >>> StartUpdateColor) + , HE.onTouchMove $ HE.input (Left >>> UpdateColor) + , HE.onTouchEnd $ HE.input_ EndUpdateColor + ] + [ HH.div [ HP.classes [ HH.ClassName "ColorPicker-saturation"]] [] + , HH.div [ HP.classes [ HH.ClassName "ColorPicker-brightness"]] [] + , HH.div + [ HP.classes [ HH.ClassName "ColorPicker-sbSelector"] + , HCSS.style $ case color of + Nothing → CSS.display CSS.displayNone + Just c → do + CSS.backgroundColor c + CSS.borderColor $ if Color.isLight c + then CSS.black + else CSS.white + ] + [] + ] + , HH.div + [ HP.classes [ HH.ClassName "ColorPicker-hue"]] + [ HH.div + [ HP.classes + [ HH.ClassName "ColorPicker-hSelector"] + , let + hue = getHue $ orDefault color + in + HCSS.style do + CSS.top $ CSS.pct (hue / 360.0 * 100.0) + ] + [] + ] + ] + + +eval ∷ ∀ m r. MonadEff (PickerEffects r) m ⇒ Query ~> DSL m +eval (NoOp next) = pure next +eval (StartUpdateColor event next) = do + H.modify _{condition = ColorDrag} + pos <- H.liftEff $ posFromEvent event + traceAnyA pos + pure next + +eval (EndUpdateColor next) = do + H.modify _{condition = Idle} + pure next + + +eval (UpdateColor event next) = do + {condition} ← H.get + case condition of + ColorDrag -> do + pos <- H.liftEff $ posFromEvent event + traceAnyA pos + _ -> pure unit + pure next + +posFromEvent :: ∀ r. Either TouchEvent MouseEvent -> Eff (PickerEffects r) Position +posFromEvent = either touchEventToPosition mouseEventToPosition + +-- data Condition = Idle | ColorDrag | HueDrag + +orDefault ∷ Maybe Color.Color → Color.Color +orDefault = fromMaybe (Color.hsl 180.0 0.0 0.0) + +pureHue ∷ Color.Color → Color.Color +pureHue c = Color.hsl (getHue c) 1.0 0.5 + +getHue∷ Color.Color → Number +getHue = Color.toHSLA >>> _.h + +getSaturation∷ Color.Color → Number +getSaturation = Color.toHSLA >>> _.s + +getLightness∷ Color.Color → Number +getLightness = Color.toHSLA >>> _.l From c807f189c7dd4cff8ceee9da8f198a0e485aecad Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 20 Jul 2017 20:54:47 +0400 Subject: [PATCH 02/72] add initial drag component --- src/ColorPicker/Halogen/Utils/Drag.purs | 109 ++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/ColorPicker/Halogen/Utils/Drag.purs diff --git a/src/ColorPicker/Halogen/Utils/Drag.purs b/src/ColorPicker/Halogen/Utils/Drag.purs new file mode 100644 index 0000000..3418b85 --- /dev/null +++ b/src/ColorPicker/Halogen/Utils/Drag.purs @@ -0,0 +1,109 @@ +module ColorPicker.Halogen.Utils.Drag + ( dragEventSource + , DragData + , DragEvent(..) + , DragEffects + , PageCoord + , mouseEventToPageCoord + ) where + +import Prelude + +import Control.Monad.Aff.AVar (AVAR) +import Control.Monad.Aff.Class (class MonadAff) +import Control.Monad.Eff (Eff) +import Control.Monad.Eff.Ref (REF, newRef, readRef, writeRef) + +import Data.Maybe (Maybe) + +import DOM (DOM) +import DOM.Event.EventTarget (EventListener, eventListener, addEventListener, removeEventListener) +import DOM.Event.Types (Event, MouseEvent) +import DOM.HTML (window) +import DOM.HTML.Event.EventTypes (mousemove, mouseup) +import DOM.HTML.Types (windowToEventTarget) + +import Halogen.Query.EventSource as ES + +import Unsafe.Coerce (unsafeCoerce) + +type DragData = + { x ∷ Number + , y ∷ Number + , deltaX ∷ Number + , deltaY ∷ Number + , offsetX ∷ Number + , offsetY ∷ Number + } + +data DragEvent + = Move MouseEvent DragData + | Done MouseEvent + +type DragEffects eff = + ( dom ∷ DOM + , ref ∷ REF + , avar ∷ AVAR + | eff + ) + +type PageCoord = + { pageX ∷ Number + , pageY ∷ Number + } + +dragEventSource + ∷ ∀ f m eff + . MonadAff (DragEffects eff) m + ⇒ MouseEvent + → (DragEvent → Maybe (f ES.SubscribeStatus)) + → ES.EventSource f m +dragEventSource mouseEvent = ES.eventSource' \emit → do + let initEv = mouseEventToPageCoord mouseEvent + eventRef ← newRef initEv + + let + removeListeners ∷ Eff (DragEffects eff) Unit + removeListeners = do + win ← windowToEventTarget <$> window + removeEventListener mousemove mouseMove false win + removeEventListener mouseup mouseUp false win + + mouseMove ∷ EventListener (DragEffects eff) + mouseMove = eventListener \ev → do + prevEv ← readRef eventRef + let + ev' = unsafeEventToPageCoord ev + x1 = prevEv.pageX + y1 = prevEv.pageY + x2 = ev'.pageX + y2 = ev'.pageY + dragData = + { x: x2 + , y: y2 + , deltaX: x2 - x1 + , deltaY: y2 - y1 + , offsetX: x2 - initEv.pageX + , offsetY: y2 - initEv.pageY + } + writeRef eventRef ev' + emit $ Move (unsafeEventToMouseEvent ev) dragData + + mouseUp ∷ EventListener (DragEffects eff) + mouseUp = eventListener \ev → do + removeListeners + emit $ Done (unsafeEventToMouseEvent ev) + + win ← windowToEventTarget <$> window + addEventListener mousemove mouseMove false win + addEventListener mouseup mouseUp false win + pure removeListeners + +unsafeEventToPageCoord ∷ Event → PageCoord +unsafeEventToPageCoord = unsafeCoerce + +unsafeEventToMouseEvent ∷ Event → MouseEvent +unsafeEventToMouseEvent = unsafeCoerce + +mouseEventToPageCoord ∷ MouseEvent → PageCoord +mouseEventToPageCoord = unsafeCoerce From 75fd6a7e9534c279808c8a80a28cb4405ae09757 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 20 Jul 2017 21:01:24 +0400 Subject: [PATCH 03/72] Update Drag --- .gitignore | 3 + bower.json | 6 +- example/example.js | 9983 ----------------------- example/index.html | 7 +- example/src/Main.purs | 11 +- src/ColorPicker/Halogen/Component.js | 3 + src/ColorPicker/Halogen/Component.purs | 131 +- src/ColorPicker/Halogen/Utils/Drag.purs | 222 +- 8 files changed, 218 insertions(+), 10148 deletions(-) delete mode 100644 example/example.js create mode 100644 src/ColorPicker/Halogen/Component.js diff --git a/.gitignore b/.gitignore index 361cf52..0e30603 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ node_modules # Generated files .psci output +example/example.js + +.psc-ide-port diff --git a/bower.json b/bower.json index a94c67e..49951f3 100644 --- a/bower.json +++ b/bower.json @@ -23,6 +23,10 @@ "purescript-colors": "^3.0.0", "purescript-halogen": "^2.1.0", "purescript-halogen-css": "^6.0.0", - "purescript-dom-classy": "^2.1.0" + "purescript-dom-classy": "^2.1.0", + "purescript-dom": "git://github.com/safareli/purescript-dom.git#mousepagexy" + }, + "resolutions": { + "purescript-dom": "mousepagexy" } } diff --git a/example/example.js b/example/example.js deleted file mode 100644 index ca1e0f4..0000000 --- a/example/example.js +++ /dev/null @@ -1,9983 +0,0 @@ -// Generated by psc-bundle 0.11.6 -var PS = {}; -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Semigroupoid = function (compose) { - this.compose = compose; - }; - var semigroupoidFn = new Semigroupoid(function (f) { - return function (g) { - return function (x) { - return f(g(x)); - }; - }; - }); - var compose = function (dict) { - return dict.compose; - }; - exports["Semigroupoid"] = Semigroupoid; - exports["compose"] = compose; - exports["semigroupoidFn"] = semigroupoidFn; -})(PS["Control.Semigroupoid"] = PS["Control.Semigroupoid"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Category = function (Semigroupoid0, id) { - this.Semigroupoid0 = Semigroupoid0; - this.id = id; - }; - var id = function (dict) { - return dict.id; - }; - var categoryFn = new Category(function () { - return Control_Semigroupoid.semigroupoidFn; - }, function (x) { - return x; - }); - exports["Category"] = Category; - exports["id"] = id; - exports["categoryFn"] = categoryFn; -})(PS["Control.Category"] = PS["Control.Category"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Prelude = PS["Prelude"]; - var IsString = function (fromString) { - this.fromString = fromString; - }; - var fromString = function (dict) { - return dict.fromString; - }; - exports["IsString"] = IsString; - exports["fromString"] = fromString; -})(PS["CSS.String"] = PS["CSS.String"] || {}); -(function(exports) { - "use strict"; - - exports.arrayApply = function (fs) { - return function (xs) { - var result = []; - var n = 0; - for (var i = 0, l = fs.length; i < l; i++) { - for (var j = 0, k = xs.length; j < k; j++) { - result[n++] = fs[i](xs[j]); - } - } - return result; - }; - }; -})(PS["Control.Apply"] = PS["Control.Apply"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var flip = function (f) { - return function (b) { - return function (a) { - return f(a)(b); - }; - }; - }; - var $$const = function (a) { - return function (v) { - return a; - }; - }; - var applyFlipped = function (x) { - return function (f) { - return f(x); - }; - }; - exports["applyFlipped"] = applyFlipped; - exports["const"] = $$const; - exports["flip"] = flip; -})(PS["Data.Function"] = PS["Data.Function"] || {}); -(function(exports) { - "use strict"; - - exports.arrayMap = function (f) { - return function (arr) { - var l = arr.length; - var result = new Array(l); - for (var i = 0; i < l; i++) { - result[i] = f(arr[i]); - } - return result; - }; - }; -})(PS["Data.Functor"] = PS["Data.Functor"] || {}); -(function(exports) { - "use strict"; - - exports.unit = {}; -})(PS["Data.Unit"] = PS["Data.Unit"] || {}); -(function(exports) { - "use strict"; - - exports.showNumberImpl = function (n) { - var str = n.toString(); - return isNaN(str + ".0") ? str : str + ".0"; - }; -})(PS["Data.Show"] = PS["Data.Show"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Show"]; - var Show = function (show) { - this.show = show; - }; - var showNumber = new Show($foreign.showNumberImpl); - var show = function (dict) { - return dict.show; - }; - exports["Show"] = Show; - exports["show"] = show; - exports["showNumber"] = showNumber; -})(PS["Data.Show"] = PS["Data.Show"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Unit"]; - var Data_Show = PS["Data.Show"]; - exports["unit"] = $foreign.unit; -})(PS["Data.Unit"] = PS["Data.Unit"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Functor"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Function = PS["Data.Function"]; - var Data_Unit = PS["Data.Unit"]; - var Functor = function (map) { - this.map = map; - }; - var map = function (dict) { - return dict.map; - }; - var $$void = function (dictFunctor) { - return map(dictFunctor)(Data_Function["const"](Data_Unit.unit)); - }; - var voidLeft = function (dictFunctor) { - return function (f) { - return function (x) { - return map(dictFunctor)(Data_Function["const"](x))(f); - }; - }; - }; - var functorFn = new Functor(Control_Semigroupoid.compose(Control_Semigroupoid.semigroupoidFn)); - var functorArray = new Functor($foreign.arrayMap); - exports["Functor"] = Functor; - exports["map"] = map; - exports["void"] = $$void; - exports["voidLeft"] = voidLeft; - exports["functorFn"] = functorFn; - exports["functorArray"] = functorArray; -})(PS["Data.Functor"] = PS["Data.Functor"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Apply = function (Functor0, apply) { - this.Functor0 = Functor0; - this.apply = apply; - }; - var applyArray = new Apply(function () { - return Data_Functor.functorArray; - }, $foreign.arrayApply); - var apply = function (dict) { - return dict.apply; - }; - var applySecond = function (dictApply) { - return function (a) { - return function (b) { - return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"](Control_Category.id(Control_Category.categoryFn)))(a))(b); - }; - }; - }; - var lift2 = function (dictApply) { - return function (f) { - return function (a) { - return function (b) { - return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b); - }; - }; - }; - }; - exports["Apply"] = Apply; - exports["apply"] = apply; - exports["applySecond"] = applySecond; - exports["lift2"] = lift2; - exports["applyArray"] = applyArray; -})(PS["Control.Apply"] = PS["Control.Apply"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Apply = PS["Control.Apply"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Unit = PS["Data.Unit"]; - var Applicative = function (Apply0, pure) { - this.Apply0 = Apply0; - this.pure = pure; - }; - var pure = function (dict) { - return dict.pure; - }; - var when = function (dictApplicative) { - return function (v) { - return function (v1) { - if (v) { - return v1; - }; - if (!v) { - return pure(dictApplicative)(Data_Unit.unit); - }; - throw new Error("Failed pattern match at Control.Applicative line 57, column 1 - line 57, column 63: " + [ v.constructor.name, v1.constructor.name ]); - }; - }; - }; - var liftA1 = function (dictApplicative) { - return function (f) { - return function (a) { - return Control_Apply.apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a); - }; - }; - }; - exports["Applicative"] = Applicative; - exports["liftA1"] = liftA1; - exports["pure"] = pure; - exports["when"] = when; -})(PS["Control.Applicative"] = PS["Control.Applicative"] || {}); -(function(exports) { - "use strict"; - - exports.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; - }; - }; -})(PS["Control.Bind"] = PS["Control.Bind"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Bind"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Unit = PS["Data.Unit"]; - var Bind = function (Apply0, bind) { - this.Apply0 = Apply0; - this.bind = bind; - }; - var Discard = function (discard) { - this.discard = discard; - }; - var discard = function (dict) { - return dict.discard; - }; - var bindArray = new Bind(function () { - return Control_Apply.applyArray; - }, $foreign.arrayBind); - var bind = function (dict) { - return dict.bind; - }; - var bindFlipped = function (dictBind) { - return Data_Function.flip(bind(dictBind)); - }; - var composeKleisliFlipped = function (dictBind) { - return function (f) { - return function (g) { - return function (a) { - return bindFlipped(dictBind)(f)(g(a)); - }; - }; - }; - }; - var discardUnit = new Discard(function (dictBind) { - return bind(dictBind); - }); - exports["Bind"] = Bind; - exports["Discard"] = Discard; - exports["bind"] = bind; - exports["bindFlipped"] = bindFlipped; - exports["composeKleisliFlipped"] = composeKleisliFlipped; - exports["discard"] = discard; - exports["bindArray"] = bindArray; - exports["discardUnit"] = discardUnit; -})(PS["Control.Bind"] = PS["Control.Bind"] || {}); -(function(exports) { - "use strict"; - - exports.fromFoldableImpl = (function () { - // jshint maxparams: 2 - 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 ------------------------------------------------------------------ - //------------------------------------------------------------------------------ - - exports.length = function (xs) { - return xs.length; - }; -})(PS["Data.Array"] = PS["Data.Array"] || {}); -(function(exports) { - "use strict"; - - exports.concatArray = function (xs) { - return function (ys) { - if (xs.length === 0) return ys; - if (ys.length === 0) return xs; - return xs.concat(ys); - }; - }; -})(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Semigroup"]; - var Data_Unit = PS["Data.Unit"]; - var Data_Void = PS["Data.Void"]; - var Semigroup = function (append) { - this.append = append; - }; - var semigroupArray = new Semigroup($foreign.concatArray); - var append = function (dict) { - return dict.append; - }; - var semigroupFn = function (dictSemigroup) { - return new Semigroup(function (f) { - return function (g) { - return function (x) { - return append(dictSemigroup)(f(x))(g(x)); - }; - }; - }); - }; - exports["Semigroup"] = Semigroup; - exports["append"] = append; - exports["semigroupFn"] = semigroupFn; - exports["semigroupArray"] = semigroupArray; -})(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Functor = PS["Data.Functor"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Alt = function (Functor0, alt) { - this.Functor0 = Functor0; - this.alt = alt; - }; - var alt = function (dict) { - return dict.alt; - }; - exports["Alt"] = Alt; - exports["alt"] = alt; -})(PS["Control.Alt"] = PS["Control.Alt"] || {}); -(function(exports) { - "use strict"; - - exports.pureE = function (a) { - return function () { - return a; - }; - }; - - exports.bindE = function (a) { - return function (f) { - return function () { - return f(a())(); - }; - }; - }; - - exports.runPure = function (f) { - return f(); - }; - - exports.foreachE = function (as) { - return function (f) { - return function () { - for (var i = 0, l = as.length; i < l; i++) { - f(as[i])(); - } - }; - }; - }; -})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Unit = PS["Data.Unit"]; - var Monad = function (Applicative0, Bind1) { - this.Applicative0 = Applicative0; - this.Bind1 = Bind1; - }; - var ap = function (dictMonad) { - return function (f) { - return function (a) { - return Control_Bind.bind(dictMonad.Bind1())(f)(function (v) { - return Control_Bind.bind(dictMonad.Bind1())(a)(function (v1) { - return Control_Applicative.pure(dictMonad.Applicative0())(v(v1)); - }); - }); - }; - }; - }; - exports["Monad"] = Monad; - exports["ap"] = ap; -})(PS["Control.Monad"] = PS["Control.Monad"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Eff"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad = PS["Control.Monad"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Unit = PS["Data.Unit"]; - var monadEff = new Control_Monad.Monad(function () { - return applicativeEff; - }, function () { - return bindEff; - }); - var bindEff = new Control_Bind.Bind(function () { - return applyEff; - }, $foreign.bindE); - var applyEff = new Control_Apply.Apply(function () { - return functorEff; - }, Control_Monad.ap(monadEff)); - var applicativeEff = new Control_Applicative.Applicative(function () { - return applyEff; - }, $foreign.pureE); - var functorEff = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEff)); - exports["functorEff"] = functorEff; - exports["applyEff"] = applyEff; - exports["applicativeEff"] = applicativeEff; - exports["bindEff"] = bindEff; - exports["monadEff"] = monadEff; - exports["foreachE"] = $foreign.foreachE; - exports["runPure"] = $foreign.runPure; -})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}); -(function(exports) { - "use strict"; - - exports.unsafeCoerceEff = function (f) { - return f; - }; -})(PS["Control.Monad.Eff.Unsafe"] = PS["Control.Monad.Eff.Unsafe"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Eff.Unsafe"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - exports["unsafeCoerceEff"] = $foreign.unsafeCoerceEff; -})(PS["Control.Monad.Eff.Unsafe"] = PS["Control.Monad.Eff.Unsafe"] || {}); -(function(exports) { - "use strict"; - - exports.newSTRef = function (val) { - return function () { - return { value: val }; - }; - }; - - exports.readSTRef = function (ref) { - return function () { - return ref.value; - }; - }; -})(PS["Control.Monad.ST"] = PS["Control.Monad.ST"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.ST"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - exports["newSTRef"] = $foreign.newSTRef; - exports["readSTRef"] = $foreign.readSTRef; -})(PS["Control.Monad.ST"] = PS["Control.Monad.ST"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Bifunctor = function (bimap) { - this.bimap = bimap; - }; - var bimap = function (dict) { - return dict.bimap; - }; - var rmap = function (dictBifunctor) { - return bimap(dictBifunctor)(Control_Category.id(Control_Category.categoryFn)); - }; - exports["Bifunctor"] = Bifunctor; - exports["bimap"] = bimap; - exports["rmap"] = rmap; -})(PS["Data.Bifunctor"] = PS["Data.Bifunctor"] || {}); -(function(exports) { - "use strict"; - - exports.topInt = 2147483647; - exports.bottomInt = -2147483648; -})(PS["Data.Bounded"] = PS["Data.Bounded"] || {}); -(function(exports) { - "use strict"; - - exports.refEq = function (r1) { - return function (r2) { - return r1 === r2; - }; - }; -})(PS["Data.Eq"] = PS["Data.Eq"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Eq"]; - var Data_Unit = PS["Data.Unit"]; - var Data_Void = PS["Data.Void"]; - var Eq = function (eq) { - this.eq = eq; - }; - var eqVoid = new Eq(function (v) { - return function (v1) { - return true; - }; - }); - var eqString = new Eq($foreign.refEq); - var eqNumber = new Eq($foreign.refEq); - var eqInt = new Eq($foreign.refEq); - var eq = function (dict) { - return dict.eq; - }; - exports["Eq"] = Eq; - exports["eq"] = eq; - exports["eqInt"] = eqInt; - exports["eqNumber"] = eqNumber; - exports["eqString"] = eqString; - exports["eqVoid"] = eqVoid; -})(PS["Data.Eq"] = PS["Data.Eq"] || {}); -(function(exports) { - "use strict"; - - exports.unsafeCompareImpl = function (lt) { - return function (eq) { - return function (gt) { - return function (x) { - return function (y) { - return x < y ? lt : x === y ? eq : gt; - }; - }; - }; - }; - }; -})(PS["Data.Ord.Unsafe"] = PS["Data.Ord.Unsafe"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Eq = PS["Data.Eq"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var LT = (function () { - function LT() { - - }; - LT.value = new LT(); - return LT; - })(); - var GT = (function () { - function GT() { - - }; - GT.value = new GT(); - return GT; - })(); - var EQ = (function () { - function EQ() { - - }; - EQ.value = new EQ(); - return EQ; - })(); - exports["LT"] = LT; - exports["GT"] = GT; - exports["EQ"] = EQ; -})(PS["Data.Ordering"] = PS["Data.Ordering"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Ord.Unsafe"]; - var Data_Ordering = PS["Data.Ordering"]; - var unsafeCompare = $foreign.unsafeCompareImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value); - exports["unsafeCompare"] = unsafeCompare; -})(PS["Data.Ord.Unsafe"] = PS["Data.Ord.Unsafe"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Ord"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Ord_Unsafe = PS["Data.Ord.Unsafe"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Unit = PS["Data.Unit"]; - var Data_Void = PS["Data.Void"]; - var Ord = function (Eq0, compare) { - this.Eq0 = Eq0; - this.compare = compare; - }; - var ordVoid = new Ord(function () { - return Data_Eq.eqVoid; - }, function (v) { - return function (v1) { - return Data_Ordering.EQ.value; - }; - }); - var ordNumber = new Ord(function () { - return Data_Eq.eqNumber; - }, Data_Ord_Unsafe.unsafeCompare); - var ordInt = new Ord(function () { - return Data_Eq.eqInt; - }, Data_Ord_Unsafe.unsafeCompare); - var compare = function (dict) { - return dict.compare; - }; - var max = function (dictOrd) { - return function (x) { - return function (y) { - var v = compare(dictOrd)(x)(y); - if (v instanceof Data_Ordering.LT) { - return y; - }; - if (v instanceof Data_Ordering.EQ) { - return x; - }; - if (v instanceof Data_Ordering.GT) { - return x; - }; - throw new Error("Failed pattern match at Data.Ord line 123, column 3 - line 126, column 12: " + [ v.constructor.name ]); - }; - }; - }; - var min = function (dictOrd) { - return function (x) { - return function (y) { - var v = compare(dictOrd)(x)(y); - if (v instanceof Data_Ordering.LT) { - return x; - }; - if (v instanceof Data_Ordering.EQ) { - return x; - }; - if (v instanceof Data_Ordering.GT) { - return y; - }; - throw new Error("Failed pattern match at Data.Ord line 114, column 3 - line 117, column 12: " + [ v.constructor.name ]); - }; - }; - }; - var clamp = function (dictOrd) { - return function (low) { - return function (hi) { - return function (x) { - return min(dictOrd)(hi)(max(dictOrd)(low)(x)); - }; - }; - }; - }; - exports["Ord"] = Ord; - exports["clamp"] = clamp; - exports["compare"] = compare; - exports["max"] = max; - exports["min"] = min; - exports["ordInt"] = ordInt; - exports["ordNumber"] = ordNumber; - exports["ordVoid"] = ordVoid; -})(PS["Data.Ord"] = PS["Data.Ord"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Bounded"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Unit = PS["Data.Unit"]; - var Bounded = function (Ord0, bottom, top) { - this.Ord0 = Ord0; - this.bottom = bottom; - this.top = top; - }; - var top = function (dict) { - return dict.top; - }; - var boundedInt = new Bounded(function () { - return Data_Ord.ordInt; - }, $foreign.bottomInt, $foreign.topInt); - var bottom = function (dict) { - return dict.bottom; - }; - exports["Bounded"] = Bounded; - exports["bottom"] = bottom; - exports["top"] = top; - exports["boundedInt"] = boundedInt; -})(PS["Data.Bounded"] = PS["Data.Bounded"] || {}); -(function(exports) { - "use strict"; - - exports.foldrArray = function (f) { - return function (init) { - return function (xs) { - var acc = init; - var len = xs.length; - for (var i = len - 1; i >= 0; i--) { - acc = f(xs[i])(acc); - } - return acc; - }; - }; - }; - - exports.foldlArray = function (f) { - return function (init) { - return function (xs) { - var acc = init; - var len = xs.length; - for (var i = 0; i < len; i++) { - acc = f(acc)(xs[i]); - } - return acc; - }; - }; - }; -})(PS["Data.Foldable"] = PS["Data.Foldable"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Data_Functor = PS["Data.Functor"]; - var Plus = function (Alt0, empty) { - this.Alt0 = Alt0; - this.empty = empty; - }; - var empty = function (dict) { - return dict.empty; - }; - exports["Plus"] = Plus; - exports["empty"] = empty; -})(PS["Control.Plus"] = PS["Control.Plus"] || {}); -(function(exports) { - "use strict"; - - exports.boolConj = function (b1) { - return function (b2) { - return b1 && b2; - }; - }; - - exports.boolDisj = function (b1) { - return function (b2) { - return b1 || b2; - }; - }; - - exports.boolNot = function (b) { - return !b; - }; -})(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.HeytingAlgebra"]; - var Data_Unit = PS["Data.Unit"]; - var HeytingAlgebra = function (conj, disj, ff, implies, not, tt) { - this.conj = conj; - this.disj = disj; - this.ff = ff; - this.implies = implies; - this.not = not; - this.tt = tt; - }; - var tt = function (dict) { - return dict.tt; - }; - var not = function (dict) { - return dict.not; - }; - var implies = function (dict) { - return dict.implies; - }; - var ff = function (dict) { - return dict.ff; - }; - var disj = function (dict) { - return dict.disj; - }; - var heytingAlgebraBoolean = new HeytingAlgebra($foreign.boolConj, $foreign.boolDisj, false, function (a) { - return function (b) { - return disj(heytingAlgebraBoolean)(not(heytingAlgebraBoolean)(a))(b); - }; - }, $foreign.boolNot, true); - var conj = function (dict) { - return dict.conj; - }; - var heytingAlgebraFunction = function (dictHeytingAlgebra) { - return new HeytingAlgebra(function (f) { - return function (g) { - return function (a) { - return conj(dictHeytingAlgebra)(f(a))(g(a)); - }; - }; - }, function (f) { - return function (g) { - return function (a) { - return disj(dictHeytingAlgebra)(f(a))(g(a)); - }; - }; - }, function (v) { - return ff(dictHeytingAlgebra); - }, function (f) { - return function (g) { - return function (a) { - return implies(dictHeytingAlgebra)(f(a))(g(a)); - }; - }; - }, function (f) { - return function (a) { - return not(dictHeytingAlgebra)(f(a)); - }; - }, function (v) { - return tt(dictHeytingAlgebra); - }); - }; - exports["HeytingAlgebra"] = HeytingAlgebra; - exports["conj"] = conj; - exports["disj"] = disj; - exports["ff"] = ff; - exports["implies"] = implies; - exports["not"] = not; - exports["tt"] = tt; - exports["heytingAlgebraBoolean"] = heytingAlgebraBoolean; - exports["heytingAlgebraFunction"] = heytingAlgebraFunction; -})(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var otherwise = true; - exports["otherwise"] = otherwise; -})(PS["Data.Boolean"] = PS["Data.Boolean"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Eq = PS["Data.Eq"]; - var Data_EuclideanRing = PS["Data.EuclideanRing"]; - var Data_Function = PS["Data.Function"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Monoid = function (Semigroup0, mempty) { - this.Semigroup0 = Semigroup0; - this.mempty = mempty; - }; - var monoidArray = new Monoid(function () { - return Data_Semigroup.semigroupArray; - }, [ ]); - var mempty = function (dict) { - return dict.mempty; - }; - var monoidFn = function (dictMonoid) { - return new Monoid(function () { - return Data_Semigroup.semigroupFn(dictMonoid.Semigroup0()); - }, Data_Function["const"](mempty(dictMonoid))); - }; - exports["Monoid"] = Monoid; - exports["mempty"] = mempty; - exports["monoidFn"] = monoidFn; - exports["monoidArray"] = monoidArray; -})(PS["Data.Monoid"] = PS["Data.Monoid"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Monad = PS["Control.Monad"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Plus = PS["Control.Plus"]; - var Data_Bounded = PS["Data.Bounded"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Nothing = (function () { - function Nothing() { - - }; - Nothing.value = new Nothing(); - return Nothing; - })(); - var Just = (function () { - function Just(value0) { - this.value0 = value0; - }; - Just.create = function (value0) { - return new Just(value0); - }; - return Just; - })(); - var maybe = function (v) { - return function (v1) { - return function (v2) { - if (v2 instanceof Nothing) { - return v; - }; - if (v2 instanceof Just) { - return v1(v2.value0); - }; - throw new Error("Failed pattern match at Data.Maybe line 219, column 1 - line 219, column 51: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); - }; - }; - }; - var isNothing = maybe(true)(Data_Function["const"](false)); - var isJust = maybe(false)(Data_Function["const"](true)); - var functorMaybe = new Data_Functor.Functor(function (v) { - return function (v1) { - if (v1 instanceof Just) { - return new Just(v(v1.value0)); - }; - return Nothing.value; - }; - }); - var fromMaybe = function (a) { - return maybe(a)(Control_Category.id(Control_Category.categoryFn)); - }; - exports["Nothing"] = Nothing; - exports["Just"] = Just; - exports["fromMaybe"] = fromMaybe; - exports["isJust"] = isJust; - exports["isNothing"] = isNothing; - exports["maybe"] = maybe; - exports["functorMaybe"] = functorMaybe; -})(PS["Data.Maybe"] = PS["Data.Maybe"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Prelude = PS["Prelude"]; - var Newtype = function (unwrap, wrap) { - this.unwrap = unwrap; - this.wrap = wrap; - }; - var wrap = function (dict) { - return dict.wrap; - }; - var unwrap = function (dict) { - return dict.unwrap; - }; - var under = function (dictNewtype) { - return function (dictNewtype1) { - return function (v) { - return function (f) { - return function ($55) { - return unwrap(dictNewtype1)(f(wrap(dictNewtype)($55))); - }; - }; - }; - }; - }; - exports["Newtype"] = Newtype; - exports["under"] = under; - exports["unwrap"] = unwrap; - exports["wrap"] = wrap; -})(PS["Data.Newtype"] = PS["Data.Newtype"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Monad = PS["Control.Monad"]; - var Data_Bounded = PS["Data.Bounded"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Prelude = PS["Prelude"]; - var First = function (x) { - return x; - }; - var semigroupFirst = new Data_Semigroup.Semigroup(function (v) { - return function (v1) { - if (v instanceof Data_Maybe.Just) { - return v; - }; - return v1; - }; - }); - var newtypeFirst = new Data_Newtype.Newtype(function (n) { - return n; - }, First); - var monoidFirst = new Data_Monoid.Monoid(function () { - return semigroupFirst; - }, Data_Maybe.Nothing.value); - exports["First"] = First; - exports["newtypeFirst"] = newtypeFirst; - exports["semigroupFirst"] = semigroupFirst; - exports["monoidFirst"] = monoidFirst; -})(PS["Data.Maybe.First"] = PS["Data.Maybe.First"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Foldable"]; - var Control_Alt = PS["Control.Alt"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Plus = PS["Control.Plus"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Maybe_First = PS["Data.Maybe.First"]; - var Data_Maybe_Last = PS["Data.Maybe.Last"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Monoid_Additive = PS["Data.Monoid.Additive"]; - var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; - var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; - var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; - var Data_Monoid_Endo = PS["Data.Monoid.Endo"]; - var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Foldable = function (foldMap, foldl, foldr) { - this.foldMap = foldMap; - this.foldl = foldl; - this.foldr = foldr; - }; - var foldr = function (dict) { - return dict.foldr; - }; - var traverse_ = function (dictApplicative) { - return function (dictFoldable) { - return function (f) { - return foldr(dictFoldable)(function ($181) { - return Control_Apply.applySecond(dictApplicative.Apply0())(f($181)); - })(Control_Applicative.pure(dictApplicative)(Data_Unit.unit)); - }; - }; - }; - var for_ = function (dictApplicative) { - return function (dictFoldable) { - return Data_Function.flip(traverse_(dictApplicative)(dictFoldable)); - }; - }; - var sequence_ = function (dictApplicative) { - return function (dictFoldable) { - return traverse_(dictApplicative)(dictFoldable)(Control_Category.id(Control_Category.categoryFn)); - }; - }; - var foldl = function (dict) { - return dict.foldl; - }; - var foldableMaybe = new Foldable(function (dictMonoid) { - return function (f) { - return function (v) { - if (v instanceof Data_Maybe.Nothing) { - return Data_Monoid.mempty(dictMonoid); - }; - if (v instanceof Data_Maybe.Just) { - return f(v.value0); - }; - throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ f.constructor.name, v.constructor.name ]); - }; - }; - }, function (v) { - return function (z) { - return function (v1) { - if (v1 instanceof Data_Maybe.Nothing) { - return z; - }; - if (v1 instanceof Data_Maybe.Just) { - return v(z)(v1.value0); - }; - throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); - }; - }; - }, function (v) { - return function (z) { - return function (v1) { - if (v1 instanceof Data_Maybe.Nothing) { - return z; - }; - if (v1 instanceof Data_Maybe.Just) { - return v(v1.value0)(z); - }; - throw new Error("Failed pattern match at Data.Foldable line 128, column 1 - line 128, column 41: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); - }; - }; - }); - var foldMapDefaultR = function (dictFoldable) { - return function (dictMonoid) { - return function (f) { - return foldr(dictFoldable)(function (x) { - return function (acc) { - return Data_Semigroup.append(dictMonoid.Semigroup0())(f(x))(acc); - }; - })(Data_Monoid.mempty(dictMonoid)); - }; - }; - }; - var foldableArray = new Foldable(function (dictMonoid) { - return foldMapDefaultR(foldableArray)(dictMonoid); - }, $foreign.foldlArray, $foreign.foldrArray); - var foldMap = function (dict) { - return dict.foldMap; - }; - exports["Foldable"] = Foldable; - exports["foldMap"] = foldMap; - exports["foldMapDefaultR"] = foldMapDefaultR; - exports["foldl"] = foldl; - exports["foldr"] = foldr; - exports["for_"] = for_; - exports["sequence_"] = sequence_; - exports["traverse_"] = traverse_; - exports["foldableArray"] = foldableArray; - exports["foldableMaybe"] = foldableMaybe; -})(PS["Data.Foldable"] = PS["Data.Foldable"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Monad = PS["Control.Monad"]; - var Data_Bifoldable = PS["Data.Bifoldable"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Bitraversable = PS["Data.Bitraversable"]; - var Data_Bounded = PS["Data.Bounded"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Prelude = PS["Prelude"]; - var Left = (function () { - function Left(value0) { - this.value0 = value0; - }; - Left.create = function (value0) { - return new Left(value0); - }; - return Left; - })(); - var Right = (function () { - function Right(value0) { - this.value0 = value0; - }; - Right.create = function (value0) { - return new Right(value0); - }; - return Right; - })(); - var functorEither = new Data_Functor.Functor(function (v) { - return function (v1) { - if (v1 instanceof Left) { - return new Left(v1.value0); - }; - if (v1 instanceof Right) { - return new Right(v(v1.value0)); - }; - throw new Error("Failed pattern match at Data.Either line 36, column 1 - line 36, column 45: " + [ v.constructor.name, v1.constructor.name ]); - }; - }); - var foldableEither = new Data_Foldable.Foldable(function (dictMonoid) { - return function (f) { - return function (v) { - if (v instanceof Left) { - return Data_Monoid.mempty(dictMonoid); - }; - if (v instanceof Right) { - return f(v.value0); - }; - throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ f.constructor.name, v.constructor.name ]); - }; - }; - }, function (v) { - return function (z) { - return function (v1) { - if (v1 instanceof Left) { - return z; - }; - if (v1 instanceof Right) { - return v(z)(v1.value0); - }; - throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); - }; - }; - }, function (v) { - return function (z) { - return function (v1) { - if (v1 instanceof Left) { - return z; - }; - if (v1 instanceof Right) { - return v(v1.value0)(z); - }; - throw new Error("Failed pattern match at Data.Either line 184, column 1 - line 184, column 47: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]); - }; - }; - }); - var eqEither = function (dictEq) { - return function (dictEq1) { - return new Data_Eq.Eq(function (x) { - return function (y) { - if (x instanceof Left && y instanceof Left) { - return Data_Eq.eq(dictEq)(x.value0)(y.value0); - }; - if (x instanceof Right && y instanceof Right) { - return Data_Eq.eq(dictEq1)(x.value0)(y.value0); - }; - return false; - }; - }); - }; - }; - var ordEither = function (dictOrd) { - return function (dictOrd1) { - return new Data_Ord.Ord(function () { - return eqEither(dictOrd.Eq0())(dictOrd1.Eq0()); - }, function (x) { - return function (y) { - if (x instanceof Left && y instanceof Left) { - return Data_Ord.compare(dictOrd)(x.value0)(y.value0); - }; - if (x instanceof Left) { - return Data_Ordering.LT.value; - }; - if (y instanceof Left) { - return Data_Ordering.GT.value; - }; - if (x instanceof Right && y instanceof Right) { - return Data_Ord.compare(dictOrd1)(x.value0)(y.value0); - }; - throw new Error("Failed pattern match at Data.Either line 176, column 8 - line 176, column 64: " + [ x.constructor.name, y.constructor.name ]); - }; - }); - }; - }; - var either = function (v) { - return function (v1) { - return function (v2) { - if (v2 instanceof Left) { - return v(v2.value0); - }; - if (v2 instanceof Right) { - return v1(v2.value0); - }; - throw new Error("Failed pattern match at Data.Either line 229, column 1 - line 229, column 64: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); - }; - }; - }; - var bifunctorEither = new Data_Bifunctor.Bifunctor(function (v) { - return function (v1) { - return function (v2) { - if (v2 instanceof Left) { - return new Left(v(v2.value0)); - }; - if (v2 instanceof Right) { - return new Right(v1(v2.value0)); - }; - throw new Error("Failed pattern match at Data.Either line 43, column 1 - line 43, column 45: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]); - }; - }; - }); - var applyEither = new Control_Apply.Apply(function () { - return functorEither; - }, function (v) { - return function (v1) { - if (v instanceof Left) { - return new Left(v.value0); - }; - if (v instanceof Right) { - return Data_Functor.map(functorEither)(v.value0)(v1); - }; - throw new Error("Failed pattern match at Data.Either line 79, column 1 - line 79, column 41: " + [ v.constructor.name, v1.constructor.name ]); - }; - }); - exports["Left"] = Left; - exports["Right"] = Right; - exports["either"] = either; - exports["functorEither"] = functorEither; - exports["bifunctorEither"] = bifunctorEither; - exports["applyEither"] = applyEither; - exports["eqEither"] = eqEither; - exports["ordEither"] = ordEither; - exports["foldableEither"] = foldableEither; -})(PS["Data.Either"] = PS["Data.Either"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Comonad = PS["Control.Comonad"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Lazy = PS["Control.Lazy"]; - var Control_Monad = PS["Control.Monad"]; - var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; - var Data_Bounded = PS["Data.Bounded"]; - var Data_CommutativeRing = PS["Data.CommutativeRing"]; - var Data_Eq = PS["Data.Eq"]; - var Data_EuclideanRing = PS["Data.EuclideanRing"]; - var Data_Field = PS["Data.Field"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Prelude = PS["Prelude"]; - var Identity = function (x) { - return x; - }; - var newtypeIdentity = new Data_Newtype.Newtype(function (n) { - return n; - }, Identity); - var functorIdentity = new Data_Functor.Functor(function (f) { - return function (v) { - return f(v); - }; - }); - var applyIdentity = new Control_Apply.Apply(function () { - return functorIdentity; - }, function (v) { - return function (v1) { - return v(v1); - }; - }); - var bindIdentity = new Control_Bind.Bind(function () { - return applyIdentity; - }, function (v) { - return function (f) { - return f(v); - }; - }); - var applicativeIdentity = new Control_Applicative.Applicative(function () { - return applyIdentity; - }, Identity); - var monadIdentity = new Control_Monad.Monad(function () { - return applicativeIdentity; - }, function () { - return bindIdentity; - }); - exports["Identity"] = Identity; - exports["newtypeIdentity"] = newtypeIdentity; - exports["functorIdentity"] = functorIdentity; - exports["applyIdentity"] = applyIdentity; - exports["applicativeIdentity"] = applicativeIdentity; - exports["bindIdentity"] = bindIdentity; - exports["monadIdentity"] = monadIdentity; -})(PS["Data.Identity"] = PS["Data.Identity"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; - var Control_Monad_ST = PS["Control.Monad.ST"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Either = PS["Data.Either"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Unit = PS["Data.Unit"]; - var Partial_Unsafe = PS["Partial.Unsafe"]; - var Prelude = PS["Prelude"]; - var Loop = (function () { - function Loop(value0) { - this.value0 = value0; - }; - Loop.create = function (value0) { - return new Loop(value0); - }; - return Loop; - })(); - var Done = (function () { - function Done(value0) { - this.value0 = value0; - }; - Done.create = function (value0) { - return new Done(value0); - }; - return Done; - })(); - var MonadRec = function (Monad0, tailRecM) { - this.Monad0 = Monad0; - this.tailRecM = tailRecM; - }; - var tailRecM = function (dict) { - return dict.tailRecM; - }; - var tailRecEff = function (f) { - return function (a) { - var fromDone = function (v) { - var __unused = function (dictPartial1) { - return function ($dollar16) { - return $dollar16; - }; - }; - return __unused()((function () { - if (v instanceof Done) { - return v.value0; - }; - throw new Error("Failed pattern match at Control.Monad.Rec.Class line 141, column 28 - line 141, column 42: " + [ v.constructor.name ]); - })()); - }; - var f$prime = function ($52) { - return Control_Monad_Eff_Unsafe.unsafeCoerceEff(f($52)); - }; - return function __do() { - var v = Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Control_Monad_ST.newSTRef)(f$prime(a))(); - (function () { - while (!(function __do() { - var v1 = v.value; - if (v1 instanceof Loop) { - var v2 = f$prime(v1.value0)(); - var v3 = v.value = v2; - return false; - }; - if (v1 instanceof Done) { - return true; - }; - throw new Error("Failed pattern match at Control.Monad.Rec.Class line 130, column 5 - line 135, column 26: " + [ v1.constructor.name ]); - })()) { - - }; - return {}; - })(); - return Data_Functor.map(Control_Monad_Eff.functorEff)(fromDone)(Control_Monad_ST.readSTRef(v))(); - }; - }; - }; - var monadRecEff = new MonadRec(function () { - return Control_Monad_Eff.monadEff; - }, tailRecEff); - exports["Loop"] = Loop; - exports["Done"] = Done; - exports["MonadRec"] = MonadRec; - exports["tailRecM"] = tailRecM; - exports["monadRecEff"] = monadRecEff; -})(PS["Control.Monad.Rec.Class"] = PS["Control.Monad.Rec.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Control_Plus = PS["Control.Plus"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Prelude = PS["Prelude"]; - var NonEmpty = (function () { - function NonEmpty(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - NonEmpty.create = function (value0) { - return function (value1) { - return new NonEmpty(value0, value1); - }; - }; - return NonEmpty; - })(); - var singleton = function (dictPlus) { - return function (a) { - return new NonEmpty(a, Control_Plus.empty(dictPlus)); - }; - }; - var functorNonEmpty = function (dictFunctor) { - return new Data_Functor.Functor(function (f) { - return function (v) { - return new NonEmpty(f(v.value0), Data_Functor.map(dictFunctor)(f)(v.value1)); - }; - }); - }; - exports["NonEmpty"] = NonEmpty; - exports["singleton"] = singleton; - exports["functorNonEmpty"] = functorNonEmpty; -})(PS["Data.NonEmpty"] = PS["Data.NonEmpty"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Biapplicative = PS["Control.Biapplicative"]; - var Control_Biapply = PS["Control.Biapply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Comonad = PS["Control.Comonad"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Lazy = PS["Control.Lazy"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifoldable = PS["Data.Bifoldable"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Bitraversable = PS["Data.Bitraversable"]; - var Data_BooleanAlgebra = PS["Data.BooleanAlgebra"]; - var Data_Bounded = PS["Data.Bounded"]; - var Data_CommutativeRing = PS["Data.CommutativeRing"]; - var Data_Distributive = PS["Data.Distributive"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Functor_Invariant = PS["Data.Functor.Invariant"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Maybe_First = PS["Data.Maybe.First"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Type_Equality = PS["Type.Equality"]; - var Tuple = (function () { - function Tuple(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Tuple.create = function (value0) { - return function (value1) { - return new Tuple(value0, value1); - }; - }; - return Tuple; - })(); - var snd = function (v) { - return v.value1; - }; - var lookup = function (dictFoldable) { - return function (dictEq) { - return function (a) { - return function ($264) { - return Data_Newtype.unwrap(Data_Maybe_First.newtypeFirst)(Data_Foldable.foldMap(dictFoldable)(Data_Maybe_First.monoidFirst)(function (v) { - var $146 = Data_Eq.eq(dictEq)(a)(v.value0); - if ($146) { - return new Data_Maybe.Just(v.value1); - }; - return Data_Maybe.Nothing.value; - })($264)); - }; - }; - }; - }; - var functorTuple = new Data_Functor.Functor(function (f) { - return function (v) { - return new Tuple(v.value0, f(v.value1)); - }; - }); - var fst = function (v) { - return v.value0; - }; - exports["Tuple"] = Tuple; - exports["fst"] = fst; - exports["lookup"] = lookup; - exports["snd"] = snd; - exports["functorTuple"] = functorTuple; -})(PS["Data.Tuple"] = PS["Data.Tuple"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Array"]; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Lazy = PS["Control.Lazy"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_ST = PS["Control.Monad.ST"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Array_ST = PS["Data.Array.ST"]; - var Data_Array_ST_Iterator = PS["Data.Array.ST.Iterator"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var Partial_Unsafe = PS["Partial.Unsafe"]; - var Prelude = PS["Prelude"]; - var singleton = function (a) { - return [ a ]; - }; - var fromFoldable = function (dictFoldable) { - return $foreign.fromFoldableImpl(Data_Foldable.foldr(dictFoldable)); - }; - var concatMap = Data_Function.flip(Control_Bind.bind(Control_Bind.bindArray)); - var mapMaybe = function (f) { - return concatMap(function ($94) { - return Data_Maybe.maybe([ ])(singleton)(f($94)); - }); - }; - exports["concatMap"] = concatMap; - exports["fromFoldable"] = fromFoldable; - exports["mapMaybe"] = mapMaybe; - exports["singleton"] = singleton; - exports["length"] = $foreign.length; -})(PS["Data.Array"] = PS["Data.Array"] || {}); -(function(exports) { - "use strict"; - - // module Data.Int - - exports.fromNumberImpl = function (just) { - return function (nothing) { - return function (n) { - /* jshint bitwise: false */ - return (n | 0) === n ? just(n) : nothing; - }; - }; - }; - - exports.toNumber = function (n) { - return n; - }; -})(PS["Data.Int"] = PS["Data.Int"] || {}); -(function(exports) { - /* globals exports */ - "use strict"; - - exports.infinity = Infinity; -})(PS["Global"] = PS["Global"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Global"]; - exports["infinity"] = $foreign.infinity; -})(PS["Global"] = PS["Global"] || {}); -(function(exports) { - "use strict"; - - // module Math - - exports.abs = Math.abs; - - exports.remainder = function (n) { - return function (m) { - return n % m; - }; - }; - - exports.round = Math.round; -})(PS["Math"] = PS["Math"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Math"]; - exports["abs"] = $foreign.abs; - exports["remainder"] = $foreign.remainder; - exports["round"] = $foreign.round; -})(PS["Math"] = PS["Math"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Int"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Bounded = PS["Data.Bounded"]; - var Data_Eq = PS["Data.Eq"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Int_Bits = PS["Data.Int.Bits"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Show = PS["Data.Show"]; - var Global = PS["Global"]; - var $$Math = PS["Math"]; - var Prelude = PS["Prelude"]; - var fromNumber = $foreign.fromNumberImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value); - var unsafeClamp = function (x) { - if (x === Global.infinity) { - return 0; - }; - if (x === -Global.infinity) { - return 0; - }; - if (x >= $foreign.toNumber(Data_Bounded.top(Data_Bounded.boundedInt))) { - return Data_Bounded.top(Data_Bounded.boundedInt); - }; - if (x <= $foreign.toNumber(Data_Bounded.bottom(Data_Bounded.boundedInt))) { - return Data_Bounded.bottom(Data_Bounded.boundedInt); - }; - if (Data_Boolean.otherwise) { - return Data_Maybe.fromMaybe(0)(fromNumber(x)); - }; - throw new Error("Failed pattern match at Data.Int line 64, column 1 - line 64, column 29: " + [ x.constructor.name ]); - }; - var round = function ($13) { - return unsafeClamp($$Math.round($13)); - }; - exports["fromNumber"] = fromNumber; - exports["round"] = round; - exports["toNumber"] = $foreign.toNumber; -})(PS["Data.Int"] = PS["Data.Int"] || {}); -(function(exports) { - "use strict"; - - exports.joinWith = function (s) { - return function (xs) { - return xs.join(s); - }; - }; -})(PS["Data.String"] = PS["Data.String"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.String"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_String_Unsafe = PS["Data.String.Unsafe"]; - var Prelude = PS["Prelude"]; - exports["joinWith"] = $foreign.joinWith; -})(PS["Data.String"] = PS["Data.String"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Array = PS["Data.Array"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_EuclideanRing = PS["Data.EuclideanRing"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Int = PS["Data.Int"]; - var Data_Int_Bits = PS["Data.Int.Bits"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_String = PS["Data.String"]; - var Data_String_Regex = PS["Data.String.Regex"]; - var $$Math = PS["Math"]; - var Partial_Unsafe = PS["Partial.Unsafe"]; - var Prelude = PS["Prelude"]; - var HSLA = (function () { - function HSLA(value0, value1, value2, value3) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - }; - HSLA.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return new HSLA(value0, value1, value2, value3); - }; - }; - }; - }; - return HSLA; - })(); - var toRGBA$prime = function (v) { - var h$prime = v.value0 / 60.0; - var chr = (1.0 - $$Math.abs(2.0 * v.value2 - 1.0)) * v.value1; - var m = v.value2 - chr / 2.0; - var x = chr * (1.0 - $$Math.abs($$Math.remainder(h$prime)(2.0) - 1.0)); - var col = (function () { - if (h$prime < 1.0) { - return { - r: chr, - g: x, - b: 0.0 - }; - }; - if (1.0 <= h$prime && h$prime < 2.0) { - return { - r: x, - g: chr, - b: 0.0 - }; - }; - if (2.0 <= h$prime && h$prime < 3.0) { - return { - r: 0.0, - g: chr, - b: x - }; - }; - if (3.0 <= h$prime && h$prime < 4.0) { - return { - r: 0.0, - g: x, - b: chr - }; - }; - if (4.0 <= h$prime && h$prime < 5.0) { - return { - r: x, - g: 0.0, - b: chr - }; - }; - if (Data_Boolean.otherwise) { - return { - r: chr, - g: 0.0, - b: x - }; - }; - throw new Error("Failed pattern match at Color line 301, column 5 - line 306, column 61: " + [ ]); - })(); - return { - r: col.r + m, - g: col.g + m, - b: col.b + m, - a: v.value3 - }; - }; - var toHSLA = function (v) { - return { - h: v.value0, - s: v.value1, - l: v.value2, - a: v.value3 - }; - }; - var modPos = function (x) { - return function (y) { - return $$Math.remainder($$Math.remainder(x)(y) + y)(y); - }; - }; - var hsla = function (h) { - return function (s) { - return function (l) { - return function (a) { - var s$prime = Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(s); - var l$prime = Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(l); - var h$prime = modPos(h)(360.0); - var a$prime = Data_Ord.clamp(Data_Ord.ordNumber)(0.0)(1.0)(a); - return new HSLA(h$prime, s$prime, l$prime, a$prime); - }; - }; - }; - }; - var hsl = function (h) { - return function (s) { - return function (l) { - return hsla(h)(s)(l)(1.0); - }; - }; - }; - var white = hsl(0.0)(0.0)(1.0); - var cssStringHSLA = function (v) { - var toString = function (n) { - return Data_Show.show(Data_Show.showNumber)(Data_Int.toNumber(Data_Int.round(100.0 * n)) / 100.0); - }; - var saturation = toString(v.value1 * 100.0) + "%"; - var lightness = toString(v.value2 * 100.0) + "%"; - var hue = toString(v.value0); - var alpha = Data_Show.show(Data_Show.showNumber)(v.value3); - var $72 = v.value3 === 1.0; - if ($72) { - return "hsl(" + (hue + (", " + (saturation + (", " + (lightness + ")"))))); - }; - return "hsla(" + (hue + (", " + (saturation + (", " + (lightness + (", " + (alpha + ")"))))))); - }; - var brightness = function (col) { - var c = toRGBA$prime(col); - return (299.0 * c.r + 587.0 * c.g + 114.0 * c.b) / 1000.0; - }; - var isLight = function (c) { - return brightness(c) > 0.5; - }; - var black = hsl(0.0)(0.0)(0.0); - exports["black"] = black; - exports["brightness"] = brightness; - exports["cssStringHSLA"] = cssStringHSLA; - exports["hsl"] = hsl; - exports["hsla"] = hsla; - exports["isLight"] = isLight; - exports["toHSLA"] = toHSLA; - exports["white"] = white; -})(PS["Color"] = PS["Color"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Prelude = PS["Prelude"]; - var Profunctor = function (dimap) { - this.dimap = dimap; - }; - var profunctorFn = new Profunctor(function (a2b) { - return function (c2d) { - return function (b2c) { - return function ($9) { - return c2d(b2c(a2b($9))); - }; - }; - }; - }); - var dimap = function (dict) { - return dict.dimap; - }; - var rmap = function (dictProfunctor) { - return function (b2c) { - return dimap(dictProfunctor)(Control_Category.id(Control_Category.categoryFn))(b2c); - }; - }; - exports["Profunctor"] = Profunctor; - exports["dimap"] = dimap; - exports["rmap"] = rmap; - exports["profunctorFn"] = profunctorFn; -})(PS["Data.Profunctor"] = PS["Data.Profunctor"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Data_Tuple = PS["Data.Tuple"]; - var Prelude = PS["Prelude"]; - var Strong = function (Profunctor0, first, second) { - this.Profunctor0 = Profunctor0; - this.first = first; - this.second = second; - }; - var strongFn = new Strong(function () { - return Data_Profunctor.profunctorFn; - }, function (a2b) { - return function (v) { - return new Data_Tuple.Tuple(a2b(v.value0), v.value1); - }; - }, Data_Functor.map(Data_Tuple.functorTuple)); - var second = function (dict) { - return dict.second; - }; - var first = function (dict) { - return dict.first; - }; - exports["Strong"] = Strong; - exports["first"] = first; - exports["second"] = second; - exports["strongFn"] = strongFn; -})(PS["Data.Profunctor.Strong"] = PS["Data.Profunctor.Strong"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_String = PS["CSS.String"]; - var Color = PS["Color"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Generic = PS["Data.Generic"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Profunctor_Strong = PS["Data.Profunctor.Strong"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Prefixed = (function () { - function Prefixed(value0) { - this.value0 = value0; - }; - Prefixed.create = function (value0) { - return new Prefixed(value0); - }; - return Prefixed; - })(); - var Plain = (function () { - function Plain(value0) { - this.value0 = value0; - }; - Plain.create = function (value0) { - return new Plain(value0); - }; - return Plain; - })(); - var Value = function (x) { - return x; - }; - var Key = function (x) { - return x; - }; - var Val = function (value) { - this.value = value; - }; - var value = function (dict) { - return dict.value; - }; - var semigroupPrefixed = new Data_Semigroup.Semigroup(function (v) { - return function (v1) { - if (v instanceof Plain && v1 instanceof Plain) { - return Plain.create(v.value0 + v1.value0); - }; - if (v instanceof Plain && v1 instanceof Prefixed) { - return Prefixed.create(Data_Functor.map(Data_Functor.functorArray)(Data_Profunctor_Strong.second(Data_Profunctor_Strong.strongFn)(function (v2) { - return v.value0 + v2; - }))(v1.value0)); - }; - if (v instanceof Prefixed && v1 instanceof Plain) { - return Prefixed.create(Data_Functor.map(Data_Functor.functorArray)(Data_Profunctor_Strong.second(Data_Profunctor_Strong.strongFn)(function (v2) { - return v1.value0 + v2; - }))(v.value0)); - }; - if (v instanceof Prefixed && v1 instanceof Prefixed) { - return Prefixed.create(Data_Semigroup.append(Data_Semigroup.semigroupArray)(v.value0)(v1.value0)); - }; - throw new Error("Failed pattern match at CSS.Property line 25, column 1 - line 25, column 49: " + [ v.constructor.name, v1.constructor.name ]); - }; - }); - var semigroupValue = new Data_Semigroup.Semigroup(function (v) { - return function (v1) { - return Value(Data_Semigroup.append(semigroupPrefixed)(v)(v1)); - }; - }); - var isStringPrefixed = new CSS_String.IsString(Plain.create); - var isStringValue = new CSS_String.IsString(function ($145) { - return Value(CSS_String.fromString(isStringPrefixed)($145)); - }); - var valColor = new Val(function ($147) { - return CSS_String.fromString(isStringValue)(Color.cssStringHSLA($147)); - }); - var valNumber = new Val(function ($150) { - return CSS_String.fromString(isStringValue)(Data_Show.show(Data_Show.showNumber)($150)); - }); - var isStringKey = new CSS_String.IsString(function ($151) { - return Key(CSS_String.fromString(isStringPrefixed)($151)); - }); - var cast = function (v) { - return v; - }; - exports["Key"] = Key; - exports["Prefixed"] = Prefixed; - exports["Plain"] = Plain; - exports["Value"] = Value; - exports["Val"] = Val; - exports["cast"] = cast; - exports["value"] = value; - exports["isStringPrefixed"] = isStringPrefixed; - exports["semigroupPrefixed"] = semigroupPrefixed; - exports["isStringKey"] = isStringKey; - exports["isStringValue"] = isStringValue; - exports["semigroupValue"] = semigroupValue; - exports["valNumber"] = valNumber; - exports["valColor"] = valColor; -})(PS["CSS.Property"] = PS["CSS.Property"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Common = PS["CSS.Common"]; - var CSS_Property = PS["CSS.Property"]; - var CSS_String = PS["CSS.String"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Generic = PS["Data.Generic"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var valSize = new CSS_Property.Val(function (v) { - return v; - }); - var pct = function (i) { - return Data_Semigroup.append(CSS_Property.semigroupValue)(CSS_Property.value(CSS_Property.valNumber)(i))(CSS_String.fromString(CSS_Property.isStringValue)("%")); - }; - exports["pct"] = pct; - exports["valSize"] = valSize; -})(PS["CSS.Size"] = PS["CSS.Size"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Data_Function = PS["Data.Function"]; - var Data_Tuple = PS["Data.Tuple"]; - var Prelude = PS["Prelude"]; - var MonadTell = function (Monad0, tell) { - this.Monad0 = Monad0; - this.tell = tell; - }; - var tell = function (dict) { - return dict.tell; - }; - exports["MonadTell"] = MonadTell; - exports["tell"] = tell; -})(PS["Control.Monad.Writer.Class"] = PS["Control.Monad.Writer.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var MonadEff = function (Monad0, liftEff) { - this.Monad0 = Monad0; - this.liftEff = liftEff; - }; - var monadEffEff = new MonadEff(function () { - return Control_Monad_Eff.monadEff; - }, Control_Category.id(Control_Category.categoryFn)); - var liftEff = function (dict) { - return dict.liftEff; - }; - exports["MonadEff"] = MonadEff; - exports["liftEff"] = liftEff; - exports["monadEffEff"] = monadEffEff; -})(PS["Control.Monad.Eff.Class"] = PS["Control.Monad.Eff.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var MonadThrow = function (Monad0, throwError) { - this.Monad0 = Monad0; - this.throwError = throwError; - }; - var throwError = function (dict) { - return dict.throwError; - }; - exports["MonadThrow"] = MonadThrow; - exports["throwError"] = throwError; -})(PS["Control.Monad.Error.Class"] = PS["Control.Monad.Error.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var MonadState = function (Monad0, state) { - this.Monad0 = Monad0; - this.state = state; - }; - var state = function (dict) { - return dict.state; - }; - var modify = function (dictMonadState) { - return function (f) { - return state(dictMonadState)(function (s) { - return new Data_Tuple.Tuple(Data_Unit.unit, f(s)); - }); - }; - }; - var get = function (dictMonadState) { - return state(dictMonadState)(function (s) { - return new Data_Tuple.Tuple(s, s); - }); - }; - exports["MonadState"] = MonadState; - exports["get"] = get; - exports["modify"] = modify; - exports["state"] = state; -})(PS["Control.Monad.State.Class"] = PS["Control.Monad.State.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Prelude = PS["Prelude"]; - var MonadTrans = function (lift) { - this.lift = lift; - }; - var lift = function (dict) { - return dict.lift; - }; - exports["MonadTrans"] = MonadTrans; - exports["lift"] = lift; -})(PS["Control.Monad.Trans.Class"] = PS["Control.Monad.Trans.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; - var Control_MonadPlus = PS["Control.MonadPlus"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Plus = PS["Control.Plus"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var WriterT = function (x) { - return x; - }; - var runWriterT = function (v) { - return v; - }; - var mapWriterT = function (f) { - return function (v) { - return f(v); - }; - }; - var functorWriterT = function (dictFunctor) { - return new Data_Functor.Functor(function (f) { - return mapWriterT(Data_Functor.map(dictFunctor)(function (v) { - return new Data_Tuple.Tuple(f(v.value0), v.value1); - })); - }); - }; - var applyWriterT = function (dictSemigroup) { - return function (dictApply) { - return new Control_Apply.Apply(function () { - return functorWriterT(dictApply.Functor0()); - }, function (v) { - return function (v1) { - var k = function (v3) { - return function (v4) { - return new Data_Tuple.Tuple(v3.value0(v4.value0), Data_Semigroup.append(dictSemigroup)(v3.value1)(v4.value1)); - }; - }; - return Control_Apply.apply(dictApply)(Data_Functor.map(dictApply.Functor0())(k)(v))(v1); - }; - }); - }; - }; - var bindWriterT = function (dictSemigroup) { - return function (dictBind) { - return new Control_Bind.Bind(function () { - return applyWriterT(dictSemigroup)(dictBind.Apply0()); - }, function (v) { - return function (k) { - return WriterT(Control_Bind.bind(dictBind)(v)(function (v1) { - var v2 = k(v1.value0); - return Data_Functor.map((dictBind.Apply0()).Functor0())(function (v3) { - return new Data_Tuple.Tuple(v3.value0, Data_Semigroup.append(dictSemigroup)(v1.value1)(v3.value1)); - })(v2); - })); - }; - }); - }; - }; - var applicativeWriterT = function (dictMonoid) { - return function (dictApplicative) { - return new Control_Applicative.Applicative(function () { - return applyWriterT(dictMonoid.Semigroup0())(dictApplicative.Apply0()); - }, function (a) { - return WriterT(Control_Applicative.pure(dictApplicative)(new Data_Tuple.Tuple(a, Data_Monoid.mempty(dictMonoid)))); - }); - }; - }; - var monadWriterT = function (dictMonoid) { - return function (dictMonad) { - return new Control_Monad.Monad(function () { - return applicativeWriterT(dictMonoid)(dictMonad.Applicative0()); - }, function () { - return bindWriterT(dictMonoid.Semigroup0())(dictMonad.Bind1()); - }); - }; - }; - var monadTellWriterT = function (dictMonoid) { - return function (dictMonad) { - return new Control_Monad_Writer_Class.MonadTell(function () { - return monadWriterT(dictMonoid)(dictMonad); - }, function ($124) { - return WriterT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Tuple.Tuple.create(Data_Unit.unit)($124))); - }); - }; - }; - exports["WriterT"] = WriterT; - exports["mapWriterT"] = mapWriterT; - exports["runWriterT"] = runWriterT; - exports["functorWriterT"] = functorWriterT; - exports["applyWriterT"] = applyWriterT; - exports["applicativeWriterT"] = applicativeWriterT; - exports["bindWriterT"] = bindWriterT; - exports["monadWriterT"] = monadWriterT; - exports["monadTellWriterT"] = monadTellWriterT; -})(PS["Control.Monad.Writer.Trans"] = PS["Control.Monad.Writer.Trans"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; - var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Tuple = PS["Data.Tuple"]; - var Prelude = PS["Prelude"]; - var runWriter = function ($1) { - return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(Control_Monad_Writer_Trans.runWriterT($1)); - }; - var execWriter = function (m) { - return Data_Tuple.snd(runWriter(m)); - }; - exports["execWriter"] = execWriter; - exports["runWriter"] = runWriter; -})(PS["Control.Monad.Writer"] = PS["Control.Monad.Writer"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Property = PS["CSS.Property"]; - var CSS_Selector = PS["CSS.Selector"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Writer = PS["Control.Monad.Writer"]; - var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; - var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Array = PS["Data.Array"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Generic = PS["Data.Generic"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Profunctor_Strong = PS["Data.Profunctor.Strong"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Property = (function () { - function Property(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Property.create = function (value0) { - return function (value1) { - return new Property(value0, value1); - }; - }; - return Property; - })(); - var S = function (x) { - return x; - }; - var runS = function (v) { - return Control_Monad_Writer.execWriter(v); - }; - var rule = function ($438) { - return S(Control_Monad_Writer_Class.tell(Control_Monad_Writer_Trans.monadTellWriterT(Data_Monoid.monoidArray)(Data_Identity.monadIdentity))(Data_Array.singleton($438))); - }; - var key = function (dictVal) { - return function (k) { - return function (v) { - return rule(new Property(CSS_Property.cast(k), CSS_Property.value(dictVal)(v))); - }; - }; - }; - var functorStyleM = new Data_Functor.Functor(function (f) { - return function (v) { - return S(Data_Functor.map(Control_Monad_Writer_Trans.functorWriterT(Data_Identity.functorIdentity))(f)(v)); - }; - }); - var applyStyleM = new Control_Apply.Apply(function () { - return functorStyleM; - }, function (v) { - return function (v1) { - return S(Control_Apply.apply(Control_Monad_Writer_Trans.applyWriterT(Data_Semigroup.semigroupArray)(Data_Identity.applyIdentity))(v)(v1)); - }; - }); - var bindStyleM = new Control_Bind.Bind(function () { - return applyStyleM; - }, function (v) { - return function (f) { - return S(Control_Bind.bind(Control_Monad_Writer_Trans.bindWriterT(Data_Semigroup.semigroupArray)(Data_Identity.bindIdentity))(v)(function ($442) { - return (function (v1) { - return v1; - })(f($442)); - })); - }; - }); - exports["Property"] = Property; - exports["S"] = S; - exports["key"] = key; - exports["rule"] = rule; - exports["runS"] = runS; - exports["functorStyleM"] = functorStyleM; - exports["applyStyleM"] = applyStyleM; - exports["bindStyleM"] = bindStyleM; -})(PS["CSS.Stylesheet"] = PS["CSS.Stylesheet"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Box = PS["CSS.Box"]; - var CSS_Color = PS["CSS.Color"]; - var CSS_Common = PS["CSS.Common"]; - var CSS_Property = PS["CSS.Property"]; - var CSS_Size = PS["CSS.Size"]; - var CSS_String = PS["CSS.String"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Generic = PS["Data.Generic"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var backgroundColor = CSS_Stylesheet.key(CSS_Property.valColor)(CSS_String.fromString(CSS_Property.isStringKey)("background-color")); - exports["backgroundColor"] = backgroundColor; -})(PS["CSS.Background"] = PS["CSS.Background"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Color = PS["CSS.Color"]; - var CSS_Property = PS["CSS.Property"]; - var CSS_Size = PS["CSS.Size"]; - var CSS_String = PS["CSS.String"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Control_Apply = PS["Control.Apply"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Generic = PS["Data.Generic"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Tuple_Nested = PS["Data.Tuple.Nested"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var borderColor = CSS_Stylesheet.key(CSS_Property.valColor)(CSS_String.fromString(CSS_Property.isStringKey)("border-color")); - exports["borderColor"] = borderColor; -})(PS["CSS.Border"] = PS["CSS.Border"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Common = PS["CSS.Common"]; - var CSS_Property = PS["CSS.Property"]; - var CSS_String = PS["CSS.String"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Control_Apply = PS["Control.Apply"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Generic = PS["Data.Generic"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Show = PS["Data.Show"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Display = function (x) { - return x; - }; - var valDisplay = new CSS_Property.Val(function (v) { - return v; - }); - var displayNone = Display(CSS_String.fromString(CSS_Property.isStringValue)("none")); - var display = CSS_Stylesheet.key(valDisplay)(CSS_String.fromString(CSS_Property.isStringKey)("display")); - exports["Display"] = Display; - exports["display"] = display; - exports["displayNone"] = displayNone; - exports["valDisplay"] = valDisplay; -})(PS["CSS.Display"] = PS["CSS.Display"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Property = PS["CSS.Property"]; - var CSS_Size = PS["CSS.Size"]; - var CSS_String = PS["CSS.String"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Data_Function = PS["Data.Function"]; - var Data_Tuple_Nested = PS["Data.Tuple.Nested"]; - var top = CSS_Stylesheet.key(CSS_Size.valSize)(CSS_String.fromString(CSS_Property.isStringKey)("top")); - exports["top"] = top; -})(PS["CSS.Geometry"] = PS["CSS.Geometry"] || {}); -(function(exports) { - "use strict"; - - exports.warn = function (s) { - return function () { - console.warn(s); - return {}; - }; - }; -})(PS["Control.Monad.Eff.Console"] = PS["Control.Monad.Eff.Console"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Eff.Console"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Data_Show = PS["Data.Show"]; - var Data_Unit = PS["Data.Unit"]; - exports["warn"] = $foreign.warn; -})(PS["Control.Monad.Eff.Console"] = PS["Control.Monad.Eff.Console"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Property = PS["CSS.Property"]; - var CSS_Selector = PS["CSS.Selector"]; - var CSS_String = PS["CSS.String"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Console = PS["Control.Monad.Eff.Console"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Array = PS["Data.Array"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Generic = PS["Data.Generic"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_These = PS["Data.These"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var collect$prime = function (v) { - return function (v1) { - if (v instanceof CSS_Property.Plain && v1 instanceof CSS_Property.Plain) { - return [ new Data_Either.Right(new Data_Tuple.Tuple(v.value0, v1.value0)) ]; - }; - if (v instanceof CSS_Property.Prefixed && v1 instanceof CSS_Property.Plain) { - return Data_Functor.map(Data_Functor.functorArray)(function (v3) { - return Data_Either.Right.create(new Data_Tuple.Tuple(v3.value0 + v3.value1, v1.value0)); - })(v.value0); - }; - if (v instanceof CSS_Property.Plain && v1 instanceof CSS_Property.Prefixed) { - return Data_Functor.map(Data_Functor.functorArray)(function (v2) { - return Data_Either.Right.create(new Data_Tuple.Tuple(v.value0, v2.value0 + v2.value1)); - })(v1.value0); - }; - if (v instanceof CSS_Property.Prefixed && v1 instanceof CSS_Property.Prefixed) { - return Data_Functor.map(Data_Functor.functorArray)(function (v2) { - return Data_Maybe.maybe(new Data_Either.Left(v2.value0 + v2.value1))(function ($189) { - return Data_Either.Right.create(Data_Tuple.Tuple.create(v2.value0 + v2.value1)((function (v3) { - return v2.value0 + v3; - })($189))); - })(Data_Tuple.lookup(Data_Foldable.foldableArray)(Data_Eq.eqString)(v2.value0)(v1.value0)); - })(v.value0); - }; - throw new Error("Failed pattern match at CSS.Render line 161, column 1 - line 161, column 80: " + [ v.constructor.name, v1.constructor.name ]); - }; - }; - var collect = function (v) { - return collect$prime(v.value0)(v.value1); - }; - exports["collect"] = collect; -})(PS["CSS.Render"] = PS["CSS.Render"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; - var Control_MonadPlus = PS["Control.MonadPlus"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Plus = PS["Control.Plus"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Tuple = PS["Data.Tuple"]; - var Prelude = PS["Prelude"]; - var ExceptT = function (x) { - return x; - }; - var runExceptT = function (v) { - return v; - }; - var mapExceptT = function (f) { - return function (v) { - return f(v); - }; - }; - var functorExceptT = function (dictFunctor) { - return new Data_Functor.Functor(function (f) { - return mapExceptT(Data_Functor.map(dictFunctor)(Data_Functor.map(Data_Either.functorEither)(f))); - }); - }; - var except = function (dictApplicative) { - return function ($96) { - return ExceptT(Control_Applicative.pure(dictApplicative)($96)); - }; - }; - var monadExceptT = function (dictMonad) { - return new Control_Monad.Monad(function () { - return applicativeExceptT(dictMonad); - }, function () { - return bindExceptT(dictMonad); - }); - }; - var bindExceptT = function (dictMonad) { - return new Control_Bind.Bind(function () { - return applyExceptT(dictMonad); - }, function (v) { - return function (k) { - return Control_Bind.bind(dictMonad.Bind1())(v)(Data_Either.either(function ($97) { - return Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Left.create($97)); - })(function (a) { - var v1 = k(a); - return v1; - })); - }; - }); - }; - var applyExceptT = function (dictMonad) { - return new Control_Apply.Apply(function () { - return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0()); - }, Control_Monad.ap(monadExceptT(dictMonad))); - }; - var applicativeExceptT = function (dictMonad) { - return new Control_Applicative.Applicative(function () { - return applyExceptT(dictMonad); - }, function ($98) { - return ExceptT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Right.create($98))); - }); - }; - var monadThrowExceptT = function (dictMonad) { - return new Control_Monad_Error_Class.MonadThrow(function () { - return monadExceptT(dictMonad); - }, function ($102) { - return ExceptT(Control_Applicative.pure(dictMonad.Applicative0())(Data_Either.Left.create($102))); - }); - }; - exports["ExceptT"] = ExceptT; - exports["except"] = except; - exports["mapExceptT"] = mapExceptT; - exports["runExceptT"] = runExceptT; - exports["functorExceptT"] = functorExceptT; - exports["applyExceptT"] = applyExceptT; - exports["applicativeExceptT"] = applicativeExceptT; - exports["bindExceptT"] = bindExceptT; - exports["monadExceptT"] = monadExceptT; - exports["monadThrowExceptT"] = monadThrowExceptT; -})(PS["Control.Monad.Except.Trans"] = PS["Control.Monad.Except.Trans"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Newtype = PS["Data.Newtype"]; - var Prelude = PS["Prelude"]; - var runExcept = function ($0) { - return Data_Newtype.unwrap(Data_Identity.newtypeIdentity)(Control_Monad_Except_Trans.runExceptT($0)); - }; - exports["runExcept"] = runExcept; -})(PS["Control.Monad.Except"] = PS["Control.Monad.Except"] || {}); -(function(exports) { - "use strict"; - - exports.toForeign = function (value) { - return value; - }; - - exports.unsafeFromForeign = function (value) { - return value; - }; - - exports.typeOf = function (value) { - return typeof value; - }; - - exports.tagOf = function (value) { - return Object.prototype.toString.call(value).slice(8, -1); - }; -})(PS["Data.Foreign"] = PS["Data.Foreign"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Comonad = PS["Control.Comonad"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Monad = PS["Control.Monad"]; - var Control_MonadPlus = PS["Control.MonadPlus"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Plus = PS["Control.Plus"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semigroup_Foldable = PS["Data.Semigroup.Foldable"]; - var Data_Semigroup_Traversable = PS["Data.Semigroup.Traversable"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var Prelude = PS["Prelude"]; - var Nil = (function () { - function Nil() { - - }; - Nil.value = new Nil(); - return Nil; - })(); - var Cons = (function () { - function Cons(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Cons.create = function (value0) { - return function (value1) { - return new Cons(value0, value1); - }; - }; - return Cons; - })(); - var NonEmptyList = function (x) { - return x; - }; - var foldableList = new Data_Foldable.Foldable(function (dictMonoid) { - return function (f) { - return Data_Foldable.foldl(foldableList)(function (acc) { - return function ($143) { - return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f($143)); - }; - })(Data_Monoid.mempty(dictMonoid)); - }; - }, function (f) { - var go = function ($copy_b) { - return function ($copy_v) { - var $tco_var_b = $copy_b; - var $tco_done = false; - var $tco_result; - function $tco_loop(b, v) { - if (v instanceof Nil) { - $tco_done = true; - return b; - }; - if (v instanceof Cons) { - $tco_var_b = f(b)(v.value0); - $copy_v = v.value1; - return; - }; - throw new Error("Failed pattern match at Data.List.Types line 78, column 12 - line 80, column 30: " + [ v.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_b, $copy_v); - }; - return $tco_result; - }; - }; - return go; - }, function (f) { - return function (b) { - var rev = function ($copy_acc) { - return function ($copy_v) { - var $tco_var_acc = $copy_acc; - var $tco_done = false; - var $tco_result; - function $tco_loop(acc, v) { - if (v instanceof Nil) { - $tco_done = true; - return acc; - }; - if (v instanceof Cons) { - $tco_var_acc = new Cons(v.value0, acc); - $copy_v = v.value1; - return; - }; - throw new Error("Failed pattern match at Data.List.Types line 73, column 15 - line 75, column 33: " + [ v.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_acc, $copy_v); - }; - return $tco_result; - }; - }; - return function ($144) { - return Data_Foldable.foldl(foldableList)(Data_Function.flip(f))(b)(rev(Nil.value)($144)); - }; - }; - }); - var functorList = new Data_Functor.Functor(function (f) { - return Data_Foldable.foldr(foldableList)(function (x) { - return function (acc) { - return new Cons(f(x), acc); - }; - })(Nil.value); - }); - var functorNonEmptyList = Data_NonEmpty.functorNonEmpty(functorList); - var semigroupList = new Data_Semigroup.Semigroup(function (xs) { - return function (ys) { - return Data_Foldable.foldr(foldableList)(Cons.create)(ys)(xs); - }; - }); - var applyList = new Control_Apply.Apply(function () { - return functorList; - }, function (v) { - return function (v1) { - if (v instanceof Nil) { - return Nil.value; - }; - if (v instanceof Cons) { - return Data_Semigroup.append(semigroupList)(Data_Functor.map(functorList)(v.value0)(v1))(Control_Apply.apply(applyList)(v.value1)(v1)); - }; - throw new Error("Failed pattern match at Data.List.Types line 94, column 1 - line 94, column 33: " + [ v.constructor.name, v1.constructor.name ]); - }; - }); - var applyNonEmptyList = new Control_Apply.Apply(function () { - return functorNonEmptyList; - }, function (v) { - return function (v1) { - return new Data_NonEmpty.NonEmpty(v.value0(v1.value0), Data_Semigroup.append(semigroupList)(Control_Apply.apply(applyList)(v.value1)(new Cons(v1.value0, Nil.value)))(Control_Apply.apply(applyList)(new Cons(v.value0, v.value1))(v1.value1))); - }; - }); - var applicativeList = new Control_Applicative.Applicative(function () { - return applyList; - }, function (a) { - return new Cons(a, Nil.value); - }); - var altList = new Control_Alt.Alt(function () { - return functorList; - }, Data_Semigroup.append(semigroupList)); - var plusList = new Control_Plus.Plus(function () { - return altList; - }, Nil.value); - var applicativeNonEmptyList = new Control_Applicative.Applicative(function () { - return applyNonEmptyList; - }, function ($149) { - return NonEmptyList(Data_NonEmpty.singleton(plusList)($149)); - }); - exports["Nil"] = Nil; - exports["Cons"] = Cons; - exports["NonEmptyList"] = NonEmptyList; - exports["semigroupList"] = semigroupList; - exports["functorList"] = functorList; - exports["foldableList"] = foldableList; - exports["applyList"] = applyList; - exports["applicativeList"] = applicativeList; - exports["altList"] = altList; - exports["plusList"] = plusList; - exports["functorNonEmptyList"] = functorNonEmptyList; - exports["applyNonEmptyList"] = applyNonEmptyList; - exports["applicativeNonEmptyList"] = applicativeNonEmptyList; -})(PS["Data.List.Types"] = PS["Data.List.Types"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Lazy = PS["Control.Lazy"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var reverse = (function () { - var go = function ($copy_acc) { - return function ($copy_v) { - var $tco_var_acc = $copy_acc; - var $tco_done = false; - var $tco_result; - function $tco_loop(acc, v) { - if (v instanceof Data_List_Types.Nil) { - $tco_done = true; - return acc; - }; - if (v instanceof Data_List_Types.Cons) { - $tco_var_acc = new Data_List_Types.Cons(v.value0, acc); - $copy_v = v.value1; - return; - }; - throw new Error("Failed pattern match at Data.List line 365, column 3 - line 365, column 19: " + [ acc.constructor.name, v.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_acc, $copy_v); - }; - return $tco_result; - }; - }; - return go(Data_List_Types.Nil.value); - })(); - var $$null = function (v) { - if (v instanceof Data_List_Types.Nil) { - return true; - }; - return false; - }; - exports["null"] = $$null; - exports["reverse"] = reverse; -})(PS["Data.List"] = PS["Data.List"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_NonEmpty = PS["Data.NonEmpty"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semigroup_Foldable = PS["Data.Semigroup.Foldable"]; - var Data_Semigroup_Traversable = PS["Data.Semigroup.Traversable"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var Partial_Unsafe = PS["Partial.Unsafe"]; - var Prelude = PS["Prelude"]; - var singleton = function ($160) { - return Data_List_Types.NonEmptyList(Data_NonEmpty.singleton(Data_List_Types.plusList)($160)); - }; - exports["singleton"] = singleton; -})(PS["Data.List.NonEmpty"] = PS["Data.List.NonEmpty"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Foreign"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Except = PS["Control.Monad.Except"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Int = PS["Data.Int"]; - var Data_List_NonEmpty = PS["Data.List.NonEmpty"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_String = PS["Data.String"]; - var Prelude = PS["Prelude"]; - var TypeMismatch = (function () { - function TypeMismatch(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - TypeMismatch.create = function (value0) { - return function (value1) { - return new TypeMismatch(value0, value1); - }; - }; - return TypeMismatch; - })(); - var fail = function ($121) { - return Control_Monad_Error_Class.throwError(Control_Monad_Except_Trans.monadThrowExceptT(Data_Identity.monadIdentity))(Data_List_NonEmpty.singleton($121)); - }; - var unsafeReadTagged = function (tag) { - return function (value) { - if ($foreign.tagOf(value) === tag) { - return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))($foreign.unsafeFromForeign(value)); - }; - if (Data_Boolean.otherwise) { - return fail(new TypeMismatch(tag, $foreign.tagOf(value))); - }; - throw new Error("Failed pattern match at Data.Foreign line 104, column 1 - line 104, column 55: " + [ tag.constructor.name, value.constructor.name ]); - }; - }; - exports["TypeMismatch"] = TypeMismatch; - exports["fail"] = fail; - exports["unsafeReadTagged"] = unsafeReadTagged; - exports["toForeign"] = $foreign.toForeign; - exports["typeOf"] = $foreign.typeOf; -})(PS["Data.Foreign"] = PS["Data.Foreign"] || {}); -(function(exports) { - "use strict"; - - // module Unsafe.Coerce - - exports.unsafeCoerce = function (x) { - return x; - }; -})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Unsafe.Coerce"]; - exports["unsafeCoerce"] = $foreign.unsafeCoerce; -})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Monad_Except = PS["Control.Monad.Except"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function = PS["Data.Function"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var fromAny = function (f) { - return function ($0) { - return Data_Either.either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create)(Control_Monad_Except.runExcept(Unsafe_Coerce.unsafeCoerce(f)($0))); - }; - }; - exports["fromAny"] = fromAny; -})(PS["DOM.Classy.Util"] = PS["DOM.Classy.Util"] || {}); -(function(exports) { - "use strict"; - - exports.target = function (e) { - return e.target; - }; -})(PS["DOM.Event.Event"] = PS["DOM.Event.Event"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Event.Types"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Identity = PS["Data.Identity"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var touchEventToEvent = Unsafe_Coerce.unsafeCoerce; - var readTouchEvent = Data_Foreign.unsafeReadTagged("TouchEvent"); - var readMouseEvent = Data_Foreign.unsafeReadTagged("MouseEvent"); - var mouseEventToEvent = Unsafe_Coerce.unsafeCoerce; - exports["mouseEventToEvent"] = mouseEventToEvent; - exports["readMouseEvent"] = readMouseEvent; - exports["readTouchEvent"] = readTouchEvent; - exports["touchEventToEvent"] = touchEventToEvent; -})(PS["DOM.Event.Types"] = PS["DOM.Event.Types"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_Util_FFI = PS["DOM.Util.FFI"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var elementToNode = Unsafe_Coerce.unsafeCoerce; - exports["elementToNode"] = elementToNode; -})(PS["DOM.Node.Types"] = PS["DOM.Node.Types"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Event.Event"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Event_EventPhase = PS["DOM.Event.EventPhase"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Enum = PS["Data.Enum"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - exports["target"] = $foreign.target; -})(PS["DOM.Event.Event"] = PS["DOM.Event.Event"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Classy_Util = PS["DOM.Classy.Util"]; - var DOM_Event_Event = PS["DOM.Event.Event"]; - var DOM_Event_EventPhase = PS["DOM.Event.EventPhase"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_HTML_Event_Types = PS["DOM.HTML.Event.Types"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var DOM_Websocket_Event_Types = PS["DOM.Websocket.Event.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - var IsEvent = function (fromEvent, toEvent) { - this.fromEvent = fromEvent; - this.toEvent = toEvent; - }; - var toEvent = function (dict) { - return dict.toEvent; - }; - var target = function (dictIsEvent) { - return function ($15) { - return DOM_Event_Event.target(toEvent(dictIsEvent)($15)); - }; - }; - var isEventTouchEvent = new IsEvent(DOM_Classy_Util.fromAny(DOM_Event_Types.readTouchEvent), DOM_Event_Types.touchEventToEvent); - var isEventMouseEvent = new IsEvent(DOM_Classy_Util.fromAny(DOM_Event_Types.readMouseEvent), DOM_Event_Types.mouseEventToEvent); - var fromEvent = function (dict) { - return dict.fromEvent; - }; - exports["IsEvent"] = IsEvent; - exports["fromEvent"] = fromEvent; - exports["target"] = target; - exports["toEvent"] = toEvent; - exports["isEventMouseEvent"] = isEventMouseEvent; - exports["isEventTouchEvent"] = isEventTouchEvent; -})(PS["DOM.Classy.Event"] = PS["DOM.Classy.Event"] || {}); -(function(exports) { - "use strict"; - - exports._readHTMLElement = function (failure) { - return function (success) { - return function (value) { - var tag = Object.prototype.toString.call(value); - if (tag.indexOf("[object HTML") === 0 && tag.indexOf("Element]") === tag.length - 8) { - return success(value); - } else { - return failure(tag); - } - }; - }; - }; -})(PS["DOM.HTML.Types"] = PS["DOM.HTML.Types"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.HTML.Types"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Either = PS["Data.Either"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Identity = PS["Data.Identity"]; - var Data_List_Types = PS["Data.List.Types"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var windowToEventTarget = Unsafe_Coerce.unsafeCoerce; - var readHTMLElement = $foreign._readHTMLElement(function ($0) { - return Control_Monad_Except_Trans.except(Data_Identity.applicativeIdentity)(Data_Either.Left.create(Control_Applicative.pure(Data_List_Types.applicativeNonEmptyList)(Data_Foreign.TypeMismatch.create("HTMLElement")($0)))); - })(function ($1) { - return Control_Monad_Except_Trans.except(Data_Identity.applicativeIdentity)(Data_Either.Right.create($1)); - }); - var htmlElementToNode = Unsafe_Coerce.unsafeCoerce; - var htmlDocumentToParentNode = Unsafe_Coerce.unsafeCoerce; - var htmlDocumentToDocument = Unsafe_Coerce.unsafeCoerce; - exports["htmlDocumentToDocument"] = htmlDocumentToDocument; - exports["htmlDocumentToParentNode"] = htmlDocumentToParentNode; - exports["htmlElementToNode"] = htmlElementToNode; - exports["readHTMLElement"] = readHTMLElement; - exports["windowToEventTarget"] = windowToEventTarget; -})(PS["DOM.HTML.Types"] = PS["DOM.HTML.Types"] || {}); -(function(exports) { - "use strict"; - - var getEffProp = function (name) { - return function (node) { - return function () { - return node[name]; - }; - }; - }; - - exports._parentNode = getEffProp("parentNode"); - - exports._nextSibling = getEffProp("nextSibling"); - - exports.insertBefore = function (node1) { - return function (node2) { - return function (parent) { - return function () { - return parent.insertBefore(node1, node2); - }; - }; - }; - }; - - exports.appendChild = function (node) { - return function (parent) { - return function () { - return parent.appendChild(node); - }; - }; - }; - - exports.removeChild = function (node) { - return function (parent) { - return function () { - return parent.removeChild(node); - }; - }; - }; -})(PS["DOM.Node.Node"] = PS["DOM.Node.Node"] || {}); -(function(exports) { - "use strict"; - - exports["null"] = null; - - exports.nullable = function (a, r, f) { - return a == null ? r : f(a); - }; - - exports.notNull = function (x) { - return x; - }; -})(PS["Data.Nullable"] = PS["Data.Nullable"] || {}); -(function(exports) { - "use strict"; - - exports.runFn4 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return fn(a, b, c, d); - }; - }; - }; - }; - }; -})(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Function.Uncurried"]; - var Data_Unit = PS["Data.Unit"]; - exports["runFn4"] = $foreign.runFn4; -})(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.Nullable"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Show = PS["Data.Show"]; - var Prelude = PS["Prelude"]; - var toNullable = Data_Maybe.maybe($foreign["null"])($foreign.notNull); - var toMaybe = function (n) { - return $foreign.nullable(n, Data_Maybe.Nothing.value, Data_Maybe.Just.create); - }; - exports["toMaybe"] = toMaybe; - exports["toNullable"] = toNullable; -})(PS["Data.Nullable"] = PS["Data.Nullable"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Node.Node"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Node_NodeType = PS["DOM.Node.NodeType"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Enum = PS["Data.Enum"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Nullable = PS["Data.Nullable"]; - var Prelude = PS["Prelude"]; - var parentNode = function ($2) { - return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Nullable.toMaybe)($foreign._parentNode($2)); - }; - var nextSibling = function ($6) { - return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Nullable.toMaybe)($foreign._nextSibling($6)); - }; - exports["nextSibling"] = nextSibling; - exports["parentNode"] = parentNode; - exports["appendChild"] = $foreign.appendChild; - exports["insertBefore"] = $foreign.insertBefore; - exports["removeChild"] = $foreign.removeChild; -})(PS["DOM.Node.Node"] = PS["DOM.Node.Node"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Classy_Util = PS["DOM.Classy.Util"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_Node_Node = PS["DOM.Node.Node"]; - var DOM_Node_NodeType = PS["DOM.Node.NodeType"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var IsNode = function (fromNode, toNode) { - this.fromNode = fromNode; - this.toNode = toNode; - }; - var toNode = function (dict) { - return dict.toNode; - }; - var isNodeHTMLElement = new IsNode(DOM_Classy_Util.fromAny(DOM_HTML_Types.readHTMLElement), Unsafe_Coerce.unsafeCoerce); - var fromNode = function (dict) { - return dict.fromNode; - }; - exports["IsNode"] = IsNode; - exports["fromNode"] = fromNode; - exports["toNode"] = toNode; - exports["isNodeHTMLElement"] = isNodeHTMLElement; -})(PS["DOM.Classy.Node"] = PS["DOM.Classy.Node"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Classy_Node = PS["DOM.Classy.Node"]; - var DOM_Classy_Util = PS["DOM.Classy.Util"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_Node_Element = PS["DOM.Node.Element"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var IsElement = function (IsNode0, fromElement, toElement) { - this.IsNode0 = IsNode0; - this.fromElement = fromElement; - this.toElement = toElement; - }; - var toElement = function (dict) { - return dict.toElement; - }; - var isElementHTMLElement = new IsElement(function () { - return DOM_Classy_Node.isNodeHTMLElement; - }, DOM_Classy_Util.fromAny(DOM_HTML_Types.readHTMLElement), Unsafe_Coerce.unsafeCoerce); - var fromElement = function (dict) { - return dict.fromElement; - }; - exports["IsElement"] = IsElement; - exports["fromElement"] = fromElement; - exports["toElement"] = toElement; - exports["isElementHTMLElement"] = isElementHTMLElement; -})(PS["DOM.Classy.Element"] = PS["DOM.Classy.Element"] || {}); -(function(exports) { - "use strict"; - - // - CSSOM --------------------------------------------------------------------- - - exports.getBoundingClientRect = function (el) { - return function () { - return el.getBoundingClientRect(); - }; - }; -})(PS["DOM.HTML.HTMLElement"] = PS["DOM.HTML.HTMLElement"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.HTML.HTMLElement"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Nullable = PS["Data.Nullable"]; - var Prelude = PS["Prelude"]; - exports["getBoundingClientRect"] = $foreign.getBoundingClientRect; -})(PS["DOM.HTML.HTMLElement"] = PS["DOM.HTML.HTMLElement"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Classy_Element = PS["DOM.Classy.Element"]; - var DOM_Classy_Util = PS["DOM.Classy.Util"]; - var DOM_HTML_HTMLElement = PS["DOM.HTML.HTMLElement"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var IsHTMLElement = function (IsElement0, fromHTMLElement, toHTMLElement) { - this.IsElement0 = IsElement0; - this.fromHTMLElement = fromHTMLElement; - this.toHTMLElement = toHTMLElement; - }; - var toHTMLElement = function (dict) { - return dict.toHTMLElement; - }; - var isHTMLElementHTMLElement = new IsHTMLElement(function () { - return DOM_Classy_Element.isElementHTMLElement; - }, Data_Maybe.Just.create, Control_Category.id(Control_Category.categoryFn)); - var getBoundingClientRect = function (dictIsHTMLElement) { - return function ($45) { - return DOM_HTML_HTMLElement.getBoundingClientRect(toHTMLElement(dictIsHTMLElement)($45)); - }; - }; - var fromHTMLElement = function (dict) { - return dict.fromHTMLElement; - }; - exports["IsHTMLElement"] = IsHTMLElement; - exports["fromHTMLElement"] = fromHTMLElement; - exports["getBoundingClientRect"] = getBoundingClientRect; - exports["toHTMLElement"] = toHTMLElement; - exports["isHTMLElementHTMLElement"] = isHTMLElementHTMLElement; -})(PS["DOM.Classy.HTMLElement"] = PS["DOM.Classy.HTMLElement"] || {}); -(function(exports) { - "use strict"; - - exports.clientX = function (e) { - return e.clientX; - }; - - exports.clientY = function (e) { - return e.clientY; - }; -})(PS["DOM.Event.MouseEvent"] = PS["DOM.Event.MouseEvent"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Event.MouseEvent"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Nullable = PS["Data.Nullable"]; - var Prelude = PS["Prelude"]; - exports["clientX"] = $foreign.clientX; - exports["clientY"] = $foreign.clientY; -})(PS["DOM.Event.MouseEvent"] = PS["DOM.Event.MouseEvent"] || {}); -(function(exports) { - "use strict"; - - exports.clientX = function (t) { - return t.clientX; - }; - - exports.clientY = function (t) { - return t.clientY; - }; - - exports._item = function (i) { - return function(l) { - return l.item(i); - }; - }; - - exports.touches = function (e) { - return e.touches; - }; -})(PS["DOM.Event.TouchEvent"] = PS["DOM.Event.TouchEvent"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Event.TouchEvent"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Nullable = PS["Data.Nullable"]; - var Prelude = PS["Prelude"]; - var item = function (i) { - return function ($0) { - return Data_Nullable.toMaybe($foreign._item(i)($0)); - }; - }; - exports["item"] = item; - exports["clientX"] = $foreign.clientX; - exports["clientY"] = $foreign.clientY; - exports["touches"] = $foreign.touches; -})(PS["DOM.Event.TouchEvent"] = PS["DOM.Event.TouchEvent"] || {}); -(function(exports) { - "use strict"; - - // Alias require to prevent webpack or browserify from actually requiring. - var req = typeof module === "undefined" ? undefined : module.require; - var util = req === undefined ? undefined : req("util"); - - exports.traceAny = function () { - return function (x) { - return function (k) { - // node only recurses two levels into an object before printing - // "[object]" for further objects when using console.log() - if (util !== undefined) { - console.log(util.inspect(x, { depth: null, colors: true })); - } else { - console.log(x); - } - return k({}); - }; - }; - }; -})(PS["Debug.Trace"] = PS["Debug.Trace"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Debug.Trace"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Show = PS["Data.Show"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var DebugWarning = {}; - var warn = function (dictWarn) { - return DebugWarning; - }; - var traceAnyA = function (dictDebugWarning) { - return function (dictApplicative) { - return function (s) { - return $foreign.traceAny(dictDebugWarning)(s)(function (v) { - return Control_Applicative.pure(dictApplicative)(Data_Unit.unit); - }); - }; - }; - }; - exports["DebugWarning"] = DebugWarning; - exports["traceAnyA"] = traceAnyA; - exports["warn"] = warn; -})(PS["Debug.Trace"] = PS["Debug.Trace"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Eq = PS["Data.Eq"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - var OrdBox = (function () { - function OrdBox(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - OrdBox.create = function (value0) { - return function (value1) { - return function (value2) { - return new OrdBox(value0, value1, value2); - }; - }; - }; - return OrdBox; - })(); - var unOrdBox = function (v) { - return v.value2; - }; - var mkOrdBox = function (dictOrd) { - return OrdBox.create(Data_Eq.eq(dictOrd.Eq0()))(Data_Ord.compare(dictOrd)); - }; - var eqOrdBox = new Data_Eq.Eq(function (v) { - return function (v1) { - return v.value0(v.value2)(v1.value2); - }; - }); - var ordOrdBox = new Data_Ord.Ord(function () { - return eqOrdBox; - }, function (v) { - return function (v1) { - return v.value1(v.value2)(v1.value2); - }; - }); - exports["mkOrdBox"] = mkOrdBox; - exports["unOrdBox"] = unOrdBox; - exports["eqOrdBox"] = eqOrdBox; - exports["ordOrdBox"] = ordOrdBox; -})(PS["Halogen.Data.OrdBox"] = PS["Halogen.Data.OrdBox"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - var RefUpdate = (function () { - function RefUpdate(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - RefUpdate.create = function (value0) { - return function (value1) { - return function (value2) { - return new RefUpdate(value0, value1, value2); - }; - }; - }; - return RefUpdate; - })(); - var Query = (function () { - function Query(value0) { - this.value0 = value0; - }; - Query.create = function (value0) { - return new Query(value0); - }; - return Query; - })(); - var bifunctorInputF = new Data_Bifunctor.Bifunctor(function (f) { - return function (g) { - return function (v) { - if (v instanceof RefUpdate) { - return new RefUpdate(v.value0, v.value1, f(v.value2)); - }; - if (v instanceof Query) { - return new Query(g(v.value0)); - }; - throw new Error("Failed pattern match at Halogen.Query.InputF line 21, column 15 - line 23, column 27: " + [ v.constructor.name ]); - }; - }; - }); - var functorInputF = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorInputF)); - exports["RefUpdate"] = RefUpdate; - exports["Query"] = Query; - exports["bifunctorInputF"] = bifunctorInputF; - exports["functorInputF"] = functorInputF; -})(PS["Halogen.Query.InputF"] = PS["Halogen.Query.InputF"] || {}); -(function(exports) { - "use strict"; - - exports.newRef = function (val) { - return function () { - return { value: val }; - }; - }; - - exports.readRef = function (ref) { - return function () { - return ref.value; - }; - }; - - exports["modifyRef'"] = function (ref) { - return function (f) { - return function () { - var t = f(ref.value); - ref.value = t.state; - return t.value; - }; - }; - }; - - exports.writeRef = function (ref) { - return function (val) { - return function () { - ref.value = val; - return {}; - }; - }; - }; -})(PS["Control.Monad.Eff.Ref"] = PS["Control.Monad.Eff.Ref"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Eff.Ref"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var modifyRef = function (ref) { - return function (f) { - return $foreign["modifyRef'"](ref)(function (s) { - return { - state: f(s), - value: Data_Unit.unit - }; - }); - }; - }; - exports["modifyRef"] = modifyRef; - exports["modifyRef'"] = $foreign["modifyRef'"]; - exports["newRef"] = $foreign.newRef; - exports["readRef"] = $foreign.readRef; - exports["writeRef"] = $foreign.writeRef; -})(PS["Control.Monad.Eff.Ref"] = PS["Control.Monad.Eff.Ref"] || {}); -(function(exports) { - "use strict"; - - exports.eventListener = function (fn) { - return function (event) { - return fn(event)(); - }; - }; - - exports.addEventListener = function (type) { - return function (listener) { - return function (useCapture) { - return function (target) { - return function () { - target.addEventListener(type, listener, useCapture); - return {}; - }; - }; - }; - }; - }; -})(PS["DOM.Event.EventTarget"] = PS["DOM.Event.EventTarget"] || {}); -(function(exports) { - "use strict"; - - exports.error = function (msg) { - return new Error(msg); - }; - - exports.throwException = function (e) { - return function () { - throw e; - }; - }; -})(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Eff.Exception"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Show = PS["Data.Show"]; - var Prelude = PS["Prelude"]; - var $$throw = function ($1) { - return $foreign.throwException($foreign.error($1)); - }; - exports["throw"] = $$throw; - exports["error"] = $foreign.error; - exports["throwException"] = $foreign.throwException; -})(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Event.EventTarget"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var DOM = PS["DOM"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var Prelude = PS["Prelude"]; - exports["addEventListener"] = $foreign.addEventListener; - exports["eventListener"] = $foreign.eventListener; -})(PS["DOM.Event.EventTarget"] = PS["DOM.Event.EventTarget"] || {}); -(function(exports) { - "use strict"; - - exports._copyEff = function (m) { - return function () { - var r = {}; - for (var k in m) { - if (hasOwnProperty.call(m, k)) { - r[k] = m[k]; - } - } - return r; - }; - }; - - exports.empty = {}; - - exports.runST = function (f) { - return f; - }; - - exports._foldM = function (bind) { - return function (f) { - return function (mz) { - return function (m) { - var acc = mz; - function g(k) { - return function (z) { - return f(z)(k)(m[k]); - }; - } - for (var k in m) { - if (hasOwnProperty.call(m, k)) { - acc = bind(acc)(g(k)); - } - } - return acc; - }; - }; - }; - }; - - exports._lookup = function (no, yes, k, m) { - return k in m ? yes(m[k]) : no; - }; - - function toArrayWithKey(f) { - return function (m) { - var r = []; - for (var k in m) { - if (hasOwnProperty.call(m, k)) { - r.push(f(k)(m[k])); - } - } - return r; - }; - } -})(PS["Data.StrMap"] = PS["Data.StrMap"] || {}); -(function(exports) { - "use strict"; - - exports["new"] = function () { - return {}; - }; - - exports.poke = function (m) { - return function (k) { - return function (v) { - return function () { - m[k] = v; - return m; - }; - }; - }; - }; - - exports["delete"] = function (m) { - return function (k) { - return function () { - delete m[k]; - return m; - }; - }; - }; -})(PS["Data.StrMap.ST"] = PS["Data.StrMap.ST"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.StrMap.ST"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_ST = PS["Control.Monad.ST"]; - var Data_Maybe = PS["Data.Maybe"]; - exports["delete"] = $foreign["delete"]; - exports["new"] = $foreign["new"]; - exports["poke"] = $foreign.poke; -})(PS["Data.StrMap.ST"] = PS["Data.StrMap.ST"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Data.StrMap"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_ST = PS["Control.Monad.ST"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Array = PS["Data.Array"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_StrMap_ST = PS["Data.StrMap.ST"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var Prelude = PS["Prelude"]; - var thawST = $foreign._copyEff; - var pureST = function (f) { - return Control_Monad_Eff.runPure($foreign.runST(f)); - }; - var mutate = function (f) { - return function (m) { - return pureST(function __do() { - var v = thawST(m)(); - var v1 = f(v)(); - return v; - }); - }; - }; - var lookup = Data_Function_Uncurried.runFn4($foreign._lookup)(Data_Maybe.Nothing.value)(Data_Maybe.Just.create); - var insert = function (k) { - return function (v) { - return mutate(function (s) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_StrMap_ST.poke(s)(k)(v)); - }); - }; - }; - var fromFoldable = function (dictFoldable) { - return function (l) { - return pureST(function __do() { - var v = Data_StrMap_ST["new"](); - Control_Monad_Eff.foreachE(Data_Array.fromFoldable(dictFoldable)(l))(function (v1) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_StrMap_ST.poke(v)(v1.value0)(v1.value1)); - })(); - return v; - }); - }; - }; - var fold = $foreign._foldM(Data_Function.applyFlipped); - var foldMap = function (dictMonoid) { - return function (f) { - return fold(function (acc) { - return function (k) { - return function (v) { - return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f(k)(v)); - }; - }; - })(Data_Monoid.mempty(dictMonoid)); - }; - }; - var $$delete = function (k) { - return mutate(function (s) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(Data_StrMap_ST["delete"](s)(k)); - }); - }; - var alter = function (f) { - return function (k) { - return function (m) { - var v = f(lookup(k)(m)); - if (v instanceof Data_Maybe.Nothing) { - return $$delete(k)(m); - }; - if (v instanceof Data_Maybe.Just) { - return insert(k)(v.value0)(m); - }; - throw new Error("Failed pattern match at Data.StrMap line 198, column 15 - line 200, column 25: " + [ v.constructor.name ]); - }; - }; - }; - exports["alter"] = alter; - exports["fold"] = fold; - exports["foldMap"] = foldMap; - exports["fromFoldable"] = fromFoldable; - exports["insert"] = insert; - exports["lookup"] = lookup; - exports["pureST"] = pureST; - exports["thawST"] = thawST; - exports["empty"] = $foreign.empty; -})(PS["Data.StrMap"] = PS["Data.StrMap"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Data_Void = PS["Data.Void"]; - var Prelude = PS["Prelude"]; - var Step = (function () { - function Step(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - Step.create = function (value0) { - return function (value1) { - return function (value2) { - return new Step(value0, value1, value2); - }; - }; - }; - return Step; - })(); - var step = function (v) { - return v.value1; - }; - var halt = function (v) { - return v.value2; - }; - var extract = function (v) { - return v.value0; - }; - exports["Step"] = Step; - exports["extract"] = extract; - exports["halt"] = halt; - exports["step"] = step; -})(PS["Halogen.VDom.Machine"] = PS["Halogen.VDom.Machine"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Generic = PS["Data.Generic"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var ElemSpec = (function () { - function ElemSpec(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - ElemSpec.create = function (value0) { - return function (value1) { - return function (value2) { - return new ElemSpec(value0, value1, value2); - }; - }; - }; - return ElemSpec; - })(); - var Text = (function () { - function Text(value0) { - this.value0 = value0; - }; - Text.create = function (value0) { - return new Text(value0); - }; - return Text; - })(); - var Elem = (function () { - function Elem(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Elem.create = function (value0) { - return function (value1) { - return new Elem(value0, value1); - }; - }; - return Elem; - })(); - var Keyed = (function () { - function Keyed(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Keyed.create = function (value0) { - return function (value1) { - return new Keyed(value0, value1); - }; - }; - return Keyed; - })(); - var Widget = (function () { - function Widget(value0) { - this.value0 = value0; - }; - Widget.create = function (value0) { - return new Widget(value0); - }; - return Widget; - })(); - var Grafted = (function () { - function Grafted(value0) { - this.value0 = value0; - }; - Grafted.create = function (value0) { - return new Grafted(value0); - }; - return Grafted; - })(); - var Graft = (function () { - function Graft(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - Graft.create = function (value0) { - return function (value1) { - return function (value2) { - return new Graft(value0, value1, value2); - }; - }; - }; - return Graft; - })(); - var unGraft = function (f) { - return function ($124) { - return f(Unsafe_Coerce.unsafeCoerce($124)); - }; - }; - var graft = Unsafe_Coerce.unsafeCoerce; - var functorElemSpec = new Data_Functor.Functor(function (f) { - return function (v) { - return new ElemSpec(v.value0, v.value1, f(v.value2)); - }; - }); - var eqElemName = Data_Eq.eqString; - var bifunctorGraft = new Data_Bifunctor.Bifunctor(function (f) { - return function (g) { - return unGraft(function (v) { - return graft(new Graft(function ($126) { - return f(v.value0($126)); - }, function ($127) { - return g(v.value1($127)); - }, v.value2)); - }); - }; - }); - var bifunctorVDom = new Data_Bifunctor.Bifunctor(function (f) { - return function (g) { - return function (v) { - if (v instanceof Text) { - return new Text(v.value0); - }; - if (v instanceof Grafted) { - return new Grafted(Data_Bifunctor.bimap(bifunctorGraft)(f)(g)(v.value0)); - }; - return new Grafted(graft(new Graft(f, g, v))); - }; - }; - }); - var runGraft = unGraft(function (v) { - var go = function (v2) { - if (v2 instanceof Text) { - return new Text(v2.value0); - }; - if (v2 instanceof Elem) { - return new Elem(Data_Functor.map(functorElemSpec)(v.value0)(v2.value0), Data_Functor.map(Data_Functor.functorArray)(go)(v2.value1)); - }; - if (v2 instanceof Keyed) { - return new Keyed(Data_Functor.map(functorElemSpec)(v.value0)(v2.value0), Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Data_Tuple.functorTuple)(go))(v2.value1)); - }; - if (v2 instanceof Widget) { - return new Widget(v.value1(v2.value0)); - }; - if (v2 instanceof Grafted) { - return new Grafted(Data_Bifunctor.bimap(bifunctorGraft)(v.value0)(v.value1)(v2.value0)); - }; - throw new Error("Failed pattern match at Halogen.VDom.Types line 75, column 7 - line 75, column 27: " + [ v2.constructor.name ]); - }; - return go(v.value2); - }); - exports["ElemSpec"] = ElemSpec; - exports["Graft"] = Graft; - exports["Text"] = Text; - exports["Elem"] = Elem; - exports["Keyed"] = Keyed; - exports["Widget"] = Widget; - exports["Grafted"] = Grafted; - exports["graft"] = graft; - exports["runGraft"] = runGraft; - exports["unGraft"] = unGraft; - exports["bifunctorVDom"] = bifunctorVDom; - exports["bifunctorGraft"] = bifunctorGraft; - exports["functorElemSpec"] = functorElemSpec; - exports["eqElemName"] = eqElemName; -})(PS["Halogen.VDom.Types"] = PS["Halogen.VDom.Types"] || {}); -(function(exports) { - "use strict"; - - exports.unsafeGetAny = function (key, obj) { - return obj[key]; - }; - - exports.unsafeHasAny = function (key, obj) { - return obj.hasOwnProperty(key); - }; - - exports.unsafeSetAny = function (key, val, obj) { - return function () { - obj[key] = val; - }; - }; - - exports.forE = function (a, f) { - return function () { - var b = []; - for (var i = 0; i < a.length; i++) { - b.push(f(i, a[i])()); - } - return b; - }; - }; - - exports.forInE = function (o, f) { - return function () { - var ks = Object.keys(o); - for (var i = 0; i < ks.length; i++) { - var k = ks[i]; - f(k, o[k])(); - } - }; - }; - - exports.diffWithIxE = function (a1, a2, f1, f2, f3) { - return function () { - var a3 = []; - var l1 = a1.length; - var l2 = a2.length; - var i = 0; - while (1) { - if (i < l1) { - if (i < l2) { - a3.push(f1(i, a1[i], a2[i])()); - } else { - f2(i, a1[i])(); - } - } else if (i < l2) { - a3.push(f3(i, a2[i])()); - } else { - break; - } - i++; - } - return a3; - }; - }; - - exports.strMapWithIxE = function (as, fk, f) { - return function () { - var o = {}; - for (var i = 0; i < as.length; i++) { - var a = as[i]; - var k = fk(a); - o[k] = f(k, i, a)(); - } - return o; - }; - }; - - exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { - return function () { - var o2 = {}; - for (var i = 0; i < as.length; i++) { - var a = as[i]; - var k = fk(a); - if (o1.hasOwnProperty(k)) { - o2[k] = f1(k, i, o1[k], a)(); - } else { - o2[k] = f3(k, i, a)(); - } - } - for (var k in o1) { - if (k in o2) { - continue; - } - f2(k, o1[k])(); - } - return o2; - }; - }; - - exports.refEq = function (a, b) { - return a === b; - }; - - exports.createTextNode = function (s, doc) { - return function () { - return doc.createTextNode(s); - }; - }; - - exports.setTextContent = function (s, n) { - return function () { - n.textContent = s; - }; - }; - - exports.createElement = function (ns, name, doc) { - return function () { - if (ns != null) { - return doc.createElementNS(ns, name); - } else { - return doc.createElement(name) - } - }; - }; - - exports.insertChildIx = function (i, a, b) { - return function () { - var n = b.childNodes.item(i) || null; - if (n !== a) { - b.insertBefore(a, n); - } - }; - }; - - exports.removeChild = function (a, b) { - return function () { - if (b && a.parentNode === b) { - b.removeChild(a); - } - }; - }; - - exports.unsafeParent = function (a) { - return a.parentNode; - }; - - exports.setAttribute = function (ns, attr, val, el) { - return function () { - if (ns != null) { - el.setAttributeNS(ns, attr, val); - } else { - el.setAttribute(attr, val); - } - }; - }; - - exports.removeAttribute = function (ns, attr, el) { - return function () { - if (ns != null) { - el.removeAttributeNS(ns, attr); - } else { - el.removeAttribute(attr); - } - }; - }; - - exports.addEventListener = function (ev, listener, el) { - return function () { - el.addEventListener(ev, listener, false); - }; - }; - - exports.removeEventListener = function (ev, listener, el) { - return function () { - el.removeEventListener(ev, listener, false); - }; - }; - - exports.jsUndefined = void 0; -})(PS["Halogen.VDom.Util"] = PS["Halogen.VDom.Util"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Halogen.VDom.Util"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var DOM = PS["DOM"]; - var DOM_Event_EventTarget = PS["DOM.Event.EventTarget"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Nullable = PS["Data.Nullable"]; - var Data_StrMap = PS["Data.StrMap"]; - var Data_StrMap_ST = PS["Data.StrMap.ST"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var unsafeLookup = $foreign.unsafeGetAny; - var unsafeFreeze = Unsafe_Coerce.unsafeCoerce; - var pokeMutMap = $foreign.unsafeSetAny; - var newMutMap = Unsafe_Coerce.unsafeCoerce(Data_StrMap_ST["new"]); - var effUnit = Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit); - var effPure = Control_Applicative.pure(Control_Monad_Eff.applicativeEff); - exports["effPure"] = effPure; - exports["effUnit"] = effUnit; - exports["newMutMap"] = newMutMap; - exports["pokeMutMap"] = pokeMutMap; - exports["unsafeFreeze"] = unsafeFreeze; - exports["unsafeLookup"] = unsafeLookup; - exports["addEventListener"] = $foreign.addEventListener; - exports["createElement"] = $foreign.createElement; - exports["createTextNode"] = $foreign.createTextNode; - exports["diffWithIxE"] = $foreign.diffWithIxE; - exports["diffWithKeyAndIxE"] = $foreign.diffWithKeyAndIxE; - exports["forE"] = $foreign.forE; - exports["forInE"] = $foreign.forInE; - exports["insertChildIx"] = $foreign.insertChildIx; - exports["jsUndefined"] = $foreign.jsUndefined; - exports["refEq"] = $foreign.refEq; - exports["removeAttribute"] = $foreign.removeAttribute; - exports["removeChild"] = $foreign.removeChild; - exports["removeEventListener"] = $foreign.removeEventListener; - exports["setAttribute"] = $foreign.setAttribute; - exports["setTextContent"] = $foreign.setTextContent; - exports["strMapWithIxE"] = $foreign.strMapWithIxE; - exports["unsafeGetAny"] = $foreign.unsafeGetAny; - exports["unsafeHasAny"] = $foreign.unsafeHasAny; - exports["unsafeParent"] = $foreign.unsafeParent; - exports["unsafeSetAny"] = $foreign.unsafeSetAny; -})(PS["Halogen.VDom.Util"] = PS["Halogen.VDom.Util"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var DOM = PS["DOM"]; - var DOM_Event_EventTarget = PS["DOM.Event.EventTarget"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Nullable = PS["Data.Nullable"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_StrMap = PS["Data.StrMap"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_VDom = PS["Halogen.VDom"]; - var Halogen_VDom_Machine = PS["Halogen.VDom.Machine"]; - var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; - var Halogen_VDom_Util = PS["Halogen.VDom.Util"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var Created = (function () { - function Created(value0) { - this.value0 = value0; - }; - Created.create = function (value0) { - return new Created(value0); - }; - return Created; - })(); - var Removed = (function () { - function Removed(value0) { - this.value0 = value0; - }; - Removed.create = function (value0) { - return new Removed(value0); - }; - return Removed; - })(); - var Attribute = (function () { - function Attribute(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - Attribute.create = function (value0) { - return function (value1) { - return function (value2) { - return new Attribute(value0, value1, value2); - }; - }; - }; - return Attribute; - })(); - var Property = (function () { - function Property(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Property.create = function (value0) { - return function (value1) { - return new Property(value0, value1); - }; - }; - return Property; - })(); - var Handler = (function () { - function Handler(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Handler.create = function (value0) { - return function (value1) { - return new Handler(value0, value1); - }; - }; - return Handler; - })(); - var Ref = (function () { - function Ref(value0) { - this.value0 = value0; - }; - Ref.create = function (value0) { - return new Ref(value0); - }; - return Ref; - })(); - var unsafeGetProperty = Halogen_VDom_Util.unsafeGetAny; - var setProperty = Halogen_VDom_Util.unsafeSetAny; - var removeProperty = function (key, el) { - var v = Data_Foreign.typeOf(Halogen_VDom_Util.unsafeGetAny(key, el)); - if (v === "string") { - return Halogen_VDom_Util.unsafeSetAny(key, "", el); - }; - return Halogen_VDom_Util.unsafeSetAny(key, Halogen_VDom_Util.jsUndefined, el); - }; - var propToStrKey = function (v) { - if (v instanceof Attribute && v.value0 instanceof Data_Maybe.Just) { - return "attr/" + (v.value0.value0 + (":" + v.value1)); - }; - if (v instanceof Attribute) { - return "attr/:" + v.value1; - }; - if (v instanceof Property) { - return "prop/" + v.value0; - }; - if (v instanceof Handler) { - return "handler/" + v.value0; - }; - if (v instanceof Ref) { - return "ref"; - }; - throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 179, column 16 - line 186, column 1: " + [ v.constructor.name ]); - }; - var propFromString = Unsafe_Coerce.unsafeCoerce; - var functorProp = new Data_Functor.Functor(function (f) { - return function (v) { - if (v instanceof Handler) { - return new Handler(v.value0, Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v.value1)); - }; - if (v instanceof Ref) { - return new Ref(Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v.value0)); - }; - return Unsafe_Coerce.unsafeCoerce(v); - }; - }); - var buildProp = function (emit) { - return function (el) { - var removeProp = function (prevEvents) { - return function (v, v1) { - if (v1 instanceof Attribute) { - return Halogen_VDom_Util.removeAttribute(Data_Nullable.toNullable(v1.value0), v1.value1, el); - }; - if (v1 instanceof Property) { - return removeProperty(v1.value0, el); - }; - if (v1 instanceof Handler) { - var handler = Halogen_VDom_Util.unsafeLookup(v1.value0, prevEvents); - return Halogen_VDom_Util.removeEventListener(v1.value0, Data_Tuple.fst(handler), el); - }; - if (v1 instanceof Ref) { - return Halogen_VDom_Util.effUnit; - }; - throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 166, column 5 - line 176, column 21: " + [ v1.constructor.name ]); - }; - }; - var mbEmit = Data_Maybe.maybe(Halogen_VDom_Util.effUnit)(emit); - var done = function (ps) { - var v = Data_StrMap.lookup("ref")(ps); - if (v instanceof Data_Maybe.Just && v.value0 instanceof Ref) { - return mbEmit(v.value0.value0(new Removed(el))); - }; - return Halogen_VDom_Util.effUnit; - }; - var diffProp = function (prevEvents, events) { - return function (v, v1, v11, v2) { - if (v11 instanceof Attribute && v2 instanceof Attribute) { - var v3 = v11.value2 !== v2.value2; - if (v3) { - return function __do() { - Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el)(); - return v2; - }; - }; - return Halogen_VDom_Util.effPure(v2); - }; - if (v11 instanceof Property && v2 instanceof Property) { - var v4 = Halogen_VDom_Util.refEq(v11.value1, v2.value1); - if (v4) { - return Halogen_VDom_Util.effPure(v2); - }; - if (v2.value0 === "value") { - var elVal = unsafeGetProperty("value", el); - var v5 = !Halogen_VDom_Util.refEq(elVal, v2.value1); - if (v5) { - return function __do() { - setProperty(v2.value0, v2.value1, el)(); - return v2; - }; - }; - return Halogen_VDom_Util.effPure(v2); - }; - return function __do() { - setProperty(v2.value0, v2.value1, el)(); - return v2; - }; - }; - if (v11 instanceof Handler && v2 instanceof Handler) { - var handler = Halogen_VDom_Util.unsafeLookup(v2.value0, prevEvents); - return function __do() { - Control_Monad_Eff_Ref.writeRef(Data_Tuple.snd(handler))(v2.value1)(); - Halogen_VDom_Util.pokeMutMap(v2.value0, handler, events)(); - return v2; - }; - }; - return Halogen_VDom_Util.effPure(v2); - }; - }; - var applyProp = function (events) { - return function (v, v1, v2) { - if (v2 instanceof Attribute) { - return function __do() { - Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el)(); - return v2; - }; - }; - if (v2 instanceof Property) { - return function __do() { - setProperty(v2.value0, v2.value1, el)(); - return v2; - }; - }; - if (v2 instanceof Handler) { - var v3 = Halogen_VDom_Util.unsafeGetAny(v2.value0, events); - if (Halogen_VDom_Util.unsafeHasAny(v2.value0, events)) { - return function __do() { - Control_Monad_Eff_Ref.writeRef(Data_Tuple.snd(v3))(v2.value1)(); - return v2; - }; - }; - return function __do() { - var v4 = Control_Monad_Eff_Ref.newRef(v2.value1)(); - var listener = DOM_Event_EventTarget.eventListener(function (ev) { - return function __do() { - var v5 = Control_Monad_Eff_Ref.readRef(v4)(); - return mbEmit(v5(ev))(); - }; - }); - Halogen_VDom_Util.pokeMutMap(v2.value0, new Data_Tuple.Tuple(listener, v4), events)(); - Halogen_VDom_Util.addEventListener(v2.value0, listener, el)(); - return v2; - }; - }; - if (v2 instanceof Ref) { - return function __do() { - mbEmit(v2.value0(new Created(el)))(); - return v2; - }; - }; - throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 107, column 5 - line 130, column 15: " + [ v2.constructor.name ]); - }; - }; - var patch = function (prevEvents, ps1) { - return function (ps2) { - return function __do() { - var v = Halogen_VDom_Util.newMutMap(); - var onThis = removeProp(prevEvents); - var onThese = diffProp(prevEvents, v); - var onThat = applyProp(v); - var v1 = Halogen_VDom_Util.diffWithKeyAndIxE(ps1, ps2, propToStrKey, onThese, onThis, onThat)(); - return new Halogen_VDom_Machine.Step(Data_Unit.unit, patch(Halogen_VDom_Util.unsafeFreeze(v), v1), done(v1)); - }; - }; - }; - var render = function (ps1) { - return function __do() { - var v = Halogen_VDom_Util.newMutMap(); - var v1 = Halogen_VDom_Util.strMapWithIxE(ps1, propToStrKey, applyProp(v))(); - return new Halogen_VDom_Machine.Step(Data_Unit.unit, patch(Halogen_VDom_Util.unsafeFreeze(v), v1), done(v1)); - }; - }; - return render; - }; - }; - exports["Created"] = Created; - exports["Removed"] = Removed; - exports["Attribute"] = Attribute; - exports["Property"] = Property; - exports["Handler"] = Handler; - exports["Ref"] = Ref; - exports["buildProp"] = buildProp; - exports["propFromString"] = propFromString; - exports["functorProp"] = functorProp; -})(PS["Halogen.VDom.DOM.Prop"] = PS["Halogen.VDom.DOM.Prop"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Apply = PS["Control.Apply"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_HTML_Indexed_ButtonType = PS["DOM.HTML.Indexed.ButtonType"]; - var DOM_HTML_Indexed_CrossOriginValue = PS["DOM.HTML.Indexed.CrossOriginValue"]; - var DOM_HTML_Indexed_DirValue = PS["DOM.HTML.Indexed.DirValue"]; - var DOM_HTML_Indexed_FormMethod = PS["DOM.HTML.Indexed.FormMethod"]; - var DOM_HTML_Indexed_InputType = PS["DOM.HTML.Indexed.InputType"]; - var DOM_HTML_Indexed_KindValue = PS["DOM.HTML.Indexed.KindValue"]; - var DOM_HTML_Indexed_MenuType = PS["DOM.HTML.Indexed.MenuType"]; - var DOM_HTML_Indexed_MenuitemType = PS["DOM.HTML.Indexed.MenuitemType"]; - var DOM_HTML_Indexed_OnOff = PS["DOM.HTML.Indexed.OnOff"]; - var DOM_HTML_Indexed_OrderedListType = PS["DOM.HTML.Indexed.OrderedListType"]; - var DOM_HTML_Indexed_PreloadValue = PS["DOM.HTML.Indexed.PreloadValue"]; - var DOM_HTML_Indexed_ScopeValue = PS["DOM.HTML.Indexed.ScopeValue"]; - var DOM_HTML_Indexed_StepValue = PS["DOM.HTML.Indexed.StepValue"]; - var DOM_HTML_Indexed_WrapValue = PS["DOM.HTML.Indexed.WrapValue"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Generic = PS["Data.Generic"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_MediaType = PS["Data.MediaType"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Halogen_VDom = PS["Halogen.VDom"]; - var Halogen_VDom_DOM_Prop = PS["Halogen.VDom.DOM.Prop"]; - var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var HTML = function (x) { - return x; - }; - var ClassName = function (x) { - return x; - }; - var IsProp = function (toPropValue) { - this.toPropValue = toPropValue; - }; - var toPropValue = function (dict) { - return dict.toPropValue; - }; - var text = function ($54) { - return HTML(Halogen_VDom_Types.Text.create($54)); - }; - var stringIsProp = new IsProp(Halogen_VDom_DOM_Prop.propFromString); - var slot = function ($56) { - return HTML(Halogen_VDom_Types.Widget.create($56)); - }; - var prop = function (dictIsProp) { - return function (v) { - return function ($59) { - return Halogen_VDom_DOM_Prop.Property.create(v)(toPropValue(dictIsProp)($59)); - }; - }; - }; - var newtypeClassName = new Data_Newtype.Newtype(function (n) { - return n; - }, ClassName); - var handler = Halogen_VDom_DOM_Prop.Handler.create; - var element = function (ns) { - return Unsafe_Coerce.unsafeCoerce(function (name) { - return function (props) { - return function (children) { - return new Halogen_VDom_Types.Elem(new Halogen_VDom_Types.ElemSpec(ns, name, props), children); - }; - }; - }); - }; - var bifunctorHTML = new Data_Bifunctor.Bifunctor(function (f) { - return function (g) { - return function (v) { - return Data_Bifunctor.bimap(Halogen_VDom_Types.bifunctorVDom)(Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Halogen_VDom_DOM_Prop.functorProp)(Data_Functor.map(Halogen_Query_InputF.functorInputF)(g))))(f)(v); - }; - }; - }); - var attr = function (ns) { - return function (v) { - return Halogen_VDom_DOM_Prop.Attribute.create(ns)(v); - }; - }; - exports["ClassName"] = ClassName; - exports["HTML"] = HTML; - exports["IsProp"] = IsProp; - exports["attr"] = attr; - exports["element"] = element; - exports["handler"] = handler; - exports["prop"] = prop; - exports["slot"] = slot; - exports["text"] = text; - exports["toPropValue"] = toPropValue; - exports["bifunctorHTML"] = bifunctorHTML; - exports["stringIsProp"] = stringIsProp; - exports["newtypeClassName"] = newtypeClassName; -})(PS["Halogen.HTML.Core"] = PS["Halogen.HTML.Core"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var runExists = Unsafe_Coerce.unsafeCoerce; - var mkExists = Unsafe_Coerce.unsafeCoerce; - exports["mkExists"] = mkExists; - exports["runExists"] = runExists; -})(PS["Data.Exists"] = PS["Data.Exists"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Const = PS["Data.Const"]; - var Data_Exists = PS["Data.Exists"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var ApF = (function () { - function ApF(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - ApF.create = function (value0) { - return function (value1) { - return new ApF(value0, value1); - }; - }; - return ApF; - })(); - var Pure = (function () { - function Pure(value0) { - this.value0 = value0; - }; - Pure.create = function (value0) { - return new Pure(value0); - }; - return Pure; - })(); - var Ap = (function () { - function Ap(value0) { - this.value0 = value0; - }; - Ap.create = function (value0) { - return new Ap(value0); - }; - return Ap; - })(); - var retractFreeAp = function (dictApplicative) { - return function (v) { - if (v instanceof Pure) { - return Control_Applicative.pure(dictApplicative)(v.value0); - }; - if (v instanceof Ap) { - return Data_Exists.runExists(function (v1) { - return Control_Apply.apply(dictApplicative.Apply0())(retractFreeAp(dictApplicative)(v1.value1(Data_Unit.unit)))(v1.value0(Data_Unit.unit)); - })(v.value0); - }; - throw new Error("Failed pattern match at Control.Applicative.Free line 32, column 1 - line 32, column 64: " + [ v.constructor.name ]); - }; - }; - var ap = function (v) { - return function (k) { - return new Ap(Data_Exists.mkExists(new ApF(v, k))); - }; - }; - var hoistFreeAp = function (k) { - return function (v) { - if (v instanceof Pure) { - return new Pure(v.value0); - }; - if (v instanceof Ap) { - return Data_Exists.runExists(function (v1) { - return ap(function (v3) { - return k(v1.value0(Data_Unit.unit)); - })(function (v3) { - return hoistFreeAp(k)(v1.value1(Data_Unit.unit)); - }); - })(v.value0); - }; - throw new Error("Failed pattern match at Control.Applicative.Free line 44, column 1 - line 44, column 66: " + [ k.constructor.name, v.constructor.name ]); - }; - }; - exports["hoistFreeAp"] = hoistFreeAp; - exports["retractFreeAp"] = retractFreeAp; -})(PS["Control.Applicative.Free"] = PS["Control.Applicative.Free"] || {}); -(function(exports) { - /* globals setTimeout, clearTimeout, setImmediate, clearImmediate */ - "use strict"; - - exports._cancelWith = function (nonCanceler, aff, canceler1) { - return function (success, error) { - var canceler2 = aff(success, error); - - return function (e) { - return function (success, error) { - var cancellations = 0; - var result = false; - var errored = false; - - var s = function (bool) { - cancellations = cancellations + 1; - result = result || bool; - - if (cancellations === 2 && !errored) { - success(result); - } - }; - - var f = function (err) { - if (!errored) { - errored = true; - error(err); - } - }; - - canceler2(e)(s, f); - canceler1(e)(s, f); - - return nonCanceler; - }; - }; - }; - }; - - exports._forkAff = function (nonCanceler, aff) { - var voidF = function () {}; - - return function (success) { - var canceler = aff(voidF, voidF); - success(canceler); - return nonCanceler; - }; - }; - - exports._forkAll = function (nonCanceler, foldl, affs) { - var voidF = function () {}; - - return function (success) { - var cancelers = foldl(function (acc) { - return function (aff) { - acc.push(aff(voidF, voidF)); - return acc; - }; - })([])(affs); - - var canceler = function (e) { - return function (success, error) { - var cancellations = 0; - var result = false; - var errored = false; - - var s = function (bool) { - cancellations = cancellations + 1; - result = result || bool; - - if (cancellations === cancelers.length && !errored) { - success(result); - } - }; - - var f = function (err) { - if (!errored) { - errored = true; - error(err); - } - }; - - for (var i = 0; i < cancelers.length; i++) { - cancelers[i](e)(s, f); - } - - return nonCanceler; - }; - }; - - success(canceler); - return nonCanceler; - }; - }; - - exports._makeAff = function (cb) { - return function (success, error) { - try { - return cb(function (e) { - return function () { - error(e); - }; - })(function (v) { - return function () { - success(v); - }; - })(); - } catch (err) { - error(err); - } - }; - }; - - exports._pure = function (nonCanceler, v) { - return function (success) { - success(v); - return nonCanceler; - }; - }; - - exports._throwError = function (nonCanceler, e) { - return function (success, error) { - error(e); - return nonCanceler; - }; - }; - - exports._fmap = function (f, aff) { - return function (success, error) { - return aff(function (v) { - success(f(v)); - }, error); - }; - }; - - exports._bind = function (alwaysCanceler, aff, f) { - return function (success, error) { - var canceler1, canceler2; - - var isCanceled = false; - var requestCancel = false; - - var onCanceler = function () {}; - - canceler1 = aff(function (v) { - if (requestCancel) { - isCanceled = true; - - return alwaysCanceler; - } else { - canceler2 = f(v)(success, error); - - onCanceler(canceler2); - - return canceler2; - } - }, error); - - return function (e) { - return function (s, f) { - requestCancel = true; - - if (canceler2 !== undefined) { - return canceler2(e)(s, f); - } else { - return canceler1(e)(function (bool) { - if (bool || isCanceled) { - s(true); - } else { - onCanceler = function (canceler) { - canceler(e)(s, f); - }; - } - }, f); - } - }; - }; - }; - }; - - exports._attempt = function (Left, Right, aff) { - return function (success) { - return aff(function (v) { - success(Right(v)); - }, function (e) { - success(Left(e)); - }); - }; - }; - - exports._runAff = function (errorT, successT, aff) { - // If errorT or successT throw, and an Aff is comprised only of synchronous - // effects, then it's possible for makeAff/liftEff to accidentally catch - // it, which may end up rerunning the Aff depending on error recovery - // behavior. To mitigate this, we observe synchronicity using mutation. If - // an Aff is observed to be synchronous, we let the stack reset and run the - // handlers outside of the normal callback flow. - return function () { - var status = 0; - var result, success; - - var canceler = aff(function (v) { - if (status === 2) { - successT(v)(); - } else { - status = 1; - result = v; - success = true; - } - }, function (e) { - if (status === 2) { - errorT(e)(); - } else { - status = 1; - result = e; - success = false; - } - }); - - if (status === 1) { - if (success) { - successT(result)(); - } else { - errorT(result)(); - } - } else { - status = 2; - } - - return canceler; - }; - }; - - exports._liftEff = function (nonCanceler, e) { - return function (success, error) { - var result; - try { - result = e(); - } catch (err) { - error(err); - return nonCanceler; - } - - success(result); - return nonCanceler; - }; - }; - - exports._tailRecM = function (isLeft, f, a) { - return function (success, error) { - return function go (acc) { - var result, status, canceler; - - // Observes synchronous effects using a flag. - // status = 0 (unresolved status) - // status = 1 (synchronous effect) - // status = 2 (asynchronous effect) - - var csuccess = function (v) { - // If the status is still unresolved, we have observed a - // synchronous effect. Otherwise, the status will be `2`. - if (status === 0) { - // Store the result for further synchronous processing. - result = v; - status = 1; - } else { - // When we have observed an asynchronous effect, we use normal - // recursion. This is safe because we will be on a new stack. - if (isLeft(v)) { - go(v.value0); - } else { - success(v.value0); - } - } - }; - - while (true) { - status = 0; - canceler = f(acc)(csuccess, error); - - // If the status has already resolved to `1` by our Aff handler, then - // we have observed a synchronous effect. Otherwise it will still be - // `0`. - if (status === 1) { - // When we have observed a synchronous effect, we merely swap out the - // accumulator and continue the loop, preserving stack. - if (isLeft(result)) { - acc = result.value0; - continue; - } else { - success(result.value0); - } - } else { - // If the status has not resolved yet, then we have observed an - // asynchronous effect. - status = 2; - } - return canceler; - } - - }(a); - }; - }; -})(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}); -(function(exports) { - "use strict"; - - exports._makeVar = function (nonCanceler) { - return function (success) { - success({ - consumers: [], - producers: [], - error: undefined - }); - return nonCanceler; - }; - }; - - exports._takeVar = function (nonCanceler, avar) { - return function (success, error) { - if (avar.error !== undefined) { - error(avar.error); - } else if (avar.producers.length > 0) { - avar.producers.shift()(success, error); - } else { - avar.consumers.push({ peek: false, success: success, error: error }); - } - - return nonCanceler; - }; - }; - - exports._peekVar = function (nonCanceler, avar) { - return function (success, error) { - if (avar.error !== undefined) { - error(avar.error); - } else if (avar.producers.length > 0) { - avar.producers[0](success, error); - } else { - avar.consumers.push({ peek: true, success: success, error: error }); - } - return nonCanceler; - }; - }; - - exports._putVar = function (nonCanceler, avar, a) { - return function (success, error) { - if (avar.error !== undefined) { - error(avar.error); - } else { - var shouldQueue = true; - var consumers = []; - var consumer; - - while (true) { - consumer = avar.consumers.shift(); - if (consumer) { - consumers.push(consumer); - if (consumer.peek) { - continue; - } else { - shouldQueue = false; - } - } - break; - } - - if (shouldQueue) { - avar.producers.push(function (success) { - success(a); - return nonCanceler; - }); - } - - for (var i = 0; i < consumers.length; i++) { - consumers[i].success(a); - } - - success({}); - } - - return nonCanceler; - }; - }; - - exports._killVar = function (nonCanceler, avar, e) { - return function (success, error) { - if (avar.error !== undefined) { - error(avar.error); - } else { - avar.error = e; - while (avar.consumers.length) { - avar.consumers.shift().error(e); - } - success({}); - } - - return nonCanceler; - }; - }; -})(PS["Control.Monad.Aff.Internal"] = PS["Control.Monad.Aff.Internal"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Aff.Internal"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - exports["_killVar"] = $foreign._killVar; - exports["_makeVar"] = $foreign._makeVar; - exports["_peekVar"] = $foreign._peekVar; - exports["_putVar"] = $foreign._putVar; - exports["_takeVar"] = $foreign._takeVar; -})(PS["Control.Monad.Aff.Internal"] = PS["Control.Monad.Aff.Internal"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Cont_Trans = PS["Control.Monad.Cont.Trans"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Monad_Maybe_Trans = PS["Control.Monad.Maybe.Trans"]; - var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; - var Control_Monad_Writer_Trans = PS["Control.Monad.Writer.Trans"]; - var Control_Plus = PS["Control.Plus"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Functor_Compose = PS["Data.Functor.Compose"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Parallel = function (Applicative1, Monad0, parallel, sequential) { - this.Applicative1 = Applicative1; - this.Monad0 = Monad0; - this.parallel = parallel; - this.sequential = sequential; - }; - var sequential = function (dict) { - return dict.sequential; - }; - var parallel = function (dict) { - return dict.parallel; - }; - exports["Parallel"] = Parallel; - exports["parallel"] = parallel; - exports["sequential"] = sequential; -})(PS["Control.Parallel.Class"] = PS["Control.Parallel.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Control.Monad.Aff"]; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Aff_Internal = PS["Control.Monad.Aff.Internal"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_MonadPlus = PS["Control.MonadPlus"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Parallel = PS["Control.Parallel"]; - var Control_Parallel_Class = PS["Control.Parallel.Class"]; - var Control_Plus = PS["Control.Plus"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Time_Duration = PS["Data.Time.Duration"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var ParAff = function (x) { - return x; - }; - var runAff = function (ex) { - return function (f) { - return function (aff) { - return $foreign._runAff(ex, f, aff); - }; - }; - }; - var makeAff$prime = function (h) { - return $foreign._makeAff(h); - }; - var functorAff = new Data_Functor.Functor(function (f) { - return function (fa) { - return $foreign._fmap(f, fa); - }; - }); - var functorParAff = functorAff; - var fromAVBox = Unsafe_Coerce.unsafeCoerce; - var cancel = function (v) { - return v; - }; - var attempt = function (aff) { - return $foreign._attempt(Data_Either.Left.create, Data_Either.Right.create, aff); - }; - var applyAff = new Control_Apply.Apply(function () { - return functorAff; - }, function (ff) { - return function (fa) { - return $foreign._bind(alwaysCanceler, ff, function (f) { - return Data_Functor.map(functorAff)(f)(fa); - }); - }; - }); - var applicativeAff = new Control_Applicative.Applicative(function () { - return applyAff; - }, function (v) { - return $foreign._pure(nonCanceler, v); - }); - var nonCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(false)); - var alwaysCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(true)); - var cancelWith = function (aff) { - return function (c) { - return $foreign._cancelWith(nonCanceler, aff, c); - }; - }; - var forkAff = function (aff) { - return $foreign._forkAff(nonCanceler, aff); - }; - var forkAll = function (dictFoldable) { - return function (affs) { - return $foreign._forkAll(nonCanceler, Data_Foldable.foldl(dictFoldable), affs); - }; - }; - var killVar = function (q) { - return function (e) { - return fromAVBox(Control_Monad_Aff_Internal._killVar(nonCanceler, q, e)); - }; - }; - var makeAff = function (h) { - return makeAff$prime(function (e) { - return function (a) { - return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Function["const"](nonCanceler))(h(e)(a)); - }; - }); - }; - var makeVar = fromAVBox(Control_Monad_Aff_Internal._makeVar(nonCanceler)); - var putVar = function (q) { - return function (a) { - return fromAVBox(Control_Monad_Aff_Internal._putVar(nonCanceler, q, a)); - }; - }; - var takeVar = function (q) { - return fromAVBox(Control_Monad_Aff_Internal._takeVar(nonCanceler, q)); - }; - var semigroupCanceler = new Data_Semigroup.Semigroup(function (v) { - return function (v1) { - return function (e) { - return Control_Apply.apply(applyAff)(Data_Functor.map(functorAff)(Data_HeytingAlgebra.disj(Data_HeytingAlgebra.heytingAlgebraBoolean))(v(e)))(v1(e)); - }; - }; - }); - var bindAff = new Control_Bind.Bind(function () { - return applyAff; - }, function (fa) { - return function (f) { - return $foreign._bind(alwaysCanceler, fa, f); - }; - }); - var applyParAff = new Control_Apply.Apply(function () { - return functorParAff; - }, function (v) { - return function (v1) { - var putOrKill = function (v2) { - return Data_Either.either(killVar(v2))(putVar(v2)); - }; - return Control_Bind.bind(bindAff)(makeVar)(function (v2) { - return Control_Bind.bind(bindAff)(makeVar)(function (v3) { - return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(putOrKill(v2))(attempt(v))))(function (v4) { - return Control_Bind.bind(bindAff)(forkAff(Control_Bind.bindFlipped(bindAff)(putOrKill(v3))(attempt(v1))))(function (v5) { - return cancelWith(Control_Apply.apply(applyAff)(takeVar(v2))(takeVar(v3)))(Data_Semigroup.append(semigroupCanceler)(v4)(v5)); - }); - }); - }); - }); - }; - }); - var applicativeParAff = new Control_Applicative.Applicative(function () { - return applyParAff; - }, function ($56) { - return ParAff(Control_Applicative.pure(applicativeAff)($56)); - }); - var monadAff = new Control_Monad.Monad(function () { - return applicativeAff; - }, function () { - return bindAff; - }); - var monadEffAff = new Control_Monad_Eff_Class.MonadEff(function () { - return monadAff; - }, function (eff) { - return $foreign._liftEff(nonCanceler, eff); - }); - var monadRecAff = new Control_Monad_Rec_Class.MonadRec(function () { - return monadAff; - }, function (f) { - return function (a) { - var isLoop = function (v) { - if (v instanceof Control_Monad_Rec_Class.Loop) { - return true; - }; - return false; - }; - return $foreign._tailRecM(isLoop, f, a); - }; - }); - var monadThrowAff = new Control_Monad_Error_Class.MonadThrow(function () { - return monadAff; - }, function (e) { - return $foreign._throwError(nonCanceler, e); - }); - var parallelParAff = new Control_Parallel_Class.Parallel(function () { - return applicativeParAff; - }, function () { - return monadAff; - }, ParAff, function (v) { - return v; - }); - exports["ParAff"] = ParAff; - exports["attempt"] = attempt; - exports["cancel"] = cancel; - exports["cancelWith"] = cancelWith; - exports["forkAff"] = forkAff; - exports["forkAll"] = forkAll; - exports["makeAff"] = makeAff; - exports["nonCanceler"] = nonCanceler; - exports["runAff"] = runAff; - exports["functorAff"] = functorAff; - exports["applyAff"] = applyAff; - exports["applicativeAff"] = applicativeAff; - exports["bindAff"] = bindAff; - exports["monadAff"] = monadAff; - exports["monadEffAff"] = monadEffAff; - exports["monadThrowAff"] = monadThrowAff; - exports["monadRecAff"] = monadRecAff; - exports["semigroupCanceler"] = semigroupCanceler; - exports["functorParAff"] = functorParAff; - exports["applyParAff"] = applyParAff; - exports["applicativeParAff"] = applicativeParAff; - exports["parallelParAff"] = parallelParAff; -})(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Reader_Trans = PS["Control.Monad.Reader.Trans"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Functor = PS["Data.Functor"]; - var Prelude = PS["Prelude"]; - var MonadFork = function (Monad0, fork) { - this.Monad0 = Monad0; - this.fork = fork; - }; - var monadForkAff = new MonadFork(function () { - return Control_Monad_Aff.monadAff; - }, function ($3) { - return Data_Functor.map(Control_Monad_Aff.functorAff)(Control_Monad_Aff.cancel)(Control_Monad_Aff.forkAff($3)); - }); - var fork = function (dict) { - return dict.fork; - }; - exports["MonadFork"] = MonadFork; - exports["fork"] = fork; - exports["monadForkAff"] = monadForkAff; -})(PS["Control.Monad.Fork.Class"] = PS["Control.Monad.Fork.Class"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_Tuple = PS["Data.Tuple"]; - var CatQueue = (function () { - function CatQueue(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - CatQueue.create = function (value0) { - return function (value1) { - return new CatQueue(value0, value1); - }; - }; - return CatQueue; - })(); - var uncons = function ($copy_v) { - var $tco_done = false; - var $tco_result; - function $tco_loop(v) { - if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) { - $tco_done = true; - return Data_Maybe.Nothing.value; - }; - if (v.value0 instanceof Data_List_Types.Nil) { - $copy_v = new CatQueue(Data_List.reverse(v.value1), Data_List_Types.Nil.value); - return; - }; - if (v.value0 instanceof Data_List_Types.Cons) { - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0.value0, new CatQueue(v.value0.value1, v.value1))); - }; - throw new Error("Failed pattern match at Data.CatQueue line 50, column 1 - line 50, column 63: " + [ v.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($copy_v); - }; - return $tco_result; - }; - var snoc = function (v) { - return function (a) { - return new CatQueue(v.value0, new Data_List_Types.Cons(a, v.value1)); - }; - }; - var $$null = function (v) { - if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) { - return true; - }; - return false; - }; - var empty = new CatQueue(Data_List_Types.Nil.value, Data_List_Types.Nil.value); - exports["CatQueue"] = CatQueue; - exports["empty"] = empty; - exports["null"] = $$null; - exports["snoc"] = snoc; - exports["uncons"] = uncons; -})(PS["Data.CatQueue"] = PS["Data.CatQueue"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Alt = PS["Control.Alt"]; - var Control_Alternative = PS["Control.Alternative"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad = PS["Control.Monad"]; - var Control_MonadPlus = PS["Control.MonadPlus"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Plus = PS["Control.Plus"]; - var Data_CatQueue = PS["Data.CatQueue"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_NaturalTransformation = PS["Data.NaturalTransformation"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var CatNil = (function () { - function CatNil() { - - }; - CatNil.value = new CatNil(); - return CatNil; - })(); - var CatCons = (function () { - function CatCons(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - CatCons.create = function (value0) { - return function (value1) { - return new CatCons(value0, value1); - }; - }; - return CatCons; - })(); - var link = function (v) { - return function (cat) { - if (v instanceof CatNil) { - return cat; - }; - if (v instanceof CatCons) { - return new CatCons(v.value0, Data_CatQueue.snoc(v.value1)(cat)); - }; - throw new Error("Failed pattern match at Data.CatList line 110, column 1 - line 110, column 54: " + [ v.constructor.name, cat.constructor.name ]); - }; - }; - var foldr = function (k) { - return function (b) { - return function (q) { - var foldl = function ($copy_v) { - return function ($copy_c) { - return function ($copy_v1) { - var $tco_var_v = $copy_v; - var $tco_var_c = $copy_c; - var $tco_done = false; - var $tco_result; - function $tco_loop(v, c, v1) { - if (v1 instanceof Data_List_Types.Nil) { - $tco_done = true; - return c; - }; - if (v1 instanceof Data_List_Types.Cons) { - $tco_var_v = v; - $tco_var_c = v(c)(v1.value0); - $copy_v1 = v1.value1; - return; - }; - throw new Error("Failed pattern match at Data.CatList line 125, column 3 - line 125, column 59: " + [ v.constructor.name, c.constructor.name, v1.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_v, $tco_var_c, $copy_v1); - }; - return $tco_result; - }; - }; - }; - var go = function ($copy_xs) { - return function ($copy_ys) { - var $tco_var_xs = $copy_xs; - var $tco_done = false; - var $tco_result; - function $tco_loop(xs, ys) { - var v = Data_CatQueue.uncons(xs); - if (v instanceof Data_Maybe.Nothing) { - $tco_done = true; - return foldl(function (x) { - return function (i) { - return i(x); - }; - })(b)(ys); - }; - if (v instanceof Data_Maybe.Just) { - $tco_var_xs = v.value0.value1; - $copy_ys = new Data_List_Types.Cons(k(v.value0.value0), ys); - return; - }; - throw new Error("Failed pattern match at Data.CatList line 121, column 14 - line 123, column 67: " + [ v.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_xs, $copy_ys); - }; - return $tco_result; - }; - }; - return go(q)(Data_List_Types.Nil.value); - }; - }; - }; - var uncons = function (v) { - if (v instanceof CatNil) { - return Data_Maybe.Nothing.value; - }; - if (v instanceof CatCons) { - return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, (function () { - var $41 = Data_CatQueue["null"](v.value1); - if ($41) { - return CatNil.value; - }; - return foldr(link)(CatNil.value)(v.value1); - })())); - }; - throw new Error("Failed pattern match at Data.CatList line 101, column 1 - line 101, column 61: " + [ v.constructor.name ]); - }; - var empty = CatNil.value; - var append = function (v) { - return function (v1) { - if (v1 instanceof CatNil) { - return v; - }; - if (v instanceof CatNil) { - return v1; - }; - return link(v)(v1); - }; - }; - var semigroupCatList = new Data_Semigroup.Semigroup(append); - var snoc = function (cat) { - return function (a) { - return append(cat)(new CatCons(a, Data_CatQueue.empty)); - }; - }; - exports["CatNil"] = CatNil; - exports["CatCons"] = CatCons; - exports["append"] = append; - exports["empty"] = empty; - exports["snoc"] = snoc; - exports["uncons"] = uncons; - exports["semigroupCatList"] = semigroupCatList; -})(PS["Data.CatList"] = PS["Data.CatList"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_CatList = PS["Data.CatList"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var Free = (function () { - function Free(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Free.create = function (value0) { - return function (value1) { - return new Free(value0, value1); - }; - }; - return Free; - })(); - var Return = (function () { - function Return(value0) { - this.value0 = value0; - }; - Return.create = function (value0) { - return new Return(value0); - }; - return Return; - })(); - var Bind = (function () { - function Bind(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Bind.create = function (value0) { - return function (value1) { - return new Bind(value0, value1); - }; - }; - return Bind; - })(); - var toView = function ($copy_v) { - var $tco_done = false; - var $tco_result; - function $tco_loop(v) { - var runExpF = function (v2) { - return v2; - }; - var concatF = function (v2) { - return function (r) { - return new Free(v2.value0, Data_Semigroup.append(Data_CatList.semigroupCatList)(v2.value1)(r)); - }; - }; - if (v.value0 instanceof Return) { - var v2 = Data_CatList.uncons(v.value1); - if (v2 instanceof Data_Maybe.Nothing) { - $tco_done = true; - return new Return(Unsafe_Coerce.unsafeCoerce(v.value0.value0)); - }; - if (v2 instanceof Data_Maybe.Just) { - $copy_v = Unsafe_Coerce.unsafeCoerce(concatF(runExpF(v2.value0.value0)(v.value0.value0))(v2.value0.value1)); - return; - }; - throw new Error("Failed pattern match at Control.Monad.Free line 215, column 7 - line 219, column 64: " + [ v2.constructor.name ]); - }; - if (v.value0 instanceof Bind) { - $tco_done = true; - return new Bind(v.value0.value0, function (a) { - return Unsafe_Coerce.unsafeCoerce(concatF(v.value0.value1(a))(v.value1)); - }); - }; - throw new Error("Failed pattern match at Control.Monad.Free line 213, column 3 - line 221, column 56: " + [ v.value0.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($copy_v); - }; - return $tco_result; - }; - var fromView = function (f) { - return new Free(Unsafe_Coerce.unsafeCoerce(f), Data_CatList.empty); - }; - var freeMonad = new Control_Monad.Monad(function () { - return freeApplicative; - }, function () { - return freeBind; - }); - var freeFunctor = new Data_Functor.Functor(function (k) { - return function (f) { - return Control_Bind.bindFlipped(freeBind)(function ($118) { - return Control_Applicative.pure(freeApplicative)(k($118)); - })(f); - }; - }); - var freeBind = new Control_Bind.Bind(function () { - return freeApply; - }, function (v) { - return function (k) { - return new Free(v.value0, Data_CatList.snoc(v.value1)(Unsafe_Coerce.unsafeCoerce(k))); - }; - }); - var freeApply = new Control_Apply.Apply(function () { - return freeFunctor; - }, Control_Monad.ap(freeMonad)); - var freeApplicative = new Control_Applicative.Applicative(function () { - return freeApply; - }, function ($119) { - return fromView(Return.create($119)); - }); - var liftF = function (f) { - return fromView(new Bind(Unsafe_Coerce.unsafeCoerce(f), function ($120) { - return Control_Applicative.pure(freeApplicative)(Unsafe_Coerce.unsafeCoerce($120)); - })); - }; - var foldFree = function (dictMonadRec) { - return function (k) { - var go = function (f) { - var v = toView(f); - if (v instanceof Return) { - return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(v.value0)); - }; - if (v instanceof Bind) { - return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(function ($127) { - return Control_Monad_Rec_Class.Loop.create(v.value1($127)); - })(k(v.value0)); - }; - throw new Error("Failed pattern match at Control.Monad.Free line 146, column 10 - line 148, column 37: " + [ v.constructor.name ]); - }; - return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); - }; - }; - exports["foldFree"] = foldFree; - exports["liftF"] = liftF; - exports["freeFunctor"] = freeFunctor; - exports["freeBind"] = freeBind; - exports["freeApplicative"] = freeApplicative; - exports["freeApply"] = freeApply; - exports["freeMonad"] = freeMonad; -})(PS["Control.Monad.Free"] = PS["Control.Monad.Free"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Comonad = PS["Control.Comonad"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Exists = PS["Data.Exists"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - var unCoyoneda = function (f) { - return function (v) { - return Data_Exists.runExists(function (v1) { - return f(v1.value0)(v1.value1); - })(v); - }; - }; - exports["unCoyoneda"] = unCoyoneda; -})(PS["Data.Coyoneda"] = PS["Data.Coyoneda"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Either = PS["Data.Either"]; - var Data_Exists = PS["Data.Exists"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Bound = (function () { - function Bound(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Bound.create = function (value0) { - return function (value1) { - return new Bound(value0, value1); - }; - }; - return Bound; - })(); - var FreeT = (function () { - function FreeT(value0) { - this.value0 = value0; - }; - FreeT.create = function (value0) { - return new FreeT(value0); - }; - return FreeT; - })(); - var Bind = (function () { - function Bind(value0) { - this.value0 = value0; - }; - Bind.create = function (value0) { - return new Bind(value0); - }; - return Bind; - })(); - var monadTransFreeT = function (dictFunctor) { - return new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) { - return function (ma) { - return new FreeT(function (v) { - return Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Either.Left.create)(ma); - }); - }; - }); - }; - var freeT = FreeT.create; - var bound = function (m) { - return function (f) { - return new Bind(Data_Exists.mkExists(new Bound(m, f))); - }; - }; - var functorFreeT = function (dictFunctor) { - return function (dictFunctor1) { - return new Data_Functor.Functor(function (f) { - return function (v) { - if (v instanceof FreeT) { - return new FreeT(function (v1) { - return Data_Functor.map(dictFunctor1)(Data_Bifunctor.bimap(Data_Either.bifunctorEither)(f)(Data_Functor.map(dictFunctor)(Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f))))(v.value0(Data_Unit.unit)); - }); - }; - if (v instanceof Bind) { - return Data_Exists.runExists(function (v1) { - return bound(v1.value0)(function ($104) { - return Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f)(v1.value1($104)); - }); - })(v.value0); - }; - throw new Error("Failed pattern match at Control.Monad.Free.Trans line 58, column 1 - line 58, column 71: " + [ f.constructor.name, v.constructor.name ]); - }; - }); - }; - }; - var monadFreeT = function (dictFunctor) { - return function (dictMonad) { - return new Control_Monad.Monad(function () { - return applicativeFreeT(dictFunctor)(dictMonad); - }, function () { - return bindFreeT(dictFunctor)(dictMonad); - }); - }; - }; - var bindFreeT = function (dictFunctor) { - return function (dictMonad) { - return new Control_Bind.Bind(function () { - return applyFreeT(dictFunctor)(dictMonad); - }, function (v) { - return function (f) { - if (v instanceof Bind) { - return Data_Exists.runExists(function (v1) { - return bound(v1.value0)(function (x) { - return bound(function (v2) { - return v1.value1(x); - })(f); - }); - })(v.value0); - }; - return bound(function (v1) { - return v; - })(f); - }; - }); - }; - }; - var applyFreeT = function (dictFunctor) { - return function (dictMonad) { - return new Control_Apply.Apply(function () { - return functorFreeT(dictFunctor)(((dictMonad.Bind1()).Apply0()).Functor0()); - }, Control_Monad.ap(monadFreeT(dictFunctor)(dictMonad))); - }; - }; - var applicativeFreeT = function (dictFunctor) { - return function (dictMonad) { - return new Control_Applicative.Applicative(function () { - return applyFreeT(dictFunctor)(dictMonad); - }, function (a) { - return new FreeT(function (v) { - return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Left(a)); - }); - }); - }; - }; - var liftFreeT = function (dictFunctor) { - return function (dictMonad) { - return function (fa) { - return new FreeT(function (v) { - return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(Data_Functor.map(dictFunctor)(Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad)))(fa))); - }); - }; - }; - }; - var resume = function (dictFunctor) { - return function (dictMonadRec) { - var go = function (v) { - if (v instanceof FreeT) { - return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(v.value0(Data_Unit.unit)); - }; - if (v instanceof Bind) { - return Data_Exists.runExists(function (v1) { - var v2 = v1.value0(Data_Unit.unit); - if (v2 instanceof FreeT) { - return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(v2.value0(Data_Unit.unit))(function (v3) { - if (v3 instanceof Data_Either.Left) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop(v1.value1(v3.value0))); - }; - if (v3 instanceof Data_Either.Right) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(new Data_Either.Right(Data_Functor.map(dictFunctor)(function (h) { - return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(h)(v1.value1); - })(v3.value0)))); - }; - throw new Error("Failed pattern match at Control.Monad.Free.Trans line 53, column 20 - line 55, column 67: " + [ v3.constructor.name ]); - }); - }; - if (v2 instanceof Bind) { - return Data_Exists.runExists(function (v3) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Loop(Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(v3.value0(Data_Unit.unit))(function (z) { - return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonadRec.Monad0()))(v3.value1(z))(v1.value1); - }))); - })(v2.value0); - }; - throw new Error("Failed pattern match at Control.Monad.Free.Trans line 51, column 5 - line 56, column 98: " + [ v2.constructor.name ]); - })(v.value0); - }; - throw new Error("Failed pattern match at Control.Monad.Free.Trans line 48, column 3 - line 48, column 75: " + [ v.constructor.name ]); - }; - return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go); - }; - }; - var runFreeT = function (dictFunctor) { - return function (dictMonadRec) { - return function (interp) { - var go = function (v) { - if (v instanceof Data_Either.Left) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Control_Monad_Rec_Class.Done(v.value0)); - }; - if (v instanceof Data_Either.Right) { - return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Loop.create)(interp(v.value0)); - }; - throw new Error("Failed pattern match at Control.Monad.Free.Trans line 127, column 3 - line 127, column 63: " + [ v.constructor.name ]); - }; - return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(Control_Bind.composeKleisliFlipped((dictMonadRec.Monad0()).Bind1())(go)(resume(dictFunctor)(dictMonadRec))); - }; - }; - }; - var monadRecFreeT = function (dictFunctor) { - return function (dictMonad) { - return new Control_Monad_Rec_Class.MonadRec(function () { - return monadFreeT(dictFunctor)(dictMonad); - }, function (f) { - var go = function (s) { - return Control_Bind.bind(bindFreeT(dictFunctor)(dictMonad))(f(s))(function (v) { - if (v instanceof Control_Monad_Rec_Class.Loop) { - return go(v.value0); - }; - if (v instanceof Control_Monad_Rec_Class.Done) { - return Control_Applicative.pure(applicativeFreeT(dictFunctor)(dictMonad))(v.value0); - }; - throw new Error("Failed pattern match at Control.Monad.Free.Trans line 81, column 15 - line 83, column 25: " + [ v.constructor.name ]); - }); - }; - return go; - }); - }; - }; - exports["freeT"] = freeT; - exports["liftFreeT"] = liftFreeT; - exports["resume"] = resume; - exports["runFreeT"] = runFreeT; - exports["functorFreeT"] = functorFreeT; - exports["applyFreeT"] = applyFreeT; - exports["applicativeFreeT"] = applicativeFreeT; - exports["bindFreeT"] = bindFreeT; - exports["monadFreeT"] = monadFreeT; - exports["monadTransFreeT"] = monadTransFreeT; - exports["monadRecFreeT"] = monadRecFreeT; -})(PS["Control.Monad.Free.Trans"] = PS["Control.Monad.Free.Trans"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Except = PS["Control.Monad.Except"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Parallel = PS["Control.Parallel"]; - var Control_Parallel_Class = PS["Control.Parallel.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Either = PS["Data.Either"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Emit = (function () { - function Emit(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Emit.create = function (value0) { - return function (value1) { - return new Emit(value0, value1); - }; - }; - return Emit; - })(); - var runProcess = function (dictMonadRec) { - return Control_Monad_Free_Trans.runFreeT(Data_Identity.functorIdentity)(dictMonadRec)(function ($186) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(Data_Newtype.unwrap(Data_Identity.newtypeIdentity)($186)); - }); - }; - var profunctorAwait = new Data_Profunctor.Profunctor(function (f) { - return function (g) { - return function (v) { - return Data_Profunctor.dimap(Data_Profunctor.profunctorFn)(f)(g)(v); - }; - }; - }); - var loop = function (dictFunctor) { - return function (dictMonad) { - return function (me) { - return Control_Monad_Rec_Class.tailRecM(Control_Monad_Free_Trans.monadRecFreeT(dictFunctor)(dictMonad))(function (v) { - return Data_Functor.map(Control_Monad_Free_Trans.functorFreeT(dictFunctor)(((dictMonad.Bind1()).Apply0()).Functor0()))(Data_Maybe.maybe(new Control_Monad_Rec_Class.Loop(Data_Unit.unit))(Control_Monad_Rec_Class.Done.create))(me); - })(Data_Unit.unit); - }; - }; - }; - var fuseWithL = function (dictFunctor) { - return function (dictFunctor1) { - return function (dictFunctor2) { - return function (dictMonadRec) { - return function (zap) { - return function (fs) { - return function (gs) { - var go = function (v) { - return Control_Monad_Except_Trans.runExceptT(Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(dictMonadRec.Monad0()))(Control_Monad_Except_Trans.ExceptT(Control_Monad_Free_Trans.resume(dictFunctor)(dictMonadRec)(v.value0)))(function (v1) { - return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(dictMonadRec.Monad0()))(Control_Monad_Except_Trans.ExceptT(Control_Monad_Free_Trans.resume(dictFunctor1)(dictMonadRec)(v.value1)))(function (v2) { - return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonadRec.Monad0()))(Data_Functor.map(dictFunctor2)(function (t) { - return Control_Monad_Free_Trans.freeT(function (v3) { - return go(t); - }); - })(zap(Data_Tuple.Tuple.create)(v1)(v2))); - }); - })); - }; - return Control_Monad_Free_Trans.freeT(function (v) { - return go(new Data_Tuple.Tuple(fs, gs)); - }); - }; - }; - }; - }; - }; - }; - }; - var fuseWith = function (dictFunctor) { - return function (dictFunctor1) { - return function (dictFunctor2) { - return function (dictMonadRec) { - return function (dictParallel) { - return function (zap) { - return function (fs) { - return function (gs) { - var go = function (v) { - return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(Control_Parallel_Class.sequential(dictParallel)(Control_Apply.apply((dictParallel.Applicative1()).Apply0())(Data_Functor.map(((dictParallel.Applicative1()).Apply0()).Functor0())(Control_Apply.lift2(Data_Either.applyEither)(zap(Data_Tuple.Tuple.create)))(Control_Parallel_Class.parallel(dictParallel)(Control_Monad_Free_Trans.resume(dictFunctor)(dictMonadRec)(v.value0))))(Control_Parallel_Class.parallel(dictParallel)(Control_Monad_Free_Trans.resume(dictFunctor1)(dictMonadRec)(v.value1)))))(function (v1) { - if (v1 instanceof Data_Either.Left) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Data_Either.Left(v1.value0)); - }; - if (v1 instanceof Data_Either.Right) { - return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(new Data_Either.Right(Data_Functor.map(dictFunctor2)(function (t) { - return Control_Monad_Free_Trans.freeT(function (v2) { - return go(t); - }); - })(v1.value0))); - }; - throw new Error("Failed pattern match at Control.Coroutine line 80, column 5 - line 82, column 63: " + [ v1.constructor.name ]); - }); - }; - return Control_Monad_Free_Trans.freeT(function (v) { - return go(new Data_Tuple.Tuple(fs, gs)); - }); - }; - }; - }; - }; - }; - }; - }; - }; - var functorAwait = new Data_Functor.Functor(Data_Profunctor.rmap(profunctorAwait)); - var bifunctorEmit = new Data_Bifunctor.Bifunctor(function (f) { - return function (g) { - return function (v) { - return new Emit(f(v.value0), g(v.value1)); - }; - }; - }); - var functorEmit = new Data_Functor.Functor(Data_Bifunctor.rmap(bifunctorEmit)); - var connect = function (dictMonadRec) { - return function (dictParallel) { - return fuseWith(functorEmit)(functorAwait)(Data_Identity.functorIdentity)(dictMonadRec)(dictParallel)(function (f) { - return function (v) { - return function (v1) { - return f(v.value1)(v1(v.value0)); - }; - }; - }); - }; - }; - var emit = function (dictMonad) { - return function (o) { - return Control_Monad_Free_Trans.liftFreeT(functorEmit)(dictMonad)(new Emit(o, Data_Unit.unit)); - }; - }; - var producer = function (dictMonad) { - return function (recv) { - return loop(functorEmit)(dictMonad)(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(functorEmit)(dictMonad))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(functorEmit))(dictMonad)(recv))(function (v) { - if (v instanceof Data_Either.Left) { - return Data_Functor.voidLeft(Control_Monad_Free_Trans.functorFreeT(functorEmit)(((dictMonad.Bind1()).Apply0()).Functor0()))(emit(dictMonad)(v.value0))(Data_Maybe.Nothing.value); - }; - if (v instanceof Data_Either.Right) { - return Control_Applicative.pure(Control_Monad_Free_Trans.applicativeFreeT(functorEmit)(dictMonad))(new Data_Maybe.Just(v.value0)); - }; - throw new Error("Failed pattern match at Control.Coroutine line 126, column 3 - line 128, column 29: " + [ v.constructor.name ]); - })); - }; - }; - var pullFrom = function (dictMonadRec) { - return fuseWithL(functorAwait)(functorEmit)(Data_Identity.functorIdentity)(dictMonadRec)(function (f) { - return function (v) { - return function (v1) { - return Control_Applicative.pure(Data_Identity.applicativeIdentity)(f(v(v1.value0))(v1.value1)); - }; - }; - }); - }; - var $$await = function (dictMonad) { - return Control_Monad_Free_Trans.liftFreeT(functorAwait)(dictMonad)(Control_Category.id(Control_Category.categoryFn)); - }; - exports["Emit"] = Emit; - exports["await"] = $$await; - exports["connect"] = connect; - exports["emit"] = emit; - exports["fuseWith"] = fuseWith; - exports["fuseWithL"] = fuseWithL; - exports["loop"] = loop; - exports["producer"] = producer; - exports["pullFrom"] = pullFrom; - exports["runProcess"] = runProcess; - exports["bifunctorEmit"] = bifunctorEmit; - exports["functorEmit"] = functorEmit; - exports["profunctorAwait"] = profunctorAwait; - exports["functorAwait"] = functorAwait; -})(PS["Control.Coroutine"] = PS["Control.Coroutine"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Aff_Internal = PS["Control.Monad.Aff.Internal"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Function = PS["Data.Function"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Maybe = PS["Data.Maybe"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var fromAVBox = Unsafe_Coerce.unsafeCoerce; - var killVar = function (q) { - return function (e) { - return fromAVBox(Control_Monad_Aff_Internal._killVar(Control_Monad_Aff.nonCanceler, q, e)); - }; - }; - var makeVar = fromAVBox(Control_Monad_Aff_Internal._makeVar(Control_Monad_Aff.nonCanceler)); - var peekVar = function (q) { - return fromAVBox(Control_Monad_Aff_Internal._peekVar(Control_Monad_Aff.nonCanceler, q)); - }; - var putVar = function (q) { - return function (a) { - return fromAVBox(Control_Monad_Aff_Internal._putVar(Control_Monad_Aff.nonCanceler, q, a)); - }; - }; - var takeVar = function (q) { - return fromAVBox(Control_Monad_Aff_Internal._takeVar(Control_Monad_Aff.nonCanceler, q)); - }; - exports["killVar"] = killVar; - exports["makeVar"] = makeVar; - exports["peekVar"] = peekVar; - exports["putVar"] = putVar; - exports["takeVar"] = takeVar; -})(PS["Control.Monad.Aff.AVar"] = PS["Control.Monad.Aff.AVar"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Coroutine = PS["Control.Coroutine"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"]; - var Control_Monad_Aff_Class = PS["Control.Monad.Aff.Class"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var Listening = (function () { - function Listening() { - - }; - Listening.value = new Listening(); - return Listening; - })(); - var Done = (function () { - function Done() { - - }; - Done.value = new Done(); - return Done; - })(); - var unEventSource = function (v) { - return v; - }; - var eqSubscribeStatus = new Data_Eq.Eq(function (x) { - return function (y) { - if (x instanceof Listening && y instanceof Listening) { - return true; - }; - if (x instanceof Done && y instanceof Done) { - return true; - }; - return false; - }; - }); - exports["Listening"] = Listening; - exports["Done"] = Done; - exports["unEventSource"] = unEventSource; - exports["eqSubscribeStatus"] = eqSubscribeStatus; -})(PS["Halogen.Query.EventSource"] = PS["Halogen.Query.EventSource"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var unFork = Unsafe_Coerce.unsafeCoerce; - exports["unFork"] = unFork; -})(PS["Halogen.Query.ForkF"] = PS["Halogen.Query.ForkF"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Applicative_Free = PS["Control.Applicative.Free"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad = PS["Control.Monad"]; - var Control_Monad_Aff_Class = PS["Control.Monad.Aff.Class"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Fork = PS["Control.Monad.Fork"]; - var Control_Monad_Fork_Class = PS["Control.Monad.Fork.Class"]; - var Control_Monad_Free = PS["Control.Monad.Free"]; - var Control_Monad_Reader_Class = PS["Control.Monad.Reader.Class"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Monad_Writer_Class = PS["Control.Monad.Writer.Class"]; - var Control_Parallel_Class = PS["Control.Parallel.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Coyoneda = PS["Data.Coyoneda"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_Query_EventSource = PS["Halogen.Query.EventSource"]; - var Halogen_Query_ForkF = PS["Halogen.Query.ForkF"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Prelude = PS["Prelude"]; - var HalogenM = function (x) { - return x; - }; - var State = (function () { - function State(value0) { - this.value0 = value0; - }; - State.create = function (value0) { - return new State(value0); - }; - return State; - })(); - var Subscribe = (function () { - function Subscribe(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Subscribe.create = function (value0) { - return function (value1) { - return new Subscribe(value0, value1); - }; - }; - return Subscribe; - })(); - var Lift = (function () { - function Lift(value0) { - this.value0 = value0; - }; - Lift.create = function (value0) { - return new Lift(value0); - }; - return Lift; - })(); - var Halt = (function () { - function Halt(value0) { - this.value0 = value0; - }; - Halt.create = function (value0) { - return new Halt(value0); - }; - return Halt; - })(); - var GetSlots = (function () { - function GetSlots(value0) { - this.value0 = value0; - }; - GetSlots.create = function (value0) { - return new GetSlots(value0); - }; - return GetSlots; - })(); - var CheckSlot = (function () { - function CheckSlot(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - CheckSlot.create = function (value0) { - return function (value1) { - return new CheckSlot(value0, value1); - }; - }; - return CheckSlot; - })(); - var ChildQuery = (function () { - function ChildQuery(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - ChildQuery.create = function (value0) { - return function (value1) { - return new ChildQuery(value0, value1); - }; - }; - return ChildQuery; - })(); - var Raise = (function () { - function Raise(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - Raise.create = function (value0) { - return function (value1) { - return new Raise(value0, value1); - }; - }; - return Raise; - })(); - var Par = (function () { - function Par(value0) { - this.value0 = value0; - }; - Par.create = function (value0) { - return new Par(value0); - }; - return Par; - })(); - var Fork = (function () { - function Fork(value0) { - this.value0 = value0; - }; - Fork.create = function (value0) { - return new Fork(value0); - }; - return Fork; - })(); - var GetRef = (function () { - function GetRef(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - GetRef.create = function (value0) { - return function (value1) { - return new GetRef(value0, value1); - }; - }; - return GetRef; - })(); - var functorHalogenM = new Data_Functor.Functor(function (f) { - return function (v) { - return Data_Functor.map(Control_Monad_Free.freeFunctor)(f)(v); - }; - }); - var applyHalogenM = new Control_Apply.Apply(function () { - return functorHalogenM; - }, function (v) { - return function (v1) { - return Control_Apply.apply(Control_Monad_Free.freeApply)(v)(v1); - }; - }); - var bindHalogenM = new Control_Bind.Bind(function () { - return applyHalogenM; - }, function (v) { - return function (f) { - return Control_Bind.bind(Control_Monad_Free.freeBind)(v)(function (x) { - var v1 = f(x); - return v1; - }); - }; - }); - var applicativeHalogenM = new Control_Applicative.Applicative(function () { - return applyHalogenM; - }, function (a) { - return Control_Applicative.pure(Control_Monad_Free.freeApplicative)(a); - }); - var monadHalogenM = new Control_Monad.Monad(function () { - return applicativeHalogenM; - }, function () { - return bindHalogenM; - }); - var monadEffHalogenM = function (dictMonadEff) { - return new Control_Monad_Eff_Class.MonadEff(function () { - return monadHalogenM; - }, function (eff) { - return HalogenM(Control_Monad_Free.liftF(Lift.create(Control_Monad_Eff_Class.liftEff(dictMonadEff)(eff)))); - }); - }; - var monadStateHalogenM = new Control_Monad_State_Class.MonadState(function () { - return monadHalogenM; - }, function ($70) { - return HalogenM(Control_Monad_Free.liftF(State.create($70))); - }); - exports["State"] = State; - exports["Subscribe"] = Subscribe; - exports["Lift"] = Lift; - exports["Halt"] = Halt; - exports["GetSlots"] = GetSlots; - exports["CheckSlot"] = CheckSlot; - exports["ChildQuery"] = ChildQuery; - exports["Raise"] = Raise; - exports["Par"] = Par; - exports["Fork"] = Fork; - exports["GetRef"] = GetRef; - exports["HalogenM"] = HalogenM; - exports["functorHalogenM"] = functorHalogenM; - exports["applyHalogenM"] = applyHalogenM; - exports["applicativeHalogenM"] = applicativeHalogenM; - exports["bindHalogenM"] = bindHalogenM; - exports["monadHalogenM"] = monadHalogenM; - exports["monadEffHalogenM"] = monadEffHalogenM; - exports["monadStateHalogenM"] = monadStateHalogenM; -})(PS["Halogen.Query.HalogenM"] = PS["Halogen.Query.HalogenM"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Const = PS["Data.Const"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var ComponentSlot = (function () { - function ComponentSlot(value0, value1, value2, value3, value4, value5) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - }; - ComponentSlot.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return function (value4) { - return function (value5) { - return new ComponentSlot(value0, value1, value2, value3, value4, value5); - }; - }; - }; - }; - }; - }; - return ComponentSlot; - })(); - var unComponentSlot = function (f) { - return function (cs) { - var v = Unsafe_Coerce.unsafeCoerce(cs); - return f(v.value0)(v.value1)(v.value2)(v.value3)(v.value4)(v.value5); - }; - }; - var unComponent = Unsafe_Coerce.unsafeCoerce; - var mkComponentSlot = Unsafe_Coerce.unsafeCoerce(ComponentSlot.create); - var mkComponent = Unsafe_Coerce.unsafeCoerce; - var parentComponent = function (dictOrd) { - return function (spec) { - return mkComponent({ - initialState: spec.initialState, - render: spec.render, - "eval": spec["eval"], - receiver: spec.receiver, - initializer: Data_Maybe.Nothing.value, - finalizer: Data_Maybe.Nothing.value, - mkOrdBox: Halogen_Data_OrdBox.mkOrdBox(dictOrd) - }); - }; - }; - var lifecycleComponent = function (dictBifunctor) { - return function (spec) { - return mkComponent({ - initialState: spec.initialState, - render: Unsafe_Coerce.unsafeCoerce(spec.render), - "eval": spec["eval"], - receiver: spec.receiver, - initializer: spec.initializer, - finalizer: spec.finalizer, - mkOrdBox: Halogen_Data_OrdBox.mkOrdBox(Data_Ord.ordVoid) - }); - }; - }; - var component = function (dictBifunctor) { - return function (spec) { - return lifecycleComponent(dictBifunctor)({ - initialState: spec.initialState, - render: spec.render, - "eval": spec["eval"], - receiver: spec.receiver, - initializer: Data_Maybe.Nothing.value, - finalizer: Data_Maybe.Nothing.value - }); - }; - }; - exports["component"] = component; - exports["lifecycleComponent"] = lifecycleComponent; - exports["mkComponent"] = mkComponent; - exports["mkComponentSlot"] = mkComponentSlot; - exports["parentComponent"] = parentComponent; - exports["unComponent"] = unComponent; - exports["unComponentSlot"] = unComponentSlot; -})(PS["Halogen.Component"] = PS["Halogen.Component"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Prelude = PS["Prelude"]; - var Choice = function (Profunctor0, left, right) { - this.Profunctor0 = Profunctor0; - this.left = left; - this.right = right; - }; - var right = function (dict) { - return dict.right; - }; - var left = function (dict) { - return dict.left; - }; - exports["Choice"] = Choice; - exports["left"] = left; - exports["right"] = right; -})(PS["Data.Profunctor.Choice"] = PS["Data.Profunctor.Choice"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Const = PS["Data.Const"]; - var Data_Either = PS["Data.Either"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Lens_Internal_Wander = PS["Data.Lens.Internal.Wander"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; - var Data_Profunctor_Cochoice = PS["Data.Profunctor.Cochoice"]; - var Data_Profunctor_Strong = PS["Data.Profunctor.Strong"]; - var Data_Tuple = PS["Data.Tuple"]; - var Prelude = PS["Prelude"]; - var Forget = function (x) { - return x; - }; - var profunctorForget = new Data_Profunctor.Profunctor(function (f) { - return function (v) { - return function (v1) { - return function ($25) { - return v1(f($25)); - }; - }; - }; - }); - var newtypeForget = new Data_Newtype.Newtype(function (n) { - return n; - }, Forget); - var choiceForget = function (dictMonoid) { - return new Data_Profunctor_Choice.Choice(function () { - return profunctorForget; - }, function (v) { - return Data_Either.either(v)(Data_Monoid.mempty(Data_Monoid.monoidFn(dictMonoid))); - }, function (v) { - return Data_Either.either(Data_Monoid.mempty(Data_Monoid.monoidFn(dictMonoid)))(v); - }); - }; - exports["Forget"] = Forget; - exports["newtypeForget"] = newtypeForget; - exports["profunctorForget"] = profunctorForget; - exports["choiceForget"] = choiceForget; -})(PS["Data.Lens.Internal.Forget"] = PS["Data.Lens.Internal.Forget"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Lens_Internal_Forget = PS["Data.Lens.Internal.Forget"]; - var Data_Lens_Internal_Indexed = PS["Data.Lens.Internal.Indexed"]; - var Data_Lens_Types = PS["Data.Lens.Types"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Maybe_First = PS["Data.Maybe.First"]; - var Data_Maybe_Last = PS["Data.Maybe.Last"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Monoid_Additive = PS["Data.Monoid.Additive"]; - var Data_Monoid_Conj = PS["Data.Monoid.Conj"]; - var Data_Monoid_Disj = PS["Data.Monoid.Disj"]; - var Data_Monoid_Dual = PS["Data.Monoid.Dual"]; - var Data_Monoid_Endo = PS["Data.Monoid.Endo"]; - var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Prelude = PS["Prelude"]; - var foldMapOf = Data_Newtype.under(Data_Lens_Internal_Forget.newtypeForget)(Data_Lens_Internal_Forget.newtypeForget)(Data_Lens_Internal_Forget.Forget); - var preview = function (p) { - return function ($62) { - return Data_Newtype.unwrap(Data_Maybe_First.newtypeFirst)(foldMapOf(p)(function ($63) { - return Data_Maybe_First.First(Data_Maybe.Just.create($63)); - })($62)); - }; - }; - exports["foldMapOf"] = foldMapOf; - exports["preview"] = preview; -})(PS["Data.Lens.Fold"] = PS["Data.Lens.Fold"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Either = PS["Data.Either"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; - var Data_Profunctor_Costrong = PS["Data.Profunctor.Costrong"]; - var Data_Tuple = PS["Data.Tuple"]; - var Tagged = function (x) { - return x; - }; - var taggedProfunctor = new Data_Profunctor.Profunctor(function (v) { - return function (g) { - return function (v1) { - return g(v1); - }; - }; - }); - var taggedChoice = new Data_Profunctor_Choice.Choice(function () { - return taggedProfunctor; - }, function (v) { - return new Data_Either.Left(v); - }, function (v) { - return new Data_Either.Right(v); - }); - var newtypeTagged = new Data_Newtype.Newtype(function (n) { - return n; - }, Tagged); - exports["Tagged"] = Tagged; - exports["newtypeTagged"] = newtypeTagged; - exports["taggedProfunctor"] = taggedProfunctor; - exports["taggedChoice"] = taggedChoice; -})(PS["Data.Lens.Internal.Tagged"] = PS["Data.Lens.Internal.Tagged"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_MonadPlus = PS["Control.MonadPlus"]; - var Control_MonadZero = PS["Control.MonadZero"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Lens_Internal_Market = PS["Data.Lens.Internal.Market"]; - var Data_Lens_Internal_Tagged = PS["Data.Lens.Internal.Tagged"]; - var Data_Lens_Types = PS["Data.Lens.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Profunctor = PS["Data.Profunctor"]; - var Data_Profunctor_Choice = PS["Data.Profunctor.Choice"]; - var Prelude = PS["Prelude"]; - var review = Data_Newtype.under(Data_Lens_Internal_Tagged.newtypeTagged)(Data_Lens_Internal_Tagged.newtypeTagged)(Data_Lens_Internal_Tagged.Tagged); - var prism = function (to) { - return function (fro) { - return function (dictChoice) { - return function (pab) { - return Data_Profunctor.dimap(dictChoice.Profunctor0())(fro)(Data_Either.either(Control_Category.id(Control_Category.categoryFn))(Control_Category.id(Control_Category.categoryFn)))(Data_Profunctor_Choice.right(dictChoice)(Data_Profunctor.rmap(dictChoice.Profunctor0())(to)(pab))); - }; - }; - }; - }; - var prism$prime = function (to) { - return function (fro) { - return function (dictChoice) { - return prism(to)(function (s) { - return Data_Maybe.maybe(new Data_Either.Left(s))(Data_Either.Right.create)(fro(s)); - })(dictChoice); - }; - }; - }; - exports["prism"] = prism; - exports["prism'"] = prism$prime; - exports["review"] = review; -})(PS["Data.Lens.Prism"] = PS["Data.Lens.Prism"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Either = PS["Data.Either"]; - var Data_Void = PS["Data.Void"]; - var in1 = Data_Either.Left.create; - var at1 = function (b) { - return function (f) { - return function (y) { - if (y instanceof Data_Either.Left) { - return f(y.value0); - }; - return b; - }; - }; - }; - exports["at1"] = at1; - exports["in1"] = in1; -})(PS["Data.Either.Nested"] = PS["Data.Either.Nested"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Comonad = PS["Control.Comonad"]; - var Control_Extend = PS["Control.Extend"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Bifunctor = PS["Data.Bifunctor"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Prelude = PS["Prelude"]; - var left = function (fa) { - return new Data_Either.Left(fa); - }; - exports["left"] = left; -})(PS["Data.Functor.Coproduct"] = PS["Data.Functor.Coproduct"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Const = PS["Data.Const"]; - var Data_Either = PS["Data.Either"]; - var Data_Functor_Coproduct = PS["Data.Functor.Coproduct"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Void = PS["Data.Void"]; - var Prelude = PS["Prelude"]; - var in1 = Data_Functor_Coproduct.left; - var at1 = function (b) { - return function (f) { - return function (y) { - if (y instanceof Data_Either.Left) { - return f(y.value0); - }; - return b; - }; - }; - }; - exports["at1"] = at1; - exports["in1"] = in1; -})(PS["Data.Functor.Coproduct.Nested"] = PS["Data.Functor.Coproduct.Nested"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Data_Either = PS["Data.Either"]; - var Data_Either_Nested = PS["Data.Either.Nested"]; - var Data_Functor_Coproduct = PS["Data.Functor.Coproduct"]; - var Data_Functor_Coproduct_Nested = PS["Data.Functor.Coproduct.Nested"]; - var Data_Lens = PS["Data.Lens"]; - var Data_Lens_Prism = PS["Data.Lens.Prism"]; - var Data_Maybe = PS["Data.Maybe"]; - var _Either1 = function (dictChoice) { - return Data_Lens_Prism["prism'"](Data_Either_Nested.in1)(Data_Either_Nested.at1(Data_Maybe.Nothing.value)(Data_Maybe.Just.create))(dictChoice); - }; - var _Coproduct1 = function (dictChoice) { - return Data_Lens_Prism["prism'"](Data_Functor_Coproduct_Nested.in1)(Data_Functor_Coproduct_Nested.at1(Data_Maybe.Nothing.value)(Data_Maybe.Just.create))(dictChoice); - }; - exports["_Coproduct1"] = _Coproduct1; - exports["_Either1"] = _Either1; -})(PS["Halogen.Data.Prism"] = PS["Halogen.Data.Prism"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Lens = PS["Data.Lens"]; - var Data_Lens_Fold = PS["Data.Lens.Fold"]; - var Data_Lens_Internal_Forget = PS["Data.Lens.Internal.Forget"]; - var Data_Lens_Internal_Tagged = PS["Data.Lens.Internal.Tagged"]; - var Data_Lens_Prism = PS["Data.Lens.Prism"]; - var Data_Lens_Prism_Coproduct = PS["Data.Lens.Prism.Coproduct"]; - var Data_Lens_Prism_Either = PS["Data.Lens.Prism.Either"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Maybe_First = PS["Data.Maybe.First"]; - var Halogen_Data_Prism = PS["Halogen.Data.Prism"]; - var Prelude = PS["Prelude"]; - var ChildPath = (function () { - function ChildPath(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - ChildPath.create = function (value0) { - return function (value1) { - return new ChildPath(value0, value1); - }; - }; - return ChildPath; - })(); - var prjQuery = function (v) { - return Data_Lens_Fold.preview(v.value0(Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst))); - }; - var injSlot = function (v) { - return Data_Lens_Prism.review(v.value1(Data_Lens_Internal_Tagged.taggedChoice)); - }; - var injQuery = function (v) { - return Data_Lens_Prism.review(v.value0(Data_Lens_Internal_Tagged.taggedChoice)); - }; - var cp1 = new ChildPath(function (dictChoice) { - return Halogen_Data_Prism._Coproduct1(dictChoice); - }, function (dictChoice) { - return Halogen_Data_Prism._Either1(dictChoice); - }); - exports["ChildPath"] = ChildPath; - exports["cp1"] = cp1; - exports["injQuery"] = injQuery; - exports["injSlot"] = injSlot; - exports["prjQuery"] = prjQuery; -})(PS["Halogen.Component.ChildPath"] = PS["Halogen.Component.ChildPath"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_HTML_Indexed = PS["DOM.HTML.Indexed"]; - var DOM_HTML_Indexed_ButtonType = PS["DOM.HTML.Indexed.ButtonType"]; - var DOM_HTML_Indexed_FormMethod = PS["DOM.HTML.Indexed.FormMethod"]; - var DOM_HTML_Indexed_InputType = PS["DOM.HTML.Indexed.InputType"]; - var DOM_HTML_Indexed_MenuType = PS["DOM.HTML.Indexed.MenuType"]; - var DOM_HTML_Indexed_MenuitemType = PS["DOM.HTML.Indexed.MenuitemType"]; - var DOM_HTML_Indexed_OnOff = PS["DOM.HTML.Indexed.OnOff"]; - var DOM_HTML_Indexed_OrderedListType = PS["DOM.HTML.Indexed.OrderedListType"]; - var DOM_HTML_Indexed_PreloadValue = PS["DOM.HTML.Indexed.PreloadValue"]; - var DOM_HTML_Indexed_StepValue = PS["DOM.HTML.Indexed.StepValue"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_MediaType = PS["Data.MediaType"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_String = PS["Data.String"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var prop = function (dictIsProp) { - return Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.prop(dictIsProp)); - }; - var value = prop(Halogen_HTML_Core.stringIsProp)("value"); - var classes = function ($8) { - return prop(Halogen_HTML_Core.stringIsProp)("className")(Data_String.joinWith(" ")(Data_Functor.map(Data_Functor.functorArray)(Data_Newtype.unwrap(Halogen_HTML_Core.newtypeClassName))($8))); - }; - var attr = Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.attr(Data_Maybe.Nothing.value)); - exports["attr"] = attr; - exports["classes"] = classes; - exports["prop"] = prop; - exports["value"] = value; -})(PS["Halogen.HTML.Properties"] = PS["Halogen.HTML.Properties"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_HTML_Indexed = PS["DOM.HTML.Indexed"]; - var Data_Function = PS["Data.Function"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Tuple = PS["Data.Tuple"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Halogen_VDom = PS["Halogen.VDom"]; - var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var element = Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.element(Data_Maybe.Nothing.value)); - var h1 = element("h1"); - var h1_ = h1([ ]); - var div = element("div"); - var div_ = div([ ]); - exports["div"] = div; - exports["div_"] = div_; - exports["element"] = element; - exports["h1"] = h1; - exports["h1_"] = h1_; -})(PS["Halogen.HTML.Elements"] = PS["Halogen.HTML.Elements"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Halogen_Component = PS["Halogen.Component"]; - var Halogen_Component_ChildPath = PS["Halogen.Component.ChildPath"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; - var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; - var Prelude = PS["Prelude"]; - var slot$prime = function (i) { - return function (p) { - return function (component) { - return function (input) { - return function (outputQuery) { - var pq = Halogen_Component_ChildPath.prjQuery(i); - var f = function ($2) { - return Data_Functor.map(Data_Maybe.functorMaybe)(Halogen_Component_ChildPath.injQuery(i))(Halogen_Component.unComponent(function (v) { - return v.receiver; - })(component)($2)); - }; - return Halogen_HTML_Core.slot(Halogen_Component.mkComponentSlot(Halogen_Component_ChildPath.injSlot(i)(p))(component)(input)(f)(outputQuery)(pq)); - }; - }; - }; - }; - }; - var slot = function (p) { - return function (component) { - return function (input) { - return function (outputQuery) { - var f = Halogen_Component.unComponent(function (v) { - return v.receiver; - })(component); - return Halogen_HTML_Core.slot(Halogen_Component.mkComponentSlot(p)(component)(input)(f)(outputQuery)(Data_Maybe.Just.create)); - }; - }; - }; - }; - exports["slot"] = slot; - exports["slot'"] = slot$prime; -})(PS["Halogen.HTML"] = PS["Halogen.HTML"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var CSS_Property = PS["CSS.Property"]; - var CSS_Render = PS["CSS.Render"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Array = PS["Data.Array"]; - var Data_Either = PS["Data.Either"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_MediaType = PS["Data.MediaType"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_StrMap = PS["Data.StrMap"]; - var Data_String = PS["Data.String"]; - var Data_Tuple = PS["Data.Tuple"]; - var Halogen_HTML = PS["Halogen.HTML"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; - var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; - var Prelude = PS["Prelude"]; - var style = (function () { - var toString = function ($4) { - return Data_String.joinWith("; ")(Data_StrMap.foldMap(Data_Monoid.monoidArray)(function (key) { - return function (val) { - return [ key + (": " + val) ]; - }; - })($4)); - }; - var rights = Data_Array.concatMap(Data_Foldable.foldMap(Data_Either.foldableEither)(Data_Monoid.monoidArray)(Data_Array.singleton)); - var property = function (v) { - if (v instanceof CSS_Stylesheet.Property) { - return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, v.value1)); - }; - return Data_Maybe.Nothing.value; - }; - var rules = function (rs) { - var properties = Control_Bind.bind(Control_Bind.bindArray)(Data_Array.mapMaybe(property)(rs))(function ($5) { - return rights(CSS_Render.collect($5)); - }); - return Data_StrMap.fromFoldable(Data_Foldable.foldableArray)(properties); - }; - return function ($6) { - return Halogen_HTML_Properties.attr("style")(toString(rules(CSS_Stylesheet.runS($6)))); - }; - })(); - exports["style"] = style; -})(PS["Halogen.HTML.CSS"] = PS["Halogen.HTML.CSS"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var touchstart = "touchstart"; - var touchmove = "touchmove"; - var touchend = "touchend"; - var mouseup = "mouseup"; - var mousemove = "mousemove"; - var mousedown = "mousedown"; - var load = "load"; - exports["load"] = load; - exports["mousedown"] = mousedown; - exports["mousemove"] = mousemove; - exports["mouseup"] = mouseup; - exports["touchend"] = touchend; - exports["touchmove"] = touchmove; - exports["touchstart"] = touchstart; -})(PS["DOM.HTML.Event.EventTypes"] = PS["DOM.HTML.Event.EventTypes"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Apply = PS["Control.Apply"]; - var Control_Category = PS["Control.Category"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_List = PS["Data.List"]; - var Data_List_Lazy = PS["Data.List.Lazy"]; - var Data_List_Lazy_Types = PS["Data.List.Lazy.Types"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Monoid = PS["Data.Monoid"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Ordering = PS["Data.Ordering"]; - var Data_Semigroup = PS["Data.Semigroup"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Show = PS["Data.Show"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unfoldable = PS["Data.Unfoldable"]; - var Partial_Unsafe = PS["Partial.Unsafe"]; - var Prelude = PS["Prelude"]; - var Leaf = (function () { - function Leaf() { - - }; - Leaf.value = new Leaf(); - return Leaf; - })(); - var Two = (function () { - function Two(value0, value1, value2, value3) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - }; - Two.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return new Two(value0, value1, value2, value3); - }; - }; - }; - }; - return Two; - })(); - var Three = (function () { - function Three(value0, value1, value2, value3, value4, value5, value6) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - this.value6 = value6; - }; - Three.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return function (value4) { - return function (value5) { - return function (value6) { - return new Three(value0, value1, value2, value3, value4, value5, value6); - }; - }; - }; - }; - }; - }; - }; - return Three; - })(); - var TwoLeft = (function () { - function TwoLeft(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - TwoLeft.create = function (value0) { - return function (value1) { - return function (value2) { - return new TwoLeft(value0, value1, value2); - }; - }; - }; - return TwoLeft; - })(); - var TwoRight = (function () { - function TwoRight(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - TwoRight.create = function (value0) { - return function (value1) { - return function (value2) { - return new TwoRight(value0, value1, value2); - }; - }; - }; - return TwoRight; - })(); - var ThreeLeft = (function () { - function ThreeLeft(value0, value1, value2, value3, value4, value5) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - }; - ThreeLeft.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return function (value4) { - return function (value5) { - return new ThreeLeft(value0, value1, value2, value3, value4, value5); - }; - }; - }; - }; - }; - }; - return ThreeLeft; - })(); - var ThreeMiddle = (function () { - function ThreeMiddle(value0, value1, value2, value3, value4, value5) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - }; - ThreeMiddle.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return function (value4) { - return function (value5) { - return new ThreeMiddle(value0, value1, value2, value3, value4, value5); - }; - }; - }; - }; - }; - }; - return ThreeMiddle; - })(); - var ThreeRight = (function () { - function ThreeRight(value0, value1, value2, value3, value4, value5) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - this.value4 = value4; - this.value5 = value5; - }; - ThreeRight.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return function (value4) { - return function (value5) { - return new ThreeRight(value0, value1, value2, value3, value4, value5); - }; - }; - }; - }; - }; - }; - return ThreeRight; - })(); - var KickUp = (function () { - function KickUp(value0, value1, value2, value3) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - this.value3 = value3; - }; - KickUp.create = function (value0) { - return function (value1) { - return function (value2) { - return function (value3) { - return new KickUp(value0, value1, value2, value3); - }; - }; - }; - }; - return KickUp; - })(); - var values = function (v) { - if (v instanceof Leaf) { - return Data_List_Types.Nil.value; - }; - if (v instanceof Two) { - return Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value2))(values(v.value3))); - }; - if (v instanceof Three) { - return Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value2))(Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value3))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value5))(values(v.value6))))); - }; - throw new Error("Failed pattern match at Data.Map line 553, column 1 - line 553, column 40: " + [ v.constructor.name ]); - }; - var lookup = function (dictOrd) { - return function (k) { - var comp = Data_Ord.compare(dictOrd); - var go = function ($copy_v) { - var $tco_done = false; - var $tco_result; - function $tco_loop(v) { - if (v instanceof Leaf) { - $tco_done = true; - return Data_Maybe.Nothing.value; - }; - if (v instanceof Two) { - var v2 = comp(k)(v.value1); - if (v2 instanceof Data_Ordering.EQ) { - $tco_done = true; - return new Data_Maybe.Just(v.value2); - }; - if (v2 instanceof Data_Ordering.LT) { - $copy_v = v.value0; - return; - }; - $copy_v = v.value3; - return; - }; - if (v instanceof Three) { - var v3 = comp(k)(v.value1); - if (v3 instanceof Data_Ordering.EQ) { - $tco_done = true; - return new Data_Maybe.Just(v.value2); - }; - var v4 = comp(k)(v.value4); - if (v4 instanceof Data_Ordering.EQ) { - $tco_done = true; - return new Data_Maybe.Just(v.value5); - }; - if (v3 instanceof Data_Ordering.LT) { - $copy_v = v.value0; - return; - }; - if (v4 instanceof Data_Ordering.GT) { - $copy_v = v.value6; - return; - }; - $copy_v = v.value3; - return; - }; - throw new Error("Failed pattern match at Data.Map line 162, column 5 - line 162, column 22: " + [ v.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($copy_v); - }; - return $tco_result; - }; - return go; - }; - }; - var member = function (dictOrd) { - return function (k) { - return function (m) { - return Data_Maybe.isJust(lookup(dictOrd)(k)(m)); - }; - }; - }; - var keys = function (v) { - if (v instanceof Leaf) { - return Data_List_Types.Nil.value; - }; - if (v instanceof Two) { - return Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value1))(keys(v.value3))); - }; - if (v instanceof Three) { - return Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value1))(Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value3))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value4))(keys(v.value6))))); - }; - throw new Error("Failed pattern match at Data.Map line 547, column 1 - line 547, column 38: " + [ v.constructor.name ]); - }; - var functorMap = new Data_Functor.Functor(function (v) { - return function (v1) { - if (v1 instanceof Leaf) { - return Leaf.value; - }; - if (v1 instanceof Two) { - return new Two(Data_Functor.map(functorMap)(v)(v1.value0), v1.value1, v(v1.value2), Data_Functor.map(functorMap)(v)(v1.value3)); - }; - if (v1 instanceof Three) { - return new Three(Data_Functor.map(functorMap)(v)(v1.value0), v1.value1, v(v1.value2), Data_Functor.map(functorMap)(v)(v1.value3), v1.value4, v(v1.value5), Data_Functor.map(functorMap)(v)(v1.value6)); - }; - throw new Error("Failed pattern match at Data.Map line 87, column 1 - line 87, column 39: " + [ v.constructor.name, v1.constructor.name ]); - }; - }); - var fromZipper = function ($copy_dictOrd) { - return function ($copy_v) { - return function ($copy_tree) { - var $tco_var_dictOrd = $copy_dictOrd; - var $tco_var_v = $copy_v; - var $tco_done = false; - var $tco_result; - function $tco_loop(dictOrd, v, tree) { - if (v instanceof Data_List_Types.Nil) { - $tco_done = true; - return tree; - }; - if (v instanceof Data_List_Types.Cons) { - if (v.value0 instanceof TwoLeft) { - $tco_var_dictOrd = dictOrd; - $tco_var_v = v.value1; - $copy_tree = new Two(tree, v.value0.value0, v.value0.value1, v.value0.value2); - return; - }; - if (v.value0 instanceof TwoRight) { - $tco_var_dictOrd = dictOrd; - $tco_var_v = v.value1; - $copy_tree = new Two(v.value0.value0, v.value0.value1, v.value0.value2, tree); - return; - }; - if (v.value0 instanceof ThreeLeft) { - $tco_var_dictOrd = dictOrd; - $tco_var_v = v.value1; - $copy_tree = new Three(tree, v.value0.value0, v.value0.value1, v.value0.value2, v.value0.value3, v.value0.value4, v.value0.value5); - return; - }; - if (v.value0 instanceof ThreeMiddle) { - $tco_var_dictOrd = dictOrd; - $tco_var_v = v.value1; - $copy_tree = new Three(v.value0.value0, v.value0.value1, v.value0.value2, tree, v.value0.value3, v.value0.value4, v.value0.value5); - return; - }; - if (v.value0 instanceof ThreeRight) { - $tco_var_dictOrd = dictOrd; - $tco_var_v = v.value1; - $copy_tree = new Three(v.value0.value0, v.value0.value1, v.value0.value2, v.value0.value3, v.value0.value4, v.value0.value5, tree); - return; - }; - throw new Error("Failed pattern match at Data.Map line 376, column 3 - line 381, column 88: " + [ v.value0.constructor.name ]); - }; - throw new Error("Failed pattern match at Data.Map line 373, column 1 - line 373, column 80: " + [ v.constructor.name, tree.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_dictOrd, $tco_var_v, $copy_tree); - }; - return $tco_result; - }; - }; - }; - var insert = function (dictOrd) { - return function (k) { - return function (v) { - var up = function ($copy_v1) { - return function ($copy_v2) { - var $tco_var_v1 = $copy_v1; - var $tco_done = false; - var $tco_result; - function $tco_loop(v1, v2) { - if (v1 instanceof Data_List_Types.Nil) { - $tco_done = true; - return new Two(v2.value0, v2.value1, v2.value2, v2.value3); - }; - if (v1 instanceof Data_List_Types.Cons) { - if (v1.value0 instanceof TwoLeft) { - $tco_done = true; - return fromZipper(dictOrd)(v1.value1)(new Three(v2.value0, v2.value1, v2.value2, v2.value3, v1.value0.value0, v1.value0.value1, v1.value0.value2)); - }; - if (v1.value0 instanceof TwoRight) { - $tco_done = true; - return fromZipper(dictOrd)(v1.value1)(new Three(v1.value0.value0, v1.value0.value1, v1.value0.value2, v2.value0, v2.value1, v2.value2, v2.value3)); - }; - if (v1.value0 instanceof ThreeLeft) { - $tco_var_v1 = v1.value1; - $copy_v2 = new KickUp(new Two(v2.value0, v2.value1, v2.value2, v2.value3), v1.value0.value0, v1.value0.value1, new Two(v1.value0.value2, v1.value0.value3, v1.value0.value4, v1.value0.value5)); - return; - }; - if (v1.value0 instanceof ThreeMiddle) { - $tco_var_v1 = v1.value1; - $copy_v2 = new KickUp(new Two(v1.value0.value0, v1.value0.value1, v1.value0.value2, v2.value0), v2.value1, v2.value2, new Two(v2.value3, v1.value0.value3, v1.value0.value4, v1.value0.value5)); - return; - }; - if (v1.value0 instanceof ThreeRight) { - $tco_var_v1 = v1.value1; - $copy_v2 = new KickUp(new Two(v1.value0.value0, v1.value0.value1, v1.value0.value2, v1.value0.value3), v1.value0.value4, v1.value0.value5, new Two(v2.value0, v2.value1, v2.value2, v2.value3)); - return; - }; - throw new Error("Failed pattern match at Data.Map line 412, column 5 - line 417, column 108: " + [ v1.value0.constructor.name, v2.constructor.name ]); - }; - throw new Error("Failed pattern match at Data.Map line 409, column 3 - line 409, column 56: " + [ v1.constructor.name, v2.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_v1, $copy_v2); - }; - return $tco_result; - }; - }; - var comp = Data_Ord.compare(dictOrd); - var down = function ($copy_ctx) { - return function ($copy_v1) { - var $tco_var_ctx = $copy_ctx; - var $tco_done = false; - var $tco_result; - function $tco_loop(ctx, v1) { - if (v1 instanceof Leaf) { - $tco_done = true; - return up(ctx)(new KickUp(Leaf.value, k, v, Leaf.value)); - }; - if (v1 instanceof Two) { - var v2 = comp(k)(v1.value1); - if (v2 instanceof Data_Ordering.EQ) { - $tco_done = true; - return fromZipper(dictOrd)(ctx)(new Two(v1.value0, k, v, v1.value3)); - }; - if (v2 instanceof Data_Ordering.LT) { - $tco_var_ctx = new Data_List_Types.Cons(new TwoLeft(v1.value1, v1.value2, v1.value3), ctx); - $copy_v1 = v1.value0; - return; - }; - $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(v1.value0, v1.value1, v1.value2), ctx); - $copy_v1 = v1.value3; - return; - }; - if (v1 instanceof Three) { - var v3 = comp(k)(v1.value1); - if (v3 instanceof Data_Ordering.EQ) { - $tco_done = true; - return fromZipper(dictOrd)(ctx)(new Three(v1.value0, k, v, v1.value3, v1.value4, v1.value5, v1.value6)); - }; - var v4 = comp(k)(v1.value4); - if (v4 instanceof Data_Ordering.EQ) { - $tco_done = true; - return fromZipper(dictOrd)(ctx)(new Three(v1.value0, v1.value1, v1.value2, v1.value3, k, v, v1.value6)); - }; - if (v3 instanceof Data_Ordering.LT) { - $tco_var_ctx = new Data_List_Types.Cons(new ThreeLeft(v1.value1, v1.value2, v1.value3, v1.value4, v1.value5, v1.value6), ctx); - $copy_v1 = v1.value0; - return; - }; - if (v3 instanceof Data_Ordering.GT && v4 instanceof Data_Ordering.LT) { - $tco_var_ctx = new Data_List_Types.Cons(new ThreeMiddle(v1.value0, v1.value1, v1.value2, v1.value4, v1.value5, v1.value6), ctx); - $copy_v1 = v1.value3; - return; - }; - $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(v1.value0, v1.value1, v1.value2, v1.value3, v1.value4, v1.value5), ctx); - $copy_v1 = v1.value6; - return; - }; - throw new Error("Failed pattern match at Data.Map line 392, column 3 - line 392, column 55: " + [ ctx.constructor.name, v1.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_ctx, $copy_v1); - }; - return $tco_result; - }; - }; - return down(Data_List_Types.Nil.value); - }; - }; - }; - var pop = function (dictOrd) { - return function (k) { - var up = function (ctxs) { - return function (tree) { - if (ctxs instanceof Data_List_Types.Nil) { - return tree; - }; - if (ctxs instanceof Data_List_Types.Cons) { - var __unused = function (dictPartial1) { - return function ($dollar51) { - return $dollar51; - }; - }; - return __unused()((function () { - if (ctxs.value0 instanceof TwoLeft && (ctxs.value0.value2 instanceof Leaf && tree instanceof Leaf)) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(Leaf.value, ctxs.value0.value0, ctxs.value0.value1, Leaf.value)); - }; - if (ctxs.value0 instanceof TwoRight && (ctxs.value0.value0 instanceof Leaf && tree instanceof Leaf)) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value)); - }; - if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Two) { - return up(ctxs.value1)(new Three(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0, ctxs.value0.value2.value1, ctxs.value0.value2.value2, ctxs.value0.value2.value3)); - }; - if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Two) { - return up(ctxs.value1)(new Three(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3, ctxs.value0.value1, ctxs.value0.value2, tree)); - }; - if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Three) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(new Two(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0), ctxs.value0.value2.value1, ctxs.value0.value2.value2, new Two(ctxs.value0.value2.value3, ctxs.value0.value2.value4, ctxs.value0.value2.value5, ctxs.value0.value2.value6))); - }; - if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Three) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(new Two(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3), ctxs.value0.value0.value4, ctxs.value0.value0.value5, new Two(ctxs.value0.value0.value6, ctxs.value0.value1, ctxs.value0.value2, tree))); - }; - if (ctxs.value0 instanceof ThreeLeft && (ctxs.value0.value2 instanceof Leaf && (ctxs.value0.value5 instanceof Leaf && tree instanceof Leaf))) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value0, ctxs.value0.value1, Leaf.value, ctxs.value0.value3, ctxs.value0.value4, Leaf.value)); - }; - if (ctxs.value0 instanceof ThreeMiddle && (ctxs.value0.value0 instanceof Leaf && (ctxs.value0.value5 instanceof Leaf && tree instanceof Leaf))) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value, ctxs.value0.value3, ctxs.value0.value4, Leaf.value)); - }; - if (ctxs.value0 instanceof ThreeRight && (ctxs.value0.value0 instanceof Leaf && (ctxs.value0.value3 instanceof Leaf && tree instanceof Leaf))) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value, ctxs.value0.value4, ctxs.value0.value5, Leaf.value)); - }; - if (ctxs.value0 instanceof ThreeLeft && ctxs.value0.value2 instanceof Two) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(new Three(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0, ctxs.value0.value2.value1, ctxs.value0.value2.value2, ctxs.value0.value2.value3), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); - }; - if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value0 instanceof Two) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(new Three(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3, ctxs.value0.value1, ctxs.value0.value2, tree), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); - }; - if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value5 instanceof Two) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Three(tree, ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5.value0, ctxs.value0.value5.value1, ctxs.value0.value5.value2, ctxs.value0.value5.value3))); - }; - if (ctxs.value0 instanceof ThreeRight && ctxs.value0.value3 instanceof Two) { - return fromZipper(dictOrd)(ctxs.value1)(new Two(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Three(ctxs.value0.value3.value0, ctxs.value0.value3.value1, ctxs.value0.value3.value2, ctxs.value0.value3.value3, ctxs.value0.value4, ctxs.value0.value5, tree))); - }; - if (ctxs.value0 instanceof ThreeLeft && ctxs.value0.value2 instanceof Three) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(new Two(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0), ctxs.value0.value2.value1, ctxs.value0.value2.value2, new Two(ctxs.value0.value2.value3, ctxs.value0.value2.value4, ctxs.value0.value2.value5, ctxs.value0.value2.value6), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); - }; - if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value0 instanceof Three) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(new Two(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3), ctxs.value0.value0.value4, ctxs.value0.value0.value5, new Two(ctxs.value0.value0.value6, ctxs.value0.value1, ctxs.value0.value2, tree), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5)); - }; - if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value5 instanceof Three) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Two(tree, ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5.value0), ctxs.value0.value5.value1, ctxs.value0.value5.value2, new Two(ctxs.value0.value5.value3, ctxs.value0.value5.value4, ctxs.value0.value5.value5, ctxs.value0.value5.value6))); - }; - if (ctxs.value0 instanceof ThreeRight && ctxs.value0.value3 instanceof Three) { - return fromZipper(dictOrd)(ctxs.value1)(new Three(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Two(ctxs.value0.value3.value0, ctxs.value0.value3.value1, ctxs.value0.value3.value2, ctxs.value0.value3.value3), ctxs.value0.value3.value4, ctxs.value0.value3.value5, new Two(ctxs.value0.value3.value6, ctxs.value0.value4, ctxs.value0.value5, tree))); - }; - throw new Error("Failed pattern match at Data.Map line 462, column 9 - line 479, column 136: " + [ ctxs.value0.constructor.name, tree.constructor.name ]); - })()); - }; - throw new Error("Failed pattern match at Data.Map line 459, column 5 - line 479, column 136: " + [ ctxs.constructor.name ]); - }; - }; - var removeMaxNode = function (ctx) { - return function (m) { - var __unused = function (dictPartial1) { - return function ($dollar53) { - return $dollar53; - }; - }; - return __unused()((function () { - if (m instanceof Two && (m.value0 instanceof Leaf && m.value3 instanceof Leaf)) { - return up(ctx)(Leaf.value); - }; - if (m instanceof Two) { - return removeMaxNode(new Data_List_Types.Cons(new TwoRight(m.value0, m.value1, m.value2), ctx))(m.value3); - }; - if (m instanceof Three && (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf))) { - return up(new Data_List_Types.Cons(new TwoRight(Leaf.value, m.value1, m.value2), ctx))(Leaf.value); - }; - if (m instanceof Three) { - return removeMaxNode(new Data_List_Types.Cons(new ThreeRight(m.value0, m.value1, m.value2, m.value3, m.value4, m.value5), ctx))(m.value6); - }; - throw new Error("Failed pattern match at Data.Map line 491, column 5 - line 495, column 107: " + [ m.constructor.name ]); - })()); - }; - }; - var maxNode = function (m) { - var __unused = function (dictPartial1) { - return function ($dollar55) { - return $dollar55; - }; - }; - return __unused()((function () { - if (m instanceof Two && m.value3 instanceof Leaf) { - return { - key: m.value1, - value: m.value2 - }; - }; - if (m instanceof Two) { - return maxNode(m.value3); - }; - if (m instanceof Three && m.value6 instanceof Leaf) { - return { - key: m.value4, - value: m.value5 - }; - }; - if (m instanceof Three) { - return maxNode(m.value6); - }; - throw new Error("Failed pattern match at Data.Map line 482, column 33 - line 486, column 45: " + [ m.constructor.name ]); - })()); - }; - var comp = Data_Ord.compare(dictOrd); - var down = function ($copy_ctx) { - return function ($copy_m) { - var $tco_var_ctx = $copy_ctx; - var $tco_done = false; - var $tco_result; - function $tco_loop(ctx, m) { - if (m instanceof Leaf) { - $tco_done = true; - return Data_Maybe.Nothing.value; - }; - if (m instanceof Two) { - var v = comp(k)(m.value1); - if (m.value3 instanceof Leaf && v instanceof Data_Ordering.EQ) { - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, up(ctx)(Leaf.value))); - }; - if (v instanceof Data_Ordering.EQ) { - var max = maxNode(m.value0); - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, removeMaxNode(new Data_List_Types.Cons(new TwoLeft(max.key, max.value, m.value3), ctx))(m.value0))); - }; - if (v instanceof Data_Ordering.LT) { - $tco_var_ctx = new Data_List_Types.Cons(new TwoLeft(m.value1, m.value2, m.value3), ctx); - $copy_m = m.value0; - return; - }; - $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(m.value0, m.value1, m.value2), ctx); - $copy_m = m.value3; - return; - }; - if (m instanceof Three) { - var leaves = (function () { - if (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf)) { - return true; - }; - return false; - })(); - var v = comp(k)(m.value4); - var v3 = comp(k)(m.value1); - if (leaves && v3 instanceof Data_Ordering.EQ) { - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, fromZipper(dictOrd)(ctx)(new Two(Leaf.value, m.value4, m.value5, Leaf.value)))); - }; - if (leaves && v instanceof Data_Ordering.EQ) { - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value5, fromZipper(dictOrd)(ctx)(new Two(Leaf.value, m.value1, m.value2, Leaf.value)))); - }; - if (v3 instanceof Data_Ordering.EQ) { - var max = maxNode(m.value0); - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, removeMaxNode(new Data_List_Types.Cons(new ThreeLeft(max.key, max.value, m.value3, m.value4, m.value5, m.value6), ctx))(m.value0))); - }; - if (v instanceof Data_Ordering.EQ) { - var max = maxNode(m.value3); - $tco_done = true; - return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value5, removeMaxNode(new Data_List_Types.Cons(new ThreeMiddle(m.value0, m.value1, m.value2, max.key, max.value, m.value6), ctx))(m.value3))); - }; - if (v3 instanceof Data_Ordering.LT) { - $tco_var_ctx = new Data_List_Types.Cons(new ThreeLeft(m.value1, m.value2, m.value3, m.value4, m.value5, m.value6), ctx); - $copy_m = m.value0; - return; - }; - if (v3 instanceof Data_Ordering.GT && v instanceof Data_Ordering.LT) { - $tco_var_ctx = new Data_List_Types.Cons(new ThreeMiddle(m.value0, m.value1, m.value2, m.value4, m.value5, m.value6), ctx); - $copy_m = m.value3; - return; - }; - $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(m.value0, m.value1, m.value2, m.value3, m.value4, m.value5), ctx); - $copy_m = m.value6; - return; - }; - throw new Error("Failed pattern match at Data.Map line 432, column 34 - line 455, column 80: " + [ m.constructor.name ]); - }; - while (!$tco_done) { - $tco_result = $tco_loop($tco_var_ctx, $copy_m); - }; - return $tco_result; - }; - }; - return down(Data_List_Types.Nil.value); - }; - }; - var foldableMap = new Data_Foldable.Foldable(function (dictMonoid) { - return function (f) { - return function (m) { - return Data_Foldable.foldMap(Data_List_Types.foldableList)(dictMonoid)(f)(values(m)); - }; - }; - }, function (f) { - return function (z) { - return function (m) { - return Data_Foldable.foldl(Data_List_Types.foldableList)(f)(z)(values(m)); - }; - }; - }, function (f) { - return function (z) { - return function (m) { - return Data_Foldable.foldr(Data_List_Types.foldableList)(f)(z)(values(m)); - }; - }; - }); - var empty = Leaf.value; - var $$delete = function (dictOrd) { - return function (k) { - return function (m) { - return Data_Maybe.maybe(m)(Data_Tuple.snd)(pop(dictOrd)(k)(m)); - }; - }; - }; - exports["delete"] = $$delete; - exports["empty"] = empty; - exports["insert"] = insert; - exports["keys"] = keys; - exports["lookup"] = lookup; - exports["member"] = member; - exports["pop"] = pop; - exports["values"] = values; - exports["functorMap"] = functorMap; - exports["foldableMap"] = foldableMap; -})(PS["Data.Map"] = PS["Data.Map"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Aff_Class = PS["Control.Monad.Aff.Class"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Except = PS["Control.Monad.Except"]; - var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Parallel = PS["Control.Parallel"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var Data_Either = PS["Data.Either"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Map = PS["Data.Map"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_Component_ChildPath = PS["Halogen.Component.ChildPath"]; - var Halogen_Query_EventSource = PS["Halogen.Query.EventSource"]; - var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Prelude = PS["Prelude"]; - var action = function (act) { - return act(Data_Unit.unit); - }; - exports["action"] = action; -})(PS["Halogen.Query"] = PS["Halogen.Query"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Except = PS["Control.Monad.Except"]; - var Control_Monad_Except_Trans = PS["Control.Monad.Except.Trans"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM_Event_Event = PS["DOM.Event.Event"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_HTML_Event_EventTypes = PS["DOM.HTML.Event.EventTypes"]; - var DOM_HTML_Event_Types = PS["DOM.HTML.Event.Types"]; - var Data_Either = PS["Data.Either"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Foreign_Index = PS["Data.Foreign.Index"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Identity = PS["Data.Identity"]; - var Data_Maybe = PS["Data.Maybe"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; - var Halogen_Query = PS["Halogen.Query"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var touchHandler = Unsafe_Coerce.unsafeCoerce; - var mouseHandler = Unsafe_Coerce.unsafeCoerce; - var input_ = function (f) { - return function (v) { - return Data_Maybe.Just.create(Halogen_Query.action(f)); - }; - }; - var input = function (f) { - return function (x) { - return Data_Maybe.Just.create(Halogen_Query.action(f(x))); - }; - }; - var handler = function (et) { - return function ($1) { - return Unsafe_Coerce.unsafeCoerce(Halogen_HTML_Core.handler)(et)(Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(Halogen_Query_InputF.Query.create))($1)); - }; - }; - var onMouseDown = function ($8) { - return handler(DOM_HTML_Event_EventTypes.mousedown)(mouseHandler($8)); - }; - var onMouseMove = function ($11) { - return handler(DOM_HTML_Event_EventTypes.mousemove)(mouseHandler($11)); - }; - var onMouseUp = function ($14) { - return handler(DOM_HTML_Event_EventTypes.mouseup)(mouseHandler($14)); - }; - var onTouchEnd = function ($16) { - return handler(DOM_HTML_Event_EventTypes.touchend)(touchHandler($16)); - }; - var onTouchMove = function ($19) { - return handler(DOM_HTML_Event_EventTypes.touchmove)(touchHandler($19)); - }; - var onTouchStart = function ($20) { - return handler(DOM_HTML_Event_EventTypes.touchstart)(touchHandler($20)); - }; - exports["handler"] = handler; - exports["input"] = input; - exports["input_"] = input_; - exports["onMouseDown"] = onMouseDown; - exports["onMouseMove"] = onMouseMove; - exports["onMouseUp"] = onMouseUp; - exports["onTouchEnd"] = onTouchEnd; - exports["onTouchMove"] = onTouchMove; - exports["onTouchStart"] = onTouchStart; -})(PS["Halogen.HTML.Events"] = PS["Halogen.HTML.Events"] || {}); -(function(exports) { - "use strict"; - var CSS = PS["CSS"]; - var CSS_Background = PS["CSS.Background"]; - var CSS_Border = PS["CSS.Border"]; - var CSS_Display = PS["CSS.Display"]; - var CSS_Geometry = PS["CSS.Geometry"]; - var CSS_Size = PS["CSS.Size"]; - var CSS_Stylesheet = PS["CSS.Stylesheet"]; - var Color = PS["Color"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_State_Class = PS["Control.Monad.State.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Classy_Event = PS["DOM.Classy.Event"]; - var DOM_Classy_HTMLElement = PS["DOM.Classy.HTMLElement"]; - var DOM_Classy_Node = PS["DOM.Classy.Node"]; - var DOM_Event_MouseEvent = PS["DOM.Event.MouseEvent"]; - var DOM_Event_TouchEvent = PS["DOM.Event.TouchEvent"]; - var DOM_Event_Types = PS["DOM.Event.Types"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var Data_Either = PS["Data.Either"]; - var Data_EuclideanRing = PS["Data.EuclideanRing"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Int = PS["Data.Int"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ring = PS["Data.Ring"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Unit = PS["Data.Unit"]; - var Debug_Trace = PS["Debug.Trace"]; - var Halogen = PS["Halogen"]; - var Halogen_Component = PS["Halogen.Component"]; - var Halogen_HTML = PS["Halogen.HTML"]; - var Halogen_HTML_CSS = PS["Halogen.HTML.CSS"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; - var Halogen_HTML_Events = PS["Halogen.HTML.Events"]; - var Halogen_HTML_Properties = PS["Halogen.HTML.Properties"]; - var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; - var $$Math = PS["Math"]; - var Prelude = PS["Prelude"]; - var NoOp = (function () { - function NoOp(value0) { - this.value0 = value0; - }; - NoOp.create = function (value0) { - return new NoOp(value0); - }; - return NoOp; - })(); - var StartUpdateColor = (function () { - function StartUpdateColor(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - StartUpdateColor.create = function (value0) { - return function (value1) { - return new StartUpdateColor(value0, value1); - }; - }; - return StartUpdateColor; - })(); - var EndUpdateColor = (function () { - function EndUpdateColor(value0) { - this.value0 = value0; - }; - EndUpdateColor.create = function (value0) { - return new EndUpdateColor(value0); - }; - return EndUpdateColor; - })(); - var UpdateColor = (function () { - function UpdateColor(value0, value1) { - this.value0 = value0; - this.value1 = value1; - }; - UpdateColor.create = function (value0) { - return function (value1) { - return new UpdateColor(value0, value1); - }; - }; - return UpdateColor; - })(); - var Idle = (function () { - function Idle() { - - }; - Idle.value = new Idle(); - return Idle; - })(); - var ColorDrag = (function () { - function ColorDrag() { - - }; - ColorDrag.value = new ColorDrag(); - return ColorDrag; - })(); - var positionInRect = function (v) { - return function (v1) { - return { - x: ((v.x - v1.left) / v1.width) * 100.0, - y: ((v.y - v1.top) / v1.height) * 100.0 - }; - }; - }; - - // data Condition = Idle | ColorDrag | HueDrag - var orDefault = Data_Maybe.fromMaybe(Color.hsl(180.0)(0.0)(0.0)); - var getHue = function ($52) { - return (function (v) { - return v.h; - })(Color.toHSLA($52)); - }; - var pureHue = function (c) { - return Color.hsl(getHue(c))(1.0)(0.5); - }; - var render = function (v) { - return Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker" ]) ])([ Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-color" ]), Halogen_HTML_CSS.style(CSS_Background.backgroundColor(pureHue(orDefault(v.color)))), Halogen_HTML_Events.onMouseDown(Halogen_HTML_Events.input(function ($53) { - return StartUpdateColor.create(Data_Either.Right.create($53)); - })), Halogen_HTML_Events.onMouseMove(Halogen_HTML_Events.input(function ($54) { - return UpdateColor.create(Data_Either.Right.create($54)); - })), Halogen_HTML_Events.onMouseUp(Halogen_HTML_Events.input_(EndUpdateColor.create)), Halogen_HTML_Events.onTouchStart(Halogen_HTML_Events.input(function ($55) { - return StartUpdateColor.create(Data_Either.Left.create($55)); - })), Halogen_HTML_Events.onTouchMove(Halogen_HTML_Events.input(function ($56) { - return UpdateColor.create(Data_Either.Left.create($56)); - })), Halogen_HTML_Events.onTouchEnd(Halogen_HTML_Events.input_(EndUpdateColor.create)) ])([ Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-saturation" ]) ])([ ]), Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-brightness" ]) ])([ ]), Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-sbSelector" ]), Halogen_HTML_CSS.style((function () { - if (v.color instanceof Data_Maybe.Nothing) { - return CSS_Display.display(CSS_Display.displayNone); - }; - if (v.color instanceof Data_Maybe.Just) { - return Control_Bind.discard(Control_Bind.discardUnit)(CSS_Stylesheet.bindStyleM)(CSS_Background.backgroundColor(v.color.value0))(function () { - return CSS_Border.borderColor((function () { - var $25 = Color.isLight(v.color.value0); - if ($25) { - return Color.black; - }; - return Color.white; - })()); - }); - }; - throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 121, column 24 - line 127, column 31: " + [ v.color.constructor.name ]); - })()) ])([ ]) ]), Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-hue" ]) ])([ Halogen_HTML_Elements.div([ Halogen_HTML_Properties.classes([ "ColorPicker-hSelector" ]), (function () { - var hue = getHue(orDefault(v.color)); - return Halogen_HTML_CSS.style(CSS_Geometry.top(CSS_Size.pct((hue / 360.0) * 100.0))); - })() ])([ ]) ]) ]); - }; - var applyRect = function (dictIsEvent) { - return function (e) { - return function (input) { - var elem = DOM_Classy_Node.fromNode(DOM_Classy_Node.isNodeHTMLElement)(DOM_Classy_Event.target(dictIsEvent)(e)); - var rect = Data_Functor.map(Data_Maybe.functorMaybe)(DOM_Classy_HTMLElement.getBoundingClientRect(DOM_Classy_HTMLElement.isHTMLElementHTMLElement))(elem); - if (rect instanceof Data_Maybe.Nothing) { - return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(input); - }; - if (rect instanceof Data_Maybe.Just) { - return Data_Functor.map(Control_Monad_Eff.functorEff)(positionInRect(input))(rect.value0); - }; - throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 82, column 5 - line 84, column 43: " + [ rect.constructor.name ]); - }; - }; - }; - var mouseEventToPosition = function (e) { - return applyRect(DOM_Classy_Event.isEventMouseEvent)(e)({ - x: Data_Int.toNumber(DOM_Event_MouseEvent.clientX(e)), - y: Data_Int.toNumber(DOM_Event_MouseEvent.clientY(e)) - }); - }; - var touchEventToPosition = function (e) { - var fstTouch = DOM_Event_TouchEvent.item(0)(DOM_Event_TouchEvent.touches(e)); - if (fstTouch instanceof Data_Maybe.Nothing) { - return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)({ - x: 0.0, - y: 0.0 - }); - }; - if (fstTouch instanceof Data_Maybe.Just) { - return applyRect(DOM_Classy_Event.isEventTouchEvent)(e)({ - x: Data_Int.toNumber(DOM_Event_TouchEvent.clientX(fstTouch.value0)), - y: Data_Int.toNumber(DOM_Event_TouchEvent.clientY(fstTouch.value0)) - }); - }; - throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 91, column 5 - line 95, column 42: " + [ fstTouch.constructor.name ]); - }; - var posFromEvent = Data_Either.either(touchEventToPosition)(mouseEventToPosition); - var $$eval = function (dictMonadEff) { - return function (v) { - if (v instanceof NoOp) { - return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value0); - }; - if (v instanceof StartUpdateColor) { - return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.modify(Halogen_Query_HalogenM.monadStateHalogenM)(function (v1) { - var $34 = {}; - for (var $35 in v1) { - if ({}.hasOwnProperty.call(v1, $35)) { - $34[$35] = v1[$35]; - }; - }; - $34.condition = ColorDrag.value; - return $34; - }))(function () { - return Control_Bind.bind(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_Eff_Class.liftEff(Halogen_Query_HalogenM.monadEffHalogenM(dictMonadEff))(posFromEvent(v.value0)))(function (v1) { - return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Debug_Trace.traceAnyA(Debug_Trace.warn())(Halogen_Query_HalogenM.applicativeHalogenM)(v1))(function () { - return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value1); - }); - }); - }); - }; - if (v instanceof EndUpdateColor) { - return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.modify(Halogen_Query_HalogenM.monadStateHalogenM)(function (v1) { - var $40 = {}; - for (var $41 in v1) { - if ({}.hasOwnProperty.call(v1, $41)) { - $40[$41] = v1[$41]; - }; - }; - $40.condition = Idle.value; - return $40; - }))(function () { - return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value0); - }); - }; - if (v instanceof UpdateColor) { - return Control_Bind.bind(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.get(Halogen_Query_HalogenM.monadStateHalogenM))(function (v1) { - return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)((function () { - if (v1.condition instanceof ColorDrag) { - return Control_Bind.bind(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_Eff_Class.liftEff(Halogen_Query_HalogenM.monadEffHalogenM(dictMonadEff))(posFromEvent(v.value0)))(function (v2) { - return Debug_Trace.traceAnyA(Debug_Trace.warn())(Halogen_Query_HalogenM.applicativeHalogenM)(v2); - }); - }; - return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Unit.unit); - })())(function () { - return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value1); - }); - }); - }; - throw new Error("Failed pattern match at ColorPicker.Halogen.Component line 147, column 1 - line 147, column 60: " + [ v.constructor.name ]); - }; - }; - var picker = function (dictMonadEff) { - return Halogen_Component.component(Halogen_HTML_Core.bifunctorHTML)({ - initialState: Data_Function["const"]({ - color: Data_Maybe.Nothing.value, - condition: Idle.value - }), - render: render, - "eval": $$eval(dictMonadEff), - receiver: Data_Function["const"](Data_Maybe.Nothing.value) - }); - }; - exports["Idle"] = Idle; - exports["ColorDrag"] = ColorDrag; - exports["NoOp"] = NoOp; - exports["StartUpdateColor"] = StartUpdateColor; - exports["EndUpdateColor"] = EndUpdateColor; - exports["UpdateColor"] = UpdateColor; - exports["applyRect"] = applyRect; - exports["getHue"] = getHue; - exports["mouseEventToPosition"] = mouseEventToPosition; - exports["orDefault"] = orDefault; - exports["picker"] = picker; - exports["posFromEvent"] = posFromEvent; - exports["positionInRect"] = positionInRect; - exports["pureHue"] = pureHue; - exports["render"] = render; - exports["touchEventToPosition"] = touchEventToPosition; -})(PS["ColorPicker.Halogen.Component"] = PS["ColorPicker.Halogen.Component"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var unsafeCoerceAff = Unsafe_Coerce.unsafeCoerce; - exports["unsafeCoerceAff"] = unsafeCoerceAff; -})(PS["Control.Monad.Aff.Unsafe"] = PS["Control.Monad.Aff.Unsafe"] || {}); -(function(exports) { - /* global window */ - "use strict"; - - exports.window = function () { - return window; - }; -})(PS["DOM.HTML"] = PS["DOM.HTML"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.HTML"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var DOM = PS["DOM"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - exports["window"] = $foreign.window; -})(PS["DOM.HTML"] = PS["DOM.HTML"] || {}); -(function(exports) { - "use strict"; - - exports.document = function (window) { - return function () { - return window.document; - }; - }; -})(PS["DOM.HTML.Window"] = PS["DOM.HTML.Window"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.HTML.Window"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_WebStorage_Types = PS["DOM.WebStorage.Types"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Nullable = PS["Data.Nullable"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - exports["document"] = $foreign.document; -})(PS["DOM.HTML.Window"] = PS["DOM.HTML.Window"] || {}); -(function(exports) { - "use strict"; - - exports._querySelector = function (selector) { - return function (node) { - return function () { - return node.querySelector(selector); - }; - }; - }; -})(PS["DOM.Node.ParentNode"] = PS["DOM.Node.ParentNode"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["DOM.Node.ParentNode"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Newtype = PS["Data.Newtype"]; - var Data_Nullable = PS["Data.Nullable"]; - var Data_Ord = PS["Data.Ord"]; - var Prelude = PS["Prelude"]; - var querySelector = function (qs) { - return function ($3) { - return Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Nullable.toMaybe)($foreign._querySelector(qs)($3)); - }; - }; - exports["querySelector"] = querySelector; -})(PS["DOM.Node.ParentNode"] = PS["DOM.Node.ParentNode"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Map = PS["Data.Map"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_StrMap = PS["Data.StrMap"]; - var Data_Traversable = PS["Data.Traversable"]; - var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; - var Halogen_Component = PS["Halogen.Component"]; - var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; - var Prelude = PS["Prelude"]; - var Unsafe_Coerce = PS["Unsafe.Coerce"]; - var unRenderStateX = Unsafe_Coerce.unsafeCoerce; - var unDriverStateX = Unsafe_Coerce.unsafeCoerce; - var renderStateX_ = function (dictApplicative) { - return function (f) { - return unDriverStateX(function (st) { - return Data_Foldable.traverse_(dictApplicative)(Data_Foldable.foldableMaybe)(f)(st.rendering); - }); - }; - }; - var mkRenderStateX = function (v) { - return Unsafe_Coerce.unsafeCoerce; - }; - var renderStateX = function (dictFunctor) { - return function (f) { - return unDriverStateX(function (st) { - return mkRenderStateX(st.prjQuery)(f(st.rendering)); - }); - }; - }; - var mkDriverStateXRef = Unsafe_Coerce.unsafeCoerce; - var initDriverState = function (component) { - return function (input) { - return function (handler) { - return function (prjQuery) { - return function (lchs) { - return function __do() { - var v = Control_Monad_Eff_Ref.newRef(Unsafe_Coerce.unsafeCoerce({}))(); - var v1 = Control_Monad_Eff_Ref.newRef(Data_Map.empty)(); - var v2 = Control_Monad_Eff_Ref.newRef(Data_Map.empty)(); - var v3 = Control_Monad_Eff_Ref.newRef(Data_Functor.voidLeft(Data_Maybe.functorMaybe)(component.initializer)(Data_List_Types.Nil.value))(); - var v4 = Control_Monad_Eff_Ref.newRef(new Data_Maybe.Just(Data_List_Types.Nil.value))(); - var v5 = Control_Monad_Eff_Ref.newRef(Data_Maybe.Nothing.value)(); - var v6 = Control_Monad_Eff_Ref.newRef(0)(); - var v7 = Control_Monad_Eff_Ref.newRef(new Data_Maybe.Just(Data_Map.empty))(); - var ds = { - component: component, - state: component.initialState(input), - refs: Data_StrMap.empty, - children: Data_Map.empty, - childrenIn: v1, - childrenOut: v2, - selfRef: v, - handler: handler, - pendingQueries: v3, - pendingOuts: v4, - pendingHandlers: v5, - rendering: Data_Maybe.Nothing.value, - prjQuery: prjQuery, - fresh: v6, - subscriptions: v7, - lifecycleHandlers: lchs - }; - Control_Monad_Eff_Ref.writeRef(v)(ds)(); - return mkDriverStateXRef(v); - }; - }; - }; - }; - }; - }; - exports["initDriverState"] = initDriverState; - exports["mkDriverStateXRef"] = mkDriverStateXRef; - exports["renderStateX"] = renderStateX; - exports["renderStateX_"] = renderStateX_; - exports["unDriverStateX"] = unDriverStateX; - exports["unRenderStateX"] = unRenderStateX; -})(PS["Halogen.Aff.Driver.State"] = PS["Halogen.Aff.Driver.State"] || {}); -(function(exports) { - "use strict"; - - exports.reallyUnsafeRefEq = function (a) { - return function (b) { - return a === b; - }; - }; -})(PS["Unsafe.Reference"] = PS["Unsafe.Reference"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var $foreign = PS["Unsafe.Reference"]; - var unsafeRefEq = $foreign.reallyUnsafeRefEq; - exports["unsafeRefEq"] = unsafeRefEq; -})(PS["Unsafe.Reference"] = PS["Unsafe.Reference"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Applicative_Free = PS["Control.Applicative.Free"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Coroutine = PS["Control.Coroutine"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"]; - var Control_Monad_Aff_Unsafe = PS["Control.Monad.Aff.Unsafe"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Fork = PS["Control.Monad.Fork"]; - var Control_Monad_Fork_Class = PS["Control.Monad.Fork.Class"]; - var Control_Monad_Free = PS["Control.Monad.Free"]; - var Control_Monad_Free_Trans = PS["Control.Monad.Free.Trans"]; - var Control_Monad_Trans_Class = PS["Control.Monad.Trans.Class"]; - var Control_Parallel = PS["Control.Parallel"]; - var Control_Parallel_Class = PS["Control.Parallel.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Boolean = PS["Data.Boolean"]; - var Data_Coyoneda = PS["Data.Coyoneda"]; - var Data_Either = PS["Data.Either"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Map = PS["Data.Map"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_StrMap = PS["Data.StrMap"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_Aff_Driver_State = PS["Halogen.Aff.Driver.State"]; - var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; - var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; - var Halogen_Query_EventSource = PS["Halogen.Query.EventSource"]; - var Halogen_Query_ForkF = PS["Halogen.Query.ForkF"]; - var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Prelude = PS["Prelude"]; - var Unsafe_Reference = PS["Unsafe.Reference"]; - var queuingHandler = function (handler) { - return function (ref) { - return function (message) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { - if (v instanceof Data_Maybe.Nothing) { - return handler(message); - }; - if (v instanceof Data_Maybe.Just) { - return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(ref)(new Data_Maybe.Just(new Data_List_Types.Cons(handler(message), v.value0)))); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 201, column 3 - line 205, column 57: " + [ v.constructor.name ]); - }); - }; - }; - }; - var parSequenceAff_ = function (v) { - if (v instanceof Data_List_Types.Nil) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(Data_Unit.unit); - }; - if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) { - return Data_Functor["void"](Control_Monad_Aff.functorAff)(v.value0); - }; - if (v instanceof Data_List_Types.Cons) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff_AVar.makeVar)(function (v1) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.newRef(v.value1)))(function (v2) { - var run = function (a) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff.attempt(a))(function (v3) { - if (v3 instanceof Data_Either.Left) { - return Control_Monad_Aff_AVar.putVar(v1)(new Data_Maybe.Just(v3.value0)); - }; - if (v3 instanceof Data_Either.Right) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v2)))(function (v4) { - if (v4 instanceof Data_List_Types.Nil) { - return Control_Monad_Aff_AVar.putVar(v1)(Data_Maybe.Nothing.value); - }; - if (v4 instanceof Data_List_Types.Cons) { - return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(v2)(v4.value1)); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 55, column 15 - line 57, column 57: " + [ v4.constructor.name ]); - }); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 51, column 23 - line 57, column 57: " + [ v3.constructor.name ]); - }); - }; - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(Data_Functor.map(Data_List_Types.functorList)(run)(v)))(function (v3) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff_AVar.peekVar(v1))(function (v4) { - if (v4 instanceof Data_Maybe.Nothing) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(Data_Unit.unit); - }; - if (v4 instanceof Data_Maybe.Just) { - return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(v4.value0); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 59, column 24 - line 61, column 33: " + [ v4.constructor.name ]); - }); - }); - }); - }); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 43, column 19 - line 61, column 33: " + [ v.constructor.name ]); - }; - var handleLifecycle = function (lchs) { - return function (f) { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(lchs)({ - initializers: Data_List_Types.Nil.value, - finalizers: Data_List_Types.Nil.value - })))(function () { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(f))(function (v) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(lchs)))(function (v1) { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(v1.finalizers)))(function () { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(parSequenceAff_(v1.initializers))(function () { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v); - }); - }); - }); - }); - }); - }; - }; - var $$eval = function (render) { - return function (r) { - var go = function (ref) { - return function (v) { - if (v instanceof Halogen_Query_HalogenM.State) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { - var v2 = v.value0(v1.state); - if (Unsafe_Reference.unsafeRefEq(v1.state)(v2.value1)) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v2.value0); - }; - if (Data_Boolean.otherwise) { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.writeRef(ref)((function () { - var $61 = {}; - for (var $62 in v1) { - if ({}.hasOwnProperty.call(v1, $62)) { - $61[$62] = v1[$62]; - }; - }; - $61.state = v2.value1; - return $61; - })())))(function () { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(handleLifecycle(v1.lifecycleHandlers)(render(v1.lifecycleHandlers)(ref)))(function () { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v2.value0); - }); - }); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 106, column 7 - line 112, column 21: " + [ v2.constructor.name ]); - }); - }; - if (v instanceof Halogen_Query_HalogenM.Subscribe) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAff(Control_Bind.bind(Control_Monad_Aff.bindAff)(Halogen_Query_EventSource.unEventSource(v.value0))(function (v2) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref["modifyRef'"](v1.fresh)(function (i) { - return { - state: i + 1 | 0, - value: i - }; - })))(function (v3) { - var done$prime = Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v1.subscriptions)))(function (v4) { - return Control_Applicative.when(Control_Monad_Aff.applicativeAff)(Data_Maybe.maybe(false)(Data_Map.member(Data_Ord.ordInt)(v3))(v4))(Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(v2.done)(function () { - return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(v1.subscriptions)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map["delete"](Data_Ord.ordInt)(v3)))); - })); - }); - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(v1.subscriptions)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map.insert(Data_Ord.ordInt)(v3)(done$prime)))))(function () { - var consumer = Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Control_Coroutine["await"](Control_Monad_Aff.monadAff))(function (v4) { - return Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(Control_Coroutine.functorAwait))(Control_Monad_Aff.monadAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v1.subscriptions))))(function (v5) { - return Control_Applicative.when(Control_Monad_Free_Trans.applicativeFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Data_Maybe.isJust(v5))(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(Control_Coroutine.functorAwait))(Control_Monad_Aff.monadAff)(evalF(ref)(v4)))(function (v6) { - return Control_Applicative.when(Control_Monad_Free_Trans.applicativeFreeT(Control_Coroutine.functorAwait)(Control_Monad_Aff.monadAff))(Data_Eq.eq(Halogen_Query_EventSource.eqSubscribeStatus)(v6)(Halogen_Query_EventSource.Listening.value))(consumer); - })); - }); - }); - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Coroutine.runProcess(Control_Monad_Aff.monadRecAff)(Control_Coroutine.pullFrom(Control_Monad_Aff.monadRecAff)(consumer)(v2.producer)))(function () { - return done$prime; - }); - }); - }); - }))))(function () { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1); - }); - }); - }; - if (v instanceof Halogen_Query_HalogenM.Lift) { - return v.value0; - }; - if (v instanceof Halogen_Query_HalogenM.Halt) { - return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error(v.value0)); - }; - if (v instanceof Halogen_Query_HalogenM.GetSlots) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value0(Data_Functor.map(Data_List_Types.functorList)(Halogen_Data_OrdBox.unOrdBox)(Data_Map.keys(v1.children)))); - }); - }; - if (v instanceof Halogen_Query_HalogenM.CheckSlot) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1(Data_Map.member(Halogen_Data_OrdBox.ordOrdBox)(v1.component.mkOrdBox(v.value0))(v1.children))); - }); - }; - if (v instanceof Halogen_Query_HalogenM.ChildQuery) { - return evalChildQuery(ref)(v.value0)(v.value1); - }; - if (v instanceof Halogen_Query_HalogenM.Raise) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(queuingHandler(v1.handler)(v1.pendingOuts)(v.value0))(function () { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1); - }); - }); - }; - if (v instanceof Halogen_Query_HalogenM.Par) { - return Control_Parallel_Class.sequential(Control_Monad_Aff.parallelParAff)(Control_Applicative_Free.retractFreeAp(Control_Monad_Aff.applicativeParAff)(Control_Applicative_Free.hoistFreeAp(function ($128) { - return Control_Parallel_Class.parallel(Control_Monad_Aff.parallelParAff)(evalM(ref)($128)); - })(v.value0))); - }; - if (v instanceof Halogen_Query_HalogenM.Fork) { - return Halogen_Query_ForkF.unFork(function (v1) { - return Data_Functor.map(Control_Monad_Aff.functorAff)(function ($129) { - return v1.value1(Data_Functor.map(Data_Functor.functorFn)(Control_Monad_Aff_Unsafe.unsafeCoerceAff)($129)); - })(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff)(evalM(ref)(v1.value0))); - })(v.value0); - }; - if (v instanceof Halogen_Query_HalogenM.GetRef) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v1) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value1(Data_StrMap.lookup(v.value0)(v1.refs))); - }); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 103, column 12 - line 158, column 34: " + [ v.constructor.name ]); - }; - }; - var evalM = function (ref) { - return function (v) { - return Control_Monad_Free.foldFree(Control_Monad_Aff.monadRecAff)(go(ref))(v); - }; - }; - var evalF = function (ref) { - return function (q) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { - var v1 = v["component"]["eval"](q); - return Control_Monad_Free.foldFree(Control_Monad_Aff.monadRecAff)(go(ref))(v1); - }); - }; - }; - var evalChildQuery = function (ref) { - return function (p) { - return Data_Coyoneda.unCoyoneda(function (k) { - return function (q) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { - var v1 = Data_Map.lookup(Halogen_Data_OrdBox.ordOrdBox)(v.component.mkOrdBox(p))(v.children); - if (v1 instanceof Data_Maybe.Just) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(v1.value0)))(function (v2) { - return Halogen_Aff_Driver_State.unDriverStateX(function (ds) { - var v3 = ds.prjQuery(q); - if (v3 instanceof Data_Maybe.Just) { - return Data_Functor.map(Control_Monad_Aff.functorAff)(k)(evalF(ds.selfRef)(v3.value0)); - }; - if (v3 instanceof Data_Maybe.Nothing) { - return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error("Query projection failed for child query")); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 171, column 32 - line 173, column 82: " + [ v3.constructor.name ]); - })(v2); - }); - }; - if (v1 instanceof Data_Maybe.Nothing) { - return Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error("Slot lookup failed for child query")); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 168, column 5 - line 174, column 73: " + [ v1.constructor.name ]); - }); - }; - }); - }; - }; - return function (v) { - if (v instanceof Halogen_Query_InputF.RefUpdate) { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(r)(function (v1) { - var $121 = {}; - for (var $122 in v1) { - if ({}.hasOwnProperty.call(v1, $122)) { - $121[$122] = v1[$122]; - }; - }; - $121.refs = Data_StrMap.alter(Data_Function["const"](v.value1))(v.value0)(v1.refs); - return $121; - })))(function () { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(v.value2); - }); - }; - if (v instanceof Halogen_Query_InputF.Query) { - return evalF(r)(v.value0); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval line 89, column 3 - line 94, column 25: " + [ v.constructor.name ]); - }; - }; - }; - exports["eval"] = $$eval; - exports["handleLifecycle"] = handleLifecycle; - exports["parSequenceAff_"] = parSequenceAff_; - exports["queuingHandler"] = queuingHandler; -})(PS["Halogen.Aff.Driver.Eval"] = PS["Halogen.Aff.Driver.Eval"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Coroutine = PS["Control.Coroutine"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Console = PS["Control.Monad.Eff.Console"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"]; - var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var Data_Either = PS["Data.Either"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_List = PS["Data.List"]; - var Data_List_Types = PS["Data.List.Types"]; - var Data_Map = PS["Data.Map"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Semiring = PS["Data.Semiring"]; - var Data_Traversable = PS["Data.Traversable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen = PS["Halogen"]; - var Halogen_Aff_Driver_Eval = PS["Halogen.Aff.Driver.Eval"]; - var Halogen_Aff_Driver_State = PS["Halogen.Aff.Driver.State"]; - var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; - var Halogen_Component = PS["Halogen.Component"]; - var Halogen_Data_OrdBox = PS["Halogen.Data.OrdBox"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Prelude = PS["Prelude"]; - var newLifecycleHandlers = Control_Monad_Eff_Ref.newRef({ - initializers: Data_List_Types.Nil.value, - finalizers: Data_List_Types.Nil.value - }); - var handleAff = function ($63) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(Control_Monad_Aff.runAff(Control_Monad_Eff_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit)))($63)); - }; - var runUI = function (renderSpec) { - return function (component) { - return function (i) { - var subscribe = function (fresh) { - return function (ref) { - return function (consumer) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff_AVar.makeVar)(function (v) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(function __do() { - var v1 = Control_Monad_Eff_Ref.readRef(fresh)(); - Control_Monad_Eff_Ref.modifyRef(fresh)(function (v2) { - return v2 + 1 | 0; - })(); - Control_Monad_Eff_Ref.modifyRef(ref)(Data_Map.insert(Data_Ord.ordInt)(v1)(v))(); - return v1; - }))(function (v1) { - var producer = Control_Coroutine.producer(Control_Monad_Aff.monadAff)(Data_Functor.map(Control_Monad_Aff.functorAff)(Data_Either.Left.create)(Control_Monad_Aff_AVar.takeVar(v))); - return Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAff(Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Coroutine.runProcess(Control_Monad_Aff.monadRecAff)(Control_Coroutine.connect(Control_Monad_Aff.monadRecAff)(Control_Monad_Aff.parallelParAff)(producer)(consumer)))(function () { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.modifyRef(ref)(Data_Map["delete"](Data_Ord.ordInt)(v1))))(function () { - return Control_Monad_Aff_AVar.killVar(v)(Control_Monad_Eff_Exception.error("ended")); - }); - }))); - }); - }); - }; - }; - }; - var rootHandler = function (ref) { - return function (message) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.readRef(ref)))(function (v) { - return Data_Functor["void"](Control_Monad_Aff.functorAff)(Control_Monad_Aff.forkAll(Data_Map.foldableMap)(Data_Functor.map(Data_Map.functorMap)(function ($$var) { - return Control_Monad_Aff_AVar.putVar($$var)(message); - })(v))); - }); - }; - }; - var handlePending = function (ref) { - return function __do() { - var v = Control_Monad_Eff_Ref.readRef(ref)(); - Control_Monad_Eff_Ref.writeRef(ref)(Data_Maybe.Nothing.value)(); - return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(v)(function ($64) { - return handleAff(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(Data_List.reverse($64))); - })(); - }; - }; - var cleanupSubscriptions = function (v) { - return function __do() { - Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(function ($65) { - return handleAff(Control_Monad_Aff.forkAll(Data_Map.foldableMap)($65)); - }))(Control_Monad_Eff_Ref.readRef(v.subscriptions))(); - return Control_Monad_Eff_Ref.writeRef(v.subscriptions)(Data_Maybe.Nothing.value)(); - }; - }; - var squashChildInitializers = function (lchs) { - return function (preInits) { - return Halogen_Aff_Driver_State.unDriverStateX(function (st) { - var parentInitializer = Data_Functor.map(Data_Maybe.functorMaybe)(function ($66) { - return evalF(st.selfRef)(Halogen_Query_InputF.Query.create($66)); - })(st.component.initializer); - return Control_Monad_Eff_Ref.modifyRef(lchs)(function (handlers) { - return { - initializers: new Data_List_Types.Cons(Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Halogen_Aff_Driver_Eval.parSequenceAff_(Data_List.reverse(handlers.initializers)))(function () { - return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(Data_Foldable.sequence_(Control_Monad_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(parentInitializer))(function () { - return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(function __do() { - handlePending(st.pendingQueries)(); - return handlePending(st.pendingOuts)(); - }); - }); - }), preInits), - finalizers: handlers.finalizers - }; - }); - }); - }; - }; - var runComponent = function (lchs) { - return function (handler) { - return function (j) { - return function (prjQuery) { - return Halogen_Component.unComponent(function (c) { - return function __do() { - var v = newLifecycleHandlers(); - var v1 = Halogen_Aff_Driver_State.initDriverState(c)(j)(handler)(prjQuery)(v)(); - var v2 = Control_Monad_Eff_Ref.readRef(lchs)(); - Control_Monad_Eff_Ref.writeRef(lchs)({ - initializers: Data_List_Types.Nil.value, - finalizers: v2.finalizers - })(); - Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Halogen_Aff_Driver_State.unDriverStateX(function ($67) { - return render(lchs)((function (v3) { - return v3.selfRef; - })($67)); - }))(Control_Monad_Eff_Ref.readRef(v1))(); - Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(squashChildInitializers(lchs)(v2.initializers))(Control_Monad_Eff_Ref.readRef(v1))(); - return v1; - }; - }); - }; - }; - }; - }; - var renderChild = function (lchs) { - return function (handler) { - return function (mkOrdBox) { - return function (childrenInRef) { - return function (childrenOutRef) { - return Halogen_Component.unComponentSlot(function (p) { - return function (ctor) { - return function (input) { - return function (inputQuery) { - return function (outputQuery) { - return function (prjQuery) { - var ordP = mkOrdBox(p); - return function __do() { - var v = Control_Monad_Eff_Ref.readRef(childrenInRef)(); - var v1 = (function () { - var v1 = Data_Map.pop(Halogen_Data_OrdBox.ordOrdBox)(ordP)(v); - if (v1 instanceof Data_Maybe.Just) { - return function __do() { - Control_Monad_Eff_Ref.writeRef(childrenInRef)(v1.value0.value1)(); - Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(inputQuery(input))(function (q) { - return function __do() { - var v2 = Control_Monad_Eff_Ref.readRef(v1.value0.value0)(); - return Halogen_Aff_Driver_State.unDriverStateX(function (st) { - return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(st.prjQuery(q))(function ($68) { - return handleAff(evalF(st.selfRef)(Halogen_Query_InputF.Query.create($68))); - }); - })(v2)(); - }; - })(); - return v1.value0.value0; - }; - }; - if (v1 instanceof Data_Maybe.Nothing) { - return runComponent(lchs)(function ($69) { - return Data_Maybe.maybe(Control_Applicative.pure(Control_Monad_Aff.applicativeAff)(Data_Unit.unit))(handler)(outputQuery($69)); - })(input)(prjQuery)(ctor); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver line 260, column 14 - line 268, column 92: " + [ v1.constructor.name ]); - })()(); - var v2 = Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Map.member(Halogen_Data_OrdBox.ordOrdBox)(ordP))(Control_Monad_Eff_Ref.readRef(childrenOutRef))(); - Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v2)(Control_Monad_Eff_Unsafe.unsafeCoerceEff(Control_Monad_Eff_Console.warn("Halogen: Duplicate slot address was detected during rendering, unexpected results may occur")))(); - Control_Monad_Eff_Ref.modifyRef(childrenOutRef)(Data_Map.insert(Halogen_Data_OrdBox.ordOrdBox)(ordP)(v1))(); - return Control_Bind.bind(Control_Monad_Eff.bindEff)(Control_Monad_Eff_Ref.readRef(v1))(Halogen_Aff_Driver_State.renderStateX(Control_Monad_Eff.functorEff)(function (v3) { - if (v3 instanceof Data_Maybe.Nothing) { - return Control_Monad_Eff_Exception["throw"]("Halogen internal error: child was not initialized in renderChild"); - }; - if (v3 instanceof Data_Maybe.Just) { - return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(renderSpec.renderChild(v3.value0)); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver line 274, column 36 - line 276, column 50: " + [ v3.constructor.name ]); - }))(); - }; - }; - }; - }; - }; - }; - }); - }; - }; - }; - }; - }; - var render = function (lchs) { - return function ($$var) { - return function __do() { - var v = Control_Monad_Eff_Ref.readRef($$var)(); - var v1 = Data_Functor.map(Control_Monad_Eff.functorEff)(Data_Maybe.isNothing)(Control_Monad_Eff_Ref.readRef(v.pendingHandlers))(); - Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v1)(Control_Monad_Eff_Ref.writeRef(v.pendingHandlers)(new Data_Maybe.Just(Data_List_Types.Nil.value)))(); - Control_Monad_Eff_Ref.writeRef(v.childrenOut)(Data_Map.empty)(); - Control_Monad_Eff_Ref.writeRef(v.childrenIn)(v.children)(); - var handler = Halogen_Aff_Driver_Eval.queuingHandler(function ($70) { - return Data_Functor["void"](Control_Monad_Aff.functorAff)(evalF(v.selfRef)($70)); - })(v.pendingHandlers); - var childHandler = Halogen_Aff_Driver_Eval.queuingHandler(function ($71) { - return handler(Halogen_Query_InputF.Query.create($71)); - })(v.pendingQueries); - var v2 = renderSpec.render(function ($72) { - return handleAff(handler($72)); - })(renderChild(lchs)(childHandler)(v.component.mkOrdBox)(v.childrenIn)(v.childrenOut))(v.component.render(v.state))(v.rendering)(); - var v3 = Control_Monad_Eff_Ref.readRef(v.childrenOut)(); - Control_Bind.bind(Control_Monad_Eff.bindEff)(Control_Monad_Eff_Ref.readRef(v.childrenIn))(Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Map.foldableMap)(function (childVar) { - return function __do() { - var v4 = Control_Monad_Eff_Ref.readRef(childVar)(); - Halogen_Aff_Driver_State.renderStateX_(Control_Monad_Eff.applicativeEff)(renderSpec.removeChild)(v4)(); - return finalize(lchs)(v4)(); - }; - }))(); - Control_Monad_Eff_Ref.modifyRef(v.selfRef)(function (v4) { - return { - rendering: new Data_Maybe.Just(v2), - children: v3, - component: v4.component, - state: v4.state, - refs: v4.refs, - childrenIn: v4.childrenIn, - childrenOut: v4.childrenOut, - selfRef: v4.selfRef, - handler: v4.handler, - pendingQueries: v4.pendingQueries, - pendingOuts: v4.pendingOuts, - pendingHandlers: v4.pendingHandlers, - prjQuery: v4.prjQuery, - fresh: v4.fresh, - subscriptions: v4.subscriptions, - lifecycleHandlers: v4.lifecycleHandlers - }; - })(); - return Control_Applicative.when(Control_Monad_Eff.applicativeEff)(v1)(Data_Function.flip(Control_Monad_Rec_Class.tailRecM(Control_Monad_Rec_Class.monadRecEff))(Data_Unit.unit)(function (v4) { - return function __do() { - var v5 = Control_Monad_Eff_Ref.readRef(v.pendingHandlers)(); - Control_Monad_Eff_Ref.writeRef(v.pendingHandlers)(new Data_Maybe.Just(Data_List_Types.Nil.value))(); - Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(function ($73) { - return handleAff(Control_Monad_Aff.forkAll(Data_List_Types.foldableList)(Data_List.reverse($73))); - })(v5)(); - var v6 = Control_Monad_Eff_Ref.readRef(v.pendingHandlers)(); - var $57 = Data_Maybe.maybe(false)(Data_List["null"])(v6); - if ($57) { - return Data_Functor.voidLeft(Control_Monad_Eff.functorEff)(Control_Monad_Eff_Ref.writeRef(v.pendingHandlers)(Data_Maybe.Nothing.value))(new Control_Monad_Rec_Class.Done(Data_Unit.unit))(); - }; - return new Control_Monad_Rec_Class.Loop(Data_Unit.unit); - }; - }))(); - }; - }; - }; - var finalize = function (lchs) { - return Halogen_Aff_Driver_State.unDriverStateX(function (st) { - return function __do() { - cleanupSubscriptions(st)(); - Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(function ($74) { - return evalF(st.selfRef)(Halogen_Query_InputF.Query.create($74)); - })(st.component.finalizer))(function (f) { - return Control_Monad_Eff_Ref.modifyRef(lchs)(function (handlers) { - return { - initializers: handlers.initializers, - finalizers: new Data_List_Types.Cons(f, handlers.finalizers) - }; - }); - })(); - return Data_Foldable.for_(Control_Monad_Eff.applicativeEff)(Data_Map.foldableMap)(st.children)(Control_Bind.composeKleisliFlipped(Control_Monad_Eff.bindEff)(finalize(lchs))(Control_Monad_Eff_Ref.readRef))(); - }; - }); - }; - var evalF = function (ref) { - return Halogen_Aff_Driver_Eval["eval"](render)(ref); - }; - var evalDriver = function (ref) { - return function (prjQuery) { - return function (q) { - var v = prjQuery(q); - if (v instanceof Data_Maybe.Just) { - return evalF(ref)(new Halogen_Query_InputF.Query(v.value0)); - }; - if (v instanceof Data_Maybe.Nothing) { - return Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Exception.throwException(Control_Monad_Eff_Exception.error("Halogen internal error: query projection failed in runUI'"))); - }; - throw new Error("Failed pattern match at Halogen.Aff.Driver line 138, column 5 - line 140, column 110: " + [ v.constructor.name ]); - }; - }; - }; - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(newLifecycleHandlers))(function (v) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Monad_Eff_Ref.newRef(0)))(function (v1) { - return Halogen_Aff_Driver_Eval.handleLifecycle(v)(function __do() { - var v2 = Control_Monad_Eff_Ref.newRef(Data_Map.empty)(); - return Control_Bind.bind(Control_Monad_Eff.bindEff)(Control_Bind.bind(Control_Monad_Eff.bindEff)(runComponent(v)(rootHandler(v2))(i)(Data_Maybe.Just.create)(component))(Control_Monad_Eff_Ref.readRef))(Halogen_Aff_Driver_State.unDriverStateX(function (st) { - return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)({ - query: evalDriver(st.selfRef)(st.prjQuery), - subscribe: subscribe(v1)(v2) - }); - }))(); - }); - }); - }); - }; - }; - }; - exports["runUI"] = runUI; -})(PS["Halogen.Aff.Driver"] = PS["Halogen.Aff.Driver"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"]; - var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"]; - var Control_Monad_Except = PS["Control.Monad.Except"]; - var Control_Semigroupoid = PS["Control.Semigroupoid"]; - var DOM = PS["DOM"]; - var DOM_Event_EventTarget = PS["DOM.Event.EventTarget"]; - var DOM_HTML = PS["DOM.HTML"]; - var DOM_HTML_Event_EventTypes = PS["DOM.HTML.Event.EventTypes"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_HTML_Window = PS["DOM.HTML.Window"]; - var DOM_Node_ParentNode = PS["DOM.Node.ParentNode"]; - var Data_Either = PS["Data.Either"]; - var Data_Foreign = PS["Data.Foreign"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; - var Prelude = PS["Prelude"]; - var selectElement = function (query) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(Control_Bind.composeKleisliFlipped(Control_Monad_Eff.bindEff)(function ($8) { - return DOM_Node_ParentNode.querySelector(query)(DOM_HTML_Types.htmlDocumentToParentNode($8)); - })(DOM_HTML_Window.document))(DOM_HTML.window)))(function (v) { - return Control_Applicative.pure(Control_Monad_Aff.applicativeAff)((function () { - if (v instanceof Data_Maybe.Nothing) { - return Data_Maybe.Nothing.value; - }; - if (v instanceof Data_Maybe.Just) { - return Data_Either.either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create)(Control_Monad_Except.runExcept(DOM_HTML_Types.readHTMLElement(Data_Foreign.toForeign(v.value0)))); - }; - throw new Error("Failed pattern match at Halogen.Aff.Util line 53, column 8 - line 55, column 88: " + [ v.constructor.name ]); - })()); - }); - }; - var runHalogenAff = function ($9) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(Control_Monad_Aff.runAff(Control_Monad_Eff_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit)))($9)); - }; - var awaitLoad = Control_Monad_Aff.makeAff(function (v) { - return function (callback) { - return Control_Monad_Eff_Class.liftEff(Control_Monad_Eff_Class.monadEffEff)(function __do() { - var $10 = DOM_HTML.window(); - return DOM_Event_EventTarget.addEventListener(DOM_HTML_Event_EventTypes.load)(DOM_Event_EventTarget.eventListener(function (v1) { - return callback(Data_Unit.unit); - }))(false)(DOM_HTML_Types.windowToEventTarget($10))(); - }); - }; - }); - var awaitBody = Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Aff.bindAff)(awaitLoad)(function () { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(selectElement("body"))(function (v) { - return Data_Maybe.maybe(Control_Monad_Error_Class.throwError(Control_Monad_Aff.monadThrowAff)(Control_Monad_Eff_Exception.error("Could not find body")))(Control_Applicative.pure(Control_Monad_Aff.applicativeAff))(v); - }); - }); - exports["awaitBody"] = awaitBody; - exports["awaitLoad"] = awaitLoad; - exports["runHalogenAff"] = runHalogenAff; - exports["selectElement"] = selectElement; -})(PS["Halogen.Aff.Util"] = PS["Halogen.Aff.Util"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var DOM = PS["DOM"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Array = PS["Data.Array"]; - var Data_Eq = PS["Data.Eq"]; - var Data_Function_Uncurried = PS["Data.Function.Uncurried"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Nullable = PS["Data.Nullable"]; - var Data_Tuple = PS["Data.Tuple"]; - var Halogen_VDom_Machine = PS["Halogen.VDom.Machine"]; - var Halogen_VDom_Types = PS["Halogen.VDom.Types"]; - var Halogen_VDom_Util = PS["Halogen.VDom.Util"]; - var Prelude = PS["Prelude"]; - var eqElemSpec = function (a, b) { - if (Data_Eq.eq(Halogen_VDom_Types.eqElemName)(a.value1)(b.value1)) { - if (a.value0 instanceof Data_Maybe.Just && (b.value0 instanceof Data_Maybe.Just && a.value0.value0 === b.value0.value0)) { - return true; - }; - if (a.value0 instanceof Data_Maybe.Nothing && b.value0 instanceof Data_Maybe.Nothing) { - return true; - }; - return false; - }; - return false; - }; - var buildWidget = function (v) { - var patch = function (v1) { - return function (v2) { - if (v2 instanceof Halogen_VDom_Types.Grafted) { - return patch(v1)(Halogen_VDom_Types.runGraft(v2.value0)); - }; - if (v2 instanceof Halogen_VDom_Types.Widget) { - return function __do() { - var v3 = v1.value1(v2.value0)(); - return new Halogen_VDom_Machine.Step(v3.value0, patch(v3), v3.value2); - }; - }; - return function __do() { - v1.value2(); - return buildVDom(v)(v2)(); - }; - }; - }; - var render = function (w) { - return function __do() { - var v1 = v.buildWidget(v)(w)(); - return new Halogen_VDom_Machine.Step(v1.value0, patch(v1), v1.value2); - }; - }; - return render; - }; - var buildVDom = function (spec) { - var render = function (v) { - if (v instanceof Halogen_VDom_Types.Text) { - return buildText(spec)(v.value0); - }; - if (v instanceof Halogen_VDom_Types.Elem) { - return buildElem(spec)(v.value0)(v.value1); - }; - if (v instanceof Halogen_VDom_Types.Keyed) { - return buildKeyed(spec)(v.value0)(v.value1); - }; - if (v instanceof Halogen_VDom_Types.Widget) { - return buildWidget(spec)(v.value0); - }; - if (v instanceof Halogen_VDom_Types.Grafted) { - return buildVDom(spec)(Halogen_VDom_Types.runGraft(v.value0)); - }; - throw new Error("Failed pattern match at Halogen.VDom.DOM line 58, column 12 - line 63, column 44: " + [ v.constructor.name ]); - }; - return render; - }; - var buildText = function (v) { - var done = function (node) { - return function __do() { - var v1 = Halogen_VDom_Util.unsafeParent(node); - return Halogen_VDom_Util.removeChild(node, v1)(); - }; - }; - var patch = function (node, s1) { - return function (v1) { - if (v1 instanceof Halogen_VDom_Types.Grafted) { - return patch(node, s1)(Halogen_VDom_Types.runGraft(v1.value0)); - }; - if (v1 instanceof Halogen_VDom_Types.Text) { - var res = new Halogen_VDom_Machine.Step(node, patch(node, v1.value0), done(node)); - var v2 = s1 === v1.value0; - if (v2) { - return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(res); - }; - return function __do() { - Halogen_VDom_Util.setTextContent(v1.value0, node)(); - return res; - }; - }; - return function __do() { - done(node)(); - return buildVDom(v)(v1)(); - }; - }; - }; - var render = function (s) { - return function __do() { - var v1 = Halogen_VDom_Util.createTextNode(s, v.document)(); - return new Halogen_VDom_Machine.Step(v1, patch(v1, s), done(v1)); - }; - }; - return render; - }; - var buildKeyed = function (v) { - var done = function (node, attrs, steps) { - return function __do() { - var v1 = Halogen_VDom_Util.unsafeParent(node); - Halogen_VDom_Util.removeChild(node, v1)(); - Halogen_VDom_Util.forInE(steps, function (v2, v3) { - return v3.value2; - })(); - return Halogen_VDom_Machine.halt(attrs)(); - }; - }; - var patch = function (node, attrs, v1, ch1, len1) { - return function (v2) { - if (v2 instanceof Halogen_VDom_Types.Grafted) { - return patch(node, attrs, v1, ch1, len1)(Halogen_VDom_Types.runGraft(v2.value0)); - }; - if (v2 instanceof Halogen_VDom_Types.Keyed && eqElemSpec(v1, v2.value0)) { - var v3 = Data_Array.length(v2.value1); - if (len1 === 0 && v3 === 0) { - return function __do() { - var v5 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); - return new Halogen_VDom_Machine.Step(node, patch(node, v5, v2.value0, ch1, 0), done(node, v5, ch1)); - }; - }; - var onThis = function (k, v5) { - return v5.value2; - }; - var onThese = function (k, ix$prime, v5, v6) { - return function __do() { - var v7 = v5.value1(v6.value1)(); - Halogen_VDom_Util.insertChildIx(ix$prime, v7.value0, node)(); - return v7; - }; - }; - var onThat = function (k, ix, v5) { - return function __do() { - var v6 = buildVDom(v)(v5.value1)(); - Halogen_VDom_Util.insertChildIx(ix, v6.value0, node)(); - return v6; - }; - }; - return function __do() { - var v5 = Halogen_VDom_Util.diffWithKeyAndIxE(ch1, v2.value1, Data_Tuple.fst, onThese, onThis, onThat)(); - var v6 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); - return new Halogen_VDom_Machine.Step(node, patch(node, v6, v2.value0, v5, v3), done(node, v6, v5)); - }; - }; - return function __do() { - done(node, attrs, ch1)(); - return buildVDom(v)(v2)(); - }; - }; - }; - var render = function (v1) { - return function (ch1) { - return function __do() { - var v2 = Halogen_VDom_Util.createElement(Data_Nullable.toNullable(v1.value0), v1.value1, v.document)(); - var node = DOM_Node_Types.elementToNode(v2); - var onChild = function (k, ix, v3) { - return function __do() { - var v4 = buildVDom(v)(v3.value1)(); - Halogen_VDom_Util.insertChildIx(ix, v4.value0, node)(); - return v4; - }; - }; - var v3 = Halogen_VDom_Util.strMapWithIxE(ch1, Data_Tuple.fst, onChild)(); - var v4 = v.buildAttributes(v2)(v1.value2)(); - return new Halogen_VDom_Machine.Step(node, patch(node, v4, v1, v3, Data_Array.length(ch1)), done(node, v4, v3)); - }; - }; - }; - return render; - }; - var buildElem = function (v) { - var done = function (node, attrs, steps) { - return function __do() { - var v1 = Halogen_VDom_Util.unsafeParent(node); - Halogen_VDom_Util.removeChild(node, v1)(); - Control_Monad_Eff.foreachE(steps)(Halogen_VDom_Machine.halt)(); - return Halogen_VDom_Machine.halt(attrs)(); - }; - }; - var patch = function (node, attrs, v1, ch1) { - return function (v2) { - if (v2 instanceof Halogen_VDom_Types.Grafted) { - return patch(node, attrs, v1, ch1)(Halogen_VDom_Types.runGraft(v2.value0)); - }; - if (v2 instanceof Halogen_VDom_Types.Elem && eqElemSpec(v1, v2.value0)) { - var v3 = Data_Array.length(v2.value1); - var v4 = Data_Array.length(ch1); - if (v4 === 0 && v3 === 0) { - return function __do() { - var v5 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); - return new Halogen_VDom_Machine.Step(node, patch(node, v5, v2.value0, ch1), done(node, v5, ch1)); - }; - }; - var onThis = function (ix, v5) { - return v5.value2; - }; - var onThese = function (ix, v5, vdom) { - return function __do() { - var v6 = v5.value1(vdom)(); - Halogen_VDom_Util.insertChildIx(ix, v6.value0, node)(); - return v6; - }; - }; - var onThat = function (ix, vdom) { - return function __do() { - var v5 = buildVDom(v)(vdom)(); - Halogen_VDom_Util.insertChildIx(ix, v5.value0, node)(); - return v5; - }; - }; - return function __do() { - var v5 = Halogen_VDom_Util.diffWithIxE(ch1, v2.value1, onThese, onThis, onThat)(); - var v6 = Halogen_VDom_Machine.step(attrs)(v2.value0.value2)(); - return new Halogen_VDom_Machine.Step(node, patch(node, v6, v2.value0, v5), done(node, v6, v5)); - }; - }; - return function __do() { - done(node, attrs, ch1)(); - return buildVDom(v)(v2)(); - }; - }; - }; - var render = function (v1) { - return function (ch1) { - return function __do() { - var v2 = Halogen_VDom_Util.createElement(Data_Nullable.toNullable(v1.value0), v1.value1, v.document)(); - var node = DOM_Node_Types.elementToNode(v2); - var onChild = function (ix, child) { - return function __do() { - var v3 = buildVDom(v)(child)(); - Halogen_VDom_Util.insertChildIx(ix, v3.value0, node)(); - return v3; - }; - }; - var v3 = Halogen_VDom_Util.forE(ch1, onChild)(); - var v4 = v.buildAttributes(v2)(v1.value2)(); - return new Halogen_VDom_Machine.Step(node, patch(node, v4, v1, v3), done(node, v4, v3)); - }; - }; - }; - return render; - }; - exports["buildElem"] = buildElem; - exports["buildKeyed"] = buildKeyed; - exports["buildText"] = buildText; - exports["buildVDom"] = buildVDom; - exports["buildWidget"] = buildWidget; -})(PS["Halogen.VDom.DOM"] = PS["Halogen.VDom.DOM"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Category = PS["Control.Category"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"]; - var DOM = PS["DOM"]; - var DOM_HTML = PS["DOM.HTML"]; - var DOM_HTML_Types = PS["DOM.HTML.Types"]; - var DOM_HTML_Window = PS["DOM.HTML.Window"]; - var DOM_Node_Node = PS["DOM.Node.Node"]; - var DOM_Node_Types = PS["DOM.Node.Types"]; - var Data_Foldable = PS["Data.Foldable"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor = PS["Data.Functor"]; - var Data_HeytingAlgebra = PS["Data.HeytingAlgebra"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen_Aff_Driver = PS["Halogen.Aff.Driver"]; - var Halogen_Aff_Driver_State = PS["Halogen.Aff.Driver.State"]; - var Halogen_Aff_Effects = PS["Halogen.Aff.Effects"]; - var Halogen_Component = PS["Halogen.Component"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_Query_InputF = PS["Halogen.Query.InputF"]; - var Halogen_VDom = PS["Halogen.VDom"]; - var Halogen_VDom_DOM = PS["Halogen.VDom.DOM"]; - var Halogen_VDom_DOM_Prop = PS["Halogen.VDom.DOM.Prop"]; - var Halogen_VDom_Machine = PS["Halogen.VDom.Machine"]; - var Prelude = PS["Prelude"]; - var Unsafe_Reference = PS["Unsafe.Reference"]; - var substInParent = function (v) { - return function (v1) { - return function (v2) { - if (v1 instanceof Data_Maybe.Just && v2 instanceof Data_Maybe.Just) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(DOM_Node_Node.insertBefore(v)(v1.value0)(v2.value0)); - }; - if (v1 instanceof Data_Maybe.Nothing && v2 instanceof Data_Maybe.Just) { - return Data_Functor["void"](Control_Monad_Eff.functorEff)(DOM_Node_Node.appendChild(v)(v2.value0)); - }; - return Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit); - }; - }; - }; - var removeChild = function (v) { - return function __do() { - var v1 = DOM_Node_Node.parentNode(v.node)(); - return Data_Foldable.traverse_(Control_Monad_Eff.applicativeEff)(Data_Foldable.foldableMaybe)(function (pn) { - return DOM_Node_Node.removeChild(v.node)(pn); - })(v1)(); - }; - }; - var mkSpec = function (handler) { - return function (renderChildRef) { - return function (document) { - var getNode = Halogen_Aff_Driver_State.unRenderStateX(function (v) { - return v.node; - }); - var done = Control_Applicative.pure(Control_Monad_Eff.applicativeEff)(Data_Unit.unit); - var patch = function (slot) { - return function __do() { - var v = Control_Monad_Eff_Ref.readRef(renderChildRef)(); - var v1 = v(slot)(); - var node = getNode(v1); - return new Halogen_VDom_Machine.Step(node, patch, done); - }; - }; - var buildWidget = function (spec) { - return function (slot) { - return function __do() { - var v = Control_Monad_Eff_Ref.readRef(renderChildRef)(); - var v1 = v(slot)(); - var node = getNode(v1); - return new Halogen_VDom_Machine.Step(node, patch, done); - }; - }; - }; - var buildAttributes = Halogen_VDom_DOM_Prop.buildProp(handler); - return { - buildWidget: buildWidget, - buildAttributes: buildAttributes, - document: document - }; - }; - }; - }; - var renderSpec = function (document) { - return function (container) { - var render = function (handler) { - return function (child) { - return function (v) { - return function (v1) { - if (v1 instanceof Data_Maybe.Nothing) { - return function __do() { - var v2 = Control_Monad_Eff_Ref.newRef(child)(); - var spec = mkSpec(handler)(v2)(document); - var v3 = Halogen_VDom_DOM.buildVDom(spec)(v)(); - var node = Halogen_VDom_Machine.extract(v3); - Data_Functor["void"](Control_Monad_Eff.functorEff)(DOM_Node_Node.appendChild(node)(DOM_HTML_Types.htmlElementToNode(container)))(); - return { - machine: v3, - node: node, - renderChildRef: v2 - }; - }; - }; - if (v1 instanceof Data_Maybe.Just) { - return function __do() { - Control_Monad_Eff_Ref.writeRef(v1.value0.renderChildRef)(child)(); - var v2 = DOM_Node_Node.parentNode(v1.value0.node)(); - var v3 = DOM_Node_Node.nextSibling(v1.value0.node)(); - var v4 = Halogen_VDom_Machine.step(v1.value0.machine)(v)(); - var newNode = Halogen_VDom_Machine.extract(v4); - Control_Applicative.when(Control_Monad_Eff.applicativeEff)(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraBoolean)))(Unsafe_Reference.unsafeRefEq)(v1.value0.node)(newNode))(substInParent(newNode)(v3)(v2))(); - return { - machine: v4, - node: newNode, - renderChildRef: v1.value0.renderChildRef - }; - }; - }; - throw new Error("Failed pattern match at Halogen.VDom.Driver line 121, column 5 - line 137, column 80: " + [ v1.constructor.name ]); - }; - }; - }; - }; - return { - render: render, - renderChild: Control_Category.id(Control_Category.categoryFn), - removeChild: removeChild - }; - }; - }; - var runUI = function (component) { - return function (i) { - return function (element) { - return Control_Bind.bind(Control_Monad_Aff.bindAff)(Control_Monad_Eff_Class.liftEff(Control_Monad_Aff.monadEffAff)(Data_Functor.map(Control_Monad_Eff.functorEff)(DOM_HTML_Types.htmlDocumentToDocument)(Control_Bind.bindFlipped(Control_Monad_Eff.bindEff)(DOM_HTML_Window.document)(DOM_HTML.window))))(function (v) { - return Halogen_Aff_Driver.runUI(renderSpec(v)(element))(component)(i); - }); - }; - }; - }; - exports["runUI"] = runUI; -})(PS["Halogen.VDom.Driver"] = PS["Halogen.VDom.Driver"] || {}); -(function(exports) { - // Generated by purs version 0.11.6 - "use strict"; - var ColorPicker_Halogen_Component = PS["ColorPicker.Halogen.Component"]; - var Control_Applicative = PS["Control.Applicative"]; - var Control_Bind = PS["Control.Bind"]; - var Control_Monad_Aff = PS["Control.Monad.Aff"]; - var Control_Monad_Eff = PS["Control.Monad.Eff"]; - var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"]; - var Data_Either = PS["Data.Either"]; - var Data_Either_Nested = PS["Data.Either.Nested"]; - var Data_Function = PS["Data.Function"]; - var Data_Functor_Coproduct_Nested = PS["Data.Functor.Coproduct.Nested"]; - var Data_Maybe = PS["Data.Maybe"]; - var Data_Ord = PS["Data.Ord"]; - var Data_Unit = PS["Data.Unit"]; - var Halogen = PS["Halogen"]; - var Halogen_Aff = PS["Halogen.Aff"]; - var Halogen_Aff_Util = PS["Halogen.Aff.Util"]; - var Halogen_Component = PS["Halogen.Component"]; - var Halogen_Component_ChildPath = PS["Halogen.Component.ChildPath"]; - var Halogen_HTML = PS["Halogen.HTML"]; - var Halogen_HTML_Core = PS["Halogen.HTML.Core"]; - var Halogen_HTML_Elements = PS["Halogen.HTML.Elements"]; - var Halogen_HTML_Events = PS["Halogen.HTML.Events"]; - var Halogen_Query_HalogenM = PS["Halogen.Query.HalogenM"]; - var Halogen_VDom_Driver = PS["Halogen.VDom.Driver"]; - var Prelude = PS["Prelude"]; - var HandleMsg = (function () { - function HandleMsg(value0, value1, value2) { - this.value0 = value0; - this.value1 = value1; - this.value2 = value2; - }; - HandleMsg.create = function (value0) { - return function (value1) { - return function (value2) { - return new HandleMsg(value0, value1, value2); - }; - }; - }; - return HandleMsg; - })(); - var $$eval = function (v) { - return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(v.value2); - }; - var cpColor = Halogen_Component_ChildPath.cp1; - var render = function (dictMonadEff) { - return function (v) { - return Halogen_HTML_Elements.div_([ Halogen_HTML_Elements.h1_([ Halogen_HTML_Core.text("Picker 1") ]), Halogen_HTML["slot'"](cpColor)(0)(ColorPicker_Halogen_Component.picker(dictMonadEff))(Data_Unit.unit)(Halogen_HTML_Events.input(HandleMsg.create(0))) ]); - }; - }; - var example = function (dictMonadEff) { - return Halogen_Component.parentComponent(Data_Either.ordEither(Data_Ord.ordInt)(Data_Ord.ordVoid))({ - initialState: Data_Function["const"]({}), - render: render(dictMonadEff), - "eval": $$eval, - receiver: Data_Function["const"](Data_Maybe.Nothing.value) - }); - }; - var main = Halogen_Aff_Util.runHalogenAff(Control_Bind.bind(Control_Monad_Aff.bindAff)(Halogen_Aff_Util.awaitBody)(function (v) { - return Halogen_VDom_Driver.runUI(example(Control_Monad_Aff.monadEffAff))(Data_Unit.unit)(v); - })); - exports["HandleMsg"] = HandleMsg; - exports["cpColor"] = cpColor; - exports["eval"] = $$eval; - exports["example"] = example; - exports["main"] = main; - exports["render"] = render; -})(PS["Main"] = PS["Main"] || {}); -PS["Main"].main(); diff --git a/example/index.html b/example/index.html index 53aaf16..e532593 100644 --- a/example/index.html +++ b/example/index.html @@ -5,10 +5,13 @@ diff --git a/example/src/Main.purs b/example/src/Main.purs index c2c798b..b3badd9 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -47,9 +47,22 @@ example = H.parentComponent render ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => State → HTML m render _ = HH.div_ $ [ HH.h1_ [ HH.text "Picker 1" ]] - <> [ HH.slot' cpColor 0 CPicker.picker {mainRectWidth: 200, hueRectWidth: 30} (HE.input (HandleMsg 0))] + <> [ HH.slot' cpColor 0 CPicker.picker config0 (HE.input (HandleMsg 0))] <> [ HH.h1_ [ HH.text "Picker 2" ]] - <> [ HH.slot' cpColor 1 CPicker.picker {mainRectWidth: 300, hueRectWidth: 30} (HE.input (HandleMsg 1))] + <> [ HH.slot' cpColor 1 CPicker.picker config1 (HE.input (HandleMsg 1))] eval ∷ ∀ m. Query ~> DSL m eval (HandleMsg _ _ next) = pure next + +config0 ∷ CPicker.Props +config0 = + { fieldRectWidth: 200 + , sliderRectWidth: 30 + , editing: [CPicker.componentHue <> CPicker.componentSL] + } +config1 ∷ CPicker.Props +config1 = + { fieldRectWidth: 260 + , sliderRectWidth: 30 + , editing: [CPicker.componentHue <> CPicker.componentSV <> CPicker.componentHEX, CPicker.componentRGB] + } diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index c1528ab..767bbed 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -8,14 +8,24 @@ import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) import Data.Either (Either(..), either) -import Data.Int (toNumber) +import Data.Either.Nested as Either +import Data.Foldable (fold, for_) +import Data.Functor.Coproduct.Nested as Coproduct +import Data.Int (floor, toNumber) +import Data.String as String import Data.Maybe (Maybe(..)) import Halogen (liftEff) import Halogen as H +import Halogen.Component.ChildPath as CP import Halogen.HTML as HH import Halogen.HTML.CSS as HCSS import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP +import Halogen.Query.HalogenM (halt) +import Math (round) +import NumberInput.Halogen.Component as Num +import NumberInput.Range (Range(..)) +import PatternInput.Halogen.Component as PatternInput type State = { color ∷ Color.Color -- switch to Maybe Color @@ -24,70 +34,117 @@ type State = type Message = Unit +componentHue :: Array ColorComponent +componentHue = [Hue] + +componentSL :: Array ColorComponent +componentSL = [HSL_S, HSL_L] + +componentSV :: Array ColorComponent +componentSV = [HSV_S, HSV_V] + +componentRGB :: Array ColorComponent +componentRGB = [Red, Green, Blue] + +componentHEX :: Array ColorComponent +componentHEX = [HEX] + +type ColorComponentGroups = Array ColorComponents +type ColorComponents = Array ColorComponent + type Props = - { mainRectWidth ∷ Int - , hueRectWidth ∷ Int + { fieldRectWidth ∷ Int + , sliderRectWidth ∷ Int + , editing ∷ ColorComponentGroups } +data ColorComponent = Hue | HSL_S | HSV_S | HSL_L | HSV_V | Red | Green | Blue | HEX +derive instance colorComponentEq ∷ Eq ColorComponent +derive instance colorComponentOrd ∷ Ord ColorComponent + data Query a = SetProps Props a | FieldDragStart Drag.CursorEvent a | FieldDragMove Drag.DragEvent a | SliderDragStart Drag.CursorEvent a | SliderDragMove Drag.DragEvent a + | ComponentUpdate (Color.Color -> Maybe Color.Color) a + | Init a -type HTML = H.ComponentHTML Query +type ChildQuery = Coproduct.Coproduct2 (Num.Query Number) (PatternInput.Query Color.Color) +type Slot = Either.Either2 ColorComponent Unit -type DSL m = H.ComponentDSL State Query Message m +cpColorComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery ColorComponent Slot +cpColorComponent = CP.cp1 + +cpColorComponentHex ∷ CP.ChildPath (PatternInput.Query Color.Color) ChildQuery Unit Slot +cpColorComponentHex = CP.cp2 + +type HTML m = H.ParentHTML Query ChildQuery Slot m + +type DSL m = H.ParentDSL State Query ChildQuery Slot Message m type PickerEffects r = Drag.DragEffects r initialColor ∷ Color.Color -initialColor = Color.hsl 182.4 0.49 0.64 +initialColor = Color.hsl 180.0 0.5 0.5 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m -picker = H.component +picker = H.lifecycleParentComponent { initialState: { color: initialColor, props: _ } , render , eval , receiver: HE.input SetProps + , initializer: Just $ H.action Init + , finalizer: Nothing } - -render ∷ State → HTML +render ∷ ∀ m. State → HTML m render {color, props} = HH.div [ HP.classes [ HH.ClassName "ColorPicker"] , HCSS.style do + -- TODO remove backgroundColor CSS.backgroundColor color CSS.color if Color.isLight color then CSS.black else CSS.white ] - [ HH.div - [ HP.classes [ HH.ClassName "ColorPicker-color"] + [ dragger, editing ] + where + hsv = Color.toHSVA color + dragger = + HH.div + [ HP.classes [ HH.ClassName "ColorPicker-dragger"] ] + [ field, slider ] + + field = + HH.div + [ HP.classes [ HH.ClassName "ColorPicker-field"] , HCSS.style do - CSS.width $ CSS.px $ toNumber props.mainRectWidth - CSS.backgroundColor $ Color.hsl hsl.h 1.0 0.5 + CSS.width $ CSS.px $ toNumber props.fieldRectWidth + CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 , HE.onMouseDown $ HE.input (Left >>> FieldDragStart) , HE.onTouchStart $ HE.input (Right >>> FieldDragStart) ] - [ HH.div [ HP.classes [ HH.ClassName "ColorPicker-field"]] [] + [ HH.div [ HP.classes [ HH.ClassName "ColorPicker-fieldGradient"]] [] , HH.div [ HP.classes [ HH.ClassName "ColorPicker-fieldSelector"] , HCSS.style do CSS.display CSS.block - CSS.left $ CSS.pct (hsl.s * 100.0) - CSS.bottom $ CSS.pct (hsl.l * 100.0) + CSS.left $ CSS.pct (hsv.s * 100.0) + CSS.bottom $ CSS.pct (hsv.v * 100.0) CSS.backgroundColor color ] [] ] - , HH.div + + slider = + HH.div [ HP.classes [ HH.ClassName "ColorPicker-slider"] , HCSS.style do - CSS.width $ CSS.px $ toNumber props.hueRectWidth + CSS.width $ CSS.px $ toNumber props.sliderRectWidth , HE.onMouseDown $ HE.input (Left >>> SliderDragStart) , HE.onTouchStart $ HE.input (Right >>> SliderDragStart) ] @@ -95,15 +152,164 @@ render {color, props} = [ HP.classes [ HH.ClassName "ColorPicker-sliderSelector"] , HCSS.style do - CSS.top $ CSS.pct ((1.0 - hsl.h / 360.0) * 100.0) + CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) ] [] ] - ] + + editing = + HH.div + [ HP.classes [ HH.ClassName "ColorPicker-editing"] ] + (renderEditingItem <$> props.editing ) + +renderEditingItem :: ∀ m. ColorComponents -> HTML m +renderEditingItem x = HH.div [ HP.classes [ HH.ClassName "ColorPicker-editingItem"] ] $ x <#> case _ of + Hue -> embedNum hasValRound Hue confHue + HSV_S -> embedNum hasValRound HSV_S confSaturation + HSV_V -> embedNum hasValRound HSV_V confValue + HSL_S -> embedNum hasValRound HSL_S confSaturation + HSL_L -> embedNum hasValRound HSL_L confLightness + Red -> embedNum hasvalCail Red confRed + Green -> embedNum hasvalCail Green confGreen + Blue -> embedNum hasvalCail Blue confBlue + HEX -> renderHex + where - hsl = Color.toHSLA color + hasValRound :: Num.HasNumberInputVal Number + hasValRound = Num.numberHasNumberInputVal + {fromString = Num.numberHasNumberInputVal.fromString >>> map roundFractionalNum} + + hasvalCail :: Num.HasNumberInputVal Number + hasvalCail = Num.numberHasNumberInputVal + {fromString = Num.numberHasNumberInputVal.fromString >>> map roundNum} + + embedNum :: Num.HasNumberInputVal Number -> ColorComponent -> Num.Config Number -> HTML m + embedNum hasVal component conf = input conf.placeholder + $ HH.slot' cpColorComponent component (Num.input hasVal conf) unit + $ HE.input \(Num.NotifyChange val) -> ComponentUpdate $ \color -> + val <#> \n -> do + case component of + Hue -> modifyHSL (_{h = n}) color + HSL_S -> modifyHSL (_{s = n / 100.0}) color + HSL_L -> modifyHSL (_{l = n / 100.0}) color + HSV_S -> modifyHSV (_{s = n / 100.0}) color + HSV_V -> modifyHSV (_{v = n / 100.0}) color + Red -> modifyRGB (_{r = asInt n}) color + Green -> modifyRGB (_{g = asInt n}) color + Blue -> modifyRGB (_{b = asInt n}) color + HEX -> color -- hex values will not be comming from Number input + where + asInt = floor + input :: String -> HTML m -> HTML m + input label child = + HH.label [HP.classes [HH.ClassName "ColorPicker-input"]] + [ HH.span [HP.classes [HH.ClassName "ColorPicker-inputLabel"]] [HH.text label] + , child + ] + renderHex = input "#" + $ HH.slot' cpColorComponentHex unit (PatternInput.input + { fromString: \str -> Color.fromHexString $ "#" <> str + , toString: \color -> String.toUpper $ String.drop 1 $ Color.toHexString color + } + { title: "Hex" + , placeholder: "HEX" + , root: [HH.ClassName "ColorPicker-inputElem", HH.ClassName "ColorPicker-inputElem--color"] + , rootInvalid: [HH.ClassName "ColorPicker-inputElem--invalid"] + }) unit + $ HE.input \(PatternInput.NotifyChange val) -> ComponentUpdate $ const val + + +mkConf ∷ ∀ a. { title ∷ String, placeholder ∷ String, range ∷ Range a } -> Num.Config a +mkConf { title, placeholder, range } = + { title + , placeholder + , range + , root: [HH.ClassName "ColorPicker-inputElem"] + , rootInvalid: [HH.ClassName "ColorPicker-inputElem--invalid"] + , rootLength: \n -> [HH.ClassName $ "ColorPicker-inputElem--length-" <> show n] + } + +confRed ∷ Num.Config Number +confRed = mkConf + { title: "Red" + , placeholder: "R" + , range: MinMax 0.0 256.0 + } + +confGreen ∷ Num.Config Number +confGreen = mkConf + { title: "Green" + , placeholder: "G" + , range: MinMax 0.0 256.0 + } + +confBlue ∷ Num.Config Number +confBlue = mkConf + { title: "Blue" + , placeholder: "B" + , range: MinMax 0.0 256.0 + } + +confHue ∷ Num.Config Number +confHue = mkConf + { title: "Hue" + , placeholder: "H" + , range: MinMax 0.0 360.0 + } +confSaturation ∷ Num.Config Number +confSaturation = mkConf + { title: "Saturation" + , placeholder: "S" + , range: MinMax 0.0 100.0 + } +confLightness ∷ Num.Config Number +confLightness = mkConf + { title: "Lightness" + , placeholder: "L" + , range: MinMax 0.0 100.0 + } + +confValue ∷ Num.Config Number +confValue = mkConf + { title: "Value" + , placeholder: "V" + , range: MinMax 0.0 100.0 + } + + + +propagate :: ∀ m. DSL m Unit +propagate = do + { color, props: { editing }} <- H.get + let hsl = Color.toHSLA color + let hsv = Color.toHSVA color + let rgb = Color.toRGBA color + for_ (fold editing) $ case _ of + Hue -> H.query' cpColorComponent Hue (set $ roundFractionalNum hsl.h) >>= mustBeMounted + HSL_S -> H.query' cpColorComponent HSL_S (set $ roundFractionalNum $ 100.0 * hsl.s) >>= mustBeMounted + HSL_L -> H.query' cpColorComponent HSL_L (set $ roundFractionalNum $ 100.0 * hsl.l) >>= mustBeMounted + HSV_S -> H.query' cpColorComponent HSV_S (set $ roundFractionalNum $ 100.0 * hsv.s) >>= mustBeMounted + HSV_V -> H.query' cpColorComponent HSV_V (set $ roundFractionalNum $ 100.0 * hsv.v) >>= mustBeMounted + Red -> H.query' cpColorComponent Red (set $ roundNum $ toNumber rgb.r) >>= mustBeMounted + Green -> H.query' cpColorComponent Green (set $ roundNum $ toNumber rgb.g) >>= mustBeMounted + Blue -> H.query' cpColorComponent Blue (set $ roundNum $ toNumber rgb.b) >>= mustBeMounted + HEX -> H.query' cpColorComponentHex unit (H.action $ PatternInput.SetValue $ Just $ color) >>= mustBeMounted + where + set n = H.action (Num.SetValue $ Just $ roundFractionalNum n) + eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m +eval (Init next) = do + propagate + pure next +eval (ComponentUpdate update next) = do + { color } <- H.get + for_ (update color) $ \color' -> do + H.modify _{ color = color'} + propagate + pure next + + eval (SetProps props next) = do H.modify _{props = props} pure next @@ -112,25 +318,27 @@ eval (FieldDragMove drag next) = do Drag.Move event dragData → do {color} ← H.get let - hsl = Color.toHSLA color - s = dragData.progress.x - l = 1.0 - dragData.progress.y + hsv = Color.toHSVA color + s = roundFractionalNum $ dragData.progress.x + v = roundFractionalNum $ 1.0 - dragData.progress.y H.modify _ - { color = Color.hsl hsl.h s l + { color = Color.hsv hsv.h s v } Drag.Done event → pure unit + propagate pure next eval (SliderDragMove drag next) = do case drag of Drag.Move event dragData → do {color} ← H.get let - h = (1.0 - dragData.progress.y) * 360.0 + h = roundFractionalNum $ (1.0 - dragData.progress.y) * 360.0 hsl = Color.toHSLA color H.modify _ { color = Color.hsl h hsl.s hsl.l } Drag.Done event → pure unit + propagate pure next eval (SliderDragStart event next) = startDrag SliderDragMove event next eval (FieldDragStart event next) = startDrag FieldDragMove event next @@ -147,3 +355,29 @@ startDrag action event next = do liftEff $ either preventDefault preventDefault event initialDragData ← liftEff $ Drag.mkFirstDragData event eval $ action (Drag.Move event initialDragData) next + +type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } +type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } +type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } + +modifyHSL ∷ (RecordHSLA → RecordHSLA) -> Color.Color -> Color.Color +modifyHSL f c = case f (Color.toHSLA c) of {h, s, l, a} -> Color.hsla h s l a + +modifyHSV ∷ (RecordHSVA → RecordHSVA) -> Color.Color -> Color.Color +modifyHSV f c = case f (Color.toHSVA c) of {h, s, v, a} -> Color.hsva h s v a + +modifyRGB ∷ (RecordRGBA → RecordRGBA) -> Color.Color -> Color.Color +modifyRGB f c = case f (Color.toRGBA c) of {r, g, b, a} -> Color.rgba r g b a + +mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a +mustBeMounted (Just x) = pure x +mustBeMounted _ = halt "children must be mounted" + + +roundFractionalNum :: Number -> Number +roundFractionalNum n = roundNum (n * scalar) / scalar + where + scalar = 100.0 + +roundNum :: Number -> Number +roundNum = round diff --git a/src/PatternInput/Halogen/Component.purs b/src/PatternInput/Halogen/Component.purs new file mode 100644 index 0000000..a47f07a --- /dev/null +++ b/src/PatternInput/Halogen/Component.purs @@ -0,0 +1,87 @@ +module PatternInput.Halogen.Component + ( input + , Query(..) + , Message(..) + , Config + , Input + , InputValue + , HasInputVal + ) + where + +import Prelude + +import Control.MonadPlus (guard) +import Data.Maybe (Maybe(..), maybe) +import Data.Tuple (Tuple(..), fst, snd) +import Halogen as H +import Halogen.HTML as HH +import Halogen.HTML.Core (ClassName) +import Halogen.HTML.Events as HE +import Halogen.HTML.Properties as HP + + +type State val = InputValue val +type InputValue val = Tuple (Maybe val) String + +type HasInputVal a = + { fromString ∷ String → Maybe a + , toString ∷ a → String + } + +data Message val = NotifyChange (Input val) +type Input val = Maybe val +data Query val next + = GetValue (Input val → next) + | SetValue (Input val) next + | Update String next + +type DSL val = H.ComponentDSL (State val) (Query val) (Message val) +type HTML val = H.ComponentHTML (Query val) + +type Config val = + { title ∷ String + , placeholder ∷ String + , root ∷ Array ClassName + , rootInvalid ∷ Array ClassName + } + +input ∷ ∀ val m + . Eq val + ⇒ HasInputVal val + → Config val + → H.Component HH.HTML (Query val) Unit (Message val) m +input hasInputVal conf = H.component + { initialState: const $ Tuple Nothing "" + , render: render hasInputVal conf + , eval: eval hasInputVal + , receiver: const Nothing + } + +render ∷ ∀ val. HasInputVal val → Config val → State val → HTML val +render hasInputVal conf value = HH.input + [ HP.type_ HP.InputText + , HP.classes $ conf.root <> (guard (isInvalid value) *> conf.rootInvalid) + , HP.title conf.title + , HP.placeholder conf.placeholder + , HP.value $ snd value + , HE.onValueInput $ HE.input Update + ] + +eval ∷ ∀ val m . Eq val ⇒ HasInputVal val → Query val ~> DSL val m +eval hasInputVal (SetValue val next) = do + prevVal ← H.get + unless (fst prevVal == val) (H.put $ Tuple val (maybe "" hasInputVal.toString val)) + pure next +eval _ (GetValue next) = H.get <#> (fst >>> next) +eval hasInputVal (Update str next) = do + prevVal ← H.get + let nextVal = Tuple (hasInputVal.fromString str) str + H.put nextVal + unless (nextVal == prevVal) $ H.raise (NotifyChange $ fst nextVal) + pure next + +isInvalid ∷ ∀ a. InputValue a → Boolean +isInvalid (Tuple _ "") = false +isInvalid (Tuple Nothing _) = true +isInvalid _ = false From f99642a644db8c5d078a7735450d10db6431e321 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 3 Aug 2017 19:53:51 +0200 Subject: [PATCH 10/72] move classes into Props --- example/index.html | 18 ++-- example/src/Main.purs | 36 ++++++-- src/ColorPicker/Halogen/Component.purs | 123 +++++++++++++------------ 3 files changed, 97 insertions(+), 80 deletions(-) diff --git a/example/index.html b/example/index.html index 2427f9f..90b7d06 100644 --- a/example/index.html +++ b/example/index.html @@ -13,6 +13,12 @@ display: inline-flex; } +.ColorPicker--small .ColorPicker-field { width: 10em; } +.ColorPicker--small .ColorPicker-slider { width: 1em; } + +.ColorPicker--large .ColorPicker-field { width: 15em; } +.ColorPicker--large .ColorPicker-slider { width: 1.5em;} + .ColorPicker-dragger { user-select: none; display: flex; @@ -23,7 +29,6 @@ transition: box-shadow 200ms ease-out; position: relative; height: 100%; - width: 150px; float: left; margin-right: 5px; } @@ -53,7 +58,6 @@ .ColorPicker-slider { box-shadow: 0 0 1px 1px currentColor; transition: box-shadow 200ms ease-out; - width: 20px; position: relative; background: linear-gradient(#f00 0%, #f0f 17%, #00f 34%, #0ff 50%, #0f0 67%, #ff0 84%, #f00 100%); } @@ -65,7 +69,7 @@ border-bottom: 1px solid #000; right: -3px; margin-top: -1px; - width: 10px; + width: 100%; height: 2px; } @@ -94,19 +98,11 @@ .ColorPicker-inputElem { border: solid 1px; padding: 0.3em; -} -.ColorPicker-inputElem--length-3 { width: 5em; } - .ColorPicker-inputElem--invalid { color: red; } - -.ColorPicker-inputElem--color { - width: 5em -} - diff --git a/example/src/Main.purs b/example/src/Main.purs index b3badd9..61dae84 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -3,11 +3,12 @@ module Main where import Prelude import ColorPicker.Halogen.Component as CPicker -import Control.Monad.Eff (Eff) import Control.Monad.Aff.Class (class MonadAff) +import Control.Monad.Eff (Eff) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct import Data.Maybe (Maybe(..)) +import Halogen (ClassName(..)) import Halogen as H import Halogen.Aff as HA import Halogen.Component.ChildPath as CP @@ -55,14 +56,29 @@ eval ∷ ∀ m. Query ~> DSL m eval (HandleMsg _ _ next) = pure next config0 ∷ CPicker.Props -config0 = - { fieldRectWidth: 200 - , sliderRectWidth: 30 - , editing: [CPicker.componentHue <> CPicker.componentSL] - } +config0 = mkConf + [ClassName "ColorPicker--small"] + [CPicker.componentHue <> CPicker.componentSL] + config1 ∷ CPicker.Props -config1 = - { fieldRectWidth: 260 - , sliderRectWidth: 30 - , editing: [CPicker.componentHue <> CPicker.componentSV <> CPicker.componentHEX, CPicker.componentRGB] +config1 = mkConf + [ClassName "ColorPicker--large"] + [CPicker.componentHue <> CPicker.componentSV <> CPicker.componentHEX, CPicker.componentRGB] + +mkConf ∷ Array ClassName -> CPicker.ColorComponentGroups -> CPicker.Props +mkConf root editing = + { rootClasses: [ClassName "ColorPicker"] <> root + , draggerClasses: [ClassName "ColorPicker-dragger"] + , fieldClasses: [ClassName "ColorPicker-field"] + , fieldGradientClasses: [ClassName "ColorPicker-fieldGradient"] + , fieldSelectorClasses: [ClassName "ColorPicker-fieldSelector"] + , sliderClasses: [ClassName "ColorPicker-slider"] + , sliderSelectorClasses: [ClassName "ColorPicker-sliderSelector"] + , editingClasses: [ClassName "ColorPicker-editing"] + , editingItemClasses: [ClassName "ColorPicker-editingItem"] + , inputClasses: [ClassName "ColorPicker-input"] + , inputLabelClasses: [ClassName "ColorPicker-inputLabel"] + , inputElemClasses: [ClassName "ColorPicker-inputElem"] + , inputElemInvalidClasses: [ClassName "ColorPicker-inputElem--invalid"] + , editing } diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 767bbed..a9871b4 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -53,8 +53,19 @@ type ColorComponentGroups = Array ColorComponents type ColorComponents = Array ColorComponent type Props = - { fieldRectWidth ∷ Int - , sliderRectWidth ∷ Int + { rootClasses ∷ Array HH.ClassName + , draggerClasses ∷ Array HH.ClassName + , fieldClasses ∷ Array HH.ClassName + , fieldGradientClasses ∷ Array HH.ClassName + , fieldSelectorClasses ∷ Array HH.ClassName + , sliderClasses ∷ Array HH.ClassName + , sliderSelectorClasses ∷ Array HH.ClassName + , editingClasses ∷ Array HH.ClassName + , editingItemClasses ∷ Array HH.ClassName + , inputClasses ∷ Array HH.ClassName + , inputLabelClasses ∷ Array HH.ClassName + , inputElemClasses ∷ Array HH.ClassName + , inputElemInvalidClasses ∷ Array HH.ClassName , editing ∷ ColorComponentGroups } @@ -102,7 +113,7 @@ picker = H.lifecycleParentComponent render ∷ ∀ m. State → HTML m render {color, props} = HH.div - [ HP.classes [ HH.ClassName "ColorPicker"] + [ HP.classes props.rootClasses , HCSS.style do -- TODO remove backgroundColor CSS.backgroundColor color @@ -115,21 +126,19 @@ render {color, props} = hsv = Color.toHSVA color dragger = HH.div - [ HP.classes [ HH.ClassName "ColorPicker-dragger"] ] + [ HP.classes props.draggerClasses ] [ field, slider ] field = HH.div - [ HP.classes [ HH.ClassName "ColorPicker-field"] - , HCSS.style do - CSS.width $ CSS.px $ toNumber props.fieldRectWidth - CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 + [ HP.classes props.fieldClasses + , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 , HE.onMouseDown $ HE.input (Left >>> FieldDragStart) , HE.onTouchStart $ HE.input (Right >>> FieldDragStart) ] - [ HH.div [ HP.classes [ HH.ClassName "ColorPicker-fieldGradient"]] [] + [ HH.div [ HP.classes props.fieldGradientClasses] [] , HH.div - [ HP.classes [ HH.ClassName "ColorPicker-fieldSelector"] + [ HP.classes props.fieldSelectorClasses , HCSS.style do CSS.display CSS.block CSS.left $ CSS.pct (hsv.s * 100.0) @@ -141,37 +150,32 @@ render {color, props} = slider = HH.div - [ HP.classes - [ HH.ClassName "ColorPicker-slider"] - , HCSS.style do - CSS.width $ CSS.px $ toNumber props.sliderRectWidth - , HE.onMouseDown $ HE.input (Left >>> SliderDragStart) - , HE.onTouchStart $ HE.input (Right >>> SliderDragStart) - ] + [ HP.classes props.sliderClasses + , HE.onMouseDown $ HE.input (Left >>> SliderDragStart) + , HE.onTouchStart $ HE.input (Right >>> SliderDragStart) + ] [ HH.div - [ HP.classes - [ HH.ClassName "ColorPicker-sliderSelector"] - , HCSS.style do - CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) - ] - [] + [ HP.classes props.sliderSelectorClasses + , HCSS.style $ CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) + ] + [] ] editing = HH.div - [ HP.classes [ HH.ClassName "ColorPicker-editing"] ] - (renderEditingItem <$> props.editing ) - -renderEditingItem :: ∀ m. ColorComponents -> HTML m -renderEditingItem x = HH.div [ HP.classes [ HH.ClassName "ColorPicker-editingItem"] ] $ x <#> case _ of - Hue -> embedNum hasValRound Hue confHue - HSV_S -> embedNum hasValRound HSV_S confSaturation - HSV_V -> embedNum hasValRound HSV_V confValue - HSL_S -> embedNum hasValRound HSL_S confSaturation - HSL_L -> embedNum hasValRound HSL_L confLightness - Red -> embedNum hasvalCail Red confRed - Green -> embedNum hasvalCail Green confGreen - Blue -> embedNum hasvalCail Blue confBlue + [ HP.classes props.editingClasses ] + (renderEditingItem props <$> props.editing ) + +renderEditingItem :: ∀ m. Props -> ColorComponents -> HTML m +renderEditingItem props x = HH.div [ HP.classes props.editingItemClasses ] $ x <#> case _ of + Hue -> embedNum hasValRound Hue $ mkConf props confHue + HSV_S -> embedNum hasValRound HSV_S $ mkConf props confSaturation + HSV_V -> embedNum hasValRound HSV_V $ mkConf props confValue + HSL_S -> embedNum hasValRound HSL_S $ mkConf props confSaturation + HSL_L -> embedNum hasValRound HSL_L $ mkConf props confLightness + Red -> embedNum hasvalCail Red $ mkConf props confRed + Green -> embedNum hasvalCail Green $ mkConf props confGreen + Blue -> embedNum hasvalCail Blue $ mkConf props confBlue HEX -> renderHex where @@ -202,8 +206,8 @@ renderEditingItem x = HH.div [ HP.classes [ HH.ClassName "ColorPicker-editingIte asInt = floor input :: String -> HTML m -> HTML m input label child = - HH.label [HP.classes [HH.ClassName "ColorPicker-input"]] - [ HH.span [HP.classes [HH.ClassName "ColorPicker-inputLabel"]] [HH.text label] + HH.label [HP.classes props.inputClasses] + [ HH.span [HP.classes props.inputLabelClasses] [HH.text label] , child ] renderHex = input "#" @@ -213,64 +217,65 @@ renderEditingItem x = HH.div [ HP.classes [ HH.ClassName "ColorPicker-editingIte } { title: "Hex" , placeholder: "HEX" - , root: [HH.ClassName "ColorPicker-inputElem", HH.ClassName "ColorPicker-inputElem--color"] - , rootInvalid: [HH.ClassName "ColorPicker-inputElem--invalid"] + , root: props.inputElemClasses + , rootInvalid: props.inputElemInvalidClasses }) unit $ HE.input \(PatternInput.NotifyChange val) -> ComponentUpdate $ const val +type PreNumConf a = { title ∷ String, placeholder ∷ String, range ∷ Range a } -mkConf ∷ ∀ a. { title ∷ String, placeholder ∷ String, range ∷ Range a } -> Num.Config a -mkConf { title, placeholder, range } = +mkConf ∷ ∀ a. Props -> PreNumConf a -> Num.Config a +mkConf props { title, placeholder, range } = { title , placeholder , range - , root: [HH.ClassName "ColorPicker-inputElem"] - , rootInvalid: [HH.ClassName "ColorPicker-inputElem--invalid"] - , rootLength: \n -> [HH.ClassName $ "ColorPicker-inputElem--length-" <> show n] + , root: props.inputElemClasses + , rootInvalid: props.inputElemInvalidClasses + , rootLength: const [] } -confRed ∷ Num.Config Number -confRed = mkConf +confRed ∷ PreNumConf Number +confRed = { title: "Red" , placeholder: "R" , range: MinMax 0.0 256.0 } -confGreen ∷ Num.Config Number -confGreen = mkConf +confGreen ∷ PreNumConf Number +confGreen = { title: "Green" , placeholder: "G" , range: MinMax 0.0 256.0 } -confBlue ∷ Num.Config Number -confBlue = mkConf +confBlue ∷ PreNumConf Number +confBlue = { title: "Blue" , placeholder: "B" , range: MinMax 0.0 256.0 } -confHue ∷ Num.Config Number -confHue = mkConf +confHue ∷ PreNumConf Number +confHue = { title: "Hue" , placeholder: "H" , range: MinMax 0.0 360.0 } -confSaturation ∷ Num.Config Number -confSaturation = mkConf +confSaturation ∷ PreNumConf Number +confSaturation = { title: "Saturation" , placeholder: "S" , range: MinMax 0.0 100.0 } -confLightness ∷ Num.Config Number -confLightness = mkConf +confLightness ∷ PreNumConf Number +confLightness = { title: "Lightness" , placeholder: "L" , range: MinMax 0.0 100.0 } -confValue ∷ Num.Config Number -confValue = mkConf +confValue ∷ PreNumConf Number +confValue = { title: "Value" , placeholder: "V" , range: MinMax 0.0 100.0 From 1b902044e5ac327337fbcc8c439d7a159ce1e3e5 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 3 Aug 2017 20:14:52 +0200 Subject: [PATCH 11/72] fix field value rounding --- src/ColorPicker/Halogen/Component.purs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index a9871b4..4b43594 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -12,8 +12,8 @@ import Data.Either.Nested as Either import Data.Foldable (fold, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.Int (floor, toNumber) -import Data.String as String import Data.Maybe (Maybe(..)) +import Data.String as String import Halogen (liftEff) import Halogen as H import Halogen.Component.ChildPath as CP @@ -22,7 +22,7 @@ import Halogen.HTML.CSS as HCSS import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Halogen.Query.HalogenM (halt) -import Math (round) +import Math (pow, round) import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) import PatternInput.Halogen.Component as PatternInput @@ -324,8 +324,8 @@ eval (FieldDragMove drag next) = do {color} ← H.get let hsv = Color.toHSVA color - s = roundFractionalNum $ dragData.progress.x - v = roundFractionalNum $ 1.0 - dragData.progress.y + s = roundFractionalNum' 2 $ (dragData.progress.x) + v = roundFractionalNum' 2 $ (1.0 - dragData.progress.y) H.modify _ { color = Color.hsv hsv.h s v } @@ -380,9 +380,12 @@ mustBeMounted _ = halt "children must be mounted" roundFractionalNum :: Number -> Number -roundFractionalNum n = roundNum (n * scalar) / scalar +roundFractionalNum = roundFractionalNum' 0 + +roundFractionalNum' :: Int -> Number -> Number +roundFractionalNum' digits n = roundNum (n * scalar) / scalar where - scalar = 100.0 + scalar = pow 10.0 (toNumber $ digits + 2) roundNum :: Number -> Number roundNum = round From bfdd433a4d12f2f17df5109fec7837b6f61acfd1 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 3 Aug 2017 20:19:29 +0200 Subject: [PATCH 12/72] unicode --- example/src/Main.purs | 2 +- src/ColorPicker/Halogen/Component.purs | 114 ++++++++++++------------ src/ColorPicker/Halogen/Utils/Drag.purs | 4 +- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 61dae84..b7356e3 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -65,7 +65,7 @@ config1 = mkConf [ClassName "ColorPicker--large"] [CPicker.componentHue <> CPicker.componentSV <> CPicker.componentHEX, CPicker.componentRGB] -mkConf ∷ Array ClassName -> CPicker.ColorComponentGroups -> CPicker.Props +mkConf ∷ Array ClassName → CPicker.ColorComponentGroups → CPicker.Props mkConf root editing = { rootClasses: [ClassName "ColorPicker"] <> root , draggerClasses: [ClassName "ColorPicker-dragger"] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 4b43594..bd864c4 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -34,19 +34,19 @@ type State = type Message = Unit -componentHue :: Array ColorComponent +componentHue ∷ Array ColorComponent componentHue = [Hue] -componentSL :: Array ColorComponent +componentSL ∷ Array ColorComponent componentSL = [HSL_S, HSL_L] -componentSV :: Array ColorComponent +componentSV ∷ Array ColorComponent componentSV = [HSV_S, HSV_V] -componentRGB :: Array ColorComponent +componentRGB ∷ Array ColorComponent componentRGB = [Red, Green, Blue] -componentHEX :: Array ColorComponent +componentHEX ∷ Array ColorComponent componentHEX = [HEX] type ColorComponentGroups = Array ColorComponents @@ -79,7 +79,7 @@ data Query a | FieldDragMove Drag.DragEvent a | SliderDragStart Drag.CursorEvent a | SliderDragMove Drag.DragEvent a - | ComponentUpdate (Color.Color -> Maybe Color.Color) a + | ComponentUpdate (Color.Color → Maybe Color.Color) a | Init a type ChildQuery = Coproduct.Coproduct2 (Num.Query Number) (PatternInput.Query Color.Color) @@ -166,45 +166,45 @@ render {color, props} = [ HP.classes props.editingClasses ] (renderEditingItem props <$> props.editing ) -renderEditingItem :: ∀ m. Props -> ColorComponents -> HTML m +renderEditingItem ∷ ∀ m. Props → ColorComponents → HTML m renderEditingItem props x = HH.div [ HP.classes props.editingItemClasses ] $ x <#> case _ of - Hue -> embedNum hasValRound Hue $ mkConf props confHue - HSV_S -> embedNum hasValRound HSV_S $ mkConf props confSaturation - HSV_V -> embedNum hasValRound HSV_V $ mkConf props confValue - HSL_S -> embedNum hasValRound HSL_S $ mkConf props confSaturation - HSL_L -> embedNum hasValRound HSL_L $ mkConf props confLightness - Red -> embedNum hasvalCail Red $ mkConf props confRed - Green -> embedNum hasvalCail Green $ mkConf props confGreen - Blue -> embedNum hasvalCail Blue $ mkConf props confBlue - HEX -> renderHex + Hue → embedNum hasValRound Hue $ mkConf props confHue + HSV_S → embedNum hasValRound HSV_S $ mkConf props confSaturation + HSV_V → embedNum hasValRound HSV_V $ mkConf props confValue + HSL_S → embedNum hasValRound HSL_S $ mkConf props confSaturation + HSL_L → embedNum hasValRound HSL_L $ mkConf props confLightness + Red → embedNum hasvalCail Red $ mkConf props confRed + Green → embedNum hasvalCail Green $ mkConf props confGreen + Blue → embedNum hasvalCail Blue $ mkConf props confBlue + HEX → renderHex where - hasValRound :: Num.HasNumberInputVal Number + hasValRound ∷ Num.HasNumberInputVal Number hasValRound = Num.numberHasNumberInputVal {fromString = Num.numberHasNumberInputVal.fromString >>> map roundFractionalNum} - hasvalCail :: Num.HasNumberInputVal Number + hasvalCail ∷ Num.HasNumberInputVal Number hasvalCail = Num.numberHasNumberInputVal {fromString = Num.numberHasNumberInputVal.fromString >>> map roundNum} - embedNum :: Num.HasNumberInputVal Number -> ColorComponent -> Num.Config Number -> HTML m + embedNum ∷ Num.HasNumberInputVal Number → ColorComponent → Num.Config Number → HTML m embedNum hasVal component conf = input conf.placeholder $ HH.slot' cpColorComponent component (Num.input hasVal conf) unit - $ HE.input \(Num.NotifyChange val) -> ComponentUpdate $ \color -> - val <#> \n -> do + $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → + val <#> \n → do case component of - Hue -> modifyHSL (_{h = n}) color - HSL_S -> modifyHSL (_{s = n / 100.0}) color - HSL_L -> modifyHSL (_{l = n / 100.0}) color - HSV_S -> modifyHSV (_{s = n / 100.0}) color - HSV_V -> modifyHSV (_{v = n / 100.0}) color - Red -> modifyRGB (_{r = asInt n}) color - Green -> modifyRGB (_{g = asInt n}) color - Blue -> modifyRGB (_{b = asInt n}) color - HEX -> color -- hex values will not be comming from Number input + Hue → modifyHSL (_{h = n}) color + HSL_S → modifyHSL (_{s = n / 100.0}) color + HSL_L → modifyHSL (_{l = n / 100.0}) color + HSV_S → modifyHSV (_{s = n / 100.0}) color + HSV_V → modifyHSV (_{v = n / 100.0}) color + Red → modifyRGB (_{r = asInt n}) color + Green → modifyRGB (_{g = asInt n}) color + Blue → modifyRGB (_{b = asInt n}) color + HEX → color -- hex values will not be comming from Number input where asInt = floor - input :: String -> HTML m -> HTML m + input ∷ String → HTML m → HTML m input label child = HH.label [HP.classes props.inputClasses] [ HH.span [HP.classes props.inputLabelClasses] [HH.text label] @@ -212,19 +212,19 @@ renderEditingItem props x = HH.div [ HP.classes props.editingItemClasses ] $ x < ] renderHex = input "#" $ HH.slot' cpColorComponentHex unit (PatternInput.input - { fromString: \str -> Color.fromHexString $ "#" <> str - , toString: \color -> String.toUpper $ String.drop 1 $ Color.toHexString color + { fromString: \str → Color.fromHexString $ "#" <> str + , toString: \color → String.toUpper $ String.drop 1 $ Color.toHexString color } { title: "Hex" , placeholder: "HEX" , root: props.inputElemClasses , rootInvalid: props.inputElemInvalidClasses }) unit - $ HE.input \(PatternInput.NotifyChange val) -> ComponentUpdate $ const val + $ HE.input \(PatternInput.NotifyChange val) → ComponentUpdate $ const val type PreNumConf a = { title ∷ String, placeholder ∷ String, range ∷ Range a } -mkConf ∷ ∀ a. Props -> PreNumConf a -> Num.Config a +mkConf ∷ ∀ a. Props → PreNumConf a → Num.Config a mkConf props { title, placeholder, range } = { title , placeholder @@ -283,22 +283,22 @@ confValue = -propagate :: ∀ m. DSL m Unit +propagate ∷ ∀ m. DSL m Unit propagate = do - { color, props: { editing }} <- H.get + { color, props: { editing }} ← H.get let hsl = Color.toHSLA color let hsv = Color.toHSVA color let rgb = Color.toRGBA color for_ (fold editing) $ case _ of - Hue -> H.query' cpColorComponent Hue (set $ roundFractionalNum hsl.h) >>= mustBeMounted - HSL_S -> H.query' cpColorComponent HSL_S (set $ roundFractionalNum $ 100.0 * hsl.s) >>= mustBeMounted - HSL_L -> H.query' cpColorComponent HSL_L (set $ roundFractionalNum $ 100.0 * hsl.l) >>= mustBeMounted - HSV_S -> H.query' cpColorComponent HSV_S (set $ roundFractionalNum $ 100.0 * hsv.s) >>= mustBeMounted - HSV_V -> H.query' cpColorComponent HSV_V (set $ roundFractionalNum $ 100.0 * hsv.v) >>= mustBeMounted - Red -> H.query' cpColorComponent Red (set $ roundNum $ toNumber rgb.r) >>= mustBeMounted - Green -> H.query' cpColorComponent Green (set $ roundNum $ toNumber rgb.g) >>= mustBeMounted - Blue -> H.query' cpColorComponent Blue (set $ roundNum $ toNumber rgb.b) >>= mustBeMounted - HEX -> H.query' cpColorComponentHex unit (H.action $ PatternInput.SetValue $ Just $ color) >>= mustBeMounted + Hue → H.query' cpColorComponent Hue (set $ roundFractionalNum hsl.h) >>= mustBeMounted + HSL_S → H.query' cpColorComponent HSL_S (set $ roundFractionalNum $ 100.0 * hsl.s) >>= mustBeMounted + HSL_L → H.query' cpColorComponent HSL_L (set $ roundFractionalNum $ 100.0 * hsl.l) >>= mustBeMounted + HSV_S → H.query' cpColorComponent HSV_S (set $ roundFractionalNum $ 100.0 * hsv.s) >>= mustBeMounted + HSV_V → H.query' cpColorComponent HSV_V (set $ roundFractionalNum $ 100.0 * hsv.v) >>= mustBeMounted + Red → H.query' cpColorComponent Red (set $ roundNum $ toNumber rgb.r) >>= mustBeMounted + Green → H.query' cpColorComponent Green (set $ roundNum $ toNumber rgb.g) >>= mustBeMounted + Blue → H.query' cpColorComponent Blue (set $ roundNum $ toNumber rgb.b) >>= mustBeMounted + HEX → H.query' cpColorComponentHex unit (H.action $ PatternInput.SetValue $ Just $ color) >>= mustBeMounted where set n = H.action (Num.SetValue $ Just $ roundFractionalNum n) @@ -308,8 +308,8 @@ eval (Init next) = do propagate pure next eval (ComponentUpdate update next) = do - { color } <- H.get - for_ (update color) $ \color' -> do + { color } ← H.get + for_ (update color) $ \color' → do H.modify _{ color = color'} propagate pure next @@ -365,27 +365,27 @@ type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } -modifyHSL ∷ (RecordHSLA → RecordHSLA) -> Color.Color -> Color.Color -modifyHSL f c = case f (Color.toHSLA c) of {h, s, l, a} -> Color.hsla h s l a +modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color.Color → Color.Color +modifyHSL f c = case f (Color.toHSLA c) of {h, s, l, a} → Color.hsla h s l a -modifyHSV ∷ (RecordHSVA → RecordHSVA) -> Color.Color -> Color.Color -modifyHSV f c = case f (Color.toHSVA c) of {h, s, v, a} -> Color.hsva h s v a +modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color.Color → Color.Color +modifyHSV f c = case f (Color.toHSVA c) of {h, s, v, a} → Color.hsva h s v a -modifyRGB ∷ (RecordRGBA → RecordRGBA) -> Color.Color -> Color.Color -modifyRGB f c = case f (Color.toRGBA c) of {r, g, b, a} -> Color.rgba r g b a +modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color.Color → Color.Color +modifyRGB f c = case f (Color.toRGBA c) of {r, g, b, a} → Color.rgba r g b a mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a mustBeMounted (Just x) = pure x mustBeMounted _ = halt "children must be mounted" -roundFractionalNum :: Number -> Number +roundFractionalNum ∷ Number → Number roundFractionalNum = roundFractionalNum' 0 -roundFractionalNum' :: Int -> Number -> Number +roundFractionalNum' ∷ Int → Number → Number roundFractionalNum' digits n = roundNum (n * scalar) / scalar where scalar = pow 10.0 (toNumber $ digits + 2) -roundNum :: Number -> Number +roundNum ∷ Number → Number roundNum = round diff --git a/src/ColorPicker/Halogen/Utils/Drag.purs b/src/ColorPicker/Halogen/Utils/Drag.purs index adcefaf..c09d593 100644 --- a/src/ColorPicker/Halogen/Utils/Drag.purs +++ b/src/ColorPicker/Halogen/Utils/Drag.purs @@ -128,7 +128,7 @@ cursorEventToPosition (Right e) = , y: toNumber $ TouchE.pageY t } -scrollPosition :: ∀ r. Eff (dom ∷ DOM | r) Position +scrollPosition ∷ ∀ r. Eff (dom ∷ DOM | r) Position scrollPosition = do w ← window x ← toNumber <$> scrollX w @@ -198,7 +198,7 @@ mkDragData pos event node = do positionZero ∷ Position positionZero = { x: 0.0, y: 0.0 } -mkFirstDragData :: ∀ r. CursorEvent → Eff ( dom ∷ DOM | r ) DragData +mkFirstDragData ∷ ∀ r. CursorEvent → Eff ( dom ∷ DOM | r ) DragData mkFirstDragData event = do let position = cursorEventToPosition event let node = cursorEventToTarget event From e0f690eb4a4f7271b9ce0d64175c173609459724 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 4 Aug 2017 11:36:00 +0200 Subject: [PATCH 13/72] use Map for classes --- example/src/Main.purs | 32 ++++++------ src/ColorPicker/Halogen/Component.purs | 68 +++++++++++++++----------- 2 files changed, 57 insertions(+), 43 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index b7356e3..b1dde33 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -7,7 +7,9 @@ import Control.Monad.Aff.Class (class MonadAff) import Control.Monad.Eff (Eff) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct +import Data.Map (fromFoldable) import Data.Maybe (Maybe(..)) +import Data.Tuple (Tuple(..)) import Halogen (ClassName(..)) import Halogen as H import Halogen.Aff as HA @@ -67,18 +69,20 @@ config1 = mkConf mkConf ∷ Array ClassName → CPicker.ColorComponentGroups → CPicker.Props mkConf root editing = - { rootClasses: [ClassName "ColorPicker"] <> root - , draggerClasses: [ClassName "ColorPicker-dragger"] - , fieldClasses: [ClassName "ColorPicker-field"] - , fieldGradientClasses: [ClassName "ColorPicker-fieldGradient"] - , fieldSelectorClasses: [ClassName "ColorPicker-fieldSelector"] - , sliderClasses: [ClassName "ColorPicker-slider"] - , sliderSelectorClasses: [ClassName "ColorPicker-sliderSelector"] - , editingClasses: [ClassName "ColorPicker-editing"] - , editingItemClasses: [ClassName "ColorPicker-editingItem"] - , inputClasses: [ClassName "ColorPicker-input"] - , inputLabelClasses: [ClassName "ColorPicker-inputLabel"] - , inputElemClasses: [ClassName "ColorPicker-inputElem"] - , inputElemInvalidClasses: [ClassName "ColorPicker-inputElem--invalid"] - , editing + { editing + , classes: fromFoldable + [ Tuple CPicker.Root $ [ClassName "ColorPicker"] <> root + , Tuple CPicker.Dragger [ClassName "ColorPicker-dragger"] + , Tuple CPicker.Field [ClassName "ColorPicker-field"] + , Tuple CPicker.FieldGradient [ClassName "ColorPicker-fieldGradient"] + , Tuple CPicker.FieldSelector [ClassName "ColorPicker-fieldSelector"] + , Tuple CPicker.Slider [ClassName "ColorPicker-slider"] + , Tuple CPicker.SliderSelector [ClassName "ColorPicker-sliderSelector"] + , Tuple CPicker.Editing [ClassName "ColorPicker-editing"] + , Tuple CPicker.EditingItem [ClassName "ColorPicker-editingItem"] + , Tuple CPicker.Input [ClassName "ColorPicker-input"] + , Tuple CPicker.InputLabel [ClassName "ColorPicker-inputLabel"] + , Tuple CPicker.InputElem [ClassName "ColorPicker-inputElem"] + , Tuple CPicker.InputElemInvalid [ClassName "ColorPicker-inputElem--invalid"] + ] } diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index bd864c4..709a6c0 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -12,7 +12,8 @@ import Data.Either.Nested as Either import Data.Foldable (fold, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.Int (floor, toNumber) -import Data.Maybe (Maybe(..)) +import Data.Map (Map, lookup) +import Data.Maybe (Maybe(..), fromMaybe) import Data.String as String import Halogen (liftEff) import Halogen as H @@ -52,20 +53,29 @@ componentHEX = [HEX] type ColorComponentGroups = Array ColorComponents type ColorComponents = Array ColorComponent +classesFor :: Props -> ClassGroup -> Array HH.ClassName +classesFor {classes} key = fromMaybe [] $ lookup key classes + +data ClassGroup + = Root + | Dragger + | Field + | FieldGradient + | FieldSelector + | Slider + | SliderSelector + | Editing + | EditingItem + | Input + | InputLabel + | InputElem + | InputElemInvalid + +derive instance classGroupEq ∷ Eq ClassGroup +derive instance classGroupOrd ∷ Ord ClassGroup + type Props = - { rootClasses ∷ Array HH.ClassName - , draggerClasses ∷ Array HH.ClassName - , fieldClasses ∷ Array HH.ClassName - , fieldGradientClasses ∷ Array HH.ClassName - , fieldSelectorClasses ∷ Array HH.ClassName - , sliderClasses ∷ Array HH.ClassName - , sliderSelectorClasses ∷ Array HH.ClassName - , editingClasses ∷ Array HH.ClassName - , editingItemClasses ∷ Array HH.ClassName - , inputClasses ∷ Array HH.ClassName - , inputLabelClasses ∷ Array HH.ClassName - , inputElemClasses ∷ Array HH.ClassName - , inputElemInvalidClasses ∷ Array HH.ClassName + { classes ∷ Map ClassGroup (Array HH.ClassName) , editing ∷ ColorComponentGroups } @@ -113,7 +123,7 @@ picker = H.lifecycleParentComponent render ∷ ∀ m. State → HTML m render {color, props} = HH.div - [ HP.classes props.rootClasses + [ HP.classes $ props `classesFor` Root , HCSS.style do -- TODO remove backgroundColor CSS.backgroundColor color @@ -126,19 +136,19 @@ render {color, props} = hsv = Color.toHSVA color dragger = HH.div - [ HP.classes props.draggerClasses ] + [ HP.classes $ props `classesFor` Dragger ] [ field, slider ] field = HH.div - [ HP.classes props.fieldClasses + [ HP.classes $ props `classesFor` Field , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 , HE.onMouseDown $ HE.input (Left >>> FieldDragStart) , HE.onTouchStart $ HE.input (Right >>> FieldDragStart) ] - [ HH.div [ HP.classes props.fieldGradientClasses] [] + [ HH.div [ HP.classes $ props `classesFor` FieldGradient] [] , HH.div - [ HP.classes props.fieldSelectorClasses + [ HP.classes $ props `classesFor` FieldSelector , HCSS.style do CSS.display CSS.block CSS.left $ CSS.pct (hsv.s * 100.0) @@ -150,12 +160,12 @@ render {color, props} = slider = HH.div - [ HP.classes props.sliderClasses + [ HP.classes $ props `classesFor` Slider , HE.onMouseDown $ HE.input (Left >>> SliderDragStart) , HE.onTouchStart $ HE.input (Right >>> SliderDragStart) ] [ HH.div - [ HP.classes props.sliderSelectorClasses + [ HP.classes $ props `classesFor` SliderSelector , HCSS.style $ CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) ] [] @@ -163,11 +173,11 @@ render {color, props} = editing = HH.div - [ HP.classes props.editingClasses ] + [ HP.classes $ props `classesFor` Editing ] (renderEditingItem props <$> props.editing ) renderEditingItem ∷ ∀ m. Props → ColorComponents → HTML m -renderEditingItem props x = HH.div [ HP.classes props.editingItemClasses ] $ x <#> case _ of +renderEditingItem props x = HH.div [ HP.classes $ props `classesFor` EditingItem ] $ x <#> case _ of Hue → embedNum hasValRound Hue $ mkConf props confHue HSV_S → embedNum hasValRound HSV_S $ mkConf props confSaturation HSV_V → embedNum hasValRound HSV_V $ mkConf props confValue @@ -206,8 +216,8 @@ renderEditingItem props x = HH.div [ HP.classes props.editingItemClasses ] $ x < asInt = floor input ∷ String → HTML m → HTML m input label child = - HH.label [HP.classes props.inputClasses] - [ HH.span [HP.classes props.inputLabelClasses] [HH.text label] + HH.label [HP.classes $ props `classesFor` Input] + [ HH.span [HP.classes $ props `classesFor` InputLabel] [HH.text label] , child ] renderHex = input "#" @@ -217,8 +227,8 @@ renderEditingItem props x = HH.div [ HP.classes props.editingItemClasses ] $ x < } { title: "Hex" , placeholder: "HEX" - , root: props.inputElemClasses - , rootInvalid: props.inputElemInvalidClasses + , root: props `classesFor` InputElem + , rootInvalid: props `classesFor` InputElemInvalid }) unit $ HE.input \(PatternInput.NotifyChange val) → ComponentUpdate $ const val @@ -229,8 +239,8 @@ mkConf props { title, placeholder, range } = { title , placeholder , range - , root: props.inputElemClasses - , rootInvalid: props.inputElemInvalidClasses + , root: props `classesFor` InputElem + , rootInvalid: props `classesFor` InputElemInvalid , rootLength: const [] } From 86aa727418c7e4abf75b0d0b6bb5ef4017122f0f Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 4 Aug 2017 11:44:34 +0200 Subject: [PATCH 14/72] use case _ of in eval --- src/ColorPicker/Halogen/Component.purs | 116 ++++++++++++------------ src/PatternInput/Halogen/Component.purs | 23 ++--- 2 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 709a6c0..6ecbf4d 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -293,6 +293,63 @@ confValue = +eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m +eval = case _ of + Init next → do + propagate + pure next + ComponentUpdate update next → do + { color } ← H.get + for_ (update color) $ \color' → do + H.modify _{ color = color'} + propagate + pure next + SetProps props next → do + H.modify _{props = props} + pure next + FieldDragMove drag next → do + case drag of + Drag.Move event dragData → do + {color} ← H.get + let + hsv = Color.toHSVA color + s = roundFractionalNum' 2 $ (dragData.progress.x) + v = roundFractionalNum' 2 $ (1.0 - dragData.progress.y) + H.modify _ + { color = Color.hsv hsv.h s v + } + Drag.Done event → pure unit + propagate + pure next + SliderDragMove drag next → do + case drag of + Drag.Move event dragData → do + {color} ← H.get + let + h = roundFractionalNum $ (1.0 - dragData.progress.y) * 360.0 + hsl = Color.toHSLA color + H.modify _ + { color = Color.hsl h hsl.s hsl.l + } + Drag.Done event → pure unit + propagate + pure next + SliderDragStart event next → startDrag SliderDragMove event next + FieldDragStart event next → startDrag FieldDragMove event next + where + startDrag + ∷ ∀ a + . (∀ b. Drag.DragEvent → b → Query b) + → Drag.CursorEvent + → a + → DSL m a + startDrag action event next = do + H.subscribe $ Drag.dragEventSource event \drag → + Just (action drag H.Listening) + liftEff $ either preventDefault preventDefault event + initialDragData ← liftEff $ Drag.mkFirstDragData event + eval $ action (Drag.Move event initialDragData) next + propagate ∷ ∀ m. DSL m Unit propagate = do { color, props: { editing }} ← H.get @@ -312,65 +369,6 @@ propagate = do where set n = H.action (Num.SetValue $ Just $ roundFractionalNum n) - -eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m -eval (Init next) = do - propagate - pure next -eval (ComponentUpdate update next) = do - { color } ← H.get - for_ (update color) $ \color' → do - H.modify _{ color = color'} - propagate - pure next - - -eval (SetProps props next) = do - H.modify _{props = props} - pure next -eval (FieldDragMove drag next) = do - case drag of - Drag.Move event dragData → do - {color} ← H.get - let - hsv = Color.toHSVA color - s = roundFractionalNum' 2 $ (dragData.progress.x) - v = roundFractionalNum' 2 $ (1.0 - dragData.progress.y) - H.modify _ - { color = Color.hsv hsv.h s v - } - Drag.Done event → pure unit - propagate - pure next -eval (SliderDragMove drag next) = do - case drag of - Drag.Move event dragData → do - {color} ← H.get - let - h = roundFractionalNum $ (1.0 - dragData.progress.y) * 360.0 - hsl = Color.toHSLA color - H.modify _ - { color = Color.hsl h hsl.s hsl.l - } - Drag.Done event → pure unit - propagate - pure next -eval (SliderDragStart event next) = startDrag SliderDragMove event next -eval (FieldDragStart event next) = startDrag FieldDragMove event next - -startDrag - ∷ ∀ a m r. MonadAff (PickerEffects r) m - ⇒ (∀ b. Drag.DragEvent → b → Query b) - → Drag.CursorEvent - → a - → DSL m a -startDrag action event next = do - H.subscribe $ Drag.dragEventSource event \drag → - Just (action drag H.Listening) - liftEff $ either preventDefault preventDefault event - initialDragData ← liftEff $ Drag.mkFirstDragData event - eval $ action (Drag.Move event initialDragData) next - type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } diff --git a/src/PatternInput/Halogen/Component.purs b/src/PatternInput/Halogen/Component.purs index a47f07a..a1f2d7e 100644 --- a/src/PatternInput/Halogen/Component.purs +++ b/src/PatternInput/Halogen/Component.purs @@ -69,17 +69,18 @@ render hasInputVal conf value = HH.input ] eval ∷ ∀ val m . Eq val ⇒ HasInputVal val → Query val ~> DSL val m -eval hasInputVal (SetValue val next) = do - prevVal ← H.get - unless (fst prevVal == val) (H.put $ Tuple val (maybe "" hasInputVal.toString val)) - pure next -eval _ (GetValue next) = H.get <#> (fst >>> next) -eval hasInputVal (Update str next) = do - prevVal ← H.get - let nextVal = Tuple (hasInputVal.fromString str) str - H.put nextVal - unless (nextVal == prevVal) $ H.raise (NotifyChange $ fst nextVal) - pure next +eval hasInputVal = case _ of + SetValue val next → do + prevVal ← H.get + unless (fst prevVal == val) (H.put $ Tuple val (maybe "" hasInputVal.toString val)) + pure next + GetValue next → H.get <#> (fst >>> next) + Update str next → do + prevVal ← H.get + let nextVal = Tuple (hasInputVal.fromString str) str + H.put nextVal + unless (nextVal == prevVal) $ H.raise (NotifyChange $ fst nextVal) + pure next isInvalid ∷ ∀ a. InputValue a → Boolean isInvalid (Tuple _ "") = false From 7bfdc03d3b62fca7505cff596e8741445b45ff1a Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 4 Aug 2017 17:20:57 +0200 Subject: [PATCH 15/72] show previous color --- example/index.html | 53 +++++++++- example/src/Main.purs | 44 ++++++-- src/ColorPicker/Halogen/Component.purs | 141 +++++++++++++++++-------- 3 files changed, 182 insertions(+), 56 deletions(-) diff --git a/example/index.html b/example/index.html index 90b7d06..fc74a9c 100644 --- a/example/index.html +++ b/example/index.html @@ -9,8 +9,9 @@ } .ColorPicker { - padding: 100px; + padding: 0.5em; display: inline-flex; + background: hsl(0, 0%, 80%); } .ColorPicker--small .ColorPicker-field { width: 10em; } @@ -73,8 +74,39 @@ height: 2px; } +.ColorPicker-aside { + display: flex; + flex-direction: column; + margin-left: 0.25em +} +.ColorPicker-stage { + display: flex; + margin-bottom: 0.5em +} +.ColorPicker-colorBlockCurrent, +.ColorPicker-colorBlockPrevious { + border-top: 1px solid; + border-bottom: 1px solid; + flex: 1 1 0%; + height: 1.5em; +} + +.ColorPicker-colorBlockCurrent { + border-left: 1px solid; +} + +.ColorPicker-colorBlockPrevious { + border-right: 1px solid; + cursor: pointer; +} + +.ColorPicker-colorBlockPrevious:focus { + outline: -webkit-focus-ring-color auto 5px; +} + .ColorPicker-editing { display: flex; + flex: 1; } .ColorPicker-editingItem { @@ -85,7 +117,7 @@ .ColorPicker-input { display: flex; height: 1.5em; - padding: 0.25em; + margin-bottom: 0.5em; } .ColorPicker-inputLabel { @@ -100,9 +132,26 @@ padding: 0.3em; width: 5em; } + .ColorPicker-inputElem--invalid { color: red; } + +.ColorPicker-actions { + display: flex; + justify-content: flex-end; +} + +.ColorPicker-actionSet { + height: 2em; + border: 1px solid; + width: 6em; +} + +.ColorPicker-actionSet:active { + box-shadow: 0 0 2px currentColor +} + diff --git a/example/src/Main.purs b/example/src/Main.purs index b1dde33..a5dbcb5 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -2,13 +2,15 @@ module Main where import Prelude +import Color (Color) import ColorPicker.Halogen.Component as CPicker import Control.Monad.Aff.Class (class MonadAff) import Control.Monad.Eff (Eff) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct -import Data.Map (fromFoldable) +import Data.Map (Map, fromFoldable, insert, lookup) import Data.Maybe (Maybe(..)) +import Data.Monoid (mempty) import Data.Tuple (Tuple(..)) import Halogen (ClassName(..)) import Halogen as H @@ -25,7 +27,7 @@ main = HA.runHalogenAff do data Query a = HandleMsg ColorIdx CPicker.Message a -type State = {} +type State = Map Int {current ∷ Color, next ∷ Color } type ColorIdx = Int type ChildQuery = Coproduct.Coproduct1 CPicker.Query type Slot = Either.Either1 ColorIdx @@ -41,21 +43,39 @@ type DSL m = H.ParentDSL State Query ChildQuery Slot Void m example ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => H.Component HH.HTML Query Unit Void m example = H.parentComponent - { initialState: const {} + { initialState: const mempty , render , eval , receiver: const Nothing } render ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => State → HTML m -render _ = HH.div_ - $ [ HH.h1_ [ HH.text "Picker 1" ]] - <> [ HH.slot' cpColor 0 CPicker.picker config0 (HE.input (HandleMsg 0))] - <> [ HH.h1_ [ HH.text "Picker 2" ]] - <> [ HH.slot' cpColor 1 CPicker.picker config1 (HE.input (HandleMsg 1))] +render state = HH.div_ + $ renderPicker 0 config0 + <> renderPicker 1 config1 + + where + renderPicker idx conf = + [ HH.h1_ [ HH.text $ "Picker " <> show idx ] + , HH.slot' cpColor idx CPicker.picker conf (HE.input $ HandleMsg idx) + , HH.p_ [ HH.text case lookup idx state of + Just ({current, next}) → + "uncommited (current: " <> show current <>", next:" <> show next <> ")" + Nothing → "no color" + ] + ] eval ∷ ∀ m. Query ~> DSL m -eval (HandleMsg _ _ next) = pure next +eval (HandleMsg idx msg next) = do + H.modify update + pure next + where + update state = insert idx val state + where + val = case lookup idx state, msg of + Just s, CPicker.NextChange next -> s{next = next} + _, CPicker.NextChange x -> { next: x, current: x } + _, CPicker.NotifyChange x -> {next: x, current: x} config0 ∷ CPicker.Props config0 = mkConf @@ -78,11 +98,17 @@ mkConf root editing = , Tuple CPicker.FieldSelector [ClassName "ColorPicker-fieldSelector"] , Tuple CPicker.Slider [ClassName "ColorPicker-slider"] , Tuple CPicker.SliderSelector [ClassName "ColorPicker-sliderSelector"] + , Tuple CPicker.Aside [ClassName "ColorPicker-aside"] + , Tuple CPicker.Stage [ClassName "ColorPicker-stage"] + , Tuple CPicker.ColorBlockCurrent [ClassName "ColorPicker-colorBlockCurrent"] + , Tuple CPicker.ColorBlockPrevious [ClassName "ColorPicker-colorBlockPrevious"] , Tuple CPicker.Editing [ClassName "ColorPicker-editing"] , Tuple CPicker.EditingItem [ClassName "ColorPicker-editingItem"] , Tuple CPicker.Input [ClassName "ColorPicker-input"] , Tuple CPicker.InputLabel [ClassName "ColorPicker-inputLabel"] , Tuple CPicker.InputElem [ClassName "ColorPicker-inputElem"] , Tuple CPicker.InputElemInvalid [ClassName "ColorPicker-inputElem--invalid"] + , Tuple CPicker.Actions [ClassName "ColorPicker-actions"] + , Tuple CPicker.ActionSet [ClassName "ColorPicker-actionSet"] ] } diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 6ecbf4d..d916ba1 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -3,6 +3,7 @@ module ColorPicker.Halogen.Component where import Prelude import CSS as CSS +import Color (Color) import Color as Color import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) @@ -15,6 +16,7 @@ import Data.Int (floor, toNumber) import Data.Map (Map, lookup) import Data.Maybe (Maybe(..), fromMaybe) import Data.String as String +import Debug.Trace (spy) import Halogen (liftEff) import Halogen as H import Halogen.Component.ChildPath as CP @@ -28,12 +30,14 @@ import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) import PatternInput.Halogen.Component as PatternInput + type State = - { color ∷ Color.Color -- switch to Maybe Color + { colorCurrent ∷ Color + , colorNext ∷ Color , props ∷ Props } -type Message = Unit +data Message = NextChange Color | NotifyChange Color componentHue ∷ Array ColorComponent componentHue = [Hue] @@ -53,7 +57,7 @@ componentHEX = [HEX] type ColorComponentGroups = Array ColorComponents type ColorComponents = Array ColorComponent -classesFor :: Props -> ClassGroup -> Array HH.ClassName +classesFor :: Props → ClassGroup → Array HH.ClassName classesFor {classes} key = fromMaybe [] $ lookup key classes data ClassGroup @@ -64,12 +68,18 @@ data ClassGroup | FieldSelector | Slider | SliderSelector + | Aside + | Stage + | ColorBlockCurrent + | ColorBlockPrevious | Editing | EditingItem | Input | InputLabel | InputElem | InputElemInvalid + | Actions + | ActionSet derive instance classGroupEq ∷ Eq ClassGroup derive instance classGroupOrd ∷ Ord ClassGroup @@ -89,16 +99,17 @@ data Query a | FieldDragMove Drag.DragEvent a | SliderDragStart Drag.CursorEvent a | SliderDragMove Drag.DragEvent a - | ComponentUpdate (Color.Color → Maybe Color.Color) a + | ComponentUpdate (Color → Maybe Color) a + | Commit a | Init a -type ChildQuery = Coproduct.Coproduct2 (Num.Query Number) (PatternInput.Query Color.Color) +type ChildQuery = Coproduct.Coproduct2 (Num.Query Number) (PatternInput.Query Color) type Slot = Either.Either2 ColorComponent Unit cpColorComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery ColorComponent Slot cpColorComponent = CP.cp1 -cpColorComponentHex ∷ CP.ChildPath (PatternInput.Query Color.Color) ChildQuery Unit Slot +cpColorComponentHex ∷ CP.ChildPath (PatternInput.Query Color) ChildQuery Unit Slot cpColorComponentHex = CP.cp2 type HTML m = H.ParentHTML Query ChildQuery Slot m @@ -107,12 +118,12 @@ type DSL m = H.ParentDSL State Query ChildQuery Slot Message m type PickerEffects r = Drag.DragEffects r -initialColor ∷ Color.Color -initialColor = Color.hsl 180.0 0.5 0.5 +initialColor ∷ Color +initialColor = Color.hsl 0.0 0.0 0.0 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m picker = H.lifecycleParentComponent - { initialState: { color: initialColor, props: _ } + { initialState: { colorCurrent: initialColor, colorNext: initialColor, props: _ } , render , eval , receiver: HE.input SetProps @@ -121,22 +132,18 @@ picker = H.lifecycleParentComponent } render ∷ ∀ m. State → HTML m -render {color, props} = +render { colorCurrent, colorNext, props} = HH.div - [ HP.classes $ props `classesFor` Root - , HCSS.style do - -- TODO remove backgroundColor - CSS.backgroundColor color - CSS.color if Color.isLight color - then CSS.black - else CSS.white - ] - [ dragger, editing ] + [ HP.classes $ props `classesFor` Root ] + [ dragger, aside ] where - hsv = Color.toHSVA color + textColor c = CSS.color if Color.isLight c then CSS.black else CSS.white + hsv = Color.toHSVA $ colorNext dragger = HH.div - [ HP.classes $ props `classesFor` Dragger ] + [ HP.classes $ props `classesFor` Dragger + , HCSS.style $ textColor colorNext + ] [ field, slider ] field = @@ -153,7 +160,7 @@ render {color, props} = CSS.display CSS.block CSS.left $ CSS.pct (hsv.s * 100.0) CSS.bottom $ CSS.pct (hsv.v * 100.0) - CSS.backgroundColor color + CSS.backgroundColor colorNext ] [] ] @@ -171,10 +178,44 @@ render {color, props} = [] ] + aside = + HH.div + [ HP.classes $ props `classesFor` Aside ] + [stage, editing, actions] + stage = + HH.div + [ HP.classes $ props `classesFor` Stage ] + [ HH.div + [ HP.classes $ props `classesFor` ColorBlockCurrent + , HCSS.style do + CSS.backgroundColor colorNext + textColor colorNext + ] + [] + , HH.div + [ HP.tabIndex 0 + , HP.classes $ props `classesFor` ColorBlockPrevious + , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just colorCurrent) + , HCSS.style do + CSS.backgroundColor colorCurrent + textColor colorCurrent + ] + [] + ] + editing = HH.div [ HP.classes $ props `classesFor` Editing ] (renderEditingItem props <$> props.editing ) + actions = + HH.div + [ HP.classes $ props `classesFor` Actions ] + [ HH.button + [ HP.classes $ props `classesFor` ActionSet + , HE.onClick $ HE.input \_ -> Commit + ] + [ HH.text "Set" ] + ] renderEditingItem ∷ ∀ m. Props → ColorComponents → HTML m renderEditingItem props x = HH.div [ HP.classes $ props `classesFor` EditingItem ] $ x <#> case _ of @@ -292,17 +333,28 @@ confValue = } +updateColor :: ∀ m. State → Color → DSL m Unit +updateColor state colorNext = do + H.put state{colorNext = colorNext} + H.raise $ NextChange colorNext + propagate + eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m eval = case _ of Init next → do propagate pure next + Commit next → do + state ← H.get + H.put $ state{colorCurrent = state.colorNext, colorNext = state.colorNext} + void $ map spy H.get + H.raise $ NotifyChange state.colorNext + pure next ComponentUpdate update next → do - { color } ← H.get - for_ (update color) $ \color' → do - H.modify _{ color = color'} - propagate + state ← H.get + for_ (update state.colorNext) $ \color' → do + updateColor state $ color' pure next SetProps props next → do H.modify _{props = props} @@ -310,29 +362,25 @@ eval = case _ of FieldDragMove drag next → do case drag of Drag.Move event dragData → do - {color} ← H.get + state ← H.get let + color = state.colorNext hsv = Color.toHSVA color s = roundFractionalNum' 2 $ (dragData.progress.x) v = roundFractionalNum' 2 $ (1.0 - dragData.progress.y) - H.modify _ - { color = Color.hsv hsv.h s v - } + updateColor state (Color.hsv hsv.h s v) + pure unit Drag.Done event → pure unit - propagate pure next SliderDragMove drag next → do case drag of Drag.Move event dragData → do - {color} ← H.get + state ← H.get let h = roundFractionalNum $ (1.0 - dragData.progress.y) * 360.0 - hsl = Color.toHSLA color - H.modify _ - { color = Color.hsl h hsl.s hsl.l - } + hsl = Color.toHSLA $ state.colorNext + updateColor state (Color.hsl h hsl.s hsl.l) Drag.Done event → pure unit - propagate pure next SliderDragStart event next → startDrag SliderDragMove event next FieldDragStart event next → startDrag FieldDragMove event next @@ -350,12 +398,15 @@ eval = case _ of initialDragData ← liftEff $ Drag.mkFirstDragData event eval $ action (Drag.Move event initialDragData) next + propagate ∷ ∀ m. DSL m Unit propagate = do - { color, props: { editing }} ← H.get - let hsl = Color.toHSLA color - let hsv = Color.toHSVA color - let rgb = Color.toRGBA color + { colorNext, props: { editing }} ← H.get + let + c = colorNext + hsl = Color.toHSLA c + hsv = Color.toHSVA c + rgb = Color.toRGBA c for_ (fold editing) $ case _ of Hue → H.query' cpColorComponent Hue (set $ roundFractionalNum hsl.h) >>= mustBeMounted HSL_S → H.query' cpColorComponent HSL_S (set $ roundFractionalNum $ 100.0 * hsl.s) >>= mustBeMounted @@ -365,7 +416,7 @@ propagate = do Red → H.query' cpColorComponent Red (set $ roundNum $ toNumber rgb.r) >>= mustBeMounted Green → H.query' cpColorComponent Green (set $ roundNum $ toNumber rgb.g) >>= mustBeMounted Blue → H.query' cpColorComponent Blue (set $ roundNum $ toNumber rgb.b) >>= mustBeMounted - HEX → H.query' cpColorComponentHex unit (H.action $ PatternInput.SetValue $ Just $ color) >>= mustBeMounted + HEX → H.query' cpColorComponentHex unit (H.action $ PatternInput.SetValue $ Just $ c) >>= mustBeMounted where set n = H.action (Num.SetValue $ Just $ roundFractionalNum n) @@ -373,13 +424,13 @@ type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } -modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color.Color → Color.Color +modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color → Color modifyHSL f c = case f (Color.toHSLA c) of {h, s, l, a} → Color.hsla h s l a -modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color.Color → Color.Color +modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color → Color modifyHSV f c = case f (Color.toHSVA c) of {h, s, v, a} → Color.hsva h s v a -modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color.Color → Color.Color +modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color → Color modifyRGB f c = case f (Color.toRGBA c) of {r, g, b, a} → Color.rgba r g b a mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a From af2d4258e392c35a720c9d4892c7b37bf9822acb Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 4 Aug 2017 19:47:56 +0200 Subject: [PATCH 16/72] make ColorComponents extensible --- example/src/Main.purs | 29 ++- src/ColorPicker/Halogen/ColorComponents.purs | 242 ++++++++++++++++++ src/ColorPicker/Halogen/Component.purs | 251 +++++-------------- 3 files changed, 330 insertions(+), 192 deletions(-) create mode 100644 src/ColorPicker/Halogen/ColorComponents.purs diff --git a/example/src/Main.purs b/example/src/Main.purs index a5dbcb5..95a87f6 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -2,7 +2,7 @@ module Main where import Prelude -import Color (Color) +import Color (Color, rgb) import ColorPicker.Halogen.Component as CPicker import Control.Monad.Aff.Class (class MonadAff) import Control.Monad.Eff (Eff) @@ -19,6 +19,7 @@ import Halogen.Component.ChildPath as CP import Halogen.HTML as HH import Halogen.HTML.Events as HE import Halogen.VDom.Driver (runUI) +import PatternInput.Halogen.ColorComponents as C main ∷ Eff (HA.HalogenEffects ()) Unit main = HA.runHalogenAff do @@ -53,6 +54,7 @@ render ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => State → HTML m render state = HH.div_ $ renderPicker 0 config0 <> renderPicker 1 config1 + <> renderPicker 2 config2 where renderPicker idx conf = @@ -80,13 +82,34 @@ eval (HandleMsg idx msg next) = do config0 ∷ CPicker.Props config0 = mkConf [ClassName "ColorPicker--small"] - [CPicker.componentHue <> CPicker.componentSL] + [ [C.componentHue] <> C.componentSL + ] config1 ∷ CPicker.Props config1 = mkConf [ClassName "ColorPicker--large"] - [CPicker.componentHue <> CPicker.componentSV <> CPicker.componentHEX, CPicker.componentRGB] + [ [C.componentHue] <> C.componentSV <> [C.componentHEX] + , C.componentRGB + ] +config2 ∷ CPicker.Props +config2 = mkConf + [ClassName "ColorPicker--small"] + [[ componentRedORNoRed ]] + +componentRedORNoRed :: C.ColorComponent +componentRedORNoRed = C.TextComponentSpec + { hasInputVal: + { fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing + , toString: \color → if color == (rgb 255 0 0) then "red" else "nored" + } + , key: "Red" + , config: + { title: "red or nored?" + , prefix: "🛑" + , placeholder: "red" + } + } mkConf ∷ Array ClassName → CPicker.ColorComponentGroups → CPicker.Props mkConf root editing = { editing diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs new file mode 100644 index 0000000..7b60c37 --- /dev/null +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -0,0 +1,242 @@ +module PatternInput.Halogen.ColorComponents + ( ColorComponent(..) + , PreNumConf + , PreTextConf + , RecordHSLA + , RecordHSVA + , RecordRGBA + , componentHue + , componentSaturationHSL + , componentLightness + , componentSaturationHSV + , componentValue + , componentRed + , componentGreen + , componentBlue + , componentHEX + , componentSL + , componentSV + , componentRGB + ) where + +import Prelude + +import Color (Color) +import Color as Color +import Data.Int (floor, toNumber) +import Data.String as String +import Data.Maybe (Maybe(..)) +import Math (round) +import NumberInput.Halogen.Component as Num +import NumberInput.Range (Range(..)) +import PatternInput.Halogen.Component as PatternInput + + +type PreNumConf a = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range a } +type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } + +data ColorComponent + = NumberComponentSpec + { hasNumVal ∷ Num.HasNumberInputVal Number + , update ∷ Number → Color → Maybe Color + , key ∷ String + , read ∷ + { hsl ∷ RecordHSLA + , hsv ∷ RecordHSVA + , rgb ∷ RecordRGBA + } → Number + , config ∷ PreNumConf Number + } + | TextComponentSpec + { hasInputVal ∷ PatternInput.HasInputVal Color + , key ∷ String + , config ∷ PreTextConf + } + + +componentHue ∷ ColorComponent +componentHue = NumberComponentSpec + { hasNumVal: hasValRound + , key: "Hue" + , update: \n color → Just $ modifyHSL (_{h = n}) color + , read: \({rgb, hsv, hsl}) → roundFractionalNum hsl.h + , config: confHue + } + + +componentSaturationHSL ∷ ColorComponent +componentSaturationHSL = NumberComponentSpec + { hasNumVal: hasValRound + , key: "SaturationHSL" + , update: \n color → Just $ modifyHSV (_{s = n / 100.0}) color + , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s + , config: confSaturation + } + +componentLightness ∷ ColorComponent +componentLightness = NumberComponentSpec + { hasNumVal: hasValRound + , key: "Lightness" + , update: \n color → Just $ modifyHSV (_{v = n / 100.0}) color + , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l + , config: confLightness + } + +componentSaturationHSV ∷ ColorComponent +componentSaturationHSV = NumberComponentSpec + { hasNumVal: hasValRound + , key: "SaturationHSV" + , update: \n color → Just $ modifyHSL (_{s = n / 100.0}) color + , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s + , config: confSaturation + } + +componentValue ∷ ColorComponent +componentValue = NumberComponentSpec + { hasNumVal: hasValRound + , key: "Value" + , update: \n color → Just $ modifyHSL (_{l = n / 100.0}) color + , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v + , config: confValue + } + +componentRed ∷ ColorComponent +componentRed = NumberComponentSpec + { hasNumVal: hasvalCail + , key: "Red" + , update: \n color → Just $ modifyRGB (_{r = asInt n}) color + , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r + , config: confRed + } + +componentGreen ∷ ColorComponent +componentGreen = NumberComponentSpec + { hasNumVal: hasvalCail + , key: "Green" + , update: \n color → Just $ modifyRGB (_{g = asInt n}) color + , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g + , config: confGreen + } + +componentBlue ∷ ColorComponent +componentBlue = NumberComponentSpec + { hasNumVal: hasvalCail + , key: "Blue" + , update: \n color → Just $ modifyRGB (_{b = asInt n}) color + , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b + , config: confBlue + } + +componentHEX ∷ ColorComponent +componentHEX = TextComponentSpec + { hasInputVal: + { fromString: \str → Color.fromHexString $ "#" <> str + , toString: \color → String.toUpper $ String.drop 1 $ Color.toHexString color + } + , key: "HEX" + , config: + { prefix: "#" + , title: "Hex" + , placeholder: "HEX" + } + } + +componentSL ∷ Array ColorComponent +componentSL = [componentSaturationHSL, componentLightness] + +componentSV ∷ Array ColorComponent +componentSV = [componentSaturationHSV, componentValue] + +componentRGB ∷ Array ColorComponent +componentRGB = [componentRed, componentGreen, componentBlue] + + +-- Internal helpers + + +confRed ∷ PreNumConf Number +confRed = + { title: "Red" + , placeholder: "R" + , prefix: "R" + , range: MinMax 0.0 256.0 + } + +confGreen ∷ PreNumConf Number +confGreen = + { title: "Green" + , placeholder: "G" + , prefix: "G" + , range: MinMax 0.0 256.0 + } + +confBlue ∷ PreNumConf Number +confBlue = + { title: "Blue" + , placeholder: "B" + , prefix: "B" + , range: MinMax 0.0 256.0 + } + +confHue ∷ PreNumConf Number +confHue = + { title: "Hue" + , placeholder: "H" + , prefix: "H" + , range: MinMax 0.0 360.0 + } +confSaturation ∷ PreNumConf Number +confSaturation = + { title: "Saturation" + , placeholder: "S" + , prefix: "S" + , range: MinMax 0.0 100.0 + } +confLightness ∷ PreNumConf Number +confLightness = + { title: "Lightness" + , placeholder: "L" + , prefix: "L" + , range: MinMax 0.0 100.0 + } + +confValue ∷ PreNumConf Number +confValue = + { title: "Value" + , placeholder: "V" + , prefix: "V" + , range: MinMax 0.0 100.0 + } + + +asInt :: Number -> Int +asInt = floor + +hasValRound ∷ Num.HasNumberInputVal Number +hasValRound = Num.numberHasNumberInputVal + {fromString = Num.numberHasNumberInputVal.fromString >>> map roundFractionalNum} + +hasvalCail ∷ Num.HasNumberInputVal Number +hasvalCail = Num.numberHasNumberInputVal + {fromString = Num.numberHasNumberInputVal.fromString >>> map roundNum} + +roundFractionalNum ∷ Number → Number +roundFractionalNum n = roundNum (n * scalar) / scalar + where + scalar = 100.0 + +roundNum ∷ Number → Number +roundNum = round + +type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } +type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } +type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } + +modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color → Color +modifyHSL f c = case f (Color.toHSLA c) of {h, s, l, a} → Color.hsla h s l a + +modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color → Color +modifyHSV f c = case f (Color.toHSVA c) of {h, s, v, a} → Color.hsva h s v a + +modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color → Color +modifyRGB f c = case f (Color.toRGBA c) of {r, g, b, a} → Color.rgba r g b a diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index d916ba1..970f423 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -12,10 +12,8 @@ import Data.Either (Either(..), either) import Data.Either.Nested as Either import Data.Foldable (fold, for_) import Data.Functor.Coproduct.Nested as Coproduct -import Data.Int (floor, toNumber) import Data.Map (Map, lookup) import Data.Maybe (Maybe(..), fromMaybe) -import Data.String as String import Debug.Trace (spy) import Halogen (liftEff) import Halogen as H @@ -25,9 +23,8 @@ import Halogen.HTML.CSS as HCSS import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Halogen.Query.HalogenM (halt) -import Math (pow, round) import NumberInput.Halogen.Component as Num -import NumberInput.Range (Range(..)) +import PatternInput.Halogen.ColorComponents (ColorComponent(..), PreNumConf, PreTextConf) import PatternInput.Halogen.Component as PatternInput @@ -39,20 +36,6 @@ type State = data Message = NextChange Color | NotifyChange Color -componentHue ∷ Array ColorComponent -componentHue = [Hue] - -componentSL ∷ Array ColorComponent -componentSL = [HSL_S, HSL_L] - -componentSV ∷ Array ColorComponent -componentSV = [HSV_S, HSV_V] - -componentRGB ∷ Array ColorComponent -componentRGB = [Red, Green, Blue] - -componentHEX ∷ Array ColorComponent -componentHEX = [HEX] type ColorComponentGroups = Array ColorComponents type ColorComponents = Array ColorComponent @@ -89,9 +72,6 @@ type Props = , editing ∷ ColorComponentGroups } -data ColorComponent = Hue | HSL_S | HSV_S | HSL_L | HSV_V | Red | Green | Blue | HEX -derive instance colorComponentEq ∷ Eq ColorComponent -derive instance colorComponentOrd ∷ Ord ColorComponent data Query a = SetProps Props a @@ -104,13 +84,13 @@ data Query a | Init a type ChildQuery = Coproduct.Coproduct2 (Num.Query Number) (PatternInput.Query Color) -type Slot = Either.Either2 ColorComponent Unit +type Slot = Either.Either2 String String -cpColorComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery ColorComponent Slot -cpColorComponent = CP.cp1 +cpNumComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery String Slot +cpNumComponent = CP.cp1 -cpColorComponentHex ∷ CP.ChildPath (PatternInput.Query Color) ChildQuery Unit Slot -cpColorComponentHex = CP.cp2 +cpTextComponent ∷ CP.ChildPath (PatternInput.Query Color) ChildQuery String Slot +cpTextComponent = CP.cp2 type HTML m = H.ParentHTML Query ChildQuery Slot m @@ -139,6 +119,7 @@ render { colorCurrent, colorNext, props} = where textColor c = CSS.color if Color.isLight c then CSS.black else CSS.white hsv = Color.toHSVA $ colorNext + dragger = HH.div [ HP.classes $ props `classesFor` Dragger @@ -182,6 +163,7 @@ render { colorCurrent, colorNext, props} = HH.div [ HP.classes $ props `classesFor` Aside ] [stage, editing, actions] + stage = HH.div [ HP.classes $ props `classesFor` Stage ] @@ -207,6 +189,7 @@ render { colorCurrent, colorNext, props} = HH.div [ HP.classes $ props `classesFor` Editing ] (renderEditingItem props <$> props.editing ) + actions = HH.div [ HP.classes $ props `classesFor` Actions ] @@ -217,66 +200,36 @@ render { colorCurrent, colorNext, props} = [ HH.text "Set" ] ] -renderEditingItem ∷ ∀ m. Props → ColorComponents → HTML m -renderEditingItem props x = HH.div [ HP.classes $ props `classesFor` EditingItem ] $ x <#> case _ of - Hue → embedNum hasValRound Hue $ mkConf props confHue - HSV_S → embedNum hasValRound HSV_S $ mkConf props confSaturation - HSV_V → embedNum hasValRound HSV_V $ mkConf props confValue - HSL_S → embedNum hasValRound HSL_S $ mkConf props confSaturation - HSL_L → embedNum hasValRound HSL_L $ mkConf props confLightness - Red → embedNum hasvalCail Red $ mkConf props confRed - Green → embedNum hasvalCail Green $ mkConf props confGreen - Blue → embedNum hasvalCail Blue $ mkConf props confBlue - HEX → renderHex - +renderEditingItem ∷ ∀ m. Props → ColorComponents → HTML m +renderEditingItem props x = HH.div [ HP.classes $ props `classesFor` EditingItem ] $ x <#> renderItem where - hasValRound ∷ Num.HasNumberInputVal Number - hasValRound = Num.numberHasNumberInputVal - {fromString = Num.numberHasNumberInputVal.fromString >>> map roundFractionalNum} - - hasvalCail ∷ Num.HasNumberInputVal Number - hasvalCail = Num.numberHasNumberInputVal - {fromString = Num.numberHasNumberInputVal.fromString >>> map roundNum} - - embedNum ∷ Num.HasNumberInputVal Number → ColorComponent → Num.Config Number → HTML m - embedNum hasVal component conf = input conf.placeholder - $ HH.slot' cpColorComponent component (Num.input hasVal conf) unit - $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → - val <#> \n → do - case component of - Hue → modifyHSL (_{h = n}) color - HSL_S → modifyHSL (_{s = n / 100.0}) color - HSL_L → modifyHSL (_{l = n / 100.0}) color - HSV_S → modifyHSV (_{s = n / 100.0}) color - HSV_V → modifyHSV (_{v = n / 100.0}) color - Red → modifyRGB (_{r = asInt n}) color - Green → modifyRGB (_{g = asInt n}) color - Blue → modifyRGB (_{b = asInt n}) color - HEX → color -- hex values will not be comming from Number input - where - asInt = floor + renderItem = case _ of + NumberComponentSpec { key, hasNumVal, update, config } → + input config.prefix + $ HH.slot' cpNumComponent key (Num.input hasNumVal (mkNumConf props config)) unit + $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → update <$> val >>= (_ $ color) + TextComponentSpec { hasInputVal, key, config } → + input config.prefix + $ HH.slot' cpTextComponent key (PatternInput.input hasInputVal (mkTextConfig props config)) unit + $ HE.input \(PatternInput.NotifyChange val) → ComponentUpdate $ const val + input ∷ String → HTML m → HTML m input label child = HH.label [HP.classes $ props `classesFor` Input] [ HH.span [HP.classes $ props `classesFor` InputLabel] [HH.text label] , child ] - renderHex = input "#" - $ HH.slot' cpColorComponentHex unit (PatternInput.input - { fromString: \str → Color.fromHexString $ "#" <> str - , toString: \color → String.toUpper $ String.drop 1 $ Color.toHexString color - } - { title: "Hex" - , placeholder: "HEX" - , root: props `classesFor` InputElem - , rootInvalid: props `classesFor` InputElemInvalid - }) unit - $ HE.input \(PatternInput.NotifyChange val) → ComponentUpdate $ const val -type PreNumConf a = { title ∷ String, placeholder ∷ String, range ∷ Range a } +mkTextConfig ∷ ∀ a. Props → PreTextConf → PatternInput.Config a +mkTextConfig props { title, placeholder } = + { title + , placeholder + , root: props `classesFor` InputElem + , rootInvalid: props `classesFor` InputElemInvalid + } -mkConf ∷ ∀ a. Props → PreNumConf a → Num.Config a -mkConf props { title, placeholder, range } = +mkNumConf ∷ ∀ a. Props → PreNumConf a → Num.Config a +mkNumConf props { title, placeholder, range } = { title , placeholder , range @@ -285,61 +238,6 @@ mkConf props { title, placeholder, range } = , rootLength: const [] } -confRed ∷ PreNumConf Number -confRed = - { title: "Red" - , placeholder: "R" - , range: MinMax 0.0 256.0 - } - -confGreen ∷ PreNumConf Number -confGreen = - { title: "Green" - , placeholder: "G" - , range: MinMax 0.0 256.0 - } - -confBlue ∷ PreNumConf Number -confBlue = - { title: "Blue" - , placeholder: "B" - , range: MinMax 0.0 256.0 - } - -confHue ∷ PreNumConf Number -confHue = - { title: "Hue" - , placeholder: "H" - , range: MinMax 0.0 360.0 - } -confSaturation ∷ PreNumConf Number -confSaturation = - { title: "Saturation" - , placeholder: "S" - , range: MinMax 0.0 100.0 - } -confLightness ∷ PreNumConf Number -confLightness = - { title: "Lightness" - , placeholder: "L" - , range: MinMax 0.0 100.0 - } - -confValue ∷ PreNumConf Number -confValue = - { title: "Value" - , placeholder: "V" - , range: MinMax 0.0 100.0 - } - - -updateColor :: ∀ m. State → Color → DSL m Unit -updateColor state colorNext = do - H.put state{colorNext = colorNext} - H.raise $ NextChange colorNext - propagate - - eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m eval = case _ of Init next → do @@ -366,8 +264,8 @@ eval = case _ of let color = state.colorNext hsv = Color.toHSVA color - s = roundFractionalNum' 2 $ (dragData.progress.x) - v = roundFractionalNum' 2 $ (1.0 - dragData.progress.y) + s = dragData.progress.x + v = 1.0 - dragData.progress.y updateColor state (Color.hsv hsv.h s v) pure unit Drag.Done event → pure unit @@ -377,74 +275,49 @@ eval = case _ of Drag.Move event dragData → do state ← H.get let - h = roundFractionalNum $ (1.0 - dragData.progress.y) * 360.0 + h = (1.0 - dragData.progress.y) * 360.0 hsl = Color.toHSLA $ state.colorNext updateColor state (Color.hsl h hsl.s hsl.l) Drag.Done event → pure unit pure next SliderDragStart event next → startDrag SliderDragMove event next FieldDragStart event next → startDrag FieldDragMove event next - where - startDrag - ∷ ∀ a - . (∀ b. Drag.DragEvent → b → Query b) - → Drag.CursorEvent - → a - → DSL m a - startDrag action event next = do - H.subscribe $ Drag.dragEventSource event \drag → - Just (action drag H.Listening) - liftEff $ either preventDefault preventDefault event - initialDragData ← liftEff $ Drag.mkFirstDragData event - eval $ action (Drag.Move event initialDragData) next +startDrag + ∷ ∀ m r a + . MonadAff (PickerEffects r) m + ⇒ (∀ b. Drag.DragEvent → b → Query b) + → Drag.CursorEvent + → a + → DSL m a +startDrag action event next = do + H.subscribe $ Drag.dragEventSource event \drag → + Just (action drag H.Listening) + liftEff $ either preventDefault preventDefault event + initialDragData ← liftEff $ Drag.mkFirstDragData event + eval $ action (Drag.Move event initialDragData) next + +updateColor :: ∀ m. State → Color → DSL m Unit +updateColor state colorNext = do + H.put state{colorNext = colorNext} + H.raise $ NextChange colorNext + propagate propagate ∷ ∀ m. DSL m Unit propagate = do { colorNext, props: { editing }} ← H.get let - c = colorNext - hsl = Color.toHSLA c - hsv = Color.toHSVA c - rgb = Color.toRGBA c - for_ (fold editing) $ case _ of - Hue → H.query' cpColorComponent Hue (set $ roundFractionalNum hsl.h) >>= mustBeMounted - HSL_S → H.query' cpColorComponent HSL_S (set $ roundFractionalNum $ 100.0 * hsl.s) >>= mustBeMounted - HSL_L → H.query' cpColorComponent HSL_L (set $ roundFractionalNum $ 100.0 * hsl.l) >>= mustBeMounted - HSV_S → H.query' cpColorComponent HSV_S (set $ roundFractionalNum $ 100.0 * hsv.s) >>= mustBeMounted - HSV_V → H.query' cpColorComponent HSV_V (set $ roundFractionalNum $ 100.0 * hsv.v) >>= mustBeMounted - Red → H.query' cpColorComponent Red (set $ roundNum $ toNumber rgb.r) >>= mustBeMounted - Green → H.query' cpColorComponent Green (set $ roundNum $ toNumber rgb.g) >>= mustBeMounted - Blue → H.query' cpColorComponent Blue (set $ roundNum $ toNumber rgb.b) >>= mustBeMounted - HEX → H.query' cpColorComponentHex unit (H.action $ PatternInput.SetValue $ Just $ c) >>= mustBeMounted - where - set n = H.action (Num.SetValue $ Just $ roundFractionalNum n) - -type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } -type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } -type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } - -modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color → Color -modifyHSL f c = case f (Color.toHSLA c) of {h, s, l, a} → Color.hsla h s l a - -modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color → Color -modifyHSV f c = case f (Color.toHSVA c) of {h, s, v, a} → Color.hsva h s v a - -modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color → Color -modifyRGB f c = case f (Color.toRGBA c) of {r, g, b, a} → Color.rgba r g b a + colorEnv = + { hsl: Color.toHSLA colorNext + , hsv: Color.toHSVA colorNext + , rgb: Color.toRGBA colorNext + } + for_ (fold editing) $ \spec -> mustBeMounted =<< case spec of + TextComponentSpec { key } → + H.query' cpTextComponent key (H.action $ PatternInput.SetValue $ Just colorNext) + NumberComponentSpec {key, read} → + H.query' cpNumComponent key (H.action $ Num.SetValue $ Just $ read colorEnv) mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a mustBeMounted (Just x) = pure x mustBeMounted _ = halt "children must be mounted" - - -roundFractionalNum ∷ Number → Number -roundFractionalNum = roundFractionalNum' 0 - -roundFractionalNum' ∷ Int → Number → Number -roundFractionalNum' digits n = roundNum (n * scalar) / scalar - where - scalar = pow 10.0 (toNumber $ digits + 2) - -roundNum ∷ Number → Number -roundNum = round From ff3a0b67cad7bd377bf7701b94eca9124f7ad5a2 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 4 Aug 2017 19:52:05 +0200 Subject: [PATCH 17/72] add title and correct name of color stage --- example/index.html | 8 ++++---- example/src/Main.purs | 2 +- src/ColorPicker/Halogen/Component.purs | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/example/index.html b/example/index.html index fc74a9c..c556224 100644 --- a/example/index.html +++ b/example/index.html @@ -83,19 +83,19 @@ display: flex; margin-bottom: 0.5em } -.ColorPicker-colorBlockCurrent, -.ColorPicker-colorBlockPrevious { +.ColorPicker-colorBlockNext, +.ColorPicker-colorBlockCurrent { border-top: 1px solid; border-bottom: 1px solid; flex: 1 1 0%; height: 1.5em; } -.ColorPicker-colorBlockCurrent { +.ColorPicker-colorBlockNext { border-left: 1px solid; } -.ColorPicker-colorBlockPrevious { +.ColorPicker-colorBlockCurrent { border-right: 1px solid; cursor: pointer; } diff --git a/example/src/Main.purs b/example/src/Main.purs index 95a87f6..fecced0 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -124,7 +124,7 @@ mkConf root editing = , Tuple CPicker.Aside [ClassName "ColorPicker-aside"] , Tuple CPicker.Stage [ClassName "ColorPicker-stage"] , Tuple CPicker.ColorBlockCurrent [ClassName "ColorPicker-colorBlockCurrent"] - , Tuple CPicker.ColorBlockPrevious [ClassName "ColorPicker-colorBlockPrevious"] + , Tuple CPicker.ColorBlockNext [ClassName "ColorPicker-colorBlockNext"] , Tuple CPicker.Editing [ClassName "ColorPicker-editing"] , Tuple CPicker.EditingItem [ClassName "ColorPicker-editingItem"] , Tuple CPicker.Input [ClassName "ColorPicker-input"] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 970f423..b1fd801 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -54,7 +54,7 @@ data ClassGroup | Aside | Stage | ColorBlockCurrent - | ColorBlockPrevious + | ColorBlockNext | Editing | EditingItem | Input @@ -168,7 +168,8 @@ render { colorCurrent, colorNext, props} = HH.div [ HP.classes $ props `classesFor` Stage ] [ HH.div - [ HP.classes $ props `classesFor` ColorBlockCurrent + [ HP.classes $ props `classesFor` ColorBlockNext + , HP.title "Next value" , HCSS.style do CSS.backgroundColor colorNext textColor colorNext @@ -176,7 +177,8 @@ render { colorCurrent, colorNext, props} = [] , HH.div [ HP.tabIndex 0 - , HP.classes $ props `classesFor` ColorBlockPrevious + , HP.classes $ props `classesFor` ColorBlockCurrent + , HP.title "Current value" , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just colorCurrent) , HCSS.style do CSS.backgroundColor colorCurrent From 290cbb935c650db1fdfacaf2df3abe97758e1dae Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 4 Aug 2017 20:01:30 +0200 Subject: [PATCH 18/72] spacing and unicode --- example/index.html | 4 +++- example/src/Main.purs | 8 ++++---- src/ColorPicker/Halogen/ColorComponents.purs | 2 +- src/ColorPicker/Halogen/Component.purs | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/example/index.html b/example/index.html index c556224..c5ef3f5 100644 --- a/example/index.html +++ b/example/index.html @@ -3,6 +3,7 @@ Halogen Datepicker Example diff --git a/example/src/Main.purs b/example/src/Main.purs index 2b5f169..359a648 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -3,9 +3,12 @@ module Main where import Prelude import Color (Color, rgb) +import ColorPicker.Halogen.ColorComponents as C import ColorPicker.Halogen.Component as CPicker +import ColorPicker.Halogen.Layout as L import Control.Monad.Aff.Class (class MonadAff) import Control.Monad.Eff (Eff) +import Data.Array (reverse) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct import Data.Map (Map, fromFoldable, insert, lookup) @@ -19,7 +22,6 @@ import Halogen.Component.ChildPath as CP import Halogen.HTML as HH import Halogen.HTML.Events as HE import Halogen.VDom.Driver (runUI) -import ColorPicker.Halogen.ColorComponents as C main ∷ Eff (HA.HalogenEffects ()) Unit main = HA.runHalogenAff do @@ -80,26 +82,27 @@ eval (HandleMsg idx msg next) = do _, CPicker.NotifyChange x → {next: x, current: x} config0 ∷ CPicker.Props -config0 = mkConf - [ClassName "ColorPicker--small"] +config0 = mkConf reverse + (ClassName "ColorPicker--small") [ [C.componentHue] <> C.componentSL ] config1 ∷ CPicker.Props -config1 = mkConf - [ClassName "ColorPicker--large"] - [ [C.componentHue] <> C.componentSV <> [C.componentHEX] - , C.componentRGB +config1 = mkConf id + (ClassName "ColorPicker--large") + [ [C.componentHue] <> C.componentSV <> C.componentSL + , C.componentRGB <> [C.componentHEX] ] config2 ∷ CPicker.Props -config2 = mkConf - [ClassName "ColorPicker--small"] - [[ componentRedORNoRed ]] +config2 = mkConf id + (ClassName "ColorPicker--small") + [ [ const componentRedORNoRed ]] componentRedORNoRed ∷ C.ColorComponent componentRedORNoRed = C.TextComponentSpec - { fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing + { classes: inputClasses + , fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing , toString: \color → if color == (rgb 255 0 0) then "red" else "nored" , key: "Red" , config: @@ -108,29 +111,51 @@ componentRedORNoRed = C.TextComponentSpec , placeholder: "red" } } -mkConf ∷ Array ClassName → CPicker.ColorComponentGroups → CPicker.Props -mkConf root editing = - { editing + +mkConf + ∷ (∀ a. Array a → Array a) + → ClassName + → Array (Array (C.InputClasses → C.ColorComponent)) + → CPicker.Props +mkConf reverse' root editGroups = + { layout: + [ ClassName "ColorPicker", root ] `L.Group` (reverse' + [ [ ClassName "ColorPicker-dragger" ] `L.Group` + [ L.Component $ C.componentDragSV + { root: [ ClassName "ColorPicker-field" ] + , isLight: [ ClassName "IsLight" ] + , isDark: [ ClassName "IsDark" ] + , selector: [ ClassName "ColorPicker-fieldSelector"] + } + , L.Component $ C.componentDragHue + { root: [ ClassName "ColorPicker-slider" ] + , selector: [ ClassName "ColorPicker-sliderSelector"] + } + ] + , [ ClassName "ColorPicker-aside" ] `L.Group` + [ L.Stage + , L.Group [ ClassName "ColorPicker-editing" ] $ + editGroups <#> \editGroup → + L.Group [ ClassName "ColorPicker-editingItem" ] $ + editGroup <#> \mkItem -> L.Component $ mkItem inputClasses + , L.Actions + ] + ]) , classes: fromFoldable - [ Tuple CPicker.Root $ [ClassName "ColorPicker"] <> root - , Tuple CPicker.Dragger [ClassName "ColorPicker-dragger"] - , Tuple CPicker.Field [ClassName "ColorPicker-field"] - , Tuple CPicker.FieldSelector [ClassName "ColorPicker-fieldSelector"] - , Tuple CPicker.Slider [ClassName "ColorPicker-slider"] - , Tuple CPicker.SliderSelector [ClassName "ColorPicker-sliderSelector"] - , Tuple CPicker.Aside [ClassName "ColorPicker-aside"] - , Tuple CPicker.Stage [ClassName "ColorPicker-stage"] - , Tuple CPicker.ColorBlockCurrent [ClassName "ColorPicker-colorBlockCurrent"] - , Tuple CPicker.ColorBlockNext [ClassName "ColorPicker-colorBlockNext"] - , Tuple CPicker.Editing [ClassName "ColorPicker-editing"] - , Tuple CPicker.EditingItem [ClassName "ColorPicker-editingItem"] - , Tuple CPicker.Input [ClassName "ColorPicker-input"] - , Tuple CPicker.InputLabel [ClassName "ColorPicker-inputLabel"] - , Tuple CPicker.InputElem [ClassName "ColorPicker-inputElem"] - , Tuple CPicker.InputElemInvalid [ClassName "ColorPicker-inputElem--invalid"] - , Tuple CPicker.Actions [ClassName "ColorPicker-actions"] - , Tuple CPicker.ActionSet [ClassName "ColorPicker-actionSet"] - , Tuple CPicker.IsLight [ClassName "IsLight"] - , Tuple CPicker.IsDark [ClassName "IsDark"] + [ Tuple CPicker.Stage [ ClassName "ColorPicker-stage" ] + , Tuple CPicker.ColorBlockCurrent [ ClassName "ColorPicker-colorBlockCurrent" ] + , Tuple CPicker.ColorBlockNext [ ClassName "ColorPicker-colorBlockNext" ] + , Tuple CPicker.Actions [ ClassName "ColorPicker-actions" ] + , Tuple CPicker.ActionSet [ ClassName "ColorPicker-actionSet" ] + , Tuple CPicker.IsLight [ ClassName "IsLight" ] + , Tuple CPicker.IsDark [ ClassName "IsDark" ] ] } + +inputClasses ∷ C.InputClasses +inputClasses = + { root: [ClassName "ColorPicker-input"] + , label: [ClassName "ColorPicker-inputLabel"] + , elem: [ClassName "ColorPicker-inputElem"] + , elemInvalid: [ClassName "ColorPicker-inputElem--invalid"] + } diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 08884a0..c812992 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -2,9 +2,13 @@ module ColorPicker.Halogen.ColorComponents ( ColorComponent(..) , PreNumConf , PreTextConf + , InputClasses , RecordHSLA , RecordHSVA , RecordRGBA + , StyleProps + , PositionUpdate + , ColorEnv , componentHue , componentSaturationHSL , componentLightness @@ -17,46 +21,121 @@ module ColorPicker.Halogen.ColorComponents , componentSL , componentSV , componentRGB + , componentDragHue + , componentDragSV ) where import Prelude +import CSS (CSS) +import CSS as CSS import Color (Color) import Color as Color import Data.Int (floor, toNumber) -import Data.String as String import Data.Maybe (Maybe(..)) +import Data.String as String +import Halogen (ClassName) import Math (round) import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) +type PositionUpdate = { x ∷ Number, y ∷ Number } → Color → Color + +type StyleProps = + { classes ∷ Array ClassName + , css ∷ CSS + } type PreNumConf a = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range a } + type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } +type ColorEnv = + { hsl ∷ RecordHSLA + , hsv ∷ RecordHSVA + , rgb ∷ RecordRGBA + , isLight ∷ Boolean + , color ∷ Color + } + +type InputClasses = + { root ∷ Array ClassName + , label ∷ Array ClassName + , elem ∷ Array ClassName + , elemInvalid ∷ Array ClassName + } + +--TODO remove key from spec data ColorComponent = NumberComponentSpec { hasNumVal ∷ Num.HasNumberInputVal Number , update ∷ Number → Color → Maybe Color , key ∷ String - , read ∷ - { hsl ∷ RecordHSLA - , hsv ∷ RecordHSVA - , rgb ∷ RecordRGBA - } → Number + , read ∷ ColorEnv → Number , config ∷ PreNumConf Number + , classes ∷ InputClasses } | TextComponentSpec { fromString ∷ String → Maybe Color , toString ∷ Color → String , key ∷ String , config ∷ PreTextConf + , classes ∷ InputClasses + } + | DragComponentSpec + { root ∷ ColorEnv → StyleProps + , selector ∷ ColorEnv → StyleProps + , update ∷ { x ∷ Number, y ∷ Number } → Color → Color + } + + +componentDragSV ∷ + { isLight ∷ Array ClassName + , isDark ∷ Array ClassName + , root ∷ Array ClassName + , selector ∷ Array ClassName + } + → ColorComponent +componentDragSV classes = DragComponentSpec + { update : \{x, y} color → + let hsv = Color.toHSVA color + in Color.hsv hsv.h x (1.0 - y) + , root: \{isLight, hsv} → + { classes: classes.root <> if isLight then classes.isLight else classes.isDark + , css: CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 } + , selector: \{hsv, color} → + { classes: classes.selector + , css: do + CSS.left $ CSS.pct (hsv.s * 100.0) + CSS.bottom $ CSS.pct (hsv.v * 100.0) + CSS.backgroundColor color + } + } +componentDragHue ∷ + { root ∷ Array ClassName + , selector ∷ Array ClassName + } + → ColorComponent +componentDragHue classes = DragComponentSpec + { update : \{y} color → + let hsl = Color.toHSLA $ color + in (Color.hsl ((1.0 - y) * 360.0) hsl.s hsl.l) + , root: \_ → + { classes: classes.root + , css: pure unit + } + , selector: \{hsv} → + { classes: classes.selector + , css: CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) + } + } -componentHue ∷ ColorComponent -componentHue = NumberComponentSpec - { hasNumVal: hasValRound +componentHue ∷ InputClasses → ColorComponent +componentHue classes = NumberComponentSpec + { classes + , hasNumVal: hasValRound , key: "Hue" , update: \n color → Just $ modifyHSL (_{h = n}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum hsl.h @@ -64,72 +143,80 @@ componentHue = NumberComponentSpec } -componentSaturationHSL ∷ ColorComponent -componentSaturationHSL = NumberComponentSpec - { hasNumVal: hasValRound +componentSaturationHSL ∷ InputClasses → ColorComponent +componentSaturationHSL classes = NumberComponentSpec + { classes + , hasNumVal: hasValRound , key: "SaturationHSL" , update: \n color → Just $ modifyHSL (_{s = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s , config: confSaturation } -componentLightness ∷ ColorComponent -componentLightness = NumberComponentSpec - { hasNumVal: hasValRound +componentLightness ∷ InputClasses → ColorComponent +componentLightness classes = NumberComponentSpec + { classes + , hasNumVal: hasValRound , key: "Lightness" , update: \n color → Just $ modifyHSL (_{l = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l , config: confLightness } -componentSaturationHSV ∷ ColorComponent -componentSaturationHSV = NumberComponentSpec - { hasNumVal: hasValRound +componentSaturationHSV ∷ InputClasses → ColorComponent +componentSaturationHSV classes = NumberComponentSpec + { classes + , hasNumVal: hasValRound , key: "SaturationHSV" - , update: \n color → Just $ modifyHSL (_{s = n / 100.0}) color + , update: \n color → Just $ modifyHSV (_{s = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s , config: confSaturation } -componentValue ∷ ColorComponent -componentValue = NumberComponentSpec - { hasNumVal: hasValRound +componentValue ∷ InputClasses → ColorComponent +componentValue classes = NumberComponentSpec + { classes + , hasNumVal: hasValRound , key: "Value" - , update: \n color → Just $ modifyHSL (_{l = n / 100.0}) color + , update: \n color → Just $ modifyHSV (_{v = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v , config: confValue } -componentRed ∷ ColorComponent -componentRed = NumberComponentSpec - { hasNumVal: hasvalCail +componentRed ∷ InputClasses → ColorComponent +componentRed classes = NumberComponentSpec + { classes + , hasNumVal: hasvalCail , key: "Red" , update: \n color → Just $ modifyRGB (_{r = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r , config: confRed } -componentGreen ∷ ColorComponent -componentGreen = NumberComponentSpec - { hasNumVal: hasvalCail +componentGreen ∷ InputClasses → ColorComponent +componentGreen classes = NumberComponentSpec + { classes + , hasNumVal: hasvalCail , key: "Green" , update: \n color → Just $ modifyRGB (_{g = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g , config: confGreen } -componentBlue ∷ ColorComponent -componentBlue = NumberComponentSpec - { hasNumVal: hasvalCail +componentBlue ∷ InputClasses → ColorComponent +componentBlue classes = NumberComponentSpec + { classes + , hasNumVal: hasvalCail , key: "Blue" , update: \n color → Just $ modifyRGB (_{b = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b , config: confBlue } -componentHEX ∷ ColorComponent -componentHEX = TextComponentSpec - { fromString: \str → Color.fromHexString $ "#" <> str +componentHEX ∷ InputClasses → ColorComponent +componentHEX classes = TextComponentSpec + { classes + , fromString: \str → Color.fromHexString $ "#" <> str , toString: \color → String.toUpper $ String.drop 1 $ Color.toHexString color , key: "HEX" , config: @@ -139,13 +226,13 @@ componentHEX = TextComponentSpec } } -componentSL ∷ Array ColorComponent +componentSL ∷ Array (InputClasses → ColorComponent) componentSL = [componentSaturationHSL, componentLightness] -componentSV ∷ Array ColorComponent +componentSV ∷ Array (InputClasses → ColorComponent) componentSV = [componentSaturationHSV, componentValue] -componentRGB ∷ Array ColorComponent +componentRGB ∷ Array (InputClasses → ColorComponent) componentRGB = [componentRed, componentGreen, componentBlue] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 3f72a85..978449b 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,14 +16,15 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), PreNumConf) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, PreNumConf, InputClasses) +import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import Control.MonadZero (guard) import DOM.Classy.Event (preventDefault) import Data.Either (Either(..), either, isLeft) import Data.Either.Nested as Either -import Data.Foldable (fold, foldMap, for_) +import Data.Foldable (foldMap, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.Map (Map, insert, lookup) import Data.Maybe (Maybe(..), fromMaybe) @@ -56,22 +57,9 @@ classesFor ∷ Props → ClassGroup → Array HH.ClassName classesFor {classes} key = fromMaybe [] $ lookup key classes data ClassGroup - = Root - | Dragger - | Field - | FieldSelector - | Slider - | SliderSelector - | Aside - | Stage + = Stage | ColorBlockCurrent | ColorBlockNext - | Editing - | EditingItem - | Input - | InputLabel - | InputElem - | InputElemInvalid | Actions | ActionSet | IsLight @@ -82,16 +70,14 @@ derive instance classGroupOrd ∷ Ord ClassGroup type Props = { classes ∷ Map ClassGroup (Array HH.ClassName) - , editing ∷ ColorComponentGroups + , layout ∷ L.Layout } data Query a = SetProps Props a - | FieldDragStart Drag.CursorEvent a - | FieldDragMove Drag.DragEvent a - | SliderDragStart Drag.CursorEvent a - | SliderDragMove Drag.DragEvent a + | DragStart PositionUpdate Drag.CursorEvent a + | DragMove PositionUpdate Drag.DragEvent a | ComponentUpdate (Color → Maybe Color) a | Commit a | Init a @@ -126,122 +112,96 @@ picker = H.lifecycleParentComponent } render ∷ ∀ m. State → HTML m -render state@{ color, inputs, props} = - HH.div - [ HP.classes $ props `classesFor` Root ] - [ dragger, aside ] - where - colorClasses c = props `classesFor` (if Color.isLight c then IsLight else IsDark) - hsv = Color.toHSVA $ color.next +render state@{ color, inputs, props} = renderLayout state props.layout - dragger = +renderLayout ∷ ∀ m. State → L.Layout → HTML m +renderLayout state@{ color, inputs, props} = case _ of + L.Group classes l → HH.div - [ HP.classes $ (props `classesFor` Dragger) <> colorClasses color.next ] - [ field, slider ] - - field = + [ HP.classes classes ] + $ map (renderLayout state) l + L.Actions → HH.div - [ HP.classes $ props `classesFor` Field - , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 - , HE.onMouseDown $ HE.input (Left >>> FieldDragStart) - , HE.onTouchStart $ HE.input (Right >>> FieldDragStart) - ] - [ HH.div - [ HP.classes $ props `classesFor` FieldSelector - , HCSS.style do - CSS.display CSS.block - CSS.left $ CSS.pct (hsv.s * 100.0) - CSS.bottom $ CSS.pct (hsv.v * 100.0) - CSS.backgroundColor color.next - ] - [] - ] - - slider = - HH.div - [ HP.classes $ props `classesFor` Slider - , HE.onMouseDown $ HE.input (Left >>> SliderDragStart) - , HE.onTouchStart $ HE.input (Right >>> SliderDragStart) - ] - [ HH.div - [ HP.classes $ props `classesFor` SliderSelector - , HCSS.style $ CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) - ] - [] + [ HP.classes $ props `classesFor` Actions ] + [ HH.button + [ HP.classes $ props `classesFor` ActionSet + , HE.onClick $ HE.input \_ → Commit + ] + [ HH.text "Set" ] ] - - aside = - HH.div - [ HP.classes $ props `classesFor` Aside ] - [stage, editing, actions] - - stage = + L.Stage → HH.div [ HP.classes $ props `classesFor` Stage ] [ HH.div - [ HP.classes $ (props `classesFor` ColorBlockNext) <> colorClasses color.next + [ HP.classes $ (props `classesFor` ColorBlockNext) <> colorClasses props color.next , HP.title "Next value" , HCSS.style $ CSS.backgroundColor color.next ] [] , HH.div [ HP.tabIndex 0 - , HP.classes $ (props `classesFor` ColorBlockCurrent) <> colorClasses color.current + , HP.classes $ (props `classesFor` ColorBlockCurrent) <> colorClasses props color.current , HP.title "Current value" , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just color.current) , HCSS.style $ CSS.backgroundColor color.current ] [] ] + L.Component c → renderColorComponent state c - editing = - HH.div - [ HP.classes $ props `classesFor` Editing ] - (renderEditingItem state <$> props.editing ) - - actions = - HH.div - [ HP.classes $ props `classesFor` Actions ] - [ HH.button - [ HP.classes $ props `classesFor` ActionSet - , HE.onClick $ HE.input \_ → Commit - ] - [ HH.text "Set" ] - ] - -renderEditingItem ∷ ∀ m. State -> ColorComponents → HTML m -renderEditingItem { inputs, props } x = HH.div [ HP.classes $ props `classesFor` EditingItem ] $ x <#> renderItem where - renderItem = case _ of - NumberComponentSpec { key, hasNumVal, update, config } → - input config.prefix + hsv = Color.toHSVA $ color.next + colorEnv = calcColorEnv color.next + renderColorComponent ∷ State → ColorComponent → HTML m + renderColorComponent { inputs, props } = case _ of + DragComponentSpec spec → + let + root = spec.root colorEnv + selector = spec.selector colorEnv + in + HH.div + [ HP.classes root.classes + , HCSS.style $ root.css + , HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) + , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) + ] + [ HH.div + [ HP.classes $ selector.classes + , HCSS.style $ selector.css + ] + [] + ] + NumberComponentSpec { classes, key, hasNumVal, update, config } → + input classes config.prefix $ pure - $ HH.slot' cpNumComponent key (Num.input hasNumVal (mkNumConf props config)) unit + $ HH.slot' cpNumComponent key (Num.input hasNumVal (mkNumConf classes config)) unit $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → update <$> val >>= (_ $ color) - TextComponentSpec { fromString, key, config } → - input config.prefix $ flip foldMap (lookup key inputs) \val -> pure $ HH.input + TextComponentSpec { classes, fromString, key, config } → + input classes config.prefix $ flip foldMap (lookup key inputs) \val → pure $ HH.input [ HP.type_ HP.InputText , HP.classes - $ (props `classesFor` InputElem) - <> (guard (isLeft val) *> (props `classesFor` InputElemInvalid)) + $ classes.elem + <> (guard (isLeft val) *> (classes.elemInvalid)) , HP.title config.title , HP.placeholder config.placeholder , HP.value $ either id id val - , HE.onValueInput $ HE.input $ \ str -> UpdateTextInput key str (fromString str) + , HE.onValueInput $ HE.input $ \ str → UpdateTextInput key str (fromString str) ] + where + input classes label child = + HH.label [HP.classes classes.root] $ + [ HH.span [HP.classes classes.label] [HH.text label]] <> child - input ∷ String → Array (HTML m) → HTML m - input label child = - HH.label [HP.classes $ props `classesFor` Input] $ - [ HH.span [HP.classes $ props `classesFor` InputLabel] [HH.text label]] <> child +colorClasses ∷ Props → Color → Array HH.ClassName +colorClasses props c = props `classesFor` (if Color.isLight c then IsLight else IsDark) -mkNumConf ∷ ∀ a. Props → PreNumConf a → Num.Config a -mkNumConf props { title, placeholder, range } = +mkNumConf ∷ ∀ a. InputClasses → PreNumConf a → Num.Config a +mkNumConf {elem, elemInvalid} { title, placeholder, range } = { title , placeholder , range - , root: props `classesFor` InputElem - , rootInvalid: props `classesFor` InputElemInvalid + , root: elem + , rootInvalid: elemInvalid , rootLength: const [] } @@ -250,9 +210,9 @@ eval = case _ of UpdateTextInput key str color next → do let val = case color of - Nothing -> Left str - Just _ -> Right str - H.modify \s -> s { inputs = insert key val s.inputs } + Nothing → Left str + Just _ → Right str + H.modify \s → s { inputs = insert key val s.inputs } eval $ ComponentUpdate (const color) next SetValue val next → do state ← H.get @@ -275,45 +235,20 @@ eval = case _ of SetProps props next → do H.modify _{props = props} pure next - FieldDragMove drag next → do + DragMove update drag next → do case drag of Drag.Move event dragData → do state ← H.get - let - color = state.color.next - hsv = Color.toHSVA color - s = dragData.progress.x - v = 1.0 - dragData.progress.y - updateColor state (Color.hsv hsv.h s v) + updateColor state $ update dragData.progress state.color.next pure unit Drag.Done event → pure unit pure next - SliderDragMove drag next → do - case drag of - Drag.Move event dragData → do - state ← H.get - let - h = (1.0 - dragData.progress.y) * 360.0 - hsl = Color.toHSLA $ state.color.next - updateColor state (Color.hsl h hsl.s hsl.l) - Drag.Done event → pure unit - pure next - SliderDragStart event next → startDrag SliderDragMove event next - FieldDragStart event next → startDrag FieldDragMove event next - -startDrag - ∷ ∀ m r a - . MonadAff (PickerEffects r) m - ⇒ (∀ b. Drag.DragEvent → b → Query b) - → Drag.CursorEvent - → a - → DSL m a -startDrag action event next = do - H.subscribe $ Drag.dragEventSource event \drag → - Just (action drag H.Listening) - liftEff $ either preventDefault preventDefault event - initialDragData ← liftEff $ Drag.mkFirstDragData event - eval $ action (Drag.Move event initialDragData) next + DragStart update event next → do + H.subscribe $ Drag.dragEventSource event \drag → + Just (DragMove update drag H.Listening) + liftEff $ either preventDefault preventDefault event + initialDragData ← liftEff $ Drag.mkFirstDragData event + eval $ DragMove update (Drag.Move event initialDragData) next updateColor ∷ ∀ m. State → Color → DSL m Unit updateColor state colorNext = do @@ -321,20 +256,35 @@ updateColor state colorNext = do H.raise $ NextChange colorNext propagate + +calcColorEnv ∷ Color → ColorEnv +calcColorEnv color = + { hsl: Color.toHSLA color + , hsv: Color.toHSVA color + , rgb: Color.toRGBA color + , isLight: Color.isLight color + , color: color + } + propagate ∷ ∀ m. DSL m Unit propagate = do - { color, props: { editing }} ← H.get - let - colorEnv = - { hsl: Color.toHSLA color.next - , hsv: Color.toHSVA color.next - , rgb: Color.toRGBA color.next - } - for_ (fold editing) $ \spec → case spec of - TextComponentSpec { key, toString } → - H.modify \s -> s { inputs = insert key (Right $ toString color.next) s.inputs } - NumberComponentSpec {key, read} → - H.query' cpNumComponent key (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted + { color, props: { layout }} ← H.get + propagateLayout + color + (calcColorEnv color.next) + layout + where + propagateLayout ∷ ValueProgress Color → ColorEnv → L.Layout → DSL m Unit + propagateLayout color colorEnv = case _ of + L.Group _ l → for_ l (propagateLayout color colorEnv) + L.Stage → pure unit + L.Actions → pure unit + L.Component c → case c of + DragComponentSpec _ → pure unit + TextComponentSpec { key, toString } → + H.modify \s → s { inputs = insert key (Right $ toString color.next) s.inputs } + NumberComponentSpec {key, read} → + H.query' cpNumComponent key (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a mustBeMounted (Just x) = pure x diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs new file mode 100644 index 0000000..4906fef --- /dev/null +++ b/src/ColorPicker/Halogen/Layout.purs @@ -0,0 +1,11 @@ +module ColorPicker.Halogen.Layout where + + +import ColorPicker.Halogen.ColorComponents (ColorComponent) +import Halogen (ClassName) + +data Layout + = Group (Array ClassName) (Array Layout) + | Component ColorComponent + | Stage + | Actions diff --git a/src/ColorPicker/Halogen/Utils/Drag.purs b/src/ColorPicker/Halogen/Utils/Drag.purs index 7e4fd3b..44ad28e 100644 --- a/src/ColorPicker/Halogen/Utils/Drag.purs +++ b/src/ColorPicker/Halogen/Utils/Drag.purs @@ -152,7 +152,7 @@ nodeBoundingClientRect → Eff (dom ∷ DOM | r) DOMRect nodeBoundingClientRect node = fromMaybe (pure {left: 0.0, right: 0.0, top: 0.0, bottom: 0.0, width: 0.0, height: 0.0}) - (getBoundingClientRect <$>elem) + (getBoundingClientRect <$> elem) where elem ∷ Maybe HTMLElement elem = fromNode node From 7d2c0fda7fd21b30d71475f6607b0b22fcf41e7e Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 10 Aug 2017 20:07:43 +0200 Subject: [PATCH 29/72] unfix infix with parens --- example/src/Main.purs | 4 ++-- src/ColorPicker/Halogen/Component.purs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 359a648..68d4467 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -119,7 +119,7 @@ mkConf → CPicker.Props mkConf reverse' root editGroups = { layout: - [ ClassName "ColorPicker", root ] `L.Group` (reverse' + L.Group [ ClassName "ColorPicker", root ] $ reverse' [ [ ClassName "ColorPicker-dragger" ] `L.Group` [ L.Component $ C.componentDragSV { root: [ ClassName "ColorPicker-field" ] @@ -140,7 +140,7 @@ mkConf reverse' root editGroups = editGroup <#> \mkItem -> L.Component $ mkItem inputClasses , L.Actions ] - ]) + ] , classes: fromFoldable [ Tuple CPicker.Stage [ ClassName "ColorPicker-stage" ] , Tuple CPicker.ColorBlockCurrent [ ClassName "ColorPicker-colorBlockCurrent" ] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 978449b..29b07a7 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -133,14 +133,14 @@ renderLayout state@{ color, inputs, props} = case _ of HH.div [ HP.classes $ props `classesFor` Stage ] [ HH.div - [ HP.classes $ (props `classesFor` ColorBlockNext) <> colorClasses props color.next + [ HP.classes $ classesFor props ColorBlockNext <> colorClasses props color.next , HP.title "Next value" , HCSS.style $ CSS.backgroundColor color.next ] [] , HH.div [ HP.tabIndex 0 - , HP.classes $ (props `classesFor` ColorBlockCurrent) <> colorClasses props color.current + , HP.classes $ classesFor props ColorBlockCurrent <> colorClasses props color.current , HP.title "Current value" , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just color.current) , HCSS.style $ CSS.backgroundColor color.current @@ -193,7 +193,7 @@ renderLayout state@{ color, inputs, props} = case _ of [ HH.span [HP.classes classes.label] [HH.text label]] <> child colorClasses ∷ Props → Color → Array HH.ClassName -colorClasses props c = props `classesFor` (if Color.isLight c then IsLight else IsDark) +colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark mkNumConf ∷ ∀ a. InputClasses → PreNumConf a → Num.Config a mkNumConf {elem, elemInvalid} { title, placeholder, range } = From 88e9b581b60f00fc3021d8a6871f02fa2ed02278 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 11 Aug 2017 22:46:47 +0200 Subject: [PATCH 30/72] use Cynamic -> a instead of Color -> a --- example/src/Main.purs | 6 +- src/ColorPicker/Halogen/ColorComponents.purs | 123 ++++++++++--------- src/ColorPicker/Halogen/Component.purs | 11 +- 3 files changed, 74 insertions(+), 66 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 68d4467..b59c707 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -103,7 +103,7 @@ componentRedORNoRed ∷ C.ColorComponent componentRedORNoRed = C.TextComponentSpec { classes: inputClasses , fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing - , toString: \color → if color == (rgb 255 0 0) then "red" else "nored" + , toString: \{color} → if color == (rgb 255 0 0) then "red" else "nored" , key: "Red" , config: { title: "red or nored?" @@ -115,7 +115,7 @@ componentRedORNoRed = C.TextComponentSpec mkConf ∷ (∀ a. Array a → Array a) → ClassName - → Array (Array (C.InputClasses → C.ColorComponent)) + → Array (Array (C.InputProps C.Classes → C.ColorComponent)) → CPicker.Props mkConf reverse' root editGroups = { layout: @@ -152,7 +152,7 @@ mkConf reverse' root editGroups = ] } -inputClasses ∷ C.InputClasses +inputClasses ∷ C.InputProps C.Classes inputClasses = { root: [ClassName "ColorPicker-input"] , label: [ClassName "ColorPicker-inputLabel"] diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index c812992..83ed431 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -1,12 +1,14 @@ module ColorPicker.Halogen.ColorComponents ( ColorComponent(..) + , Dynamic + , Styles , PreNumConf , PreTextConf - , InputClasses + , InputProps + , Classes , RecordHSLA , RecordHSVA , RecordRGBA - , StyleProps , PositionUpdate , ColorEnv , componentHue @@ -39,14 +41,18 @@ import Math (round) import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) -type PositionUpdate = { x ∷ Number, y ∷ Number } → Color → Color +type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color -type StyleProps = - { classes ∷ Array ClassName +type Dynamic s = ColorEnv → s + +type Classes = Array ClassName + +type Styles = + { classes ∷ Classes , css ∷ CSS } -type PreNumConf a = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range a } +type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } @@ -58,34 +64,35 @@ type ColorEnv = , color ∷ Color } -type InputClasses = - { root ∷ Array ClassName - , label ∷ Array ClassName - , elem ∷ Array ClassName - , elemInvalid ∷ Array ClassName +type InputProps c = + { root ∷ c + , label ∷ c + , elem ∷ c + , elemInvalid ∷ c } + --TODO remove key from spec data ColorComponent = NumberComponentSpec { hasNumVal ∷ Num.HasNumberInputVal Number - , update ∷ Number → Color → Maybe Color + , update ∷ Number → Dynamic (Maybe Color) , key ∷ String - , read ∷ ColorEnv → Number - , config ∷ PreNumConf Number - , classes ∷ InputClasses + , read ∷ Dynamic Number + , config ∷ PreNumConf + , classes ∷ InputProps Classes } | TextComponentSpec { fromString ∷ String → Maybe Color - , toString ∷ Color → String + , toString ∷ Dynamic String , key ∷ String , config ∷ PreTextConf - , classes ∷ InputClasses + , classes ∷ InputProps Classes } | DragComponentSpec - { root ∷ ColorEnv → StyleProps - , selector ∷ ColorEnv → StyleProps - , update ∷ { x ∷ Number, y ∷ Number } → Color → Color + { root ∷ Dynamic Styles + , selector ∷ Dynamic Styles + , update ∷ PositionUpdate } @@ -97,7 +104,7 @@ componentDragSV ∷ } → ColorComponent componentDragSV classes = DragComponentSpec - { update : \{x, y} color → + { update : \{x, y} {color} → let hsv = Color.toHSVA color in Color.hsv hsv.h x (1.0 - y) , root: \{isLight, hsv} → @@ -119,7 +126,7 @@ componentDragHue ∷ } → ColorComponent componentDragHue classes = DragComponentSpec - { update : \{y} color → + { update : \{y} {color} → let hsl = Color.toHSLA $ color in (Color.hsl ((1.0 - y) * 360.0) hsl.s hsl.l) , root: \_ → @@ -132,92 +139,92 @@ componentDragHue classes = DragComponentSpec } } -componentHue ∷ InputClasses → ColorComponent +componentHue ∷ InputProps Classes → ColorComponent componentHue classes = NumberComponentSpec { classes , hasNumVal: hasValRound , key: "Hue" - , update: \n color → Just $ modifyHSL (_{h = n}) color + , update: \n {color} → Just $ modifyHSL (_{h = n}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum hsl.h , config: confHue } -componentSaturationHSL ∷ InputClasses → ColorComponent +componentSaturationHSL ∷ InputProps Classes → ColorComponent componentSaturationHSL classes = NumberComponentSpec { classes , hasNumVal: hasValRound , key: "SaturationHSL" - , update: \n color → Just $ modifyHSL (_{s = n / 100.0}) color + , update: \n {color} → Just $ modifyHSL (_{s = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s , config: confSaturation } -componentLightness ∷ InputClasses → ColorComponent +componentLightness ∷ InputProps Classes → ColorComponent componentLightness classes = NumberComponentSpec { classes , hasNumVal: hasValRound , key: "Lightness" - , update: \n color → Just $ modifyHSL (_{l = n / 100.0}) color + , update: \n {color} → Just $ modifyHSL (_{l = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l , config: confLightness } -componentSaturationHSV ∷ InputClasses → ColorComponent +componentSaturationHSV ∷ InputProps Classes → ColorComponent componentSaturationHSV classes = NumberComponentSpec { classes , hasNumVal: hasValRound , key: "SaturationHSV" - , update: \n color → Just $ modifyHSV (_{s = n / 100.0}) color + , update: \n {color} → Just $ modifyHSV (_{s = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s , config: confSaturation } -componentValue ∷ InputClasses → ColorComponent +componentValue ∷ InputProps Classes → ColorComponent componentValue classes = NumberComponentSpec { classes , hasNumVal: hasValRound , key: "Value" - , update: \n color → Just $ modifyHSV (_{v = n / 100.0}) color + , update: \n {color} → Just $ modifyHSV (_{v = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v , config: confValue } -componentRed ∷ InputClasses → ColorComponent +componentRed ∷ InputProps Classes → ColorComponent componentRed classes = NumberComponentSpec { classes - , hasNumVal: hasvalCail + , hasNumVal: hasValCail , key: "Red" - , update: \n color → Just $ modifyRGB (_{r = asInt n}) color + , update: \n {color} → Just $ modifyRGB (_{r = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r , config: confRed } -componentGreen ∷ InputClasses → ColorComponent +componentGreen ∷ InputProps Classes → ColorComponent componentGreen classes = NumberComponentSpec { classes - , hasNumVal: hasvalCail + , hasNumVal: hasValCail , key: "Green" - , update: \n color → Just $ modifyRGB (_{g = asInt n}) color + , update: \n {color} → Just $ modifyRGB (_{g = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g , config: confGreen } -componentBlue ∷ InputClasses → ColorComponent +componentBlue ∷ InputProps Classes → ColorComponent componentBlue classes = NumberComponentSpec { classes - , hasNumVal: hasvalCail + , hasNumVal: hasValCail , key: "Blue" - , update: \n color → Just $ modifyRGB (_{b = asInt n}) color + , update: \n {color} → Just $ modifyRGB (_{b = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b , config: confBlue } -componentHEX ∷ InputClasses → ColorComponent +componentHEX ∷ InputProps Classes → ColorComponent componentHEX classes = TextComponentSpec { classes , fromString: \str → Color.fromHexString $ "#" <> str - , toString: \color → String.toUpper $ String.drop 1 $ Color.toHexString color + , toString: \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color , key: "HEX" , config: { prefix: "#" @@ -226,20 +233,20 @@ componentHEX classes = TextComponentSpec } } -componentSL ∷ Array (InputClasses → ColorComponent) +componentSL ∷ Array (InputProps Classes → ColorComponent) componentSL = [componentSaturationHSL, componentLightness] -componentSV ∷ Array (InputClasses → ColorComponent) +componentSV ∷ Array (InputProps Classes → ColorComponent) componentSV = [componentSaturationHSV, componentValue] -componentRGB ∷ Array (InputClasses → ColorComponent) +componentRGB ∷ Array (InputProps Classes → ColorComponent) componentRGB = [componentRed, componentGreen, componentBlue] -- Internal helpers -confRed ∷ PreNumConf Number +confRed ∷ PreNumConf confRed = { title: "Red" , placeholder: "R" @@ -247,7 +254,7 @@ confRed = , range: MinMax 0.0 256.0 } -confGreen ∷ PreNumConf Number +confGreen ∷ PreNumConf confGreen = { title: "Green" , placeholder: "G" @@ -255,7 +262,7 @@ confGreen = , range: MinMax 0.0 256.0 } -confBlue ∷ PreNumConf Number +confBlue ∷ PreNumConf confBlue = { title: "Blue" , placeholder: "B" @@ -263,21 +270,21 @@ confBlue = , range: MinMax 0.0 256.0 } -confHue ∷ PreNumConf Number +confHue ∷ PreNumConf confHue = { title: "Hue" , placeholder: "H" , prefix: "H" , range: MinMax 0.0 360.0 } -confSaturation ∷ PreNumConf Number +confSaturation ∷ PreNumConf confSaturation = { title: "Saturation" , placeholder: "S" , prefix: "S" , range: MinMax 0.0 100.0 } -confLightness ∷ PreNumConf Number +confLightness ∷ PreNumConf confLightness = { title: "Lightness" , placeholder: "L" @@ -285,7 +292,7 @@ confLightness = , range: MinMax 0.0 100.0 } -confValue ∷ PreNumConf Number +confValue ∷ PreNumConf confValue = { title: "Value" , placeholder: "V" @@ -294,15 +301,12 @@ confValue = } -asInt ∷ Number → Int -asInt = floor - hasValRound ∷ Num.HasNumberInputVal Number hasValRound = Num.numberHasNumberInputVal {fromString = Num.numberHasNumberInputVal.fromString >>> map roundFractionalNum} -hasvalCail ∷ Num.HasNumberInputVal Number -hasvalCail = Num.numberHasNumberInputVal +hasValCail ∷ Num.HasNumberInputVal Number +hasValCail = Num.numberHasNumberInputVal {fromString = Num.numberHasNumberInputVal.fromString >>> map roundNum} roundFractionalNum ∷ Number → Number @@ -310,6 +314,9 @@ roundFractionalNum n = roundNum (n * scalar) / scalar where scalar = 100.0 +asInt ∷ Number → Int +asInt = floor + roundNum ∷ Number → Number roundNum = round diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 29b07a7..7efe29a 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,7 +16,7 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, PreNumConf, InputClasses) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, PreNumConf, InputProps, Classes) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) @@ -175,7 +175,7 @@ renderLayout state@{ color, inputs, props} = case _ of input classes config.prefix $ pure $ HH.slot' cpNumComponent key (Num.input hasNumVal (mkNumConf classes config)) unit - $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → update <$> val >>= (_ $ color) + $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → update <$> val >>= (_ $ colorEnv) TextComponentSpec { classes, fromString, key, config } → input classes config.prefix $ flip foldMap (lookup key inputs) \val → pure $ HH.input [ HP.type_ HP.InputText @@ -195,7 +195,7 @@ renderLayout state@{ color, inputs, props} = case _ of colorClasses ∷ Props → Color → Array HH.ClassName colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark -mkNumConf ∷ ∀ a. InputClasses → PreNumConf a → Num.Config a +mkNumConf ∷ InputProps Classes → PreNumConf → Num.Config Number mkNumConf {elem, elemInvalid} { title, placeholder, range } = { title , placeholder @@ -239,7 +239,7 @@ eval = case _ of case drag of Drag.Move event dragData → do state ← H.get - updateColor state $ update dragData.progress state.color.next + updateColor state $ update dragData.progress (calcColorEnv state.color.next) pure unit Drag.Done event → pure unit pure next @@ -274,6 +274,7 @@ propagate = do (calcColorEnv color.next) layout where + -- TODO at this point `color` arg can be removed propagateLayout ∷ ValueProgress Color → ColorEnv → L.Layout → DSL m Unit propagateLayout color colorEnv = case _ of L.Group _ l → for_ l (propagateLayout color colorEnv) @@ -282,7 +283,7 @@ propagate = do L.Component c → case c of DragComponentSpec _ → pure unit TextComponentSpec { key, toString } → - H.modify \s → s { inputs = insert key (Right $ toString color.next) s.inputs } + H.modify \s → s { inputs = insert key (Right $ toString colorEnv) s.inputs } NumberComponentSpec {key, read} → H.query' cpNumComponent key (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted From 8d8e7a5031fa41c72644a7be137cd6c6ef8d0076 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 14 Aug 2017 01:07:40 +0200 Subject: [PATCH 31/72] refactor components - use Cursor instead of string key - make styles and props more dynamic --- bower.json | 2 +- example/src/Main.purs | 4 +- src/ColorPicker/Halogen/ColorComponents.purs | 61 ++++----- src/ColorPicker/Halogen/Component.purs | 129 ++++++++++++------- 4 files changed, 115 insertions(+), 81 deletions(-) diff --git a/bower.json b/bower.json index 0607588..932970f 100644 --- a/bower.json +++ b/bower.json @@ -25,7 +25,7 @@ "purescript-halogen-css": "^6.0.0", "purescript-dom-classy": "^2.1.0", "purescript-dom": "^4.7.0", - "purescript-number-input-halogen": "git://github.com/safareli/purescript-number-input-halogen.git#initial" + "purescript-number-input-halogen": "git://github.com/safareli/purescript-number-input-halogen.git#initial-props" }, "resolutions": { "purescript-colors": "hsv" diff --git a/example/src/Main.purs b/example/src/Main.purs index b59c707..c371efb 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -3,6 +3,7 @@ module Main where import Prelude import Color (Color, rgb) +import ColorPicker.Halogen.ColorComponents (toDynamicStyles) import ColorPicker.Halogen.ColorComponents as C import ColorPicker.Halogen.Component as CPicker import ColorPicker.Halogen.Layout as L @@ -101,10 +102,9 @@ config2 = mkConf id componentRedORNoRed ∷ C.ColorComponent componentRedORNoRed = C.TextComponentSpec - { classes: inputClasses + { styles: toDynamicStyles inputClasses , fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing , toString: \{color} → if color == (rgb 255 0 0) then "red" else "nored" - , key: "Red" , config: { title: "red or nored?" , prefix: "🛑" diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 83ed431..7e03b73 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -25,6 +25,8 @@ module ColorPicker.Halogen.ColorComponents , componentRGB , componentDragHue , componentDragSV + , mapInputProps + , toDynamicStyles ) where import Prelude @@ -72,22 +74,19 @@ type InputProps c = } ---TODO remove key from spec data ColorComponent = NumberComponentSpec - { hasNumVal ∷ Num.HasNumberInputVal Number + { hasNumVal ∷ Num.HasNumberInputValue Number , update ∷ Number → Dynamic (Maybe Color) - , key ∷ String , read ∷ Dynamic Number , config ∷ PreNumConf - , classes ∷ InputProps Classes + , styles ∷ InputProps (Dynamic Styles) } | TextComponentSpec { fromString ∷ String → Maybe Color , toString ∷ Dynamic String - , key ∷ String , config ∷ PreTextConf - , classes ∷ InputProps Classes + , styles ∷ InputProps (Dynamic Styles) } | DragComponentSpec { root ∷ Dynamic Styles @@ -141,9 +140,8 @@ componentDragHue classes = DragComponentSpec componentHue ∷ InputProps Classes → ColorComponent componentHue classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValRound - , key: "Hue" , update: \n {color} → Just $ modifyHSL (_{h = n}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum hsl.h , config: confHue @@ -152,9 +150,8 @@ componentHue classes = NumberComponentSpec componentSaturationHSL ∷ InputProps Classes → ColorComponent componentSaturationHSL classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValRound - , key: "SaturationHSL" , update: \n {color} → Just $ modifyHSL (_{s = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s , config: confSaturation @@ -162,9 +159,8 @@ componentSaturationHSL classes = NumberComponentSpec componentLightness ∷ InputProps Classes → ColorComponent componentLightness classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValRound - , key: "Lightness" , update: \n {color} → Just $ modifyHSL (_{l = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l , config: confLightness @@ -172,19 +168,28 @@ componentLightness classes = NumberComponentSpec componentSaturationHSV ∷ InputProps Classes → ColorComponent componentSaturationHSV classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValRound - , key: "SaturationHSV" , update: \n {color} → Just $ modifyHSV (_{s = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s , config: confSaturation } +mapInputProps :: ∀ a b. (a -> b) -> InputProps a -> InputProps b +mapInputProps f { root, label, elem, elemInvalid } = + { root: f root + , label: f label + , elem: f elem + , elemInvalid: f elemInvalid + } + +toDynamicStyles :: InputProps Classes -> InputProps (Dynamic Styles) +toDynamicStyles = mapInputProps $ { classes: _, css: pure unit } >>> const + componentValue ∷ InputProps Classes → ColorComponent componentValue classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValRound - , key: "Value" , update: \n {color} → Just $ modifyHSV (_{v = n / 100.0}) color , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v , config: confValue @@ -192,9 +197,8 @@ componentValue classes = NumberComponentSpec componentRed ∷ InputProps Classes → ColorComponent componentRed classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValCail - , key: "Red" , update: \n {color} → Just $ modifyRGB (_{r = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r , config: confRed @@ -202,9 +206,8 @@ componentRed classes = NumberComponentSpec componentGreen ∷ InputProps Classes → ColorComponent componentGreen classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValCail - , key: "Green" , update: \n {color} → Just $ modifyRGB (_{g = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g , config: confGreen @@ -212,9 +215,8 @@ componentGreen classes = NumberComponentSpec componentBlue ∷ InputProps Classes → ColorComponent componentBlue classes = NumberComponentSpec - { classes + { styles: toDynamicStyles classes , hasNumVal: hasValCail - , key: "Blue" , update: \n {color} → Just $ modifyRGB (_{b = asInt n}) color , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b , config: confBlue @@ -222,10 +224,9 @@ componentBlue classes = NumberComponentSpec componentHEX ∷ InputProps Classes → ColorComponent componentHEX classes = TextComponentSpec - { classes + { styles: toDynamicStyles classes , fromString: \str → Color.fromHexString $ "#" <> str , toString: \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color - , key: "HEX" , config: { prefix: "#" , title: "Hex" @@ -301,13 +302,13 @@ confValue = } -hasValRound ∷ Num.HasNumberInputVal Number -hasValRound = Num.numberHasNumberInputVal - {fromString = Num.numberHasNumberInputVal.fromString >>> map roundFractionalNum} +hasValRound ∷ Num.HasNumberInputValue Number +hasValRound = Num.numberHasNumberInputValue + {fromString = Num.numberHasNumberInputValue.fromString >>> map roundFractionalNum} -hasValCail ∷ Num.HasNumberInputVal Number -hasValCail = Num.numberHasNumberInputVal - {fromString = Num.numberHasNumberInputVal.fromString >>> map roundNum} +hasValCail ∷ Num.HasNumberInputValue Number +hasValCail = Num.numberHasNumberInputValue + {fromString = Num.numberHasNumberInputValue.fromString >>> map roundNum} roundFractionalNum ∷ Number → Number roundFractionalNum n = roundNum (n * scalar) / scalar diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 7efe29a..3dad480 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,19 +16,22 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, PreNumConf, InputProps, Classes) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, mapInputProps) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import Control.MonadZero (guard) import DOM.Classy.Event (preventDefault) +import Data.Array (index, mapWithIndex) import Data.Either (Either(..), either, isLeft) import Data.Either.Nested as Either -import Data.Foldable (foldMap, for_) +import Data.Foldable (foldMap, foldr, for_) import Data.Functor.Coproduct.Nested as Coproduct +import Data.List as List import Data.Map (Map, insert, lookup) import Data.Maybe (Maybe(..), fromMaybe) import Data.Monoid (mempty) +import Data.Traversable (sequence) import Halogen (liftEff) import Halogen as H import Halogen.Component.ChildPath as CP @@ -43,7 +46,7 @@ import NumberInput.Halogen.Component as Num type ValueProgress a = { current ∷ a, next ∷ a } type State = { color ∷ ValueProgress Color - , inputs ∷ Map String (Either String String) + , inputs ∷ Map Cursor (Either String String) , props ∷ Props } @@ -78,17 +81,19 @@ data Query a = SetProps Props a | DragStart PositionUpdate Drag.CursorEvent a | DragMove PositionUpdate Drag.DragEvent a + -- TODO `ComponentUpdate` could be removed at some point | ComponentUpdate (Color → Maybe Color) a + | NumberComponentUpdate Cursor (Maybe Number) a + | TextComponentUpdate Cursor String a | Commit a | Init a | GetValue (ValueProgress Color → a) | SetValue (ValueProgress Color) a - | UpdateTextInput String String (Maybe Color) a type ChildQuery = Coproduct.Coproduct1 (Num.Query Number) -type Slot = Either.Either1 String +type Slot = Either.Either1 Cursor -cpNumComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery String Slot +cpNumComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery Cursor Slot cpNumComponent = CP.cp1 @@ -112,14 +117,15 @@ picker = H.lifecycleParentComponent } render ∷ ∀ m. State → HTML m -render state@{ color, inputs, props} = renderLayout state props.layout +render state@{ color, inputs, props} = renderLayout state List.Nil props.layout -renderLayout ∷ ∀ m. State → L.Layout → HTML m -renderLayout state@{ color, inputs, props} = case _ of + +renderLayout ∷ ∀ m. State → Cursor → L.Layout → HTML m +renderLayout state@{ color, inputs, props} cursor = case _ of L.Group classes l → HH.div [ HP.classes classes ] - $ map (renderLayout state) l + $ mapWithIndex (\idx → renderLayout state (List.Cons idx cursor)) l L.Actions → HH.div [ HP.classes $ props `classesFor` Actions ] @@ -147,13 +153,13 @@ renderLayout state@{ color, inputs, props} = case _ of ] [] ] - L.Component c → renderColorComponent state c + L.Component c → renderColorComponent state cursor c where hsv = Color.toHSVA $ color.next colorEnv = calcColorEnv color.next - renderColorComponent ∷ State → ColorComponent → HTML m - renderColorComponent { inputs, props } = case _ of + renderColorComponent ∷ State → Cursor → ColorComponent → HTML m + renderColorComponent { inputs, props } cursor = case _ of DragComponentSpec spec → let root = spec.root colorEnv @@ -171,49 +177,66 @@ renderLayout state@{ color, inputs, props} = case _ of ] [] ] - NumberComponentSpec { classes, key, hasNumVal, update, config } → - input classes config.prefix + NumberComponentSpec { styles, hasNumVal, update, config } → let computedStyles = mapInputProps (_ $ colorEnv) styles in + input computedStyles config.prefix $ pure - $ HH.slot' cpNumComponent key (Num.input hasNumVal (mkNumConf classes config)) unit - $ HE.input \(Num.NotifyChange val) → ComponentUpdate $ \color → update <$> val >>= (_ $ colorEnv) - TextComponentSpec { classes, fromString, key, config } → - input classes config.prefix $ flip foldMap (lookup key inputs) \val → pure $ HH.input + $ HH.slot' + cpNumComponent + cursor + Num.input + { title: config.title + , hasNumberValue: hasNumVal + , placeholder: config.placeholder + , range: config.range + , root: computedStyles.elem.classes + , rootInvalid: computedStyles.elemInvalid.classes + , rootLength: const [] + } + $ HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val + TextComponentSpec { styles, fromString, config } → let computedStyles = mapInputProps (_ $ colorEnv) styles in + input computedStyles config.prefix + $ flip foldMap (lookup cursor inputs) \val → pure + $ HH.input [ HP.type_ HP.InputText , HP.classes - $ classes.elem - <> (guard (isLeft val) *> (classes.elemInvalid)) + $ computedStyles.elem.classes + <> (guard (isLeft val) *> (computedStyles.elemInvalid.classes)) , HP.title config.title , HP.placeholder config.placeholder , HP.value $ either id id val - , HE.onValueInput $ HE.input $ \ str → UpdateTextInput key str (fromString str) + , HE.onValueInput $ HE.input $ TextComponentUpdate cursor ] where - input classes label child = - HH.label [HP.classes classes.root] $ - [ HH.span [HP.classes classes.label] [HH.text label]] <> child + input styles label child = + HH.label [HP.classes styles.root.classes] $ + [ HH.span [HP.classes styles.label.classes] [HH.text label]] <> child colorClasses ∷ Props → Color → Array HH.ClassName colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark -mkNumConf ∷ InputProps Classes → PreNumConf → Num.Config Number -mkNumConf {elem, elemInvalid} { title, placeholder, range } = - { title - , placeholder - , range - , root: elem - , rootInvalid: elemInvalid - , rootLength: const [] - } eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m eval = case _ of - UpdateTextInput key str color next → do - let - val = case color of - Nothing → Left str - Just _ → Right str - H.modify \s → s { inputs = insert key val s.inputs } - eval $ ComponentUpdate (const color) next + TextComponentUpdate cursor str next → do + {props} ← H.get + case focus cursor props.layout of + Just (L.Component (TextComponentSpec { fromString })) → do + let + color = fromString str + val = case color of + Nothing → Left str + Just _ → Right str + H.modify \s → s { inputs = insert cursor val s.inputs } + eval $ ComponentUpdate (const color) next + _ → pure next + NumberComponentUpdate cursor num next → do + { color, props } ← H.get + case focus cursor props.layout of + Just (L.Component (NumberComponentSpec { update })) → eval $ + ComponentUpdate + (\_ → update <$> num >>= (_ $ calcColorEnv color.next)) + next + _ → pure next SetValue val next → do state ← H.get H.put $ state{ color = val } @@ -272,21 +295,31 @@ propagate = do propagateLayout color (calcColorEnv color.next) + List.Nil layout where -- TODO at this point `color` arg can be removed - propagateLayout ∷ ValueProgress Color → ColorEnv → L.Layout → DSL m Unit - propagateLayout color colorEnv = case _ of - L.Group _ l → for_ l (propagateLayout color colorEnv) + propagateLayout ∷ ValueProgress Color → ColorEnv → Cursor → L.Layout → DSL m Unit + propagateLayout color colorEnv cursor = case _ of + L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateLayout color colorEnv (List.Cons idx cursor)) l L.Stage → pure unit L.Actions → pure unit L.Component c → case c of DragComponentSpec _ → pure unit - TextComponentSpec { key, toString } → - H.modify \s → s { inputs = insert key (Right $ toString colorEnv) s.inputs } - NumberComponentSpec {key, read} → - H.query' cpNumComponent key (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted + TextComponentSpec { toString } → + H.modify \s → s { inputs = insert cursor (Right $ toString colorEnv) s.inputs } + NumberComponentSpec { read} → + H.query' cpNumComponent cursor (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a mustBeMounted (Just x) = pure x mustBeMounted _ = halt "children must be mounted" + +type Cursor = List.List Int + +focus :: Cursor → L.Layout → Maybe L.Layout +focus cursor layout = foldr f (Just layout) cursor + where + f idx = case _ of + Just (L.Group _ l) → index l idx + _ → Nothing From 86b8da17876b0da156156047a84a8498f26cdae8 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 14 Aug 2017 14:13:16 +0200 Subject: [PATCH 32/72] update todos --- src/ColorPicker/Halogen/ColorComponents.purs | 2 ++ src/ColorPicker/Halogen/Component.purs | 18 ++++++++++++------ src/ColorPicker/Halogen/Layout.purs | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 7e03b73..346f9df 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -49,6 +49,7 @@ type Dynamic s = ColorEnv → s type Classes = Array ClassName +-- TODO make sure all css and classes are used properly (hint: number input) type Styles = { classes ∷ Classes , css ∷ CSS @@ -58,6 +59,7 @@ type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } +-- TODO add Lazy type ColorEnv = { hsl ∷ RecordHSLA , hsv ∷ RecordHSVA diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 3dad480..725f2cb 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -46,7 +46,7 @@ import NumberInput.Halogen.Component as Num type ValueProgress a = { current ∷ a, next ∷ a } type State = { color ∷ ValueProgress Color - , inputs ∷ Map Cursor (Either String String) + , inputs ∷ Map Cursor (Either String String) -- Left is invalid, Right is valid , props ∷ Props } @@ -160,6 +160,14 @@ renderLayout state@{ color, inputs, props} cursor = case _ of colorEnv = calcColorEnv color.next renderColorComponent ∷ State → Cursor → ColorComponent → HTML m renderColorComponent { inputs, props } cursor = case _ of + -- TODO refactor so spec is just a function of type + -- ∷ ∀ p r i + -- . ColorEnv + -- → IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) i + -- → Array (HTML p i) + -- + -- we can make other specs in the same fession instead + -- off caryng around multipe env -> style functions DragComponentSpec spec → let root = spec.root colorEnv @@ -293,15 +301,13 @@ propagate ∷ ∀ m. DSL m Unit propagate = do { color, props: { layout }} ← H.get propagateLayout - color (calcColorEnv color.next) List.Nil layout where - -- TODO at this point `color` arg can be removed - propagateLayout ∷ ValueProgress Color → ColorEnv → Cursor → L.Layout → DSL m Unit - propagateLayout color colorEnv cursor = case _ of - L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateLayout color colorEnv (List.Cons idx cursor)) l + propagateLayout ∷ ColorEnv → Cursor → L.Layout → DSL m Unit + propagateLayout colorEnv cursor = case _ of + L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateLayout colorEnv (List.Cons idx cursor)) l L.Stage → pure unit L.Actions → pure unit L.Component c → case c of diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 4906fef..bce95ad 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -7,5 +7,6 @@ import Halogen (ClassName) data Layout = Group (Array ClassName) (Array Layout) | Component ColorComponent + -- TODO remove this Stage and Actions variants they could be expressed using some ButtonComponents | Stage | Actions From f14ad3c2c202face8d7f8ae0da0c86d1ca56d53e Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 14 Aug 2017 15:19:46 +0200 Subject: [PATCH 33/72] remove fromString lookup on text component as text in just a node (not embeded component, like number) we don't need cursor staff and can just attache `fromString` function to query --- src/ColorPicker/Halogen/Component.purs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 725f2cb..9b64e0d 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -84,7 +84,7 @@ data Query a -- TODO `ComponentUpdate` could be removed at some point | ComponentUpdate (Color → Maybe Color) a | NumberComponentUpdate Cursor (Maybe Number) a - | TextComponentUpdate Cursor String a + | TextComponentUpdate Cursor (String → Maybe Color) String a | Commit a | Init a | GetValue (ValueProgress Color → a) @@ -212,7 +212,7 @@ renderLayout state@{ color, inputs, props} cursor = case _ of , HP.title config.title , HP.placeholder config.placeholder , HP.value $ either id id val - , HE.onValueInput $ HE.input $ TextComponentUpdate cursor + , HE.onValueInput $ HE.input $ TextComponentUpdate cursor fromString ] where input styles label child = @@ -225,18 +225,15 @@ colorClasses props c = classesFor props $ if Color.isLight c then IsLight else I eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m eval = case _ of - TextComponentUpdate cursor str next → do + TextComponentUpdate cursor fromString str next → do {props} ← H.get - case focus cursor props.layout of - Just (L.Component (TextComponentSpec { fromString })) → do - let - color = fromString str - val = case color of - Nothing → Left str - Just _ → Right str - H.modify \s → s { inputs = insert cursor val s.inputs } - eval $ ComponentUpdate (const color) next - _ → pure next + let + color = fromString str + val = case color of + Nothing → Left str + Just _ → Right str + H.modify \s → s { inputs = insert cursor val s.inputs } + eval $ ComponentUpdate (const color) next NumberComponentUpdate cursor num next → do { color, props } ← H.get case focus cursor props.layout of From e27c4c5842e5b20d846cb79400a4658e49c663c6 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Tue, 15 Aug 2017 18:52:45 +0200 Subject: [PATCH 34/72] WIP view function --- src/ColorPicker/Halogen/ColorComponents.purs | 83 +++++++++++++------- src/ColorPicker/Halogen/Component.purs | 52 +++++++----- 2 files changed, 89 insertions(+), 46 deletions(-) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 346f9df..a0ea9a3 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -27,6 +27,10 @@ module ColorPicker.Halogen.ColorComponents , componentDragSV , mapInputProps , toDynamicStyles + , DragComponentView(..) + , DragComponentViewX + , mkDragComponentViewX + , unDragComponentViewX ) where import Prelude @@ -35,13 +39,18 @@ import CSS (CSS) import CSS as CSS import Color (Color) import Color as Color +import DOM.Event.Types (MouseEvent, TouchEvent) import Data.Int (floor, toNumber) import Data.Maybe (Maybe(..)) import Data.String as String import Halogen (ClassName) +import Halogen.HTML as HH +import Halogen.HTML.CSS as HCSS +import Halogen.HTML.Properties as HP import Math (round) import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) +import Unsafe.Coerce (unsafeCoerce) type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color @@ -91,12 +100,29 @@ data ColorComponent , styles ∷ InputProps (Dynamic Styles) } | DragComponentSpec - { root ∷ Dynamic Styles - , selector ∷ Dynamic Styles - , update ∷ PositionUpdate + { update ∷ PositionUpdate + , view ∷ DragComponentViewX } +-- generalise to some View type parametrised by required rows +data DragComponentView + = DragComponentView + ( ∀ r + . ColorEnv + → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) Void) + → HH.HTML Void Void) + + +foreign import data DragComponentViewX :: Type + +mkDragComponentViewX :: forall r. DragComponentView -> DragComponentViewX +mkDragComponentViewX = unsafeCoerce + +unDragComponentViewX :: forall a. (DragComponentView -> a) -> DragComponentViewX -> a +unDragComponentViewX = unsafeCoerce + + componentDragSV ∷ { isLight ∷ Array ClassName , isDark ∷ Array ClassName @@ -105,21 +131,23 @@ componentDragSV ∷ } → ColorComponent componentDragSV classes = DragComponentSpec - { update : \{x, y} {color} → - let hsv = Color.toHSVA color - in Color.hsv hsv.h x (1.0 - y) - , root: \{isLight, hsv} → - { classes: classes.root <> if isLight then classes.isLight else classes.isDark - , css: CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 + { update: \{x, y} {hsv} → Color.hsv hsv.h x (1.0 - y) + , view: mkDragComponentViewX $ DragComponentView \{isLight, hsv, color} props -> + HH.div + ([ HP.classes $ classes.root <> if isLight then classes.isLight else classes.isDark + , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 + ] <> props) -- TODO error here + [ HH.div + [ HP.classes classes.selector + , HCSS.style do + CSS.left $ CSS.pct (hsv.s * 100.0) + CSS.bottom $ CSS.pct (hsv.v * 100.0) + CSS.backgroundColor color + ] + [] + ] } - , selector: \{hsv, color} → - { classes: classes.selector - , css: do - CSS.left $ CSS.pct (hsv.s * 100.0) - CSS.bottom $ CSS.pct (hsv.v * 100.0) - CSS.backgroundColor color - } - } + componentDragHue ∷ { root ∷ Array ClassName @@ -127,18 +155,17 @@ componentDragHue ∷ } → ColorComponent componentDragHue classes = DragComponentSpec - { update : \{y} {color} → - let hsl = Color.toHSLA $ color - in (Color.hsl ((1.0 - y) * 360.0) hsl.s hsl.l) - , root: \_ → - { classes: classes.root - , css: pure unit + { update: \{y} {hsl} → Color.hsl ((1.0 - y) * 360.0) hsl.s hsl.l + , view: mkDragComponentViewX $ DragComponentView \{isLight, hsv, color} props -> + HH.div + ([ HP.classes classes.root ] <> props) + [ HH.div + [ HP.classes classes.selector + , HCSS.style $ CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) + ] + [] + ] } - , selector: \{hsv} → - { classes: classes.selector - , css: CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) - } - } componentHue ∷ InputProps Classes → ColorComponent componentHue classes = NumberComponentSpec diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 9b64e0d..cb6b437 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,13 +16,15 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, mapInputProps) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, mapInputProps, DragComponentView(..), DragComponentViewX, unDragComponentViewX) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import Control.MonadZero (guard) import DOM.Classy.Event (preventDefault) +import DOM.Event.Types (MouseEvent, TouchEvent) import Data.Array (index, mapWithIndex) +import Data.Bifunctor (bimap) import Data.Either (Either(..), either, isLeft) import Data.Either.Nested as Either import Data.Foldable (foldMap, foldr, for_) @@ -168,23 +170,7 @@ renderLayout state@{ color, inputs, props} cursor = case _ of -- -- we can make other specs in the same fession instead -- off caryng around multipe env -> style functions - DragComponentSpec spec → - let - root = spec.root colorEnv - selector = spec.selector colorEnv - in - HH.div - [ HP.classes root.classes - , HCSS.style $ root.css - , HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) - , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) - ] - [ HH.div - [ HP.classes $ selector.classes - , HCSS.style $ selector.css - ] - [] - ] + DragComponentSpec spec → renderDrag colorEnv spec NumberComponentSpec { styles, hasNumVal, update, config } → let computedStyles = mapInputProps (_ $ colorEnv) styles in input computedStyles config.prefix $ pure @@ -326,3 +312,33 @@ focus cursor layout = foldr f (Just layout) cursor f idx = case _ of Just (L.Group _ l) → index l idx _ → Nothing + +props :: forall r. + PositionUpdate -> Array + (HH.IProp + ( onMouseDown :: MouseEvent + , onTouchStart :: TouchEvent + | r + ) + (Query Unit) + ) +props update = + [ HE.onMouseDown $ HE.input (Left >>> DragStart update) + , HE.onTouchStart $ HE.input (Right >>> DragStart update) + ] + +renderDrag + ∷ ∀ m q + . ColorEnv + → { update ∷ PositionUpdate + , view ∷ DragComponentViewX + } + → HTML m +renderDrag colorEnv spec = unDragComponentViewX (\(DragComponentView f) -> bimap absurd absurd $ f colorEnv []) spec.view + + +-- funcMM :: ∀ r i p +-- . DragComponentViewX +-- → DragComponentView r i p +-- -- funcMM view = unDragComponentViewX (\(DragComponentView x) -> DragComponentView x) view +-- funcMM view = From a8aab815be553a8b417d6a9cbb63404d3b73864c Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Tue, 15 Aug 2017 21:20:08 +0200 Subject: [PATCH 35/72] compiles but not responding --- example/src/Main.purs | 34 ++- src/ColorPicker/Halogen/ColorComponents.purs | 220 +++++++++++-------- src/ColorPicker/Halogen/Component.purs | 135 ++++++------ 3 files changed, 215 insertions(+), 174 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index c371efb..43b94ba 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -3,7 +3,6 @@ module Main where import Prelude import Color (Color, rgb) -import ColorPicker.Halogen.ColorComponents (toDynamicStyles) import ColorPicker.Halogen.ColorComponents as C import ColorPicker.Halogen.Component as CPicker import ColorPicker.Halogen.Layout as L @@ -57,7 +56,7 @@ render ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => State → HTML m render state = HH.div_ $ renderPicker 0 config0 <> renderPicker 1 config1 - <> renderPicker 2 config2 + -- <> renderPicker 2 config2 where renderPicker idx conf = @@ -95,22 +94,21 @@ config1 = mkConf id , C.componentRGB <> [C.componentHEX] ] -config2 ∷ CPicker.Props -config2 = mkConf id - (ClassName "ColorPicker--small") - [ [ const componentRedORNoRed ]] - -componentRedORNoRed ∷ C.ColorComponent -componentRedORNoRed = C.TextComponentSpec - { styles: toDynamicStyles inputClasses - , fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing - , toString: \{color} → if color == (rgb 255 0 0) then "red" else "nored" - , config: - { title: "red or nored?" - , prefix: "🛑" - , placeholder: "red" - } - } +-- config2 ∷ CPicker.Props +-- config2 = mkConf id +-- (ClassName "ColorPicker--small") +-- [ [ const componentRedORNoRed ]] + +-- componentRedORNoRed ∷ C.ColorComponent +-- componentRedORNoRed = C.textComponent +-- { fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing +-- , toString: \{color} → if color == (rgb 255 0 0) then "red" else "nored" +-- , config: +-- { title: "red or nored?" +-- , prefix: "🛑" +-- , placeholder: "red" +-- } +-- } mkConf ∷ (∀ a. Array a → Array a) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index a0ea9a3..88537f3 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -26,11 +26,12 @@ module ColorPicker.Halogen.ColorComponents , componentDragHue , componentDragSV , mapInputProps - , toDynamicStyles + , ExistsRow , DragComponentView(..) - , DragComponentViewX - , mkDragComponentViewX - , unDragComponentViewX + , mkExistsRow + , runExistsRow + , TextComponentView(..) + , NumberComponentView(..) ) where import Prelude @@ -39,9 +40,12 @@ import CSS (CSS) import CSS as CSS import Color (Color) import Color as Color -import DOM.Event.Types (MouseEvent, TouchEvent) +import Control.MonadZero (guard) +import DOM.Event.Types (Event, MouseEvent, TouchEvent) +import Data.Either (Either, either, isLeft) import Data.Int (floor, toNumber) import Data.Maybe (Maybe(..)) +import Data.Newtype (class Newtype) import Data.String as String import Halogen (ClassName) import Halogen.HTML as HH @@ -87,41 +91,50 @@ type InputProps c = data ColorComponent = NumberComponentSpec - { hasNumVal ∷ Num.HasNumberInputValue Number - , update ∷ Number → Dynamic (Maybe Color) + { update ∷ Number → Dynamic (Maybe Color) , read ∷ Dynamic Number - , config ∷ PreNumConf - , styles ∷ InputProps (Dynamic Styles) + , props ∷ Num.Props Number + , view ∷ NumberComponentView } | TextComponentSpec { fromString ∷ String → Maybe Color - , toString ∷ Dynamic String - , config ∷ PreTextConf - , styles ∷ InputProps (Dynamic Styles) + , toString ∷ Dynamic String -- TODO remove to as in view we already ahve ColorEnv + , view ∷ ExistsRow TextComponentView } | DragComponentSpec { update ∷ PositionUpdate - , view ∷ DragComponentViewX + , view ∷ ExistsRow DragComponentView } --- generalise to some View type parametrised by required rows -data DragComponentView - = DragComponentView - ( ∀ r - . ColorEnv +newtype NumberComponentView = NumberComponentView + ( ColorEnv + → HH.HTML Void Void + → HH.HTML Void Void) + +derive instance numberComponentViewNewType :: Newtype NumberComponentView _ + +newtype TextComponentView r = TextComponentView + ( ColorEnv + → Either String String -- TODO update to Maybe String (for invlaid strings) + → Array (HH.IProp (value :: String, onInput :: Event | r) Void) + → HH.HTML Void Void) + +newtype DragComponentView r = DragComponentView + ( ColorEnv → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) Void) → HH.HTML Void Void) -foreign import data DragComponentViewX :: Type -mkDragComponentViewX :: forall r. DragComponentView -> DragComponentViewX -mkDragComponentViewX = unsafeCoerce -unDragComponentViewX :: forall a. (DragComponentView -> a) -> DragComponentViewX -> a -unDragComponentViewX = unsafeCoerce +foreign import data ExistsRow :: (# Type -> Type) -> Type + +mkExistsRow :: ∀ f r. f r -> ExistsRow f +mkExistsRow = unsafeCoerce +runExistsRow :: ∀ f a. (∀ r. f r -> a) -> ExistsRow f -> a +runExistsRow = unsafeCoerce componentDragSV ∷ { isLight ∷ Array ClassName @@ -132,7 +145,7 @@ componentDragSV ∷ → ColorComponent componentDragSV classes = DragComponentSpec { update: \{x, y} {hsv} → Color.hsv hsv.h x (1.0 - y) - , view: mkDragComponentViewX $ DragComponentView \{isLight, hsv, color} props -> + , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> HH.div ([ HP.classes $ classes.root <> if isLight then classes.isLight else classes.isDark , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 @@ -156,7 +169,7 @@ componentDragHue ∷ → ColorComponent componentDragHue classes = DragComponentSpec { update: \{y} {hsl} → Color.hsl ((1.0 - y) * 360.0) hsl.s hsl.l - , view: mkDragComponentViewX $ DragComponentView \{isLight, hsv, color} props -> + , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> HH.div ([ HP.classes classes.root ] <> props) [ HH.div @@ -167,42 +180,61 @@ componentDragHue classes = DragComponentSpec ] } -componentHue ∷ InputProps Classes → ColorComponent -componentHue classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValRound - , update: \n {color} → Just $ modifyHSL (_{h = n}) color - , read: \({rgb, hsv, hsl}) → roundFractionalNum hsl.h - , config: confHue +mkNumComponent + :: (Number -> Dynamic (Maybe Color)) + -> Dynamic Number + -> InputProps Classes + -> PreNumConf + -> ColorComponent +mkNumComponent update read classes conf = NumberComponentSpec + { update + , read + , props: + { title: conf.title + , hasNumberValue: hasValRound + , placeholder: conf.placeholder + , range: conf.range + , root: classes.elem + , rootInvalid: classes.elemInvalid + , rootLength: const [] + } + , view: NumberComponentView \ {} input -> renderInput + { root: classes.root + , label: classes.label + , prefix: conf.prefix + , child: input + } } +componentHue ∷ InputProps Classes → ColorComponent +componentHue classes = mkNumComponent + (\n {color} → Just $ modifyHSL (_{h = n}) color) + (\({rgb, hsv, hsl}) → roundFractionalNum hsl.h) + classes + confHue + + componentSaturationHSL ∷ InputProps Classes → ColorComponent -componentSaturationHSL classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValRound - , update: \n {color} → Just $ modifyHSL (_{s = n / 100.0}) color - , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s - , config: confSaturation - } +componentSaturationHSL classes = mkNumComponent + (\n {color} → Just $ modifyHSL (_{s = n / 100.0}) color) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s) + classes + confSaturation componentLightness ∷ InputProps Classes → ColorComponent -componentLightness classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValRound - , update: \n {color} → Just $ modifyHSL (_{l = n / 100.0}) color - , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l - , config: confLightness - } +componentLightness classes = mkNumComponent + (\n {color} → Just $ modifyHSL (_{l = n / 100.0}) color) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l) + classes + confLightness componentSaturationHSV ∷ InputProps Classes → ColorComponent -componentSaturationHSV classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValRound - , update: \n {color} → Just $ modifyHSV (_{s = n / 100.0}) color - , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s - , config: confSaturation - } +componentSaturationHSV classes = mkNumComponent + (\n {color} → Just $ modifyHSV (_{s = n / 100.0}) color) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s) + classes + confSaturation mapInputProps :: ∀ a b. (a -> b) -> InputProps a -> InputProps b mapInputProps f { root, label, elem, elemInvalid } = @@ -216,53 +248,67 @@ toDynamicStyles :: InputProps Classes -> InputProps (Dynamic Styles) toDynamicStyles = mapInputProps $ { classes: _, css: pure unit } >>> const componentValue ∷ InputProps Classes → ColorComponent -componentValue classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValRound - , update: \n {color} → Just $ modifyHSV (_{v = n / 100.0}) color - , read: \({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v - , config: confValue - } +componentValue classes = mkNumComponent + (\n {color} → Just $ modifyHSV (_{v = n / 100.0}) color) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v) + classes + confValue componentRed ∷ InputProps Classes → ColorComponent -componentRed classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValCail - , update: \n {color} → Just $ modifyRGB (_{r = asInt n}) color - , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r - , config: confRed - } +componentRed classes = mkNumComponent + (\n {color} → Just $ modifyRGB (_{r = asInt n}) color) + (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r) + classes + confRed componentGreen ∷ InputProps Classes → ColorComponent -componentGreen classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValCail - , update: \n {color} → Just $ modifyRGB (_{g = asInt n}) color - , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g - , config: confGreen - } +componentGreen classes = mkNumComponent + (\n {color} → Just $ modifyRGB (_{g = asInt n}) color) + (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g) + classes + confGreen componentBlue ∷ InputProps Classes → ColorComponent -componentBlue classes = NumberComponentSpec - { styles: toDynamicStyles classes - , hasNumVal: hasValCail - , update: \n {color} → Just $ modifyRGB (_{b = asInt n}) color - , read: \({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b - , config: confBlue - } +componentBlue classes = mkNumComponent + (\n {color} → Just $ modifyRGB (_{b = asInt n}) color) + (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b) + classes + confBlue componentHEX ∷ InputProps Classes → ColorComponent componentHEX classes = TextComponentSpec - { styles: toDynamicStyles classes - , fromString: \str → Color.fromHexString $ "#" <> str + { fromString: \str → Color.fromHexString $ "#" <> str , toString: \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color - , config: - { prefix: "#" - , title: "Hex" - , placeholder: "HEX" + , view: mkExistsRow $ TextComponentView \env val props -> renderInput + { root: classes.root + , label: classes.label + , prefix: "#" + , child: HH.input $ + [ HP.type_ HP.InputText + , HP.classes + $ classes.elem + <> (guard (isLeft val) *> (classes.elemInvalid)) + , HP.title "Hex" + , HP.value $ either id id val + , HP.placeholder "Hex" + ] <> props } } +renderInput :: ∀ i p. + { child :: HH.HTML i p + , prefix :: String + , label :: Classes + , root :: Classes + } + -> HH.HTML i p +renderInput {root, label, prefix, child} = + HH.label + [ HP.classes root] + [ HH.span [HP.classes label] [HH.text prefix] + , child + ] + componentSL ∷ Array (InputProps Classes → ColorComponent) componentSL = [componentSaturationHSL, componentLightness] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index cb6b437..fdf8f5c 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,11 +16,10 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, mapInputProps, DragComponentView(..), DragComponentViewX, unDragComponentViewX) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, mapInputProps, DragComponentView(..), TextComponentView(..), runExistsRow) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) -import Control.MonadZero (guard) import DOM.Classy.Event (preventDefault) import DOM.Event.Types (MouseEvent, TouchEvent) import Data.Array (index, mapWithIndex) @@ -31,8 +30,9 @@ import Data.Foldable (foldMap, foldr, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.List as List import Data.Map (Map, insert, lookup) -import Data.Maybe (Maybe(..), fromMaybe) +import Data.Maybe (Maybe(..), fromMaybe, maybe) import Data.Monoid (mempty) +import Data.Newtype (unwrap) import Data.Traversable (sequence) import Halogen (liftEff) import Halogen as H @@ -43,6 +43,7 @@ import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Halogen.Query.HalogenM (halt) import NumberInput.Halogen.Component as Num +import Unsafe.Coerce (unsafeCoerce) type ValueProgress a = { current ∷ a, next ∷ a } @@ -162,48 +163,32 @@ renderLayout state@{ color, inputs, props} cursor = case _ of colorEnv = calcColorEnv color.next renderColorComponent ∷ State → Cursor → ColorComponent → HTML m renderColorComponent { inputs, props } cursor = case _ of - -- TODO refactor so spec is just a function of type - -- ∷ ∀ p r i - -- . ColorEnv - -- → IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) i - -- → Array (HTML p i) - -- - -- we can make other specs in the same fession instead - -- off caryng around multipe env -> style functions - DragComponentSpec spec → renderDrag colorEnv spec - NumberComponentSpec { styles, hasNumVal, update, config } → let computedStyles = mapInputProps (_ $ colorEnv) styles in - input computedStyles config.prefix - $ pure + DragComponentSpec spec → + let + run :: ∀ r. DragComponentView r -> HTML m + run (DragComponentView view) = unHTML $ view colorEnv $ mkProps + [ HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) + , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) + ] + in runExistsRow run spec.view + NumberComponentSpec spec → + unHTML + $ unwrap spec.view colorEnv + $ mkHTML $ HH.slot' cpNumComponent cursor Num.input - { title: config.title - , hasNumberValue: hasNumVal - , placeholder: config.placeholder - , range: config.range - , root: computedStyles.elem.classes - , rootInvalid: computedStyles.elemInvalid.classes - , rootLength: const [] - } + spec.props $ HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val - TextComponentSpec { styles, fromString, config } → let computedStyles = mapInputProps (_ $ colorEnv) styles in - input computedStyles config.prefix - $ flip foldMap (lookup cursor inputs) \val → pure - $ HH.input - [ HP.type_ HP.InputText - , HP.classes - $ computedStyles.elem.classes - <> (guard (isLeft val) *> (computedStyles.elemInvalid.classes)) - , HP.title config.title - , HP.placeholder config.placeholder - , HP.value $ either id id val - , HE.onValueInput $ HE.input $ TextComponentUpdate cursor fromString - ] - where - input styles label child = - HH.label [HP.classes styles.root.classes] $ - [ HH.span [HP.classes styles.label.classes] [HH.text label]] <> child + TextComponentSpec spec → + let + run :: ∀ r. TextComponentView r -> HTML m + run (TextComponentView view) = bimap absurd absurd $ view colorEnv val $ mkProps + [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString ] + val :: Either String String + val = maybe (Right $ spec.toString colorEnv) id $ lookup cursor inputs + in runExistsRow run spec.view colorClasses ∷ Props → Color → Array HH.ClassName colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark @@ -313,32 +298,44 @@ focus cursor layout = foldr f (Just layout) cursor Just (L.Group _ l) → index l idx _ → Nothing -props :: forall r. - PositionUpdate -> Array - (HH.IProp - ( onMouseDown :: MouseEvent - , onTouchStart :: TouchEvent - | r - ) - (Query Unit) - ) -props update = - [ HE.onMouseDown $ HE.input (Left >>> DragStart update) - , HE.onTouchStart $ HE.input (Right >>> DragStart update) - ] - -renderDrag - ∷ ∀ m q - . ColorEnv - → { update ∷ PositionUpdate - , view ∷ DragComponentViewX - } - → HTML m -renderDrag colorEnv spec = unDragComponentViewX (\(DragComponentView f) -> bimap absurd absurd $ f colorEnv []) spec.view - - --- funcMM :: ∀ r i p --- . DragComponentViewX --- → DragComponentView r i p --- -- funcMM view = unDragComponentViewX (\(DragComponentView x) -> DragComponentView x) view --- funcMM view = +mkHTML + ∷ ∀ p i + . HH.HTML p i + → HH.HTML Void Void +mkHTML = unsafeCoerce + +unHTML + ∷ ∀ p i + . HH.HTML Void Void + -> HH.HTML p i +unHTML = bimap absurd absurd + + +mkProps + ∷ ∀ r + . Array (HH.IProp r (Query Unit)) + → Array (HH.IProp r Void) +mkProps = unsafeCoerce + +{-- error without unsafeCoerce +Could not match type + +Query Unit + +with type + +Void + +while trying to match type IProp + ( onMouseDown :: MouseEvent + | t1 + ) + t2 +with type IProp + ( onMouseDown :: MouseEvent + , onTouchStart :: TouchEvent + | t0 + ) + Void + +--} From 932f58adac0e9b8c46e198450f33900afcc202a9 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Wed, 16 Aug 2017 22:26:43 +0100 Subject: [PATCH 36/72] This seems to work --- src/ColorPicker/Halogen/ColorComponents.purs | 30 ++++----- src/ColorPicker/Halogen/Component.purs | 70 ++++---------------- 2 files changed, 28 insertions(+), 72 deletions(-) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 88537f3..0fa26cb 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -45,7 +45,6 @@ import DOM.Event.Types (Event, MouseEvent, TouchEvent) import Data.Either (Either, either, isLeft) import Data.Int (floor, toNumber) import Data.Maybe (Maybe(..)) -import Data.Newtype (class Newtype) import Data.String as String import Halogen (ClassName) import Halogen.HTML as HH @@ -108,25 +107,26 @@ data ColorComponent newtype NumberComponentView = NumberComponentView - ( ColorEnv - → HH.HTML Void Void - → HH.HTML Void Void) - -derive instance numberComponentViewNewType :: Newtype NumberComponentView _ + ( ∀ p i + . ColorEnv + → HH.HTML p i + → HH.HTML p i + ) newtype TextComponentView r = TextComponentView - ( ColorEnv + ( ∀ p i + . ColorEnv → Either String String -- TODO update to Maybe String (for invlaid strings) - → Array (HH.IProp (value :: String, onInput :: Event | r) Void) - → HH.HTML Void Void) + → Array (HH.IProp (value :: String, onInput :: Event | r) i) + → HH.HTML p i + ) newtype DragComponentView r = DragComponentView - ( ColorEnv - → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) Void) - → HH.HTML Void Void) - - - + ( ∀ p i + . ColorEnv + → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) i) + → HH.HTML p i + ) foreign import data ExistsRow :: (# Type -> Type) -> Type diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index fdf8f5c..62372e1 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,7 +16,7 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, PositionUpdate, mapInputProps, DragComponentView(..), TextComponentView(..), runExistsRow) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, DragComponentView(..), NumberComponentView(..), PositionUpdate, TextComponentView(..), mapInputProps, runExistsRow) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) @@ -32,7 +32,6 @@ import Data.List as List import Data.Map (Map, insert, lookup) import Data.Maybe (Maybe(..), fromMaybe, maybe) import Data.Monoid (mempty) -import Data.Newtype (unwrap) import Data.Traversable (sequence) import Halogen (liftEff) import Halogen as H @@ -43,8 +42,6 @@ import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Halogen.Query.HalogenM (halt) import NumberInput.Halogen.Component as Num -import Unsafe.Coerce (unsafeCoerce) - type ValueProgress a = { current ∷ a, next ∷ a } type State = @@ -166,25 +163,26 @@ renderLayout state@{ color, inputs, props} cursor = case _ of DragComponentSpec spec → let run :: ∀ r. DragComponentView r -> HTML m - run (DragComponentView view) = unHTML $ view colorEnv $ mkProps + run (DragComponentView view) = view colorEnv $ [ HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) ] in runExistsRow run spec.view NumberComponentSpec spec → - unHTML - $ unwrap spec.view colorEnv - $ mkHTML - $ HH.slot' - cpNumComponent - cursor - Num.input - spec.props - $ HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val + let + NumberComponentView view = spec.view + in + view colorEnv $ + HH.slot' + cpNumComponent + cursor + Num.input + spec.props + (HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val) TextComponentSpec spec → let run :: ∀ r. TextComponentView r -> HTML m - run (TextComponentView view) = bimap absurd absurd $ view colorEnv val $ mkProps + run (TextComponentView view) = view colorEnv val $ [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString ] val :: Either String String val = maybe (Right $ spec.toString colorEnv) id $ lookup cursor inputs @@ -297,45 +295,3 @@ focus cursor layout = foldr f (Just layout) cursor f idx = case _ of Just (L.Group _ l) → index l idx _ → Nothing - -mkHTML - ∷ ∀ p i - . HH.HTML p i - → HH.HTML Void Void -mkHTML = unsafeCoerce - -unHTML - ∷ ∀ p i - . HH.HTML Void Void - -> HH.HTML p i -unHTML = bimap absurd absurd - - -mkProps - ∷ ∀ r - . Array (HH.IProp r (Query Unit)) - → Array (HH.IProp r Void) -mkProps = unsafeCoerce - -{-- error without unsafeCoerce -Could not match type - -Query Unit - -with type - -Void - -while trying to match type IProp - ( onMouseDown :: MouseEvent - | t1 - ) - t2 -with type IProp - ( onMouseDown :: MouseEvent - , onTouchStart :: TouchEvent - | t0 - ) - Void - ---} From e1d147f00836b7b8d43848bb6672be5322be88bc Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 17 Aug 2017 20:59:27 +0200 Subject: [PATCH 37/72] update input state handling --- example/src/Main.purs | 50 +++++++++++------ src/ColorPicker/Halogen/ColorComponents.purs | 42 +++++++------- src/ColorPicker/Halogen/Component.purs | 58 ++++++++++---------- 3 files changed, 84 insertions(+), 66 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 43b94ba..a6495e9 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -8,11 +8,12 @@ import ColorPicker.Halogen.Component as CPicker import ColorPicker.Halogen.Layout as L import Control.Monad.Aff.Class (class MonadAff) import Control.Monad.Eff (Eff) +import Control.MonadZero (guard) import Data.Array (reverse) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct import Data.Map (Map, fromFoldable, insert, lookup) -import Data.Maybe (Maybe(..)) +import Data.Maybe (Maybe(..), maybe') import Data.Monoid (mempty) import Data.Tuple (Tuple(..)) import Halogen (ClassName(..)) @@ -21,6 +22,7 @@ import Halogen.Aff as HA import Halogen.Component.ChildPath as CP import Halogen.HTML as HH import Halogen.HTML.Events as HE +import Halogen.HTML.Properties as HP import Halogen.VDom.Driver (runUI) main ∷ Eff (HA.HalogenEffects ()) Unit @@ -56,7 +58,7 @@ render ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => State → HTML m render state = HH.div_ $ renderPicker 0 config0 <> renderPicker 1 config1 - -- <> renderPicker 2 config2 + <> renderPicker 2 config2 where renderPicker idx conf = @@ -94,21 +96,35 @@ config1 = mkConf id , C.componentRGB <> [C.componentHEX] ] --- config2 ∷ CPicker.Props --- config2 = mkConf id --- (ClassName "ColorPicker--small") --- [ [ const componentRedORNoRed ]] - --- componentRedORNoRed ∷ C.ColorComponent --- componentRedORNoRed = C.textComponent --- { fromString: \str → if str == "red" then Just (rgb 255 0 0) else Nothing --- , toString: \{color} → if color == (rgb 255 0 0) then "red" else "nored" --- , config: --- { title: "red or nored?" --- , prefix: "🛑" --- , placeholder: "red" --- } --- } +config2 ∷ CPicker.Props +config2 = mkConf id + (ClassName "ColorPicker--small") + [ [ const componentRedORNoRed ]] + +componentRedORNoRed ∷ C.ColorComponent +componentRedORNoRed = C.TextComponentSpec + { fromString: \str → if str == "red" then Just (red) else Nothing + , view: C.mkExistsRow $ C.TextComponentView \env val props -> + HH.label + [ HP.classes inputClasses.root] + [ HH.span [HP.classes inputClasses.label] [HH.text "🛑"] + , HH.input $ + [ HP.type_ HP.InputText + , HP.classes + $ inputClasses.elem + <> (guard (C.isInvalid val) *> (inputClasses.elemInvalid)) + , HP.title "red or nored?" + , HP.value $ maybe' (\_ -> toString env) _.value val + , HP.placeholder "red" + ] <> props + ] + } + where + red = rgb 255 0 0 + toString = \{color} → if color == red then "red" else "noRed" + + + mkConf ∷ (∀ a. Array a → Array a) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 0fa26cb..ff49a7d 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -1,7 +1,9 @@ module ColorPicker.Halogen.ColorComponents ( ColorComponent(..) + , InputTextValue + , isValid + , isInvalid , Dynamic - , Styles , PreNumConf , PreTextConf , InputProps @@ -36,15 +38,13 @@ module ColorPicker.Halogen.ColorComponents import Prelude -import CSS (CSS) import CSS as CSS import Color (Color) import Color as Color import Control.MonadZero (guard) -import DOM.Event.Types (Event, MouseEvent, TouchEvent) -import Data.Either (Either, either, isLeft) +import DOM.Event.Types (Event, FocusEvent, MouseEvent, TouchEvent) import Data.Int (floor, toNumber) -import Data.Maybe (Maybe(..)) +import Data.Maybe (Maybe(..), isJust, maybe, maybe') import Data.String as String import Halogen (ClassName) import Halogen.HTML as HH @@ -55,18 +55,15 @@ import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) import Unsafe.Coerce (unsafeCoerce) + +type InputTextValue = { value ∷ String, isValid ∷ Boolean } + type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color type Dynamic s = ColorEnv → s type Classes = Array ClassName --- TODO make sure all css and classes are used properly (hint: number input) -type Styles = - { classes ∷ Classes - , css ∷ CSS - } - type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } @@ -97,7 +94,6 @@ data ColorComponent } | TextComponentSpec { fromString ∷ String → Maybe Color - , toString ∷ Dynamic String -- TODO remove to as in view we already ahve ColorEnv , view ∷ ExistsRow TextComponentView } | DragComponentSpec @@ -116,8 +112,8 @@ newtype NumberComponentView = NumberComponentView newtype TextComponentView r = TextComponentView ( ∀ p i . ColorEnv - → Either String String -- TODO update to Maybe String (for invlaid strings) - → Array (HH.IProp (value :: String, onInput :: Event | r) i) + → Maybe InputTextValue + → Array (HH.IProp (value :: String, onInput :: Event, onBlur :: FocusEvent | r) i) → HH.HTML p i ) @@ -149,7 +145,7 @@ componentDragSV classes = DragComponentSpec HH.div ([ HP.classes $ classes.root <> if isLight then classes.isLight else classes.isDark , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 - ] <> props) -- TODO error here + ] <> props) [ HH.div [ HP.classes classes.selector , HCSS.style do @@ -244,8 +240,6 @@ mapInputProps f { root, label, elem, elemInvalid } = , elemInvalid: f elemInvalid } -toDynamicStyles :: InputProps Classes -> InputProps (Dynamic Styles) -toDynamicStyles = mapInputProps $ { classes: _, css: pure unit } >>> const componentValue ∷ InputProps Classes → ColorComponent componentValue classes = mkNumComponent @@ -278,7 +272,6 @@ componentBlue classes = mkNumComponent componentHEX ∷ InputProps Classes → ColorComponent componentHEX classes = TextComponentSpec { fromString: \str → Color.fromHexString $ "#" <> str - , toString: \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color , view: mkExistsRow $ TextComponentView \env val props -> renderInput { root: classes.root , label: classes.label @@ -287,13 +280,22 @@ componentHEX classes = TextComponentSpec [ HP.type_ HP.InputText , HP.classes $ classes.elem - <> (guard (isLeft val) *> (classes.elemInvalid)) + <> (guard (isInvalid val) *> (classes.elemInvalid)) , HP.title "Hex" - , HP.value $ either id id val + , HP.value $ maybe' (\_ -> toString env) _.value val , HP.placeholder "Hex" ] <> props } } + where + toString = \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color + + +isValid :: Maybe InputTextValue -> Boolean +isValid = maybe true _.isValid + +isInvalid :: Maybe InputTextValue -> Boolean +isInvalid = not isValid renderInput :: ∀ i p. { child :: HH.HTML i p diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 62372e1..3e81dd1 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,21 +16,19 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, DragComponentView(..), NumberComponentView(..), PositionUpdate, TextComponentView(..), mapInputProps, runExistsRow) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, DragComponentView(..), NumberComponentView(..), PositionUpdate, TextComponentView(..), InputTextValue, runExistsRow) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) -import DOM.Event.Types (MouseEvent, TouchEvent) import Data.Array (index, mapWithIndex) -import Data.Bifunctor (bimap) -import Data.Either (Either(..), either, isLeft) +import Data.Either (Either(..), either) import Data.Either.Nested as Either -import Data.Foldable (foldMap, foldr, for_) +import Data.Foldable (foldr, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.List as List import Data.Map (Map, insert, lookup) -import Data.Maybe (Maybe(..), fromMaybe, maybe) +import Data.Maybe (Maybe(..), fromMaybe) import Data.Monoid (mempty) import Data.Traversable (sequence) import Halogen (liftEff) @@ -46,7 +44,7 @@ import NumberInput.Halogen.Component as Num type ValueProgress a = { current ∷ a, next ∷ a } type State = { color ∷ ValueProgress Color - , inputs ∷ Map Cursor (Either String String) -- Left is invalid, Right is valid + , inputValues ∷ Map Cursor InputTextValue , props ∷ Props } @@ -85,6 +83,7 @@ data Query a | ComponentUpdate (Color → Maybe Color) a | NumberComponentUpdate Cursor (Maybe Number) a | TextComponentUpdate Cursor (String → Maybe Color) String a + | TextComponentBlur Cursor a | Commit a | Init a | GetValue (ValueProgress Color → a) @@ -108,7 +107,7 @@ initialColor = Color.hsl 0.0 0.0 0.0 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m picker = H.lifecycleParentComponent - { initialState: { color: { current: initialColor, next: initialColor }, inputs: mempty, props: _ } + { initialState: { color: { current: initialColor, next: initialColor }, inputValues: mempty, props: _ } , render , eval , receiver: HE.input SetProps @@ -117,11 +116,11 @@ picker = H.lifecycleParentComponent } render ∷ ∀ m. State → HTML m -render state@{ color, inputs, props} = renderLayout state List.Nil props.layout +render state = renderLayout state List.Nil state.props.layout renderLayout ∷ ∀ m. State → Cursor → L.Layout → HTML m -renderLayout state@{ color, inputs, props} cursor = case _ of +renderLayout state@{ color, inputValues, props} cursor = case _ of L.Group classes l → HH.div [ HP.classes classes ] @@ -153,13 +152,7 @@ renderLayout state@{ color, inputs, props} cursor = case _ of ] [] ] - L.Component c → renderColorComponent state cursor c - - where - hsv = Color.toHSVA $ color.next - colorEnv = calcColorEnv color.next - renderColorComponent ∷ State → Cursor → ColorComponent → HTML m - renderColorComponent { inputs, props } cursor = case _ of + L.Component c → case c of DragComponentSpec spec → let run :: ∀ r. DragComponentView r -> HTML m @@ -182,11 +175,14 @@ renderLayout state@{ color, inputs, props} cursor = case _ of TextComponentSpec spec → let run :: ∀ r. TextComponentView r -> HTML m - run (TextComponentView view) = view colorEnv val $ - [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString ] - val :: Either String String - val = maybe (Right $ spec.toString colorEnv) id $ lookup cursor inputs + run (TextComponentView view) = view colorEnv + (lookup cursor inputValues) + [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString + , HE.onBlur $ HE.input_ $ TextComponentBlur cursor + ] in runExistsRow run spec.view + where + colorEnv = calcColorEnv color.next colorClasses ∷ Props → Color → Array HH.ClassName colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark @@ -194,14 +190,19 @@ colorClasses props c = classesFor props $ if Color.isLight c then IsLight else I eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m eval = case _ of + TextComponentBlur cursor next → do + state ← H.get + let val = lookup cursor state.inputValues + for_ (lookup cursor state.inputValues) \val -> + when val.isValid $ H.modify _ { inputValues = mempty :: Map Cursor InputTextValue } + pure next TextComponentUpdate cursor fromString str next → do - {props} ← H.get let color = fromString str - val = case color of - Nothing → Left str - Just _ → Right str - H.modify \s → s { inputs = insert cursor val s.inputs } + isValid = case color of + Nothing → false + Just _ → true + H.modify \s → s { inputValues = insert cursor {isValid, value: str} s.inputValues } eval $ ComponentUpdate (const color) next NumberComponentUpdate cursor num next → do { color, props } ← H.get @@ -278,9 +279,8 @@ propagate = do L.Actions → pure unit L.Component c → case c of DragComponentSpec _ → pure unit - TextComponentSpec { toString } → - H.modify \s → s { inputs = insert cursor (Right $ toString colorEnv) s.inputs } - NumberComponentSpec { read} → + TextComponentSpec _ → pure unit + NumberComponentSpec { read } → H.query' cpNumComponent cursor (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a From 53bcc672c73f0a1a86aea38f0ce65ab58e58e778 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 17 Aug 2017 21:46:20 +0200 Subject: [PATCH 38/72] use modify* functions --- src/ColorPicker/Halogen/ColorComponents.purs | 34 ++++++++++---------- src/ColorPicker/Halogen/Component.purs | 5 ++- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index ff49a7d..3835929 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -44,7 +44,7 @@ import Color as Color import Control.MonadZero (guard) import DOM.Event.Types (Event, FocusEvent, MouseEvent, TouchEvent) import Data.Int (floor, toNumber) -import Data.Maybe (Maybe(..), isJust, maybe, maybe') +import Data.Maybe (Maybe(..), maybe, maybe') import Data.String as String import Halogen (ClassName) import Halogen.HTML as HH @@ -140,7 +140,7 @@ componentDragSV ∷ } → ColorComponent componentDragSV classes = DragComponentSpec - { update: \{x, y} {hsv} → Color.hsv hsv.h x (1.0 - y) + { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> HH.div ([ HP.classes $ classes.root <> if isLight then classes.isLight else classes.isDark @@ -164,7 +164,7 @@ componentDragHue ∷ } → ColorComponent componentDragHue classes = DragComponentSpec - { update: \{y} {hsl} → Color.hsl ((1.0 - y) * 360.0) hsl.s hsl.l + { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> HH.div ([ HP.classes classes.root ] <> props) @@ -205,7 +205,7 @@ mkNumComponent update read classes conf = NumberComponentSpec componentHue ∷ InputProps Classes → ColorComponent componentHue classes = mkNumComponent - (\n {color} → Just $ modifyHSL (_{h = n}) color) + (\n → Just <<< modifyHSL (_{h = n})) (\({rgb, hsv, hsl}) → roundFractionalNum hsl.h) classes confHue @@ -213,21 +213,21 @@ componentHue classes = mkNumComponent componentSaturationHSL ∷ InputProps Classes → ColorComponent componentSaturationHSL classes = mkNumComponent - (\n {color} → Just $ modifyHSL (_{s = n / 100.0}) color) + (\n → Just <<< modifyHSL (_{s = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s) classes confSaturation componentLightness ∷ InputProps Classes → ColorComponent componentLightness classes = mkNumComponent - (\n {color} → Just $ modifyHSL (_{l = n / 100.0}) color) + (\n → Just <<< modifyHSL (_{l = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l) classes confLightness componentSaturationHSV ∷ InputProps Classes → ColorComponent componentSaturationHSV classes = mkNumComponent - (\n {color} → Just $ modifyHSV (_{s = n / 100.0}) color) + (\n → Just <<< modifyHSV (_{s = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s) classes confSaturation @@ -243,28 +243,28 @@ mapInputProps f { root, label, elem, elemInvalid } = componentValue ∷ InputProps Classes → ColorComponent componentValue classes = mkNumComponent - (\n {color} → Just $ modifyHSV (_{v = n / 100.0}) color) + (\n → Just <<< modifyHSV (_{v = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v) classes confValue componentRed ∷ InputProps Classes → ColorComponent componentRed classes = mkNumComponent - (\n {color} → Just $ modifyRGB (_{r = asInt n}) color) + (\n → Just <<< modifyRGB (_{r = asInt n})) (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r) classes confRed componentGreen ∷ InputProps Classes → ColorComponent componentGreen classes = mkNumComponent - (\n {color} → Just $ modifyRGB (_{g = asInt n}) color) + (\n → Just <<< modifyRGB (_{g = asInt n})) (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g) classes confGreen componentBlue ∷ InputProps Classes → ColorComponent componentBlue classes = mkNumComponent - (\n {color} → Just $ modifyRGB (_{b = asInt n}) color) + (\n → Just <<< modifyRGB (_{b = asInt n})) (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b) classes confBlue @@ -402,11 +402,11 @@ type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } -modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color → Color -modifyHSL f c = let {h, s, l, a} = f (Color.toHSLA c) in Color.hsla h s l a +modifyHSL ∷ (RecordHSLA → RecordHSLA) → Dynamic Color +modifyHSL f { hsl } = let {h, s, l, a} = f hsl in Color.hsla h s l a -modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color → Color -modifyHSV f c = let {h, s, v, a} = f (Color.toHSVA c) in Color.hsva h s v a +modifyHSV ∷ (RecordHSVA → RecordHSVA) → Dynamic Color +modifyHSV f { hsv } = let {h, s, v, a} = f hsv in Color.hsva h s v a -modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color → Color -modifyRGB f c = let {r, g, b, a} = f (Color.toRGBA c) in Color.rgba r g b a +modifyRGB ∷ (RecordRGBA → RecordRGBA) → Dynamic Color +modifyRGB f { rgb } = let {r, g, b, a} = f rgb in Color.rgba r g b a diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 3e81dd1..fac417e 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -107,7 +107,10 @@ initialColor = Color.hsl 0.0 0.0 0.0 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m picker = H.lifecycleParentComponent - { initialState: { color: { current: initialColor, next: initialColor }, inputValues: mempty, props: _ } + { initialState: + { color: { current: initialColor, next: initialColor } + , inputValues: mempty + , props: _ } , render , eval , receiver: HE.input SetProps From 3503ced272ed3022f8b0286884a2ff14efd24635 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 00:54:11 +0200 Subject: [PATCH 39/72] ValueProgress to ValueHistory --- example/index.html | 29 +++++++---- example/src/Main.purs | 2 +- src/ColorPicker/Halogen/Component.purs | 71 ++++++++++++++------------ 3 files changed, 59 insertions(+), 43 deletions(-) diff --git a/example/index.html b/example/index.html index 585f912..77e99b5 100644 --- a/example/index.html +++ b/example/index.html @@ -82,26 +82,35 @@ .ColorPicker-stage { display: flex; margin: 0.2em; + box-shadow: 0 0 0 1px black inset, 0 0 0 2px white inset; + padding: 1px 2px 1px 1px; } -.ColorPicker-colorBlockNext, -.ColorPicker-colorBlockCurrent { - border-top: 0.1em solid; - border-bottom: 0.1em solid; - flex: 1 1 0%; +.ColorPicker-colorBlockCurrent, +.ColorPicker-colorBlockOld { height: 1.5em; + box-sizing: border-box; } -.ColorPicker-colorBlockNext { - border-left: 0.1em solid; +.ColorPicker-colorBlockCurrent:not(:only-child) { + box-shadow: 0px 0 0 1px black; + margin-right: 1px; + border-right-width: 0.05em; } - .ColorPicker-colorBlockCurrent { - border-right: 0.1em solid; + border: 0.05em solid white; + border-right-width: 0; + flex: 2 1 0%; +} + +.ColorPicker-colorBlockOld { + flex: 1 1 0%; + border-top: 1px solid white; + border-bottom: 1px solid white; cursor: pointer; } -.ColorPicker-colorBlockPrevious:focus { +.ColorPicker-ColorBlockOld:focus { outline: -webkit-focus-ring-color auto 5px; } diff --git a/example/src/Main.purs b/example/src/Main.purs index a6495e9..08c3c19 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -158,7 +158,7 @@ mkConf reverse' root editGroups = , classes: fromFoldable [ Tuple CPicker.Stage [ ClassName "ColorPicker-stage" ] , Tuple CPicker.ColorBlockCurrent [ ClassName "ColorPicker-colorBlockCurrent" ] - , Tuple CPicker.ColorBlockNext [ ClassName "ColorPicker-colorBlockNext" ] + , Tuple CPicker.ColorBlockOld [ ClassName "ColorPicker-colorBlockOld" ] , Tuple CPicker.Actions [ ClassName "ColorPicker-actions" ] , Tuple CPicker.ActionSet [ ClassName "ColorPicker-actionSet" ] , Tuple CPicker.IsLight [ ClassName "IsLight" ] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index fac417e..4cd9b0b 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -1,7 +1,7 @@ module ColorPicker.Halogen.Component ( picker , Query(GetValue, SetValue, Commit) - , ValueProgress + , ValueHistory , Message(..) , Props , ClassGroup(..) @@ -21,7 +21,7 @@ import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) -import Data.Array (index, mapWithIndex) +import Data.Array (head, index, mapWithIndex, nub, take) import Data.Either (Either(..), either) import Data.Either.Nested as Either import Data.Foldable (foldr, for_) @@ -41,9 +41,9 @@ import Halogen.HTML.Properties as HP import Halogen.Query.HalogenM (halt) import NumberInput.Halogen.Component as Num -type ValueProgress a = { current ∷ a, next ∷ a } +type ValueHistory a = { old ∷ Array a, current ∷ a } type State = - { color ∷ ValueProgress Color + { color ∷ ValueHistory Color , inputValues ∷ Map Cursor InputTextValue , props ∷ Props } @@ -60,7 +60,7 @@ classesFor {classes} key = fromMaybe [] $ lookup key classes data ClassGroup = Stage | ColorBlockCurrent - | ColorBlockNext + | ColorBlockOld | Actions | ActionSet | IsLight @@ -86,8 +86,8 @@ data Query a | TextComponentBlur Cursor a | Commit a | Init a - | GetValue (ValueProgress Color → a) - | SetValue (ValueProgress Color) a + | GetValue (ValueHistory Color → a) + | SetValue (ValueHistory Color) a type ChildQuery = Coproduct.Coproduct1 (Num.Query Number) type Slot = Either.Either1 Cursor @@ -108,7 +108,7 @@ initialColor = Color.hsl 0.0 0.0 0.0 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m picker = H.lifecycleParentComponent { initialState: - { color: { current: initialColor, next: initialColor } + { color: { current: initialColor, old: [] } , inputValues: mempty , props: _ } , render @@ -138,23 +138,25 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of [ HH.text "Set" ] ] L.Stage → - HH.div - [ HP.classes $ props `classesFor` Stage ] - [ HH.div - [ HP.classes $ classesFor props ColorBlockNext <> colorClasses props color.next - , HP.title "Next value" - , HCSS.style $ CSS.backgroundColor color.next - ] - [] - , HH.div + let + current = HH.div + [ HP.classes $ classesFor props ColorBlockCurrent <> colorClasses props color.current + , HP.title "Current value" + , HCSS.style $ CSS.backgroundColor color.current + ] [] + + old = take 4 color.old <#> \c -> + HH.div [ HP.tabIndex 0 - , HP.classes $ classesFor props ColorBlockCurrent <> colorClasses props color.current - , HP.title "Current value" - , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just color.current) - , HCSS.style $ CSS.backgroundColor color.current - ] - [] - ] + , HP.classes $ classesFor props ColorBlockOld <> colorClasses props c + , HP.title "Old value" + , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just c) + , HCSS.style $ CSS.backgroundColor c + ] [] + in + HH.div + [ HP.classes $ props `classesFor` Stage ] $ + [ current ] <> old L.Component c → case c of DragComponentSpec spec → let @@ -185,7 +187,7 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of ] in runExistsRow run spec.view where - colorEnv = calcColorEnv color.next + colorEnv = calcColorEnv color.current colorClasses ∷ Props → Color → Array HH.ClassName colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark @@ -212,7 +214,7 @@ eval = case _ of case focus cursor props.layout of Just (L.Component (NumberComponentSpec { update })) → eval $ ComponentUpdate - (\_ → update <$> num >>= (_ $ calcColorEnv color.next)) + (\_ → update <$> num >>= (_ $ calcColorEnv color.current)) next _ → pure next SetValue val next → do @@ -225,12 +227,17 @@ eval = case _ of pure next Commit next → do state ← H.get - H.put $ state{ color {current = state.color.next, next = state.color.next} } - H.raise $ NotifyChange state.color.next + -- TODO disable Commit button if this condition is not true + when (Just state.color.current /= head state.color.old) do + H.put $ state{ color = + { current: state.color.current + , old: nub $ [state.color.current] <> state.color.old + }} + H.raise $ NotifyChange state.color.current pure next ComponentUpdate update next → do state ← H.get - for_ (update state.color.next) $ \color' → do + for_ (update state.color.current) $ \color' → do updateColor state $ color' pure next SetProps props next → do @@ -240,7 +247,7 @@ eval = case _ of case drag of Drag.Move event dragData → do state ← H.get - updateColor state $ update dragData.progress (calcColorEnv state.color.next) + updateColor state $ update dragData.progress (calcColorEnv state.color.current) pure unit Drag.Done event → pure unit pure next @@ -253,7 +260,7 @@ eval = case _ of updateColor ∷ ∀ m. State → Color → DSL m Unit updateColor state colorNext = do - H.put state{ color { next = colorNext } } + H.put state{ color { current = colorNext } } H.raise $ NextChange colorNext propagate @@ -271,7 +278,7 @@ propagate ∷ ∀ m. DSL m Unit propagate = do { color, props: { layout }} ← H.get propagateLayout - (calcColorEnv color.next) + (calcColorEnv color.current) List.Nil layout where From ad0867a6063d1901e636d5049f9d2b6c2bc3bcd1 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 01:16:11 +0200 Subject: [PATCH 40/72] use LazyColor --- example/src/Main.purs | 2 - src/ColorPicker/Halogen/ColorComponents.purs | 68 ++++++++++-------- src/ColorPicker/Halogen/Component.purs | 74 +++++++------------- 3 files changed, 66 insertions(+), 78 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 08c3c19..af14358 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -161,8 +161,6 @@ mkConf reverse' root editGroups = , Tuple CPicker.ColorBlockOld [ ClassName "ColorPicker-colorBlockOld" ] , Tuple CPicker.Actions [ ClassName "ColorPicker-actions" ] , Tuple CPicker.ActionSet [ ClassName "ColorPicker-actionSet" ] - , Tuple CPicker.IsLight [ ClassName "IsLight" ] - , Tuple CPicker.IsDark [ ClassName "IsDark" ] ] } diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 3835929..55b9890 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -12,7 +12,6 @@ module ColorPicker.Halogen.ColorComponents , RecordHSVA , RecordRGBA , PositionUpdate - , ColorEnv , componentHue , componentSaturationHSL , componentLightness @@ -34,6 +33,8 @@ module ColorPicker.Halogen.ColorComponents , runExistsRow , TextComponentView(..) , NumberComponentView(..) + , mkLazyColor + , LazyColor ) where import Prelude @@ -44,6 +45,7 @@ import Color as Color import Control.MonadZero (guard) import DOM.Event.Types (Event, FocusEvent, MouseEvent, TouchEvent) import Data.Int (floor, toNumber) +import Data.Lazy (Lazy, defer, force) import Data.Maybe (Maybe(..), maybe, maybe') import Data.String as String import Halogen (ClassName) @@ -60,7 +62,7 @@ type InputTextValue = { value ∷ String, isValid ∷ Boolean } type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color -type Dynamic s = ColorEnv → s +type Dynamic s = LazyColor → s type Classes = Array ClassName @@ -68,15 +70,25 @@ type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } --- TODO add Lazy -type ColorEnv = - { hsl ∷ RecordHSLA - , hsv ∷ RecordHSVA - , rgb ∷ RecordRGBA - , isLight ∷ Boolean - , color ∷ Color + +type LazyColor = + { color :: Color + , hsl :: Lazy RecordHSLA + , hsv :: Lazy RecordHSVA + , rgb :: Lazy RecordRGBA + , isLight :: Lazy Boolean + } + +mkLazyColor :: Color -> LazyColor +mkLazyColor color = + { color + , hsl: defer \_ -> Color.toHSLA color + , hsv: defer \_ -> Color.toHSVA color + , rgb: defer \_ -> Color.toRGBA color + , isLight: defer \_ -> Color.isLight color } + type InputProps c = { root ∷ c , label ∷ c @@ -104,14 +116,14 @@ data ColorComponent newtype NumberComponentView = NumberComponentView ( ∀ p i - . ColorEnv + . LazyColor → HH.HTML p i → HH.HTML p i ) newtype TextComponentView r = TextComponentView ( ∀ p i - . ColorEnv + . LazyColor → Maybe InputTextValue → Array (HH.IProp (value :: String, onInput :: Event, onBlur :: FocusEvent | r) i) → HH.HTML p i @@ -119,7 +131,7 @@ newtype TextComponentView r = TextComponentView newtype DragComponentView r = DragComponentView ( ∀ p i - . ColorEnv + . LazyColor → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) i) → HH.HTML p i ) @@ -143,14 +155,14 @@ componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> HH.div - ([ HP.classes $ classes.root <> if isLight then classes.isLight else classes.isDark - , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 + ([ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark + , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 ] <> props) [ HH.div [ HP.classes classes.selector , HCSS.style do - CSS.left $ CSS.pct (hsv.s * 100.0) - CSS.bottom $ CSS.pct (hsv.v * 100.0) + CSS.left $ CSS.pct ((force hsv).s * 100.0) + CSS.bottom $ CSS.pct ((force hsv).v * 100.0) CSS.backgroundColor color ] [] @@ -170,7 +182,7 @@ componentDragHue classes = DragComponentSpec ([ HP.classes classes.root ] <> props) [ HH.div [ HP.classes classes.selector - , HCSS.style $ CSS.top $ CSS.pct ((1.0 - hsv.h / 360.0) * 100.0) + , HCSS.style $ CSS.top $ CSS.pct ((1.0 - (force hsv).h / 360.0) * 100.0) ] [] ] @@ -206,7 +218,7 @@ mkNumComponent update read classes conf = NumberComponentSpec componentHue ∷ InputProps Classes → ColorComponent componentHue classes = mkNumComponent (\n → Just <<< modifyHSL (_{h = n})) - (\({rgb, hsv, hsl}) → roundFractionalNum hsl.h) + (\({rgb, hsv, hsl}) → roundFractionalNum (force hsl).h) classes confHue @@ -214,21 +226,21 @@ componentHue classes = mkNumComponent componentSaturationHSL ∷ InputProps Classes → ColorComponent componentSaturationHSL classes = mkNumComponent (\n → Just <<< modifyHSL (_{s = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.s) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).s) classes confSaturation componentLightness ∷ InputProps Classes → ColorComponent componentLightness classes = mkNumComponent (\n → Just <<< modifyHSL (_{l = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsl.l) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).l) classes confLightness componentSaturationHSV ∷ InputProps Classes → ColorComponent componentSaturationHSV classes = mkNumComponent (\n → Just <<< modifyHSV (_{s = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.s) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).s) classes confSaturation @@ -244,28 +256,28 @@ mapInputProps f { root, label, elem, elemInvalid } = componentValue ∷ InputProps Classes → ColorComponent componentValue classes = mkNumComponent (\n → Just <<< modifyHSV (_{v = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * hsv.v) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).v) classes confValue componentRed ∷ InputProps Classes → ColorComponent componentRed classes = mkNumComponent (\n → Just <<< modifyRGB (_{r = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.r) + (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).r) classes confRed componentGreen ∷ InputProps Classes → ColorComponent componentGreen classes = mkNumComponent (\n → Just <<< modifyRGB (_{g = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.g) + (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).g) classes confGreen componentBlue ∷ InputProps Classes → ColorComponent componentBlue classes = mkNumComponent (\n → Just <<< modifyRGB (_{b = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber rgb.b) + (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).b) classes confBlue @@ -403,10 +415,10 @@ type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } modifyHSL ∷ (RecordHSLA → RecordHSLA) → Dynamic Color -modifyHSL f { hsl } = let {h, s, l, a} = f hsl in Color.hsla h s l a +modifyHSL f { hsl } = let {h, s, l, a} = f (force hsl) in Color.hsla h s l a modifyHSV ∷ (RecordHSVA → RecordHSVA) → Dynamic Color -modifyHSV f { hsv } = let {h, s, v, a} = f hsv in Color.hsva h s v a +modifyHSV f { hsv } = let {h, s, v, a} = f (force hsv) in Color.hsva h s v a modifyRGB ∷ (RecordRGBA → RecordRGBA) → Dynamic Color -modifyRGB f { rgb } = let {r, g, b, a} = f rgb in Color.rgba r g b a +modifyRGB f { rgb } = let {r, g, b, a} = f (force rgb) in Color.rgba r g b a diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 4cd9b0b..365dcbf 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -5,8 +5,6 @@ module ColorPicker.Halogen.Component , Message(..) , Props , ClassGroup(..) - , ColorComponentGroups - , ColorComponents , PickerEffects ) where @@ -16,12 +14,12 @@ import Prelude import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), ColorEnv, DragComponentView(..), NumberComponentView(..), PositionUpdate, TextComponentView(..), InputTextValue, runExistsRow) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), DragComponentView(..), InputTextValue, LazyColor, NumberComponentView(..), PositionUpdate, TextComponentView(..), mkLazyColor, runExistsRow) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) -import Data.Array (head, index, mapWithIndex, nub, take) +import Data.Array (head, index, mapWithIndex, nubBy, take) import Data.Either (Either(..), either) import Data.Either.Nested as Either import Data.Foldable (foldr, for_) @@ -43,17 +41,13 @@ import NumberInput.Halogen.Component as Num type ValueHistory a = { old ∷ Array a, current ∷ a } type State = - { color ∷ ValueHistory Color + { color ∷ ValueHistory LazyColor , inputValues ∷ Map Cursor InputTextValue , props ∷ Props } data Message = NextChange Color | NotifyChange Color - -type ColorComponentGroups = Array ColorComponents -type ColorComponents = Array ColorComponent - classesFor ∷ Props → ClassGroup → Array HH.ClassName classesFor {classes} key = fromMaybe [] $ lookup key classes @@ -63,8 +57,6 @@ data ClassGroup | ColorBlockOld | Actions | ActionSet - | IsLight - | IsDark derive instance classGroupEq ∷ Eq ClassGroup derive instance classGroupOrd ∷ Ord ClassGroup @@ -86,8 +78,8 @@ data Query a | TextComponentBlur Cursor a | Commit a | Init a - | GetValue (ValueHistory Color → a) - | SetValue (ValueHistory Color) a + | GetValue (ValueHistory LazyColor → a) -- TODO make ValueHistory and use normal Color here + | SetValue (ValueHistory LazyColor) a type ChildQuery = Coproduct.Coproduct1 (Num.Query Number) type Slot = Either.Either1 Cursor @@ -108,7 +100,7 @@ initialColor = Color.hsl 0.0 0.0 0.0 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m picker = H.lifecycleParentComponent { initialState: - { color: { current: initialColor, old: [] } + { color: { current: mkLazyColor initialColor, old: [] } , inputValues: mempty , props: _ } , render @@ -140,18 +132,18 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of L.Stage → let current = HH.div - [ HP.classes $ classesFor props ColorBlockCurrent <> colorClasses props color.current + [ HP.classes $ classesFor props ColorBlockCurrent , HP.title "Current value" - , HCSS.style $ CSS.backgroundColor color.current + , HCSS.style $ CSS.backgroundColor color.current.color ] [] old = take 4 color.old <#> \c -> HH.div [ HP.tabIndex 0 - , HP.classes $ classesFor props ColorBlockOld <> colorClasses props c + , HP.classes $ classesFor props ColorBlockOld , HP.title "Old value" - , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just c) - , HCSS.style $ CSS.backgroundColor c + , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just c.color) + , HCSS.style $ CSS.backgroundColor c.color ] [] in HH.div @@ -161,7 +153,7 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of DragComponentSpec spec → let run :: ∀ r. DragComponentView r -> HTML m - run (DragComponentView view) = view colorEnv $ + run (DragComponentView view) = view color.current $ [ HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) ] @@ -170,7 +162,7 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of let NumberComponentView view = spec.view in - view colorEnv $ + view color.current $ HH.slot' cpNumComponent cursor @@ -180,17 +172,12 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of TextComponentSpec spec → let run :: ∀ r. TextComponentView r -> HTML m - run (TextComponentView view) = view colorEnv + run (TextComponentView view) = view color.current (lookup cursor inputValues) [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString , HE.onBlur $ HE.input_ $ TextComponentBlur cursor ] in runExistsRow run spec.view - where - colorEnv = calcColorEnv color.current - -colorClasses ∷ Props → Color → Array HH.ClassName -colorClasses props c = classesFor props $ if Color.isLight c then IsLight else IsDark eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m @@ -214,7 +201,7 @@ eval = case _ of case focus cursor props.layout of Just (L.Component (NumberComponentSpec { update })) → eval $ ComponentUpdate - (\_ → update <$> num >>= (_ $ calcColorEnv color.current)) + (\_ → update <$> num >>= (_ $ color.current)) next _ → pure next SetValue val next → do @@ -228,16 +215,16 @@ eval = case _ of Commit next → do state ← H.get -- TODO disable Commit button if this condition is not true - when (Just state.color.current /= head state.color.old) do + when (Just state.color.current.color /= (map _.color $ head state.color.old)) do H.put $ state{ color = { current: state.color.current - , old: nub $ [state.color.current] <> state.color.old + , old: nubBy (\a b -> eq a.color b.color) $ [state.color.current] <> state.color.old }} - H.raise $ NotifyChange state.color.current + H.raise $ NotifyChange state.color.current.color pure next ComponentUpdate update next → do state ← H.get - for_ (update state.color.current) $ \color' → do + for_ (update state.color.current.color) $ \color' → do updateColor state $ color' pure next SetProps props next → do @@ -247,7 +234,7 @@ eval = case _ of case drag of Drag.Move event dragData → do state ← H.get - updateColor state $ update dragData.progress (calcColorEnv state.color.current) + updateColor state $ update dragData.progress state.color.current pure unit Drag.Done event → pure unit pure next @@ -260,38 +247,29 @@ eval = case _ of updateColor ∷ ∀ m. State → Color → DSL m Unit updateColor state colorNext = do - H.put state{ color { current = colorNext } } + H.put state{ color { current = mkLazyColor colorNext } } H.raise $ NextChange colorNext propagate -calcColorEnv ∷ Color → ColorEnv -calcColorEnv color = - { hsl: Color.toHSLA color - , hsv: Color.toHSVA color - , rgb: Color.toRGBA color - , isLight: Color.isLight color - , color: color - } - propagate ∷ ∀ m. DSL m Unit propagate = do { color, props: { layout }} ← H.get propagateLayout - (calcColorEnv color.current) + color.current List.Nil layout where - propagateLayout ∷ ColorEnv → Cursor → L.Layout → DSL m Unit - propagateLayout colorEnv cursor = case _ of - L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateLayout colorEnv (List.Cons idx cursor)) l + propagateLayout ∷ LazyColor → Cursor → L.Layout → DSL m Unit + propagateLayout color cursor = case _ of + L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateLayout color (List.Cons idx cursor)) l L.Stage → pure unit L.Actions → pure unit L.Component c → case c of DragComponentSpec _ → pure unit TextComponentSpec _ → pure unit NumberComponentSpec { read } → - H.query' cpNumComponent cursor (H.action $ Num.SetValue $ Just $ read colorEnv) >>= mustBeMounted + H.query' cpNumComponent cursor (H.action $ Num.SetValue $ Just $ read color) >>= mustBeMounted mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a mustBeMounted (Just x) = pure x From e6569462eddb07ae25ea2315f0ab6bcfe5ac917c Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 16:52:34 +0200 Subject: [PATCH 41/72] remove Stage and Actions node from Layout and reconstruct them using components --- example/src/Main.purs | 22 ++--- src/ColorPicker/Halogen/ColorComponents.purs | 75 ++++++++++++---- src/ColorPicker/Halogen/Component.purs | 95 +++++++------------- src/ColorPicker/Halogen/Layout.purs | 9 +- 4 files changed, 104 insertions(+), 97 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index af14358..5f63070 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -12,10 +12,9 @@ import Control.MonadZero (guard) import Data.Array (reverse) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct -import Data.Map (Map, fromFoldable, insert, lookup) +import Data.Map (Map, insert, lookup) import Data.Maybe (Maybe(..), maybe') import Data.Monoid (mempty) -import Data.Tuple (Tuple(..)) import Halogen (ClassName(..)) import Halogen as H import Halogen.Aff as HA @@ -104,7 +103,7 @@ config2 = mkConf id componentRedORNoRed ∷ C.ColorComponent componentRedORNoRed = C.TextComponentSpec { fromString: \str → if str == "red" then Just (red) else Nothing - , view: C.mkExistsRow $ C.TextComponentView \env val props -> + , view: C.mkExistsRow $ C.TextComponentView \env val props -> pure $ HH.label [ HP.classes inputClasses.root] [ HH.span [HP.classes inputClasses.label] [HH.text "🛑"] @@ -133,7 +132,7 @@ mkConf → CPicker.Props mkConf reverse' root editGroups = { layout: - L.Group [ ClassName "ColorPicker", root ] $ reverse' + L.Root [ ClassName "ColorPicker", root ] $ reverse' [ [ ClassName "ColorPicker-dragger" ] `L.Group` [ L.Component $ C.componentDragSV { root: [ ClassName "ColorPicker-field" ] @@ -147,21 +146,18 @@ mkConf reverse' root editGroups = } ] , [ ClassName "ColorPicker-aside" ] `L.Group` - [ L.Stage + [ [ ClassName "ColorPicker-stage" ] `L.Group` + [ L.Component $ C.componentPreview [ ClassName "ColorPicker-colorBlockCurrent" ] + , L.Component $ C.componentHistory [ ClassName "ColorPicker-colorBlockOld" ] + ] , L.Group [ ClassName "ColorPicker-editing" ] $ editGroups <#> \editGroup → L.Group [ ClassName "ColorPicker-editingItem" ] $ editGroup <#> \mkItem -> L.Component $ mkItem inputClasses - , L.Actions + , [ ClassName "ColorPicker-actions" ] `L.Group` + [ L.Component $ C.componentSet [ ClassName "ColorPicker-actionSet" ] ] ] ] - , classes: fromFoldable - [ Tuple CPicker.Stage [ ClassName "ColorPicker-stage" ] - , Tuple CPicker.ColorBlockCurrent [ ClassName "ColorPicker-colorBlockCurrent" ] - , Tuple CPicker.ColorBlockOld [ ClassName "ColorPicker-colorBlockOld" ] - , Tuple CPicker.Actions [ ClassName "ColorPicker-actions" ] - , Tuple CPicker.ActionSet [ ClassName "ColorPicker-actionSet" ] - ] } inputClasses ∷ C.InputProps C.Classes diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 55b9890..11be3aa 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -35,6 +35,10 @@ module ColorPicker.Halogen.ColorComponents , NumberComponentView(..) , mkLazyColor , LazyColor + , ValueHistory + , componentPreview + , componentHistory + , componentSet ) where import Prelude @@ -44,13 +48,15 @@ import Color (Color) import Color as Color import Control.MonadZero (guard) import DOM.Event.Types (Event, FocusEvent, MouseEvent, TouchEvent) +import Data.Array (take) import Data.Int (floor, toNumber) import Data.Lazy (Lazy, defer, force) import Data.Maybe (Maybe(..), maybe, maybe') import Data.String as String -import Halogen (ClassName) +import Halogen as H import Halogen.HTML as HH import Halogen.HTML.CSS as HCSS +import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Math (round) import NumberInput.Halogen.Component as Num @@ -58,13 +64,15 @@ import NumberInput.Range (Range(..)) import Unsafe.Coerce (unsafeCoerce) +type ValueHistory a = { old ∷ Array a, current ∷ a } + type InputTextValue = { value ∷ String, isValid ∷ Boolean } type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color type Dynamic s = LazyColor → s -type Classes = Array ClassName +type Classes = Array H.ClassName type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } @@ -112,13 +120,21 @@ data ColorComponent { update ∷ PositionUpdate , view ∷ ExistsRow DragComponentView } + | ActionComponentSpec + ( ∀ p i + . { color ∷ ValueHistory LazyColor + , setColor ∷ Color → i + , commit ∷ i + } + → Array (HH.HTML p i) + ) newtype NumberComponentView = NumberComponentView ( ∀ p i . LazyColor → HH.HTML p i - → HH.HTML p i + → Array (HH.HTML p i) ) newtype TextComponentView r = TextComponentView @@ -126,14 +142,14 @@ newtype TextComponentView r = TextComponentView . LazyColor → Maybe InputTextValue → Array (HH.IProp (value :: String, onInput :: Event, onBlur :: FocusEvent | r) i) - → HH.HTML p i + → Array (HH.HTML p i) ) newtype DragComponentView r = DragComponentView ( ∀ p i . LazyColor → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) i) - → HH.HTML p i + → Array (HH.HTML p i) ) foreign import data ExistsRow :: (# Type -> Type) -> Type @@ -144,16 +160,45 @@ mkExistsRow = unsafeCoerce runExistsRow :: ∀ f a. (∀ r. f r -> a) -> ExistsRow f -> a runExistsRow = unsafeCoerce + +componentPreview ∷ Array H.ClassName -> ColorComponent +componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ + HH.div + [ HP.classes $ classes + , HP.title "Current value" + , HCSS.style $ CSS.backgroundColor color.current.color + ] [] + +componentHistory ∷ Array H.ClassName -> ColorComponent +componentHistory classes = ActionComponentSpec \{ color , setColor } → + take 4 color.old <#> \c -> + HH.div + [ HP.tabIndex 0 + , HP.classes $ classes + , HP.title "Old value" + , HE.onClick $ (\_ → Just $ setColor c.color) + , HCSS.style $ CSS.backgroundColor c.color + ] [] + + +componentSet ∷ Array H.ClassName -> ColorComponent +componentSet classes = ActionComponentSpec \{ commit } → pure $ + HH.button + [ HP.classes classes + , HE.onClick $ const $ Just commit + ] + [ HH.text "Set" ] + componentDragSV ∷ - { isLight ∷ Array ClassName - , isDark ∷ Array ClassName - , root ∷ Array ClassName - , selector ∷ Array ClassName + { isLight ∷ Array H.ClassName + , isDark ∷ Array H.ClassName + , root ∷ Array H.ClassName + , selector ∷ Array H.ClassName } → ColorComponent componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} - , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> + , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> pure $ HH.div ([ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 @@ -171,13 +216,13 @@ componentDragSV classes = DragComponentSpec componentDragHue ∷ - { root ∷ Array ClassName - , selector ∷ Array ClassName + { root ∷ Array H.ClassName + , selector ∷ Array H.ClassName } → ColorComponent componentDragHue classes = DragComponentSpec { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } - , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> + , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> pure $ HH.div ([ HP.classes classes.root ] <> props) [ HH.div @@ -206,7 +251,7 @@ mkNumComponent update read classes conf = NumberComponentSpec , rootInvalid: classes.elemInvalid , rootLength: const [] } - , view: NumberComponentView \ {} input -> renderInput + , view: NumberComponentView \ {} input -> pure $ renderInput { root: classes.root , label: classes.label , prefix: conf.prefix @@ -284,7 +329,7 @@ componentBlue classes = mkNumComponent componentHEX ∷ InputProps Classes → ColorComponent componentHEX classes = TextComponentSpec { fromString: \str → Color.fromHexString $ "#" <> str - , view: mkExistsRow $ TextComponentView \env val props -> renderInput + , view: mkExistsRow $ TextComponentView \env val props -> pure $ renderInput { root: classes.root , label: classes.label , prefix: "#" diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 365dcbf..704d02d 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -1,45 +1,40 @@ module ColorPicker.Halogen.Component ( picker , Query(GetValue, SetValue, Commit) - , ValueHistory , Message(..) , Props - , ClassGroup(..) , PickerEffects ) where import Prelude -import CSS as CSS import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), DragComponentView(..), InputTextValue, LazyColor, NumberComponentView(..), PositionUpdate, TextComponentView(..), mkLazyColor, runExistsRow) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), DragComponentView(..), InputTextValue, LazyColor, NumberComponentView(..), PositionUpdate, TextComponentView(..), ValueHistory, mkLazyColor, runExistsRow) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) -import Data.Array (head, index, mapWithIndex, nubBy, take) +import Data.Array (head, index, mapWithIndex, nubBy) import Data.Either (Either(..), either) import Data.Either.Nested as Either -import Data.Foldable (foldr, for_) +import Data.Foldable (fold, foldr, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.List as List import Data.Map (Map, insert, lookup) -import Data.Maybe (Maybe(..), fromMaybe) +import Data.Maybe (Maybe(..)) import Data.Monoid (mempty) import Data.Traversable (sequence) import Halogen (liftEff) import Halogen as H import Halogen.Component.ChildPath as CP import Halogen.HTML as HH -import Halogen.HTML.CSS as HCSS import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Halogen.Query.HalogenM (halt) import NumberInput.Halogen.Component as Num -type ValueHistory a = { old ∷ Array a, current ∷ a } type State = { color ∷ ValueHistory LazyColor , inputValues ∷ Map Cursor InputTextValue @@ -48,22 +43,9 @@ type State = data Message = NextChange Color | NotifyChange Color -classesFor ∷ Props → ClassGroup → Array HH.ClassName -classesFor {classes} key = fromMaybe [] $ lookup key classes - -data ClassGroup - = Stage - | ColorBlockCurrent - | ColorBlockOld - | Actions - | ActionSet - -derive instance classGroupEq ∷ Eq ClassGroup -derive instance classGroupOrd ∷ Ord ClassGroup type Props = - { classes ∷ Map ClassGroup (Array HH.ClassName) - , layout ∷ L.Layout + { layout ∷ L.Layout } @@ -111,48 +93,29 @@ picker = H.lifecycleParentComponent } render ∷ ∀ m. State → HTML m -render state = renderLayout state List.Nil state.props.layout +render state = + let L.Root classes children = state.props.layout + in + HH.div + [HP.classes classes] $ + fold $ mapWithIndex (\idx -> renderLayout state $ List.Cons idx List.Nil) children -renderLayout ∷ ∀ m. State → Cursor → L.Layout → HTML m +renderLayout ∷ ∀ m. State → Cursor → L.ChildLayout → Array (HTML m) renderLayout state@{ color, inputValues, props} cursor = case _ of - L.Group classes l → + L.Group classes l → pure $ HH.div [ HP.classes classes ] - $ mapWithIndex (\idx → renderLayout state (List.Cons idx cursor)) l - L.Actions → - HH.div - [ HP.classes $ props `classesFor` Actions ] - [ HH.button - [ HP.classes $ props `classesFor` ActionSet - , HE.onClick $ HE.input \_ → Commit - ] - [ HH.text "Set" ] - ] - L.Stage → - let - current = HH.div - [ HP.classes $ classesFor props ColorBlockCurrent - , HP.title "Current value" - , HCSS.style $ CSS.backgroundColor color.current.color - ] [] - - old = take 4 color.old <#> \c -> - HH.div - [ HP.tabIndex 0 - , HP.classes $ classesFor props ColorBlockOld - , HP.title "Old value" - , HE.onClick $ HE.input (\_ → ComponentUpdate $ const $ Just c.color) - , HCSS.style $ CSS.backgroundColor c.color - ] [] - in - HH.div - [ HP.classes $ props `classesFor` Stage ] $ - [ current ] <> old - L.Component c → case c of + $ fold $ mapWithIndex (\idx → renderLayout state (List.Cons idx cursor)) l + L.Component c → case c of + ActionComponentSpec view → view + { color + , setColor: H.action <<< ComponentUpdate <<< const <<< Just + , commit: H.action Commit + } DragComponentSpec spec → let - run :: ∀ r. DragComponentView r -> HTML m + run :: ∀ r. DragComponentView r -> Array (HTML m) run (DragComponentView view) = view color.current $ [ HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) @@ -171,7 +134,7 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of (HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val) TextComponentSpec spec → let - run :: ∀ r. TextComponentView r -> HTML m + run :: ∀ r. TextComponentView r -> Array (HTML m) run (TextComponentView view) = view color.current (lookup cursor inputValues) [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString @@ -262,12 +225,14 @@ propagate = do where propagateLayout ∷ LazyColor → Cursor → L.Layout → DSL m Unit propagateLayout color cursor = case _ of - L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateLayout color (List.Cons idx cursor)) l - L.Stage → pure unit - L.Actions → pure unit + L.Root _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l + propagateChildLayout ∷ LazyColor → Cursor → L.ChildLayout → DSL m Unit + propagateChildLayout color cursor = case _ of + L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l L.Component c → case c of DragComponentSpec _ → pure unit TextComponentSpec _ → pure unit + ActionComponentSpec _ → pure unit NumberComponentSpec { read } → H.query' cpNumComponent cursor (H.action $ Num.SetValue $ Just $ read color) >>= mustBeMounted @@ -277,8 +242,10 @@ mustBeMounted _ = halt "children must be mounted" type Cursor = List.List Int -focus :: Cursor → L.Layout → Maybe L.Layout -focus cursor layout = foldr f (Just layout) cursor +focus :: Cursor → L.Layout → Maybe L.ChildLayout +focus cursor layout = + let L.Root x children = layout + in foldr f (Just $ L.Group x children) cursor where f idx = case _ of Just (L.Group _ l) → index l idx diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index bce95ad..80fee5c 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -4,9 +4,8 @@ module ColorPicker.Halogen.Layout where import ColorPicker.Halogen.ColorComponents (ColorComponent) import Halogen (ClassName) -data Layout - = Group (Array ClassName) (Array Layout) +data Layout = Root (Array ClassName) (Array ChildLayout) + +data ChildLayout + = Group (Array ClassName) (Array ChildLayout) | Component ColorComponent - -- TODO remove this Stage and Actions variants they could be expressed using some ButtonComponents - | Stage - | Actions From 319e2ce17efd57d41d0396c8c4fbe812e6beb383 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 17:36:22 +0200 Subject: [PATCH 42/72] pass event handlers to views instead of props --- example/src/Main.purs | 12 +- src/ColorPicker/Halogen/ColorComponents.purs | 115 +++++++++---------- src/ColorPicker/Halogen/Component.purs | 50 ++++---- 3 files changed, 81 insertions(+), 96 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 5f63070..d6994ae 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -103,19 +103,21 @@ config2 = mkConf id componentRedORNoRed ∷ C.ColorComponent componentRedORNoRed = C.TextComponentSpec { fromString: \str → if str == "red" then Just (red) else Nothing - , view: C.mkExistsRow $ C.TextComponentView \env val props -> pure $ + , view: \{color, value, onBlur, onValueInput } -> pure $ HH.label [ HP.classes inputClasses.root] [ HH.span [HP.classes inputClasses.label] [HH.text "🛑"] - , HH.input $ + , HH.input [ HP.type_ HP.InputText , HP.classes $ inputClasses.elem - <> (guard (C.isInvalid val) *> (inputClasses.elemInvalid)) + <> (guard (C.isInvalid value) *> (inputClasses.elemInvalid)) , HP.title "red or nored?" - , HP.value $ maybe' (\_ -> toString env) _.value val + , HP.value $ maybe' (\_ -> toString color) _.value value , HP.placeholder "red" - ] <> props + , HE.onValueInput $ onValueInput >>> Just + , HE.onBlur $ onBlur >>> Just + ] ] } where diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 11be3aa..714d6f2 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -27,12 +27,6 @@ module ColorPicker.Halogen.ColorComponents , componentDragHue , componentDragSV , mapInputProps - , ExistsRow - , DragComponentView(..) - , mkExistsRow - , runExistsRow - , TextComponentView(..) - , NumberComponentView(..) , mkLazyColor , LazyColor , ValueHistory @@ -47,7 +41,7 @@ import CSS as CSS import Color (Color) import Color as Color import Control.MonadZero (guard) -import DOM.Event.Types (Event, FocusEvent, MouseEvent, TouchEvent) +import DOM.Event.Types (FocusEvent, MouseEvent, TouchEvent) import Data.Array (take) import Data.Int (floor, toNumber) import Data.Lazy (Lazy, defer, force) @@ -61,7 +55,6 @@ import Halogen.HTML.Properties as HP import Math (round) import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) -import Unsafe.Coerce (unsafeCoerce) type ValueHistory a = { old ∷ Array a, current ∷ a } @@ -110,15 +103,36 @@ data ColorComponent { update ∷ Number → Dynamic (Maybe Color) , read ∷ Dynamic Number , props ∷ Num.Props Number - , view ∷ NumberComponentView + , view ∷ + ( ∀ p i + . { color :: LazyColor + , input :: HH.HTML p i + } + → Array (HH.HTML p i) + ) } | TextComponentSpec { fromString ∷ String → Maybe Color - , view ∷ ExistsRow TextComponentView + , view ∷ + ( ∀ p i + . { color :: LazyColor + , value :: Maybe InputTextValue + , onValueInput :: String -> i + , onBlur :: FocusEvent -> i + } + → Array (HH.HTML p i) + ) } | DragComponentSpec { update ∷ PositionUpdate - , view ∷ ExistsRow DragComponentView + , view ∷ + ( ∀ p i + . { color:: LazyColor + , onMouseDown :: MouseEvent -> i + , onTouchStart :: TouchEvent -> i + } + → Array (HH.HTML p i) + ) } | ActionComponentSpec ( ∀ p i @@ -130,37 +144,6 @@ data ColorComponent ) -newtype NumberComponentView = NumberComponentView - ( ∀ p i - . LazyColor - → HH.HTML p i - → Array (HH.HTML p i) - ) - -newtype TextComponentView r = TextComponentView - ( ∀ p i - . LazyColor - → Maybe InputTextValue - → Array (HH.IProp (value :: String, onInput :: Event, onBlur :: FocusEvent | r) i) - → Array (HH.HTML p i) - ) - -newtype DragComponentView r = DragComponentView - ( ∀ p i - . LazyColor - → Array (HH.IProp (onMouseDown :: MouseEvent, onTouchStart :: TouchEvent | r) i) - → Array (HH.HTML p i) - ) - -foreign import data ExistsRow :: (# Type -> Type) -> Type - -mkExistsRow :: ∀ f r. f r -> ExistsRow f -mkExistsRow = unsafeCoerce - -runExistsRow :: ∀ f a. (∀ r. f r -> a) -> ExistsRow f -> a -runExistsRow = unsafeCoerce - - componentPreview ∷ Array H.ClassName -> ColorComponent componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ HH.div @@ -198,11 +181,13 @@ componentDragSV ∷ → ColorComponent componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} - , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> pure $ + , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ HH.div - ([ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark + [ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 - ] <> props) + , HE.onTouchStart $ onTouchStart >>> Just + , HE.onMouseDown $ onMouseDown >>> Just + ] [ HH.div [ HP.classes classes.selector , HCSS.style do @@ -222,9 +207,12 @@ componentDragHue ∷ → ColorComponent componentDragHue classes = DragComponentSpec { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } - , view: mkExistsRow $ DragComponentView \{isLight, hsv, color} props -> pure $ + , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ HH.div - ([ HP.classes classes.root ] <> props) + [ HP.classes classes.root + , HE.onTouchStart $ onTouchStart >>> Just + , HE.onMouseDown $ onMouseDown >>> Just + ] [ HH.div [ HP.classes classes.selector , HCSS.style $ CSS.top $ CSS.pct ((1.0 - (force hsv).h / 360.0) * 100.0) @@ -251,7 +239,7 @@ mkNumComponent update read classes conf = NumberComponentSpec , rootInvalid: classes.elemInvalid , rootLength: const [] } - , view: NumberComponentView \ {} input -> pure $ renderInput + , view: \ {input} -> pure $ renderInput { root: classes.root , label: classes.label , prefix: conf.prefix @@ -329,20 +317,23 @@ componentBlue classes = mkNumComponent componentHEX ∷ InputProps Classes → ColorComponent componentHEX classes = TextComponentSpec { fromString: \str → Color.fromHexString $ "#" <> str - , view: mkExistsRow $ TextComponentView \env val props -> pure $ renderInput - { root: classes.root - , label: classes.label - , prefix: "#" - , child: HH.input $ - [ HP.type_ HP.InputText - , HP.classes - $ classes.elem - <> (guard (isInvalid val) *> (classes.elemInvalid)) - , HP.title "Hex" - , HP.value $ maybe' (\_ -> toString env) _.value val - , HP.placeholder "Hex" - ] <> props - } + , view: \{color, value, onValueInput, onBlur} -> pure $ + renderInput + { root: classes.root + , label: classes.label + , prefix: "#" + , child: HH.input $ + [ HP.type_ HP.InputText + , HP.classes + $ classes.elem + <> (guard (isInvalid value) *> (classes.elemInvalid)) + , HP.title "Hex" + , HP.value $ maybe' (\_ -> toString color) _.value value + , HP.placeholder "Hex" + , HE.onValueInput $ onValueInput >>> Just + , HE.onBlur $ onBlur >>> Just + ] + } } where toString = \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 704d02d..1dea21f 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -11,7 +11,7 @@ import Prelude import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), DragComponentView(..), InputTextValue, LazyColor, NumberComponentView(..), PositionUpdate, TextComponentView(..), ValueHistory, mkLazyColor, runExistsRow) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mkLazyColor) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) @@ -113,34 +113,26 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of , setColor: H.action <<< ComponentUpdate <<< const <<< Just , commit: H.action Commit } - DragComponentSpec spec → - let - run :: ∀ r. DragComponentView r -> Array (HTML m) - run (DragComponentView view) = view color.current $ - [ HE.onMouseDown $ HE.input (Left >>> DragStart spec.update) - , HE.onTouchStart $ HE.input (Right >>> DragStart spec.update) - ] - in runExistsRow run spec.view - NumberComponentSpec spec → - let - NumberComponentView view = spec.view - in - view color.current $ - HH.slot' - cpNumComponent - cursor - Num.input - spec.props - (HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val) - TextComponentSpec spec → - let - run :: ∀ r. TextComponentView r -> Array (HTML m) - run (TextComponentView view) = view color.current - (lookup cursor inputValues) - [ HE.onValueInput $ HE.input $ TextComponentUpdate cursor spec.fromString - , HE.onBlur $ HE.input_ $ TextComponentBlur cursor - ] - in runExistsRow run spec.view + DragComponentSpec spec → spec.view + { color: color.current + , onMouseDown: Left >>> DragStart spec.update >>> H.action + , onTouchStart: Right >>> DragStart spec.update >>> H.action + } + NumberComponentSpec spec → spec.view + { color: color.current + , input: HH.slot' + cpNumComponent + cursor + Num.input + spec.props + (HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val) + } + TextComponentSpec spec → spec.view + { color: color.current + , value: lookup cursor inputValues + , onValueInput: TextComponentUpdate cursor spec.fromString >>> H.action + , onBlur: const (TextComponentBlur cursor) >>> H.action + } eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m From 92f61bf0770b37fff847c128753fdc84e16f56d3 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 17:37:20 +0200 Subject: [PATCH 43/72] refactor Query.UpdateCommand inito UpdateCurrentColor --- src/ColorPicker/Halogen/Component.purs | 29 +++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 1dea21f..7dfa54b 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -53,8 +53,7 @@ data Query a = SetProps Props a | DragStart PositionUpdate Drag.CursorEvent a | DragMove PositionUpdate Drag.DragEvent a - -- TODO `ComponentUpdate` could be removed at some point - | ComponentUpdate (Color → Maybe Color) a + | UpdateCurrentColor Color a | NumberComponentUpdate Cursor (Maybe Number) a | TextComponentUpdate Cursor (String → Maybe Color) String a | TextComponentBlur Cursor a @@ -110,7 +109,7 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of L.Component c → case c of ActionComponentSpec view → view { color - , setColor: H.action <<< ComponentUpdate <<< const <<< Just + , setColor: H.action <<< UpdateCurrentColor , commit: H.action Commit } DragComponentSpec spec → spec.view @@ -149,16 +148,17 @@ eval = case _ of isValid = case color of Nothing → false Just _ → true - H.modify \s → s { inputValues = insert cursor {isValid, value: str} s.inputValues } - eval $ ComponentUpdate (const color) next + state <- H.get + let state' = state { inputValues = insert cursor {isValid, value: str} state.inputValues } + for_ color $ updateColor state' + pure next NumberComponentUpdate cursor num next → do - { color, props } ← H.get - case focus cursor props.layout of - Just (L.Component (NumberComponentSpec { update })) → eval $ - ComponentUpdate - (\_ → update <$> num >>= (_ $ color.current)) - next - _ → pure next + state ← H.get + case focus cursor state.props.layout of + Just (L.Component (NumberComponentSpec { update })) → + for_ (update <$> num >>= (_ $ state.color.current)) $ updateColor state + _ → pure unit + pure next SetValue val next → do state ← H.get H.put $ state{ color = val } @@ -177,10 +177,9 @@ eval = case _ of }} H.raise $ NotifyChange state.color.current.color pure next - ComponentUpdate update next → do + UpdateCurrentColor color next → do state ← H.get - for_ (update state.color.current.color) $ \color' → do - updateColor state $ color' + updateColor state color pure next SetProps props next → do H.modify _{props = props} From 615648222b794d8986205b3e454077dc5c320c7d Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:00:13 +0200 Subject: [PATCH 44/72] remove LazyColor from Query --- src/ColorPicker/Halogen/ColorComponents.purs | 4 ++++ src/ColorPicker/Halogen/Component.purs | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index 714d6f2..f969ddd 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -30,6 +30,7 @@ module ColorPicker.Halogen.ColorComponents , mkLazyColor , LazyColor , ValueHistory + , mapValueHistory , componentPreview , componentHistory , componentSet @@ -57,6 +58,9 @@ import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) +mapValueHistory :: ∀ a b. (a -> b) -> ValueHistory a -> ValueHistory b +mapValueHistory f { current, old } = { current: f current, old: map f old } + type ValueHistory a = { old ∷ Array a, current ∷ a } type InputTextValue = { value ∷ String, isValid ∷ Boolean } diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 7dfa54b..9c7994c 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -11,7 +11,7 @@ import Prelude import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mkLazyColor) +import ColorPicker.Halogen.ColorComponents (ColorComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mapValueHistory, mkLazyColor) import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) @@ -59,8 +59,9 @@ data Query a | TextComponentBlur Cursor a | Commit a | Init a - | GetValue (ValueHistory LazyColor → a) -- TODO make ValueHistory and use normal Color here - | SetValue (ValueHistory LazyColor) a + | GetValue (ValueHistory Color → a) + | SetValue (ValueHistory Color) a + type ChildQuery = Coproduct.Coproduct1 (Num.Query Number) type Slot = Either.Either1 Cursor @@ -161,9 +162,9 @@ eval = case _ of pure next SetValue val next → do state ← H.get - H.put $ state{ color = val } + H.put $ state{ color = mapValueHistory mkLazyColor val } pure next - GetValue next → H.get <#> (_.color >>> next) + GetValue next → H.get <#> (_.color >>> (mapValueHistory _.color) >>> next) Init next → do propagate pure next From 91bc9659b0b89c34fc4dd2673f1e7a42d3c76d9e Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:06:04 +0200 Subject: [PATCH 45/72] disable Set button if color is not changed --- src/ColorPicker/Halogen/ColorComponents.purs | 5 +++-- src/ColorPicker/Halogen/Component.purs | 14 ++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index f969ddd..c145d73 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -43,7 +43,7 @@ import Color (Color) import Color as Color import Control.MonadZero (guard) import DOM.Event.Types (FocusEvent, MouseEvent, TouchEvent) -import Data.Array (take) +import Data.Array (head, take) import Data.Int (floor, toNumber) import Data.Lazy (Lazy, defer, force) import Data.Maybe (Maybe(..), maybe, maybe') @@ -169,10 +169,11 @@ componentHistory classes = ActionComponentSpec \{ color , setColor } → componentSet ∷ Array H.ClassName -> ColorComponent -componentSet classes = ActionComponentSpec \{ commit } → pure $ +componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } → pure $ HH.button [ HP.classes classes , HE.onClick $ const $ Just commit + , HP.disabled $ Just current.color == (map _.color $ head old) ] [ HH.text "Set" ] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 9c7994c..e7129c4 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -16,7 +16,7 @@ import ColorPicker.Halogen.Layout as L import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) -import Data.Array (head, index, mapWithIndex, nubBy) +import Data.Array (index, mapWithIndex, nubBy) import Data.Either (Either(..), either) import Data.Either.Nested as Either import Data.Foldable (fold, foldr, for_) @@ -170,13 +170,11 @@ eval = case _ of pure next Commit next → do state ← H.get - -- TODO disable Commit button if this condition is not true - when (Just state.color.current.color /= (map _.color $ head state.color.old)) do - H.put $ state{ color = - { current: state.color.current - , old: nubBy (\a b -> eq a.color b.color) $ [state.color.current] <> state.color.old - }} - H.raise $ NotifyChange state.color.current.color + H.put $ state{ color = + { current: state.color.current + , old: nubBy (\a b -> eq a.color b.color) $ [state.color.current] <> state.color.old + }} + H.raise $ NotifyChange state.color.current.color pure next UpdateCurrentColor color next → do state ← H.get From 5ac5f62737a85b3d05b0aa869978c9ac3035eddb Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:19:29 +0200 Subject: [PATCH 46/72] refactor ColorComponents --- example/src/Main.purs | 18 ++- src/ColorPicker/Halogen/ColorComponents.purs | 138 +++++++++---------- 2 files changed, 78 insertions(+), 78 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index d6994ae..81f2e9d 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -85,14 +85,26 @@ eval (HandleMsg idx msg next) = do config0 ∷ CPicker.Props config0 = mkConf reverse (ClassName "ColorPicker--small") - [ [C.componentHue] <> C.componentSL + [ [ C.componentHue + , C.componentSaturationHSL + , C.componentLightness + ] ] config1 ∷ CPicker.Props config1 = mkConf id (ClassName "ColorPicker--large") - [ [C.componentHue] <> C.componentSV <> C.componentSL - , C.componentRGB <> [C.componentHEX] + [ [ C.componentHue + , C.componentSaturationHSV + , C.componentValue + , C.componentSaturationHSL + , C.componentLightness + ] + , [ C.componentRed + , C.componentGreen + , C.componentBlue + , C.componentHEX + ] ] config2 ∷ CPicker.Props diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs index c145d73..d6ec7ca 100644 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ b/src/ColorPicker/Halogen/ColorComponents.purs @@ -1,17 +1,30 @@ module ColorPicker.Halogen.ColorComponents ( ColorComponent(..) + + , NumberComponentView + , TextComponentView + , DragComponentView + , ActionComponentView + , InputTextValue , isValid , isInvalid + + , PositionUpdate , Dynamic , PreNumConf - , PreTextConf , InputProps , Classes + , ValueHistory + , mapValueHistory + + , LazyColor , RecordHSLA , RecordHSVA , RecordRGBA - , PositionUpdate + , mkLazyColor + + , componentHue , componentSaturationHSL , componentLightness @@ -21,16 +34,8 @@ module ColorPicker.Halogen.ColorComponents , componentGreen , componentBlue , componentHEX - , componentSL - , componentSV - , componentRGB , componentDragHue , componentDragSV - , mapInputProps - , mkLazyColor - , LazyColor - , ValueHistory - , mapValueHistory , componentPreview , componentHistory , componentSet @@ -58,9 +63,6 @@ import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) -mapValueHistory :: ∀ a b. (a -> b) -> ValueHistory a -> ValueHistory b -mapValueHistory f { current, old } = { current: f current, old: map f old } - type ValueHistory a = { old ∷ Array a, current ∷ a } type InputTextValue = { value ∷ String, isValid ∷ Boolean } @@ -73,9 +75,6 @@ type Classes = Array H.ClassName type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } -type PreTextConf = { prefix ∷ String, title ∷ String, placeholder ∷ String } - - type LazyColor = { color :: Color , hsl :: Lazy RecordHSLA @@ -84,16 +83,6 @@ type LazyColor = , isLight :: Lazy Boolean } -mkLazyColor :: Color -> LazyColor -mkLazyColor color = - { color - , hsl: defer \_ -> Color.toHSLA color - , hsv: defer \_ -> Color.toHSVA color - , rgb: defer \_ -> Color.toRGBA color - , isLight: defer \_ -> Color.isLight color - } - - type InputProps c = { root ∷ c , label ∷ c @@ -107,45 +96,61 @@ data ColorComponent { update ∷ Number → Dynamic (Maybe Color) , read ∷ Dynamic Number , props ∷ Num.Props Number - , view ∷ - ( ∀ p i - . { color :: LazyColor - , input :: HH.HTML p i - } - → Array (HH.HTML p i) - ) + , view ∷ NumberComponentView } | TextComponentSpec { fromString ∷ String → Maybe Color - , view ∷ - ( ∀ p i - . { color :: LazyColor - , value :: Maybe InputTextValue - , onValueInput :: String -> i - , onBlur :: FocusEvent -> i - } - → Array (HH.HTML p i) - ) + , view ∷ TextComponentView } | DragComponentSpec { update ∷ PositionUpdate - , view ∷ - ( ∀ p i - . { color:: LazyColor - , onMouseDown :: MouseEvent -> i - , onTouchStart :: TouchEvent -> i - } - → Array (HH.HTML p i) - ) + , view ∷ DragComponentView } - | ActionComponentSpec - ( ∀ p i - . { color ∷ ValueHistory LazyColor - , setColor ∷ Color → i - , commit ∷ i - } - → Array (HH.HTML p i) - ) + | ActionComponentSpec ActionComponentView + +type NumberComponentView = + ∀ p i + . { color :: LazyColor + , input :: HH.HTML p i + } + → Array (HH.HTML p i) + +type TextComponentView = + ∀ p i + . { color :: LazyColor + , value :: Maybe InputTextValue + , onValueInput :: String -> i + , onBlur :: FocusEvent -> i + } + → Array (HH.HTML p i) + +type DragComponentView = + ∀ p i + . { color:: LazyColor + , onMouseDown :: MouseEvent -> i + , onTouchStart :: TouchEvent -> i + } + → Array (HH.HTML p i) + +type ActionComponentView = + ∀ p i + . { color ∷ ValueHistory LazyColor + , setColor ∷ Color → i + , commit ∷ i + } + → Array (HH.HTML p i) + +mapValueHistory :: ∀ a b. (a -> b) -> ValueHistory a -> ValueHistory b +mapValueHistory f { current, old } = { current: f current, old: map f old } + +mkLazyColor :: Color -> LazyColor +mkLazyColor color = + { color + , hsl: defer \_ -> Color.toHSLA color + , hsv: defer \_ -> Color.toHSVA color + , rgb: defer \_ -> Color.toRGBA color + , isLight: defer \_ -> Color.isLight color + } componentPreview ∷ Array H.ClassName -> ColorComponent @@ -282,14 +287,6 @@ componentSaturationHSV classes = mkNumComponent classes confSaturation -mapInputProps :: ∀ a b. (a -> b) -> InputProps a -> InputProps b -mapInputProps f { root, label, elem, elemInvalid } = - { root: f root - , label: f label - , elem: f elem - , elemInvalid: f elemInvalid - } - componentValue ∷ InputProps Classes → ColorComponent componentValue classes = mkNumComponent @@ -364,15 +361,6 @@ renderInput {root, label, prefix, child} = , child ] -componentSL ∷ Array (InputProps Classes → ColorComponent) -componentSL = [componentSaturationHSL, componentLightness] - -componentSV ∷ Array (InputProps Classes → ColorComponent) -componentSV = [componentSaturationHSV, componentValue] - -componentRGB ∷ Array (InputProps Classes → ColorComponent) -componentRGB = [componentRed, componentGreen, componentBlue] - -- Internal helpers From ec6c8abd8211fa7bf445cc0db7d161653883af3c Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:23:19 +0200 Subject: [PATCH 47/72] merge ColorComponent and Layout modules --- example/src/Main.purs | 45 +- src/ColorPicker/Halogen/ColorComponents.purs | 453 ------------------ src/ColorPicker/Halogen/Component.purs | 33 +- src/ColorPicker/Halogen/Layout.purs | 460 ++++++++++++++++++- 4 files changed, 493 insertions(+), 498 deletions(-) delete mode 100644 src/ColorPicker/Halogen/ColorComponents.purs diff --git a/example/src/Main.purs b/example/src/Main.purs index 81f2e9d..0315970 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -3,7 +3,6 @@ module Main where import Prelude import Color (Color, rgb) -import ColorPicker.Halogen.ColorComponents as C import ColorPicker.Halogen.Component as CPicker import ColorPicker.Halogen.Layout as L import Control.Monad.Aff.Class (class MonadAff) @@ -85,25 +84,25 @@ eval (HandleMsg idx msg next) = do config0 ∷ CPicker.Props config0 = mkConf reverse (ClassName "ColorPicker--small") - [ [ C.componentHue - , C.componentSaturationHSL - , C.componentLightness + [ [ L.componentHue + , L.componentSaturationHSL + , L.componentLightness ] ] config1 ∷ CPicker.Props config1 = mkConf id (ClassName "ColorPicker--large") - [ [ C.componentHue - , C.componentSaturationHSV - , C.componentValue - , C.componentSaturationHSL - , C.componentLightness + [ [ L.componentHue + , L.componentSaturationHSV + , L.componentValue + , L.componentSaturationHSL + , L.componentLightness ] - , [ C.componentRed - , C.componentGreen - , C.componentBlue - , C.componentHEX + , [ L.componentRed + , L.componentGreen + , L.componentBlue + , L.componentHEX ] ] @@ -112,8 +111,8 @@ config2 = mkConf id (ClassName "ColorPicker--small") [ [ const componentRedORNoRed ]] -componentRedORNoRed ∷ C.ColorComponent -componentRedORNoRed = C.TextComponentSpec +componentRedORNoRed ∷ L.ColorComponent +componentRedORNoRed = L.TextComponentSpec { fromString: \str → if str == "red" then Just (red) else Nothing , view: \{color, value, onBlur, onValueInput } -> pure $ HH.label @@ -123,7 +122,7 @@ componentRedORNoRed = C.TextComponentSpec [ HP.type_ HP.InputText , HP.classes $ inputClasses.elem - <> (guard (C.isInvalid value) *> (inputClasses.elemInvalid)) + <> (guard (L.isInvalid value) *> (inputClasses.elemInvalid)) , HP.title "red or nored?" , HP.value $ maybe' (\_ -> toString color) _.value value , HP.placeholder "red" @@ -142,39 +141,39 @@ componentRedORNoRed = C.TextComponentSpec mkConf ∷ (∀ a. Array a → Array a) → ClassName - → Array (Array (C.InputProps C.Classes → C.ColorComponent)) + → Array (Array (L.InputProps L.Classes → L.ColorComponent)) → CPicker.Props mkConf reverse' root editGroups = { layout: L.Root [ ClassName "ColorPicker", root ] $ reverse' [ [ ClassName "ColorPicker-dragger" ] `L.Group` - [ L.Component $ C.componentDragSV + [ L.Component $ L.componentDragSV { root: [ ClassName "ColorPicker-field" ] , isLight: [ ClassName "IsLight" ] , isDark: [ ClassName "IsDark" ] , selector: [ ClassName "ColorPicker-fieldSelector"] } - , L.Component $ C.componentDragHue + , L.Component $ L.componentDragHue { root: [ ClassName "ColorPicker-slider" ] , selector: [ ClassName "ColorPicker-sliderSelector"] } ] , [ ClassName "ColorPicker-aside" ] `L.Group` [ [ ClassName "ColorPicker-stage" ] `L.Group` - [ L.Component $ C.componentPreview [ ClassName "ColorPicker-colorBlockCurrent" ] - , L.Component $ C.componentHistory [ ClassName "ColorPicker-colorBlockOld" ] + [ L.Component $ L.componentPreview [ ClassName "ColorPicker-colorBlockCurrent" ] + , L.Component $ L.componentHistory [ ClassName "ColorPicker-colorBlockOld" ] ] , L.Group [ ClassName "ColorPicker-editing" ] $ editGroups <#> \editGroup → L.Group [ ClassName "ColorPicker-editingItem" ] $ editGroup <#> \mkItem -> L.Component $ mkItem inputClasses , [ ClassName "ColorPicker-actions" ] `L.Group` - [ L.Component $ C.componentSet [ ClassName "ColorPicker-actionSet" ] ] + [ L.Component $ L.componentSet [ ClassName "ColorPicker-actionSet" ] ] ] ] } -inputClasses ∷ C.InputProps C.Classes +inputClasses ∷ L.InputProps L.Classes inputClasses = { root: [ClassName "ColorPicker-input"] , label: [ClassName "ColorPicker-inputLabel"] diff --git a/src/ColorPicker/Halogen/ColorComponents.purs b/src/ColorPicker/Halogen/ColorComponents.purs deleted file mode 100644 index d6ec7ca..0000000 --- a/src/ColorPicker/Halogen/ColorComponents.purs +++ /dev/null @@ -1,453 +0,0 @@ -module ColorPicker.Halogen.ColorComponents - ( ColorComponent(..) - - , NumberComponentView - , TextComponentView - , DragComponentView - , ActionComponentView - - , InputTextValue - , isValid - , isInvalid - - , PositionUpdate - , Dynamic - , PreNumConf - , InputProps - , Classes - , ValueHistory - , mapValueHistory - - , LazyColor - , RecordHSLA - , RecordHSVA - , RecordRGBA - , mkLazyColor - - - , componentHue - , componentSaturationHSL - , componentLightness - , componentSaturationHSV - , componentValue - , componentRed - , componentGreen - , componentBlue - , componentHEX - , componentDragHue - , componentDragSV - , componentPreview - , componentHistory - , componentSet - ) where - -import Prelude - -import CSS as CSS -import Color (Color) -import Color as Color -import Control.MonadZero (guard) -import DOM.Event.Types (FocusEvent, MouseEvent, TouchEvent) -import Data.Array (head, take) -import Data.Int (floor, toNumber) -import Data.Lazy (Lazy, defer, force) -import Data.Maybe (Maybe(..), maybe, maybe') -import Data.String as String -import Halogen as H -import Halogen.HTML as HH -import Halogen.HTML.CSS as HCSS -import Halogen.HTML.Events as HE -import Halogen.HTML.Properties as HP -import Math (round) -import NumberInput.Halogen.Component as Num -import NumberInput.Range (Range(..)) - - -type ValueHistory a = { old ∷ Array a, current ∷ a } - -type InputTextValue = { value ∷ String, isValid ∷ Boolean } - -type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color - -type Dynamic s = LazyColor → s - -type Classes = Array H.ClassName - -type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } - -type LazyColor = - { color :: Color - , hsl :: Lazy RecordHSLA - , hsv :: Lazy RecordHSVA - , rgb :: Lazy RecordRGBA - , isLight :: Lazy Boolean - } - -type InputProps c = - { root ∷ c - , label ∷ c - , elem ∷ c - , elemInvalid ∷ c - } - - -data ColorComponent - = NumberComponentSpec - { update ∷ Number → Dynamic (Maybe Color) - , read ∷ Dynamic Number - , props ∷ Num.Props Number - , view ∷ NumberComponentView - } - | TextComponentSpec - { fromString ∷ String → Maybe Color - , view ∷ TextComponentView - } - | DragComponentSpec - { update ∷ PositionUpdate - , view ∷ DragComponentView - } - | ActionComponentSpec ActionComponentView - -type NumberComponentView = - ∀ p i - . { color :: LazyColor - , input :: HH.HTML p i - } - → Array (HH.HTML p i) - -type TextComponentView = - ∀ p i - . { color :: LazyColor - , value :: Maybe InputTextValue - , onValueInput :: String -> i - , onBlur :: FocusEvent -> i - } - → Array (HH.HTML p i) - -type DragComponentView = - ∀ p i - . { color:: LazyColor - , onMouseDown :: MouseEvent -> i - , onTouchStart :: TouchEvent -> i - } - → Array (HH.HTML p i) - -type ActionComponentView = - ∀ p i - . { color ∷ ValueHistory LazyColor - , setColor ∷ Color → i - , commit ∷ i - } - → Array (HH.HTML p i) - -mapValueHistory :: ∀ a b. (a -> b) -> ValueHistory a -> ValueHistory b -mapValueHistory f { current, old } = { current: f current, old: map f old } - -mkLazyColor :: Color -> LazyColor -mkLazyColor color = - { color - , hsl: defer \_ -> Color.toHSLA color - , hsv: defer \_ -> Color.toHSVA color - , rgb: defer \_ -> Color.toRGBA color - , isLight: defer \_ -> Color.isLight color - } - - -componentPreview ∷ Array H.ClassName -> ColorComponent -componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ - HH.div - [ HP.classes $ classes - , HP.title "Current value" - , HCSS.style $ CSS.backgroundColor color.current.color - ] [] - -componentHistory ∷ Array H.ClassName -> ColorComponent -componentHistory classes = ActionComponentSpec \{ color , setColor } → - take 4 color.old <#> \c -> - HH.div - [ HP.tabIndex 0 - , HP.classes $ classes - , HP.title "Old value" - , HE.onClick $ (\_ → Just $ setColor c.color) - , HCSS.style $ CSS.backgroundColor c.color - ] [] - - -componentSet ∷ Array H.ClassName -> ColorComponent -componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } → pure $ - HH.button - [ HP.classes classes - , HE.onClick $ const $ Just commit - , HP.disabled $ Just current.color == (map _.color $ head old) - ] - [ HH.text "Set" ] - -componentDragSV ∷ - { isLight ∷ Array H.ClassName - , isDark ∷ Array H.ClassName - , root ∷ Array H.ClassName - , selector ∷ Array H.ClassName - } - → ColorComponent -componentDragSV classes = DragComponentSpec - { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} - , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ - HH.div - [ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark - , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 - , HE.onTouchStart $ onTouchStart >>> Just - , HE.onMouseDown $ onMouseDown >>> Just - ] - [ HH.div - [ HP.classes classes.selector - , HCSS.style do - CSS.left $ CSS.pct ((force hsv).s * 100.0) - CSS.bottom $ CSS.pct ((force hsv).v * 100.0) - CSS.backgroundColor color - ] - [] - ] - } - - -componentDragHue ∷ - { root ∷ Array H.ClassName - , selector ∷ Array H.ClassName - } - → ColorComponent -componentDragHue classes = DragComponentSpec - { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } - , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ - HH.div - [ HP.classes classes.root - , HE.onTouchStart $ onTouchStart >>> Just - , HE.onMouseDown $ onMouseDown >>> Just - ] - [ HH.div - [ HP.classes classes.selector - , HCSS.style $ CSS.top $ CSS.pct ((1.0 - (force hsv).h / 360.0) * 100.0) - ] - [] - ] - } - -mkNumComponent - :: (Number -> Dynamic (Maybe Color)) - -> Dynamic Number - -> InputProps Classes - -> PreNumConf - -> ColorComponent -mkNumComponent update read classes conf = NumberComponentSpec - { update - , read - , props: - { title: conf.title - , hasNumberValue: hasValRound - , placeholder: conf.placeholder - , range: conf.range - , root: classes.elem - , rootInvalid: classes.elemInvalid - , rootLength: const [] - } - , view: \ {input} -> pure $ renderInput - { root: classes.root - , label: classes.label - , prefix: conf.prefix - , child: input - } - } - - -componentHue ∷ InputProps Classes → ColorComponent -componentHue classes = mkNumComponent - (\n → Just <<< modifyHSL (_{h = n})) - (\({rgb, hsv, hsl}) → roundFractionalNum (force hsl).h) - classes - confHue - - -componentSaturationHSL ∷ InputProps Classes → ColorComponent -componentSaturationHSL classes = mkNumComponent - (\n → Just <<< modifyHSL (_{s = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).s) - classes - confSaturation - -componentLightness ∷ InputProps Classes → ColorComponent -componentLightness classes = mkNumComponent - (\n → Just <<< modifyHSL (_{l = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).l) - classes - confLightness - -componentSaturationHSV ∷ InputProps Classes → ColorComponent -componentSaturationHSV classes = mkNumComponent - (\n → Just <<< modifyHSV (_{s = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).s) - classes - confSaturation - - -componentValue ∷ InputProps Classes → ColorComponent -componentValue classes = mkNumComponent - (\n → Just <<< modifyHSV (_{v = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).v) - classes - confValue - -componentRed ∷ InputProps Classes → ColorComponent -componentRed classes = mkNumComponent - (\n → Just <<< modifyRGB (_{r = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).r) - classes - confRed - -componentGreen ∷ InputProps Classes → ColorComponent -componentGreen classes = mkNumComponent - (\n → Just <<< modifyRGB (_{g = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).g) - classes - confGreen - -componentBlue ∷ InputProps Classes → ColorComponent -componentBlue classes = mkNumComponent - (\n → Just <<< modifyRGB (_{b = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).b) - classes - confBlue - -componentHEX ∷ InputProps Classes → ColorComponent -componentHEX classes = TextComponentSpec - { fromString: \str → Color.fromHexString $ "#" <> str - , view: \{color, value, onValueInput, onBlur} -> pure $ - renderInput - { root: classes.root - , label: classes.label - , prefix: "#" - , child: HH.input $ - [ HP.type_ HP.InputText - , HP.classes - $ classes.elem - <> (guard (isInvalid value) *> (classes.elemInvalid)) - , HP.title "Hex" - , HP.value $ maybe' (\_ -> toString color) _.value value - , HP.placeholder "Hex" - , HE.onValueInput $ onValueInput >>> Just - , HE.onBlur $ onBlur >>> Just - ] - } - } - where - toString = \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color - - -isValid :: Maybe InputTextValue -> Boolean -isValid = maybe true _.isValid - -isInvalid :: Maybe InputTextValue -> Boolean -isInvalid = not isValid - -renderInput :: ∀ i p. - { child :: HH.HTML i p - , prefix :: String - , label :: Classes - , root :: Classes - } - -> HH.HTML i p -renderInput {root, label, prefix, child} = - HH.label - [ HP.classes root] - [ HH.span [HP.classes label] [HH.text prefix] - , child - ] - - --- Internal helpers - - -confRed ∷ PreNumConf -confRed = - { title: "Red" - , placeholder: "R" - , prefix: "R" - , range: MinMax 0.0 256.0 - } - -confGreen ∷ PreNumConf -confGreen = - { title: "Green" - , placeholder: "G" - , prefix: "G" - , range: MinMax 0.0 256.0 - } - -confBlue ∷ PreNumConf -confBlue = - { title: "Blue" - , placeholder: "B" - , prefix: "B" - , range: MinMax 0.0 256.0 - } - -confHue ∷ PreNumConf -confHue = - { title: "Hue" - , placeholder: "H" - , prefix: "H" - , range: MinMax 0.0 360.0 - } -confSaturation ∷ PreNumConf -confSaturation = - { title: "Saturation" - , placeholder: "S" - , prefix: "S" - , range: MinMax 0.0 100.0 - } -confLightness ∷ PreNumConf -confLightness = - { title: "Lightness" - , placeholder: "L" - , prefix: "L" - , range: MinMax 0.0 100.0 - } - -confValue ∷ PreNumConf -confValue = - { title: "Value" - , placeholder: "V" - , prefix: "V" - , range: MinMax 0.0 100.0 - } - - -hasValRound ∷ Num.HasNumberInputValue Number -hasValRound = Num.numberHasNumberInputValue - {fromString = Num.numberHasNumberInputValue.fromString >>> map roundFractionalNum} - -hasValCail ∷ Num.HasNumberInputValue Number -hasValCail = Num.numberHasNumberInputValue - {fromString = Num.numberHasNumberInputValue.fromString >>> map roundNum} - -roundFractionalNum ∷ Number → Number -roundFractionalNum n = roundNum (n * scalar) / scalar - where - scalar = 100.0 - -asInt ∷ Number → Int -asInt = floor - -roundNum ∷ Number → Number -roundNum = round - -type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } -type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } -type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } - -modifyHSL ∷ (RecordHSLA → RecordHSLA) → Dynamic Color -modifyHSL f { hsl } = let {h, s, l, a} = f (force hsl) in Color.hsla h s l a - -modifyHSV ∷ (RecordHSVA → RecordHSVA) → Dynamic Color -modifyHSV f { hsv } = let {h, s, v, a} = f (force hsv) in Color.hsva h s v a - -modifyRGB ∷ (RecordRGBA → RecordRGBA) → Dynamic Color -modifyRGB f { rgb } = let {r, g, b, a} = f (force rgb) in Color.rgba r g b a diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index e7129c4..2ceaf84 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -11,8 +11,7 @@ import Prelude import Color (Color) import Color as Color -import ColorPicker.Halogen.ColorComponents (ColorComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mapValueHistory, mkLazyColor) -import ColorPicker.Halogen.Layout as L +import ColorPicker.Halogen.Layout (Layout(..), ChildLayout(..), ColorComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mapValueHistory, mkLazyColor) import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) @@ -45,7 +44,7 @@ data Message = NextChange Color | NotifyChange Color type Props = - { layout ∷ L.Layout + { layout ∷ Layout } @@ -94,20 +93,20 @@ picker = H.lifecycleParentComponent render ∷ ∀ m. State → HTML m render state = - let L.Root classes children = state.props.layout + let Root classes children = state.props.layout in HH.div [HP.classes classes] $ fold $ mapWithIndex (\idx -> renderLayout state $ List.Cons idx List.Nil) children -renderLayout ∷ ∀ m. State → Cursor → L.ChildLayout → Array (HTML m) +renderLayout ∷ ∀ m. State → Cursor → ChildLayout → Array (HTML m) renderLayout state@{ color, inputValues, props} cursor = case _ of - L.Group classes l → pure $ + Group classes l → pure $ HH.div [ HP.classes classes ] $ fold $ mapWithIndex (\idx → renderLayout state (List.Cons idx cursor)) l - L.Component c → case c of + Component c → case c of ActionComponentSpec view → view { color , setColor: H.action <<< UpdateCurrentColor @@ -156,7 +155,7 @@ eval = case _ of NumberComponentUpdate cursor num next → do state ← H.get case focus cursor state.props.layout of - Just (L.Component (NumberComponentSpec { update })) → + Just (Component (NumberComponentSpec { update })) → for_ (update <$> num >>= (_ $ state.color.current)) $ updateColor state _ → pure unit pure next @@ -213,13 +212,13 @@ propagate = do List.Nil layout where - propagateLayout ∷ LazyColor → Cursor → L.Layout → DSL m Unit + propagateLayout ∷ LazyColor → Cursor → Layout → DSL m Unit propagateLayout color cursor = case _ of - L.Root _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l - propagateChildLayout ∷ LazyColor → Cursor → L.ChildLayout → DSL m Unit + Root _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l + propagateChildLayout ∷ LazyColor → Cursor → ChildLayout → DSL m Unit propagateChildLayout color cursor = case _ of - L.Group _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l - L.Component c → case c of + Group _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l + Component c → case c of DragComponentSpec _ → pure unit TextComponentSpec _ → pure unit ActionComponentSpec _ → pure unit @@ -232,11 +231,11 @@ mustBeMounted _ = halt "children must be mounted" type Cursor = List.List Int -focus :: Cursor → L.Layout → Maybe L.ChildLayout +focus :: Cursor → Layout → Maybe ChildLayout focus cursor layout = - let L.Root x children = layout - in foldr f (Just $ L.Group x children) cursor + let Root x children = layout + in foldr f (Just $ Group x children) cursor where f idx = case _ of - Just (L.Group _ l) → index l idx + Just (Group _ l) → index l idx _ → Nothing diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 80fee5c..0da6f02 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -1,11 +1,461 @@ -module ColorPicker.Halogen.Layout where +module ColorPicker.Halogen.Layout + ( Layout(..) + , ChildLayout(..) + , ColorComponent(..) + , NumberComponentView + , TextComponentView + , DragComponentView + , ActionComponentView -import ColorPicker.Halogen.ColorComponents (ColorComponent) -import Halogen (ClassName) + , InputTextValue + , isValid + , isInvalid -data Layout = Root (Array ClassName) (Array ChildLayout) + , PositionUpdate + , Dynamic + , PreNumConf + , InputProps + , Classes + , ValueHistory + , mapValueHistory + + , LazyColor + , RecordHSLA + , RecordHSVA + , RecordRGBA + , mkLazyColor + + + , componentHue + , componentSaturationHSL + , componentLightness + , componentSaturationHSV + , componentValue + , componentRed + , componentGreen + , componentBlue + , componentHEX + , componentDragHue + , componentDragSV + , componentPreview + , componentHistory + , componentSet + ) where + +import Prelude + +import CSS as CSS +import Color (Color) +import Color as Color +import Control.MonadZero (guard) +import DOM.Event.Types (FocusEvent, MouseEvent, TouchEvent) +import Data.Array (head, take) +import Data.Int (floor, toNumber) +import Data.Lazy (Lazy, defer, force) +import Data.Maybe (Maybe(..), maybe, maybe') +import Data.String as String +import Halogen as H +import Halogen.HTML as HH +import Halogen.HTML.CSS as HCSS +import Halogen.HTML.Events as HE +import Halogen.HTML.Properties as HP +import Math (round) +import NumberInput.Halogen.Component as Num +import NumberInput.Range (Range(..)) + +data Layout = Root (Array H.ClassName) (Array ChildLayout) data ChildLayout - = Group (Array ClassName) (Array ChildLayout) + = Group (Array H.ClassName) (Array ChildLayout) | Component ColorComponent + + +type ValueHistory a = { old ∷ Array a, current ∷ a } + +type InputTextValue = { value ∷ String, isValid ∷ Boolean } + +type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color + +type Dynamic s = LazyColor → s + +type Classes = Array H.ClassName + +type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } + +type LazyColor = + { color :: Color + , hsl :: Lazy RecordHSLA + , hsv :: Lazy RecordHSVA + , rgb :: Lazy RecordRGBA + , isLight :: Lazy Boolean + } + +type InputProps c = + { root ∷ c + , label ∷ c + , elem ∷ c + , elemInvalid ∷ c + } + + +data ColorComponent + = NumberComponentSpec + { update ∷ Number → Dynamic (Maybe Color) + , read ∷ Dynamic Number + , props ∷ Num.Props Number + , view ∷ NumberComponentView + } + | TextComponentSpec + { fromString ∷ String → Maybe Color + , view ∷ TextComponentView + } + | DragComponentSpec + { update ∷ PositionUpdate + , view ∷ DragComponentView + } + | ActionComponentSpec ActionComponentView + +type NumberComponentView = + ∀ p i + . { color :: LazyColor + , input :: HH.HTML p i + } + → Array (HH.HTML p i) + +type TextComponentView = + ∀ p i + . { color :: LazyColor + , value :: Maybe InputTextValue + , onValueInput :: String -> i + , onBlur :: FocusEvent -> i + } + → Array (HH.HTML p i) + +type DragComponentView = + ∀ p i + . { color:: LazyColor + , onMouseDown :: MouseEvent -> i + , onTouchStart :: TouchEvent -> i + } + → Array (HH.HTML p i) + +type ActionComponentView = + ∀ p i + . { color ∷ ValueHistory LazyColor + , setColor ∷ Color → i + , commit ∷ i + } + → Array (HH.HTML p i) + +mapValueHistory :: ∀ a b. (a -> b) -> ValueHistory a -> ValueHistory b +mapValueHistory f { current, old } = { current: f current, old: map f old } + +mkLazyColor :: Color -> LazyColor +mkLazyColor color = + { color + , hsl: defer \_ -> Color.toHSLA color + , hsv: defer \_ -> Color.toHSVA color + , rgb: defer \_ -> Color.toRGBA color + , isLight: defer \_ -> Color.isLight color + } + + +componentPreview ∷ Array H.ClassName -> ColorComponent +componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ + HH.div + [ HP.classes $ classes + , HP.title "Current value" + , HCSS.style $ CSS.backgroundColor color.current.color + ] [] + +componentHistory ∷ Array H.ClassName -> ColorComponent +componentHistory classes = ActionComponentSpec \{ color , setColor } → + take 4 color.old <#> \c -> + HH.div + [ HP.tabIndex 0 + , HP.classes $ classes + , HP.title "Old value" + , HE.onClick $ (\_ → Just $ setColor c.color) + , HCSS.style $ CSS.backgroundColor c.color + ] [] + + +componentSet ∷ Array H.ClassName -> ColorComponent +componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } → pure $ + HH.button + [ HP.classes classes + , HE.onClick $ const $ Just commit + , HP.disabled $ Just current.color == (map _.color $ head old) + ] + [ HH.text "Set" ] + +componentDragSV ∷ + { isLight ∷ Array H.ClassName + , isDark ∷ Array H.ClassName + , root ∷ Array H.ClassName + , selector ∷ Array H.ClassName + } + → ColorComponent +componentDragSV classes = DragComponentSpec + { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} + , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ + HH.div + [ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark + , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 + , HE.onTouchStart $ onTouchStart >>> Just + , HE.onMouseDown $ onMouseDown >>> Just + ] + [ HH.div + [ HP.classes classes.selector + , HCSS.style do + CSS.left $ CSS.pct ((force hsv).s * 100.0) + CSS.bottom $ CSS.pct ((force hsv).v * 100.0) + CSS.backgroundColor color + ] + [] + ] + } + + +componentDragHue ∷ + { root ∷ Array H.ClassName + , selector ∷ Array H.ClassName + } + → ColorComponent +componentDragHue classes = DragComponentSpec + { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } + , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ + HH.div + [ HP.classes classes.root + , HE.onTouchStart $ onTouchStart >>> Just + , HE.onMouseDown $ onMouseDown >>> Just + ] + [ HH.div + [ HP.classes classes.selector + , HCSS.style $ CSS.top $ CSS.pct ((1.0 - (force hsv).h / 360.0) * 100.0) + ] + [] + ] + } + +mkNumComponent + :: (Number -> Dynamic (Maybe Color)) + -> Dynamic Number + -> InputProps Classes + -> PreNumConf + -> ColorComponent +mkNumComponent update read classes conf = NumberComponentSpec + { update + , read + , props: + { title: conf.title + , hasNumberValue: hasValRound + , placeholder: conf.placeholder + , range: conf.range + , root: classes.elem + , rootInvalid: classes.elemInvalid + , rootLength: const [] + } + , view: \ {input} -> pure $ renderInput + { root: classes.root + , label: classes.label + , prefix: conf.prefix + , child: input + } + } + + +componentHue ∷ InputProps Classes → ColorComponent +componentHue classes = mkNumComponent + (\n → Just <<< modifyHSL (_{h = n})) + (\({rgb, hsv, hsl}) → roundFractionalNum (force hsl).h) + classes + confHue + + +componentSaturationHSL ∷ InputProps Classes → ColorComponent +componentSaturationHSL classes = mkNumComponent + (\n → Just <<< modifyHSL (_{s = n / 100.0})) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).s) + classes + confSaturation + +componentLightness ∷ InputProps Classes → ColorComponent +componentLightness classes = mkNumComponent + (\n → Just <<< modifyHSL (_{l = n / 100.0})) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).l) + classes + confLightness + +componentSaturationHSV ∷ InputProps Classes → ColorComponent +componentSaturationHSV classes = mkNumComponent + (\n → Just <<< modifyHSV (_{s = n / 100.0})) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).s) + classes + confSaturation + + +componentValue ∷ InputProps Classes → ColorComponent +componentValue classes = mkNumComponent + (\n → Just <<< modifyHSV (_{v = n / 100.0})) + (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).v) + classes + confValue + +componentRed ∷ InputProps Classes → ColorComponent +componentRed classes = mkNumComponent + (\n → Just <<< modifyRGB (_{r = asInt n})) + (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).r) + classes + confRed + +componentGreen ∷ InputProps Classes → ColorComponent +componentGreen classes = mkNumComponent + (\n → Just <<< modifyRGB (_{g = asInt n})) + (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).g) + classes + confGreen + +componentBlue ∷ InputProps Classes → ColorComponent +componentBlue classes = mkNumComponent + (\n → Just <<< modifyRGB (_{b = asInt n})) + (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).b) + classes + confBlue + +componentHEX ∷ InputProps Classes → ColorComponent +componentHEX classes = TextComponentSpec + { fromString: \str → Color.fromHexString $ "#" <> str + , view: \{color, value, onValueInput, onBlur} -> pure $ + renderInput + { root: classes.root + , label: classes.label + , prefix: "#" + , child: HH.input $ + [ HP.type_ HP.InputText + , HP.classes + $ classes.elem + <> (guard (isInvalid value) *> (classes.elemInvalid)) + , HP.title "Hex" + , HP.value $ maybe' (\_ -> toString color) _.value value + , HP.placeholder "Hex" + , HE.onValueInput $ onValueInput >>> Just + , HE.onBlur $ onBlur >>> Just + ] + } + } + where + toString = \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color + + +isValid :: Maybe InputTextValue -> Boolean +isValid = maybe true _.isValid + +isInvalid :: Maybe InputTextValue -> Boolean +isInvalid = not isValid + +renderInput :: ∀ i p. + { child :: HH.HTML i p + , prefix :: String + , label :: Classes + , root :: Classes + } + -> HH.HTML i p +renderInput {root, label, prefix, child} = + HH.label + [ HP.classes root] + [ HH.span [HP.classes label] [HH.text prefix] + , child + ] + + +-- Internal helpers + + +confRed ∷ PreNumConf +confRed = + { title: "Red" + , placeholder: "R" + , prefix: "R" + , range: MinMax 0.0 256.0 + } + +confGreen ∷ PreNumConf +confGreen = + { title: "Green" + , placeholder: "G" + , prefix: "G" + , range: MinMax 0.0 256.0 + } + +confBlue ∷ PreNumConf +confBlue = + { title: "Blue" + , placeholder: "B" + , prefix: "B" + , range: MinMax 0.0 256.0 + } + +confHue ∷ PreNumConf +confHue = + { title: "Hue" + , placeholder: "H" + , prefix: "H" + , range: MinMax 0.0 360.0 + } +confSaturation ∷ PreNumConf +confSaturation = + { title: "Saturation" + , placeholder: "S" + , prefix: "S" + , range: MinMax 0.0 100.0 + } +confLightness ∷ PreNumConf +confLightness = + { title: "Lightness" + , placeholder: "L" + , prefix: "L" + , range: MinMax 0.0 100.0 + } + +confValue ∷ PreNumConf +confValue = + { title: "Value" + , placeholder: "V" + , prefix: "V" + , range: MinMax 0.0 100.0 + } + + +hasValRound ∷ Num.HasNumberInputValue Number +hasValRound = Num.numberHasNumberInputValue + {fromString = Num.numberHasNumberInputValue.fromString >>> map roundFractionalNum} + +hasValCail ∷ Num.HasNumberInputValue Number +hasValCail = Num.numberHasNumberInputValue + {fromString = Num.numberHasNumberInputValue.fromString >>> map roundNum} + +roundFractionalNum ∷ Number → Number +roundFractionalNum n = roundNum (n * scalar) / scalar + where + scalar = 100.0 + +asInt ∷ Number → Int +asInt = floor + +roundNum ∷ Number → Number +roundNum = round + +type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } +type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } +type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } + +modifyHSL ∷ (RecordHSLA → RecordHSLA) → Dynamic Color +modifyHSL f { hsl } = let {h, s, l, a} = f (force hsl) in Color.hsla h s l a + +modifyHSV ∷ (RecordHSVA → RecordHSVA) → Dynamic Color +modifyHSV f { hsv } = let {h, s, v, a} = f (force hsv) in Color.hsva h s v a + +modifyRGB ∷ (RecordRGBA → RecordRGBA) → Dynamic Color +modifyRGB f { rgb } = let {r, g, b, a} = f (force rgb) in Color.rgba r g b a From 60fef5e77e91ace67bfb6ddf29c7ee4b4b63d751 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:25:25 +0200 Subject: [PATCH 48/72] remove isLight from LazyColor --- src/ColorPicker/Halogen/Layout.purs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 0da6f02..1de2f74 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -88,7 +88,6 @@ type LazyColor = , hsl :: Lazy RecordHSLA , hsv :: Lazy RecordHSVA , rgb :: Lazy RecordRGBA - , isLight :: Lazy Boolean } type InputProps c = @@ -157,7 +156,6 @@ mkLazyColor color = , hsl: defer \_ -> Color.toHSLA color , hsv: defer \_ -> Color.toHSVA color , rgb: defer \_ -> Color.toRGBA color - , isLight: defer \_ -> Color.isLight color } @@ -199,9 +197,9 @@ componentDragSV ∷ → ColorComponent componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} - , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ + , view: \{color: {hsv, color}, onMouseDown, onTouchStart} -> pure $ HH.div - [ HP.classes $ classes.root <> if (force isLight) then classes.isLight else classes.isDark + [ HP.classes $ classes.root <> if Color.isLight color then classes.isLight else classes.isDark , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 , HE.onTouchStart $ onTouchStart >>> Just , HE.onMouseDown $ onMouseDown >>> Just @@ -225,7 +223,7 @@ componentDragHue ∷ → ColorComponent componentDragHue classes = DragComponentSpec { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } - , view: \{color: {isLight, hsv, color}, onMouseDown, onTouchStart} -> pure $ + , view: \{color: {hsv, color}, onMouseDown, onTouchStart} -> pure $ HH.div [ HP.classes classes.root , HE.onTouchStart $ onTouchStart >>> Just From 81b0d76b762e26792b47be04d448e9686b380e80 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:31:39 +0200 Subject: [PATCH 49/72] refactor examples --- example/src/Main.purs | 97 +++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 0315970..2c55841 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -14,7 +14,6 @@ import Data.Functor.Coproduct.Nested as Coproduct import Data.Map (Map, insert, lookup) import Data.Maybe (Maybe(..), maybe') import Data.Monoid (mempty) -import Halogen (ClassName(..)) import Halogen as H import Halogen.Aff as HA import Halogen.Component.ChildPath as CP @@ -82,17 +81,19 @@ eval (HandleMsg idx msg next) = do _, CPicker.NotifyChange x → {next: x, current: x} config0 ∷ CPicker.Props -config0 = mkConf reverse - (ClassName "ColorPicker--small") - [ [ L.componentHue - , L.componentSaturationHSL - , L.componentLightness +config0 = mkConf $ L.Root c $ reverse l + where + L.Root c l = mkLayout + (H.ClassName "ColorPicker--small") + [ [ L.componentHue + , L.componentSaturationHSL + , L.componentLightness + ] ] - ] config1 ∷ CPicker.Props -config1 = mkConf id - (ClassName "ColorPicker--large") +config1 = mkConf $ mkLayout + (H.ClassName "ColorPicker--large") [ [ L.componentHue , L.componentSaturationHSV , L.componentValue @@ -107,8 +108,8 @@ config1 = mkConf id ] config2 ∷ CPicker.Props -config2 = mkConf id - (ClassName "ColorPicker--small") +config2 = mkConf $ mkLayout + (H.ClassName "ColorPicker--small") [ [ const componentRedORNoRed ]] componentRedORNoRed ∷ L.ColorComponent @@ -136,47 +137,45 @@ componentRedORNoRed = L.TextComponentSpec toString = \{color} → if color == red then "red" else "noRed" +mkConf :: L.Layout -> CPicker.Props +mkConf = { layout: _ } - -mkConf - ∷ (∀ a. Array a → Array a) - → ClassName +mkLayout + ∷ H.ClassName → Array (Array (L.InputProps L.Classes → L.ColorComponent)) - → CPicker.Props -mkConf reverse' root editGroups = - { layout: - L.Root [ ClassName "ColorPicker", root ] $ reverse' - [ [ ClassName "ColorPicker-dragger" ] `L.Group` - [ L.Component $ L.componentDragSV - { root: [ ClassName "ColorPicker-field" ] - , isLight: [ ClassName "IsLight" ] - , isDark: [ ClassName "IsDark" ] - , selector: [ ClassName "ColorPicker-fieldSelector"] - } - , L.Component $ L.componentDragHue - { root: [ ClassName "ColorPicker-slider" ] - , selector: [ ClassName "ColorPicker-sliderSelector"] - } - ] - , [ ClassName "ColorPicker-aside" ] `L.Group` - [ [ ClassName "ColorPicker-stage" ] `L.Group` - [ L.Component $ L.componentPreview [ ClassName "ColorPicker-colorBlockCurrent" ] - , L.Component $ L.componentHistory [ ClassName "ColorPicker-colorBlockOld" ] - ] - , L.Group [ ClassName "ColorPicker-editing" ] $ - editGroups <#> \editGroup → - L.Group [ ClassName "ColorPicker-editingItem" ] $ - editGroup <#> \mkItem -> L.Component $ mkItem inputClasses - , [ ClassName "ColorPicker-actions" ] `L.Group` - [ L.Component $ L.componentSet [ ClassName "ColorPicker-actionSet" ] ] - ] - ] - } + → L.Layout +mkLayout root editGroups = + [ H.ClassName "ColorPicker", root ] `L.Root` + [ [ H.ClassName "ColorPicker-dragger" ] `L.Group` + [ L.Component $ L.componentDragSV + { root: [ H.ClassName "ColorPicker-field" ] + , isLight: [ H.ClassName "IsLight" ] + , isDark: [ H.ClassName "IsDark" ] + , selector: [ H.ClassName "ColorPicker-fieldSelector"] + } + , L.Component $ L.componentDragHue + { root: [ H.ClassName "ColorPicker-slider" ] + , selector: [ H.ClassName "ColorPicker-sliderSelector"] + } + ] + , [ H.ClassName "ColorPicker-aside" ] `L.Group` + [ [ H.ClassName "ColorPicker-stage" ] `L.Group` + [ L.Component $ L.componentPreview [ H.ClassName "ColorPicker-colorBlockCurrent" ] + , L.Component $ L.componentHistory [ H.ClassName "ColorPicker-colorBlockOld" ] + ] + , L.Group [ H.ClassName "ColorPicker-editing" ] $ + editGroups <#> \editGroup → + L.Group [ H.ClassName "ColorPicker-editingItem" ] $ + editGroup <#> \mkItem -> L.Component $ mkItem inputClasses + , [ H.ClassName "ColorPicker-actions" ] `L.Group` + [ L.Component $ L.componentSet [ H.ClassName "ColorPicker-actionSet" ] ] + ] + ] inputClasses ∷ L.InputProps L.Classes inputClasses = - { root: [ClassName "ColorPicker-input"] - , label: [ClassName "ColorPicker-inputLabel"] - , elem: [ClassName "ColorPicker-inputElem"] - , elemInvalid: [ClassName "ColorPicker-inputElem--invalid"] + { root: [H.ClassName "ColorPicker-input"] + , label: [H.ClassName "ColorPicker-inputLabel"] + , elem: [H.ClassName "ColorPicker-inputElem"] + , elemInvalid: [H.ClassName "ColorPicker-inputElem--invalid"] } From aa03770f1752a3750f534c6e0191e668d3c56f82 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:31:57 +0200 Subject: [PATCH 50/72] ColorComponent to PickerComponent --- example/src/Main.purs | 4 +-- src/ColorPicker/Halogen/Component.purs | 2 +- src/ColorPicker/Halogen/Layout.purs | 36 +++++++++++++------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 2c55841..fcd4af8 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -112,7 +112,7 @@ config2 = mkConf $ mkLayout (H.ClassName "ColorPicker--small") [ [ const componentRedORNoRed ]] -componentRedORNoRed ∷ L.ColorComponent +componentRedORNoRed ∷ L.PickerComponent componentRedORNoRed = L.TextComponentSpec { fromString: \str → if str == "red" then Just (red) else Nothing , view: \{color, value, onBlur, onValueInput } -> pure $ @@ -142,7 +142,7 @@ mkConf = { layout: _ } mkLayout ∷ H.ClassName - → Array (Array (L.InputProps L.Classes → L.ColorComponent)) + → Array (Array (L.InputProps L.Classes → L.PickerComponent)) → L.Layout mkLayout root editGroups = [ H.ClassName "ColorPicker", root ] `L.Root` diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 2ceaf84..b2972b7 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -11,7 +11,7 @@ import Prelude import Color (Color) import Color as Color -import ColorPicker.Halogen.Layout (Layout(..), ChildLayout(..), ColorComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mapValueHistory, mkLazyColor) +import ColorPicker.Halogen.Layout (Layout(..), ChildLayout(..), PickerComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mapValueHistory, mkLazyColor) import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 1de2f74..5f17df0 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -1,7 +1,7 @@ module ColorPicker.Halogen.Layout ( Layout(..) , ChildLayout(..) - , ColorComponent(..) + , PickerComponent(..) , NumberComponentView , TextComponentView @@ -68,7 +68,7 @@ data Layout = Root (Array H.ClassName) (Array ChildLayout) data ChildLayout = Group (Array H.ClassName) (Array ChildLayout) - | Component ColorComponent + | Component PickerComponent type ValueHistory a = { old ∷ Array a, current ∷ a } @@ -98,7 +98,7 @@ type InputProps c = } -data ColorComponent +data PickerComponent = NumberComponentSpec { update ∷ Number → Dynamic (Maybe Color) , read ∷ Dynamic Number @@ -159,7 +159,7 @@ mkLazyColor color = } -componentPreview ∷ Array H.ClassName -> ColorComponent +componentPreview ∷ Array H.ClassName -> PickerComponent componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ HH.div [ HP.classes $ classes @@ -167,7 +167,7 @@ componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ , HCSS.style $ CSS.backgroundColor color.current.color ] [] -componentHistory ∷ Array H.ClassName -> ColorComponent +componentHistory ∷ Array H.ClassName -> PickerComponent componentHistory classes = ActionComponentSpec \{ color , setColor } → take 4 color.old <#> \c -> HH.div @@ -179,7 +179,7 @@ componentHistory classes = ActionComponentSpec \{ color , setColor } → ] [] -componentSet ∷ Array H.ClassName -> ColorComponent +componentSet ∷ Array H.ClassName -> PickerComponent componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } → pure $ HH.button [ HP.classes classes @@ -194,7 +194,7 @@ componentDragSV ∷ , root ∷ Array H.ClassName , selector ∷ Array H.ClassName } - → ColorComponent + → PickerComponent componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} , view: \{color: {hsv, color}, onMouseDown, onTouchStart} -> pure $ @@ -220,7 +220,7 @@ componentDragHue ∷ { root ∷ Array H.ClassName , selector ∷ Array H.ClassName } - → ColorComponent + → PickerComponent componentDragHue classes = DragComponentSpec { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } , view: \{color: {hsv, color}, onMouseDown, onTouchStart} -> pure $ @@ -242,7 +242,7 @@ mkNumComponent -> Dynamic Number -> InputProps Classes -> PreNumConf - -> ColorComponent + -> PickerComponent mkNumComponent update read classes conf = NumberComponentSpec { update , read @@ -264,7 +264,7 @@ mkNumComponent update read classes conf = NumberComponentSpec } -componentHue ∷ InputProps Classes → ColorComponent +componentHue ∷ InputProps Classes → PickerComponent componentHue classes = mkNumComponent (\n → Just <<< modifyHSL (_{h = n})) (\({rgb, hsv, hsl}) → roundFractionalNum (force hsl).h) @@ -272,21 +272,21 @@ componentHue classes = mkNumComponent confHue -componentSaturationHSL ∷ InputProps Classes → ColorComponent +componentSaturationHSL ∷ InputProps Classes → PickerComponent componentSaturationHSL classes = mkNumComponent (\n → Just <<< modifyHSL (_{s = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).s) classes confSaturation -componentLightness ∷ InputProps Classes → ColorComponent +componentLightness ∷ InputProps Classes → PickerComponent componentLightness classes = mkNumComponent (\n → Just <<< modifyHSL (_{l = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).l) classes confLightness -componentSaturationHSV ∷ InputProps Classes → ColorComponent +componentSaturationHSV ∷ InputProps Classes → PickerComponent componentSaturationHSV classes = mkNumComponent (\n → Just <<< modifyHSV (_{s = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).s) @@ -294,35 +294,35 @@ componentSaturationHSV classes = mkNumComponent confSaturation -componentValue ∷ InputProps Classes → ColorComponent +componentValue ∷ InputProps Classes → PickerComponent componentValue classes = mkNumComponent (\n → Just <<< modifyHSV (_{v = n / 100.0})) (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).v) classes confValue -componentRed ∷ InputProps Classes → ColorComponent +componentRed ∷ InputProps Classes → PickerComponent componentRed classes = mkNumComponent (\n → Just <<< modifyRGB (_{r = asInt n})) (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).r) classes confRed -componentGreen ∷ InputProps Classes → ColorComponent +componentGreen ∷ InputProps Classes → PickerComponent componentGreen classes = mkNumComponent (\n → Just <<< modifyRGB (_{g = asInt n})) (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).g) classes confGreen -componentBlue ∷ InputProps Classes → ColorComponent +componentBlue ∷ InputProps Classes → PickerComponent componentBlue classes = mkNumComponent (\n → Just <<< modifyRGB (_{b = asInt n})) (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).b) classes confBlue -componentHEX ∷ InputProps Classes → ColorComponent +componentHEX ∷ InputProps Classes → PickerComponent componentHEX classes = TextComponentSpec { fromString: \str → Color.fromHexString $ "#" <> str , view: \{color, value, onValueInput, onBlur} -> pure $ From 0ad19683db3ca0adb45cd8cb258cd57d8429dc5f Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:33:15 +0200 Subject: [PATCH 51/72] update componentHistory --- example/src/Main.purs | 2 +- src/ColorPicker/Halogen/Layout.purs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index fcd4af8..8e84199 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -161,7 +161,7 @@ mkLayout root editGroups = , [ H.ClassName "ColorPicker-aside" ] `L.Group` [ [ H.ClassName "ColorPicker-stage" ] `L.Group` [ L.Component $ L.componentPreview [ H.ClassName "ColorPicker-colorBlockCurrent" ] - , L.Component $ L.componentHistory [ H.ClassName "ColorPicker-colorBlockOld" ] + , L.Component $ L.componentHistory 4 [ H.ClassName "ColorPicker-colorBlockOld" ] ] , L.Group [ H.ClassName "ColorPicker-editing" ] $ editGroups <#> \editGroup → diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 5f17df0..a24fd1d 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -167,9 +167,9 @@ componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ , HCSS.style $ CSS.backgroundColor color.current.color ] [] -componentHistory ∷ Array H.ClassName -> PickerComponent -componentHistory classes = ActionComponentSpec \{ color , setColor } → - take 4 color.old <#> \c -> +componentHistory ∷ Int -> Array H.ClassName -> PickerComponent +componentHistory historySize classes = ActionComponentSpec \{ color , setColor } → + take historySize color.old <#> \c -> HH.div [ HP.tabIndex 0 , HP.classes $ classes From e3f5e3efdfb0280f64c88f0dbe821fbe14139b3d Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Sat, 19 Aug 2017 18:36:11 +0200 Subject: [PATCH 52/72] fix unicode --- example/src/Main.purs | 8 +-- src/ColorPicker/Halogen/Component.purs | 12 ++-- src/ColorPicker/Halogen/Layout.purs | 80 +++++++++++++------------- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 8e84199..5b2ba28 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -115,7 +115,7 @@ config2 = mkConf $ mkLayout componentRedORNoRed ∷ L.PickerComponent componentRedORNoRed = L.TextComponentSpec { fromString: \str → if str == "red" then Just (red) else Nothing - , view: \{color, value, onBlur, onValueInput } -> pure $ + , view: \{color, value, onBlur, onValueInput } → pure $ HH.label [ HP.classes inputClasses.root] [ HH.span [HP.classes inputClasses.label] [HH.text "🛑"] @@ -125,7 +125,7 @@ componentRedORNoRed = L.TextComponentSpec $ inputClasses.elem <> (guard (L.isInvalid value) *> (inputClasses.elemInvalid)) , HP.title "red or nored?" - , HP.value $ maybe' (\_ -> toString color) _.value value + , HP.value $ maybe' (\_ → toString color) _.value value , HP.placeholder "red" , HE.onValueInput $ onValueInput >>> Just , HE.onBlur $ onBlur >>> Just @@ -137,7 +137,7 @@ componentRedORNoRed = L.TextComponentSpec toString = \{color} → if color == red then "red" else "noRed" -mkConf :: L.Layout -> CPicker.Props +mkConf ∷ L.Layout → CPicker.Props mkConf = { layout: _ } mkLayout @@ -166,7 +166,7 @@ mkLayout root editGroups = , L.Group [ H.ClassName "ColorPicker-editing" ] $ editGroups <#> \editGroup → L.Group [ H.ClassName "ColorPicker-editingItem" ] $ - editGroup <#> \mkItem -> L.Component $ mkItem inputClasses + editGroup <#> \mkItem → L.Component $ mkItem inputClasses , [ H.ClassName "ColorPicker-actions" ] `L.Group` [ L.Component $ L.componentSet [ H.ClassName "ColorPicker-actionSet" ] ] ] diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index b2972b7..c1ab844 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -97,7 +97,7 @@ render state = in HH.div [HP.classes classes] $ - fold $ mapWithIndex (\idx -> renderLayout state $ List.Cons idx List.Nil) children + fold $ mapWithIndex (\idx → renderLayout state $ List.Cons idx List.Nil) children renderLayout ∷ ∀ m. State → Cursor → ChildLayout → Array (HTML m) @@ -139,8 +139,8 @@ eval = case _ of TextComponentBlur cursor next → do state ← H.get let val = lookup cursor state.inputValues - for_ (lookup cursor state.inputValues) \val -> - when val.isValid $ H.modify _ { inputValues = mempty :: Map Cursor InputTextValue } + for_ (lookup cursor state.inputValues) \val → + when val.isValid $ H.modify _ { inputValues = mempty ∷ Map Cursor InputTextValue } pure next TextComponentUpdate cursor fromString str next → do let @@ -148,7 +148,7 @@ eval = case _ of isValid = case color of Nothing → false Just _ → true - state <- H.get + state ← H.get let state' = state { inputValues = insert cursor {isValid, value: str} state.inputValues } for_ color $ updateColor state' pure next @@ -171,7 +171,7 @@ eval = case _ of state ← H.get H.put $ state{ color = { current: state.color.current - , old: nubBy (\a b -> eq a.color b.color) $ [state.color.current] <> state.color.old + , old: nubBy (\a b → eq a.color b.color) $ [state.color.current] <> state.color.old }} H.raise $ NotifyChange state.color.current.color pure next @@ -231,7 +231,7 @@ mustBeMounted _ = halt "children must be mounted" type Cursor = List.List Int -focus :: Cursor → Layout → Maybe ChildLayout +focus ∷ Cursor → Layout → Maybe ChildLayout focus cursor layout = let Root x children = layout in foldr f (Just $ Group x children) cursor diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index a24fd1d..24090a9 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -84,10 +84,10 @@ type Classes = Array H.ClassName type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } type LazyColor = - { color :: Color - , hsl :: Lazy RecordHSLA - , hsv :: Lazy RecordHSVA - , rgb :: Lazy RecordRGBA + { color ∷ Color + , hsl ∷ Lazy RecordHSLA + , hsv ∷ Lazy RecordHSVA + , rgb ∷ Lazy RecordRGBA } type InputProps c = @@ -117,25 +117,25 @@ data PickerComponent type NumberComponentView = ∀ p i - . { color :: LazyColor - , input :: HH.HTML p i + . { color ∷ LazyColor + , input ∷ HH.HTML p i } → Array (HH.HTML p i) type TextComponentView = ∀ p i - . { color :: LazyColor - , value :: Maybe InputTextValue - , onValueInput :: String -> i - , onBlur :: FocusEvent -> i + . { color ∷ LazyColor + , value ∷ Maybe InputTextValue + , onValueInput ∷ String → i + , onBlur ∷ FocusEvent → i } → Array (HH.HTML p i) type DragComponentView = ∀ p i - . { color:: LazyColor - , onMouseDown :: MouseEvent -> i - , onTouchStart :: TouchEvent -> i + . { color∷ LazyColor + , onMouseDown ∷ MouseEvent → i + , onTouchStart ∷ TouchEvent → i } → Array (HH.HTML p i) @@ -147,19 +147,19 @@ type ActionComponentView = } → Array (HH.HTML p i) -mapValueHistory :: ∀ a b. (a -> b) -> ValueHistory a -> ValueHistory b +mapValueHistory ∷ ∀ a b. (a → b) → ValueHistory a → ValueHistory b mapValueHistory f { current, old } = { current: f current, old: map f old } -mkLazyColor :: Color -> LazyColor +mkLazyColor ∷ Color → LazyColor mkLazyColor color = { color - , hsl: defer \_ -> Color.toHSLA color - , hsv: defer \_ -> Color.toHSVA color - , rgb: defer \_ -> Color.toRGBA color + , hsl: defer \_ → Color.toHSLA color + , hsv: defer \_ → Color.toHSVA color + , rgb: defer \_ → Color.toRGBA color } -componentPreview ∷ Array H.ClassName -> PickerComponent +componentPreview ∷ Array H.ClassName → PickerComponent componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ HH.div [ HP.classes $ classes @@ -167,9 +167,9 @@ componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ , HCSS.style $ CSS.backgroundColor color.current.color ] [] -componentHistory ∷ Int -> Array H.ClassName -> PickerComponent +componentHistory ∷ Int → Array H.ClassName → PickerComponent componentHistory historySize classes = ActionComponentSpec \{ color , setColor } → - take historySize color.old <#> \c -> + take historySize color.old <#> \c → HH.div [ HP.tabIndex 0 , HP.classes $ classes @@ -179,7 +179,7 @@ componentHistory historySize classes = ActionComponentSpec \{ color , setColor } ] [] -componentSet ∷ Array H.ClassName -> PickerComponent +componentSet ∷ Array H.ClassName → PickerComponent componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } → pure $ HH.button [ HP.classes classes @@ -197,7 +197,7 @@ componentDragSV ∷ → PickerComponent componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} - , view: \{color: {hsv, color}, onMouseDown, onTouchStart} -> pure $ + , view: \{color: {hsv, color}, onMouseDown, onTouchStart} → pure $ HH.div [ HP.classes $ classes.root <> if Color.isLight color then classes.isLight else classes.isDark , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 @@ -223,7 +223,7 @@ componentDragHue ∷ → PickerComponent componentDragHue classes = DragComponentSpec { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } - , view: \{color: {hsv, color}, onMouseDown, onTouchStart} -> pure $ + , view: \{color: {hsv, color}, onMouseDown, onTouchStart} → pure $ HH.div [ HP.classes classes.root , HE.onTouchStart $ onTouchStart >>> Just @@ -238,11 +238,11 @@ componentDragHue classes = DragComponentSpec } mkNumComponent - :: (Number -> Dynamic (Maybe Color)) - -> Dynamic Number - -> InputProps Classes - -> PreNumConf - -> PickerComponent + ∷ (Number → Dynamic (Maybe Color)) + → Dynamic Number + → InputProps Classes + → PreNumConf + → PickerComponent mkNumComponent update read classes conf = NumberComponentSpec { update , read @@ -255,7 +255,7 @@ mkNumComponent update read classes conf = NumberComponentSpec , rootInvalid: classes.elemInvalid , rootLength: const [] } - , view: \ {input} -> pure $ renderInput + , view: \ {input} → pure $ renderInput { root: classes.root , label: classes.label , prefix: conf.prefix @@ -325,7 +325,7 @@ componentBlue classes = mkNumComponent componentHEX ∷ InputProps Classes → PickerComponent componentHEX classes = TextComponentSpec { fromString: \str → Color.fromHexString $ "#" <> str - , view: \{color, value, onValueInput, onBlur} -> pure $ + , view: \{color, value, onValueInput, onBlur} → pure $ renderInput { root: classes.root , label: classes.label @@ -336,7 +336,7 @@ componentHEX classes = TextComponentSpec $ classes.elem <> (guard (isInvalid value) *> (classes.elemInvalid)) , HP.title "Hex" - , HP.value $ maybe' (\_ -> toString color) _.value value + , HP.value $ maybe' (\_ → toString color) _.value value , HP.placeholder "Hex" , HE.onValueInput $ onValueInput >>> Just , HE.onBlur $ onBlur >>> Just @@ -347,19 +347,19 @@ componentHEX classes = TextComponentSpec toString = \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color -isValid :: Maybe InputTextValue -> Boolean +isValid ∷ Maybe InputTextValue → Boolean isValid = maybe true _.isValid -isInvalid :: Maybe InputTextValue -> Boolean +isInvalid ∷ Maybe InputTextValue → Boolean isInvalid = not isValid -renderInput :: ∀ i p. - { child :: HH.HTML i p - , prefix :: String - , label :: Classes - , root :: Classes +renderInput ∷ ∀ i p. + { child ∷ HH.HTML i p + , prefix ∷ String + , label ∷ Classes + , root ∷ Classes } - -> HH.HTML i p + → HH.HTML i p renderInput {root, label, prefix, child} = HH.label [ HP.classes root] From 908f15ade06fef212ae922c315523e6bebeda7c6 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 16:54:37 +0200 Subject: [PATCH 53/72] move styles to example/styles.css --- example/index.html | 163 +-------------------------------------------- example/styles.css | 153 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 162 deletions(-) create mode 100644 example/styles.css diff --git a/example/index.html b/example/index.html index 77e99b5..edc19f9 100644 --- a/example/index.html +++ b/example/index.html @@ -2,168 +2,7 @@ Halogen Datepicker Example - + diff --git a/example/styles.css b/example/styles.css new file mode 100644 index 0000000..c4b8197 --- /dev/null +++ b/example/styles.css @@ -0,0 +1,153 @@ +.ColorPicker { + padding: 0.3em; + display: inline-flex; + background: hsl(0, 0%, 80%); +} + +.IsLight { color: black; } +.IsDark { color: white; } + +.ColorPicker--small .ColorPicker-field { width: 10em; height: 10em; } +.ColorPicker--small .ColorPicker-slider { width: 1em; } + +.ColorPicker--large .ColorPicker-field { width: 15em; height: 15em; } +.ColorPicker--large .ColorPicker-slider { width: 1.5em;} + +.ColorPicker-dragger { + user-select: none; + display: flex; +} + +.ColorPicker-field { + box-shadow: 0 0 0.1em 0.1em currentColor; + transition: box-shadow 200ms ease-out; + position: relative; + height: 100%; + float: left; + margin: 0.2em; + background: + linear-gradient(to top, hsl(0, 0%, 0%) 0%, hsla(0, 0%, 0%, 0) 100%), + linear-gradient(to right, hsl(0, 0%, 100%) 0%, hsla(0, 0%, 100%, 0) 100%); +} + +.ColorPicker-fieldSelector { + pointer-events: none; + box-shadow: 0 0 0 0.1em currentColor; + transition: box-shadow 200ms ease-out; + position: absolute; + width: 1em; + height: 1em; + margin-left: -0.5em; + margin-bottom: -0.5em; + background: hsl(0, 0%, 100%); + border-radius: 50%; + z-index: 10; +} + +.ColorPicker-slider { + margin: 0.2em; + box-shadow: 0 0 0.1em 0.1em currentColor; + transition: box-shadow 200ms ease-out; + position: relative; + background: linear-gradient(#f00 0%, #f0f 17%, #00f 34%, #0ff 50%, #0f0 67%, #ff0 84%, #f00 100%); +} + +.ColorPicker-sliderSelector { + pointer-events: none; + position: absolute; + background: #fff; + border-bottom: 0.05em solid #000; + right: -0.2em; + margin-top: -0.05em; + width: 100%; + height: 0.1em; +} + +.ColorPicker-aside { + display: flex; + flex-direction: column; +} + +.ColorPicker-stage { + display: flex; + margin: 0.2em; + box-shadow: 0 0 0 1px black inset, 0 0 0 2px white inset; + padding: 1px 2px 1px 1px; +} + +.ColorPicker-colorBlockCurrent, +.ColorPicker-colorBlockOld { + height: 1.5em; + box-sizing: border-box; +} + +.ColorPicker-colorBlockCurrent:not(:only-child) { + box-shadow: 0px 0 0 1px black; + margin-right: 1px; + border-right-width: 0.05em; +} +.ColorPicker-colorBlockCurrent { + border: 0.05em solid white; + border-right-width: 0; + flex: 2 1 0%; +} + +.ColorPicker-colorBlockOld { + flex: 1 1 0%; + border-top: 1px solid white; + border-bottom: 1px solid white; + cursor: pointer; +} + +.ColorPicker-ColorBlockOld:focus { + outline: -webkit-focus-ring-color auto 5px; +} + +.ColorPicker-editing { + display: flex; + flex: 1; +} + +.ColorPicker-editingItem { + display: flex; + flex-direction: column; +} + +.ColorPicker-input { + display: flex; + height: 1.5em; + margin: 0.2em; +} + +.ColorPicker-inputLabel { + width: 2em; + display: block; + text-align: center; + align-self: center; +} + +.ColorPicker-inputElem { + border: solid 0.1em; + padding: 0.3em; + width: 5em; +} + +.ColorPicker-inputElem--invalid { + color: red; +} + +.ColorPicker-actions { + display: flex; + justify-content: flex-end; + margin: 0.2em; +} + +.ColorPicker-actionSet { + height: 2em; + border: 0.1em solid; + width: 6em; +} + +.ColorPicker-actionSet:active { + box-shadow: 0 0 0.2em currentColor +} From 2e53be8e8ef6998665209a4f4f2e7eb8e9b93e13 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 16:58:12 +0200 Subject: [PATCH 54/72] fix example issues --- example/src/Main.purs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 5b2ba28..f080fb4 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -12,7 +12,7 @@ import Data.Array (reverse) import Data.Either.Nested as Either import Data.Functor.Coproduct.Nested as Coproduct import Data.Map (Map, insert, lookup) -import Data.Maybe (Maybe(..), maybe') +import Data.Maybe (Maybe(..), maybe) import Data.Monoid (mempty) import Halogen as H import Halogen.Aff as HA @@ -34,11 +34,9 @@ type ColorIdx = Int type ChildQuery = Coproduct.Coproduct1 CPicker.Query type Slot = Either.Either1 ColorIdx - cpColor ∷ CP.ChildPath CPicker.Query ChildQuery ColorIdx Slot cpColor = CP.cp1 - type HTML m = H.ParentHTML Query ChildQuery Slot m type DSL m = H.ParentDSL State Query ChildQuery Slot Void m @@ -114,7 +112,7 @@ config2 = mkConf $ mkLayout componentRedORNoRed ∷ L.PickerComponent componentRedORNoRed = L.TextComponentSpec - { fromString: \str → if str == "red" then Just (red) else Nothing + { fromString: \str → guard (str == "red") $> red , view: \{color, value, onBlur, onValueInput } → pure $ HH.label [ HP.classes inputClasses.root] @@ -125,7 +123,7 @@ componentRedORNoRed = L.TextComponentSpec $ inputClasses.elem <> (guard (L.isInvalid value) *> (inputClasses.elemInvalid)) , HP.title "red or nored?" - , HP.value $ maybe' (\_ → toString color) _.value value + , HP.value $ maybe (toString color) _.value value , HP.placeholder "red" , HE.onValueInput $ onValueInput >>> Just , HE.onBlur $ onBlur >>> Just From 720005710e0c28525aadbac813d4aa3e8a454061 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 16:59:01 +0200 Subject: [PATCH 55/72] newlines --- src/ColorPicker/Halogen/Component.purs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index c1ab844..233b813 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -42,12 +42,10 @@ type State = data Message = NextChange Color | NotifyChange Color - type Props = { layout ∷ Layout } - data Query a = SetProps Props a | DragStart PositionUpdate Drag.CursorEvent a @@ -68,13 +66,12 @@ type Slot = Either.Either1 Cursor cpNumComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery Cursor Slot cpNumComponent = CP.cp1 - type HTML m = H.ParentHTML Query ChildQuery Slot m - type DSL m = H.ParentDSL State Query ChildQuery Slot Message m type PickerEffects r = Drag.DragEffects r + initialColor ∷ Color initialColor = Color.hsl 0.0 0.0 0.0 From 9110b2ebe7ea1ebb3fff5fb42c880131475b3bdd Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:07:41 +0200 Subject: [PATCH 56/72] fix issues in Component.purs --- src/ColorPicker/Halogen/Component.purs | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 233b813..9420547 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -22,7 +22,7 @@ import Data.Foldable (fold, foldr, for_) import Data.Functor.Coproduct.Nested as Coproduct import Data.List as List import Data.Map (Map, insert, lookup) -import Data.Maybe (Maybe(..)) +import Data.Maybe (Maybe(..), isJust) import Data.Monoid (mempty) import Data.Traversable (sequence) import Halogen (liftEff) @@ -140,14 +140,16 @@ eval = case _ of when val.isValid $ H.modify _ { inputValues = mempty ∷ Map Cursor InputTextValue } pure next TextComponentUpdate cursor fromString str next → do - let - color = fromString str - isValid = case color of - Nothing → false - Just _ → true + let color = fromString str state ← H.get - let state' = state { inputValues = insert cursor {isValid, value: str} state.inputValues } - for_ color $ updateColor state' + for_ color $ updateColor $ state + { inputValues = insert + cursor + { isValid: isJust color + , value: str + } + state.inputValues + } pure next NumberComponentUpdate cursor num next → do state ← H.get @@ -157,19 +159,20 @@ eval = case _ of _ → pure unit pure next SetValue val next → do - state ← H.get - H.put $ state{ color = mapValueHistory mkLazyColor val } + H.modify _{ color = mapValueHistory mkLazyColor val } pure next - GetValue next → H.get <#> (_.color >>> (mapValueHistory _.color) >>> next) + GetValue next → H.gets $ _.color >>> mapValueHistory _.color >>> next Init next → do propagate pure next Commit next → do state ← H.get - H.put $ state{ color = - { current: state.color.current - , old: nubBy (\a b → eq a.color b.color) $ [state.color.current] <> state.color.old - }} + H.put $ state + { color = + { current: state.color.current + , old: nubBy (\a b → eq a.color b.color) $ [state.color.current] <> state.color.old + } + } H.raise $ NotifyChange state.color.current.color pure next UpdateCurrentColor color next → do From 88fce6f74b379d69863f88bb2fd5725b0ccc2063 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:24:45 +0200 Subject: [PATCH 57/72] remove `Dynamic` and LazyColor --- example/src/Main.purs | 2 +- src/ColorPicker/Halogen/Component.purs | 22 +++--- src/ColorPicker/Halogen/Layout.purs | 94 ++++++++++---------------- 3 files changed, 47 insertions(+), 71 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index f080fb4..8df0b50 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -132,7 +132,7 @@ componentRedORNoRed = L.TextComponentSpec } where red = rgb 255 0 0 - toString = \{color} → if color == red then "red" else "noRed" + toString = \color → if color == red then "red" else "noRed" mkConf ∷ L.Layout → CPicker.Props diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 9420547..994ecf7 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -11,11 +11,11 @@ import Prelude import Color (Color) import Color as Color -import ColorPicker.Halogen.Layout (Layout(..), ChildLayout(..), PickerComponent(..), InputTextValue, LazyColor, PositionUpdate, ValueHistory, mapValueHistory, mkLazyColor) +import ColorPicker.Halogen.Layout (ChildLayout(..), InputTextValue, Layout(..), PickerComponent(..), PositionUpdate, ValueHistory) import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) import DOM.Classy.Event (preventDefault) -import Data.Array (index, mapWithIndex, nubBy) +import Data.Array (index, mapWithIndex, nub) import Data.Either (Either(..), either) import Data.Either.Nested as Either import Data.Foldable (fold, foldr, for_) @@ -35,7 +35,7 @@ import Halogen.Query.HalogenM (halt) import NumberInput.Halogen.Component as Num type State = - { color ∷ ValueHistory LazyColor + { color ∷ ValueHistory Color , inputValues ∷ Map Cursor InputTextValue , props ∷ Props } @@ -78,7 +78,7 @@ initialColor = Color.hsl 0.0 0.0 0.0 picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m picker = H.lifecycleParentComponent { initialState: - { color: { current: mkLazyColor initialColor, old: [] } + { color: { current: initialColor, old: [] } , inputValues: mempty , props: _ } , render @@ -159,9 +159,9 @@ eval = case _ of _ → pure unit pure next SetValue val next → do - H.modify _{ color = mapValueHistory mkLazyColor val } + H.modify _{ color = val } pure next - GetValue next → H.gets $ _.color >>> mapValueHistory _.color >>> next + GetValue next → H.gets $ _.color >>> next Init next → do propagate pure next @@ -170,10 +170,10 @@ eval = case _ of H.put $ state { color = { current: state.color.current - , old: nubBy (\a b → eq a.color b.color) $ [state.color.current] <> state.color.old + , old: nub $ [state.color.current] <> state.color.old } } - H.raise $ NotifyChange state.color.current.color + H.raise $ NotifyChange state.color.current pure next UpdateCurrentColor color next → do state ← H.get @@ -199,7 +199,7 @@ eval = case _ of updateColor ∷ ∀ m. State → Color → DSL m Unit updateColor state colorNext = do - H.put state{ color { current = mkLazyColor colorNext } } + H.put state{ color { current = colorNext } } H.raise $ NextChange colorNext propagate @@ -212,10 +212,10 @@ propagate = do List.Nil layout where - propagateLayout ∷ LazyColor → Cursor → Layout → DSL m Unit + propagateLayout ∷ Color → Cursor → Layout → DSL m Unit propagateLayout color cursor = case _ of Root _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l - propagateChildLayout ∷ LazyColor → Cursor → ChildLayout → DSL m Unit + propagateChildLayout ∷ Color → Cursor → ChildLayout → DSL m Unit propagateChildLayout color cursor = case _ of Group _ l → void $ sequence $ mapWithIndex (\idx → propagateChildLayout color (List.Cons idx cursor)) l Component c → case c of diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 24090a9..478ba98 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -13,18 +13,14 @@ module ColorPicker.Halogen.Layout , isInvalid , PositionUpdate - , Dynamic , PreNumConf , InputProps , Classes , ValueHistory - , mapValueHistory - , LazyColor , RecordHSLA , RecordHSVA , RecordRGBA - , mkLazyColor , componentHue @@ -52,7 +48,6 @@ import Control.MonadZero (guard) import DOM.Event.Types (FocusEvent, MouseEvent, TouchEvent) import Data.Array (head, take) import Data.Int (floor, toNumber) -import Data.Lazy (Lazy, defer, force) import Data.Maybe (Maybe(..), maybe, maybe') import Data.String as String import Halogen as H @@ -75,20 +70,12 @@ type ValueHistory a = { old ∷ Array a, current ∷ a } type InputTextValue = { value ∷ String, isValid ∷ Boolean } -type PositionUpdate = { x ∷ Number, y ∷ Number } → Dynamic Color - -type Dynamic s = LazyColor → s +type PositionUpdate = { x ∷ Number, y ∷ Number } → Color → Color type Classes = Array H.ClassName type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } -type LazyColor = - { color ∷ Color - , hsl ∷ Lazy RecordHSLA - , hsv ∷ Lazy RecordHSVA - , rgb ∷ Lazy RecordRGBA - } type InputProps c = { root ∷ c @@ -100,8 +87,8 @@ type InputProps c = data PickerComponent = NumberComponentSpec - { update ∷ Number → Dynamic (Maybe Color) - , read ∷ Dynamic Number + { update ∷ Number → Color → Maybe Color + , read ∷ Color → Number , props ∷ Num.Props Number , view ∷ NumberComponentView } @@ -117,14 +104,14 @@ data PickerComponent type NumberComponentView = ∀ p i - . { color ∷ LazyColor + . { color ∷ Color , input ∷ HH.HTML p i } → Array (HH.HTML p i) type TextComponentView = ∀ p i - . { color ∷ LazyColor + . { color ∷ Color , value ∷ Maybe InputTextValue , onValueInput ∷ String → i , onBlur ∷ FocusEvent → i @@ -133,7 +120,7 @@ type TextComponentView = type DragComponentView = ∀ p i - . { color∷ LazyColor + . { color∷ Color , onMouseDown ∷ MouseEvent → i , onTouchStart ∷ TouchEvent → i } @@ -141,41 +128,30 @@ type DragComponentView = type ActionComponentView = ∀ p i - . { color ∷ ValueHistory LazyColor + . { color ∷ ValueHistory Color , setColor ∷ Color → i , commit ∷ i } → Array (HH.HTML p i) -mapValueHistory ∷ ∀ a b. (a → b) → ValueHistory a → ValueHistory b -mapValueHistory f { current, old } = { current: f current, old: map f old } - -mkLazyColor ∷ Color → LazyColor -mkLazyColor color = - { color - , hsl: defer \_ → Color.toHSLA color - , hsv: defer \_ → Color.toHSVA color - , rgb: defer \_ → Color.toRGBA color - } - componentPreview ∷ Array H.ClassName → PickerComponent componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ HH.div [ HP.classes $ classes , HP.title "Current value" - , HCSS.style $ CSS.backgroundColor color.current.color + , HCSS.style $ CSS.backgroundColor color.current ] [] componentHistory ∷ Int → Array H.ClassName → PickerComponent componentHistory historySize classes = ActionComponentSpec \{ color , setColor } → - take historySize color.old <#> \c → + take historySize color.old <#> \color → HH.div [ HP.tabIndex 0 , HP.classes $ classes , HP.title "Old value" - , HE.onClick $ (\_ → Just $ setColor c.color) - , HCSS.style $ CSS.backgroundColor c.color + , HE.onClick $ const $ Just $ setColor color + , HCSS.style $ CSS.backgroundColor color ] [] @@ -184,7 +160,7 @@ componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } HH.button [ HP.classes classes , HE.onClick $ const $ Just commit - , HP.disabled $ Just current.color == (map _.color $ head old) + , HP.disabled $ Just current == head old ] [ HH.text "Set" ] @@ -197,18 +173,18 @@ componentDragSV ∷ → PickerComponent componentDragSV classes = DragComponentSpec { update: \{x, y} → modifyHSV _{ s = x, v = 1.0 - y} - , view: \{color: {hsv, color}, onMouseDown, onTouchStart} → pure $ + , view: \{color, onMouseDown, onTouchStart} → let hsv = Color.toHSVA color in pure $ HH.div [ HP.classes $ classes.root <> if Color.isLight color then classes.isLight else classes.isDark - , HCSS.style $ CSS.backgroundColor $ Color.hsl (force hsv).h 1.0 0.5 + , HCSS.style $ CSS.backgroundColor $ Color.hsl hsv.h 1.0 0.5 , HE.onTouchStart $ onTouchStart >>> Just , HE.onMouseDown $ onMouseDown >>> Just ] [ HH.div [ HP.classes classes.selector , HCSS.style do - CSS.left $ CSS.pct ((force hsv).s * 100.0) - CSS.bottom $ CSS.pct ((force hsv).v * 100.0) + CSS.left $ CSS.pct (hsv.s * 100.0) + CSS.bottom $ CSS.pct (hsv.v * 100.0) CSS.backgroundColor color ] [] @@ -223,7 +199,7 @@ componentDragHue ∷ → PickerComponent componentDragHue classes = DragComponentSpec { update: \{y} → modifyHSL _{ h = (1.0 - y) * 360.0 } - , view: \{color: {hsv, color}, onMouseDown, onTouchStart} → pure $ + , view: \{color, onMouseDown, onTouchStart} → pure $ HH.div [ HP.classes classes.root , HE.onTouchStart $ onTouchStart >>> Just @@ -231,15 +207,15 @@ componentDragHue classes = DragComponentSpec ] [ HH.div [ HP.classes classes.selector - , HCSS.style $ CSS.top $ CSS.pct ((1.0 - (force hsv).h / 360.0) * 100.0) + , HCSS.style $ CSS.top $ CSS.pct ((1.0 - (Color.toHSVA color).h / 360.0) * 100.0) ] [] ] } mkNumComponent - ∷ (Number → Dynamic (Maybe Color)) - → Dynamic Number + ∷ (Number → Color → Maybe Color) + → (Color → Number) → InputProps Classes → PreNumConf → PickerComponent @@ -267,7 +243,7 @@ mkNumComponent update read classes conf = NumberComponentSpec componentHue ∷ InputProps Classes → PickerComponent componentHue classes = mkNumComponent (\n → Just <<< modifyHSL (_{h = n})) - (\({rgb, hsv, hsl}) → roundFractionalNum (force hsl).h) + (\color → roundFractionalNum (Color.toHSLA color).h) classes confHue @@ -275,21 +251,21 @@ componentHue classes = mkNumComponent componentSaturationHSL ∷ InputProps Classes → PickerComponent componentSaturationHSL classes = mkNumComponent (\n → Just <<< modifyHSL (_{s = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).s) + (\color → roundFractionalNum $ 100.0 * (Color.toHSLA color).s) classes confSaturation componentLightness ∷ InputProps Classes → PickerComponent componentLightness classes = mkNumComponent (\n → Just <<< modifyHSL (_{l = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsl).l) + (\color → roundFractionalNum $ 100.0 * (Color.toHSLA color).l) classes confLightness componentSaturationHSV ∷ InputProps Classes → PickerComponent componentSaturationHSV classes = mkNumComponent (\n → Just <<< modifyHSV (_{s = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).s) + (\color → roundFractionalNum $ 100.0 * (Color.toHSVA color).s) classes confSaturation @@ -297,28 +273,28 @@ componentSaturationHSV classes = mkNumComponent componentValue ∷ InputProps Classes → PickerComponent componentValue classes = mkNumComponent (\n → Just <<< modifyHSV (_{v = n / 100.0})) - (\({rgb, hsv, hsl}) → roundFractionalNum $ 100.0 * (force hsv).v) + (\color → roundFractionalNum $ 100.0 * (Color.toHSVA color).v) classes confValue componentRed ∷ InputProps Classes → PickerComponent componentRed classes = mkNumComponent (\n → Just <<< modifyRGB (_{r = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).r) + (\color → roundNum $ toNumber (Color.toRGBA color).r) classes confRed componentGreen ∷ InputProps Classes → PickerComponent componentGreen classes = mkNumComponent (\n → Just <<< modifyRGB (_{g = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).g) + (\color → roundNum $ toNumber (Color.toRGBA color).g) classes confGreen componentBlue ∷ InputProps Classes → PickerComponent componentBlue classes = mkNumComponent (\n → Just <<< modifyRGB (_{b = asInt n})) - (\({rgb, hsv, hsl}) → roundNum $ toNumber (force rgb).b) + (\color → roundNum $ toNumber (Color.toRGBA color).b) classes confBlue @@ -344,7 +320,7 @@ componentHEX classes = TextComponentSpec } } where - toString = \{color} → String.toUpper $ String.drop 1 $ Color.toHexString color + toString = \color → String.toUpper $ String.drop 1 $ Color.toHexString color isValid ∷ Maybe InputTextValue → Boolean @@ -449,11 +425,11 @@ type RecordHSLA = { h ∷ Number, s ∷ Number, l ∷ Number, a ∷ Number } type RecordHSVA = { h ∷ Number, s ∷ Number, v ∷ Number, a ∷ Number } type RecordRGBA = { r ∷ Int, g ∷ Int, b ∷ Int, a ∷ Number } -modifyHSL ∷ (RecordHSLA → RecordHSLA) → Dynamic Color -modifyHSL f { hsl } = let {h, s, l, a} = f (force hsl) in Color.hsla h s l a +modifyHSL ∷ (RecordHSLA → RecordHSLA) → Color → Color +modifyHSL f c = let {h, s, l, a} = f $ Color.toHSLA c in Color.hsla h s l a -modifyHSV ∷ (RecordHSVA → RecordHSVA) → Dynamic Color -modifyHSV f { hsv } = let {h, s, v, a} = f (force hsv) in Color.hsva h s v a +modifyHSV ∷ (RecordHSVA → RecordHSVA) → Color → Color +modifyHSV f c = let {h, s, v, a} = f $ Color.toHSVA c in Color.hsva h s v a -modifyRGB ∷ (RecordRGBA → RecordRGBA) → Dynamic Color -modifyRGB f { rgb } = let {r, g, b, a} = f (force rgb) in Color.rgba r g b a +modifyRGB ∷ (RecordRGBA → RecordRGBA) → Color → Color +modifyRGB f c = let {r, g, b, a} = f $ Color.toRGBA c in Color.rgba r g b a From 5df936ea370bfb9e259dc9ebd6617e677f8a6477 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:28:18 +0200 Subject: [PATCH 58/72] use open rows --- src/ColorPicker/Halogen/Layout.purs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 478ba98..ddcefe0 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -76,7 +76,6 @@ type Classes = Array H.ClassName type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } - type InputProps c = { root ∷ c , label ∷ c @@ -84,7 +83,6 @@ type InputProps c = , elemInvalid ∷ c } - data PickerComponent = NumberComponentSpec { update ∷ Number → Color → Maybe Color @@ -164,11 +162,12 @@ componentSet classes = ActionComponentSpec \{ color: {current, old}, commit } ] [ HH.text "Set" ] -componentDragSV ∷ +componentDragSV ∷ ∀ r. { isLight ∷ Array H.ClassName , isDark ∷ Array H.ClassName , root ∷ Array H.ClassName , selector ∷ Array H.ClassName + | r } → PickerComponent componentDragSV classes = DragComponentSpec @@ -192,9 +191,10 @@ componentDragSV classes = DragComponentSpec } -componentDragHue ∷ +componentDragHue ∷ ∀ r. { root ∷ Array H.ClassName , selector ∷ Array H.ClassName + | r } → PickerComponent componentDragHue classes = DragComponentSpec From 67e60da114f9a99b4b9068de06bd2ab4dda2876c Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:29:42 +0200 Subject: [PATCH 59/72] fix parens --- src/ColorPicker/Halogen/Layout.purs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index ddcefe0..cc6a22d 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -13,7 +13,7 @@ module ColorPicker.Halogen.Layout , isInvalid , PositionUpdate - , PreNumConf + , NumConf , InputProps , Classes , ValueHistory @@ -74,7 +74,7 @@ type PositionUpdate = { x ∷ Number, y ∷ Number } → Color → Color type Classes = Array H.ClassName -type PreNumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } +type NumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } type InputProps c = { root ∷ c @@ -217,7 +217,7 @@ mkNumComponent ∷ (Number → Color → Maybe Color) → (Color → Number) → InputProps Classes - → PreNumConf + → NumConf → PickerComponent mkNumComponent update read classes conf = NumberComponentSpec { update @@ -347,7 +347,7 @@ renderInput {root, label, prefix, child} = -- Internal helpers -confRed ∷ PreNumConf +confRed ∷ NumConf confRed = { title: "Red" , placeholder: "R" @@ -355,7 +355,7 @@ confRed = , range: MinMax 0.0 256.0 } -confGreen ∷ PreNumConf +confGreen ∷ NumConf confGreen = { title: "Green" , placeholder: "G" @@ -363,7 +363,7 @@ confGreen = , range: MinMax 0.0 256.0 } -confBlue ∷ PreNumConf +confBlue ∷ NumConf confBlue = { title: "Blue" , placeholder: "B" @@ -371,21 +371,21 @@ confBlue = , range: MinMax 0.0 256.0 } -confHue ∷ PreNumConf +confHue ∷ NumConf confHue = { title: "Hue" , placeholder: "H" , prefix: "H" , range: MinMax 0.0 360.0 } -confSaturation ∷ PreNumConf +confSaturation ∷ NumConf confSaturation = { title: "Saturation" , placeholder: "S" , prefix: "S" , range: MinMax 0.0 100.0 } -confLightness ∷ PreNumConf +confLightness ∷ NumConf confLightness = { title: "Lightness" , placeholder: "L" @@ -393,7 +393,7 @@ confLightness = , range: MinMax 0.0 100.0 } -confValue ∷ PreNumConf +confValue ∷ NumConf confValue = { title: "Value" , placeholder: "V" From f766e2c3c3580cf6ffbc4113cc5ef1ced7440ed7 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:33:42 +0200 Subject: [PATCH 60/72] refactor inputProps type --- src/ColorPicker/Halogen/Layout.purs | 48 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index cc6a22d..eb73018 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -72,15 +72,13 @@ type InputTextValue = { value ∷ String, isValid ∷ Boolean } type PositionUpdate = { x ∷ Number, y ∷ Number } → Color → Color -type Classes = Array H.ClassName - type NumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } -type InputProps c = - { root ∷ c - , label ∷ c - , elem ∷ c - , elemInvalid ∷ c +type InputProps = + { root ∷ Array H.ClassName + , label ∷ Array H.ClassName + , elem ∷ Array H.ClassName + , elemInvalid ∷ Array H.ClassName } data PickerComponent @@ -216,7 +214,7 @@ componentDragHue classes = DragComponentSpec mkNumComponent ∷ (Number → Color → Maybe Color) → (Color → Number) - → InputProps Classes + → InputProps → NumConf → PickerComponent mkNumComponent update read classes conf = NumberComponentSpec @@ -240,65 +238,65 @@ mkNumComponent update read classes conf = NumberComponentSpec } -componentHue ∷ InputProps Classes → PickerComponent +componentHue ∷ InputProps → PickerComponent componentHue classes = mkNumComponent - (\n → Just <<< modifyHSL (_{h = n})) + (\n → Just <<< modifyHSL _{h = n}) (\color → roundFractionalNum (Color.toHSLA color).h) classes confHue -componentSaturationHSL ∷ InputProps Classes → PickerComponent +componentSaturationHSL ∷ InputProps → PickerComponent componentSaturationHSL classes = mkNumComponent - (\n → Just <<< modifyHSL (_{s = n / 100.0})) + (\n → Just <<< modifyHSL _{s = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSLA color).s) classes confSaturation -componentLightness ∷ InputProps Classes → PickerComponent +componentLightness ∷ InputProps → PickerComponent componentLightness classes = mkNumComponent - (\n → Just <<< modifyHSL (_{l = n / 100.0})) + (\n → Just <<< modifyHSL _{l = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSLA color).l) classes confLightness -componentSaturationHSV ∷ InputProps Classes → PickerComponent +componentSaturationHSV ∷ InputProps → PickerComponent componentSaturationHSV classes = mkNumComponent - (\n → Just <<< modifyHSV (_{s = n / 100.0})) + (\n → Just <<< modifyHSV _{s = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSVA color).s) classes confSaturation -componentValue ∷ InputProps Classes → PickerComponent +componentValue ∷ InputProps → PickerComponent componentValue classes = mkNumComponent - (\n → Just <<< modifyHSV (_{v = n / 100.0})) + (\n → Just <<< modifyHSV _{v = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSVA color).v) classes confValue -componentRed ∷ InputProps Classes → PickerComponent +componentRed ∷ InputProps → PickerComponent componentRed classes = mkNumComponent - (\n → Just <<< modifyRGB (_{r = asInt n})) + (\n → Just <<< modifyRGB _{r = asInt n}) (\color → roundNum $ toNumber (Color.toRGBA color).r) classes confRed -componentGreen ∷ InputProps Classes → PickerComponent +componentGreen ∷ InputProps → PickerComponent componentGreen classes = mkNumComponent - (\n → Just <<< modifyRGB (_{g = asInt n})) + (\n → Just <<< modifyRGB _{g = asInt n}) (\color → roundNum $ toNumber (Color.toRGBA color).g) classes confGreen -componentBlue ∷ InputProps Classes → PickerComponent +componentBlue ∷ InputProps → PickerComponent componentBlue classes = mkNumComponent - (\n → Just <<< modifyRGB (_{b = asInt n})) + (\n → Just <<< modifyRGB _{b = asInt n}) (\color → roundNum $ toNumber (Color.toRGBA color).b) classes confBlue -componentHEX ∷ InputProps Classes → PickerComponent +componentHEX ∷ InputProps → PickerComponent componentHEX classes = TextComponentSpec { fromString: \str → Color.fromHexString $ "#" <> str , view: \{color, value, onValueInput, onBlur} → pure $ From c2ecfd469d8eed176893b8cffb148d82db73d97a Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:34:12 +0200 Subject: [PATCH 61/72] add comment about Layout types --- src/ColorPicker/Halogen/Layout.purs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index eb73018..b03a2fd 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -59,8 +59,11 @@ import Math (round) import NumberInput.Halogen.Component as Num import NumberInput.Range (Range(..)) +-- We have two types for Layout as in halogen render can not return +-- Array of HTML nodes, so by asking for `Layout` in Props, we can +-- have allow only one node for as root node, but allow `PickerComponent`-s +-- to return Array of HTML nodes. data Layout = Root (Array H.ClassName) (Array ChildLayout) - data ChildLayout = Group (Array H.ClassName) (Array ChildLayout) | Component PickerComponent From 0dc0f284ec8325148da207367d8d8ee599bed4d5 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:43:01 +0200 Subject: [PATCH 62/72] fix Classes leftover --- example/src/Main.purs | 4 ++-- src/ColorPicker/Halogen/Layout.purs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/example/src/Main.purs b/example/src/Main.purs index 8df0b50..c2d24a9 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -140,7 +140,7 @@ mkConf = { layout: _ } mkLayout ∷ H.ClassName - → Array (Array (L.InputProps L.Classes → L.PickerComponent)) + → Array (Array (L.InputProps → L.PickerComponent)) → L.Layout mkLayout root editGroups = [ H.ClassName "ColorPicker", root ] `L.Root` @@ -170,7 +170,7 @@ mkLayout root editGroups = ] ] -inputClasses ∷ L.InputProps L.Classes +inputClasses ∷ L.InputProps inputClasses = { root: [H.ClassName "ColorPicker-input"] , label: [H.ClassName "ColorPicker-inputLabel"] diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index b03a2fd..42a95e6 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -15,7 +15,6 @@ module ColorPicker.Halogen.Layout , PositionUpdate , NumConf , InputProps - , Classes , ValueHistory , RecordHSLA @@ -333,8 +332,8 @@ isInvalid = not isValid renderInput ∷ ∀ i p. { child ∷ HH.HTML i p , prefix ∷ String - , label ∷ Classes - , root ∷ Classes + , label ∷ Array H.ClassName + , root ∷ Array H.ClassName } → HH.HTML i p renderInput {root, label, prefix, child} = From 542377cbfaf9e8bc9c4c1de85ca461e1d02a6bf8 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:50:11 +0200 Subject: [PATCH 63/72] fix name shalowed --- src/ColorPicker/Halogen/Component.purs | 1 - src/ColorPicker/Halogen/Layout.purs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 994ecf7..279fa74 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -135,7 +135,6 @@ eval ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Query ~> DSL m eval = case _ of TextComponentBlur cursor next → do state ← H.get - let val = lookup cursor state.inputValues for_ (lookup cursor state.inputValues) \val → when val.isValid $ H.modify _ { inputValues = mempty ∷ Map Cursor InputTextValue } pure next diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 42a95e6..6d102cc 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -143,13 +143,13 @@ componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ componentHistory ∷ Int → Array H.ClassName → PickerComponent componentHistory historySize classes = ActionComponentSpec \{ color , setColor } → - take historySize color.old <#> \color → + take historySize color.old <#> \c → HH.div [ HP.tabIndex 0 , HP.classes $ classes , HP.title "Old value" - , HE.onClick $ const $ Just $ setColor color - , HCSS.style $ CSS.backgroundColor color + , HE.onClick $ const $ Just $ setColor c + , HCSS.style $ CSS.backgroundColor c ] [] From 6b604e8730343446546a96a985bea1cc534d7e6e Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Mon, 21 Aug 2017 17:57:09 +0200 Subject: [PATCH 64/72] new line --- src/ColorPicker/Halogen/Layout.purs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index 6d102cc..b13306c 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -21,7 +21,6 @@ module ColorPicker.Halogen.Layout , RecordHSVA , RecordRGBA - , componentHue , componentSaturationHSL , componentLightness From 32cfc0ee06700428a0d692b4d1539c3948cb0a43 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 24 Aug 2017 15:09:34 +0200 Subject: [PATCH 65/72] fix stage height --- example/styles.css | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/example/styles.css b/example/styles.css index c4b8197..d0fa472 100644 --- a/example/styles.css +++ b/example/styles.css @@ -7,10 +7,10 @@ .IsLight { color: black; } .IsDark { color: white; } -.ColorPicker--small .ColorPicker-field { width: 10em; height: 10em; } +.ColorPicker--small .ColorPicker-field { width: 10em; } .ColorPicker--small .ColorPicker-slider { width: 1em; } -.ColorPicker--large .ColorPicker-field { width: 15em; height: 15em; } +.ColorPicker--large .ColorPicker-field { width: 15em; } .ColorPicker--large .ColorPicker-slider { width: 1.5em;} .ColorPicker-dragger { @@ -22,7 +22,6 @@ box-shadow: 0 0 0.1em 0.1em currentColor; transition: box-shadow 200ms ease-out; position: relative; - height: 100%; float: left; margin: 0.2em; background: @@ -30,6 +29,15 @@ linear-gradient(to right, hsl(0, 0%, 100%) 0%, hsla(0, 0%, 100%, 0) 100%); } +/* Make .ColorPicker-field square */ +.ColorPicker-field:after { + content: ""; + display: block; + width: 100%; + margin-top: 100%; +} + + .ColorPicker-fieldSelector { pointer-events: none; box-shadow: 0 0 0 0.1em currentColor; From b6f2afc27156fce2faee0081f553e9ca1c2e298c Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 24 Aug 2017 15:10:00 +0200 Subject: [PATCH 66/72] use button for history items --- example/styles.css | 13 ++++++++----- src/ColorPicker/Halogen/Layout.purs | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/example/styles.css b/example/styles.css index d0fa472..0eee6ae 100644 --- a/example/styles.css +++ b/example/styles.css @@ -64,9 +64,9 @@ pointer-events: none; position: absolute; background: #fff; - border-bottom: 0.05em solid #000; - right: -0.2em; - margin-top: -0.05em; + border-bottom: 1px solid #000; + right: -4px; + margin-top: -1px; width: 100%; height: 0.1em; } @@ -85,17 +85,20 @@ .ColorPicker-colorBlockCurrent, .ColorPicker-colorBlockOld { + font-size: inherit; height: 1.5em; box-sizing: border-box; + border-width: 0 ; + margin:0; } .ColorPicker-colorBlockCurrent:not(:only-child) { box-shadow: 0px 0 0 1px black; margin-right: 1px; - border-right-width: 0.05em; + border-right-width: 1px; } .ColorPicker-colorBlockCurrent { - border: 0.05em solid white; + border: 1px solid white; border-right-width: 0; flex: 2 1 0%; } diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index b13306c..a9e39c1 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -143,9 +143,8 @@ componentPreview classes = ActionComponentSpec \{ color , setColor } → pure $ componentHistory ∷ Int → Array H.ClassName → PickerComponent componentHistory historySize classes = ActionComponentSpec \{ color , setColor } → take historySize color.old <#> \c → - HH.div - [ HP.tabIndex 0 - , HP.classes $ classes + HH.button + [ HP.classes $ classes , HP.title "Old value" , HE.onClick $ const $ Just $ setColor c , HCSS.style $ CSS.backgroundColor c From f1a6c019c98f580ff7f166282a30033846172b70 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 24 Aug 2017 18:37:42 +0200 Subject: [PATCH 67/72] add IntComponent for RGB input issue --- src/ColorPicker/Halogen/Component.purs | 34 ++++++-- src/ColorPicker/Halogen/Layout.purs | 110 +++++++++++++++---------- 2 files changed, 95 insertions(+), 49 deletions(-) diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 279fa74..0b5d7ff 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -52,6 +52,7 @@ data Query a | DragMove PositionUpdate Drag.DragEvent a | UpdateCurrentColor Color a | NumberComponentUpdate Cursor (Maybe Number) a + | IntComponentUpdate Cursor (Maybe Int) a | TextComponentUpdate Cursor (String → Maybe Color) String a | TextComponentBlur Cursor a | Commit a @@ -60,11 +61,14 @@ data Query a | SetValue (ValueHistory Color) a -type ChildQuery = Coproduct.Coproduct1 (Num.Query Number) -type Slot = Either.Either1 Cursor +type ChildQuery = Coproduct.Coproduct2 (Num.Query Number) (Num.Query Int) +type Slot = Either.Either2 Cursor Cursor -cpNumComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery Cursor Slot -cpNumComponent = CP.cp1 +cpNumberComponent ∷ CP.ChildPath (Num.Query Number) ChildQuery Cursor Slot +cpNumberComponent = CP.cp1 + +cpIntComponent ∷ CP.ChildPath (Num.Query Int) ChildQuery Cursor Slot +cpIntComponent = CP.cp2 type HTML m = H.ParentHTML Query ChildQuery Slot m type DSL m = H.ParentDSL State Query ChildQuery Slot Message m @@ -117,12 +121,21 @@ renderLayout state@{ color, inputValues, props} cursor = case _ of NumberComponentSpec spec → spec.view { color: color.current , input: HH.slot' - cpNumComponent + cpNumberComponent cursor Num.input spec.props (HE.input \(Num.NotifyChange val) → NumberComponentUpdate cursor val) } + IntComponentSpec spec → spec.view + { color: color.current + , input: HH.slot' + cpIntComponent + cursor + Num.input + spec.props + (HE.input \(Num.NotifyChange val) → IntComponentUpdate cursor val) + } TextComponentSpec spec → spec.view { color: color.current , value: lookup cursor inputValues @@ -157,6 +170,13 @@ eval = case _ of for_ (update <$> num >>= (_ $ state.color.current)) $ updateColor state _ → pure unit pure next + IntComponentUpdate cursor num next → do + state ← H.get + case focus cursor state.props.layout of + Just (Component (IntComponentSpec { update })) → + for_ (update <$> num >>= (_ $ state.color.current)) $ updateColor state + _ → pure unit + pure next SetValue val next → do H.modify _{ color = val } pure next @@ -222,7 +242,9 @@ propagate = do TextComponentSpec _ → pure unit ActionComponentSpec _ → pure unit NumberComponentSpec { read } → - H.query' cpNumComponent cursor (H.action $ Num.SetValue $ Just $ read color) >>= mustBeMounted + H.query' cpNumberComponent cursor (H.action $ Num.SetValue $ Just $ read color) >>= mustBeMounted + IntComponentSpec { read } → + H.query' cpIntComponent cursor (H.action $ Num.SetValue $ Just $ read color) >>= mustBeMounted mustBeMounted ∷ ∀ s f g p o m a. Maybe a → H.HalogenM s f g p o m a mustBeMounted (Just x) = pure x diff --git a/src/ColorPicker/Halogen/Layout.purs b/src/ColorPicker/Halogen/Layout.purs index a9e39c1..727031c 100644 --- a/src/ColorPicker/Halogen/Layout.purs +++ b/src/ColorPicker/Halogen/Layout.purs @@ -2,8 +2,9 @@ module ColorPicker.Halogen.Layout ( Layout(..) , ChildLayout(..) , PickerComponent(..) + , NumComponentSpec - , NumberComponentView + , NumComponentView , TextComponentView , DragComponentView , ActionComponentView @@ -45,7 +46,6 @@ import Color as Color import Control.MonadZero (guard) import DOM.Event.Types (FocusEvent, MouseEvent, TouchEvent) import Data.Array (head, take) -import Data.Int (floor, toNumber) import Data.Maybe (Maybe(..), maybe, maybe') import Data.String as String import Halogen as H @@ -73,7 +73,7 @@ type InputTextValue = { value ∷ String, isValid ∷ Boolean } type PositionUpdate = { x ∷ Number, y ∷ Number } → Color → Color -type NumConf = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range Number } +type NumConf a = { prefix ∷ String, title ∷ String, placeholder ∷ String, range ∷ Range a } type InputProps = { root ∷ Array H.ClassName @@ -83,12 +83,8 @@ type InputProps = } data PickerComponent - = NumberComponentSpec - { update ∷ Number → Color → Maybe Color - , read ∷ Color → Number - , props ∷ Num.Props Number - , view ∷ NumberComponentView - } + = NumberComponentSpec (NumComponentSpec Number) + | IntComponentSpec (NumComponentSpec Int) | TextComponentSpec { fromString ∷ String → Maybe Color , view ∷ TextComponentView @@ -99,7 +95,14 @@ data PickerComponent } | ActionComponentSpec ActionComponentView -type NumberComponentView = +type NumComponentSpec a = + { update ∷ a → Color → Maybe Color + , read ∷ Color → a + , props ∷ Num.Props a + , view ∷ NumComponentView + } + +type NumComponentView = ∀ p i . { color ∷ Color , input ∷ HH.HTML p i @@ -212,17 +215,23 @@ componentDragHue classes = DragComponentSpec } mkNumComponent - ∷ (Number → Color → Maybe Color) - → (Color → Number) + :: ∀ a + . (a → Color → Maybe Color) + → (Color → a) → InputProps - → NumConf - → PickerComponent -mkNumComponent update read classes conf = NumberComponentSpec + → NumConf a + → Num.HasNumberInputValue a + → { update :: a → Color → Maybe Color + , read :: Color → a + , props :: Num.Props a + , view :: NumComponentView + } +mkNumComponent update read classes conf hasNumVal = { update , read , props: { title: conf.title - , hasNumberValue: hasValRound + , hasNumberValue: hasNumVal , placeholder: conf.placeholder , range: conf.range , root: classes.elem @@ -237,9 +246,27 @@ mkNumComponent update read classes conf = NumberComponentSpec } } +mkNumberComponent + ∷ (Number → Color → Maybe Color) + → (Color → Number) + → InputProps + → NumConf Number + → PickerComponent +mkNumberComponent update read classes conf = NumberComponentSpec $ + mkNumComponent update read classes conf hasValRound + +mkIntComponent + ∷ (Int → Color → Maybe Color) + → (Color → Int) + → InputProps + → NumConf Int + → PickerComponent +mkIntComponent update read classes conf = IntComponentSpec $ + mkNumComponent update read classes conf Num.intHasNumberInputValue + componentHue ∷ InputProps → PickerComponent -componentHue classes = mkNumComponent +componentHue classes = mkNumberComponent (\n → Just <<< modifyHSL _{h = n}) (\color → roundFractionalNum (Color.toHSLA color).h) classes @@ -247,21 +274,21 @@ componentHue classes = mkNumComponent componentSaturationHSL ∷ InputProps → PickerComponent -componentSaturationHSL classes = mkNumComponent +componentSaturationHSL classes = mkNumberComponent (\n → Just <<< modifyHSL _{s = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSLA color).s) classes confSaturation componentLightness ∷ InputProps → PickerComponent -componentLightness classes = mkNumComponent +componentLightness classes = mkNumberComponent (\n → Just <<< modifyHSL _{l = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSLA color).l) classes confLightness componentSaturationHSV ∷ InputProps → PickerComponent -componentSaturationHSV classes = mkNumComponent +componentSaturationHSV classes = mkNumberComponent (\n → Just <<< modifyHSV _{s = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSVA color).s) classes @@ -269,30 +296,30 @@ componentSaturationHSV classes = mkNumComponent componentValue ∷ InputProps → PickerComponent -componentValue classes = mkNumComponent +componentValue classes = mkNumberComponent (\n → Just <<< modifyHSV _{v = n / 100.0}) (\color → roundFractionalNum $ 100.0 * (Color.toHSVA color).v) classes confValue componentRed ∷ InputProps → PickerComponent -componentRed classes = mkNumComponent - (\n → Just <<< modifyRGB _{r = asInt n}) - (\color → roundNum $ toNumber (Color.toRGBA color).r) +componentRed classes = mkIntComponent + (\n → Just <<< modifyRGB _{r = n}) + (\color → (Color.toRGBA color).r) classes confRed componentGreen ∷ InputProps → PickerComponent -componentGreen classes = mkNumComponent - (\n → Just <<< modifyRGB _{g = asInt n}) - (\color → roundNum $ toNumber (Color.toRGBA color).g) +componentGreen classes = mkIntComponent + (\n → Just <<< modifyRGB _{g = n}) + (\color → (Color.toRGBA color).g) classes confGreen componentBlue ∷ InputProps → PickerComponent -componentBlue classes = mkNumComponent - (\n → Just <<< modifyRGB _{b = asInt n}) - (\color → roundNum $ toNumber (Color.toRGBA color).b) +componentBlue classes = mkIntComponent + (\n → Just <<< modifyRGB _{b = n}) + (\color → (Color.toRGBA color).b) classes confBlue @@ -345,45 +372,45 @@ renderInput {root, label, prefix, child} = -- Internal helpers -confRed ∷ NumConf +confRed ∷ NumConf Int confRed = { title: "Red" , placeholder: "R" , prefix: "R" - , range: MinMax 0.0 256.0 + , range: MinMax 0 256 } -confGreen ∷ NumConf +confGreen ∷ NumConf Int confGreen = { title: "Green" , placeholder: "G" , prefix: "G" - , range: MinMax 0.0 256.0 + , range: MinMax 0 256 } -confBlue ∷ NumConf +confBlue ∷ NumConf Int confBlue = { title: "Blue" , placeholder: "B" , prefix: "B" - , range: MinMax 0.0 256.0 + , range: MinMax 0 256 } -confHue ∷ NumConf +confHue ∷ NumConf Number confHue = { title: "Hue" , placeholder: "H" , prefix: "H" , range: MinMax 0.0 360.0 } -confSaturation ∷ NumConf +confSaturation ∷ NumConf Number confSaturation = { title: "Saturation" , placeholder: "S" , prefix: "S" , range: MinMax 0.0 100.0 } -confLightness ∷ NumConf +confLightness ∷ NumConf Number confLightness = { title: "Lightness" , placeholder: "L" @@ -391,7 +418,7 @@ confLightness = , range: MinMax 0.0 100.0 } -confValue ∷ NumConf +confValue ∷ NumConf Number confValue = { title: "Value" , placeholder: "V" @@ -413,9 +440,6 @@ roundFractionalNum n = roundNum (n * scalar) / scalar where scalar = 100.0 -asInt ∷ Number → Int -asInt = floor - roundNum ∷ Number → Number roundNum = round From 16ee5bfe0425573e70d5b4db0414da42ec93e3e3 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 24 Aug 2017 20:11:10 +0200 Subject: [PATCH 68/72] add normalize to examples, update styles --- example/index.html | 1 + example/styles.css | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/example/index.html b/example/index.html index edc19f9..ff80df6 100644 --- a/example/index.html +++ b/example/index.html @@ -2,6 +2,7 @@ Halogen Datepicker Example + diff --git a/example/styles.css b/example/styles.css index 0eee6ae..384c94d 100644 --- a/example/styles.css +++ b/example/styles.css @@ -126,7 +126,6 @@ .ColorPicker-input { display: flex; - height: 1.5em; margin: 0.2em; } @@ -137,10 +136,12 @@ align-self: center; } -.ColorPicker-inputElem { - border: solid 0.1em; +.ColorPicker-inputElem, +.ColorPicker-actionSet { + border: solid 1px; padding: 0.3em; width: 5em; + box-sizing: border-box; } .ColorPicker-inputElem--invalid { @@ -153,12 +154,6 @@ margin: 0.2em; } -.ColorPicker-actionSet { - height: 2em; - border: 0.1em solid; - width: 6em; -} - .ColorPicker-actionSet:active { box-shadow: 0 0 0.2em currentColor } From 5438ac2556e55c873881152a5316bd4f97b6f96b Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 24 Aug 2017 20:12:48 +0200 Subject: [PATCH 69/72] make stage elems same size as inputs --- example/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/styles.css b/example/styles.css index 384c94d..560924b 100644 --- a/example/styles.css +++ b/example/styles.css @@ -86,7 +86,7 @@ .ColorPicker-colorBlockCurrent, .ColorPicker-colorBlockOld { font-size: inherit; - height: 1.5em; + height: 1.8em; box-sizing: border-box; border-width: 0 ; margin:0; From fa687b4678245bea212cea36740c70199866e546 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Thu, 24 Aug 2017 20:22:33 +0200 Subject: [PATCH 70/72] fix flex grow --- example/styles.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/example/styles.css b/example/styles.css index 560924b..ce7cfc3 100644 --- a/example/styles.css +++ b/example/styles.css @@ -1,6 +1,6 @@ .ColorPicker { padding: 0.3em; - display: inline-flex; + display: flex; background: hsl(0, 0%, 80%); } @@ -74,6 +74,7 @@ .ColorPicker-aside { display: flex; flex-direction: column; + flex: 1 1 auto; } .ColorPicker-stage { @@ -122,6 +123,7 @@ .ColorPicker-editingItem { display: flex; flex-direction: column; + flex: 1 1 auto; } .ColorPicker-input { @@ -134,6 +136,7 @@ display: block; text-align: center; align-self: center; + flex: 1 1 auto; } .ColorPicker-inputElem, From 2331f3178238f9940d5a9084199978dd163013b4 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 1 Sep 2017 13:38:19 +0400 Subject: [PATCH 71/72] update colors version --- bower.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 932970f..43c2723 100644 --- a/bower.json +++ b/bower.json @@ -20,14 +20,11 @@ "example" ], "dependencies": { - "purescript-colors": "^v3.1.0", + "purescript-colors": "^4.0.0", "purescript-halogen": "^2.1.0", "purescript-halogen-css": "^6.0.0", "purescript-dom-classy": "^2.1.0", "purescript-dom": "^4.7.0", "purescript-number-input-halogen": "git://github.com/safareli/purescript-number-input-halogen.git#initial-props" - }, - "resolutions": { - "purescript-colors": "hsv" } } From 32116b7263b27ac5229abb27938a23a5b0e02579 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 1 Sep 2017 16:52:08 +0400 Subject: [PATCH 72/72] parameterize by initialColor --- example/index.html | 3 +++ example/src/Main.purs | 29 ++++++++++++++++---------- example/styles.css | 7 ++++++- src/ColorPicker/Halogen/Component.purs | 8 ++----- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/example/index.html b/example/index.html index ff80df6..103d91d 100644 --- a/example/index.html +++ b/example/index.html @@ -4,6 +4,9 @@ Halogen Datepicker Example + diff --git a/example/src/Main.purs b/example/src/Main.purs index c2d24a9..d4698da 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -3,6 +3,7 @@ module Main where import Prelude import Color (Color, rgb) +import Color.Scheme.X11 (blue, orange, red) import ColorPicker.Halogen.Component as CPicker import ColorPicker.Halogen.Layout as L import Control.Monad.Aff.Class (class MonadAff) @@ -50,15 +51,16 @@ example = H.parentComponent } render ∷ ∀ m r. MonadAff (CPicker.PickerEffects r) m => State → HTML m -render state = HH.div_ - $ renderPicker 0 config0 - <> renderPicker 1 config1 - <> renderPicker 2 config2 +render state = HH.div [HP.class_ $ H.ClassName "root"] + $ renderPicker orange 0 config0 + <> renderPicker blue 1 config1 + <> renderPicker red 2 config2 + <> renderPicker red 3 config3 where - renderPicker idx conf = + renderPicker color idx conf = [ HH.h1_ [ HH.text $ "Picker " <> show idx ] - , HH.slot' cpColor idx CPicker.picker conf (HE.input $ HandleMsg idx) + , HH.slot' cpColor idx (CPicker.picker color) conf (HE.input $ HandleMsg idx) , HH.p_ [ HH.text case lookup idx state of Just ({current, next}) → "uncommited (current: " <> show current <>", next:" <> show next <> ")" @@ -82,7 +84,7 @@ config0 ∷ CPicker.Props config0 = mkConf $ L.Root c $ reverse l where L.Root c l = mkLayout - (H.ClassName "ColorPicker--small") + [H.ClassName "ColorPicker--small", H.ClassName "ColorPicker--inline"] [ [ L.componentHue , L.componentSaturationHSL , L.componentLightness @@ -91,7 +93,7 @@ config0 = mkConf $ L.Root c $ reverse l config1 ∷ CPicker.Props config1 = mkConf $ mkLayout - (H.ClassName "ColorPicker--large") + [H.ClassName "ColorPicker--large", H.ClassName "ColorPicker--inline"] [ [ L.componentHue , L.componentSaturationHSV , L.componentValue @@ -107,7 +109,12 @@ config1 = mkConf $ mkLayout config2 ∷ CPicker.Props config2 = mkConf $ mkLayout - (H.ClassName "ColorPicker--small") + [H.ClassName "ColorPicker--small", H.ClassName "ColorPicker--inline"] + [ [ const componentRedORNoRed ]] + +config3 ∷ CPicker.Props +config3 = mkConf $ mkLayout + [H.ClassName "ColorPicker--small", H.ClassName "ColorPicker--block"] [ [ const componentRedORNoRed ]] componentRedORNoRed ∷ L.PickerComponent @@ -139,11 +146,11 @@ mkConf ∷ L.Layout → CPicker.Props mkConf = { layout: _ } mkLayout - ∷ H.ClassName + ∷ Array H.ClassName → Array (Array (L.InputProps → L.PickerComponent)) → L.Layout mkLayout root editGroups = - [ H.ClassName "ColorPicker", root ] `L.Root` + ([ H.ClassName "ColorPicker"] <> root) `L.Root` [ [ H.ClassName "ColorPicker-dragger" ] `L.Group` [ L.Component $ L.componentDragSV { root: [ H.ClassName "ColorPicker-field" ] diff --git a/example/styles.css b/example/styles.css index ce7cfc3..037a65d 100644 --- a/example/styles.css +++ b/example/styles.css @@ -1,8 +1,13 @@ .ColorPicker { padding: 0.3em; - display: flex; background: hsl(0, 0%, 80%); } +.ColorPicker--block { + display: flex; +} +.ColorPicker--inline { + display: inline-flex; +} .IsLight { color: black; } .IsDark { color: white; } diff --git a/src/ColorPicker/Halogen/Component.purs b/src/ColorPicker/Halogen/Component.purs index 0b5d7ff..af6ddf5 100644 --- a/src/ColorPicker/Halogen/Component.purs +++ b/src/ColorPicker/Halogen/Component.purs @@ -10,7 +10,6 @@ module ColorPicker.Halogen.Component import Prelude import Color (Color) -import Color as Color import ColorPicker.Halogen.Layout (ChildLayout(..), InputTextValue, Layout(..), PickerComponent(..), PositionUpdate, ValueHistory) import ColorPicker.Halogen.Utils.Drag as Drag import Control.Monad.Aff.Class (class MonadAff) @@ -76,11 +75,8 @@ type DSL m = H.ParentDSL State Query ChildQuery Slot Message m type PickerEffects r = Drag.DragEffects r -initialColor ∷ Color -initialColor = Color.hsl 0.0 0.0 0.0 - -picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ H.Component HH.HTML Query Props Message m -picker = H.lifecycleParentComponent +picker ∷ ∀ m r. MonadAff (PickerEffects r) m ⇒ Color → H.Component HH.HTML Query Props Message m +picker initialColor = H.lifecycleParentComponent { initialState: { color: { current: initialColor, old: [] } , inputValues: mempty