text: // Generated by purs bundle 0.13.4
  var PS = {};
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Function"] = $PS["Data.Function"] || {};
    var exports = $PS["Data.Function"];
    var flip = function (f) {
        return function (b) {
            return function (a) {
                return f(a)(b);
            };
        };
    };
    var $$const = function (a) {
        return function (v) {
            return a;
        };
    };
    exports["flip"] = flip;
    exports["const"] = $$const;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.unit = {};
  })(PS["Data.Unit"] = PS["Data.Unit"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Unit"] = $PS["Data.Unit"] || {};
    var exports = $PS["Data.Unit"];
    var $foreign = $PS["Data.Unit"];
    exports["unit"] = $foreign.unit;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Semigroupoid"] = $PS["Control.Semigroupoid"] || {};
    var exports = $PS["Control.Semigroupoid"];
    var Semigroupoid = function (compose) {
        this.compose = compose;
    };
    var semigroupoidFn = new Semigroupoid(function (f) {
        return function (g) {
            return function (x) {
                return f(g(x));
            };
        };
    });
    exports["semigroupoidFn"] = semigroupoidFn;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Category"] = $PS["Control.Category"] || {};
    var exports = $PS["Control.Category"];
    var Control_Semigroupoid = $PS["Control.Semigroupoid"];                
    var Category = function (Semigroupoid0, identity) {
        this.Semigroupoid0 = Semigroupoid0;
        this.identity = identity;
    };
    var identity = function (dict) {
        return dict.identity;
    };
    var categoryFn = new Category(function () {
        return Control_Semigroupoid.semigroupoidFn;
    }, function (x) {
        return x;
    });
    exports["identity"] = identity;
    exports["categoryFn"] = categoryFn;
  })(PS);
  (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($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Functor"] = $PS["Data.Functor"] || {};
    var exports = $PS["Data.Functor"];
    var $foreign = $PS["Data.Functor"];
    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 mapFlipped = function (dictFunctor) {
        return function (fa) {
            return function (f) {
                return map(dictFunctor)(f)(fa);
            };
        };
    };
    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 functorArray = new Functor($foreign.arrayMap);
    exports["Functor"] = Functor;
    exports["map"] = map;
    exports["mapFlipped"] = mapFlipped;
    exports["void"] = $$void;
    exports["voidLeft"] = voidLeft;
    exports["functorArray"] = functorArray;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Apply"] = $PS["Control.Apply"] || {};
    var exports = $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 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.identity(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;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Applicative"] = $PS["Control.Applicative"] || {};
    var exports = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    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 unless = 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 62, column 1 - line 62, column 65): " + [ v.constructor.name, v1.constructor.name ]);
            };
        };
    };
    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["pure"] = pure;
    exports["liftA1"] = liftA1;
    exports["unless"] = unless;
    exports["when"] = when;
  })(PS);
  (function(exports) {
    "use strict";
  
    // module Unsafe.Coerce
  
    exports.unsafeCoerce = function (x) {
      return x;
    };
  })(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Unsafe.Coerce"] = $PS["Unsafe.Coerce"] || {};
    var exports = $PS["Unsafe.Coerce"];
    var $foreign = $PS["Unsafe.Coerce"];
    exports["unsafeCoerce"] = $foreign.unsafeCoerce;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Exists"] = $PS["Data.Exists"] || {};
    var exports = $PS["Data.Exists"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
    var runExists = Unsafe_Coerce.unsafeCoerce;
    var mkExists = Unsafe_Coerce.unsafeCoerce;
    exports["mkExists"] = mkExists;
    exports["runExists"] = runExists;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Coyoneda"] = $PS["Data.Coyoneda"] || {};
    var exports = $PS["Data.Coyoneda"];
    var Control_Category = $PS["Control.Category"];
    var Data_Exists = $PS["Data.Exists"];
    var Data_Functor = $PS["Data.Functor"];                        
    var CoyonedaF = (function () {
        function CoyonedaF(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        CoyonedaF.create = function (value0) {
            return function (value1) {
                return new CoyonedaF(value0, value1);
            };
        };
        return CoyonedaF;
    })();
    var Coyoneda = function (x) {
        return x;
    };
    var unCoyoneda = function (f) {
        return function (v) {
            return Data_Exists.runExists(function (v1) {
                return f(v1.value0)(v1.value1);
            })(v);
        };
    };
    var coyoneda = function (k) {
        return function (fi) {
            return Coyoneda(Data_Exists.mkExists(new CoyonedaF(k, fi)));
        };
    };
    var functorCoyoneda = new Data_Functor.Functor(function (f) {
        return function (v) {
            return Data_Exists.runExists(function (v1) {
                return coyoneda(function ($85) {
                    return f(v1.value0($85));
                })(v1.value1);
            })(v);
        };
    });
    var liftCoyoneda = coyoneda(Control_Category.identity(Control_Category.categoryFn));
    exports["unCoyoneda"] = unCoyoneda;
    exports["liftCoyoneda"] = liftCoyoneda;
    exports["functorCoyoneda"] = functorCoyoneda;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Bind"] = $PS["Control.Bind"] || {};
    var exports = $PS["Control.Bind"];
    var Data_Function = $PS["Data.Function"];                
    var Discard = function (discard) {
        this.discard = discard;
    };
    var Bind = function (Apply0, bind) {
        this.Apply0 = Apply0;
        this.bind = bind;
    };
    var discard = function (dict) {
        return dict.discard;
    };                     
    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["bind"] = bind;
    exports["bindFlipped"] = bindFlipped;
    exports["discard"] = discard;
    exports["composeKleisliFlipped"] = composeKleisliFlipped;
    exports["discardUnit"] = discardUnit;
  })(PS);
  (function(exports) {
    "use strict";
  
    var refEq = function (r1) {
      return function (r2) {
        return r1 === r2;
      };
    };
  
    exports.eqBooleanImpl = refEq;
    exports.eqIntImpl = refEq; 
    exports.eqStringImpl = refEq;
  })(PS["Data.Eq"] = PS["Data.Eq"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Eq"] = $PS["Data.Eq"] || {};
    var exports = $PS["Data.Eq"];
    var $foreign = $PS["Data.Eq"];
    var Eq = function (eq) {
        this.eq = eq;
    }; 
    var eqUnit = new Eq(function (v) {
        return function (v1) {
            return true;
        };
    });
    var eqString = new Eq($foreign.eqStringImpl);
    var eqInt = new Eq($foreign.eqIntImpl);  
    var eqBoolean = new Eq($foreign.eqBooleanImpl);
    var eq = function (dict) {
        return dict.eq;
    };
    exports["Eq"] = Eq;
    exports["eq"] = eq;
    exports["eqBoolean"] = eqBoolean;
    exports["eqInt"] = eqInt;
    exports["eqString"] = eqString;
    exports["eqUnit"] = eqUnit;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Maybe"] = $PS["Data.Maybe"] || {};
    var exports = $PS["Data.Maybe"];
    var Control_Apply = $PS["Control.Apply"];
    var Control_Bind = $PS["Control.Bind"];
    var Control_Category = $PS["Control.Category"];
    var Data_Eq = $PS["Data.Eq"];
    var Data_Function = $PS["Data.Function"];
    var Data_Functor = $PS["Data.Functor"];          
    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 217, column 1 - line 217, 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.identity(Control_Category.categoryFn));
    }; 
    var eqMaybe = function (dictEq) {
        return new Data_Eq.Eq(function (x) {
            return function (y) {
                if (x instanceof Nothing && y instanceof Nothing) {
                    return true;
                };
                if (x instanceof Just && y instanceof Just) {
                    return Data_Eq.eq(dictEq)(x.value0)(y.value0);
                };
                return false;
            };
        });
    };
    var applyMaybe = new Control_Apply.Apply(function () {
        return functorMaybe;
    }, function (v) {
        return function (v1) {
            if (v instanceof Just) {
                return Data_Functor.map(functorMaybe)(v.value0)(v1);
            };
            if (v instanceof Nothing) {
                return Nothing.value;
            };
            throw new Error("Failed pattern match at Data.Maybe (line 67, column 1 - line 69, column 30): " + [ v.constructor.name, v1.constructor.name ]);
        };
    });
    var bindMaybe = new Control_Bind.Bind(function () {
        return applyMaybe;
    }, function (v) {
        return function (v1) {
            if (v instanceof Just) {
                return v1(v.value0);
            };
            if (v instanceof Nothing) {
                return Nothing.value;
            };
            throw new Error("Failed pattern match at Data.Maybe (line 125, column 1 - line 127, column 28): " + [ v.constructor.name, v1.constructor.name ]);
        };
    });
    exports["Nothing"] = Nothing;
    exports["Just"] = Just;
    exports["maybe"] = maybe;
    exports["fromMaybe"] = fromMaybe;
    exports["isJust"] = isJust;
    exports["isNothing"] = isNothing;
    exports["functorMaybe"] = functorMaybe;
    exports["bindMaybe"] = bindMaybe;
    exports["eqMaybe"] = eqMaybe;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Monoid"] = $PS["Data.Monoid"] || {};
    var exports = $PS["Data.Monoid"];
    var mempty = function (dict) {
        return dict.mempty;
    };
    exports["mempty"] = mempty;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Foldable"] = $PS["Data.Foldable"] || {};
    var exports = $PS["Data.Foldable"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    var Data_Function = $PS["Data.Function"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Monoid = $PS["Data.Monoid"];
    var Data_Unit = $PS["Data.Unit"];                
    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 () {
                    var $197 = Control_Apply.applySecond(dictApplicative.Apply0());
                    return function ($198) {
                        return $197(f($198));
                    };
                })())(Control_Applicative.pure(dictApplicative)(Data_Unit.unit));
            };
        };
    };
    var for_ = function (dictApplicative) {
        return function (dictFoldable) {
            return Data_Function.flip(traverse_(dictApplicative)(dictFoldable));
        };
    };
    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 129, column 1 - line 135, column 27): " + [ 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 129, column 1 - line 135, column 27): " + [ 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 129, column 1 - line 135, column 27): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
            };
        };
    });
    var foldMap = function (dict) {
        return dict.foldMap;
    };
    exports["Foldable"] = Foldable;
    exports["foldr"] = foldr;
    exports["foldl"] = foldl;
    exports["foldMap"] = foldMap;
    exports["traverse_"] = traverse_;
    exports["for_"] = for_;
    exports["foldableMaybe"] = foldableMaybe;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Alt"] = $PS["Control.Alt"] || {};
    var exports = $PS["Control.Alt"];                          
    var Alt = function (Functor0, alt) {
        this.Functor0 = Functor0;
        this.alt = alt;
    };
    exports["Alt"] = Alt;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Plus"] = $PS["Control.Plus"] || {};
    var exports = $PS["Control.Plus"];                   
    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);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Semigroup"] = $PS["Data.Semigroup"] || {};
    var exports = $PS["Data.Semigroup"];
    var Semigroup = function (append) {
        this.append = append;
    };
    var append = function (dict) {
        return dict.append;
    };
    exports["Semigroup"] = Semigroup;
    exports["append"] = append;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.List.Types"] = $PS["Data.List.Types"] || {};
    var exports = $PS["Data.List.Types"];
    var Control_Alt = $PS["Control.Alt"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    var Control_Plus = $PS["Control.Plus"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_Function = $PS["Data.Function"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Monoid = $PS["Data.Monoid"];
    var Data_Semigroup = $PS["Data.Semigroup"];                    
    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 listMap = function (f) {
        var chunkedRevMap = function ($copy_chunksAcc) {
            return function ($copy_v) {
                var $tco_var_chunksAcc = $copy_chunksAcc;
                var $tco_done = false;
                var $tco_result;
                function $tco_loop(chunksAcc, v) {
                    if (v instanceof Cons && (v.value1 instanceof Cons && v.value1.value1 instanceof Cons)) {
                        $tco_var_chunksAcc = new Cons(v, chunksAcc);
                        $copy_v = v.value1.value1.value1;
                        return;
                    };
                    var unrolledMap = function (v1) {
                        if (v1 instanceof Cons && (v1.value1 instanceof Cons && v1.value1.value1 instanceof Nil)) {
                            return new Cons(f(v1.value0), new Cons(f(v1.value1.value0), Nil.value));
                        };
                        if (v1 instanceof Cons && v1.value1 instanceof Nil) {
                            return new Cons(f(v1.value0), Nil.value);
                        };
                        return Nil.value;
                    };
                    var reverseUnrolledMap = function ($copy_v1) {
                        return function ($copy_acc) {
                            var $tco_var_v1 = $copy_v1;
                            var $tco_done = false;
                            var $tco_result;
                            function $tco_loop(v1, acc) {
                                if (v1 instanceof Cons && (v1.value0 instanceof Cons && (v1.value0.value1 instanceof Cons && v1.value0.value1.value1 instanceof Cons))) {
                                    $tco_var_v1 = v1.value1;
                                    $copy_acc = new Cons(f(v1.value0.value0), new Cons(f(v1.value0.value1.value0), new Cons(f(v1.value0.value1.value1.value0), acc)));
                                    return;
                                };
                                $tco_done = true;
                                return acc;
                            };
                            while (!$tco_done) {
                                $tco_result = $tco_loop($tco_var_v1, $copy_acc);
                            };
                            return $tco_result;
                        };
                    };
                    $tco_done = true;
                    return reverseUnrolledMap(chunksAcc)(unrolledMap(v));
                };
                while (!$tco_done) {
                    $tco_result = $tco_loop($tco_var_chunksAcc, $copy_v);
                };
                return $tco_result;
            };
        };
        return chunkedRevMap(Nil.value);
    };
    var functorList = new Data_Functor.Functor(listMap);                 
    var foldableList = new Data_Foldable.Foldable(function (dictMonoid) {
        return function (f) {
            return Data_Foldable.foldl(foldableList)(function (acc) {
                var $202 = Data_Semigroup.append(dictMonoid.Semigroup0())(acc);
                return function ($203) {
                    return $202(f($203));
                };
            })(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 109, column 12 - line 111, 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 = Data_Foldable.foldl(foldableList)(Data_Function.flip(Cons.create))(Nil.value);
            var $204 = Data_Foldable.foldl(foldableList)(Data_Function.flip(f))(b);
            return function ($205) {
                return $204(rev($205));
            };
        };
    });
    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 155, column 1 - line 157, column 48): " + [ v.constructor.name, v1.constructor.name ]);
        };
    });
    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);
    exports["Nil"] = Nil;
    exports["Cons"] = Cons;
    exports["NonEmptyList"] = NonEmptyList;
    exports["semigroupList"] = semigroupList;
    exports["foldableList"] = foldableList;
    exports["applicativeList"] = applicativeList;
    exports["plusList"] = plusList;
  })(PS);
  (function(exports) {
    "use strict";
  
    var unsafeCompareImpl = function (lt) {
      return function (eq) {
        return function (gt) {
          return function (x) {
            return function (y) {
              return x < y ? lt : x === y ? eq : gt;
            };
          };
        };
      };
    };                                         
    exports.ordIntImpl = unsafeCompareImpl;   
    exports.ordStringImpl = unsafeCompareImpl;
  })(PS["Data.Ord"] = PS["Data.Ord"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Ordering"] = $PS["Data.Ordering"] || {};
    var exports = $PS["Data.Ordering"];              
    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);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Ord"] = $PS["Data.Ord"] || {};
    var exports = $PS["Data.Ord"];
    var $foreign = $PS["Data.Ord"];
    var Data_Eq = $PS["Data.Eq"];
    var Data_Ordering = $PS["Data.Ordering"];
    var Ord = function (Eq0, compare) {
        this.Eq0 = Eq0;
        this.compare = compare;
    }; 
    var ordUnit = new Ord(function () {
        return Data_Eq.eqUnit;
    }, function (v) {
        return function (v1) {
            return Data_Ordering.EQ.value;
        };
    });
    var ordString = new Ord(function () {
        return Data_Eq.eqString;
    }, $foreign.ordStringImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
    var ordInt = new Ord(function () {
        return Data_Eq.eqInt;
    }, $foreign.ordIntImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
    var compare = function (dict) {
        return dict.compare;
    };
    exports["Ord"] = Ord;
    exports["compare"] = compare;
    exports["ordInt"] = ordInt;
    exports["ordString"] = ordString;
    exports["ordUnit"] = ordUnit;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Tuple"] = $PS["Data.Tuple"] || {};
    var exports = $PS["Data.Tuple"];
    var Data_Eq = $PS["Data.Eq"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Ord = $PS["Data.Ord"];
    var Data_Ordering = $PS["Data.Ordering"];                
    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 functorTuple = new Data_Functor.Functor(function (f) {
        return function (m) {
            return new Tuple(m.value0, f(m.value1));
        };
    });                                                                                                   
    var fst = function (v) {
        return v.value0;
    }; 
    var eqTuple = function (dictEq) {
        return function (dictEq1) {
            return new Data_Eq.Eq(function (x) {
                return function (y) {
                    return Data_Eq.eq(dictEq)(x.value0)(y.value0) && Data_Eq.eq(dictEq1)(x.value1)(y.value1);
                };
            });
        };
    };
    var ordTuple = function (dictOrd) {
        return function (dictOrd1) {
            return new Data_Ord.Ord(function () {
                return eqTuple(dictOrd.Eq0())(dictOrd1.Eq0());
            }, function (x) {
                return function (y) {
                    var v = Data_Ord.compare(dictOrd)(x.value0)(y.value0);
                    if (v instanceof Data_Ordering.LT) {
                        return Data_Ordering.LT.value;
                    };
                    if (v instanceof Data_Ordering.GT) {
                        return Data_Ordering.GT.value;
                    };
                    return Data_Ord.compare(dictOrd1)(x.value1)(y.value1);
                };
            });
        };
    };
    exports["Tuple"] = Tuple;
    exports["fst"] = fst;
    exports["snd"] = snd;
    exports["ordTuple"] = ordTuple;
    exports["functorTuple"] = functorTuple;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Map.Internal"] = $PS["Data.Map.Internal"] || {};
    var exports = $PS["Data.Map.Internal"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_List_Types = $PS["Data.List.Types"];
    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_Tuple = $PS["Data.Tuple"];                          
    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.Internal (line 612, column 1 - line 612, 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.Internal (line 200, column 5 - line 200, 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 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.Internal (line 96, column 1 - line 99, column 110): " + [ 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.Internal (line 418, column 3 - line 423, column 88): " + [ v.value0.constructor.name ]);
                    };
                    throw new Error("Failed pattern match at Data.Map.Internal (line 415, column 1 - line 415, 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.Internal (line 454, column 5 - line 459, column 108): " + [ v1.value0.constructor.name, v2.constructor.name ]);
                            };
                            throw new Error("Failed pattern match at Data.Map.Internal (line 451, column 3 - line 451, 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.Internal (line 434, column 3 - line 434, 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 ($copy_ctxs) {
                return function ($copy_tree) {
                    var $tco_var_ctxs = $copy_ctxs;
                    var $tco_done = false;
                    var $tco_result;
                    function $tco_loop(ctxs, tree) {
                        if (ctxs instanceof Data_List_Types.Nil) {
                            $tco_done = true;
                            return tree;
                        };
                        if (ctxs instanceof Data_List_Types.Cons) {
                            if (ctxs.value0 instanceof TwoLeft && (ctxs.value0.value2 instanceof Leaf && tree instanceof Leaf)) {
                                $tco_done = true;
                                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)) {
                                $tco_done = true;
                                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) {
                                $tco_var_ctxs = ctxs.value1;
                                $copy_tree = 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);
                                return;
                            };
                            if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Two) {
                                $tco_var_ctxs = ctxs.value1;
                                $copy_tree = 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);
                                return;
                            };
                            if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Three) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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))) {
                                $tco_done = true;
                                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))) {
                                $tco_done = true;
                                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))) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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) {
                                $tco_done = true;
                                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.Internal (line 511, column 9 - line 528, column 136): " + [ ctxs.value0.constructor.name, tree.constructor.name ]);
                        };
                        throw new Error("Failed pattern match at Data.Map.Internal (line 508, column 5 - line 528, column 136): " + [ ctxs.constructor.name ]);
                    };
                    while (!$tco_done) {
                        $tco_result = $tco_loop($tco_var_ctxs, $copy_tree);
                    };
                    return $tco_result;
                };
            };
            var removeMaxNode = 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 Two && (m.value0 instanceof Leaf && m.value3 instanceof Leaf)) {
                            $tco_done = true;
                            return up(ctx)(Leaf.value);
                        };
                        if (m instanceof Two) {
                            $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 && (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf))) {
                            $tco_done = true;
                            return up(new Data_List_Types.Cons(new TwoRight(Leaf.value, m.value1, m.value2), ctx))(Leaf.value);
                        };
                        if (m instanceof Three) {
                            $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.Internal (line 540, column 5 - line 544, column 107): " + [ m.constructor.name ]);
                    };
                    while (!$tco_done) {
                        $tco_result = $tco_loop($tco_var_ctx, $copy_m);
                    };
                    return $tco_result;
                };
            };
            var maxNode = function ($copy_m) {
                var $tco_done = false;
                var $tco_result;
                function $tco_loop(m) {
                    if (m instanceof Two && m.value3 instanceof Leaf) {
                        $tco_done = true;
                        return {
                            key: m.value1,
                            value: m.value2
                        };
                    };
                    if (m instanceof Two) {
                        $copy_m = m.value3;
                        return;
                    };
                    if (m instanceof Three && m.value6 instanceof Leaf) {
                        $tco_done = true;
                        return {
                            key: m.value4,
                            value: m.value5
                        };
                    };
                    if (m instanceof Three) {
                        $copy_m = m.value6;
                        return;
                    };
                    throw new Error("Failed pattern match at Data.Map.Internal (line 531, column 33 - line 535, column 45): " + [ m.constructor.name ]);
                };
                while (!$tco_done) {
                    $tco_result = $tco_loop($copy_m);
                };
                return $tco_result;
            };
            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.Internal (line 481, column 34 - line 504, 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));
            };
        };
    }; 
    var alter = function (dictOrd) {
        return function (f) {
            return function (k) {
                return function (m) {
                    var v = f(lookup(dictOrd)(k)(m));
                    if (v instanceof Data_Maybe.Nothing) {
                        return $$delete(dictOrd)(k)(m);
                    };
                    if (v instanceof Data_Maybe.Just) {
                        return insert(dictOrd)(k)(v.value0)(m);
                    };
                    throw new Error("Failed pattern match at Data.Map.Internal (line 549, column 15 - line 551, column 25): " + [ v.constructor.name ]);
                };
            };
        };
    };
    exports["empty"] = empty;
    exports["insert"] = insert;
    exports["lookup"] = lookup;
    exports["delete"] = $$delete;
    exports["pop"] = pop;
    exports["member"] = member;
    exports["alter"] = alter;
    exports["functorMap"] = functorMap;
    exports["foldableMap"] = foldableMap;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Symbol"] = $PS["Data.Symbol"] || {};
    var exports = $PS["Data.Symbol"];      
    var SProxy = (function () {
        function SProxy() {
  
        };
        SProxy.value = new SProxy();
        return SProxy;
    })();
    var IsSymbol = function (reflectSymbol) {
        this.reflectSymbol = reflectSymbol;
    };
    var reflectSymbol = function (dict) {
        return dict.reflectSymbol;
    };
    exports["IsSymbol"] = IsSymbol;
    exports["reflectSymbol"] = reflectSymbol;
    exports["SProxy"] = SProxy;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Data.OrdBox"] = $PS["Halogen.Data.OrdBox"] || {};
    var exports = $PS["Halogen.Data.OrdBox"];
    var Data_Eq = $PS["Data.Eq"];
    var Data_Ord = $PS["Data.Ord"];                
    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 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["ordOrdBox"] = ordOrdBox;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Data.Slot"] = $PS["Halogen.Data.Slot"] || {};
    var exports = $PS["Halogen.Data.Slot"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_Map_Internal = $PS["Data.Map.Internal"];
    var Data_Ord = $PS["Data.Ord"];
    var Data_Symbol = $PS["Data.Symbol"];
    var Data_Tuple = $PS["Data.Tuple"];
    var Halogen_Data_OrdBox = $PS["Halogen.Data.OrdBox"];
    var pop = function (dictCons) {
        return function (dictIsSymbol) {
            return function (dictOrd) {
                return function (sym) {
                    return function (key) {
                        return function (v) {
                            return Data_Map_Internal.pop(Data_Tuple.ordTuple(Data_Ord.ordString)(Halogen_Data_OrdBox.ordOrdBox))(new Data_Tuple.Tuple(Data_Symbol.reflectSymbol(dictIsSymbol)(sym), Halogen_Data_OrdBox.mkOrdBox(dictOrd)(key)))(v);
                        };
                    };
                };
            };
        };
    };
    var lookup = function (dictCons) {
        return function (dictIsSymbol) {
            return function (dictOrd) {
                return function (sym) {
                    return function (key) {
                        return function (v) {
                            return Data_Map_Internal.lookup(Data_Tuple.ordTuple(Data_Ord.ordString)(Halogen_Data_OrdBox.ordOrdBox))(new Data_Tuple.Tuple(Data_Symbol.reflectSymbol(dictIsSymbol)(sym), Halogen_Data_OrdBox.mkOrdBox(dictOrd)(key)))(v);
                        };
                    };
                };
            };
        };
    };
    var insert = function (dictCons) {
        return function (dictIsSymbol) {
            return function (dictOrd) {
                return function (sym) {
                    return function (key) {
                        return function (val) {
                            return function (v) {
                                return Data_Map_Internal.insert(Data_Tuple.ordTuple(Data_Ord.ordString)(Halogen_Data_OrdBox.ordOrdBox))(new Data_Tuple.Tuple(Data_Symbol.reflectSymbol(dictIsSymbol)(sym), Halogen_Data_OrdBox.mkOrdBox(dictOrd)(key)))(val)(v);
                            };
                        };
                    };
                };
            };
        };
    };
    var foreachSlot = function (dictApplicative) {
        return function (v) {
            return function (k) {
                return Data_Foldable.traverse_(dictApplicative)(Data_Map_Internal.foldableMap)(function ($37) {
                    return k($37);
                })(v);
            };
        };
    };
    var empty = Data_Map_Internal.empty;
    exports["empty"] = empty;
    exports["lookup"] = lookup;
    exports["insert"] = insert;
    exports["pop"] = pop;
    exports["foreachSlot"] = foreachSlot;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad"] = $PS["Control.Monad"] || {};
    var exports = $PS["Control.Monad"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Bind = $PS["Control.Bind"];                
    var Monad = function (Applicative0, Bind1) {
        this.Applicative0 = Applicative0;
        this.Bind1 = Bind1;
    };
    var unlessM = function (dictMonad) {
        return function (mb) {
            return function (m) {
                return Control_Bind.bind(dictMonad.Bind1())(mb)(function (v) {
                    return Control_Applicative.unless(dictMonad.Applicative0())(v)(m);
                });
            };
        };
    };
    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;
    exports["unlessM"] = unlessM;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.pureE = function (a) {
      return function () {
        return a;
      };
    };
  
    exports.bindE = function (a) {
      return function (f) {
        return function () {
          return f(a())();
        };
      };
    };
  })(PS["Effect"] = PS["Effect"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect"] = $PS["Effect"] || {};
    var exports = $PS["Effect"];
    var $foreign = $PS["Effect"];
    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 monadEffect = new Control_Monad.Monad(function () {
        return applicativeEffect;
    }, function () {
        return bindEffect;
    });
    var bindEffect = new Control_Bind.Bind(function () {
        return applyEffect;
    }, $foreign.bindE);
    var applyEffect = new Control_Apply.Apply(function () {
        return functorEffect;
    }, Control_Monad.ap(monadEffect));
    var applicativeEffect = new Control_Applicative.Applicative(function () {
        return applyEffect;
    }, $foreign.pureE);
    var functorEffect = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEffect));
    exports["functorEffect"] = functorEffect;
    exports["applicativeEffect"] = applicativeEffect;
    exports["bindEffect"] = bindEffect;
    exports["monadEffect"] = monadEffect;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.new = function (val) {
      return function () {
        return { value: val };
      };
    };
  
    exports.read = function (ref) {
      return function () {
        return ref.value;
      };
    };
  
    exports["modify'"] = function (f) {
      return function (ref) {
        return function () {
          var t = f(ref.value);
          ref.value = t.state;
          return t.value;
        };
      };
    };
  
    exports.write = function (val) {
      return function (ref) {
        return function () {
          ref.value = val;
          return {};
        };
      };
    };
  })(PS["Effect.Ref"] = PS["Effect.Ref"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Ref"] = $PS["Effect.Ref"] || {};
    var exports = $PS["Effect.Ref"];
    var $foreign = $PS["Effect.Ref"];
    var Data_Functor = $PS["Data.Functor"];
    var Effect = $PS["Effect"];                
    var modify = function (f) {
        return $foreign["modify'"](function (s) {
            var s$prime = f(s);
            return {
                state: s$prime,
                value: s$prime
            };
        });
    };
    var modify_ = function (f) {
        return function (s) {
            return Data_Functor["void"](Effect.functorEffect)(modify(f)(s));
        };
    };
    exports["modify_"] = modify_;
    exports["new"] = $foreign["new"];
    exports["read"] = $foreign.read;
    exports["modify'"] = $foreign["modify'"];
    exports["write"] = $foreign.write;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Rec.Class"] = $PS["Control.Monad.Rec.Class"] || {};
    var exports = $PS["Control.Monad.Rec.Class"];
    var Control_Bind = $PS["Control.Bind"];
    var Data_Functor = $PS["Data.Functor"];
    var Effect = $PS["Effect"];
    var Effect_Ref = $PS["Effect.Ref"];                
    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 monadRecEffect = new MonadRec(function () {
        return Effect.monadEffect;
    }, function (f) {
        return function (a) {
            var fromDone = function (v) {
                if (v instanceof Done) {
                    return v.value0;
                };
                throw new Error("Failed pattern match at Control.Monad.Rec.Class (line 113, column 30 - line 113, column 44): " + [ v.constructor.name ]);
            };
            return function __do() {
                var v = Control_Bind.bindFlipped(Effect.bindEffect)(Effect_Ref["new"])(f(a))();
                (function () {
                    while (!(function __do() {
                        var v1 = Effect_Ref.read(v)();
                        if (v1 instanceof Loop) {
                            var v2 = f(v1.value0)();
                            var v3 = Effect_Ref.write(v2)(v)();
                            return false;
                        };
                        if (v1 instanceof Done) {
                            return true;
                        };
                        throw new Error("Failed pattern match at Control.Monad.Rec.Class (line 104, column 22 - line 109, column 28): " + [ v1.constructor.name ]);
                    })()) {
  
                    };
                    return {};
                })();
                return Data_Functor.map(Effect.functorEffect)(fromDone)(Effect_Ref.read(v))();
            };
        };
    });
    exports["Loop"] = Loop;
    exports["Done"] = Done;
    exports["MonadRec"] = MonadRec;
    exports["tailRecM"] = tailRecM;
    exports["monadRecEffect"] = monadRecEffect;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.List"] = $PS["Data.List"] || {};
    var exports = $PS["Data.List"];
    var Data_List_Types = $PS["Data.List.Types"];
    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 368, column 3 - line 368, 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);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.CatQueue"] = $PS["Data.CatQueue"] || {};
    var exports = $PS["Data.CatQueue"];
    var Data_List = $PS["Data.List"];
    var Data_List_Types = $PS["Data.List.Types"];
    var Data_Maybe = $PS["Data.Maybe"];
    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 83, column 1 - line 83, 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["empty"] = empty;
    exports["null"] = $$null;
    exports["snoc"] = snoc;
    exports["uncons"] = uncons;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.CatList"] = $PS["Data.CatList"] || {};
    var exports = $PS["Data.CatList"];
    var Data_CatQueue = $PS["Data.CatQueue"];
    var Data_List_Types = $PS["Data.List.Types"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Semigroup = $PS["Data.Semigroup"];
    var Data_Tuple = $PS["Data.Tuple"];                            
    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 (v1) {
            if (v instanceof CatNil) {
                return v1;
            };
            if (v1 instanceof CatNil) {
                return v;
            };
            if (v instanceof CatCons) {
                return new CatCons(v.value0, Data_CatQueue.snoc(v.value1)(v1));
            };
            throw new Error("Failed pattern match at Data.CatList (line 109, column 1 - line 109, column 54): " + [ v.constructor.name, v1.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 $44 = Data_CatQueue["null"](v.value1);
                if ($44) {
                    return CatNil.value;
                };
                return foldr(link)(CatNil.value)(v.value1);
            })()));
        };
        throw new Error("Failed pattern match at Data.CatList (line 100, column 1 - line 100, column 61): " + [ v.constructor.name ]);
    };
    var empty = CatNil.value;
    var append = link;
    var semigroupCatList = new Data_Semigroup.Semigroup(append);
    var snoc = function (cat) {
        return function (a) {
            return append(cat)(new CatCons(a, Data_CatQueue.empty));
        };
    };
    exports["empty"] = empty;
    exports["snoc"] = snoc;
    exports["uncons"] = uncons;
    exports["semigroupCatList"] = semigroupCatList;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Free"] = $PS["Control.Monad.Free"] || {};
    var exports = $PS["Control.Monad.Free"];
    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_Rec_Class = $PS["Control.Monad.Rec.Class"];
    var Data_CatList = $PS["Data.CatList"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Semigroup = $PS["Data.Semigroup"];
    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(v.value0.value0);
                };
                if (v2 instanceof Data_Maybe.Just) {
                    $copy_v = concatF(runExpF(v2.value0.value0)(v.value0.value0))(v2.value0.value1);
                    return;
                };
                throw new Error("Failed pattern match at Control.Monad.Free (line 227, column 7 - line 231, column 64): " + [ v2.constructor.name ]);
            };
            if (v.value0 instanceof Bind) {
                $tco_done = true;
                return new Bind(v.value0.value0, function (a) {
                    return concatF(v.value0.value1(a))(v.value1);
                });
            };
            throw new Error("Failed pattern match at Control.Monad.Free (line 225, column 3 - line 233, 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(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 () {
                var $120 = Control_Applicative.pure(freeApplicative);
                return function ($121) {
                    return $120(k($121));
                };
            })())(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)(k));
        };
    });
    var freeApply = new Control_Apply.Apply(function () {
        return freeFunctor;
    }, Control_Monad.ap(freeMonad));
    var freeApplicative = new Control_Applicative.Applicative(function () {
        return freeApply;
    }, function ($122) {
        return fromView(Return.create($122));
    });
    var liftF = function (f) {
        return fromView(new Bind(f, (function () {
            var $123 = Control_Applicative.pure(freeApplicative);
            return function ($124) {
                return $123($124);
            };
        })()));
    };
    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 ($136) {
                        return Control_Monad_Rec_Class.Loop.create(v.value1($136));
                    })(k(v.value0));
                };
                throw new Error("Failed pattern match at Control.Monad.Free (line 158, column 10 - line 160, column 37): " + [ v.constructor.name ]);
            };
            return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go);
        };
    };
    exports["liftF"] = liftF;
    exports["foldFree"] = foldFree;
    exports["freeFunctor"] = freeFunctor;
    exports["freeBind"] = freeBind;
    exports["freeApplicative"] = freeApplicative;
    exports["freeMonad"] = freeMonad;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.State.Class"] = $PS["Control.Monad.State.Class"] || {};
    var exports = $PS["Control.Monad.State.Class"];
    var Data_Tuple = $PS["Data.Tuple"];
    var Data_Unit = $PS["Data.Unit"];                
    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));
            });
        };
    };
    exports["MonadState"] = MonadState;
    exports["modify_"] = modify_;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Query.HalogenM"] = $PS["Halogen.Query.HalogenM"] || {};
    var exports = $PS["Halogen.Query.HalogenM"];
    var Control_Monad_Free = $PS["Control.Monad.Free"];
    var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
    var Data_Ord = $PS["Data.Ord"];                                                  
    var SubscriptionId = function (x) {
        return x;
    };
    var ForkId = 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 Unsubscribe = (function () {
        function Unsubscribe(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Unsubscribe.create = function (value0) {
            return function (value1) {
                return new Unsubscribe(value0, value1);
            };
        };
        return Unsubscribe;
    })();
    var Lift = (function () {
        function Lift(value0) {
            this.value0 = value0;
        };
        Lift.create = function (value0) {
            return new Lift(value0);
        };
        return Lift;
    })();
    var ChildQuery = (function () {
        function ChildQuery(value0) {
            this.value0 = value0;
        };
        ChildQuery.create = function (value0) {
            return new ChildQuery(value0);
        };
        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, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Fork.create = function (value0) {
            return function (value1) {
                return new Fork(value0, value1);
            };
        };
        return Fork;
    })();
    var Kill = (function () {
        function Kill(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Kill.create = function (value0) {
            return function (value1) {
                return new Kill(value0, value1);
            };
        };
        return Kill;
    })();
    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 HalogenM = function (x) {
        return x;
    };
    var ordSubscriptionId = Data_Ord.ordInt;
    var ordForkId = Data_Ord.ordInt;
    var monadHalogenM = Control_Monad_Free.freeMonad;
    var monadStateHalogenM = new Control_Monad_State_Class.MonadState(function () {
        return monadHalogenM;
    }, function ($139) {
        return HalogenM(Control_Monad_Free.liftF(State.create($139)));
    });
    var functorHalogenM = Control_Monad_Free.freeFunctor;
    var bindHalogenM = Control_Monad_Free.freeBind;           
    var applicativeHalogenM = Control_Monad_Free.freeApplicative;
    exports["State"] = State;
    exports["Subscribe"] = Subscribe;
    exports["Unsubscribe"] = Unsubscribe;
    exports["Lift"] = Lift;
    exports["ChildQuery"] = ChildQuery;
    exports["Raise"] = Raise;
    exports["Par"] = Par;
    exports["Fork"] = Fork;
    exports["Kill"] = Kill;
    exports["GetRef"] = GetRef;
    exports["SubscriptionId"] = SubscriptionId;
    exports["ForkId"] = ForkId;
    exports["functorHalogenM"] = functorHalogenM;
    exports["applicativeHalogenM"] = applicativeHalogenM;
    exports["bindHalogenM"] = bindHalogenM;
    exports["monadStateHalogenM"] = monadStateHalogenM;
    exports["ordSubscriptionId"] = ordSubscriptionId;
    exports["ordForkId"] = ordForkId;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Query.HalogenQ"] = $PS["Halogen.Query.HalogenQ"] || {};
    var exports = $PS["Halogen.Query.HalogenQ"];           
    var Initialize = (function () {
        function Initialize(value0) {
            this.value0 = value0;
        };
        Initialize.create = function (value0) {
            return new Initialize(value0);
        };
        return Initialize;
    })();
    var Finalize = (function () {
        function Finalize(value0) {
            this.value0 = value0;
        };
        Finalize.create = function (value0) {
            return new Finalize(value0);
        };
        return Finalize;
    })();
    var Receive = (function () {
        function Receive(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Receive.create = function (value0) {
            return function (value1) {
                return new Receive(value0, value1);
            };
        };
        return Receive;
    })();
    var Action = (function () {
        function Action(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Action.create = function (value0) {
            return function (value1) {
                return new Action(value0, value1);
            };
        };
        return Action;
    })();
    var Query = (function () {
        function Query(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Query.create = function (value0) {
            return function (value1) {
                return new Query(value0, value1);
            };
        };
        return Query;
    })();
    exports["Initialize"] = Initialize;
    exports["Finalize"] = Finalize;
    exports["Receive"] = Receive;
    exports["Action"] = Action;
    exports["Query"] = Query;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Component"] = $PS["Halogen.Component"] || {};
    var exports = $PS["Halogen.Component"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Data_Coyoneda = $PS["Data.Coyoneda"];
    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_Unit = $PS["Data.Unit"];
    var Halogen_Data_Slot = $PS["Halogen.Data.Slot"];
    var Halogen_Query_HalogenM = $PS["Halogen.Query.HalogenM"];
    var Halogen_Query_HalogenQ = $PS["Halogen.Query.HalogenQ"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
    var ComponentSlot = (function () {
        function ComponentSlot(value0) {
            this.value0 = value0;
        };
        ComponentSlot.create = function (value0) {
            return new ComponentSlot(value0);
        };
        return ComponentSlot;
    })();
    var ThunkSlot = (function () {
        function ThunkSlot(value0) {
            this.value0 = value0;
        };
        ThunkSlot.create = function (value0) {
            return new ThunkSlot(value0);
        };
        return ThunkSlot;
    })();
    var unComponentSlot = Unsafe_Coerce.unsafeCoerce;
    var unComponent = Unsafe_Coerce.unsafeCoerce;
    var mkEval = function (args) {
        return function (v) {
            if (v instanceof Halogen_Query_HalogenQ.Initialize) {
                return Data_Functor.voidLeft(Halogen_Query_HalogenM.functorHalogenM)(Data_Foldable.traverse_(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Foldable.foldableMaybe)(args.handleAction)(args.initialize))(v.value0);
            };
            if (v instanceof Halogen_Query_HalogenQ.Finalize) {
                return Data_Functor.voidLeft(Halogen_Query_HalogenM.functorHalogenM)(Data_Foldable.traverse_(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Foldable.foldableMaybe)(args.handleAction)(args.finalize))(v.value0);
            };
            if (v instanceof Halogen_Query_HalogenQ.Receive) {
                return Data_Functor.voidLeft(Halogen_Query_HalogenM.functorHalogenM)(Data_Foldable.traverse_(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Foldable.foldableMaybe)(args.handleAction)(args.receive(v.value0)))(v.value1);
            };
            if (v instanceof Halogen_Query_HalogenQ.Action) {
                return Data_Functor.voidLeft(Halogen_Query_HalogenM.functorHalogenM)(args.handleAction(v.value0))(v.value1);
            };
            if (v instanceof Halogen_Query_HalogenQ.Query) {
                return Data_Coyoneda.unCoyoneda(function (g) {
                    var $28 = Data_Functor.map(Halogen_Query_HalogenM.functorHalogenM)(Data_Maybe.maybe(v.value1(Data_Unit.unit))(g));
                    return function ($29) {
                        return $28(args.handleQuery($29));
                    };
                })(v.value0);
            };
            throw new Error("Failed pattern match at Halogen.Component (line 172, column 15 - line 182, column 70): " + [ v.constructor.name ]);
        };
    };
    var mkComponentSlot = Unsafe_Coerce.unsafeCoerce;
    var mkComponent = Unsafe_Coerce.unsafeCoerce;
    var defaultEval = {
        handleAction: Data_Function["const"](Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Unit.unit)),
        handleQuery: Data_Function["const"](Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(Data_Maybe.Nothing.value)),
        receive: Data_Function["const"](Data_Maybe.Nothing.value),
        initialize: Data_Maybe.Nothing.value,
        finalize: Data_Maybe.Nothing.value
    };
    var componentSlot = function (dictCons) {
        return function (dictIsSymbol) {
            return function (dictOrd) {
                return function (label) {
                    return function (p) {
                        return function (comp) {
                            return function (input) {
                                return function (output) {
                                    return mkComponentSlot({
                                        get: Halogen_Data_Slot.lookup()(dictIsSymbol)(dictOrd)(label)(p),
                                        pop: Halogen_Data_Slot.pop()(dictIsSymbol)(dictOrd)(label)(p),
                                        set: Halogen_Data_Slot.insert()(dictIsSymbol)(dictOrd)(label)(p),
                                        component: comp,
                                        input: new Halogen_Query_HalogenQ.Receive(input, Data_Unit.unit),
                                        output: output
                                    });
                                };
                            };
                        };
                    };
                };
            };
        };
    };
    exports["mkComponent"] = mkComponent;
    exports["unComponent"] = unComponent;
    exports["mkEval"] = mkEval;
    exports["defaultEval"] = defaultEval;
    exports["ComponentSlot"] = ComponentSlot;
    exports["ThunkSlot"] = ThunkSlot;
    exports["componentSlot"] = componentSlot;
    exports["unComponentSlot"] = unComponentSlot;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Newtype"] = $PS["Data.Newtype"] || {};
    var exports = $PS["Data.Newtype"];                                   
    var Newtype = function (unwrap, wrap) {
        this.unwrap = unwrap;
        this.wrap = wrap;
    };
    var unwrap = function (dict) {
        return dict.unwrap;
    };
    exports["unwrap"] = unwrap;
    exports["Newtype"] = Newtype;
  })(PS);
  (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($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Nullable"] = $PS["Data.Nullable"] || {};
    var exports = $PS["Data.Nullable"];
    var $foreign = $PS["Data.Nullable"];
    var Data_Maybe = $PS["Data.Maybe"];              
    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);
  (function(exports) {
    "use strict";
  
    exports.typeOf = function (value) {
      return typeof value;
    };
  })(PS["Foreign"] = PS["Foreign"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Foreign"] = $PS["Foreign"] || {};
    var exports = $PS["Foreign"];
    var $foreign = $PS["Foreign"];
    exports["typeOf"] = $foreign.typeOf;
  })(PS);
  (function(exports) {
    "use strict";
  
    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["Foreign.Object"] = PS["Foreign.Object"] || {});
  (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($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Function.Uncurried"] = $PS["Data.Function.Uncurried"] || {};
    var exports = $PS["Data.Function.Uncurried"];
    var $foreign = $PS["Data.Function.Uncurried"];
    exports["runFn4"] = $foreign.runFn4;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Foreign.Object"] = $PS["Foreign.Object"] || {};
    var exports = $PS["Foreign.Object"];
    var $foreign = $PS["Foreign.Object"];
    var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
    var Data_Maybe = $PS["Data.Maybe"];
    var lookup = Data_Function_Uncurried.runFn4($foreign["_lookup"])(Data_Maybe.Nothing.value)(Data_Maybe.Just.create);
    exports["lookup"] = lookup;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.Machine"] = $PS["Halogen.VDom.Machine"] || {};
    var exports = $PS["Halogen.VDom.Machine"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
    var Step = (function () {
        function Step(value0, value1, value2, value3) {
            this.value0 = value0;
            this.value1 = value1;
            this.value2 = value2;
            this.value3 = value3;
        };
        Step.create = function (value0) {
            return function (value1) {
                return function (value2) {
                    return function (value3) {
                        return new Step(value0, value1, value2, value3);
                    };
                };
            };
        };
        return Step;
    })();
    var unStep = Unsafe_Coerce.unsafeCoerce;
    var step = function (v, a) {
        return v.value2(v.value1, a);
    };
    var mkStep = Unsafe_Coerce.unsafeCoerce;
    var halt = function (v) {
        return v.value3(v.value1);
    };
    var extract = unStep(function (v) {
        return v.value0;
    });
    exports["Step"] = Step;
    exports["mkStep"] = mkStep;
    exports["unStep"] = unStep;
    exports["extract"] = extract;
    exports["step"] = step;
    exports["halt"] = halt;
  })(PS);
  (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) {
        obj[key] = val;
    };
  
    exports.forE = function (a, f) {
      var b = [];
      for (var i = 0; i < a.length; i++) {
        b.push(f(i, a[i]));
      }
      return b;
    };
  
    exports.forEachE = function (a, f) {
      for (var i = 0; i < a.length; i++) {
        f(a[i]);
      }
    };
  
    exports.forInE = function (o, f) {
      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) {
      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) {
      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) {
      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 doc.createTextNode(s);
    };
  
    exports.setTextContent = function (s, n) {
      n.textContent = s;
    };
  
    exports.createElement = function (ns, name, doc) {
      if (ns != null) {
        return doc.createElementNS(ns, name);
      } else {
        return doc.createElement(name)
      }
    };
  
    exports.insertChildIx = function (i, a, b) {
      var n = b.childNodes.item(i) || null;
      if (n !== a) {
        b.insertBefore(a, n);
      }
    };
  
    exports.removeChild = function (a, b) {
      if (b && a.parentNode === b) {
        b.removeChild(a);
      }
    };
  
    exports.parentNode = function (a) {
      return a.parentNode;
    };
  
    exports.setAttribute = function (ns, attr, val, el) {
      if (ns != null) {
        el.setAttributeNS(ns, attr, val);
      } else {
        el.setAttribute(attr, val);
      }
    };
  
    exports.removeAttribute = function (ns, attr, el) {
      if (ns != null) {
        el.removeAttributeNS(ns, attr);
      } else {
        el.removeAttribute(attr);
      }
    };
  
    exports.addEventListener = function (ev, listener, el) {
      el.addEventListener(ev, listener, false);
    };
  
    exports.removeEventListener = function (ev, listener, el) {
      el.removeEventListener(ev, listener, false);
    };
  
    exports.jsUndefined = void 0;
  })(PS["Halogen.VDom.Util"] = PS["Halogen.VDom.Util"] || {});
  (function(exports) {
    "use strict";
  
    exports["new"] = function () {
      return {};
    };
  })(PS["Foreign.Object.ST"] = PS["Foreign.Object.ST"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Foreign.Object.ST"] = $PS["Foreign.Object.ST"] || {};
    var exports = $PS["Foreign.Object.ST"];
    var $foreign = $PS["Foreign.Object.ST"];
    exports["new"] = $foreign["new"];
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.Util"] = $PS["Halogen.VDom.Util"] || {};
    var exports = $PS["Halogen.VDom.Util"];
    var $foreign = $PS["Halogen.VDom.Util"];
    var Foreign_Object_ST = $PS["Foreign.Object.ST"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
    var unsafeLookup = $foreign.unsafeGetAny;
    var unsafeFreeze = Unsafe_Coerce.unsafeCoerce;
    var pokeMutMap = $foreign.unsafeSetAny;
    var newMutMap = Foreign_Object_ST["new"];
    exports["newMutMap"] = newMutMap;
    exports["pokeMutMap"] = pokeMutMap;
    exports["unsafeFreeze"] = unsafeFreeze;
    exports["unsafeLookup"] = unsafeLookup;
    exports["unsafeGetAny"] = $foreign.unsafeGetAny;
    exports["unsafeHasAny"] = $foreign.unsafeHasAny;
    exports["unsafeSetAny"] = $foreign.unsafeSetAny;
    exports["forE"] = $foreign.forE;
    exports["forEachE"] = $foreign.forEachE;
    exports["forInE"] = $foreign.forInE;
    exports["diffWithIxE"] = $foreign.diffWithIxE;
    exports["diffWithKeyAndIxE"] = $foreign.diffWithKeyAndIxE;
    exports["strMapWithIxE"] = $foreign.strMapWithIxE;
    exports["refEq"] = $foreign.refEq;
    exports["createTextNode"] = $foreign.createTextNode;
    exports["setTextContent"] = $foreign.setTextContent;
    exports["createElement"] = $foreign.createElement;
    exports["insertChildIx"] = $foreign.insertChildIx;
    exports["removeChild"] = $foreign.removeChild;
    exports["parentNode"] = $foreign.parentNode;
    exports["setAttribute"] = $foreign.setAttribute;
    exports["removeAttribute"] = $foreign.removeAttribute;
    exports["addEventListener"] = $foreign.addEventListener;
    exports["removeEventListener"] = $foreign.removeEventListener;
    exports["jsUndefined"] = $foreign.jsUndefined;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.eventListener = function (fn) {
      return function () {
        return function (event) {
          return fn(event)();
        };
      };
    };
  
    exports.addEventListener = function (type) {
      return function (listener) {
        return function (useCapture) {
          return function (target) {
            return function () {
              return target.addEventListener(type, listener, useCapture);
            };
          };
        };
      };
    };
  
    exports.removeEventListener = function (type) {
      return function (listener) {
        return function (useCapture) {
          return function (target) {
            return function () {
              return target.removeEventListener(type, listener, useCapture);
            };
          };
        };
      };
    };
  })(PS["Web.Event.EventTarget"] = PS["Web.Event.EventTarget"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.Event.EventTarget"] = $PS["Web.Event.EventTarget"] || {};
    var exports = $PS["Web.Event.EventTarget"];
    var $foreign = $PS["Web.Event.EventTarget"];
    exports["eventListener"] = $foreign.eventListener;
    exports["addEventListener"] = $foreign.addEventListener;
    exports["removeEventListener"] = $foreign.removeEventListener;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.DOM.Prop"] = $PS["Halogen.VDom.DOM.Prop"] || {};
    var exports = $PS["Halogen.VDom.DOM.Prop"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Nullable = $PS["Data.Nullable"];
    var Data_Tuple = $PS["Data.Tuple"];
    var Data_Unit = $PS["Data.Unit"];
    var Effect_Ref = $PS["Effect.Ref"];
    var Foreign = $PS["Foreign"];
    var Foreign_Object = $PS["Foreign.Object"];
    var Halogen_VDom_Machine = $PS["Halogen.VDom.Machine"];
    var Halogen_VDom_Util = $PS["Halogen.VDom.Util"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    var Web_Event_EventTarget = $PS["Web.Event.EventTarget"];                
    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 = Foreign.typeOf(Halogen_VDom_Util.unsafeGetAny(key, el));
        if (v === "string") {
            return Halogen_VDom_Util.unsafeSetAny(key, "", el);
        };
        if (key === "rowSpan") {
            return Halogen_VDom_Util.unsafeSetAny(key, 1, el);
        };
        if (key === "colSpan") {
            return Halogen_VDom_Util.unsafeSetAny(key, 1, 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 182, column 16 - line 187, column 16): " + [ v.constructor.name ]);
    };
    var propFromString = Unsafe_Coerce.unsafeCoerce;
    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 Data_Unit.unit;
                    };
                    throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop (line 169, column 5 - line 179, column 18): " + [ v1.constructor.name ]);
                };
            };
            var mbEmit = function (v) {
                if (v instanceof Data_Maybe.Just) {
                    return emit(v.value0)();
                };
                return Data_Unit.unit;
            };
            var haltProp = function (state) {
                var v = Foreign_Object.lookup("ref")(state.props);
                if (v instanceof Data_Maybe.Just && v.value0 instanceof Ref) {
                    return mbEmit(v.value0.value0(new Removed(el)));
                };
                return Data_Unit.unit;
            };
            var diffProp = function (prevEvents, events) {
                return function (v, v1, v11, v2) {
                    if (v11 instanceof Attribute && v2 instanceof Attribute) {
                        var $61 = v11.value2 === v2.value2;
                        if ($61) {
                            return v2;
                        };
                        Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el);
                        return v2;
                    };
                    if (v11 instanceof Property && v2 instanceof Property) {
                        var v4 = Halogen_VDom_Util.refEq(v11.value1, v2.value1);
                        if (v4) {
                            return v2;
                        };
                        if (v2.value0 === "value") {
                            var elVal = unsafeGetProperty("value", el);
                            var $70 = Halogen_VDom_Util.refEq(elVal, v2.value1);
                            if ($70) {
                                return v2;
                            };
                            setProperty(v2.value0, v2.value1, el);
                            return v2;
                        };
                        setProperty(v2.value0, v2.value1, el);
                        return v2;
                    };
                    if (v11 instanceof Handler && v2 instanceof Handler) {
                        var handler = Halogen_VDom_Util.unsafeLookup(v2.value0, prevEvents);
                        Effect_Ref.write(v2.value1)(Data_Tuple.snd(handler))();
                        Halogen_VDom_Util.pokeMutMap(v2.value0, handler, events);
                        return v2;
                    };
                    return v2;
                };
            };
            var applyProp = function (events) {
                return function (v, v1, v2) {
                    if (v2 instanceof Attribute) {
                        Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el);
                        return v2;
                    };
                    if (v2 instanceof Property) {
                        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)) {
                            Effect_Ref.write(v2.value1)(Data_Tuple.snd(v3))();
                            return v2;
                        };
                        var v4 = Effect_Ref["new"](v2.value1)();
                        var v5 = Web_Event_EventTarget.eventListener(function (ev) {
                            return function __do() {
                                var v5 = Effect_Ref.read(v4)();
                                return mbEmit(v5(ev));
                            };
                        })();
                        Halogen_VDom_Util.pokeMutMap(v2.value0, new Data_Tuple.Tuple(v5, v4), events);
                        Halogen_VDom_Util.addEventListener(v2.value0, v5, el);
                        return v2;
                    };
                    if (v2 instanceof Ref) {
                        mbEmit(v2.value0(new Created(el)));
                        return v2;
                    };
                    throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop (line 113, column 5 - line 135, column 15): " + [ v2.constructor.name ]);
                };
            };
            var patchProp = function (state, ps2) {
                var v = Halogen_VDom_Util.newMutMap();
                var onThis = removeProp(state.events);
                var onThese = diffProp(state.events, v);
                var onThat = applyProp(v);
                var v1 = Halogen_VDom_Util.diffWithKeyAndIxE(state.props, ps2, propToStrKey, onThese, onThis, onThat);
                var nextState = {
                    events: Halogen_VDom_Util.unsafeFreeze(v),
                    props: v1
                };
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Data_Unit.unit, nextState, patchProp, haltProp));
            };
            var renderProp = function (ps1) {
                var v = Halogen_VDom_Util.newMutMap();
                var v1 = Halogen_VDom_Util.strMapWithIxE(ps1, propToStrKey, applyProp(v));
                var state = {
                    events: Halogen_VDom_Util.unsafeFreeze(v),
                    props: v1
                };
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Data_Unit.unit, state, patchProp, haltProp));
            };
            return renderProp;
        };
    };
    exports["Property"] = Property;
    exports["propFromString"] = propFromString;
    exports["buildProp"] = buildProp;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Bifunctor"] = $PS["Data.Bifunctor"] || {};
    var exports = $PS["Data.Bifunctor"];
    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.identity(Control_Category.categoryFn));
    };
    exports["bimap"] = bimap;
    exports["Bifunctor"] = Bifunctor;
    exports["rmap"] = rmap;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.Types"] = $PS["Halogen.VDom.Types"] || {};
    var exports = $PS["Halogen.VDom.Types"];
    var Data_Bifunctor = $PS["Data.Bifunctor"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Tuple = $PS["Data.Tuple"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    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, value2, value3) {
            this.value0 = value0;
            this.value1 = value1;
            this.value2 = value2;
            this.value3 = value3;
        };
        Elem.create = function (value0) {
            return function (value1) {
                return function (value2) {
                    return function (value3) {
                        return new Elem(value0, value1, value2, value3);
                    };
                };
            };
        };
        return Elem;
    })();
    var Keyed = (function () {
        function Keyed(value0, value1, value2, value3) {
            this.value0 = value0;
            this.value1 = value1;
            this.value2 = value2;
            this.value3 = value3;
        };
        Keyed.create = function (value0) {
            return function (value1) {
                return function (value2) {
                    return function (value3) {
                        return new Keyed(value0, value1, value2, value3);
                    };
                };
            };
        };
        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 ($58) {
            return f($58);
        };
    };           
    var graft = Unsafe_Coerce.unsafeCoerce;
    var bifunctorGraft = new Data_Bifunctor.Bifunctor(function (f) {
        return function (g) {
            return unGraft(function (v) {
                return graft(new Graft(function ($60) {
                    return f(v.value0($60));
                }, function ($61) {
                    return g(v.value1($61));
                }, v.value2));
            });
        };
    });
    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(v2.value0, v2.value1, v.value0(v2.value2), Data_Functor.map(Data_Functor.functorArray)(go)(v2.value3));
            };
            if (v2 instanceof Keyed) {
                return new Keyed(v2.value0, v2.value1, v.value0(v2.value2), Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Data_Tuple.functorTuple)(go))(v2.value3));
            };
            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 86, column 7 - line 86, column 27): " + [ v2.constructor.name ]);
        };
        return go(v.value2);
    });
    exports["Text"] = Text;
    exports["Elem"] = Elem;
    exports["Keyed"] = Keyed;
    exports["Widget"] = Widget;
    exports["Grafted"] = Grafted;
    exports["runGraft"] = runGraft;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.HTML.Core"] = $PS["Halogen.HTML.Core"] || {};
    var exports = $PS["Halogen.HTML.Core"];
    var Data_Newtype = $PS["Data.Newtype"];
    var Halogen_VDom_DOM_Prop = $PS["Halogen.VDom.DOM.Prop"];
    var Halogen_VDom_Types = $PS["Halogen.VDom.Types"];
    var HTML = function (x) {
        return x;
    };
    var IsProp = function (toPropValue) {
        this.toPropValue = toPropValue;
    };
    var widget = function ($30) {
        return HTML(Halogen_VDom_Types.Widget.create($30));
    };
    var toPropValue = function (dict) {
        return dict.toPropValue;
    };
    var text = function ($31) {
        return HTML(Halogen_VDom_Types.Text.create($31));
    };
    var prop = function (dictIsProp) {
        return function (v) {
            var $33 = Halogen_VDom_DOM_Prop.Property.create(v);
            var $34 = toPropValue(dictIsProp);
            return function ($35) {
                return $33($34($35));
            };
        };
    };           
    var newtypeHTML = new Data_Newtype.Newtype(function (n) {
        return n;
    }, HTML);
    var isPropString = new IsProp(Halogen_VDom_DOM_Prop.propFromString);
    var element = function (ns) {
        return function (name) {
            return function (props) {
                return function (children) {
                    return new Halogen_VDom_Types.Elem(ns, name, props, children);
                };
            };
        };
    };
    exports["widget"] = widget;
    exports["text"] = text;
    exports["element"] = element;
    exports["prop"] = prop;
    exports["newtypeHTML"] = newtypeHTML;
    exports["isPropString"] = isPropString;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.HTML.Elements"] = $PS["Halogen.HTML.Elements"] || {};
    var exports = $PS["Halogen.HTML.Elements"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Halogen_HTML_Core = $PS["Halogen.HTML.Core"];
    var element = Halogen_HTML_Core.element(Data_Maybe.Nothing.value);
    var li = element("li");
    var li_ = li([  ]);
    var ul = element("ul");
    var ul_ = ul([  ]);
    var div = element("div");
    var div_ = div([  ]);  
    var a = element("a");
    exports["a"] = a;
    exports["div_"] = div_;
    exports["li_"] = li_;
    exports["ul_"] = ul_;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Children"] = $PS["Children"] || {};
    var exports = $PS["Children"];
    var Data_Function = $PS["Data.Function"];
    var Data_Unit = $PS["Data.Unit"];
    var Halogen_Component = $PS["Halogen.Component"];
    var Halogen_HTML_Core = $PS["Halogen.HTML.Core"];
    var Halogen_HTML_Elements = $PS["Halogen.HTML.Elements"];                
    var renderSalad = function (v) {
        return Halogen_HTML_Elements.ul_([ Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Athlete") ]), Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Pink Fir") ]) ]);
    };
    var salad = Halogen_Component.mkComponent({
        initialState: Data_Function["const"](Data_Unit.unit),
        render: renderSalad,
        "eval": Halogen_Component.mkEval(Halogen_Component.defaultEval)
    });
    var renderRoast = function (v) {
        return Halogen_HTML_Elements.ul_([ Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Adrianne") ]), Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Carolus") ]) ]);
    };
    var roast = Halogen_Component.mkComponent({
        initialState: Data_Function["const"](Data_Unit.unit),
        render: renderRoast,
        "eval": Halogen_Component.mkEval(Halogen_Component.defaultEval)
    });
    var renderChips = function (v) {
        return Halogen_HTML_Elements.ul_([ Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Maris Piper") ]), Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Spanish Agria") ]), Halogen_HTML_Elements.li_([ Halogen_HTML_Core.text("Cara") ]) ]);
    };
    var chips = Halogen_Component.mkComponent({
        initialState: Data_Function["const"](Data_Unit.unit),
        render: renderChips,
        "eval": Halogen_Component.mkEval(Halogen_Component.defaultEval)
    });
    exports["roast"] = roast;
    exports["chips"] = chips;
    exports["salad"] = salad;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Either"] = $PS["Data.Either"] || {};
    var exports = $PS["Data.Either"];
    var Control_Apply = $PS["Control.Apply"];
    var Data_Bifunctor = $PS["Data.Bifunctor"];
    var Data_Functor = $PS["Data.Functor"];          
    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 (f) {
        return function (m) {
            if (m instanceof Left) {
                return new Left(m.value0);
            };
            if (m instanceof Right) {
                return new Right(f(m.value0));
            };
            throw new Error("Failed pattern match at Data.Either (line 38, column 1 - line 38, column 52): " + [ m.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 238, column 1 - line 238, 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 46, column 1 - line 48, column 36): " + [ 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 82, column 1 - line 84, column 30): " + [ v.constructor.name, v1.constructor.name ]);
        };
    });
    exports["Left"] = Left;
    exports["Right"] = Right;
    exports["either"] = either;
    exports["functorEither"] = functorEither;
    exports["bifunctorEither"] = bifunctorEither;
    exports["applyEither"] = applyEither;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.NonEmpty"] = $PS["Data.NonEmpty"] || {};
    var exports = $PS["Data.NonEmpty"];
    var Control_Plus = $PS["Control.Plus"];                        
    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));
        };
    };
    exports["NonEmpty"] = NonEmpty;
    exports["singleton"] = singleton;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.List.NonEmpty"] = $PS["Data.List.NonEmpty"] || {};
    var exports = $PS["Data.List.NonEmpty"];
    var Data_List_Types = $PS["Data.List.Types"];
    var Data_NonEmpty = $PS["Data.NonEmpty"];
    var singleton = (function () {
        var $168 = Data_NonEmpty.singleton(Data_List_Types.plusList);
        return function ($169) {
            return Data_List_Types.NonEmptyList($168($169));
        };
    })();
    var cons = function (y) {
        return function (v) {
            return new Data_NonEmpty.NonEmpty(y, new Data_List_Types.Cons(v.value0, v.value1));
        };
    };
    exports["singleton"] = singleton;
    exports["cons"] = cons;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Applicative.Free"] = $PS["Control.Applicative.Free"] || {};
    var exports = $PS["Control.Applicative.Free"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    var Control_Category = $PS["Control.Category"];
    var Data_Either = $PS["Data.Either"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_List_NonEmpty = $PS["Data.List.NonEmpty"];
    var Data_List_Types = $PS["Data.List.Types"];
    var Data_NonEmpty = $PS["Data.NonEmpty"];
    var Data_Tuple = $PS["Data.Tuple"];                
    var Pure = (function () {
        function Pure(value0) {
            this.value0 = value0;
        };
        Pure.create = function (value0) {
            return new Pure(value0);
        };
        return Pure;
    })();
    var Lift = (function () {
        function Lift(value0) {
            this.value0 = value0;
        };
        Lift.create = function (value0) {
            return new Lift(value0);
        };
        return Lift;
    })();
    var Ap = (function () {
        function Ap(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        Ap.create = function (value0) {
            return function (value1) {
                return new Ap(value0, value1);
            };
        };
        return Ap;
    })();
    var mkAp = function (fba) {
        return function (fb) {
            return new Ap(fba, fb);
        };
    };
    var liftFreeAp = Lift.create;
    var goLeft = function ($copy_dictApplicative) {
        return function ($copy_fStack) {
            return function ($copy_valStack) {
                return function ($copy_nat) {
                    return function ($copy_func) {
                        return function ($copy_count) {
                            var $tco_var_dictApplicative = $copy_dictApplicative;
                            var $tco_var_fStack = $copy_fStack;
                            var $tco_var_valStack = $copy_valStack;
                            var $tco_var_nat = $copy_nat;
                            var $tco_var_func = $copy_func;
                            var $tco_done = false;
                            var $tco_result;
                            function $tco_loop(dictApplicative, fStack, valStack, nat, func, count) {
                                if (func instanceof Pure) {
                                    $tco_done = true;
                                    return new Data_Tuple.Tuple(new Data_List_Types.Cons({
                                        func: Control_Applicative.pure(dictApplicative)(func.value0),
                                        count: count
                                    }, fStack), valStack);
                                };
                                if (func instanceof Lift) {
                                    $tco_done = true;
                                    return new Data_Tuple.Tuple(new Data_List_Types.Cons({
                                        func: nat(func.value0),
                                        count: count
                                    }, fStack), valStack);
                                };
                                if (func instanceof Ap) {
                                    $tco_var_dictApplicative = dictApplicative;
                                    $tco_var_fStack = fStack;
                                    $tco_var_valStack = Data_List_NonEmpty.cons(func.value1)(valStack);
                                    $tco_var_nat = nat;
                                    $tco_var_func = func.value0;
                                    $copy_count = count + 1 | 0;
                                    return;
                                };
                                throw new Error("Failed pattern match at Control.Applicative.Free (line 102, column 41 - line 105, column 81): " + [ func.constructor.name ]);
                            };
                            while (!$tco_done) {
                                $tco_result = $tco_loop($tco_var_dictApplicative, $tco_var_fStack, $tco_var_valStack, $tco_var_nat, $tco_var_func, $copy_count);
                            };
                            return $tco_result;
                        };
                    };
                };
            };
        };
    };
    var goApply = function ($copy_dictApplicative) {
        return function ($copy_fStack) {
            return function ($copy_vals) {
                return function ($copy_gVal) {
                    var $tco_var_dictApplicative = $copy_dictApplicative;
                    var $tco_var_fStack = $copy_fStack;
                    var $tco_var_vals = $copy_vals;
                    var $tco_done = false;
                    var $tco_result;
                    function $tco_loop(dictApplicative, fStack, vals, gVal) {
                        if (fStack instanceof Data_List_Types.Nil) {
                            $tco_done = true;
                            return new Data_Either.Left(gVal);
                        };
                        if (fStack instanceof Data_List_Types.Cons) {
                            var gRes = Control_Apply.apply(dictApplicative.Apply0())(fStack.value0.func)(gVal);
                            var $14 = fStack.value0.count === 1;
                            if ($14) {
                                if (fStack.value1 instanceof Data_List_Types.Nil) {
                                    $tco_done = true;
                                    return new Data_Either.Left(gRes);
                                };
                                $tco_var_dictApplicative = dictApplicative;
                                $tco_var_fStack = fStack.value1;
                                $tco_var_vals = vals;
                                $copy_gVal = gRes;
                                return;
                            };
                            if (vals instanceof Data_List_Types.Nil) {
                                $tco_done = true;
                                return new Data_Either.Left(gRes);
                            };
                            if (vals instanceof Data_List_Types.Cons) {
                                $tco_done = true;
                                return Data_Either.Right.create(new Data_Tuple.Tuple(new Data_List_Types.Cons({
                                    func: gRes,
                                    count: fStack.value0.count - 1 | 0
                                }, fStack.value1), new Data_NonEmpty.NonEmpty(vals.value0, vals.value1)));
                            };
                            throw new Error("Failed pattern match at Control.Applicative.Free (line 83, column 11 - line 88, column 50): " + [ vals.constructor.name ]);
                        };
                        throw new Error("Failed pattern match at Control.Applicative.Free (line 72, column 3 - line 88, column 50): " + [ fStack.constructor.name ]);
                    };
                    while (!$tco_done) {
                        $tco_result = $tco_loop($tco_var_dictApplicative, $tco_var_fStack, $tco_var_vals, $copy_gVal);
                    };
                    return $tco_result;
                };
            };
        };
    };
    var functorFreeAp = new Data_Functor.Functor(function (f) {
        return function (x) {
            return mkAp(new Pure(f))(x);
        };
    });
    var foldFreeAp = function (dictApplicative) {
        return function (nat) {
            return function (z) {
                var go = function ($copy_v) {
                    var $tco_done = false;
                    var $tco_result;
                    function $tco_loop(v) {
                        if (v.value1.value0 instanceof Pure) {
                            var v1 = goApply(dictApplicative)(v.value0)(v.value1.value1)(Control_Applicative.pure(dictApplicative)(v.value1.value0.value0));
                            if (v1 instanceof Data_Either.Left) {
                                $tco_done = true;
                                return v1.value0;
                            };
                            if (v1 instanceof Data_Either.Right) {
                                $copy_v = v1.value0;
                                return;
                            };
                            throw new Error("Failed pattern match at Control.Applicative.Free (line 54, column 17 - line 56, column 24): " + [ v1.constructor.name ]);
                        };
                        if (v.value1.value0 instanceof Lift) {
                            var v1 = goApply(dictApplicative)(v.value0)(v.value1.value1)(nat(v.value1.value0.value0));
                            if (v1 instanceof Data_Either.Left) {
                                $tco_done = true;
                                return v1.value0;
                            };
                            if (v1 instanceof Data_Either.Right) {
                                $copy_v = v1.value0;
                                return;
                            };
                            throw new Error("Failed pattern match at Control.Applicative.Free (line 57, column 17 - line 59, column 24): " + [ v1.constructor.name ]);
                        };
                        if (v.value1.value0 instanceof Ap) {
                            var nextVals = new Data_NonEmpty.NonEmpty(v.value1.value0.value1, v.value1.value1);
                            $copy_v = goLeft(dictApplicative)(v.value0)(nextVals)(nat)(v.value1.value0.value0)(1);
                            return;
                        };
                        throw new Error("Failed pattern match at Control.Applicative.Free (line 53, column 5 - line 62, column 47): " + [ v.value1.value0.constructor.name ]);
                    };
                    while (!$tco_done) {
                        $tco_result = $tco_loop($copy_v);
                    };
                    return $tco_result;
                };
                return go(new Data_Tuple.Tuple(Data_List_Types.Nil.value, Data_List_NonEmpty.singleton(z)));
            };
        };
    };
    var retractFreeAp = function (dictApplicative) {
        return foldFreeAp(dictApplicative)(Control_Category.identity(Control_Category.categoryFn));
    };
    var applyFreeAp = new Control_Apply.Apply(function () {
        return functorFreeAp;
    }, function (fba) {
        return function (fb) {
            return mkAp(fba)(fb);
        };
    });
    var applicativeFreeAp = new Control_Applicative.Applicative(function () {
        return applyFreeAp;
    }, Pure.create);
    var hoistFreeAp = function (f) {
        return foldFreeAp(applicativeFreeAp)(function ($37) {
            return liftFreeAp(f($37));
        });
    };
    exports["retractFreeAp"] = retractFreeAp;
    exports["hoistFreeAp"] = hoistFreeAp;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Except.Trans"] = $PS["Control.Monad.Except.Trans"] || {};
    var exports = $PS["Control.Monad.Except.Trans"];
    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_Either = $PS["Data.Either"];
    var Data_Functor = $PS["Data.Functor"];                
    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 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 () {
                    var $98 = Control_Applicative.pure(dictMonad.Applicative0());
                    return function ($99) {
                        return $98(Data_Either.Left.create($99));
                    };
                })())(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 () {
            var $100 = Control_Applicative.pure(dictMonad.Applicative0());
            return function ($101) {
                return ExceptT($100(Data_Either.Right.create($101)));
            };
        })());
    };
    exports["ExceptT"] = ExceptT;
    exports["runExceptT"] = runExceptT;
    exports["applicativeExceptT"] = applicativeExceptT;
    exports["bindExceptT"] = bindExceptT;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Trans.Class"] = $PS["Control.Monad.Trans.Class"] || {};
    var exports = $PS["Control.Monad.Trans.Class"];
    var MonadTrans = function (lift) {
        this.lift = lift;
    };
    var lift = function (dict) {
        return dict.lift;
    };
    exports["lift"] = lift;
    exports["MonadTrans"] = MonadTrans;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Free.Trans"] = $PS["Control.Monad.Free.Trans"] || {};
    var exports = $PS["Control.Monad.Free.Trans"];
    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_Rec_Class = $PS["Control.Monad.Rec.Class"];
    var Control_Monad_Trans_Class = $PS["Control.Monad.Trans.Class"];
    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_Unit = $PS["Data.Unit"];                      
    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 () {
                                var $123 = Data_Functor.map(functorFreeT(dictFunctor)(dictFunctor1))(f);
                                return function ($124) {
                                    return $123(v1.value1($124));
                                };
                            })());
                        })(v.value0);
                    };
                    throw new Error("Failed pattern match at Control.Monad.Free.Trans (line 59, column 1 - line 61, 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 54, column 20 - line 56, 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 52, column 5 - line 57, column 98): " + [ v2.constructor.name ]);
                    })(v.value0);
                };
                throw new Error("Failed pattern match at Control.Monad.Free.Trans (line 49, column 3 - line 49, 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 141, column 3 - line 141, 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 82, column 15 - line 84, column 25): " + [ v.constructor.name ]);
                    });
                };
                return go;
            });
        };
    };
    exports["freeT"] = freeT;
    exports["liftFreeT"] = liftFreeT;
    exports["resume"] = resume;
    exports["runFreeT"] = runFreeT;
    exports["functorFreeT"] = functorFreeT;
    exports["applicativeFreeT"] = applicativeFreeT;
    exports["bindFreeT"] = bindFreeT;
    exports["monadTransFreeT"] = monadTransFreeT;
    exports["monadRecFreeT"] = monadRecFreeT;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Parallel.Class"] = $PS["Control.Parallel.Class"] || {};
    var exports = $PS["Control.Parallel.Class"];
    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["sequential"] = sequential;
    exports["Parallel"] = Parallel;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Identity"] = $PS["Data.Identity"] || {};
    var exports = $PS["Data.Identity"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Apply = $PS["Control.Apply"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Newtype = $PS["Data.Newtype"];          
    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 (m) {
            return f(m);
        };
    });
    var applyIdentity = new Control_Apply.Apply(function () {
        return functorIdentity;
    }, function (v) {
        return function (v1) {
            return v(v1);
        };
    });
    var applicativeIdentity = new Control_Applicative.Applicative(function () {
        return applyIdentity;
    }, Identity);
    exports["newtypeIdentity"] = newtypeIdentity;
    exports["functorIdentity"] = functorIdentity;
    exports["applicativeIdentity"] = applicativeIdentity;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Profunctor"] = $PS["Data.Profunctor"] || {};
    var exports = $PS["Data.Profunctor"];
    var Control_Category = $PS["Control.Category"];        
    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.identity(Control_Category.categoryFn))(b2c);
        };
    };
    exports["dimap"] = dimap;
    exports["Profunctor"] = Profunctor;
    exports["rmap"] = rmap;
    exports["profunctorFn"] = profunctorFn;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Coroutine"] = $PS["Control.Coroutine"] || {};
    var exports = $PS["Control.Coroutine"];
    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_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_Class = $PS["Control.Parallel.Class"];
    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_Newtype = $PS["Data.Newtype"];
    var Data_Profunctor = $PS["Data.Profunctor"];
    var Data_Tuple = $PS["Data.Tuple"];
    var Data_Unit = $PS["Data.Unit"];
    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 () {
            var $186 = Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0());
            var $187 = Data_Newtype.unwrap(Data_Identity.newtypeIdentity);
            return function ($188) {
                return $186($187($188));
            };
        })());
    };
    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 79, column 5 - line 81, 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 125, column 3 - line 127, 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.identity(Control_Category.categoryFn));
    };
    exports["runProcess"] = runProcess;
    exports["producer"] = producer;
    exports["await"] = $$await;
    exports["connect"] = connect;
    exports["pullFrom"] = pullFrom;
    exports["functorAwait"] = functorAwait;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Error.Class"] = $PS["Control.Monad.Error.Class"] || {};
    var exports = $PS["Control.Monad.Error.Class"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Data_Either = $PS["Data.Either"];
    var Data_Functor = $PS["Data.Functor"];                        
    var MonadThrow = function (Monad0, throwError) {
        this.Monad0 = Monad0;
        this.throwError = throwError;
    };
    var MonadError = function (MonadThrow0, catchError) {
        this.MonadThrow0 = MonadThrow0;
        this.catchError = catchError;
    };
    var throwError = function (dict) {
        return dict.throwError;
    };                                                      
    var catchError = function (dict) {
        return dict.catchError;
    };
    var $$try = function (dictMonadError) {
        return function (a) {
            return catchError(dictMonadError)(Data_Functor.map(((((dictMonadError.MonadThrow0()).Monad0()).Bind1()).Apply0()).Functor0())(Data_Either.Right.create)(a))((function () {
                var $21 = Control_Applicative.pure(((dictMonadError.MonadThrow0()).Monad0()).Applicative0());
                return function ($22) {
                    return $21(Data_Either.Left.create($22));
                };
            })());
        };
    };
    exports["throwError"] = throwError;
    exports["MonadThrow"] = MonadThrow;
    exports["MonadError"] = MonadError;
    exports["try"] = $$try;
  })(PS);
  (function(exports) {
    /* globals setImmediate, clearImmediate, setTimeout, clearTimeout */
    /* jshint -W083, -W098, -W003 */
    "use strict";
  
    var Aff = function () {
      // A unique value for empty.
      var EMPTY = {};
  
      /*
  
    An awkward approximation. We elide evidence we would otherwise need in PS for
    efficiency sake.
  
    data Aff eff a
      = Pure a
      | Throw Error
      | Catch (Aff eff a) (Error -> Aff eff a)
      | Sync (Eff eff a)
      | Async ((Either Error a -> Eff eff Unit) -> Eff eff (Canceler eff))
      | forall b. Bind (Aff eff b) (b -> Aff eff a)
      | forall b. Bracket (Aff eff b) (BracketConditions eff b) (b -> Aff eff a)
      | forall b. Fork Boolean (Aff eff b) ?(Fiber eff b -> a)
      | Sequential (ParAff aff a)
  
    */  
      var PURE    = "Pure";
      var THROW   = "Throw";
      var CATCH   = "Catch";
      var SYNC    = "Sync";
      var ASYNC   = "Async";
      var BIND    = "Bind";
      var BRACKET = "Bracket";
      var FORK    = "Fork";
      var SEQ     = "Sequential";
  
      /*
  
    data ParAff eff a
      = forall b. Map (b -> a) (ParAff eff b)
      | forall b. Apply (ParAff eff (b -> a)) (ParAff eff b)
      | Alt (ParAff eff a) (ParAff eff a)
      | ?Par (Aff eff a)
  
    */  
      var MAP   = "Map";
      var APPLY = "Apply";
      var ALT   = "Alt";
  
      // Various constructors used in interpretation
      var CONS      = "Cons";      // Cons-list, for stacks
      var RESUME    = "Resume";    // Continue indiscriminately
      var RELEASE   = "Release";   // Continue with bracket finalizers
      var FINALIZER = "Finalizer"; // A non-interruptible effect
      var FINALIZED = "Finalized"; // Marker for finalization
      var FORKED    = "Forked";    // Reference to a forked fiber, with resumption stack
      var FIBER     = "Fiber";     // Actual fiber reference
      var THUNK     = "Thunk";     // Primed effect, ready to invoke
  
      function Aff(tag, _1, _2, _3) {
        this.tag = tag;
        this._1  = _1;
        this._2  = _2;
        this._3  = _3;
      }
  
      function AffCtr(tag) {
        var fn = function (_1, _2, _3) {
          return new Aff(tag, _1, _2, _3);
        };
        fn.tag = tag;
        return fn;
      }
  
      function nonCanceler(error) {
        return new Aff(PURE, void 0);
      }
  
      function runEff(eff) {
        try {
          eff();
        } catch (error) {
          setTimeout(function () {
            throw error;
          }, 0);
        }
      }
  
      function runSync(left, right, eff) {
        try {
          return right(eff());
        } catch (error) {
          return left(error);
        }
      }
  
      function runAsync(left, eff, k) {
        try {
          return eff(k)();
        } catch (error) {
          k(left(error))();
          return nonCanceler;
        }
      }
  
      var Scheduler = function () {
        var limit    = 1024;
        var size     = 0;
        var ix       = 0;
        var queue    = new Array(limit);
        var draining = false;
  
        function drain() {
          var thunk;
          draining = true;
          while (size !== 0) {
            size--;
            thunk     = queue[ix];
            queue[ix] = void 0;
            ix        = (ix + 1) % limit;
            thunk();
          }
          draining = false;
        }
  
        return {
          isDraining: function () {
            return draining;
          },
          enqueue: function (cb) {
            var i, tmp;
            if (size === limit) {
              tmp = draining;
              drain();
              draining = tmp;
            }
  
            queue[(ix + size) % limit] = cb;
            size++;
  
            if (!draining) {
              drain();
            }
          }
        };
      }();
  
      function Supervisor(util) {
        var fibers  = {};
        var fiberId = 0;
        var count   = 0;
  
        return {
          register: function (fiber) {
            var fid = fiberId++;
            fiber.onComplete({
              rethrow: true,
              handler: function (result) {
                return function () {
                  count--;
                  delete fibers[fid];
                };
              }
            })();
            fibers[fid] = fiber;
            count++;
          },
          isEmpty: function () {
            return count === 0;
          },
          killAll: function (killError, cb) {
            return function () {
              if (count === 0) {
                return cb();
              }
  
              var killCount = 0;
              var kills     = {};
  
              function kill(fid) {
                kills[fid] = fibers[fid].kill(killError, function (result) {
                  return function () {
                    delete kills[fid];
                    killCount--;
                    if (util.isLeft(result) && util.fromLeft(result)) {
                      setTimeout(function () {
                        throw util.fromLeft(result);
                      }, 0);
                    }
                    if (killCount === 0) {
                      cb();
                    }
                  };
                })();
              }
  
              for (var k in fibers) {
                if (fibers.hasOwnProperty(k)) {
                  killCount++;
                  kill(k);
                }
              }
  
              fibers  = {};
              fiberId = 0;
              count   = 0;
  
              return function (error) {
                return new Aff(SYNC, function () {
                  for (var k in kills) {
                    if (kills.hasOwnProperty(k)) {
                      kills[k]();
                    }
                  }
                });
              };
            };
          }
        };
      }
  
      // Fiber state machine
      var SUSPENDED   = 0; // Suspended, pending a join.
      var CONTINUE    = 1; // Interpret the next instruction.
      var STEP_BIND   = 2; // Apply the next bind.
      var STEP_RESULT = 3; // Handle potential failure from a result.
      var PENDING     = 4; // An async effect is running.
      var RETURN      = 5; // The current stack has returned.
      var COMPLETED   = 6; // The entire fiber has completed.
  
      function Fiber(util, supervisor, aff) {
        // Monotonically increasing tick, increased on each asynchronous turn.
        var runTick = 0;
  
        // The current branch of the state machine.
        var status = SUSPENDED;
  
        // The current point of interest for the state machine branch.
        var step      = aff;  // Successful step
        var fail      = null; // Failure step
        var interrupt = null; // Asynchronous interrupt
  
        // Stack of continuations for the current fiber.
        var bhead = null;
        var btail = null;
  
        // Stack of attempts and finalizers for error recovery. Every `Cons` is also
        // tagged with current `interrupt` state. We use this to track which items
        // should be ignored or evaluated as a result of a kill.
        var attempts = null;
  
        // A special state is needed for Bracket, because it cannot be killed. When
        // we enter a bracket acquisition or finalizer, we increment the counter,
        // and then decrement once complete.
        var bracketCount = 0;
  
        // Each join gets a new id so they can be revoked.
        var joinId  = 0;
        var joins   = null;
        var rethrow = true;
  
        // Each invocation of `run` requires a tick. When an asynchronous effect is
        // resolved, we must check that the local tick coincides with the fiber
        // tick before resuming. This prevents multiple async continuations from
        // accidentally resuming the same fiber. A common example may be invoking
        // the provided callback in `makeAff` more than once, but it may also be an
        // async effect resuming after the fiber was already cancelled.
        function run(localRunTick) {
          var tmp, result, attempt;
          while (true) {
            tmp       = null;
            result    = null;
            attempt   = null;
  
            switch (status) {
            case STEP_BIND:
              status = CONTINUE;
              try {
                step   = bhead(step);
                if (btail === null) {
                  bhead = null;
                } else {
                  bhead = btail._1;
                  btail = btail._2;
                }
              } catch (e) {
                status = RETURN;
                fail   = util.left(e);
                step   = null;
              }
              break;
  
            case STEP_RESULT:
              if (util.isLeft(step)) {
                status = RETURN;
                fail   = step;
                step   = null;
              } else if (bhead === null) {
                status = RETURN;
              } else {
                status = STEP_BIND;
                step   = util.fromRight(step);
              }
              break;
  
            case CONTINUE:
              switch (step.tag) {
              case BIND:
                if (bhead) {
                  btail = new Aff(CONS, bhead, btail);
                }
                bhead  = step._2;
                status = CONTINUE;
                step   = step._1;
                break;
  
              case PURE:
                if (bhead === null) {
                  status = RETURN;
                  step   = util.right(step._1);
                } else {
                  status = STEP_BIND;
                  step   = step._1;
                }
                break;
  
              case SYNC:
                status = STEP_RESULT;
                step   = runSync(util.left, util.right, step._1);
                break;
  
              case ASYNC:
                status = PENDING;
                step   = runAsync(util.left, step._1, function (result) {
                  return function () {
                    if (runTick !== localRunTick) {
                      return;
                    }
                    runTick++;
                    Scheduler.enqueue(function () {
                      // It's possible to interrupt the fiber between enqueuing and
                      // resuming, so we need to check that the runTick is still
                      // valid.
                      if (runTick !== localRunTick + 1) {
                        return;
                      }
                      status = STEP_RESULT;
                      step   = result;
                      run(runTick);
                    });
                  };
                });
                return;
  
              case THROW:
                status = RETURN;
                fail   = util.left(step._1);
                step   = null;
                break;
  
              // Enqueue the Catch so that we can call the error handler later on
              // in case of an exception.
              case CATCH:
                if (bhead === null) {
                  attempts = new Aff(CONS, step, attempts, interrupt);
                } else {
                  attempts = new Aff(CONS, step, new Aff(CONS, new Aff(RESUME, bhead, btail), attempts, interrupt), interrupt);
                }
                bhead    = null;
                btail    = null;
                status   = CONTINUE;
                step     = step._1;
                break;
  
              // Enqueue the Bracket so that we can call the appropriate handlers
              // after resource acquisition.
              case BRACKET:
                bracketCount++;
                if (bhead === null) {
                  attempts = new Aff(CONS, step, attempts, interrupt);
                } else {
                  attempts = new Aff(CONS, step, new Aff(CONS, new Aff(RESUME, bhead, btail), attempts, interrupt), interrupt);
                }
                bhead  = null;
                btail  = null;
                status = CONTINUE;
                step   = step._1;
                break;
  
              case FORK:
                status = STEP_RESULT;
                tmp    = Fiber(util, supervisor, step._2);
                if (supervisor) {
                  supervisor.register(tmp);
                }
                if (step._1) {
                  tmp.run();
                }
                step = util.right(tmp);
                break;
  
              case SEQ:
                status = CONTINUE;
                step   = sequential(util, supervisor, step._1);
                break;
              }
              break;
  
            case RETURN:
              bhead = null;
              btail = null;
              // If the current stack has returned, and we have no other stacks to
              // resume or finalizers to run, the fiber has halted and we can
              // invoke all join callbacks. Otherwise we need to resume.
              if (attempts === null) {
                status = COMPLETED;
                step   = interrupt || fail || step;
              } else {
                // The interrupt status for the enqueued item.
                tmp      = attempts._3;
                attempt  = attempts._1;
                attempts = attempts._2;
  
                switch (attempt.tag) {
                // We cannot recover from an unmasked interrupt. Otherwise we should
                // continue stepping, or run the exception handler if an exception
                // was raised.
                case CATCH:
                  // We should compare the interrupt status as well because we
                  // only want it to apply if there has been an interrupt since
                  // enqueuing the catch.
                  if (interrupt && interrupt !== tmp && bracketCount === 0) {
                    status = RETURN;
                  } else if (fail) {
                    status = CONTINUE;
                    step   = attempt._2(util.fromLeft(fail));
                    fail   = null;
                  }
                  break;
  
                // We cannot resume from an unmasked interrupt or exception.
                case RESUME:
                  // As with Catch, we only want to ignore in the case of an
                  // interrupt since enqueing the item.
                  if (interrupt && interrupt !== tmp && bracketCount === 0 || fail) {
                    status = RETURN;
                  } else {
                    bhead  = attempt._1;
                    btail  = attempt._2;
                    status = STEP_BIND;
                    step   = util.fromRight(step);
                  }
                  break;
  
                // If we have a bracket, we should enqueue the handlers,
                // and continue with the success branch only if the fiber has
                // not been interrupted. If the bracket acquisition failed, we
                // should not run either.
                case BRACKET:
                  bracketCount--;
                  if (fail === null) {
                    result   = util.fromRight(step);
                    // We need to enqueue the Release with the same interrupt
                    // status as the Bracket that is initiating it.
                    attempts = new Aff(CONS, new Aff(RELEASE, attempt._2, result), attempts, tmp);
                    // We should only coninue as long as the interrupt status has not changed or
                    // we are currently within a non-interruptable finalizer.
                    if (interrupt === tmp || bracketCount > 0) {
                      status = CONTINUE;
                      step   = attempt._3(result);
                    }
                  }
                  break;
  
                // Enqueue the appropriate handler. We increase the bracket count
                // because it should not be cancelled.
                case RELEASE:
                  attempts = new Aff(CONS, new Aff(FINALIZED, step, fail), attempts, interrupt);
                  status   = CONTINUE;
                  // It has only been killed if the interrupt status has changed
                  // since we enqueued the item, and the bracket count is 0. If the
                  // bracket count is non-zero then we are in a masked state so it's
                  // impossible to be killed.
                  if (interrupt && interrupt !== tmp && bracketCount === 0) {
                    step = attempt._1.killed(util.fromLeft(interrupt))(attempt._2);
                  } else if (fail) {
                    step = attempt._1.failed(util.fromLeft(fail))(attempt._2);
                  } else {
                    step = attempt._1.completed(util.fromRight(step))(attempt._2);
                  }
                  fail = null;
                  bracketCount++;
                  break;
  
                case FINALIZER:
                  bracketCount++;
                  attempts = new Aff(CONS, new Aff(FINALIZED, step, fail), attempts, interrupt);
                  status   = CONTINUE;
                  step     = attempt._1;
                  break;
  
                case FINALIZED:
                  bracketCount--;
                  status = RETURN;
                  step   = attempt._1;
                  fail   = attempt._2;
                  break;
                }
              }
              break;
  
            case COMPLETED:
              for (var k in joins) {
                if (joins.hasOwnProperty(k)) {
                  rethrow = rethrow && joins[k].rethrow;
                  runEff(joins[k].handler(step));
                }
              }
              joins = null;
              // If we have an interrupt and a fail, then the thread threw while
              // running finalizers. This should always rethrow in a fresh stack.
              if (interrupt && fail) {
                setTimeout(function () {
                  throw util.fromLeft(fail);
                }, 0);
              // If we have an unhandled exception, and no other fiber has joined
              // then we need to throw the exception in a fresh stack.
              } else if (util.isLeft(step) && rethrow) {
                setTimeout(function () {
                  // Guard on reathrow because a completely synchronous fiber can
                  // still have an observer which was added after-the-fact.
                  if (rethrow) {
                    throw util.fromLeft(step);
                  }
                }, 0);
              }
              return;
            case SUSPENDED:
              status = CONTINUE;
              break;
            case PENDING: return;
            }
          }
        }
  
        function onComplete(join) {
          return function () {
            if (status === COMPLETED) {
              rethrow = rethrow && join.rethrow;
              join.handler(step)();
              return function () {};
            }
  
            var jid    = joinId++;
            joins      = joins || {};
            joins[jid] = join;
  
            return function() {
              if (joins !== null) {
                delete joins[jid];
              }
            };
          };
        }
  
        function kill(error, cb) {
          return function () {
            if (status === COMPLETED) {
              cb(util.right(void 0))();
              return function () {};
            }
  
            var canceler = onComplete({
              rethrow: false,
              handler: function (/* unused */) {
                return cb(util.right(void 0));
              }
            })();
  
            switch (status) {
            case SUSPENDED:
              interrupt = util.left(error);
              status    = COMPLETED;
              step      = interrupt;
              run(runTick);
              break;
            case PENDING:
              if (interrupt === null) {
                interrupt = util.left(error);
              }
              if (bracketCount === 0) {
                if (status === PENDING) {
                  attempts = new Aff(CONS, new Aff(FINALIZER, step(error)), attempts, interrupt);
                }
                status   = RETURN;
                step     = null;
                fail     = null;
                run(++runTick);
              }
              break;
            default:
              if (interrupt === null) {
                interrupt = util.left(error);
              }
              if (bracketCount === 0) {
                status = RETURN;
                step   = null;
                fail   = null;
              }
            }
  
            return canceler;
          };
        }
  
        function join(cb) {
          return function () {
            var canceler = onComplete({
              rethrow: false,
              handler: cb
            })();
            if (status === SUSPENDED) {
              run(runTick);
            }
            return canceler;
          };
        }
  
        return {
          kill: kill,
          join: join,
          onComplete: onComplete,
          isSuspended: function () {
            return status === SUSPENDED;
          },
          run: function () {
            if (status === SUSPENDED) {
              if (!Scheduler.isDraining()) {
                Scheduler.enqueue(function () {
                  run(runTick);
                });
              } else {
                run(runTick);
              }
            }
          }
        };
      }
  
      function runPar(util, supervisor, par, cb) {
        // Table of all forked fibers.
        var fiberId   = 0;
        var fibers    = {};
  
        // Table of currently running cancelers, as a product of `Alt` behavior.
        var killId    = 0;
        var kills     = {};
  
        // Error used for early cancelation on Alt branches.
        var early     = new Error("[ParAff] Early exit");
  
        // Error used to kill the entire tree.
        var interrupt = null;
  
        // The root pointer of the tree.
        var root      = EMPTY;
  
        // Walks a tree, invoking all the cancelers. Returns the table of pending
        // cancellation fibers.
        function kill(error, par, cb) {
          var step  = par;
          var head  = null;
          var tail  = null;
          var count = 0;
          var kills = {};
          var tmp, kid;
  
          loop: while (true) {
            tmp = null;
  
            switch (step.tag) {
            case FORKED:
              if (step._3 === EMPTY) {
                tmp = fibers[step._1];
                kills[count++] = tmp.kill(error, function (result) {
                  return function () {
                    count--;
                    if (count === 0) {
                      cb(result)();
                    }
                  };
                });
              }
              // Terminal case.
              if (head === null) {
                break loop;
              }
              // Go down the right side of the tree.
              step = head._2;
              if (tail === null) {
                head = null;
              } else {
                head = tail._1;
                tail = tail._2;
              }
              break;
            case MAP:
              step = step._2;
              break;
            case APPLY:
            case ALT:
              if (head) {
                tail = new Aff(CONS, head, tail);
              }
              head = step;
              step = step._1;
              break;
            }
          }
  
          if (count === 0) {
            cb(util.right(void 0))();
          } else {
            // Run the cancelation effects. We alias `count` because it's mutable.
            kid = 0;
            tmp = count;
            for (; kid < tmp; kid++) {
              kills[kid] = kills[kid]();
            }
          }
  
          return kills;
        }
  
        // When a fiber resolves, we need to bubble back up the tree with the
        // result, computing the applicative nodes.
        function join(result, head, tail) {
          var fail, step, lhs, rhs, tmp, kid;
  
          if (util.isLeft(result)) {
            fail = result;
            step = null;
          } else {
            step = result;
            fail = null;
          }
  
          loop: while (true) {
            lhs = null;
            rhs = null;
            tmp = null;
            kid = null;
  
            // We should never continue if the entire tree has been interrupted.
            if (interrupt !== null) {
              return;
            }
  
            // We've made it all the way to the root of the tree, which means
            // the tree has fully evaluated.
            if (head === null) {
              cb(fail || step)();
              return;
            }
  
            // The tree has already been computed, so we shouldn't try to do it
            // again. This should never happen.
            // TODO: Remove this?
            if (head._3 !== EMPTY) {
              return;
            }
  
            switch (head.tag) {
            case MAP:
              if (fail === null) {
                head._3 = util.right(head._1(util.fromRight(step)));
                step    = head._3;
              } else {
                head._3 = fail;
              }
              break;
            case APPLY:
              lhs = head._1._3;
              rhs = head._2._3;
              // If we have a failure we should kill the other side because we
              // can't possible yield a result anymore.
              if (fail) {
                head._3 = fail;
                tmp     = true;
                kid     = killId++;
  
                kills[kid] = kill(early, fail === lhs ? head._2 : head._1, function (/* unused */) {
                  return function () {
                    delete kills[kid];
                    if (tmp) {
                      tmp = false;
                    } else if (tail === null) {
                      join(fail, null, null);
                    } else {
                      join(fail, tail._1, tail._2);
                    }
                  };
                });
  
                if (tmp) {
                  tmp = false;
                  return;
                }
              } else if (lhs === EMPTY || rhs === EMPTY) {
                // We can only proceed if both sides have resolved.
                return;
              } else {
                step    = util.right(util.fromRight(lhs)(util.fromRight(rhs)));
                head._3 = step;
              }
              break;
            case ALT:
              lhs = head._1._3;
              rhs = head._2._3;
              // We can only proceed if both have resolved or we have a success
              if (lhs === EMPTY && util.isLeft(rhs) || rhs === EMPTY && util.isLeft(lhs)) {
                return;
              }
              // If both sides resolve with an error, we should continue with the
              // first error
              if (lhs !== EMPTY && util.isLeft(lhs) && rhs !== EMPTY && util.isLeft(rhs)) {
                fail    = step === lhs ? rhs : lhs;
                step    = null;
                head._3 = fail;
              } else {
                head._3 = step;
                tmp     = true;
                kid     = killId++;
                // Once a side has resolved, we need to cancel the side that is still
                // pending before we can continue.
                kills[kid] = kill(early, step === lhs ? head._2 : head._1, function (/* unused */) {
                  return function () {
                    delete kills[kid];
                    if (tmp) {
                      tmp = false;
                    } else if (tail === null) {
                      join(step, null, null);
                    } else {
                      join(step, tail._1, tail._2);
                    }
                  };
                });
  
                if (tmp) {
                  tmp = false;
                  return;
                }
              }
              break;
            }
  
            if (tail === null) {
              head = null;
            } else {
              head = tail._1;
              tail = tail._2;
            }
          }
        }
  
        function resolve(fiber) {
          return function (result) {
            return function () {
              delete fibers[fiber._1];
              fiber._3 = result;
              join(result, fiber._2._1, fiber._2._2);
            };
          };
        }
  
        // Walks the applicative tree, substituting non-applicative nodes with
        // `FORKED` nodes. In this tree, all applicative nodes use the `_3` slot
        // as a mutable slot for memoization. In an unresolved state, the `_3`
        // slot is `EMPTY`. In the cases of `ALT` and `APPLY`, we always walk
        // the left side first, because both operations are left-associative. As
        // we `RETURN` from those branches, we then walk the right side.
        function run() {
          var status = CONTINUE;
          var step   = par;
          var head   = null;
          var tail   = null;
          var tmp, fid;
  
          loop: while (true) {
            tmp = null;
            fid = null;
  
            switch (status) {
            case CONTINUE:
              switch (step.tag) {
              case MAP:
                if (head) {
                  tail = new Aff(CONS, head, tail);
                }
                head = new Aff(MAP, step._1, EMPTY, EMPTY);
                step = step._2;
                break;
              case APPLY:
                if (head) {
                  tail = new Aff(CONS, head, tail);
                }
                head = new Aff(APPLY, EMPTY, step._2, EMPTY);
                step = step._1;
                break;
              case ALT:
                if (head) {
                  tail = new Aff(CONS, head, tail);
                }
                head = new Aff(ALT, EMPTY, step._2, EMPTY);
                step = step._1;
                break;
              default:
                // When we hit a leaf value, we suspend the stack in the `FORKED`.
                // When the fiber resolves, it can bubble back up the tree.
                fid    = fiberId++;
                status = RETURN;
                tmp    = step;
                step   = new Aff(FORKED, fid, new Aff(CONS, head, tail), EMPTY);
                tmp    = Fiber(util, supervisor, tmp);
                tmp.onComplete({
                  rethrow: false,
                  handler: resolve(step)
                })();
                fibers[fid] = tmp;
                if (supervisor) {
                  supervisor.register(tmp);
                }
              }
              break;
            case RETURN:
              // Terminal case, we are back at the root.
              if (head === null) {
                break loop;
              }
              // If we are done with the right side, we need to continue down the
              // left. Otherwise we should continue up the stack.
              if (head._1 === EMPTY) {
                head._1 = step;
                status  = CONTINUE;
                step    = head._2;
                head._2 = EMPTY;
              } else {
                head._2 = step;
                step    = head;
                if (tail === null) {
                  head  = null;
                } else {
                  head  = tail._1;
                  tail  = tail._2;
                }
              }
            }
          }
  
          // Keep a reference to the tree root so it can be cancelled.
          root = step;
  
          for (fid = 0; fid < fiberId; fid++) {
            fibers[fid].run();
          }
        }
  
        // Cancels the entire tree. If there are already subtrees being canceled,
        // we need to first cancel those joins. We will then add fresh joins for
        // all pending branches including those that were in the process of being
        // canceled.
        function cancel(error, cb) {
          interrupt = util.left(error);
          var innerKills;
          for (var kid in kills) {
            if (kills.hasOwnProperty(kid)) {
              innerKills = kills[kid];
              for (kid in innerKills) {
                if (innerKills.hasOwnProperty(kid)) {
                  innerKills[kid]();
                }
              }
            }
          }
  
          kills = null;
          var newKills = kill(error, root, cb);
  
          return function (killError) {
            return new Aff(ASYNC, function (killCb) {
              return function () {
                for (var kid in newKills) {
                  if (newKills.hasOwnProperty(kid)) {
                    newKills[kid]();
                  }
                }
                return nonCanceler;
              };
            });
          };
        }
  
        run();
  
        return function (killError) {
          return new Aff(ASYNC, function (killCb) {
            return function () {
              return cancel(killError, killCb);
            };
          });
        };
      }
  
      function sequential(util, supervisor, par) {
        return new Aff(ASYNC, function (cb) {
          return function () {
            return runPar(util, supervisor, par, cb);
          };
        });
      }
  
      Aff.EMPTY       = EMPTY;
      Aff.Pure        = AffCtr(PURE);
      Aff.Throw       = AffCtr(THROW);
      Aff.Catch       = AffCtr(CATCH);
      Aff.Sync        = AffCtr(SYNC);
      Aff.Async       = AffCtr(ASYNC);
      Aff.Bind        = AffCtr(BIND);
      Aff.Bracket     = AffCtr(BRACKET);
      Aff.Fork        = AffCtr(FORK);
      Aff.Seq         = AffCtr(SEQ);
      Aff.ParMap      = AffCtr(MAP);
      Aff.ParApply    = AffCtr(APPLY);
      Aff.ParAlt      = AffCtr(ALT);
      Aff.Fiber       = Fiber;
      Aff.Supervisor  = Supervisor;
      Aff.Scheduler   = Scheduler;
      Aff.nonCanceler = nonCanceler;
  
      return Aff;
    }();
  
    exports._pure = Aff.Pure;
  
    exports._throwError = Aff.Throw;
  
    exports._catchError = function (aff) {
      return function (k) {
        return Aff.Catch(aff, k);
      };
    };
  
    exports._map = function (f) {
      return function (aff) {
        if (aff.tag === Aff.Pure.tag) {
          return Aff.Pure(f(aff._1));
        } else {
          return Aff.Bind(aff, function (value) {
            return Aff.Pure(f(value));
          });
        }
      };
    };
  
    exports._bind = function (aff) {
      return function (k) {
        return Aff.Bind(aff, k);
      };
    };
  
    exports._fork = function (immediate) {
      return function (aff) {
        return Aff.Fork(immediate, aff);
      };
    };
  
    exports._liftEffect = Aff.Sync;
  
    exports._parAffMap = function (f) {
      return function (aff) {
        return Aff.ParMap(f, aff);
      };
    };
  
    exports._parAffApply = function (aff1) {
      return function (aff2) {
        return Aff.ParApply(aff1, aff2);
      };
    };
  
    exports.makeAff = Aff.Async;
  
    exports.generalBracket = function (acquire) {
      return function (options) {
        return function (k) {
          return Aff.Bracket(acquire, options, k);
        };
      };
    };
  
    exports._makeFiber = function (util, aff) {
      return function () {
        return Aff.Fiber(util, null, aff);
      };
    };  
  
    exports._sequential = Aff.Seq;
  })(PS["Effect.Aff"] = PS["Effect.Aff"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Class"] = $PS["Effect.Class"] || {};
    var exports = $PS["Effect.Class"];         
    var MonadEffect = function (Monad0, liftEffect) {
        this.Monad0 = Monad0;
        this.liftEffect = liftEffect;
    };                                                         
    var liftEffect = function (dict) {
        return dict.liftEffect;
    };
    exports["liftEffect"] = liftEffect;
    exports["MonadEffect"] = MonadEffect;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.unsafePerformEffect = function (f) {
      return f();
    };
  })(PS["Effect.Unsafe"] = PS["Effect.Unsafe"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Unsafe"] = $PS["Effect.Unsafe"] || {};
    var exports = $PS["Effect.Unsafe"];
    var $foreign = $PS["Effect.Unsafe"];
    exports["unsafePerformEffect"] = $foreign.unsafePerformEffect;
  })(PS);
  (function(exports) {
    "use strict";
  
    // module Partial.Unsafe
  
    exports.unsafePartial = function (f) {
      return f();
    };
  })(PS["Partial.Unsafe"] = PS["Partial.Unsafe"] || {});
  (function(exports) {
    "use strict";
  
    // module Partial
  
    exports.crashWith = function () {
      return function (msg) {
        throw new Error(msg);
      };
    };
  })(PS["Partial"] = PS["Partial"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Partial"] = $PS["Partial"] || {};
    var exports = $PS["Partial"];
    var $foreign = $PS["Partial"];
    exports["crashWith"] = $foreign.crashWith;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Partial.Unsafe"] = $PS["Partial.Unsafe"] || {};
    var exports = $PS["Partial.Unsafe"];
    var $foreign = $PS["Partial.Unsafe"];
    var Partial = $PS["Partial"];
    var unsafeCrashWith = function (msg) {
        return $foreign.unsafePartial(function (dictPartial) {
            return Partial.crashWith()(msg);
        });
    };
    exports["unsafeCrashWith"] = unsafeCrashWith;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Aff"] = $PS["Effect.Aff"] || {};
    var exports = $PS["Effect.Aff"];
    var $foreign = $PS["Effect.Aff"];
    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_Error_Class = $PS["Control.Monad.Error.Class"];
    var Control_Monad_Rec_Class = $PS["Control.Monad.Rec.Class"];
    var Control_Parallel_Class = $PS["Control.Parallel.Class"];
    var Data_Either = $PS["Data.Either"];
    var Data_Function = $PS["Data.Function"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Unit = $PS["Data.Unit"];
    var Effect = $PS["Effect"];
    var Effect_Class = $PS["Effect.Class"];
    var Effect_Unsafe = $PS["Effect.Unsafe"];
    var Partial_Unsafe = $PS["Partial.Unsafe"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    var Canceler = function (x) {
        return x;
    };
    var suspendAff = $foreign["_fork"](false);
    var functorParAff = new Data_Functor.Functor($foreign["_parAffMap"]);
    var functorAff = new Data_Functor.Functor($foreign["_map"]);
    var forkAff = $foreign["_fork"](true);
    var ffiUtil = (function () {
        var unsafeFromRight = function (v) {
            if (v instanceof Data_Either.Right) {
                return v.value0;
            };
            if (v instanceof Data_Either.Left) {
                return Partial_Unsafe.unsafeCrashWith("unsafeFromRight: Left");
            };
            throw new Error("Failed pattern match at Effect.Aff (line 400, column 21 - line 402, column 54): " + [ v.constructor.name ]);
        };
        var unsafeFromLeft = function (v) {
            if (v instanceof Data_Either.Left) {
                return v.value0;
            };
            if (v instanceof Data_Either.Right) {
                return Partial_Unsafe.unsafeCrashWith("unsafeFromLeft: Right");
            };
            throw new Error("Failed pattern match at Effect.Aff (line 395, column 20 - line 397, column 54): " + [ v.constructor.name ]);
        };
        var isLeft = function (v) {
            if (v instanceof Data_Either.Left) {
                return true;
            };
            if (v instanceof Data_Either.Right) {
                return false;
            };
            throw new Error("Failed pattern match at Effect.Aff (line 390, column 12 - line 392, column 20): " + [ v.constructor.name ]);
        };
        return {
            isLeft: isLeft,
            fromLeft: unsafeFromLeft,
            fromRight: unsafeFromRight,
            left: Data_Either.Left.create,
            right: Data_Either.Right.create
        };
    })();
    var makeFiber = function (aff) {
        return $foreign["_makeFiber"](ffiUtil, aff);
    };
    var launchAff = function (aff) {
        return function __do() {
            var v = makeFiber(aff)();
            v.run();
            return v;
        };
    };
    var launchAff_ = (function () {
        var $49 = Data_Functor["void"](Effect.functorEffect);
        return function ($50) {
            return $49(launchAff($50));
        };
    })();
    var bracket = function (acquire) {
        return function (completed) {
            return $foreign.generalBracket(acquire)({
                killed: Data_Function["const"](completed),
                failed: Data_Function["const"](completed),
                completed: Data_Function["const"](completed)
            });
        };
    };
    var applyParAff = new Control_Apply.Apply(function () {
        return functorParAff;
    }, $foreign["_parAffApply"]);
    var monadAff = new Control_Monad.Monad(function () {
        return applicativeAff;
    }, function () {
        return bindAff;
    });
    var bindAff = new Control_Bind.Bind(function () {
        return applyAff;
    }, $foreign["_bind"]);
    var applyAff = new Control_Apply.Apply(function () {
        return functorAff;
    }, Control_Monad.ap(monadAff));
    var applicativeAff = new Control_Applicative.Applicative(function () {
        return applyAff;
    }, $foreign["_pure"]);
    var $$finally = function (fin) {
        return function (a) {
            return bracket(Control_Applicative.pure(applicativeAff)(Data_Unit.unit))(Data_Function["const"](fin))(Data_Function["const"](a));
        };
    };
    var monadEffectAff = new Effect_Class.MonadEffect(function () {
        return monadAff;
    }, $foreign["_liftEffect"]);
    var effectCanceler = (function () {
        var $51 = Effect_Class.liftEffect(monadEffectAff);
        return function ($52) {
            return Canceler(Data_Function["const"]($51($52)));
        };
    })();
    var joinFiber = function (v) {
        return $foreign.makeAff(function (k) {
            return Data_Functor.map(Effect.functorEffect)(effectCanceler)(v.join(k));
        });
    };
    var functorFiber = new Data_Functor.Functor(function (f) {
        return function (t) {
            return Effect_Unsafe.unsafePerformEffect(makeFiber(Data_Functor.map(functorAff)(f)(joinFiber(t))));
        };
    });
    var killFiber = function (e) {
        return function (v) {
            return Control_Bind.bind(bindAff)(Effect_Class.liftEffect(monadEffectAff)(v.isSuspended))(function (v1) {
                if (v1) {
                    return Effect_Class.liftEffect(monadEffectAff)(Data_Functor["void"](Effect.functorEffect)(v.kill(e, Data_Function["const"](Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit)))));
                };
                return $foreign.makeAff(function (k) {
                    return Data_Functor.map(Effect.functorEffect)(effectCanceler)(v.kill(e, k));
                });
            });
        };
    };   
    var monadThrowAff = new Control_Monad_Error_Class.MonadThrow(function () {
        return monadAff;
    }, $foreign["_throwError"]);
    var monadErrorAff = new Control_Monad_Error_Class.MonadError(function () {
        return monadThrowAff;
    }, $foreign["_catchError"]);                                  
    var runAff = function (k) {
        return function (aff) {
            return launchAff(Control_Bind.bindFlipped(bindAff)((function () {
                var $55 = Effect_Class.liftEffect(monadEffectAff);
                return function ($56) {
                    return $55(k($56));
                };
            })())(Control_Monad_Error_Class["try"](monadErrorAff)(aff)));
        };
    };
    var runAff_ = function (k) {
        return function (aff) {
            return Data_Functor["void"](Effect.functorEffect)(runAff(k)(aff));
        };
    };
    var parallelAff = new Control_Parallel_Class.Parallel(function () {
        return applicativeParAff;
    }, function () {
        return monadAff;
    }, Unsafe_Coerce.unsafeCoerce, $foreign["_sequential"]);
    var applicativeParAff = new Control_Applicative.Applicative(function () {
        return applyParAff;
    }, (function () {
        var $59 = Control_Parallel_Class.parallel(parallelAff);
        var $60 = Control_Applicative.pure(applicativeAff);
        return function ($61) {
            return $59($60($61));
        };
    })());
    var monadRecAff = new Control_Monad_Rec_Class.MonadRec(function () {
        return monadAff;
    }, function (k) {
        var go = function (a) {
            return Control_Bind.bind(bindAff)(k(a))(function (v) {
                if (v instanceof Control_Monad_Rec_Class.Done) {
                    return Control_Applicative.pure(applicativeAff)(v.value0);
                };
                if (v instanceof Control_Monad_Rec_Class.Loop) {
                    return go(v.value0);
                };
                throw new Error("Failed pattern match at Effect.Aff (line 100, column 7 - line 102, column 22): " + [ v.constructor.name ]);
            });
        };
        return go;
    });
    var nonCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(Data_Unit.unit));
    exports["launchAff_"] = launchAff_;
    exports["runAff_"] = runAff_;
    exports["forkAff"] = forkAff;
    exports["suspendAff"] = suspendAff;
    exports["finally"] = $$finally;
    exports["killFiber"] = killFiber;
    exports["joinFiber"] = joinFiber;
    exports["nonCanceler"] = nonCanceler;
    exports["effectCanceler"] = effectCanceler;
    exports["functorAff"] = functorAff;
    exports["applicativeAff"] = applicativeAff;
    exports["bindAff"] = bindAff;
    exports["monadAff"] = monadAff;
    exports["monadRecAff"] = monadRecAff;
    exports["monadThrowAff"] = monadThrowAff;
    exports["monadErrorAff"] = monadErrorAff;
    exports["monadEffectAff"] = monadEffectAff;
    exports["applicativeParAff"] = applicativeParAff;
    exports["parallelAff"] = parallelAff;
    exports["functorFiber"] = functorFiber;
    exports["makeAff"] = $foreign.makeAff;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Monad.Fork.Class"] = $PS["Control.Monad.Fork.Class"] || {};
    var exports = $PS["Control.Monad.Fork.Class"];
    var Effect_Aff = $PS["Effect.Aff"];
    var MonadFork = function (Functor1, Monad0, fork, join, suspend) {
        this.Functor1 = Functor1;
        this.Monad0 = Monad0;
        this.fork = fork;
        this.join = join;
        this.suspend = suspend;
    };
    var monadForkAff = new MonadFork(function () {
        return Effect_Aff.functorFiber;
    }, function () {
        return Effect_Aff.monadAff;
    }, Effect_Aff.forkAff, Effect_Aff.joinFiber, Effect_Aff.suspendAff);
    var fork = function (dict) {
        return dict.fork;
    };
    exports["fork"] = fork;
    exports["monadForkAff"] = monadForkAff;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Control.Parallel"] = $PS["Control.Parallel"] || {};
    var exports = $PS["Control.Parallel"];
    var Control_Category = $PS["Control.Category"];
    var Control_Parallel_Class = $PS["Control.Parallel.Class"];
    var Data_Foldable = $PS["Data.Foldable"];                      
    var parTraverse_ = function (dictParallel) {
        return function (dictFoldable) {
            return function (f) {
                var $17 = Control_Parallel_Class.sequential(dictParallel);
                var $18 = Data_Foldable.traverse_(dictParallel.Applicative1())(dictFoldable)((function () {
                    var $20 = Control_Parallel_Class.parallel(dictParallel);
                    return function ($21) {
                        return $20(f($21));
                    };
                })());
                return function ($19) {
                    return $17($18($19));
                };
            };
        };
    };
    var parSequence_ = function (dictParallel) {
        return function (dictFoldable) {
            return parTraverse_(dictParallel)(dictFoldable)(Control_Category.identity(Control_Category.categoryFn));
        };
    };
    exports["parSequence_"] = parSequence_;
  })(PS);
  (function(exports) {
    "use strict";
  
    //------------------------------------------------------------------------------
    // Array size ------------------------------------------------------------------
    //------------------------------------------------------------------------------
  
    exports.length = function (xs) {
      return xs.length;
    };
  })(PS["Data.Array"] = PS["Data.Array"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Array"] = $PS["Data.Array"] || {};
    var exports = $PS["Data.Array"];
    var $foreign = $PS["Data.Array"];
    exports["length"] = $foreign.length;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Boolean"] = $PS["Data.Boolean"] || {};
    var exports = $PS["Data.Boolean"];
    var otherwise = true;
    exports["otherwise"] = otherwise;
  })(PS);
  (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($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.HeytingAlgebra"] = $PS["Data.HeytingAlgebra"] || {};
    var exports = $PS["Data.HeytingAlgebra"];
    var $foreign = $PS["Data.HeytingAlgebra"];
    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["not"] = not;
    exports["heytingAlgebraBoolean"] = heytingAlgebraBoolean;
    exports["heytingAlgebraFunction"] = heytingAlgebraFunction;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Data.Void"] = $PS["Data.Void"] || {};
    var exports = $PS["Data.Void"];
    var absurd = function (a) {
        var spin = function ($copy_v) {
            var $tco_result;
            function $tco_loop(v) {
                $copy_v = v;
                return;
            };
            while (!false) {
                $tco_result = $tco_loop($copy_v);
            };
            return $tco_result;
        };
        return spin(a);
    };
    exports["absurd"] = absurd;
  })(PS);
  (function(exports) {
    /* globals exports, setTimeout */
    "use strict";
  
    var AVar = function () {
  
      function MutableQueue () {
        this.head = null;
        this.last = null;
        this.size = 0;
      }
  
      function MutableCell (queue, value) {
        this.queue = queue;
        this.value = value;
        this.next  = null;
        this.prev  = null;
      }
  
      function AVar (value) {
        this.draining = false;
        this.error    = null;
        this.value    = value;
        this.takes    = new MutableQueue();
        this.reads    = new MutableQueue();
        this.puts     = new MutableQueue();
      }
  
      var EMPTY = {};
  
      function runEff(eff) {
        try {
          eff();
        } catch (error) {
          setTimeout(function () {
            throw error;
          }, 0);
        }
      }
  
      function putLast (queue, value) {
        var cell = new MutableCell(queue, value);
        switch (queue.size) {
        case 0:
          queue.head = cell;
          break;
        case 1:
          cell.prev = queue.head;
          queue.head.next = cell;
          queue.last = cell;
          break;
        default:
          cell.prev = queue.last;
          queue.last.next = cell;
          queue.last = cell;
        }
        queue.size++;
        return cell;
      }
  
      function takeLast (queue) {
        var cell;
        switch (queue.size) {
        case 0:
          return null;
        case 1:
          cell = queue.head;
          queue.head = null;
          break;
        case 2:
          cell = queue.last;
          queue.head.next = null;
          queue.last = null;
          break;
        default:
          cell = queue.last;
          queue.last = cell.prev;
          queue.last.next = null;
        }
        cell.prev = null;
        cell.queue = null;
        queue.size--;
        return cell.value;
      }
  
      function takeHead (queue) {
        var cell;
        switch (queue.size) {
        case 0:
          return null;
        case 1:
          cell = queue.head;
          queue.head = null;
          break;
        case 2:
          cell = queue.head;
          queue.last.prev = null;
          queue.head = queue.last;
          queue.last = null;
          break;
        default:
          cell = queue.head;
          queue.head = cell.next;
          queue.head.prev = null;
        }
        cell.next = null;
        cell.queue = null;
        queue.size--;
        return cell.value;
      }
  
      function deleteCell (cell) {
        if (cell.queue === null) {
          return;
        }
        if (cell.queue.last === cell) {
          takeLast(cell.queue);
          return;
        }
        if (cell.queue.head === cell) {
          takeHead(cell.queue);
          return;
        }
        if (cell.prev) {
          cell.prev.next = cell.next;
        }
        if (cell.next) {
          cell.next.prev = cell.prev;
        }
        cell.queue.size--;
        cell.queue = null;
        cell.value = null;
        cell.next  = null;
        cell.prev  = null;
      }
  
      function drainVar (util, avar) {
        if (avar.draining) {
          return;
        }
  
        var ps = avar.puts;
        var ts = avar.takes;
        var rs = avar.reads;
        var p, r, t, value, rsize;
  
        avar.draining = true;
  
        while (1) { // eslint-disable-line no-constant-condition
          p = null;
          r = null;
          t = null;
          value = avar.value;
          rsize = rs.size;
  
          if (avar.error !== null) {
            value = util.left(avar.error);
            while (p = takeHead(ps)) { // eslint-disable-line no-cond-assign
              runEff(p.cb(value));
            }
            while (r = takeHead(rs)) { // eslint-disable-line no-cond-assign
              runEff(r(value));
            }
            while (t = takeHead(ts)) { // eslint-disable-line no-cond-assign
              runEff(t(value));
            }
            break;
          }
  
          // Process the next put. We do not immediately invoke the callback
          // because we want to preserve ordering. If there are takes/reads
          // we want to run those first.
          if (value === EMPTY && (p = takeHead(ps))) {
            avar.value = value = p.value;
          }
  
          if (value !== EMPTY) {
            // We go ahead and queue up the next take for the same reasons as
            // above. Invoking the read callbacks can affect the mutable queue.
            t = takeHead(ts);
            // We only want to process the reads queued up before running these
            // callbacks so we guard on rsize.
            while (rsize-- && (r = takeHead(rs))) {
              runEff(r(util.right(value)));
            }
            if (t !== null) {
              avar.value = EMPTY;
              runEff(t(util.right(value)));
            }
          }
  
          if (p !== null) {
            runEff(p.cb(util.right(void 0)));
          }
  
          // Callbacks could have queued up more items so we need to guard on the
          // actual mutable properties.
          if (avar.value === EMPTY && ps.size === 0 || avar.value !== EMPTY && ts.size === 0) {
            break;
          }
        }
        avar.draining = false;
      }
  
      AVar.EMPTY      = EMPTY;
      AVar.putLast    = putLast;
      AVar.takeLast   = takeLast;
      AVar.takeHead   = takeHead;
      AVar.deleteCell = deleteCell;
      AVar.drainVar   = drainVar;
  
      return AVar;
    }();
  
    exports.empty = function () {
      return new AVar(AVar.EMPTY);
    };
  
    exports._killVar = function (util, error, avar) {
      return function () {
        if (avar.error === null) {
          avar.error = error;
          avar.value = AVar.EMPTY;
          AVar.drainVar(util, avar);
        }
      };
    };
  
    exports._putVar = function (util, value, avar, cb) {
      return function () {
        var cell = AVar.putLast(avar.puts, { cb: cb, value: value });
        AVar.drainVar(util, avar);
        return function () {
          AVar.deleteCell(cell);
        };
      };
    };
  
    exports._takeVar = function (util, avar, cb) {
      return function () {
        var cell = AVar.putLast(avar.takes, cb);
        AVar.drainVar(util, avar);
        return function () {
          AVar.deleteCell(cell);
        };
      };
    };
  })(PS["Effect.AVar"] = PS["Effect.AVar"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.AVar"] = $PS["Effect.AVar"] || {};
    var exports = $PS["Effect.AVar"];
    var $foreign = $PS["Effect.AVar"];
    var Data_Either = $PS["Data.Either"];
    var Data_Maybe = $PS["Data.Maybe"];                
    var Killed = (function () {
        function Killed(value0) {
            this.value0 = value0;
        };
        Killed.create = function (value0) {
            return new Killed(value0);
        };
        return Killed;
    })();
    var Filled = (function () {
        function Filled(value0) {
            this.value0 = value0;
        };
        Filled.create = function (value0) {
            return new Filled(value0);
        };
        return Filled;
    })();
    var Empty = (function () {
        function Empty() {
  
        };
        Empty.value = new Empty();
        return Empty;
    })();
    var ffiUtil = {
        left: Data_Either.Left.create,
        right: Data_Either.Right.create,
        nothing: Data_Maybe.Nothing.value,
        just: Data_Maybe.Just.create,
        killed: Killed.create,
        filled: Filled.create,
        empty: Empty.value
    };
    var kill = function (err) {
        return function (avar) {
            return $foreign["_killVar"](ffiUtil, err, avar);
        };
    };
    var put = function (value) {
        return function (avar) {
            return function (cb) {
                return $foreign["_putVar"](ffiUtil, value, avar, cb);
            };
        };
    };
    var take = function (avar) {
        return function (cb) {
            return $foreign["_takeVar"](ffiUtil, avar, cb);
        };
    };
    exports["take"] = take;
    exports["put"] = put;
    exports["kill"] = kill;
    exports["empty"] = $foreign.empty;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Aff.AVar"] = $PS["Effect.Aff.AVar"] || {};
    var exports = $PS["Effect.Aff.AVar"];
    var Effect_AVar = $PS["Effect.AVar"];
    var Effect_Aff = $PS["Effect.Aff"];
    var Effect_Class = $PS["Effect.Class"];
    var take = function (avar) {
        return Effect_Aff.makeAff(function (k) {
            return function __do() {
                var v = Effect_AVar.take(avar)(k)();
                return Effect_Aff.effectCanceler(v);
            };
        });
    };
    var put = function (value) {
        return function (avar) {
            return Effect_Aff.makeAff(function (k) {
                return function __do() {
                    var v = Effect_AVar.put(value)(avar)(k)();
                    return Effect_Aff.effectCanceler(v);
                };
            });
        };
    };   
    var kill = function (error) {
        var $17 = Effect_Class.liftEffect(Effect_Aff.monadEffectAff);
        var $18 = Effect_AVar.kill(error);
        return function ($19) {
            return $17($18($19));
        };
    };
    var empty = Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_AVar.empty);
    exports["empty"] = empty;
    exports["take"] = take;
    exports["put"] = put;
    exports["kill"] = kill;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.warn = function (s) {
      return function () {
        console.warn(s);
        return {};
      };
    };
  })(PS["Effect.Console"] = PS["Effect.Console"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Console"] = $PS["Effect.Console"] || {};
    var exports = $PS["Effect.Console"];
    var $foreign = $PS["Effect.Console"];
    exports["warn"] = $foreign.warn;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.error = function (msg) {
      return new Error(msg);
    };
  
    exports.throwException = function (e) {
      return function () {
        throw e;
      };
    };
  })(PS["Effect.Exception"] = PS["Effect.Exception"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Effect.Exception"] = $PS["Effect.Exception"] || {};
    var exports = $PS["Effect.Exception"];
    var $foreign = $PS["Effect.Exception"];
    var $$throw = function ($2) {
        return $foreign.throwException($foreign.error($2));
    };
    exports["throw"] = $$throw;
    exports["error"] = $foreign.error;
    exports["throwException"] = $foreign.throwException;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Aff.Driver.State"] = $PS["Halogen.Aff.Driver.State"] || {};
    var exports = $PS["Halogen.Aff.Driver.State"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_List_Types = $PS["Data.List.Types"];
    var Data_Map_Internal = $PS["Data.Map.Internal"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Effect_Ref = $PS["Effect.Ref"];
    var Halogen_Data_Slot = $PS["Halogen.Data.Slot"];
    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 = Unsafe_Coerce.unsafeCoerce;
    var renderStateX = function (dictFunctor) {
        return function (f) {
            return unDriverStateX(function (st) {
                return mkRenderStateX(f(st.rendering));
            });
        };
    };
    var mkDriverStateXRef = Unsafe_Coerce.unsafeCoerce;
    var mapDriverState = function (f) {
        return function (v) {
            return f(v);
        };
    };
    var initDriverState = function (component) {
        return function (input) {
            return function (handler) {
                return function (lchs) {
                    return function __do() {
                        var v = Effect_Ref["new"]({})();
                        var v1 = Effect_Ref["new"](Halogen_Data_Slot.empty)();
                        var v2 = Effect_Ref["new"](Halogen_Data_Slot.empty)();
                        var v3 = Effect_Ref["new"](handler)();
                        var v4 = Effect_Ref["new"](new Data_Maybe.Just(Data_List_Types.Nil.value))();
                        var v5 = Effect_Ref["new"](new Data_Maybe.Just(Data_List_Types.Nil.value))();
                        var v6 = Effect_Ref["new"](Data_Maybe.Nothing.value)();
                        var v7 = Effect_Ref["new"](1)();
                        var v8 = Effect_Ref["new"](new Data_Maybe.Just(Data_Map_Internal.empty))();
                        var v9 = Effect_Ref["new"](Data_Map_Internal.empty)();
                        var ds = {
                            component: component,
                            state: component.initialState(input),
                            refs: Data_Map_Internal.empty,
                            children: Halogen_Data_Slot.empty,
                            childrenIn: v1,
                            childrenOut: v2,
                            selfRef: v,
                            handlerRef: v3,
                            pendingQueries: v4,
                            pendingOuts: v5,
                            pendingHandlers: v6,
                            rendering: Data_Maybe.Nothing.value,
                            fresh: v7,
                            subscriptions: v8,
                            forks: v9,
                            lifecycleHandlers: lchs
                        };
                        Effect_Ref.write(ds)(v)();
                        return mkDriverStateXRef(v);
                    };
                };
            };
        };
    };
    exports["mapDriverState"] = mapDriverState;
    exports["unDriverStateX"] = unDriverStateX;
    exports["renderStateX"] = renderStateX;
    exports["renderStateX_"] = renderStateX_;
    exports["unRenderStateX"] = unRenderStateX;
    exports["initDriverState"] = initDriverState;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Query.ChildQuery"] = $PS["Halogen.Query.ChildQuery"] || {};
    var exports = $PS["Halogen.Query.ChildQuery"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    var unChildQueryBox = Unsafe_Coerce.unsafeCoerce;
    exports["unChildQueryBox"] = unChildQueryBox;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Query.EventSource"] = $PS["Halogen.Query.EventSource"] || {};
    var exports = $PS["Halogen.Query.EventSource"];
    var finalize = function (v) {
        return v;
    };
    exports["finalize"] = finalize;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Query.Input"] = $PS["Halogen.Query.Input"] || {};
    var exports = $PS["Halogen.Query.Input"];
    var RefUpdate = (function () {
        function RefUpdate(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        RefUpdate.create = function (value0) {
            return function (value1) {
                return new RefUpdate(value0, value1);
            };
        };
        return RefUpdate;
    })();
    var Action = (function () {
        function Action(value0) {
            this.value0 = value0;
        };
        Action.create = function (value0) {
            return new Action(value0);
        };
        return Action;
    })();
    exports["RefUpdate"] = RefUpdate;
    exports["Action"] = Action;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.reallyUnsafeRefEq = function (a) {
      return function (b) {
        return a === b;
      };
    };
  })(PS["Unsafe.Reference"] = PS["Unsafe.Reference"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Unsafe.Reference"] = $PS["Unsafe.Reference"] || {};
    var exports = $PS["Unsafe.Reference"];
    var $foreign = $PS["Unsafe.Reference"];
    var unsafeRefEq = $foreign.reallyUnsafeRefEq;
    exports["unsafeRefEq"] = unsafeRefEq;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Aff.Driver.Eval"] = $PS["Halogen.Aff.Driver.Eval"] || {};
    var exports = $PS["Halogen.Aff.Driver.Eval"];
    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 = $PS["Control.Monad"];
    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 Data_Boolean = $PS["Data.Boolean"];
    var Data_Coyoneda = $PS["Data.Coyoneda"];
    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_Types = $PS["Data.List.Types"];
    var Data_Map_Internal = $PS["Data.Map.Internal"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Ord = $PS["Data.Ord"];
    var Data_Unit = $PS["Data.Unit"];
    var Effect = $PS["Effect"];
    var Effect_Aff = $PS["Effect.Aff"];
    var Effect_Class = $PS["Effect.Class"];
    var Effect_Exception = $PS["Effect.Exception"];
    var Effect_Ref = $PS["Effect.Ref"];
    var Halogen_Aff_Driver_State = $PS["Halogen.Aff.Driver.State"];
    var Halogen_Query_ChildQuery = $PS["Halogen.Query.ChildQuery"];
    var Halogen_Query_EventSource = $PS["Halogen.Query.EventSource"];
    var Halogen_Query_HalogenM = $PS["Halogen.Query.HalogenM"];
    var Halogen_Query_HalogenQ = $PS["Halogen.Query.HalogenQ"];
    var Halogen_Query_Input = $PS["Halogen.Query.Input"];
    var Unsafe_Reference = $PS["Unsafe.Reference"];                
    var unsubscribe = function (sid) {
        return function (ref) {
            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v) {
                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(v.subscriptions)))(function (v1) {
                    return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(Halogen_Query_EventSource.finalize)(Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(Data_Map_Internal.lookup(Halogen_Query_HalogenM.ordSubscriptionId)(sid))(v1));
                });
            });
        };
    };
    var queueOrRun = function (ref) {
        return function (au) {
            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v) {
                if (v instanceof Data_Maybe.Nothing) {
                    return au;
                };
                if (v instanceof Data_Maybe.Just) {
                    return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.write(new Data_Maybe.Just(new Data_List_Types.Cons(au, v.value0)))(ref));
                };
                throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval (line 195, column 33 - line 197, column 57): " + [ v.constructor.name ]);
            });
        };
    };
    var handleLifecycle = function (lchs) {
        return function (f) {
            return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.write({
                initializers: Data_List_Types.Nil.value,
                finalizers: Data_List_Types.Nil.value
            })(lchs)))(function () {
                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(f))(function (v) {
                    return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(lchs)))(function (v1) {
                        return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_List_Types.foldableList)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff))(v1.finalizers))(function () {
                            return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Parallel.parSequence_(Effect_Aff.parallelAff)(Data_List_Types.foldableList)(v1.initializers))(function () {
                                return Control_Applicative.pure(Effect_Aff.applicativeAff)(v);
                            });
                        });
                    });
                });
            });
        };
    };
    var fresh = function (f) {
        return function (ref) {
            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v) {
                return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref["modify'"](function (i) {
                    return {
                        state: i + 1 | 0,
                        value: f(i)
                    };
                })(v.fresh));
            });
        };
    };
    var evalQ = function (render) {
        return function (ref) {
            return function (q) {
                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v) {
                    return evalM(render)(ref)(v["component"]["eval"](new Halogen_Query_HalogenQ.Query(Data_Functor.map(Data_Coyoneda.functorCoyoneda)(Data_Maybe.Just.create)(Data_Coyoneda.liftCoyoneda(q)), Data_Function["const"](Data_Maybe.Nothing.value))));
                });
            };
        };
    };
    var evalM = function (render) {
        return function (initRef) {
            return function (v) {
                var evalChildQuery = function (ref) {
                    return function (cqb) {
                        return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v1) {
                            return Halogen_Query_ChildQuery.unChildQueryBox(function (v2) {
                                var evalChild = function (v3) {
                                    return Control_Parallel_Class.parallel(Effect_Aff.parallelAff)(Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(v3)))(function (v4) {
                                        return Halogen_Aff_Driver_State.unDriverStateX(function (ds) {
                                            return evalQ(render)(ds.selfRef)(v2.value1);
                                        })(v4);
                                    }));
                                };
                                return Data_Functor.map(Effect_Aff.functorAff)(v2.value2)(Control_Parallel_Class.sequential(Effect_Aff.parallelAff)(v2.value0(Effect_Aff.applicativeParAff)(evalChild)(v1.children)));
                            })(cqb);
                        });
                    };
                };
                var go = function (ref) {
                    return function (v1) {
                        if (v1 instanceof Halogen_Query_HalogenM.State) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v2) {
                                var v3 = v1.value0(v2.state);
                                if (Unsafe_Reference.unsafeRefEq(v2.state)(v3.value1)) {
                                    return Control_Applicative.pure(Effect_Aff.applicativeAff)(v3.value0);
                                };
                                if (Data_Boolean.otherwise) {
                                    return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.write({
                                        component: v2.component,
                                        state: v3.value1,
                                        refs: v2.refs,
                                        children: v2.children,
                                        childrenIn: v2.childrenIn,
                                        childrenOut: v2.childrenOut,
                                        selfRef: v2.selfRef,
                                        handlerRef: v2.handlerRef,
                                        pendingQueries: v2.pendingQueries,
                                        pendingOuts: v2.pendingOuts,
                                        pendingHandlers: v2.pendingHandlers,
                                        rendering: v2.rendering,
                                        fresh: v2.fresh,
                                        subscriptions: v2.subscriptions,
                                        forks: v2.forks,
                                        lifecycleHandlers: v2.lifecycleHandlers
                                    })(ref)))(function () {
                                        return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(handleLifecycle(v2.lifecycleHandlers)(render(v2.lifecycleHandlers)(ref)))(function () {
                                            return Control_Applicative.pure(Effect_Aff.applicativeAff)(v3.value0);
                                        });
                                    });
                                };
                                throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval (line 85, column 7 - line 91, column 21): " + [ v3.constructor.name ]);
                            });
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Subscribe) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(fresh(Halogen_Query_HalogenM.SubscriptionId)(ref))(function (v2) {
                                var v3 = v1.value0(v2);
                                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v4) {
                                    return Control_Bind.bind(Effect_Aff.bindAff)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff)(Control_Bind.bind(Effect_Aff.bindAff)(v3)(function (v5) {
                                        var done = Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(v4.subscriptions)))(function (v6) {
                                            return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.modify_(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map_Internal["delete"](Halogen_Query_HalogenM.ordSubscriptionId)(v2)))(v4.subscriptions)))(function () {
                                                return Control_Applicative.when(Effect_Aff.applicativeAff)(Data_Maybe.maybe(false)(Data_Map_Internal.member(Halogen_Query_HalogenM.ordSubscriptionId)(v2))(v6))(Halogen_Query_EventSource.finalize(v5.finalizer));
                                            });
                                        });
                                        var consumer = Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Effect_Aff.monadAff))(Control_Coroutine["await"](Effect_Aff.monadAff))(function (v6) {
                                            return Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Effect_Aff.monadAff))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(Control_Coroutine.functorAwait))(Effect_Aff.monadAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(v4.subscriptions))))(function (v7) {
                                                return Control_Applicative.when(Control_Monad_Free_Trans.applicativeFreeT(Control_Coroutine.functorAwait)(Effect_Aff.monadAff))(Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqBoolean))(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map_Internal.member(Halogen_Query_HalogenM.ordSubscriptionId)(v2))(v7))(new Data_Maybe.Just(true)))(Control_Bind.bind(Control_Monad_Free_Trans.bindFreeT(Control_Coroutine.functorAwait)(Effect_Aff.monadAff))(Control_Monad_Trans_Class.lift(Control_Monad_Free_Trans.monadTransFreeT(Control_Coroutine.functorAwait))(Effect_Aff.monadAff)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff)(evalF(render)(ref)(new Halogen_Query_Input.Action(v6)))))(function (v8) {
                                                    return consumer;
                                                }));
                                            });
                                        });
                                        return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.modify_(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map_Internal.insert(Halogen_Query_HalogenM.ordSubscriptionId)(v2)(done)))(v4.subscriptions)))(function () {
                                            return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Coroutine.runProcess(Effect_Aff.monadRecAff)(Control_Coroutine.pullFrom(Effect_Aff.monadRecAff)(consumer)(v5.producer)))(function () {
                                                return Halogen_Query_EventSource.finalize(done);
                                            });
                                        });
                                    })))(function (v5) {
                                        return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1.value1(v2));
                                    });
                                });
                            });
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Unsubscribe) {
                            return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(unsubscribe(v1.value0)(ref))(function () {
                                return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1.value1);
                            });
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Lift) {
                            return v1.value0;
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.ChildQuery) {
                            return evalChildQuery(ref)(v1.value0);
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Raise) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v2) {
                                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(v2.handlerRef)))(function (v3) {
                                    return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(queueOrRun(v2.pendingOuts)(v3(v1.value0)))(function () {
                                        return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1.value1);
                                    });
                                });
                            });
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Par) {
                            return Control_Parallel_Class.sequential(Effect_Aff.parallelAff)(Control_Applicative_Free.retractFreeAp(Effect_Aff.applicativeParAff)(Control_Applicative_Free.hoistFreeAp((function () {
                                var $111 = Control_Parallel_Class.parallel(Effect_Aff.parallelAff);
                                var $112 = evalM(render)(ref);
                                return function ($113) {
                                    return $111($112($113));
                                };
                            })())(v1.value0)));
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Fork) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(fresh(Halogen_Query_HalogenM.ForkId)(ref))(function (v2) {
                                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v3) {
                                    return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref["new"](false)))(function (v4) {
                                        return Control_Bind.bind(Effect_Aff.bindAff)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff)(Effect_Aff["finally"](Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                            Effect_Ref.modify_(Data_Map_Internal["delete"](Halogen_Query_HalogenM.ordForkId)(v2))(v3.forks)();
                                            return Effect_Ref.write(true)(v4)();
                                        }))(evalM(render)(ref)(v1.value0))))(function (v5) {
                                            return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Control_Monad.unlessM(Effect.monadEffect)(Effect_Ref.read(v4))(Effect_Ref.modify_(Data_Map_Internal.insert(Halogen_Query_HalogenM.ordForkId)(v2)(v5))(v3.forks))))(function () {
                                                return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1.value1(v2));
                                            });
                                        });
                                    });
                                });
                            });
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.Kill) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v2) {
                                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(v2.forks)))(function (v3) {
                                    return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(Effect_Aff.killFiber(Effect_Exception.error("Cancelled")))(Data_Map_Internal.lookup(Halogen_Query_HalogenM.ordForkId)(v1.value0)(v3)))(function () {
                                        return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1.value1);
                                    });
                                });
                            });
                        };
                        if (v1 instanceof Halogen_Query_HalogenM.GetRef) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v2) {
                                return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1.value1(Data_Map_Internal.lookup(Data_Ord.ordString)(v1.value0)(v2.refs)));
                            });
                        };
                        throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval (line 82, column 12 - line 146, column 33): " + [ v1.constructor.name ]);
                    };
                };
                return Control_Monad_Free.foldFree(Effect_Aff.monadRecAff)(go(initRef))(v);
            };
        };
    };
    var evalF = function (render) {
        return function (ref) {
            return function (v) {
                if (v instanceof Halogen_Query_Input.RefUpdate) {
                    return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Data_Function.flip(Effect_Ref.modify_)(ref)(Halogen_Aff_Driver_State.mapDriverState(function (st) {
                        return {
                            component: st.component,
                            state: st.state,
                            refs: Data_Map_Internal.alter(Data_Ord.ordString)(Data_Function["const"](v.value1))(v.value0)(st.refs),
                            children: st.children,
                            childrenIn: st.childrenIn,
                            childrenOut: st.childrenOut,
                            selfRef: st.selfRef,
                            handlerRef: st.handlerRef,
                            pendingQueries: st.pendingQueries,
                            pendingOuts: st.pendingOuts,
                            pendingHandlers: st.pendingHandlers,
                            rendering: st.rendering,
                            fresh: st.fresh,
                            subscriptions: st.subscriptions,
                            forks: st.forks,
                            lifecycleHandlers: st.lifecycleHandlers
                        };
                    })));
                };
                if (v instanceof Halogen_Query_Input.Action) {
                    return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v1) {
                        return evalM(render)(ref)(v1["component"]["eval"](new Halogen_Query_HalogenQ.Action(v.value0, Data_Unit.unit)));
                    });
                };
                throw new Error("Failed pattern match at Halogen.Aff.Driver.Eval (line 51, column 20 - line 57, column 62): " + [ v.constructor.name ]);
            };
        };
    };
    exports["evalF"] = evalF;
    exports["evalQ"] = evalQ;
    exports["evalM"] = evalM;
    exports["handleLifecycle"] = handleLifecycle;
    exports["queueOrRun"] = queueOrRun;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Aff.Driver"] = $PS["Halogen.Aff.Driver"] || {};
    var exports = $PS["Halogen.Aff.Driver"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Bind = $PS["Control.Bind"];
    var Control_Category = $PS["Control.Category"];
    var Control_Coroutine = $PS["Control.Coroutine"];
    var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
    var Control_Monad_Fork_Class = $PS["Control.Monad.Fork.Class"];
    var Control_Monad_Rec_Class = $PS["Control.Monad.Rec.Class"];
    var Control_Parallel = $PS["Control.Parallel"];
    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_Internal = $PS["Data.Map.Internal"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Ord = $PS["Data.Ord"];
    var Data_Unit = $PS["Data.Unit"];
    var Effect = $PS["Effect"];
    var Effect_Aff = $PS["Effect.Aff"];
    var Effect_Aff_AVar = $PS["Effect.Aff.AVar"];
    var Effect_Class = $PS["Effect.Class"];
    var Effect_Console = $PS["Effect.Console"];
    var Effect_Exception = $PS["Effect.Exception"];
    var Effect_Ref = $PS["Effect.Ref"];
    var Halogen_Aff_Driver_Eval = $PS["Halogen.Aff.Driver.Eval"];
    var Halogen_Aff_Driver_State = $PS["Halogen.Aff.Driver.State"];
    var Halogen_Component = $PS["Halogen.Component"];
    var Halogen_Data_Slot = $PS["Halogen.Data.Slot"];
    var Halogen_Query_EventSource = $PS["Halogen.Query.EventSource"];
    var Halogen_Query_HalogenQ = $PS["Halogen.Query.HalogenQ"];
    var Halogen_Query_Input = $PS["Halogen.Query.Input"];                
    var newLifecycleHandlers = Effect_Ref["new"]({
        initializers: Data_List_Types.Nil.value,
        finalizers: Data_List_Types.Nil.value
    });
    var handleAff = Effect_Aff.runAff_(Data_Either.either(Effect_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit))));
    var handlePending = function (ref) {
        return function __do() {
            var v = Effect_Ref.read(ref)();
            Effect_Ref.write(Data_Maybe.Nothing.value)(ref)();
            return Data_Foldable.for_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(v)((function () {
                var $78 = Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_List_Types.foldableList)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff));
                return function ($79) {
                    return handleAff($78(Data_List.reverse($79)));
                };
            })())();
        };
    };
    var cleanupSubscriptionsAndForks = function (v) {
        return function __do() {
            Control_Bind.bindFlipped(Effect.bindEffect)(Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)((function () {
                var $80 = Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Map_Internal.foldableMap)((function () {
                    var $82 = Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff);
                    return function ($83) {
                        return $82(Halogen_Query_EventSource.finalize($83));
                    };
                })());
                return function ($81) {
                    return handleAff($80($81));
                };
            })()))(Effect_Ref.read(v.subscriptions))();
            Effect_Ref.write(Data_Maybe.Nothing.value)(v.subscriptions)();
            Control_Bind.bindFlipped(Effect.bindEffect)(Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Map_Internal.foldableMap)((function () {
                var $84 = Effect_Aff.killFiber(Effect_Exception.error("finalized"));
                return function ($85) {
                    return handleAff($84($85));
                };
            })()))(Effect_Ref.read(v.forks))();
            return Effect_Ref.write(Data_Map_Internal.empty)(v.forks)();
        };
    };
    var runUI = function (renderSpec) {
        return function (component) {
            return function (i) {
                var subscribe = function (fresh) {
                    return function (ref) {
                        return function (consumer) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Aff_AVar.empty)(function (v) {
                                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                    var v1 = Effect_Ref.read(fresh)();
                                    Effect_Ref.modify_(function (v2) {
                                        return v2 + 1 | 0;
                                    })(fresh)();
                                    Effect_Ref.modify_(Data_Map_Internal.insert(Data_Ord.ordInt)(v1)(v))(ref)();
                                    return v1;
                                }))(function (v1) {
                                    var producer = Control_Coroutine.producer(Effect_Aff.monadAff)(Data_Functor.map(Effect_Aff.functorAff)(Data_Either.either(Data_Function["const"](new Data_Either.Right(Data_Unit.unit)))(Data_Either.Left.create))(Control_Monad_Error_Class["try"](Effect_Aff.monadErrorAff)(Effect_Aff_AVar.take(v))));
                                    return Data_Functor["void"](Effect_Aff.functorAff)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff)(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Coroutine.runProcess(Effect_Aff.monadRecAff)(Control_Coroutine.connect(Effect_Aff.monadRecAff)(Effect_Aff.parallelAff)(producer)(consumer)))(function () {
                                        return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.modify_(Data_Map_Internal["delete"](Data_Ord.ordInt)(v1))(ref)))(function () {
                                            return Effect_Aff_AVar.kill(Effect_Exception.error("ended"))(v);
                                        });
                                    })));
                                });
                            });
                        };
                    };
                };
                var rootHandler = function (ref) {
                    return function (message) {
                        return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(ref)))(function (v) {
                            return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Map_Internal.foldableMap)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff))(Data_Functor.map(Data_Map_Internal.functorMap)(Effect_Aff_AVar.put(message))(v));
                        });
                    };
                };
                var squashChildInitializers = function (lchs) {
                    return function (preInits) {
                        return Halogen_Aff_Driver_State.unDriverStateX(function (st) {
                            var parentInitializer = Halogen_Aff_Driver_Eval.evalM(render)(st.selfRef)(st["component"]["eval"](new Halogen_Query_HalogenQ.Initialize(Data_Unit.unit)));
                            return Effect_Ref.modify_(function (handlers) {
                                return {
                                    initializers: new Data_List_Types.Cons(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Parallel.parSequence_(Effect_Aff.parallelAff)(Data_List_Types.foldableList)(Data_List.reverse(handlers.initializers)))(function () {
                                        return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(parentInitializer)(function () {
                                            return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                                handlePending(st.pendingQueries)();
                                                return handlePending(st.pendingOuts)();
                                            });
                                        });
                                    }), preInits),
                                    finalizers: handlers.finalizers
                                };
                            })(lchs);
                        });
                    };
                };
                var runComponent = function (lchs) {
                    return function (handler) {
                        return function (j) {
                            return Halogen_Component.unComponent(function (c) {
                                return function __do() {
                                    var v = newLifecycleHandlers();
                                    var v1 = Halogen_Aff_Driver_State.initDriverState(c)(j)(handler)(v)();
                                    var v2 = Effect_Ref.read(lchs)();
                                    Effect_Ref.write({
                                        initializers: Data_List_Types.Nil.value,
                                        finalizers: v2.finalizers
                                    })(lchs)();
                                    Control_Bind.bindFlipped(Effect.bindEffect)(Halogen_Aff_Driver_State.unDriverStateX((function () {
                                        var $86 = render(lchs);
                                        return function ($87) {
                                            return $86((function (v3) {
                                                return v3.selfRef;
                                            })($87));
                                        };
                                    })()))(Effect_Ref.read(v1))();
                                    Control_Bind.bindFlipped(Effect.bindEffect)(squashChildInitializers(lchs)(v2.initializers))(Effect_Ref.read(v1))();
                                    return v1;
                                };
                            });
                        };
                    };
                };
                var renderChild = function (lchs) {
                    return function (handler) {
                        return function (childrenInRef) {
                            return function (childrenOutRef) {
                                return Halogen_Component.unComponentSlot(function (slot) {
                                    return function __do() {
                                        var v = Data_Functor.map(Effect.functorEffect)(slot.pop)(Effect_Ref.read(childrenInRef))();
                                        var v1 = (function () {
                                            if (v instanceof Data_Maybe.Just) {
                                                Effect_Ref.write(v.value0.value1)(childrenInRef)();
                                                var v1 = Effect_Ref.read(v.value0.value0)();
                                                Halogen_Aff_Driver_State.unDriverStateX(function (st) {
                                                    return function __do() {
                                                        Data_Function.flip(Effect_Ref.write)(st.handlerRef)((function () {
                                                            var $88 = Data_Maybe.maybe(Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit))(handler);
                                                            return function ($89) {
                                                                return $88(slot.output($89));
                                                            };
                                                        })())();
                                                        return handleAff(Halogen_Aff_Driver_Eval.evalM(render)(st.selfRef)(st["component"]["eval"](slot.input)))();
                                                    };
                                                })(v1)();
                                                return v.value0.value0;
                                            };
                                            if (v instanceof Data_Maybe.Nothing) {
                                                if (slot.input instanceof Halogen_Query_HalogenQ.Receive) {
                                                    return runComponent(lchs)((function () {
                                                        var $90 = Data_Maybe.maybe(Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit))(handler);
                                                        return function ($91) {
                                                            return $90(slot.output($91));
                                                        };
                                                    })())(slot.input.value0)(slot.component)();
                                                };
                                                return Effect_Exception["throw"]("Halogen internal error: slot input was not a Receive query")();
                                            };
                                            throw new Error("Failed pattern match at Halogen.Aff.Driver (line 236, column 14 - line 249, column 81): " + [ v.constructor.name ]);
                                        })();
                                        var v2 = Data_Functor.map(Effect.functorEffect)(function ($92) {
                                            return Data_Maybe.isJust(slot.get($92));
                                        })(Effect_Ref.read(childrenOutRef))();
                                        Control_Applicative.when(Effect.applicativeEffect)(v2)(Effect_Console.warn("Halogen: Duplicate slot address was detected during rendering, unexpected results may occur"))();
                                        Effect_Ref.modify_(slot.set(v1))(childrenOutRef)();
                                        return Control_Bind.bind(Effect.bindEffect)(Effect_Ref.read(v1))(Halogen_Aff_Driver_State.renderStateX(Effect.functorEffect)(function (v3) {
                                            if (v3 instanceof Data_Maybe.Nothing) {
                                                return Effect_Exception["throw"]("Halogen internal error: child was not initialized in renderChild");
                                            };
                                            if (v3 instanceof Data_Maybe.Just) {
                                                return Control_Applicative.pure(Effect.applicativeEffect)(renderSpec.renderChild(v3.value0));
                                            };
                                            throw new Error("Failed pattern match at Halogen.Aff.Driver (line 254, column 37 - line 256, column 50): " + [ v3.constructor.name ]);
                                        }))();
                                    };
                                });
                            };
                        };
                    };
                };
                var render = function (lchs) {
                    return function ($$var) {
                        return function __do() {
                            var v = Effect_Ref.read($$var)();
                            var v1 = Data_Functor.map(Effect.functorEffect)(Data_Maybe.isNothing)(Effect_Ref.read(v.pendingHandlers))();
                            Control_Applicative.when(Effect.applicativeEffect)(v1)(Effect_Ref.write(new Data_Maybe.Just(Data_List_Types.Nil.value))(v.pendingHandlers))();
                            Effect_Ref.write(Halogen_Data_Slot.empty)(v.childrenOut)();
                            Effect_Ref.write(v.children)(v.childrenIn)();
                            var selfRef = Control_Category.identity(Control_Category.categoryFn)(v.selfRef);
                            var pendingQueries = Control_Category.identity(Control_Category.categoryFn)(v.pendingQueries);
                            var pendingHandlers = Control_Category.identity(Control_Category.categoryFn)(v.pendingHandlers);
                            var handler = (function () {
                                var $93 = Halogen_Aff_Driver_Eval.queueOrRun(pendingHandlers);
                                var $94 = Data_Functor["void"](Effect_Aff.functorAff);
                                var $95 = Halogen_Aff_Driver_Eval.evalF(render)(selfRef);
                                return function ($96) {
                                    return $93($94($95($96)));
                                };
                            })();
                            var childHandler = (function () {
                                var $97 = Halogen_Aff_Driver_Eval.queueOrRun(pendingQueries);
                                return function ($98) {
                                    return $97(handler(Halogen_Query_Input.Action.create($98)));
                                };
                            })();
                            var v2 = renderSpec.render(function ($99) {
                                return handleAff(handler($99));
                            })(renderChild(lchs)(childHandler)(v.childrenIn)(v.childrenOut))(v.component.render(v.state))(v.rendering)();
                            var v3 = Effect_Ref.read(v.childrenOut)();
                            var v4 = Effect_Ref.read(v.childrenIn)();
                            Halogen_Data_Slot.foreachSlot(Effect.applicativeEffect)(v4)(function (v5) {
                                return function __do() {
                                    var v6 = Effect_Ref.read(v5)();
                                    Halogen_Aff_Driver_State.renderStateX_(Effect.applicativeEffect)(renderSpec.removeChild)(v6)();
                                    return finalize(lchs)(v6)();
                                };
                            })();
                            Data_Function.flip(Effect_Ref.modify_)(v.selfRef)(Halogen_Aff_Driver_State.mapDriverState(function (ds$prime) {
                                return {
                                    component: ds$prime.component,
                                    state: ds$prime.state,
                                    refs: ds$prime.refs,
                                    children: v3,
                                    childrenIn: ds$prime.childrenIn,
                                    childrenOut: ds$prime.childrenOut,
                                    selfRef: ds$prime.selfRef,
                                    handlerRef: ds$prime.handlerRef,
                                    pendingQueries: ds$prime.pendingQueries,
                                    pendingOuts: ds$prime.pendingOuts,
                                    pendingHandlers: ds$prime.pendingHandlers,
                                    rendering: new Data_Maybe.Just(v2),
                                    fresh: ds$prime.fresh,
                                    subscriptions: ds$prime.subscriptions,
                                    forks: ds$prime.forks,
                                    lifecycleHandlers: ds$prime.lifecycleHandlers
                                };
                            }))();
                            return Control_Applicative.when(Effect.applicativeEffect)(v1)(Data_Function.flip(Control_Monad_Rec_Class.tailRecM(Control_Monad_Rec_Class.monadRecEffect))(Data_Unit.unit)(function (v5) {
                                return function __do() {
                                    var v6 = Effect_Ref.read(pendingHandlers)();
                                    Effect_Ref.write(new Data_Maybe.Just(Data_List_Types.Nil.value))(pendingHandlers)();
                                    Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)((function () {
                                        var $100 = Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_List_Types.foldableList)(Control_Monad_Fork_Class.fork(Control_Monad_Fork_Class.monadForkAff));
                                        return function ($101) {
                                            return handleAff($100(Data_List.reverse($101)));
                                        };
                                    })())(v6)();
                                    var v7 = Effect_Ref.read(pendingHandlers)();
                                    var $68 = Data_Maybe.maybe(false)(Data_List["null"])(v7);
                                    if ($68) {
                                        return Data_Functor.voidLeft(Effect.functorEffect)(Effect_Ref.write(Data_Maybe.Nothing.value)(pendingHandlers))(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() {
                            cleanupSubscriptionsAndForks(st)();
                            var f = Halogen_Aff_Driver_Eval.evalM(render)(st.selfRef)(st["component"]["eval"](new Halogen_Query_HalogenQ.Finalize(Data_Unit.unit)));
                            Effect_Ref.modify_(function (handlers) {
                                return {
                                    initializers: handlers.initializers,
                                    finalizers: new Data_List_Types.Cons(f, handlers.finalizers)
                                };
                            })(lchs)();
                            return Halogen_Data_Slot.foreachSlot(Effect.applicativeEffect)(st.children)(function (v) {
                                return function __do() {
                                    var v1 = Effect_Ref.read(v)();
                                    return finalize(lchs)(v1)();
                                };
                            })();
                        };
                    });
                };
                var evalDriver = function (disposed) {
                    return function (ref) {
                        return function (q) {
                            return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref.read(disposed)))(function (v) {
                                if (v) {
                                    return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Maybe.Nothing.value);
                                };
                                return Halogen_Aff_Driver_Eval.evalQ(render)(ref)(q);
                            });
                        };
                    };
                };
                var dispose = function (disposed) {
                    return function (lchs) {
                        return function (dsx) {
                            return function (subsRef) {
                                return Halogen_Aff_Driver_Eval.handleLifecycle(lchs)(function __do() {
                                    var v = Effect_Ref.read(disposed)();
                                    if (v) {
                                        return Data_Unit.unit;
                                    };
                                    Effect_Ref.write(true)(disposed)();
                                    Control_Bind.bindFlipped(Effect.bindEffect)(Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Map_Internal.foldableMap)((function () {
                                        var $102 = Effect_Aff_AVar.kill(Effect_Exception.error("disposed"));
                                        return function ($103) {
                                            return Effect_Aff.launchAff_($102($103));
                                        };
                                    })()))(Effect_Ref.read(subsRef))();
                                    finalize(lchs)(dsx)();
                                    return Halogen_Aff_Driver_State.unDriverStateX((function () {
                                        var $104 = Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(renderSpec.dispose);
                                        return function ($105) {
                                            return $104((function (v1) {
                                                return v1.rendering;
                                            })($105));
                                        };
                                    })())(dsx)();
                                });
                            };
                        };
                    };
                };
                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(newLifecycleHandlers))(function (v) {
                    return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref["new"](0)))(function (v1) {
                        return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Ref["new"](false)))(function (v2) {
                            return Halogen_Aff_Driver_Eval.handleLifecycle(v)(function __do() {
                                var v3 = Effect_Ref["new"](Data_Map_Internal.empty)();
                                var v4 = Control_Bind.bindFlipped(Effect.bindEffect)(Effect_Ref.read)(runComponent(v)(rootHandler(v3))(i)(component))();
                                return Halogen_Aff_Driver_State.unDriverStateX(function (st) {
                                    return Control_Applicative.pure(Effect.applicativeEffect)({
                                        query: evalDriver(v2)(st.selfRef),
                                        subscribe: subscribe(v1)(v3),
                                        dispose: dispose(v2)(v)(v4)(v3)
                                    });
                                })(v4)();
                            });
                        });
                    });
                });
            };
        };
    };
    exports["runUI"] = runUI;
  })(PS);
  (function(exports) {
    "use strict";                                               
  
    exports._querySelector = function (selector) {
      return function (node) {
        return function () {
          return node.querySelector(selector);
        };
      };
    };
  })(PS["Web.DOM.ParentNode"] = PS["Web.DOM.ParentNode"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.DOM.ParentNode"] = $PS["Web.DOM.ParentNode"] || {};
    var exports = $PS["Web.DOM.ParentNode"];
    var $foreign = $PS["Web.DOM.ParentNode"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Nullable = $PS["Data.Nullable"];
    var Effect = $PS["Effect"];
    var querySelector = function (qs) {
        var $3 = Data_Functor.map(Effect.functorEffect)(Data_Nullable.toMaybe);
        var $4 = $foreign["_querySelector"](qs);
        return function ($5) {
            return $3($4($5));
        };
    };
    exports["querySelector"] = querySelector;
  })(PS);
  (function(exports) {
    /* global window */
    "use strict";
  
    exports.window = function () {
      return window;
    };
  })(PS["Web.HTML"] = PS["Web.HTML"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML"] = $PS["Web.HTML"] || {};
    var exports = $PS["Web.HTML"];
    var $foreign = $PS["Web.HTML"];
    exports["window"] = $foreign.window;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.Event.EventTypes"] = $PS["Web.HTML.Event.EventTypes"] || {};
    var exports = $PS["Web.HTML.Event.EventTypes"];
    var domcontentloaded = "DOMContentLoaded";
    exports["domcontentloaded"] = domcontentloaded;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports._readyState = function (doc) {
      return function () {
        return doc.readyState;
      };
    };
  })(PS["Web.HTML.HTMLDocument"] = PS["Web.HTML.HTMLDocument"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.HTMLDocument.ReadyState"] = $PS["Web.HTML.HTMLDocument.ReadyState"] || {};
    var exports = $PS["Web.HTML.HTMLDocument.ReadyState"];
    var Data_Maybe = $PS["Data.Maybe"];              
    var Loading = (function () {
        function Loading() {
  
        };
        Loading.value = new Loading();
        return Loading;
    })();
    var Interactive = (function () {
        function Interactive() {
  
        };
        Interactive.value = new Interactive();
        return Interactive;
    })();
    var Complete = (function () {
        function Complete() {
  
        };
        Complete.value = new Complete();
        return Complete;
    })();
    var parse = function (v) {
        if (v === "loading") {
            return new Data_Maybe.Just(Loading.value);
        };
        if (v === "interactive") {
            return new Data_Maybe.Just(Interactive.value);
        };
        if (v === "complete") {
            return new Data_Maybe.Just(Complete.value);
        };
        return Data_Maybe.Nothing.value;
    };
    exports["Loading"] = Loading;
    exports["parse"] = parse;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.HTMLDocument"] = $PS["Web.HTML.HTMLDocument"] || {};
    var exports = $PS["Web.HTML.HTMLDocument"];
    var $foreign = $PS["Web.HTML.HTMLDocument"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Effect = $PS["Effect"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    var Web_HTML_HTMLDocument_ReadyState = $PS["Web.HTML.HTMLDocument.ReadyState"];
    var toParentNode = Unsafe_Coerce.unsafeCoerce; 
    var toDocument = Unsafe_Coerce.unsafeCoerce;
    var readyState = (function () {
        var $0 = Data_Functor.map(Effect.functorEffect)((function () {
            var $2 = Data_Maybe.fromMaybe(Web_HTML_HTMLDocument_ReadyState.Loading.value);
            return function ($3) {
                return $2(Web_HTML_HTMLDocument_ReadyState.parse($3));
            };
        })());
        return function ($1) {
            return $0($foreign["_readyState"]($1));
        };
    })();
    exports["toDocument"] = toDocument;
    exports["toParentNode"] = toParentNode;
    exports["readyState"] = readyState;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports._read = function (nothing, just, value) {
      var tag = Object.prototype.toString.call(value);
      if (tag.indexOf("[object HTML") === 0 && tag.indexOf("Element]") === tag.length - 8) {
        return just(value);
      } else {
        return nothing;
      }
    };
  })(PS["Web.HTML.HTMLElement"] = PS["Web.HTML.HTMLElement"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.HTMLElement"] = $PS["Web.HTML.HTMLElement"] || {};
    var exports = $PS["Web.HTML.HTMLElement"];
    var $foreign = $PS["Web.HTML.HTMLElement"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];                   
    var toNode = Unsafe_Coerce.unsafeCoerce;
    var fromElement = function (x) {
        return $foreign["_read"](Data_Maybe.Nothing.value, Data_Maybe.Just.create, x);
    };
    exports["fromElement"] = fromElement;
    exports["toNode"] = toNode;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.document = function (window) {
      return function () {
        return window.document;
      };
    };
  
    exports.location = function (window) {
      return function () {
        return window.location;
      };
    };
  })(PS["Web.HTML.Window"] = PS["Web.HTML.Window"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.Window"] = $PS["Web.HTML.Window"] || {};
    var exports = $PS["Web.HTML.Window"];
    var $foreign = $PS["Web.HTML.Window"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];
    var toEventTarget = Unsafe_Coerce.unsafeCoerce;
    exports["toEventTarget"] = toEventTarget;
    exports["document"] = $foreign.document;
    exports["location"] = $foreign.location;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Aff.Util"] = $PS["Halogen.Aff.Util"] || {};
    var exports = $PS["Halogen.Aff.Util"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Bind = $PS["Control.Bind"];
    var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
    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 Effect = $PS["Effect"];
    var Effect_Aff = $PS["Effect.Aff"];
    var Effect_Class = $PS["Effect.Class"];
    var Effect_Exception = $PS["Effect.Exception"];
    var Web_DOM_ParentNode = $PS["Web.DOM.ParentNode"];
    var Web_Event_EventTarget = $PS["Web.Event.EventTarget"];
    var Web_HTML = $PS["Web.HTML"];
    var Web_HTML_Event_EventTypes = $PS["Web.HTML.Event.EventTypes"];
    var Web_HTML_HTMLDocument = $PS["Web.HTML.HTMLDocument"];
    var Web_HTML_HTMLDocument_ReadyState = $PS["Web.HTML.HTMLDocument.ReadyState"];
    var Web_HTML_HTMLElement = $PS["Web.HTML.HTMLElement"];
    var Web_HTML_Window = $PS["Web.HTML.Window"];                
    var selectElement = function (query) {
        return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Control_Bind.bindFlipped(Effect.bindEffect)(Control_Bind.composeKleisliFlipped(Effect.bindEffect)((function () {
            var $12 = Web_DOM_ParentNode.querySelector(query);
            return function ($13) {
                return $12(Web_HTML_HTMLDocument.toParentNode($13));
            };
        })())(Web_HTML_Window.document))(Web_HTML.window)))(function (v) {
            return Control_Applicative.pure(Effect_Aff.applicativeAff)(Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(Web_HTML_HTMLElement.fromElement)(v));
        });
    };
    var runHalogenAff = Effect_Aff.runAff_(Data_Either.either(Effect_Exception.throwException)(Data_Function["const"](Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit))));
    var awaitLoad = Effect_Aff.makeAff(function (callback) {
        return function __do() {
            var v = Control_Bind.bindFlipped(Effect.bindEffect)(Web_HTML_HTMLDocument.readyState)(Control_Bind.bindFlipped(Effect.bindEffect)(Web_HTML_Window.document)(Web_HTML.window))();
            if (v instanceof Web_HTML_HTMLDocument_ReadyState.Loading) {
                var v1 = Data_Functor.map(Effect.functorEffect)(Web_HTML_Window.toEventTarget)(Web_HTML.window)();
                var v2 = Web_Event_EventTarget.eventListener(function (v2) {
                    return callback(new Data_Either.Right(Data_Unit.unit));
                })();
                Web_Event_EventTarget.addEventListener(Web_HTML_Event_EventTypes.domcontentloaded)(v2)(false)(v1)();
                return Effect_Aff.effectCanceler(Web_Event_EventTarget.removeEventListener(Web_HTML_Event_EventTypes.domcontentloaded)(v2)(false)(v1));
            };
            callback(new Data_Either.Right(Data_Unit.unit))();
            return Effect_Aff.nonCanceler;
        };
    });
    var awaitBody = Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(awaitLoad)(function () {
        return Control_Bind.bind(Effect_Aff.bindAff)(selectElement("body"))(function (v) {
            return Data_Maybe.maybe(Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error("Could not find body")))(Control_Applicative.pure(Effect_Aff.applicativeAff))(v);
        });
    });
    exports["awaitBody"] = awaitBody;
    exports["runHalogenAff"] = runHalogenAff;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.HTML"] = $PS["Halogen.HTML"] || {};
    var exports = $PS["Halogen.HTML"];
    var Halogen_Component = $PS["Halogen.Component"];
    var Halogen_HTML_Core = $PS["Halogen.HTML.Core"];        
    var slot = function (dictCons) {
        return function (dictIsSymbol) {
            return function (dictOrd) {
                return function (label) {
                    return function (p) {
                        return function (component) {
                            return function (input) {
                                return function (outputQuery) {
                                    return Halogen_HTML_Core.widget(new Halogen_Component.ComponentSlot(Halogen_Component.componentSlot()(dictIsSymbol)(dictOrd)(label)(p)(component)(input)(outputQuery)));
                                };
                            };
                        };
                    };
                };
            };
        };
    };
    exports["slot"] = slot;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.HTML.Properties"] = $PS["Halogen.HTML.Properties"] || {};
    var exports = $PS["Halogen.HTML.Properties"];
    var Halogen_HTML_Core = $PS["Halogen.HTML.Core"];
    var prop = function (dictIsProp) {
        return Halogen_HTML_Core.prop(dictIsProp);
    };                                                   
    var href = prop(Halogen_HTML_Core.isPropString)("href");
    exports["href"] = href;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.Query"] = $PS["Halogen.Query"] || {};
    var exports = $PS["Halogen.Query"];
    var Data_Unit = $PS["Data.Unit"];                                      
    var tell = function (act) {
        return act(Data_Unit.unit);
    };
    exports["tell"] = tell;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.DOM.Element"] = $PS["Web.DOM.Element"] || {};
    var exports = $PS["Web.DOM.Element"];
    var Unsafe_Coerce = $PS["Unsafe.Coerce"];                   
    var toNode = Unsafe_Coerce.unsafeCoerce;
    exports["toNode"] = toNode;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.DOM"] = $PS["Halogen.VDom.DOM"] || {};
    var exports = $PS["Halogen.VDom.DOM"];
    var Data_Array = $PS["Data.Array"];
    var Data_Boolean = $PS["Data.Boolean"];
    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 Web_DOM_Element = $PS["Web.DOM.Element"];
    var haltWidget = function (v) {
        return Halogen_VDom_Machine.halt(v.widget);
    };
    var patchWidget = function (state, vdom) {
        if (vdom instanceof Halogen_VDom_Types.Grafted) {
            return patchWidget(state, Halogen_VDom_Types.runGraft(vdom.value0));
        };
        if (vdom instanceof Halogen_VDom_Types.Widget) {
            var v = Halogen_VDom_Machine.step(state.widget, vdom.value0);
            var res$prime = Halogen_VDom_Machine.unStep(function (v1) {
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(v1.value0, {
                    build: state.build,
                    widget: v
                }, patchWidget, haltWidget));
            })(v);
            return res$prime;
        };
        haltWidget(state);
        return state.build(vdom);
    };
    var haltText = function (v) {
        var v1 = Halogen_VDom_Util.parentNode(v.node);
        return Halogen_VDom_Util.removeChild(v.node, v1);
    };
    var patchText = function (state, vdom) {
        if (vdom instanceof Halogen_VDom_Types.Grafted) {
            return patchText(state, Halogen_VDom_Types.runGraft(vdom.value0));
        };
        if (vdom instanceof Halogen_VDom_Types.Text) {
            if (state.value === vdom.value0) {
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(state.node, state, patchText, haltText));
            };
            if (Data_Boolean.otherwise) {
                var nextState = {
                    build: state.build,
                    node: state.node,
                    value: vdom.value0
                };
                Halogen_VDom_Util.setTextContent(vdom.value0, state.node);
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(state.node, nextState, patchText, haltText));
            };
        };
        haltText(state);
        return state.build(vdom);
    };
    var haltKeyed = function (v) {
        var v1 = Halogen_VDom_Util.parentNode(v.node);
        Halogen_VDom_Util.removeChild(v.node, v1);
        Halogen_VDom_Util.forInE(v.children, function (v2, s) {
            return Halogen_VDom_Machine.halt(s);
        });
        return Halogen_VDom_Machine.halt(v.attrs);
    };
    var haltElem = function (v) {
        var v1 = Halogen_VDom_Util.parentNode(v.node);
        Halogen_VDom_Util.removeChild(v.node, v1);
        Halogen_VDom_Util.forEachE(v.children, Halogen_VDom_Machine.halt);
        return Halogen_VDom_Machine.halt(v.attrs);
    };
    var eqElemSpec = function (ns1, v, ns2, v1) {
        var $84 = v === v1;
        if ($84) {
            if (ns1 instanceof Data_Maybe.Just && (ns2 instanceof Data_Maybe.Just && ns1.value0 === ns2.value0)) {
                return true;
            };
            if (ns1 instanceof Data_Maybe.Nothing && ns2 instanceof Data_Maybe.Nothing) {
                return true;
            };
            return false;
        };
        return false;
    };
    var patchElem = function (state, vdom) {
        if (vdom instanceof Halogen_VDom_Types.Grafted) {
            return patchElem(state, Halogen_VDom_Types.runGraft(vdom.value0));
        };
        if (vdom instanceof Halogen_VDom_Types.Elem && eqElemSpec(state.ns, state.name, vdom.value0, vdom.value1)) {
            var v = Data_Array.length(vdom.value3);
            var v1 = Data_Array.length(state.children);
            if (v1 === 0 && v === 0) {
                var v2 = Halogen_VDom_Machine.step(state.attrs, vdom.value2);
                var nextState = {
                    build: state.build,
                    node: state.node,
                    attrs: v2,
                    ns: vdom.value0,
                    name: vdom.value1,
                    children: state.children
                };
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(state.node, nextState, patchElem, haltElem));
            };
            var onThis = function (ix, s) {
                return Halogen_VDom_Machine.halt(s);
            };
            var onThese = function (ix, s, v2) {
                var v3 = Halogen_VDom_Machine.step(s, v2);
                Halogen_VDom_Util.insertChildIx(ix, Halogen_VDom_Machine.extract(v3), state.node);
                return v3;
            };
            var onThat = function (ix, v2) {
                var v3 = state.build(v2);
                Halogen_VDom_Util.insertChildIx(ix, Halogen_VDom_Machine.extract(v3), state.node);
                return v3;
            };
            var v2 = Halogen_VDom_Util.diffWithIxE(state.children, vdom.value3, onThese, onThis, onThat);
            var v3 = Halogen_VDom_Machine.step(state.attrs, vdom.value2);
            var nextState = {
                build: state.build,
                node: state.node,
                attrs: v3,
                ns: vdom.value0,
                name: vdom.value1,
                children: v2
            };
            return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(state.node, nextState, patchElem, haltElem));
        };
        haltElem(state);
        return state.build(vdom);
    };
    var patchKeyed = function (state, vdom) {
        if (vdom instanceof Halogen_VDom_Types.Grafted) {
            return patchKeyed(state, Halogen_VDom_Types.runGraft(vdom.value0));
        };
        if (vdom instanceof Halogen_VDom_Types.Keyed && eqElemSpec(state.ns, state.name, vdom.value0, vdom.value1)) {
            var v = Data_Array.length(vdom.value3);
            if (state.length === 0 && v === 0) {
                var v2 = Halogen_VDom_Machine.step(state.attrs, vdom.value2);
                var nextState = {
                    build: state.build,
                    node: state.node,
                    attrs: v2,
                    ns: vdom.value0,
                    name: vdom.value1,
                    children: state.children,
                    length: 0
                };
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(state.node, nextState, patchKeyed, haltKeyed));
            };
            var onThis = function (v2, s) {
                return Halogen_VDom_Machine.halt(s);
            };
            var onThese = function (v2, ix$prime, s, v3) {
                var v5 = Halogen_VDom_Machine.step(s, v3.value1);
                Halogen_VDom_Util.insertChildIx(ix$prime, Halogen_VDom_Machine.extract(v5), state.node);
                return v5;
            };
            var onThat = function (v2, ix, v3) {
                var v5 = state.build(v3.value1);
                Halogen_VDom_Util.insertChildIx(ix, Halogen_VDom_Machine.extract(v5), state.node);
                return v5;
            };
            var v2 = Halogen_VDom_Util.diffWithKeyAndIxE(state.children, vdom.value3, Data_Tuple.fst, onThese, onThis, onThat);
            var v3 = Halogen_VDom_Machine.step(state.attrs, vdom.value2);
            var nextState = {
                build: state.build,
                node: state.node,
                attrs: v3,
                ns: vdom.value0,
                name: vdom.value1,
                children: v2,
                length: v
            };
            return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(state.node, nextState, patchKeyed, haltKeyed));
        };
        haltKeyed(state);
        return state.build(vdom);
    };
    var buildWidget = function (v, build, w) {
        var v1 = v.buildWidget(v)(w);
        var res$prime = Halogen_VDom_Machine.unStep(function (v2) {
            return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(v2.value0, {
                build: build,
                widget: v1
            }, patchWidget, haltWidget));
        })(v1);
        return res$prime;
    };
    var buildText = function (v, build, s) {
        var v1 = Halogen_VDom_Util.createTextNode(s, v.document);
        var state = {
            build: build,
            node: v1,
            value: s
        };
        return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(v1, state, patchText, haltText));
    };
    var buildKeyed = function (v, build, ns1, name1, as1, ch1) {
        var v1 = Halogen_VDom_Util.createElement(Data_Nullable.toNullable(ns1), name1, v.document);
        var node = Web_DOM_Element.toNode(v1);
        var onChild = function (k, ix, v2) {
            var v3 = build(v2.value1);
            Halogen_VDom_Util.insertChildIx(ix, Halogen_VDom_Machine.extract(v3), node);
            return v3;
        };
        var v2 = Halogen_VDom_Util.strMapWithIxE(ch1, Data_Tuple.fst, onChild);
        var v3 = v.buildAttributes(v1)(as1);
        var state = {
            build: build,
            node: node,
            attrs: v3,
            ns: ns1,
            name: name1,
            children: v2,
            length: Data_Array.length(ch1)
        };
        return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(node, state, patchKeyed, haltKeyed));
    };
    var buildElem = function (v, build, ns1, name1, as1, ch1) {
        var v1 = Halogen_VDom_Util.createElement(Data_Nullable.toNullable(ns1), name1, v.document);
        var node = Web_DOM_Element.toNode(v1);
        var onChild = function (ix, child) {
            var v2 = build(child);
            Halogen_VDom_Util.insertChildIx(ix, Halogen_VDom_Machine.extract(v2), node);
            return v2;
        };
        var v2 = Halogen_VDom_Util.forE(ch1, onChild);
        var v3 = v.buildAttributes(v1)(as1);
        var state = {
            build: build,
            node: node,
            attrs: v3,
            ns: ns1,
            name: name1,
            children: v2
        };
        return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(node, state, patchElem, haltElem));
    };
    var buildVDom = function (spec) {
        var build = function (v) {
            if (v instanceof Halogen_VDom_Types.Text) {
                return buildText(spec, build, v.value0);
            };
            if (v instanceof Halogen_VDom_Types.Elem) {
                return buildElem(spec, build, v.value0, v.value1, v.value2, v.value3);
            };
            if (v instanceof Halogen_VDom_Types.Keyed) {
                return buildKeyed(spec, build, v.value0, v.value1, v.value2, v.value3);
            };
            if (v instanceof Halogen_VDom_Types.Widget) {
                return buildWidget(spec, build, v.value0);
            };
            if (v instanceof Halogen_VDom_Types.Grafted) {
                return build(Halogen_VDom_Types.runGraft(v.value0));
            };
            throw new Error("Failed pattern match at Halogen.VDom.DOM (line 58, column 27 - line 63, column 52): " + [ v.constructor.name ]);
        };
        return build;
    };
    exports["buildVDom"] = buildVDom;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.Thunk"] = $PS["Halogen.VDom.Thunk"] || {};
    var exports = $PS["Halogen.VDom.Thunk"];
    var Halogen_VDom_DOM = $PS["Halogen.VDom.DOM"];
    var Halogen_VDom_Machine = $PS["Halogen.VDom.Machine"];
    var Halogen_VDom_Util = $PS["Halogen.VDom.Util"];        
    var Thunk = (function () {
        function Thunk(value0, value1, value2, value3) {
            this.value0 = value0;
            this.value1 = value1;
            this.value2 = value2;
            this.value3 = value3;
        };
        Thunk.create = function (value0) {
            return function (value1) {
                return function (value2) {
                    return function (value3) {
                        return new Thunk(value0, value1, value2, value3);
                    };
                };
            };
        };
        return Thunk;
    })();                                          
    var unsafeEqThunk = function (v, v1) {
        return Halogen_VDom_Util.refEq(v.value0, v1.value0) && (Halogen_VDom_Util.refEq(v.value1, v1.value1) && Halogen_VDom_Util.refEq(v.value3, v1.value3));
    };
    var thunk = function (tid, eqFn, f, a) {
        return new Thunk(tid, eqFn, f, a);
    };
    var runThunk = function (v) {
        return v.value2(v.value3);
    };
    var buildThunk = function (toVDom) {
        var haltThunk = function (state) {
            return Halogen_VDom_Machine.halt(state.vdom);
        };
        var patchThunk = function (state, t2) {
            var $45 = unsafeEqThunk(state.thunk, t2);
            if ($45) {
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Halogen_VDom_Machine.extract(state.vdom), state, patchThunk, haltThunk));
            };
            var v = Halogen_VDom_Machine.step(state.vdom, toVDom(runThunk(t2)));
            return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Halogen_VDom_Machine.extract(v), {
                vdom: v,
                thunk: t2
            }, patchThunk, haltThunk));
        };
        var renderThunk = function (spec) {
            return function (t) {
                var v = Halogen_VDom_DOM.buildVDom(spec)(toVDom(runThunk(t)));
                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Halogen_VDom_Machine.extract(v), {
                    thunk: t,
                    vdom: v
                }, patchThunk, haltThunk));
            };
        };
        return renderThunk;
    };
    exports["buildThunk"] = buildThunk;
  })(PS);
  (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["Web.DOM.Node"] = PS["Web.DOM.Node"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.DOM.Node"] = $PS["Web.DOM.Node"] || {};
    var exports = $PS["Web.DOM.Node"];
    var $foreign = $PS["Web.DOM.Node"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Nullable = $PS["Data.Nullable"];
    var Effect = $PS["Effect"];
    var parentNode = (function () {
        var $3 = Data_Functor.map(Effect.functorEffect)(Data_Nullable.toMaybe);
        return function ($4) {
            return $3($foreign["_parentNode"]($4));
        };
    })();
    var nextSibling = (function () {
        var $14 = Data_Functor.map(Effect.functorEffect)(Data_Nullable.toMaybe);
        return function ($15) {
            return $14($foreign["_nextSibling"]($15));
        };
    })();
    exports["parentNode"] = parentNode;
    exports["nextSibling"] = nextSibling;
    exports["insertBefore"] = $foreign.insertBefore;
    exports["appendChild"] = $foreign.appendChild;
    exports["removeChild"] = $foreign.removeChild;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Halogen.VDom.Driver"] = $PS["Halogen.VDom.Driver"] || {};
    var exports = $PS["Halogen.VDom.Driver"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Bind = $PS["Control.Bind"];
    var Control_Category = $PS["Control.Category"];
    var Data_Foldable = $PS["Data.Foldable"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Newtype = $PS["Data.Newtype"];
    var Data_Unit = $PS["Data.Unit"];
    var Effect = $PS["Effect"];
    var Effect_Aff = $PS["Effect.Aff"];
    var Effect_Class = $PS["Effect.Class"];
    var Effect_Ref = $PS["Effect.Ref"];
    var Halogen_Aff_Driver = $PS["Halogen.Aff.Driver"];
    var Halogen_Aff_Driver_State = $PS["Halogen.Aff.Driver.State"];
    var Halogen_Component = $PS["Halogen.Component"];
    var Halogen_HTML_Core = $PS["Halogen.HTML.Core"];
    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 Halogen_VDom_Thunk = $PS["Halogen.VDom.Thunk"];
    var Unsafe_Reference = $PS["Unsafe.Reference"];
    var Web_DOM_Node = $PS["Web.DOM.Node"];
    var Web_HTML = $PS["Web.HTML"];
    var Web_HTML_HTMLDocument = $PS["Web.HTML.HTMLDocument"];
    var Web_HTML_HTMLElement = $PS["Web.HTML.HTMLElement"];
    var Web_HTML_Window = $PS["Web.HTML.Window"];
    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"](Effect.functorEffect)(Web_DOM_Node.insertBefore(v)(v1.value0)(v2.value0));
                };
                if (v1 instanceof Data_Maybe.Nothing && v2 instanceof Data_Maybe.Just) {
                    return Data_Functor["void"](Effect.functorEffect)(Web_DOM_Node.appendChild(v)(v2.value0));
                };
                return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
            };
        };
    };
    var removeChild = function (v) {
        return function __do() {
            var v1 = Web_DOM_Node.parentNode(v.node)();
            return Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(function (pn) {
                return Web_DOM_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 = function (st) {
                    if (st instanceof Data_Maybe.Just) {
                        return Halogen_VDom_Machine.halt(st.value0);
                    };
                    return Data_Unit.unit;
                };
                var buildWidget = function (spec) {
                    var buildThunk = Halogen_VDom_Thunk.buildThunk(Data_Newtype.unwrap(Halogen_HTML_Core.newtypeHTML))(spec);
                    var renderComponentSlot = function (cs) {
                        var v = Effect_Ref.read(renderChildRef)();
                        var v1 = v(cs)();
                        var node = getNode(v1);
                        return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(node, Data_Maybe.Nothing.value, patch, done));
                    };
                    var render = function (slot) {
                        if (slot instanceof Halogen_Component.ComponentSlot) {
                            return renderComponentSlot(slot.value0);
                        };
                        if (slot instanceof Halogen_Component.ThunkSlot) {
                            var v = buildThunk(slot.value0);
                            return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Halogen_VDom_Machine.extract(v), new Data_Maybe.Just(v), patch, done));
                        };
                        throw new Error("Failed pattern match at Halogen.VDom.Driver (line 85, column 7 - line 90, column 75): " + [ slot.constructor.name ]);
                    };
                    var patch = function (st, slot) {
                        if (st instanceof Data_Maybe.Just) {
                            if (slot instanceof Halogen_Component.ComponentSlot) {
                                Halogen_VDom_Machine.halt(st.value0);
                                return renderComponentSlot(slot.value0);
                            };
                            if (slot instanceof Halogen_Component.ThunkSlot) {
                                var v = Halogen_VDom_Machine.step(st.value0, slot.value0);
                                return Halogen_VDom_Machine.mkStep(new Halogen_VDom_Machine.Step(Halogen_VDom_Machine.extract(v), new Data_Maybe.Just(v), patch, done));
                            };
                            throw new Error("Failed pattern match at Halogen.VDom.Driver (line 98, column 22 - line 104, column 79): " + [ slot.constructor.name ]);
                        };
                        return render(slot);
                    };
                    return render;
                };
                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 = Effect_Ref["new"](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"](Effect.functorEffect)(Web_DOM_Node.appendChild(node)(Web_HTML_HTMLElement.toNode(container)))();
                                    return {
                                        machine: v3,
                                        node: node,
                                        renderChildRef: v2
                                    };
                                };
                            };
                            if (v1 instanceof Data_Maybe.Just) {
                                return function __do() {
                                    Effect_Ref.write(child)(v1.value0.renderChildRef)();
                                    var v2 = Web_DOM_Node.parentNode(v1.value0.node)();
                                    var v3 = Web_DOM_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(Effect.applicativeEffect)(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 159, column 5 - line 175, column 80): " + [ v1.constructor.name ]);
                        };
                    };
                };
            };
            return {
                render: render,
                renderChild: Control_Category.identity(Control_Category.categoryFn),
                removeChild: removeChild,
                dispose: removeChild
            };
        };
    };
    var runUI = function (component) {
        return function (i) {
            return function (element) {
                return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Data_Functor.map(Effect.functorEffect)(Web_HTML_HTMLDocument.toDocument)(Control_Bind.bindFlipped(Effect.bindEffect)(Web_HTML_Window.document)(Web_HTML.window))))(function (v) {
                    return Halogen_Aff_Driver.runUI(renderSpec(v)(element))(component)(i);
                });
            };
        };
    };
    exports["runUI"] = runUI;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.Event.HashChangeEvent.EventTypes"] = $PS["Web.HTML.Event.HashChangeEvent.EventTypes"] || {};
    var exports = $PS["Web.HTML.Event.HashChangeEvent.EventTypes"];
    var hashchange = "hashchange";
    exports["hashchange"] = hashchange;
  })(PS);
  (function(exports) {
    "use strict";
  
    exports.hash = function (location) {
      return function () {
        return location.hash;
      };
    };
  })(PS["Web.HTML.Location"] = PS["Web.HTML.Location"] || {});
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Web.HTML.Location"] = $PS["Web.HTML.Location"] || {};
    var exports = $PS["Web.HTML.Location"];
    var $foreign = $PS["Web.HTML.Location"];
    exports["hash"] = $foreign.hash;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Router"] = $PS["Router"] || {};
    var exports = $PS["Router"];
    var Control_Bind = $PS["Control.Bind"];
    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 Effect = $PS["Effect"];
    var Web_Event_EventTarget = $PS["Web.Event.EventTarget"];
    var Web_HTML = $PS["Web.HTML"];
    var Web_HTML_Event_HashChangeEvent_EventTypes = $PS["Web.HTML.Event.HashChangeEvent.EventTypes"];
    var Web_HTML_Location = $PS["Web.HTML.Location"];
    var Web_HTML_Window = $PS["Web.HTML.Window"];                
    var Roast = (function () {
        function Roast() {
  
        };
        Roast.value = new Roast();
        return Roast;
    })();
    var Chips = (function () {
        function Chips() {
  
        };
        Chips.value = new Chips();
        return Chips;
    })();
    var Salad = (function () {
        function Salad() {
  
        };
        Salad.value = new Salad();
        return Salad;
    })();
    var getRoute = function __do() {
        var v = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Web_HTML.window)(Web_HTML_Window.location))(Web_HTML_Location.hash)();
        if (v === "#roast") {
            return new Data_Maybe.Just(Roast.value);
        };
        if (v === "#chips") {
            return new Data_Maybe.Just(Chips.value);
        };
        if (v === "#salad") {
            return new Data_Maybe.Just(Salad.value);
        };
        return Data_Maybe.Nothing.value;
    };
    var router = function (cb) {
        var matchRoute = function __do() {
            var v = getRoute();
            if (v instanceof Data_Maybe.Just) {
                return cb(v.value0)();
            };
            if (v instanceof Data_Maybe.Nothing) {
                return Data_Unit.unit;
            };
            throw new Error("Failed pattern match at Router (line 25, column 15 - line 27, column 37): " + [ v.constructor.name ]);
        };
        return function __do() {
            var v = Data_Functor.mapFlipped(Effect.functorEffect)(Web_HTML.window)(Web_HTML_Window.toEventTarget)();
            var v1 = Web_Event_EventTarget.eventListener(Data_Function["const"](matchRoute))();
            return Web_Event_EventTarget.addEventListener(Web_HTML_Event_HashChangeEvent_EventTypes.hashchange)(v1)(false)(v)();
        };
    };
    exports["Roast"] = Roast;
    exports["Chips"] = Chips;
    exports["Salad"] = Salad;
    exports["router"] = router;
    exports["getRoute"] = getRoute;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Parent"] = $PS["Parent"] || {};
    var exports = $PS["Parent"];
    var Children = $PS["Children"];
    var Control_Applicative = $PS["Control.Applicative"];
    var Control_Bind = $PS["Control.Bind"];
    var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Data_Ord = $PS["Data.Ord"];
    var Data_Symbol = $PS["Data.Symbol"];
    var Data_Unit = $PS["Data.Unit"];
    var Data_Void = $PS["Data.Void"];
    var Halogen_Component = $PS["Halogen.Component"];
    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 Halogen_Query_HalogenM = $PS["Halogen.Query.HalogenM"];
    var Router = $PS["Router"];                
    var ChangeRoute = (function () {
        function ChangeRoute(value0, value1) {
            this.value0 = value0;
            this.value1 = value1;
        };
        ChangeRoute.create = function (value0) {
            return function (value1) {
                return new ChangeRoute(value0, value1);
            };
        };
        return ChangeRoute;
    })();
    var renderMenu = Halogen_HTML_Elements.div_([ Halogen_HTML_Elements.a([ Halogen_HTML_Properties.href("#roast") ])([ Halogen_HTML_Core.text("Roast") ]), Halogen_HTML_Core.text(" | "), Halogen_HTML_Elements.a([ Halogen_HTML_Properties.href("#chips") ])([ Halogen_HTML_Core.text("Chips") ]), Halogen_HTML_Core.text(" | "), Halogen_HTML_Elements.a([ Halogen_HTML_Properties.href("#salad") ])([ Halogen_HTML_Core.text("Salad") ]) ]);
    var initialState = function (route) {
        return {
            currentRoute: route
        };
    };
    var handleQuery = function (v) {
        return Control_Bind.discard(Control_Bind.discardUnit)(Halogen_Query_HalogenM.bindHalogenM)(Control_Monad_State_Class.modify_(Halogen_Query_HalogenM.monadStateHalogenM)(function (v1) {
            var $4 = {};
            for (var $5 in v1) {
                if ({}.hasOwnProperty.call(v1, $5)) {
                    $4[$5] = v1[$5];
                };
            };
            $4.currentRoute = v.value0;
            return $4;
        }))(function () {
            return Control_Applicative.pure(Halogen_Query_HalogenM.applicativeHalogenM)(new Data_Maybe.Just(v.value1));
        });
    };
    var _child3 = Data_Symbol.SProxy.value;
    var _child2 = Data_Symbol.SProxy.value;
    var _child1 = Data_Symbol.SProxy.value;
    var renderPane = function (state) {
        return Halogen_HTML_Elements.div_([ (function () {
            if (state.currentRoute instanceof Router.Roast) {
                return Halogen_HTML.slot()(new Data_Symbol.IsSymbol(function () {
                    return "child1";
                }))(Data_Ord.ordUnit)(_child1)(Data_Unit.unit)(Children.roast)(Data_Unit.unit)(Data_Void.absurd);
            };
            if (state.currentRoute instanceof Router.Chips) {
                return Halogen_HTML.slot()(new Data_Symbol.IsSymbol(function () {
                    return "child2";
                }))(Data_Ord.ordUnit)(_child2)(Data_Unit.unit)(Children.chips)(Data_Unit.unit)(Data_Void.absurd);
            };
            if (state.currentRoute instanceof Router.Salad) {
                return Halogen_HTML.slot()(new Data_Symbol.IsSymbol(function () {
                    return "child3";
                }))(Data_Ord.ordUnit)(_child3)(Data_Unit.unit)(Children.salad)(Data_Unit.unit)(Data_Void.absurd);
            };
            throw new Error("Failed pattern match at Parent (line 65, column 30 - line 68, column 90): " + [ state.currentRoute.constructor.name ]);
        })() ]);
    };
    var render = function (state) {
        return Halogen_HTML_Elements.div_([ renderMenu, renderPane(state) ]);
    };
    var page = Halogen_Component.mkComponent({
        initialState: initialState,
        render: render,
        "eval": Halogen_Component.mkEval({
            handleAction: Halogen_Component.defaultEval.handleAction,
            handleQuery: handleQuery,
            receive: Halogen_Component.defaultEval.receive,
            initialize: Halogen_Component.defaultEval.initialize,
            finalize: Halogen_Component.defaultEval.finalize
        })
    });
    exports["ChangeRoute"] = ChangeRoute;
    exports["page"] = page;
  })(PS);
  (function($PS) {
    // Generated by purs version 0.13.4
    "use strict";
    $PS["Main"] = $PS["Main"] || {};
    var exports = $PS["Main"];
    var Control_Bind = $PS["Control.Bind"];
    var Data_Functor = $PS["Data.Functor"];
    var Data_Maybe = $PS["Data.Maybe"];
    var Effect = $PS["Effect"];
    var Effect_Aff = $PS["Effect.Aff"];
    var Effect_Class = $PS["Effect.Class"];
    var Halogen_Aff_Util = $PS["Halogen.Aff.Util"];
    var Halogen_Query = $PS["Halogen.Query"];
    var Halogen_VDom_Driver = $PS["Halogen.VDom.Driver"];
    var Parent = $PS["Parent"];
    var Router = $PS["Router"];                
    var main = Halogen_Aff_Util.runHalogenAff(Control_Bind.bind(Effect_Aff.bindAff)(Halogen_Aff_Util.awaitBody)(function (v) {
        return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Data_Functor.map(Effect.functorEffect)(Data_Maybe.fromMaybe(Router.Roast.value))(Router.getRoute)))(function (v1) {
            return Control_Bind.bind(Effect_Aff.bindAff)(Halogen_VDom_Driver.runUI(Parent.page)(v1)(v))(function (v2) {
                return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Router.router(function (route) {
                    return Effect_Aff.launchAff_(v2.query(Halogen_Query.tell(Parent.ChangeRoute.create(route))));
                }));
            });
        });
    }));
    exports["main"] = main;
  })(PS);
  PS["Main"].main();