UNPKG

bucklescript-tea

Version:
134 lines (121 loc) 2.61 kB
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE 'use strict'; var Block = require("bs-platform/lib/js/block.js"); var Caml_option = require("bs-platform/lib/js/caml_option.js"); var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); function result_to_option(param) { if (param.tag) { return ; } else { return Caml_option.some(param[0]); } } function option_of_result(param) { if (param.tag) { return ; } else { return Caml_option.some(param[0]); } } function ok(param) { if (param.tag) { return ; } else { return Caml_option.some(param[0]); } } function error(param) { if (param.tag) { return Caml_option.some(param[0]); } } function last_of(_param) { while(true) { var param = _param; if (param) { var tl = param[1]; var last = param[0]; if (tl && !last.tag) { _param = tl; continue ; } else { return last; } } else { throw [ Caml_builtin_exceptions.failure, "`Tea.Result.do` must never be passed the empty list" ]; } }; } function accumulate(param) { if (param) { var tl = param[1]; var last = param[0]; if (tl) { if (last.tag) { return last; } else { var e = accumulate(tl); if (e.tag) { return e; } else { return /* Ok */Block.__(0, [/* :: */[ last[0], e[0] ]]); } } } else if (last.tag) { return last; } else { return /* Ok */Block.__(0, [/* :: */[ last[0], /* [] */0 ]]); } } else { return /* Ok */Block.__(0, [/* [] */0]); } } function first(fst, e) { if (e.tag) { return e; } else { return fst; } } function error_of_any(_param) { while(true) { var param = _param; if (param) { var hd = param[0]; if (hd.tag) { return Caml_option.some(hd[0]); } else { _param = param[1]; continue ; } } else { return ; } }; } function error_of_first(fst, param) { if (param.tag) { return Caml_option.some(param[0]); } else { return error(fst); } } exports.result_to_option = result_to_option; exports.option_of_result = option_of_result; exports.ok = ok; exports.error = error; exports.last_of = last_of; exports.accumulate = accumulate; exports.first = first; exports.error_of_any = error_of_any; exports.error_of_first = error_of_first; /* No side effect */