Skip to content

Instantly share code, notes, and snippets.

@evilsoft
Last active February 13, 2017 17:12
Show Gist options
  • Save evilsoft/0f720f43af2000d2c480a712f7db4ebd to your computer and use it in GitHub Desktop.
Save evilsoft/0f720f43af2000d2c480a712f7db4ebd to your computer and use it in GitHub Desktop.
const { Pred, mconcat, isArray, not, isEmpty, safe } = require('crocks')
const pred =
mconcat(Pred, [ not(isEmpty), isArray ])
// maybeArray : a -> Maybe []
const maybeArray =
safe(pred)
console.log(maybeArray([ 1, 2 ])) // Just [ 1, 2 ]
console.log(maybeArray([])) // Nothing
console.log(maybeArray({})) // Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment