UNPKG

@rescript/std

Version:

The motiviation of this repo is that when ReScript users want to share their library with JS users, the JS users don't need have ReScript toolchain installed, this makes sharing code with JS users easier (more details on that topic can be found in our [Ex

137 lines (119 loc) 2.02 kB
import * as Curry from "./curry.js"; function getExn(x) { if (x.TAG === "Ok") { return x._0; } throw { RE_EXN_ID: "Not_found", Error: new Error() }; } function mapWithDefaultU(opt, $$default, f) { if (opt.TAG === "Ok") { return f(opt._0); } else { return $$default; } } function mapWithDefault(opt, $$default, f) { return mapWithDefaultU(opt, $$default, Curry.__1(f)); } function mapU(opt, f) { if (opt.TAG === "Ok") { return { TAG: "Ok", _0: f(opt._0) }; } else { return { TAG: "Error", _0: opt._0 }; } } function map(opt, f) { return mapU(opt, Curry.__1(f)); } function flatMapU(opt, f) { if (opt.TAG === "Ok") { return f(opt._0); } else { return { TAG: "Error", _0: opt._0 }; } } function flatMap(opt, f) { return flatMapU(opt, Curry.__1(f)); } function getWithDefault(opt, $$default) { if (opt.TAG === "Ok") { return opt._0; } else { return $$default; } } function isOk(x) { if (x.TAG === "Ok") { return true; } else { return false; } } function isError(x) { if (x.TAG === "Ok") { return false; } else { return true; } } function eqU(a, b, f) { if (a.TAG === "Ok") { if (b.TAG === "Ok") { return f(a._0, b._0); } else { return false; } } else if (b.TAG === "Ok") { return false; } else { return true; } } function eq(a, b, f) { return eqU(a, b, Curry.__2(f)); } function cmpU(a, b, f) { if (a.TAG === "Ok") { if (b.TAG === "Ok") { return f(a._0, b._0); } else { return 1; } } else if (b.TAG === "Ok") { return -1; } else { return 0; } } function cmp(a, b, f) { return cmpU(a, b, Curry.__2(f)); } export { getExn , mapWithDefaultU , mapWithDefault , mapU , map , flatMapU , flatMap , getWithDefault , isOk , isError , eqU , eq , cmpU , cmp , } /* No side effect */