UNPKG

crocks

Version:

A collection of well known Algebraic Datatypes for your utter enjoyment.

20 lines (15 loc) 618 B
/** @license ISC License (c) copyright 2018 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ var curry = require('../core/curry') var isPredOrFunc = require('../core/isPredOrFunc') var predOrFunc = require('../core/predOrFunc') // implies :: (a -> Boolean) | Pred -> (a -> Boolean) -> a -> Boolean function implies(p, q) { if(!(isPredOrFunc(p) && isPredOrFunc(q))) { throw new TypeError( 'implies: Preds or predicate functions required for first two arguments' ) } return function (x) { return !predOrFunc(p, x) || !!predOrFunc(q, x); } } module.exports = curry(implies)