// Generated by purs version 0.14.5
"use strict";
var Control_Comonad = require("../Control.Comonad/index.js");
var Control_Extend = require("../Control.Extend/index.js");
var Data_Foldable = require("../Data.Foldable/index.js");
var Data_Functor = require("../Data.Functor/index.js");
var Data_Traversable = require("../Data.Traversable/index.js");
var Data_Tuple = require("../Data.Tuple/index.js");
var EnvT = function (x) {
    return x;
};
var withEnvT = function (f) {
    return function (v) {
        return EnvT(new Data_Tuple.Tuple(f(v.value0), v.value1));
    };
};
var runEnvT = function (v) {
    return v;
};
var newtypeEnvT = {
    Coercible0: function () {
        return undefined;
    }
};
var mapEnvT = function (f) {
    return function (v) {
        return EnvT(new Data_Tuple.Tuple(v.value0, f(v.value1)));
    };
};
var functorEnvT = function (dictFunctor) {
    return {
        map: function (f) {
            return function (v) {
                return EnvT(new Data_Tuple.Tuple(v.value0, Data_Functor.map(dictFunctor)(f)(v.value1)));
            };
        }
    };
};
var foldableEnvT = function (dictFoldable) {
    return {
        foldl: function (fn) {
            return function (a) {
                return function (v) {
                    return Data_Foldable.foldl(dictFoldable)(fn)(a)(v.value1);
                };
            };
        },
        foldr: function (fn) {
            return function (a) {
                return function (v) {
                    return Data_Foldable.foldr(dictFoldable)(fn)(a)(v.value1);
                };
            };
        },
        foldMap: function (dictMonoid) {
            return function (fn) {
                return function (v) {
                    return Data_Foldable.foldMap(dictFoldable)(dictMonoid)(fn)(v.value1);
                };
            };
        }
    };
};
var traversableEnvT = function (dictTraversable) {
    return {
        sequence: function (dictApplicative) {
            return function (v) {
                return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Functor.map(Data_Functor.functorFn)(EnvT)(Data_Tuple.Tuple.create(v.value0)))(Data_Traversable.sequence(dictTraversable)(dictApplicative)(v.value1));
            };
        },
        traverse: function (dictApplicative) {
            return function (f) {
                return function (v) {
                    return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Functor.map(Data_Functor.functorFn)(EnvT)(Data_Tuple.Tuple.create(v.value0)))(Data_Traversable.traverse(dictTraversable)(dictApplicative)(f)(v.value1));
                };
            };
        },
        Functor0: function () {
            return functorEnvT(dictTraversable.Functor0());
        },
        Foldable1: function () {
            return foldableEnvT(dictTraversable.Foldable1());
        }
    };
};
var extendEnvT = function (dictExtend) {
    return {
        extend: function (f) {
            return function (v) {
                return EnvT(new Data_Tuple.Tuple(v.value0, Data_Functor.map(dictExtend.Functor0())(f)(Control_Extend.extend(dictExtend)((function () {
                    var $65 = Data_Tuple.Tuple.create(v.value0);
                    return function ($66) {
                        return EnvT($65($66));
                    };
                })())(v.value1))));
            };
        },
        Functor0: function () {
            return functorEnvT(dictExtend.Functor0());
        }
    };
};
var comonadTransEnvT = {
    lower: function (dictComonad) {
        return function (v) {
            return v.value1;
        };
    }
};
var comonadEnvT = function (dictComonad) {
    return {
        extract: function (v) {
            return Control_Comonad.extract(dictComonad)(v.value1);
        },
        Extend0: function () {
            return extendEnvT(dictComonad.Extend0());
        }
    };
};
module.exports = {
    EnvT: EnvT,
    runEnvT: runEnvT,
    withEnvT: withEnvT,
    mapEnvT: mapEnvT,
    newtypeEnvT: newtypeEnvT,
    functorEnvT: functorEnvT,
    extendEnvT: extendEnvT,
    comonadEnvT: comonadEnvT,
    comonadTransEnvT: comonadTransEnvT,
    foldableEnvT: foldableEnvT,
    traversableEnvT: traversableEnvT
};
