UNPKG

crocks

Version:

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

21 lines (16 loc) 538 B
/** @license ISC License (c) copyright 2017 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ var curry = require('../core/curry') var fl = require('../core/flNames') var isAlt = require('../core/isAlt') var isSameType = require('../core/isSameType') // alt : Alt m => m a -> m a -> m a function alt(m, x) { if(!(isAlt(m) && isSameType(m, x))) { throw new TypeError( 'alt: Both arguments must be Alts of the same type' ) } return (x[fl.alt] || x.alt).call(x, m) } module.exports = curry(alt)