// Generated by purs version 0.14.5
"use strict";
var Control_Category = require("../Control.Category/index.js");
var Data_Divide = require("../Data.Divide/index.js");
var Data_Either = require("../Data.Either/index.js");
var Data_Ordering = require("../Data.Ordering/index.js");
var choosePredicate = {
    choose: function (f) {
        return function (v) {
            return function (v1) {
                var $53 = Data_Either.either(v)(v1);
                return function ($54) {
                    return $53(f($54));
                };
            };
        };
    },
    Divide0: function () {
        return Data_Divide.dividePredicate;
    }
};
var chooseOp = function (dictSemigroup) {
    return {
        choose: function (f) {
            return function (v) {
                return function (v1) {
                    var $55 = Data_Either.either(v)(v1);
                    return function ($56) {
                        return $55(f($56));
                    };
                };
            };
        },
        Divide0: function () {
            return Data_Divide.divideOp(dictSemigroup);
        }
    };
};
var chooseEquivalence = {
    choose: function (f) {
        return function (v) {
            return function (v1) {
                return function (a) {
                    return function (b) {
                        var v2 = f(a);
                        if (v2 instanceof Data_Either.Left) {
                            var v3 = f(b);
                            if (v3 instanceof Data_Either.Left) {
                                return v(v2.value0)(v3.value0);
                            };
                            if (v3 instanceof Data_Either.Right) {
                                return false;
                            };
                            throw new Error("Failed pattern match at Data.Decide (line 27, column 15 - line 29, column 23): " + [ v3.constructor.name ]);
                        };
                        if (v2 instanceof Data_Either.Right) {
                            var v3 = f(b);
                            if (v3 instanceof Data_Either.Left) {
                                return false;
                            };
                            if (v3 instanceof Data_Either.Right) {
                                return v1(v2.value0)(v3.value0);
                            };
                            throw new Error("Failed pattern match at Data.Decide (line 30, column 16 - line 32, column 23): " + [ v3.constructor.name ]);
                        };
                        throw new Error("Failed pattern match at Data.Decide (line 26, column 66 - line 32, column 23): " + [ v2.constructor.name ]);
                    };
                };
            };
        };
    },
    Divide0: function () {
        return Data_Divide.divideEquivalence;
    }
};
var chooseComparison = {
    choose: function (f) {
        return function (v) {
            return function (v1) {
                return function (a) {
                    return function (b) {
                        var v2 = f(a);
                        if (v2 instanceof Data_Either.Left) {
                            var v3 = f(b);
                            if (v3 instanceof Data_Either.Left) {
                                return v(v2.value0)(v3.value0);
                            };
                            if (v3 instanceof Data_Either.Right) {
                                return Data_Ordering.LT.value;
                            };
                            throw new Error("Failed pattern match at Data.Decide (line 18, column 15 - line 20, column 20): " + [ v3.constructor.name ]);
                        };
                        if (v2 instanceof Data_Either.Right) {
                            var v3 = f(b);
                            if (v3 instanceof Data_Either.Left) {
                                return Data_Ordering.GT.value;
                            };
                            if (v3 instanceof Data_Either.Right) {
                                return v1(v2.value0)(v3.value0);
                            };
                            throw new Error("Failed pattern match at Data.Decide (line 21, column 16 - line 23, column 23): " + [ v3.constructor.name ]);
                        };
                        throw new Error("Failed pattern match at Data.Decide (line 17, column 63 - line 23, column 23): " + [ v2.constructor.name ]);
                    };
                };
            };
        };
    },
    Divide0: function () {
        return Data_Divide.divideComparison;
    }
};
var choose = function (dict) {
    return dict.choose;
};
var chosen = function (dictDecide) {
    return choose(dictDecide)(Control_Category.identity(Control_Category.categoryFn));
};
module.exports = {
    choose: choose,
    chosen: chosen,
    chooseComparison: chooseComparison,
    chooseEquivalence: chooseEquivalence,
    choosePredicate: choosePredicate,
    chooseOp: chooseOp
};
