// Generated by purs version 0.14.5
"use strict";
var Data_List_Types = require("../Data.List.Types/index.js");
var tail = function (dictPartial) {
    return function (v) {
        if (v instanceof Data_List_Types.Cons) {
            return v.value1;
        };
        throw new Error("Failed pattern match at Data.List.Partial (line 15, column 1 - line 15, column 46): " + [ v.constructor.name ]);
    };
};
var last = function ($copy_dictPartial) {
    return function ($copy_v) {
        var $tco_var_dictPartial = $copy_dictPartial;
        var $tco_done = false;
        var $tco_result;
        function $tco_loop(dictPartial, v) {
            if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) {
                $tco_done = true;
                return v.value0;
            };
            if (v instanceof Data_List_Types.Cons) {
                $tco_var_dictPartial = undefined;
                $copy_v = v.value1;
                return;
            };
            throw new Error("Failed pattern match at Data.List.Partial (line 21, column 1 - line 21, column 41): " + [ v.constructor.name ]);
        };
        while (!$tco_done) {
            $tco_result = $tco_loop($tco_var_dictPartial, $copy_v);
        };
        return $tco_result;
    };
};
var init = function (dictPartial) {
    return function (v) {
        if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) {
            return Data_List_Types.Nil.value;
        };
        if (v instanceof Data_List_Types.Cons) {
            return new Data_List_Types.Cons(v.value0, init()(v.value1));
        };
        throw new Error("Failed pattern match at Data.List.Partial (line 28, column 1 - line 28, column 46): " + [ v.constructor.name ]);
    };
};
var head = function (dictPartial) {
    return function (v) {
        if (v instanceof Data_List_Types.Cons) {
            return v.value0;
        };
        throw new Error("Failed pattern match at Data.List.Partial (line 9, column 1 - line 9, column 41): " + [ v.constructor.name ]);
    };
};
module.exports = {
    head: head,
    tail: tail,
    last: last,
    init: init
};
