JSFiddle - React, Tailwind, and code Playground

by dp0ch

JavaScript

// Maybe?

const Just = (a) => {
	return {
  	bind: (f) => f(a),
    toString: () => `Just(${a})`,
  };
}

const Nothing = {
	bind: (f) => Nothing,
  toString: () => 'Nothing',
};

console.log(Just(1).bind((a) => Just(a + 1)).toString());