Last active
February 13, 2017 17:12
-
-
Save evilsoft/0f720f43af2000d2c480a712f7db4ebd to your computer and use it in GitHub Desktop.
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 { 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