Skip to content

Instantly share code, notes, and snippets.

@evilsoft
Created May 21, 2017 02:55
Show Gist options
  • Save evilsoft/1e963e8f9b143ce209c01e6a252a7472 to your computer and use it in GitHub Desktop.
Save evilsoft/1e963e8f9b143ce209c01e6a252a7472 to your computer and use it in GitHub Desktop.
const {
curry, isNumber, pipeS, prop, safeLift, Star
} = require('../crocks')
const add = curry(
(x, y) => x + y
)
const pull =
x => Star(prop(x))
const safeAdd =
x => Star(safeLift(isNumber, add(x)))
const data = {
num: 56,
string: '56'
}
const flow = (key, num) => pipeS(
pull(key),
safeAdd(num)
)
flow('num', 10).runWith(data)
// => Just 66
flow('string', 100).runWith(data)
// => Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment