// Generated by purs version 0.12.5
"use strict";
var Control_Alt = require("../Control.Alt/index.js");
var Control_Applicative = require("../Control.Applicative/index.js");
var Control_Apply = require("../Control.Apply/index.js");
var Control_Bind = require("../Control.Bind/index.js");
var Control_Category = require("../Control.Category/index.js");
var Control_Lazy = require("../Control.Lazy/index.js");
var Data_Array = require("../Data.Array/index.js");
var Data_Boolean = require("../Data.Boolean/index.js");
var Data_Decimal = require("../Data.Decimal/index.js");
var Data_Either = require("../Data.Either/index.js");
var Data_Foldable = require("../Data.Foldable/index.js");
var Data_Functor = require("../Data.Functor/index.js");
var Data_Identity = require("../Data.Identity/index.js");
var Data_List = require("../Data.List/index.js");
var Data_List_Types = require("../Data.List.Types/index.js");
var Data_Map_Internal = require("../Data.Map.Internal/index.js");
var Data_Maybe = require("../Data.Maybe/index.js");
var Data_NonEmpty = require("../Data.NonEmpty/index.js");
var Data_Ord = require("../Data.Ord/index.js");
var Data_Semigroup = require("../Data.Semigroup/index.js");
var Data_String_CodePoints = require("../Data.String.CodePoints/index.js");
var Data_Unit = require("../Data.Unit/index.js");
var Data_Units = require("../Data.Units/index.js");
var Data_Units_Astronomical = require("../Data.Units.Astronomical/index.js");
var Data_Units_Bit = require("../Data.Units.Bit/index.js");
var Data_Units_CGS = require("../Data.Units.CGS/index.js");
var Data_Units_Currency = require("../Data.Units.Currency/index.js");
var Data_Units_Imperial = require("../Data.Units.Imperial/index.js");
var Data_Units_Misc = require("../Data.Units.Misc/index.js");
var Data_Units_Nautical = require("../Data.Units.Nautical/index.js");
var Data_Units_PartsPerX = require("../Data.Units.PartsPerX/index.js");
var Data_Units_SI = require("../Data.Units.SI/index.js");
var Data_Units_SI_Accepted = require("../Data.Units.SI.Accepted/index.js");
var Data_Units_SI_Derived = require("../Data.Units.SI.Derived/index.js");
var Data_Units_Time = require("../Data.Units.Time/index.js");
var Data_Units_USCustomary = require("../Data.Units.USCustomary/index.js");
var Insect_Language = require("../Insect.Language/index.js");
var Text_Parsing_Parser = require("../Text.Parsing.Parser/index.js");
var Text_Parsing_Parser_Combinators = require("../Text.Parsing.Parser.Combinators/index.js");
var Text_Parsing_Parser_String = require("../Text.Parsing.Parser.String/index.js");
var Text_Parsing_Parser_Token = require("../Text.Parsing.Parser.Token/index.js");
var DictEntry = (function () {
    function DictEntry(value0, value1) {
        this.value0 = value0;
        this.value1 = value1;
    };
    DictEntry.create = function (value0) {
        return function (value1) {
            return new DictEntry(value0, value1);
        };
    };
    return DictEntry;
})();
var Dictionary = (function () {
    function Dictionary(value0) {
        this.value0 = value0;
    };
    Dictionary.create = function (value0) {
        return new Dictionary(value0);
    };
    return Dictionary;
})();
var specialCases = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("d"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Units_Time.day)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("t"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Units_SI_Accepted.tonne)));
var sepBy1 = function (dictMonad) {
    return function (p) {
        return function (sep) {
            return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(p)(function (v) {
                return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(Data_List.many(Text_Parsing_Parser.alternativeParserT(dictMonad))(Text_Parsing_Parser.lazyParserT)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(dictMonad))(sep)(p)))(function (v1) {
                    return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(new Data_NonEmpty.NonEmpty(v, v1));
                });
            });
        };
    };
};
var prefixDict = new Dictionary([ new DictEntry(Data_Units.kibi, [ "kibi", "Ki" ]), new DictEntry(Data_Units.mebi, [ "mebi", "Mi" ]), new DictEntry(Data_Units.gibi, [ "gibi", "Gi" ]), new DictEntry(Data_Units.tebi, [ "tebi", "Ti" ]), new DictEntry(Data_Units.pebi, [ "pebi", "Pi" ]), new DictEntry(Data_Units.exbi, [ "exbi", "Ei" ]), new DictEntry(Data_Units.zebi, [ "zebi", "Zi" ]), new DictEntry(Data_Units.yobi, [ "yobi", "Yi" ]), new DictEntry(Data_Units.atto, [ "atto", "a" ]), new DictEntry(Data_Units.femto, [ "femto", "f" ]), new DictEntry(Data_Units.peta, [ "peta" ]), new DictEntry(Data_Units.mega, [ "mega" ]), new DictEntry(Data_Units.pico, [ "pico", "p" ]), new DictEntry(Data_Units.nano, [ "nano", "n" ]), new DictEntry(Data_Units.micro, [ "micro", "u", "\xb5", "\u03bc" ]), new DictEntry(Data_Units.milli, [ "milli", "m" ]), new DictEntry(Data_Units.centi, [ "centi", "c" ]), new DictEntry(Data_Units.deci, [ "deci", "d" ]), new DictEntry(Data_Units.hecto, [ "hecto", "h" ]), new DictEntry(Data_Units.kilo, [ "kilo", "k" ]), new DictEntry(Data_Units.mega, [ "M" ]), new DictEntry(Data_Units.giga, [ "giga", "G" ]), new DictEntry(Data_Units.tera, [ "tera", "T" ]), new DictEntry(Data_Units.peta, [ "P" ]), new DictEntry(Data_Units.exa, [ "exa", "E" ]) ]);
var normalUnitDict = new Dictionary([ new DictEntry(Data_Units_SI_Derived.radian, [ "radians", "radian", "rad" ]), new DictEntry(Data_Units_SI_Accepted.degree, [ "degrees", "degree", "deg", "\xb0" ]), new DictEntry(Data_Units_SI_Derived.hertz, [ "hertz", "Hz" ]), new DictEntry(Data_Units_Misc.rpm, [ "RPM", "rpm" ]), new DictEntry(Data_Units_SI_Derived.newton, [ "newton", "N" ]), new DictEntry(Data_Units_SI_Derived.joule, [ "joules", "joule", "J" ]), new DictEntry(Data_Units_SI_Derived.pascal, [ "pascal", "Pa" ]), new DictEntry(Data_Units_SI_Derived.volt, [ "volts", "volt", "V" ]), new DictEntry(Data_Units_SI_Derived.farad, [ "farad", "F" ]), new DictEntry(Data_Units_SI_Derived.ohm, [ "ohms", "ohm", "\u03a9" ]), new DictEntry(Data_Units_SI_Derived.sievert, [ "sievert", "Sv" ]), new DictEntry(Data_Units_SI_Derived.weber, [ "weber", "Wb" ]), new DictEntry(Data_Units_SI_Derived.tesla, [ "tesla", "T" ]), new DictEntry(Data_Units_SI_Derived.henry, [ "henry", "H" ]), new DictEntry(Data_Units_SI_Derived.coulomb, [ "coulomb", "C" ]), new DictEntry(Data_Units_SI_Derived.siemens, [ "siemens", "S" ]), new DictEntry(Data_Units_SI_Derived.lumen, [ "lumen", "lm" ]), new DictEntry(Data_Units_SI_Derived.lux, [ "lux", "lx" ]), new DictEntry(Data_Units_SI_Derived.becquerel, [ "becquerel", "Bq" ]), new DictEntry(Data_Units_SI_Derived.gray, [ "gray", "Gy" ]), new DictEntry(Data_Units_SI_Derived.katal, [ "katal", "kat" ]), new DictEntry(Data_Units_SI_Accepted.hectare, [ "hectare", "ha" ]), new DictEntry(Data_Units_SI_Accepted.tonne, [ "tonnes", "tonne", "tons", "ton" ]), new DictEntry(Data_Units_SI_Accepted.electronvolt, [ "electronvolt", "eV" ]), new DictEntry(Data_Units_Misc.calorie, [ "calories", "calorie", "cal" ]), new DictEntry(Data_Units_SI_Accepted.bel, [ "bel" ]), new DictEntry(Data_Units_SI_Accepted.astronomicalUnit, [ "AU", "au", "astronomicalunits", "astronomicalunit" ]), new DictEntry(Data_Units_Astronomical.parsec, [ "parsecs", "parsec", "pc" ]), new DictEntry(Data_Units_Astronomical.lightyear, [ "lightyears", "lightyear", "ly" ]), new DictEntry(Data_Units_SI_Accepted.barn, [ "barn" ]), new DictEntry(Data_Units_SI_Accepted.bar, [ "bar" ]), new DictEntry(Data_Units_SI_Accepted.angstrom, [ "angstrom", "\xc5" ]), new DictEntry(Data_Units_CGS.gauss, [ "gauss" ]), new DictEntry(Data_Units_SI.ampere, [ "amperes", "ampere", "amps", "amp", "A" ]), new DictEntry(Data_Units_SI.mole, [ "mole", "mol" ]), new DictEntry(Data_Units_SI.kelvin, [ "kelvin", "K" ]), new DictEntry(Data_Units_SI.candela, [ "candela", "cd" ]), new DictEntry(Data_Semigroup.append(Data_Units.semigroupDerivedUnit)(Data_Units_SI_Derived.watt)(Data_Units_Time.hour), [ "Wh" ]), new DictEntry(Data_Units_SI_Derived.watt, [ "watts", "watt", "W" ]), new DictEntry(Data_Units_Bit["byte"], [ "Bytes", "bytes", "Byte", "byte", "B", "Octets", "octets", "Octet", "octet" ]), new DictEntry(Data_Units_Bit.bit, [ "bits", "bit" ]), new DictEntry(Data_Units.divideUnits(Data_Units_Bit.bit)(Data_Units_SI.second), [ "bps" ]), new DictEntry(Data_Units_SI.second, [ "seconds", "second", "sec", "s" ]), new DictEntry(Data_Units_Time.minute, [ "minutes", "minute", "min" ]), new DictEntry(Data_Units_Time.hour, [ "hours", "hour", "h" ]), new DictEntry(Data_Units_Time.day, [ "days", "day" ]), new DictEntry(Data_Units_Time.week, [ "weeks", "week" ]), new DictEntry(Data_Units_Misc.fortnight, [ "fortnights", "fortnight" ]), new DictEntry(Data_Units_Time.month, [ "months", "month" ]), new DictEntry(Data_Units_Time.year, [ "years", "year" ]), new DictEntry(Data_Units_SI.gram, [ "grammes", "gramme", "grams", "gram", "g" ]), new DictEntry(Data_Units_SI.meter, [ "metres", "metre", "meters", "meter", "m" ]), new DictEntry(Data_Units_SI_Accepted.liter, [ "liters", "liter", "litres", "litre", "L", "l" ]), new DictEntry(Data_Units_Misc.atm, [ "atm" ]), new DictEntry(Data_Units_Misc.pixel, [ "pixels", "pixel", "px" ]), new DictEntry(Data_Units_Misc.frame, [ "frames", "frame" ]), new DictEntry(Data_Units.divideUnits(Data_Units_Misc.frame)(Data_Units_SI.second), [ "fps" ]), new DictEntry(Data_Units_Misc.dot, [ "dots", "dot" ]) ]);
var imperialUnitDict = new Dictionary([ new DictEntry(Data_Units_PartsPerX.percent, [ "pct", "percent" ]), new DictEntry(Data_Units_PartsPerX.partsPerMillion, [ "ppm" ]), new DictEntry(Data_Units_PartsPerX.partsPerBillion, [ "ppb" ]), new DictEntry(Data_Units_PartsPerX.partsPerTrillion, [ "ppt" ]), new DictEntry(Data_Units_PartsPerX.partsPerQuadrillion, [ "ppq" ]), new DictEntry(Data_Units_Imperial.mile, [ "miles", "mile" ]), new DictEntry(Data_Units.divideUnits(Data_Units_Imperial.mile)(Data_Units_Time.hour), [ "mph" ]), new DictEntry(Data_Units_Imperial.inch, [ "inches", "inch", "in" ]), new DictEntry(Data_Units_Imperial.yard, [ "yards", "yard", "yd" ]), new DictEntry(Data_Units_Imperial.foot, [ "feet", "foot", "ft" ]), new DictEntry(Data_Units_Imperial.thou, [ "thou" ]), new DictEntry(Data_Units_Imperial.ounce, [ "ounces", "ounce", "oz" ]), new DictEntry(Data_Units_Misc.lbf, [ "pound_force", "lbf" ]), new DictEntry(Data_Units_Imperial.pound, [ "pounds", "pound", "lb" ]), new DictEntry(Data_Units_USCustomary.gallon, [ "gallons", "gallon", "gal" ]), new DictEntry(Data_Units_USCustomary.pint, [ "pints", "pint" ]), new DictEntry(Data_Units_USCustomary.cup, [ "cups", "cup" ]), new DictEntry(Data_Units_USCustomary.tablespoon, [ "tablespoons", "tablespoon", "tbsp" ]), new DictEntry(Data_Units_USCustomary.teaspoon, [ "teaspoons", "teaspoon", "tsp" ]), new DictEntry(Data_Units_USCustomary.fluidounce, [ "fluidounces", "fluidounce", "floz" ]), new DictEntry(Data_Units_Imperial.furlong, [ "furlong" ]), new DictEntry(Data_Units_Misc.btu, [ "BTU" ]), new DictEntry(Data_Units_Misc.psi, [ "psi" ]), new DictEntry(Data_Units_Misc.mmHg, [ "mmHg" ]), new DictEntry(Data_Units_USCustomary.hogshead, [ "hogsheads", "hogshead" ]), new DictEntry(Data_Units_USCustomary.rod, [ "rods", "rod" ]), new DictEntry(Data_Units.divideUnits(Data_Units_Misc.pixel)(Data_Units_Imperial.inch), [ "ppi" ]), new DictEntry(Data_Units.divideUnits(Data_Units_Misc.dot)(Data_Units_Imperial.inch), [ "dpi" ]), new DictEntry(Data_Units_Misc.piece, [ "pieces", "piece" ]), new DictEntry(Data_Units_Misc.person, [ "persons", "person", "people" ]), new DictEntry(Data_Units_Currency.dollar, [ "dollars", "dollar", "USD", "$" ]), new DictEntry(Data_Units_Currency.euro, [ "euros", "euro", "EUR", "\u20ac" ]), new DictEntry(Data_Units_Nautical.knot, [ "knots", "knot", "kn", "kt" ]), new DictEntry(Data_Units_Nautical.nauticalMile, [ "M", "NM", "nmi" ]) ]);
var identStart = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Token.letter(Data_Identity.monadIdentity))(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("_"));
var identLetter = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Token.letter(Data_Identity.monadIdentity))(Text_Parsing_Parser_Token.digit(Data_Identity.monadIdentity)))(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("_")))(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("'"));
var foldr1 = function (f) {
    return function (v) {
        var v1 = Data_List.last(v.value1);
        var v2 = Data_List.init(v.value1);
        if (v2 instanceof Data_Maybe.Just && v1 instanceof Data_Maybe.Just) {
            return f(v.value0)(Data_Foldable.foldr(Data_List_Types.foldableList)(f)(v1.value0)(v2.value0));
        };
        return v.value0;
    };
};
var commands = [ "help", "?", "list", "ls", "ll", "reset", "clear", "cls", "quit", "exit" ];
var insectLanguage = {
    commentStart: "",
    commentEnd: "",
    commentLine: "#",
    nestedComments: false,
    identStart: identStart,
    identLetter: identLetter,
    opStart: Text_Parsing_Parser_String.oneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)([ "+", "-", "*", "\xb7", "\u22c5", "\xd7", "/", "\xf7", "%", "^", "!", "\u2192", "\u279e", "=" ]),
    opLetter: Text_Parsing_Parser_String.oneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)([  ]),
    reservedNames: Data_Semigroup.append(Data_Semigroup.semigroupArray)(commands)([ "\xb9", "\xb2", "\xb3", "\u2074", "\u2075", "\u207b\xb9", "\u207b\xb2", "\u207b\xb3", "\u207b\u2074", "\u207b\u2075", "to", "per" ]),
    reservedOpNames: [ "->", "+", "-", "*", "\xb7", "\u22c5", "\xd7", "/", "\xf7", "%", "^", "!", "**", "=", "," ],
    caseSensitive: true
};
var token = Text_Parsing_Parser_Token.makeTokenParser(Data_Identity.monadIdentity)(insectLanguage);
var $$function = function (env) {
    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(token.identifier)(function (v) {
        var $45 = v === "sum" || v === "product";
        if ($45) {
            return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v);
        };
        var v1 = Data_Map_Internal.lookup(Data_Ord.ordString)(v)(env.functions);
        if (v1 instanceof Data_Maybe.Just) {
            return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v);
        };
        if (v1 instanceof Data_Maybe.Nothing) {
            return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Unknown function '" + (v + "'"));
        };
        throw new Error("Failed pattern match at Insect.Parser (line 353, column 7 - line 355, column 61): " + [ v1.constructor.name ]);
    });
};
var parens = token.parens;
var reserved = token.reserved;
var reservedOp = token.reservedOp;
var variable = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Variable.create)(token.identifier);
var whiteSpace = token.whiteSpace;
var number = (function () {
    var fromCharArray = function ($91) {
        return Data_String_CodePoints.fromCodePointArray(Data_Functor.map(Data_Functor.functorArray)(Data_String_CodePoints.codePointFromChar)($91));
    };
    var digits = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Array.some(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(Text_Parsing_Parser_Combinators.withErrorMessage(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.oneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)([ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]))("a digit")))(function (v) {
        return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(fromCharArray(Data_Array.fromFoldable(Data_Foldable.foldableArray)(v)));
    });
    var signAndDigits = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.option(Data_Identity.monadIdentity)("+")(Text_Parsing_Parser_String.oneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)([ "+", "-" ])))(function (v) {
        return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digits)(function (v1) {
            return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_String_CodePoints.singleton(Data_String_CodePoints.codePointFromChar(v)) + v1);
        });
    });
    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digits)(function (v) {
        return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Apply.apply(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Semigroup.append(Data_Semigroup.semigroupString))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(".")))(digits)))(function (v1) {
            var fracPart = Data_Maybe.fromMaybe("")(v1);
            return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("e"))(function (v2) {
                return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.notFollowedBy(Data_Identity.monadIdentity)(identStart))(function () {
                    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(signAndDigits)(function (v3) {
                        return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))("e" + v3);
                    });
                });
            }))))(function (v2) {
                var expPart = Data_Maybe.fromMaybe("")(v2);
                return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(whiteSpace)(function () {
                    var floatStr = v + (fracPart + expPart);
                    var v3 = Data_Decimal.fromString(floatStr);
                    if (v3 instanceof Data_Maybe.Just) {
                        var $58 = Data_Decimal["isFinite"](v3.value0);
                        if ($58) {
                            return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v3.value0);
                        };
                        return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("This number is too large");
                    };
                    if (v3 instanceof Data_Maybe.Nothing) {
                        return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Parsing of number failed for input '" + (floatStr + "'"));
                    };
                    throw new Error("Failed pattern match at Insect.Parser (line 114, column 3 - line 121, column 3): " + [ v3.constructor.name ]);
                });
            });
        });
    });
})();
var command = Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reserved("help"))(reserved("?")))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.Help.value)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reserved("list"))(reserved("ls")))(reserved("ll")))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.List.value))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reserved("reset"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.Reset.value))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reserved("clear"))(reserved("cls")))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.Clear.value))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reserved("quit"))(reserved("exit")))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.Quit.value))))(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity));
var buildDictParser = function (v) {
    var abbrevParser = function (x) {
        return function (abbrev) {
            return Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(abbrev))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(x));
        };
    };
    var entryParser = function (v1) {
        return Data_Foldable.oneOf(Data_Foldable.foldableArray)(Text_Parsing_Parser.plusParserT(Data_Identity.monadIdentity))(Data_Functor.map(Data_Functor.functorArray)(abbrevParser(v1.value0))(v1.value1));
    };
    return Data_Foldable.oneOf(Data_Foldable.foldableArray)(Text_Parsing_Parser.plusParserT(Data_Identity.monadIdentity))(Data_Functor.map(Data_Functor.functorArray)(entryParser)(v.value0));
};
var imperialUnit = Text_Parsing_Parser_Combinators.withErrorMessage(Data_Identity.monadIdentity)(buildDictParser(imperialUnitDict))("imperial unit");
var normalUnit = Text_Parsing_Parser_Combinators.withErrorMessage(Data_Identity.monadIdentity)(buildDictParser(normalUnitDict))("normal unit");
var prefix = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(buildDictParser(prefixDict))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Control_Category.identity(Control_Category.categoryFn)));
var unitWithSIPrefix = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(prefix)(function (v) {
    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(normalUnit)(function (v1) {
        return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v(v1));
    });
});
var derivedUnit = (function () {
    var augment = function (p) {
        return Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(p)(Text_Parsing_Parser_Combinators.notFollowedBy(Data_Identity.monadIdentity)(identLetter));
    };
    return Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(augment(unitWithSIPrefix)))(augment(imperialUnit)))(augment(normalUnit)))(augment(specialCases)))(whiteSpace);
})();
var expression = function (env) {
    var subOp = reservedOp("-");
    var powPos = function (s) {
        return function (q) {
            if (s === 1.0) {
                return q;
            };
            if (Data_Boolean.otherwise) {
                return new Insect_Language.BinOp(Insect_Language.Pow.value, q, Insect_Language.Scalar.create(Data_Decimal.fromNumber(s)));
            };
            throw new Error("Failed pattern match at Insect.Parser (line 460, column 5 - line 461, column 65): " + [ s.constructor.name, q.constructor.name ]);
        };
    };
    var powOp = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reservedOp("^"))(reservedOp("**"));
    var powNeg = function (s) {
        return function (q) {
            return new Insect_Language.BinOp(Insect_Language.Pow.value, q, Insect_Language.Negate.create(Insect_Language.Scalar.create(Data_Decimal.fromNumber(s))));
        };
    };
    var perOp = reserved("per");
    var mulOp = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reservedOp("*"))(reservedOp("\xb7")))(reservedOp("\u22c5")))(reservedOp("\xd7"));
    var modOp = reservedOp("%");
    var facOp = reservedOp("!");
    var divOp = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reservedOp("/"))(reservedOp("\xf7"));
    var commaOp = reservedOp(",");
    var arrOp = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(reservedOp("->"))(reservedOp("\u2192")))(reservedOp("\u279e")))(reserved("to"));
    var addOp = reservedOp("+");
    return Control_Lazy.fix(Text_Parsing_Parser.lazyParserT)(function (p) {
        var atomic = Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(whiteSpace)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(parens(p))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Scalar.create)(number)))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Unit.create)(derivedUnit))))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Control_Apply.apply(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Apply.create)($$function(env)))(parens(sepBy1(Data_Identity.monadIdentity)(p)(commaOp))))))(variable));
        var suffixFac = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(atomic)(function (v) {
            return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(facOp)(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.Factorial.create))))(function (v1) {
                if (v1 instanceof Data_Maybe.Just) {
                    return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v1.value0(v));
                };
                if (v1 instanceof Data_Maybe.Nothing) {
                    return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v);
                };
                throw new Error("Failed pattern match at Insect.Parser (line 375, column 9 - line 377, column 27): " + [ v1.constructor.name ]);
            });
        });
        var suffixPow = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(suffixFac)(function (v) {
            return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\xb9"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powPos(1.0))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\xb2"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powPos(2.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\xb3"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powPos(3.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u2074"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powPos(4.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u2075"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powPos(5.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u207b\xb9"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powNeg(1.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u207b\xb2"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powNeg(2.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u207b\xb3"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powNeg(3.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u207b\u2074"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powNeg(4.0)))))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(reservedOp("\u207b\u2075"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(powNeg(5.0))))))(function (v1) {
                if (v1 instanceof Data_Maybe.Just) {
                    return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v1.value0(v));
                };
                if (v1 instanceof Data_Maybe.Nothing) {
                    return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v);
                };
                throw new Error("Failed pattern match at Insect.Parser (line 393, column 9 - line 395, column 27): " + [ v1.constructor.name ]);
            });
        });
        var sepByPow = (function () {
            var list = function (e) {
                return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(suffixPow)(function (v) {
                    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_List.many(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(powOp)(function () {
                        return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(subOp)(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Insect_Language.Negate.create)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(addOp)(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Control_Category.identity(Control_Category.categoryFn)))))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Control_Category.identity(Control_Category.categoryFn))))(function (v1) {
                            return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(e)(function (v2) {
                                return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v1(v2));
                            });
                        });
                    })))(function (v1) {
                        return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Data_NonEmpty.NonEmpty(v, v1));
                    });
                });
            };
            return Control_Lazy.fix(Text_Parsing_Parser.lazyParserT)(function (e) {
                return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(foldr1(Insect_Language.BinOp.create(Insect_Language.Pow.value)))(list(e));
            });
        })();
        var sepByMulImplicit = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Mul.value)))(sepBy1(Data_Identity.monadIdentity)(sepByPow)(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Unit.unit)));
        var prefixed = Control_Lazy.fix(Text_Parsing_Parser.lazyParserT)(function (e) {
            return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(subOp)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Negate.create)(e)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(addOp)(e)))(sepByMulImplicit);
        });
        var sepByMod = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Mod.value)))(sepBy1(Data_Identity.monadIdentity)(prefixed)(modOp));
        var sepByPer = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Div.value)))(sepBy1(Data_Identity.monadIdentity)(sepByMod)(perOp));
        var sepByDiv = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Div.value)))(sepBy1(Data_Identity.monadIdentity)(sepByPer)(divOp));
        var sepByMul = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Mul.value)))(sepBy1(Data_Identity.monadIdentity)(sepByDiv)(mulOp));
        var sepBySub = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Sub.value)))(sepBy1(Data_Identity.monadIdentity)(sepByMul)(subOp));
        var sepByAdd = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.Add.value)))(sepBy1(Data_Identity.monadIdentity)(sepBySub)(addOp));
        var sepByConv = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_NonEmpty.foldl1(Data_List_Types.foldableList)(Insect_Language.BinOp.create(Insect_Language.ConvertTo.value)))(sepBy1(Data_Identity.monadIdentity)(sepByAdd)(arrOp));
        return sepByConv;
    });
};
var fullExpression = function (env) {
    return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(whiteSpace)(function () {
        return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(expression(env))(function (v) {
            return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.withErrorMessage(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))("end of input"))(function () {
                return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v);
            });
        });
    });
};
var assignment = function (env) {
    var failIfUnit = function (n) {
        return Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Either.isRight(Text_Parsing_Parser.runParser(n)(Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(derivedUnit)(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)))))(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("'" + (n + "' is reserved for a physical unit")));
    };
    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(whiteSpace)(function () {
        return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(token.identifier)(function (v) {
            return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(parens(sepBy1(Data_Identity.monadIdentity)(token.identifier)(reservedOp(",")))))(function (v1) {
                return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(reservedOp("="))(function () {
                    return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(expression(env))(function (v2) {
                        return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(function () {
                            return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))({
                                name: v,
                                args: v1,
                                expr: v2
                            });
                        });
                    });
                });
            });
        });
    })))(function (v) {
        return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(failIfUnit(v.name))(function () {
            if (v.args instanceof Data_Maybe.Nothing) {
                return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Insect_Language.VariableAssignment(v.name, v.expr));
            };
            if (v.args instanceof Data_Maybe.Just) {
                return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Foldable.traverse_(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_NonEmpty.foldableNonEmpty(Data_List_Types.foldableList))(failIfUnit)(v.args.value0))(function () {
                    return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Insect_Language.FunctionAssignment(v.name, v.args.value0, v.expr));
                });
            };
            throw new Error("Failed pattern match at Insect.Parser (line 501, column 3 - line 505, column 45): " + [ v.args.constructor.name ]);
        });
    });
};
var statement = function (env) {
    return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Command.create)(command))(assignment(env)))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Insect_Language.Expression.create)(fullExpression(env)));
};
var parseInsect = function (env) {
    return function (inp) {
        return Text_Parsing_Parser.runParser(inp)(statement(env));
    };
};
module.exports = {
    DictEntry: DictEntry,
    Dictionary: Dictionary,
    commands: commands,
    prefixDict: prefixDict,
    normalUnitDict: normalUnitDict,
    imperialUnitDict: imperialUnitDict,
    parseInsect: parseInsect
};
