// Generated by purs version 0.12.5
"use strict";
var Control_Applicative = require("../Control.Applicative/index.js");
var Control_Bind = require("../Control.Bind/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_List_NonEmpty = require("../Data.List.NonEmpty/index.js");
var Data_List_Types = require("../Data.List.Types/index.js");
var Data_Quantity = require("../Data.Quantity/index.js");
var Data_Semiring = require("../Data.Semiring/index.js");
var tau = Data_Quantity["scalar'"](Data_Semiring.mul(Data_Decimal.semiringDecimal)(Data_Decimal.fromNumber(2.0))(Data_Decimal.pi));
var pi = Data_Quantity["scalar'"](Data_Decimal.pi);
var mean = function (xs) {
    var n = Data_Quantity["scalar'"](Data_Decimal.fromInt(Data_List_NonEmpty.length(xs)));
    return Data_Functor.map(Data_Either.functorEither)(function (v) {
        return Data_Quantity.qDivide(v)(n);
    })(Data_Foldable.foldM(Data_List_Types.foldableList)(Data_Either.monadEither)(Data_Quantity.qAdd)(Data_List_NonEmpty.head(xs))(Data_List_NonEmpty.tail(xs)));
};
var lift2 = function (f) {
    return function (q1) {
        return function (q2) {
            var u = Data_Quantity.derivedUnit(q1);
            return Control_Bind.bind(Data_Either.bindEither)(Data_Quantity["asValueIn'"](q1)(u))(function (v) {
                return Control_Bind.bind(Data_Either.bindEither)(Data_Quantity["asValueIn'"](q2)(u))(function (v2) {
                    return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Quantity["quantity'"](f(v)(v2))(u));
                });
            });
        };
    };
};
var max2 = lift2(Data_Decimal.max);
var max = function (xs) {
    return Data_Foldable.foldM(Data_List_Types.foldableList)(Data_Either.monadEither)(max2)(Data_List_NonEmpty.head(xs))(Data_List_NonEmpty.tail(xs));
};
var min2 = lift2(Data_Decimal.min);
var min = function (xs) {
    return Data_Foldable.foldM(Data_List_Types.foldableList)(Data_Either.monadEither)(min2)(Data_List_NonEmpty.head(xs))(Data_List_NonEmpty.tail(xs));
};
var modulo = lift2(Data_Decimal.modulo);
var lift = function (fn) {
    return function (q) {
        return Data_Functor.map(Data_Either.functorEither)(function ($5) {
            return Data_Quantity["scalar'"](fn($5));
        })(Data_Quantity["toScalar'"](q));
    };
};
var ln = lift(Data_Decimal.ln);
var log10 = lift(Data_Decimal.log10);
var round = lift(Data_Decimal.round);
var sin = lift(Data_Decimal.sin);
var sinh = lift(Data_Decimal.sinh);
var tan = lift(Data_Decimal.tan);
var tanh = lift(Data_Decimal.tanh);
var gamma = lift(Data_Decimal.gamma);
var floor = lift(Data_Decimal.floor);
var factorial = lift(Data_Decimal.factorial);
var exp = lift(Data_Decimal.exp);
var e = Data_Quantity["scalar'"](Data_Decimal.e);
var cosh = lift(Data_Decimal.cosh);
var cos = lift(Data_Decimal.cos);
var ceil = lift(Data_Decimal.ceil);
var atanh = lift(Data_Decimal.atanh);
var atan2 = function (x) {
    return function (y) {
        var removeDims = function (q) {
            return Data_Quantity.qDivide(q)(Data_Quantity.quantity(1.0)(Data_Quantity.derivedUnit(q)));
        };
        return Data_Functor.map(Data_Either.functorEither)(removeDims)(lift2(Data_Decimal.atan2)(x)(y));
    };
};
var atan = lift(Data_Decimal.atan);
var asinh = lift(Data_Decimal.asinh);
var asin = lift(Data_Decimal.asin);
var acosh = lift(Data_Decimal.acosh);
var acos = lift(Data_Decimal.acos);
module.exports = {
    acos: acos,
    asin: asin,
    atan: atan,
    atan2: atan2,
    cos: cos,
    exp: exp,
    ln: ln,
    sin: sin,
    tan: tan,
    sinh: sinh,
    cosh: cosh,
    tanh: tanh,
    asinh: asinh,
    acosh: acosh,
    atanh: atanh,
    ceil: ceil,
    floor: floor,
    log10: log10,
    max2: max2,
    max: max,
    min2: min2,
    min: min,
    mean: mean,
    modulo: modulo,
    round: round,
    gamma: gamma,
    factorial: factorial,
    pi: pi,
    e: e,
    tau: tau
};
