UNPKG

bs-platform

Version:

bucklescript compiler, ocaml standard libary by bucklescript and its required runtime support

113 lines (94 loc) 2.15 kB
'use strict'; var Curry = require("./curry.js"); var Caml_option = require("./caml_option.js"); function getExn(param) { if (param !== undefined) { return Caml_option.valFromOption(param); } else { throw new Error("getExn"); } } function mapWithDefaultU(opt, $$default, f) { if (opt !== undefined) { return f(Caml_option.valFromOption(opt)); } else { return $$default; } } function mapWithDefault(opt, $$default, f) { return mapWithDefaultU(opt, $$default, Curry.__1(f)); } function mapU(opt, f) { if (opt !== undefined) { return Caml_option.some(f(Caml_option.valFromOption(opt))); } } function map(opt, f) { return mapU(opt, Curry.__1(f)); } function flatMapU(opt, f) { if (opt !== undefined) { return f(Caml_option.valFromOption(opt)); } } function flatMap(opt, f) { return flatMapU(opt, Curry.__1(f)); } function getWithDefault(opt, $$default) { if (opt !== undefined) { return Caml_option.valFromOption(opt); } else { return $$default; } } function isSome(param) { return param !== undefined; } function isNone(x) { return x === undefined; } function eqU(a, b, f) { if (a !== undefined) { if (b !== undefined) { return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return false; } } else { return b === undefined; } } function eq(a, b, f) { return eqU(a, b, Curry.__2(f)); } function cmpU(a, b, f) { if (a !== undefined) { if (b !== undefined) { return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return 1; } } else if (b !== undefined) { return -1; } else { return 0; } } function cmp(a, b, f) { return cmpU(a, b, Curry.__2(f)); } exports.getExn = getExn; exports.mapWithDefaultU = mapWithDefaultU; exports.mapWithDefault = mapWithDefault; exports.mapU = mapU; exports.map = map; exports.flatMapU = flatMapU; exports.flatMap = flatMap; exports.getWithDefault = getWithDefault; exports.isSome = isSome; exports.isNone = isNone; exports.eqU = eqU; exports.eq = eq; exports.cmpU = cmpU; exports.cmp = cmp; /* No side effect */