This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _nudef = x => typeof x == 'undefined' || x == null || x == undefined; | |
const coalesce = (...vals) => vals.find((v,i)=>_nudef(v) == false || i==vals.length); | |
const u_pipe = (...fns) => (x) => fns.reduce((prev, func) => func(prev), x); | |
const None = Object.freeze({monad_name: "None", is: function is_none(x) {return x==this;}}); | |
const build_monad = monad_name => { | |
var mon = (monad_name => { | |
return val => { | |
// Unpack if a packed monad | |
if(typeof val == "function" && val.monad_name == monad_name){ | |
return val(); |