UNPKG

crocks

Version:

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

34 lines (27 loc) 865 B
/** @license ISC License (c) copyright 2016 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ var curry = require('../core/curry') var isFoldable = require('../core/isFoldable') var isFunction = require('../core/isFunction') var isMonoid = require('../core/isMonoid') var mconcatMap = require('../core/mconcatMap') // mreduceMap :: Monoid M => M -> (b -> a) -> ( [ b ] | List b ) -> a function mreduceMap(m, f, xs) { if(!isMonoid(m)) { throw new TypeError( 'mreduceMap: Monoid required for first argument' ) } if(!isFunction(f)) { throw new TypeError( 'mreduceMap: Function required for second argument' ) } if(!isFoldable(xs)) { throw new TypeError( 'mreduceMap: Foldable required for third argument' ) } return mconcatMap(m, f, xs).valueOf() } module.exports = curry(mreduceMap)