// Generated by purs version 0.14.5
"use strict";
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_Comonad = require("../Control.Comonad/index.js");
var Control_Extend = require("../Control.Extend/index.js");
var Control_Semigroupoid = require("../Control.Semigroupoid/index.js");
var Data_Eq = require("../Data.Eq/index.js");
var Data_Functor = require("../Data.Functor/index.js");
var Data_Ord = require("../Data.Ord/index.js");
var Yoneda = function (x) {
    return x;
};
var runYoneda = function (v) {
    return function (k) {
        return v(k);
    };
};
var lowerYoneda = function (v) {
    return v(Control_Category.identity(Control_Category.categoryFn));
};
var liftYoneda = function (dictFunctor) {
    return function (m) {
        return function (k) {
            return Data_Functor.map(dictFunctor)(k)(m);
        };
    };
};
var monadTransYoneda = {
    lift: function (dictMonad) {
        return liftYoneda(((dictMonad.Bind1()).Apply0()).Functor0());
    }
};
var hoistYoneda = function (nat) {
    return function (v) {
        return Data_Functor.map(Data_Functor.functorFn)(nat)(v);
    };
};
var functorYoneda = {
    map: function (f) {
        return function (m) {
            return function (k) {
                return runYoneda(m)(function ($34) {
                    return k(f($34));
                });
            };
        };
    }
};
var extendYoneda = function (dictExtend) {
    return {
        extend: function (f) {
            return function (v) {
                return function (k) {
                    return Control_Extend.extend(dictExtend)((function () {
                        var $35 = liftYoneda(dictExtend.Functor0());
                        return function ($36) {
                            return k(f($35($36)));
                        };
                    })())(v(Control_Category.identity(Control_Category.categoryFn)));
                };
            };
        },
        Functor0: function () {
            return functorYoneda;
        }
    };
};
var eqYoneda = function (dictEq1) {
    return function (dictEq) {
        return {
            eq: function (x) {
                return function (y) {
                    return Data_Eq.eq1(dictEq1)(dictEq)(lowerYoneda(x))(lowerYoneda(y));
                };
            }
        };
    };
};
var ordYoneda = function (dictOrd1) {
    return function (dictOrd) {
        return {
            compare: function (x) {
                return function (y) {
                    return Data_Ord.compare1(dictOrd1)(dictOrd)(lowerYoneda(x))(lowerYoneda(y));
                };
            },
            Eq0: function () {
                return eqYoneda(dictOrd1.Eq10())(dictOrd.Eq0());
            }
        };
    };
};
var eq1Yoneda = function (dictEq1) {
    return {
        eq1: function (dictEq) {
            return Data_Eq.eq(eqYoneda(dictEq1)(dictEq));
        }
    };
};
var ord1Yoneda = function (dictOrd1) {
    return {
        compare1: function (dictOrd) {
            return Data_Ord.compare(ordYoneda(dictOrd1)(dictOrd));
        },
        Eq10: function () {
            return eq1Yoneda(dictOrd1.Eq10());
        }
    };
};
var comonadYoneda = function (dictComonad) {
    return {
        extract: (function () {
            var $37 = Control_Comonad.extract(dictComonad);
            return function ($38) {
                return $37(lowerYoneda($38));
            };
        })(),
        Extend0: function () {
            return extendYoneda(dictComonad.Extend0());
        }
    };
};
var applyYoneda = function (dictApply) {
    return {
        apply: function (v) {
            return function (v1) {
                return function (k) {
                    return Control_Apply.apply(dictApply)(v(Control_Semigroupoid.compose(Control_Semigroupoid.semigroupoidFn)(k)))(v1(Control_Category.identity(Control_Category.categoryFn)));
                };
            };
        },
        Functor0: function () {
            return functorYoneda;
        }
    };
};
var bindYoneda = function (dictBind) {
    return {
        bind: function (v) {
            return function (g) {
                return function (k) {
                    return Control_Bind.bind(dictBind)(v(Control_Category.identity(Control_Category.categoryFn)))(function (a) {
                        return runYoneda(g(a))(k);
                    });
                };
            };
        },
        Apply0: function () {
            return applyYoneda(dictBind.Apply0());
        }
    };
};
var applicativeYoneda = function (dictApplicative) {
    return {
        pure: (function () {
            var $39 = liftYoneda((dictApplicative.Apply0()).Functor0());
            var $40 = Control_Applicative.pure(dictApplicative);
            return function ($41) {
                return $39($40($41));
            };
        })(),
        Apply0: function () {
            return applyYoneda(dictApplicative.Apply0());
        }
    };
};
var monadYoneda = function (dictMonad) {
    return {
        Applicative0: function () {
            return applicativeYoneda(dictMonad.Applicative0());
        },
        Bind1: function () {
            return bindYoneda(dictMonad.Bind1());
        }
    };
};
module.exports = {
    Yoneda: Yoneda,
    runYoneda: runYoneda,
    liftYoneda: liftYoneda,
    lowerYoneda: lowerYoneda,
    hoistYoneda: hoistYoneda,
    eqYoneda: eqYoneda,
    eq1Yoneda: eq1Yoneda,
    ordYoneda: ordYoneda,
    ord1Yoneda: ord1Yoneda,
    functorYoneda: functorYoneda,
    applyYoneda: applyYoneda,
    applicativeYoneda: applicativeYoneda,
    bindYoneda: bindYoneda,
    monadYoneda: monadYoneda,
    monadTransYoneda: monadTransYoneda,
    extendYoneda: extendYoneda,
    comonadYoneda: comonadYoneda
};
