// Generated by purs version 0.12.5
"use strict";
var Data_Decimal = require("../Data.Decimal/index.js");
var Data_Eq = require("../Data.Eq/index.js");
var Data_Generic_Rep = require("../Data.Generic.Rep/index.js");
var Data_Generic_Rep_Show = require("../Data.Generic.Rep.Show/index.js");
var Data_List_Types = require("../Data.List.Types/index.js");
var Data_NonEmpty = require("../Data.NonEmpty/index.js");
var Data_Show = require("../Data.Show/index.js");
var Data_Symbol = require("../Data.Symbol/index.js");
var Data_Units = require("../Data.Units/index.js");
var QConversionError = (function () {
    function QConversionError(value0) {
        this.value0 = value0;
    };
    QConversionError.create = function (value0) {
        return new QConversionError(value0);
    };
    return QConversionError;
})();
var WrongArityError = (function () {
    function WrongArityError(value0, value1, value2) {
        this.value0 = value0;
        this.value1 = value1;
        this.value2 = value2;
    };
    WrongArityError.create = function (value0) {
        return function (value1) {
            return function (value2) {
                return new WrongArityError(value0, value1, value2);
            };
        };
    };
    return WrongArityError;
})();
var LookupError = (function () {
    function LookupError(value0) {
        this.value0 = value0;
    };
    LookupError.create = function (value0) {
        return new LookupError(value0);
    };
    return LookupError;
})();
var NumericalError = (function () {
    function NumericalError() {

    };
    NumericalError.value = new NumericalError();
    return NumericalError;
})();
var RedefinedConstantError = (function () {
    function RedefinedConstantError(value0) {
        this.value0 = value0;
    };
    RedefinedConstantError.create = function (value0) {
        return new RedefinedConstantError(value0);
    };
    return RedefinedConstantError;
})();
var InvalidIdentifier = (function () {
    function InvalidIdentifier(value0) {
        this.value0 = value0;
    };
    InvalidIdentifier.create = function (value0) {
        return new InvalidIdentifier(value0);
    };
    return InvalidIdentifier;
})();
var Help = (function () {
    function Help() {

    };
    Help.value = new Help();
    return Help;
})();
var Reset = (function () {
    function Reset() {

    };
    Reset.value = new Reset();
    return Reset;
})();
var List = (function () {
    function List() {

    };
    List.value = new List();
    return List;
})();
var Clear = (function () {
    function Clear() {

    };
    Clear.value = new Clear();
    return Clear;
})();
var Quit = (function () {
    function Quit() {

    };
    Quit.value = new Quit();
    return Quit;
})();
var Add = (function () {
    function Add() {

    };
    Add.value = new Add();
    return Add;
})();
var Sub = (function () {
    function Sub() {

    };
    Sub.value = new Sub();
    return Sub;
})();
var Mul = (function () {
    function Mul() {

    };
    Mul.value = new Mul();
    return Mul;
})();
var Div = (function () {
    function Div() {

    };
    Div.value = new Div();
    return Div;
})();
var Pow = (function () {
    function Pow() {

    };
    Pow.value = new Pow();
    return Pow;
})();
var Mod = (function () {
    function Mod() {

    };
    Mod.value = new Mod();
    return Mod;
})();
var ConvertTo = (function () {
    function ConvertTo() {

    };
    ConvertTo.value = new ConvertTo();
    return ConvertTo;
})();
var Scalar = (function () {
    function Scalar(value0) {
        this.value0 = value0;
    };
    Scalar.create = function (value0) {
        return new Scalar(value0);
    };
    return Scalar;
})();
var Unit = (function () {
    function Unit(value0) {
        this.value0 = value0;
    };
    Unit.create = function (value0) {
        return new Unit(value0);
    };
    return Unit;
})();
var Variable = (function () {
    function Variable(value0) {
        this.value0 = value0;
    };
    Variable.create = function (value0) {
        return new Variable(value0);
    };
    return Variable;
})();
var Factorial = (function () {
    function Factorial(value0) {
        this.value0 = value0;
    };
    Factorial.create = function (value0) {
        return new Factorial(value0);
    };
    return Factorial;
})();
var Negate = (function () {
    function Negate(value0) {
        this.value0 = value0;
    };
    Negate.create = function (value0) {
        return new Negate(value0);
    };
    return Negate;
})();
var Apply = (function () {
    function Apply(value0, value1) {
        this.value0 = value0;
        this.value1 = value1;
    };
    Apply.create = function (value0) {
        return function (value1) {
            return new Apply(value0, value1);
        };
    };
    return Apply;
})();
var BinOp = (function () {
    function BinOp(value0, value1, value2) {
        this.value0 = value0;
        this.value1 = value1;
        this.value2 = value2;
    };
    BinOp.create = function (value0) {
        return function (value1) {
            return function (value2) {
                return new BinOp(value0, value1, value2);
            };
        };
    };
    return BinOp;
})();
var Expression = (function () {
    function Expression(value0) {
        this.value0 = value0;
    };
    Expression.create = function (value0) {
        return new Expression(value0);
    };
    return Expression;
})();
var VariableAssignment = (function () {
    function VariableAssignment(value0, value1) {
        this.value0 = value0;
        this.value1 = value1;
    };
    VariableAssignment.create = function (value0) {
        return function (value1) {
            return new VariableAssignment(value0, value1);
        };
    };
    return VariableAssignment;
})();
var FunctionAssignment = (function () {
    function FunctionAssignment(value0, value1, value2) {
        this.value0 = value0;
        this.value1 = value1;
        this.value2 = value2;
    };
    FunctionAssignment.create = function (value0) {
        return function (value1) {
            return function (value2) {
                return new FunctionAssignment(value0, value1, value2);
            };
        };
    };
    return FunctionAssignment;
})();
var Command = (function () {
    function Command(value0) {
        this.value0 = value0;
    };
    Command.create = function (value0) {
        return new Command(value0);
    };
    return Command;
})();
var genericCommand = new Data_Generic_Rep.Generic(function (x) {
    if (x instanceof Help) {
        return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
    };
    if (x instanceof Reset) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
    };
    if (x instanceof List) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
    };
    if (x instanceof Clear) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
    };
    if (x instanceof Quit) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
    };
    throw new Error("Failed pattern match at Insect.Language (line 77, column 8 - line 77, column 51): " + [ x.constructor.name ]);
}, function (x) {
    if (x instanceof Data_Generic_Rep.Inl) {
        return Help.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
        return Reset.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
        return List.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
        return Clear.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
        return Quit.value;
    };
    throw new Error("Failed pattern match at Insect.Language (line 77, column 8 - line 77, column 51): " + [ x.constructor.name ]);
});
var showCommand = new Data_Show.Show(Data_Generic_Rep_Show.genericShow(genericCommand)(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Help";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Reset";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "List";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Clear";
})))(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Quit";
}))))))));
var genericBinOp = new Data_Generic_Rep.Generic(function (x) {
    if (x instanceof Add) {
        return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
    };
    if (x instanceof Sub) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
    };
    if (x instanceof Mul) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
    };
    if (x instanceof Div) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
    };
    if (x instanceof Pow) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))));
    };
    if (x instanceof Mod) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))))));
    };
    if (x instanceof ConvertTo) {
        return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))))));
    };
    throw new Error("Failed pattern match at Insect.Language (line 36, column 8 - line 36, column 47): " + [ x.constructor.name ]);
}, function (x) {
    if (x instanceof Data_Generic_Rep.Inl) {
        return Add.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
        return Sub.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
        return Mul.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
        return Div.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))) {
        return Pow.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl))))) {
        return Mod.value;
    };
    if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr))))) {
        return ConvertTo.value;
    };
    throw new Error("Failed pattern match at Insect.Language (line 36, column 8 - line 36, column 47): " + [ x.constructor.name ]);
});
var showBinOp = new Data_Show.Show(Data_Generic_Rep_Show.genericShow(genericBinOp)(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Add";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Sub";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Mul";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Div";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Pow";
})))(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "Mod";
})))(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
    return "ConvertTo";
}))))))))));
var showExpression = new Data_Show.Show(function (v) {
    if (v instanceof Scalar) {
        return "(Scalar " + (Data_Show.show(Data_Decimal.showDecimal)(v.value0) + ")");
    };
    if (v instanceof Unit) {
        return "(Unit " + (Data_Show.show(Data_Units.showDerivedUnit)(v.value0) + ")");
    };
    if (v instanceof Variable) {
        return "(Variable " + (Data_Show.show(Data_Show.showString)(v.value0) + ")");
    };
    if (v instanceof Factorial) {
        return "(Factorial " + (Data_Show.show(showExpression)(v.value0) + ")");
    };
    if (v instanceof Negate) {
        return "(Negate " + (Data_Show.show(showExpression)(v.value0) + ")");
    };
    if (v instanceof Apply) {
        return "(Apply " + (Data_Show.show(Data_Show.showString)(v.value0) + (" " + (Data_Show.show(Data_NonEmpty.showNonEmpty(showExpression)(Data_List_Types.showList(showExpression)))(v.value1) + ")")));
    };
    if (v instanceof BinOp) {
        return "(BinOp " + (Data_Show.show(showBinOp)(v.value0) + (" " + (Data_Show.show(showExpression)(v.value1) + (" " + (Data_Show.show(showExpression)(v.value2) + ")")))));
    };
    throw new Error("Failed pattern match at Insect.Language (line 59, column 1 - line 59, column 42): " + [ v.constructor.name ]);
});
var showStatement = new Data_Show.Show(function (v) {
    if (v instanceof Expression) {
        return "(Expression " + (Data_Show.show(showExpression)(v.value0) + ")");
    };
    if (v instanceof VariableAssignment) {
        return "(VariableAssignment " + (Data_Show.show(Data_Show.showString)(v.value0) + (" " + (Data_Show.show(showExpression)(v.value1) + ")")));
    };
    if (v instanceof FunctionAssignment) {
        return "(FunctionAssignment " + (Data_Show.show(Data_Show.showString)(v.value0) + (" " + (Data_Show.show(Data_NonEmpty.showNonEmpty(Data_Show.showString)(Data_List_Types.showList(Data_Show.showString)))(v.value1) + (" " + (Data_Show.show(showExpression)(v.value2) + ")")))));
    };
    if (v instanceof Command) {
        return "(Command " + (Data_Show.show(showCommand)(v.value0) + ")");
    };
    throw new Error("Failed pattern match at Insect.Language (line 88, column 1 - line 88, column 40): " + [ v.constructor.name ]);
});
var eqCommand = new Data_Eq.Eq(function (x) {
    return function (y) {
        if (x instanceof Help && y instanceof Help) {
            return true;
        };
        if (x instanceof Reset && y instanceof Reset) {
            return true;
        };
        if (x instanceof List && y instanceof List) {
            return true;
        };
        if (x instanceof Clear && y instanceof Clear) {
            return true;
        };
        if (x instanceof Quit && y instanceof Quit) {
            return true;
        };
        return false;
    };
});
var eqBinOp = new Data_Eq.Eq(function (x) {
    return function (y) {
        if (x instanceof Add && y instanceof Add) {
            return true;
        };
        if (x instanceof Sub && y instanceof Sub) {
            return true;
        };
        if (x instanceof Mul && y instanceof Mul) {
            return true;
        };
        if (x instanceof Div && y instanceof Div) {
            return true;
        };
        if (x instanceof Pow && y instanceof Pow) {
            return true;
        };
        if (x instanceof Mod && y instanceof Mod) {
            return true;
        };
        if (x instanceof ConvertTo && y instanceof ConvertTo) {
            return true;
        };
        return false;
    };
});
var eqExpression = new Data_Eq.Eq(function (x) {
    return function (y) {
        if (x instanceof Scalar && y instanceof Scalar) {
            return Data_Eq.eq(Data_Decimal.eqDecimal)(x.value0)(y.value0);
        };
        if (x instanceof Unit && y instanceof Unit) {
            return Data_Eq.eq(Data_Units.eqDerivedUnit)(x.value0)(y.value0);
        };
        if (x instanceof Variable && y instanceof Variable) {
            return x.value0 === y.value0;
        };
        if (x instanceof Factorial && y instanceof Factorial) {
            return Data_Eq.eq(eqExpression)(x.value0)(y.value0);
        };
        if (x instanceof Negate && y instanceof Negate) {
            return Data_Eq.eq(eqExpression)(x.value0)(y.value0);
        };
        if (x instanceof Apply && y instanceof Apply) {
            return x.value0 === y.value0 && Data_Eq.eq(Data_NonEmpty.eqNonEmpty(Data_List_Types.eq1List)(eqExpression))(x.value1)(y.value1);
        };
        if (x instanceof BinOp && y instanceof BinOp) {
            return Data_Eq.eq(eqBinOp)(x.value0)(y.value0) && Data_Eq.eq(eqExpression)(x.value1)(y.value1) && Data_Eq.eq(eqExpression)(x.value2)(y.value2);
        };
        return false;
    };
});
var eqStatement = new Data_Eq.Eq(function (x) {
    return function (y) {
        if (x instanceof Expression && y instanceof Expression) {
            return Data_Eq.eq(eqExpression)(x.value0)(y.value0);
        };
        if (x instanceof VariableAssignment && y instanceof VariableAssignment) {
            return x.value0 === y.value0 && Data_Eq.eq(eqExpression)(x.value1)(y.value1);
        };
        if (x instanceof FunctionAssignment && y instanceof FunctionAssignment) {
            return x.value0 === y.value0 && Data_Eq.eq(Data_NonEmpty.eqNonEmpty(Data_List_Types.eq1List)(Data_Eq.eqString))(x.value1)(y.value1) && Data_Eq.eq(eqExpression)(x.value2)(y.value2);
        };
        if (x instanceof Command && y instanceof Command) {
            return Data_Eq.eq(eqCommand)(x.value0)(y.value0);
        };
        return false;
    };
});
module.exports = {
    QConversionError: QConversionError,
    WrongArityError: WrongArityError,
    LookupError: LookupError,
    NumericalError: NumericalError,
    RedefinedConstantError: RedefinedConstantError,
    InvalidIdentifier: InvalidIdentifier,
    Add: Add,
    Sub: Sub,
    Mul: Mul,
    Div: Div,
    Pow: Pow,
    Mod: Mod,
    ConvertTo: ConvertTo,
    Scalar: Scalar,
    Unit: Unit,
    Variable: Variable,
    Factorial: Factorial,
    Negate: Negate,
    Apply: Apply,
    BinOp: BinOp,
    Help: Help,
    Reset: Reset,
    List: List,
    Clear: Clear,
    Quit: Quit,
    Expression: Expression,
    VariableAssignment: VariableAssignment,
    FunctionAssignment: FunctionAssignment,
    Command: Command,
    eqBinOp: eqBinOp,
    genericBinOp: genericBinOp,
    showBinOp: showBinOp,
    eqExpression: eqExpression,
    showExpression: showExpression,
    eqCommand: eqCommand,
    genericCommand: genericCommand,
    showCommand: showCommand,
    eqStatement: eqStatement,
    showStatement: showStatement
};
