// 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_Either = require("../Data.Either/index.js");
var Data_Quantity = require("../Data.Quantity/index.js");
var Data_Units_SI = require("../Data.Units.SI/index.js");
var offsetFahrenheit = 459.67;
var offsetCelsius = 273.15;
var toCelsius = function (tempKelvin$prime) {
    return Control_Bind.bind(Data_Either.bindEither)(Data_Quantity.asValueIn(tempKelvin$prime)(Data_Units_SI.kelvin))(function (v) {
        return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Quantity.scalar(v - offsetCelsius));
    });
};
var multiplierFahrenheit = 5.0 / 9.0;
var toFahrenheit = function (tempKelvin$prime) {
    return Control_Bind.bind(Data_Either.bindEither)(Data_Quantity.asValueIn(tempKelvin$prime)(Data_Units_SI.kelvin))(function (v) {
        return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Quantity.scalar(v / multiplierFahrenheit - offsetFahrenheit));
    });
};
var fromFahrenheit = function (tempFahrenheit$prime) {
    return Control_Bind.bind(Data_Either.bindEither)(Data_Quantity.toScalar(tempFahrenheit$prime))(function (v) {
        return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Quantity.quantity((v + offsetFahrenheit) * multiplierFahrenheit)(Data_Units_SI.kelvin));
    });
};
var fromCelsius = function (tempCelsius$prime) {
    return Control_Bind.bind(Data_Either.bindEither)(Data_Quantity.toScalar(tempCelsius$prime))(function (v) {
        return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Quantity.quantity(v + offsetCelsius)(Data_Units_SI.kelvin));
    });
};
module.exports = {
    fromCelsius: fromCelsius,
    toCelsius: toCelsius,
    fromFahrenheit: fromFahrenheit,
    toFahrenheit: toFahrenheit
};
