crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
18 lines (13 loc) • 479 B
JavaScript
/** @license ISC License (c) copyright 2019 original and current authors */
/** @author Dale Francis (dalefrancis88) */
var curry = require('../core/curry')
var isFunction = require('../core/isFunction')
// PSI (P)
// psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c
function psi(f, g, x, y) {
if(!isFunction(f) || !isFunction(g)) {
throw new TypeError('psi: First and second arguments must be functions')
}
return curry(f)(g(x), g(y))
}
module.exports = curry(psi)