Skip to content

Instantly share code, notes, and snippets.

@buzzdecafe
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buzzdecafe/98e2c23458d6aad9bc77 to your computer and use it in GitHub Desktop.
Save buzzdecafe/98e2c23458d6aad9bc77 to your computer and use it in GitHub Desktop.
// run in ramda dir
var R = require('./ramda');
var Maybe = require('./ext/types/Maybe');
var ms = [Maybe(1), Maybe(2), Maybe(3)];
R.commute(Maybe.of, ms); //=> Maybe([1, 2, 3]) i.e., Just [1, 2, 3]
// or just use constructor fn:
R.commute(Maybe, ms); //=> Maybe([1, 2, 3])
ms2 = [Maybe(1), Maybe(null), Maybe(3)];
R.commute(Maybe.of, ms2); // Maybe(null) i.e. Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment