crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
12 lines (8 loc) • 379 B
JavaScript
/** @license ISC License (c) copyright 2018 original and current authors */
/** @author Ian Hofmann-Hicks (evil) */
var isApplicative = require('./isApplicative')
var isTypeRepOf = require('./isTypeRepOf')
var apOrFunc = function (af) { return function (x) { return isApplicative(af)
? af.of(x)
: isTypeRepOf(Array, af) ? [ x ] : af(x); }; }
module.exports = apOrFunc