Skip to content

Instantly share code, notes, and snippets.

@jrsinclair
Created January 3, 2017 23:51
Show Gist options
  • Select an option

  • Save jrsinclair/23d8c5d05efce3d1eafaf729f7a195d4 to your computer and use it in GitHub Desktop.

Select an option

Save jrsinclair/23d8c5d05efce3d1eafaf729f7a195d4 to your computer and use it in GitHub Desktop.
Lightweight pointfree monad operators. Poor-man's https://github.com/DrBoolean/pointfree-fantasy
/**
* Functions for working with monads.
*
* https://github.com/DrBoolean/pointfree-fantasy is probably a better implementation.
*/
/* eslint prefer-arrow-callback: 0 */
import {curry} from 'lodash/fp';
export const fmap = curry(function fmap(f, m) {
return m.map(f);
});
export const chain = curry(function chain(f, m) {
return m.chain(f);
});
export const join = curry(function join(m) {
return m.join();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment