crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
15 lines (10 loc) • 427 B
JavaScript
/** @license ISC License (c) copyright 2016 original and current authors */
/** @author Ian Hofmann-Hicks (evil) */
var compose = require('./compose')
var foldWith =
function (m) { return function (x, y) { return x.concat(m(y)); }; }
// mconcatMap :: Monoid M => M -> (b -> a) -> ([ b ] | List b) -> M a
function mconcatMap(M, f, xs) {
return xs.reduce(foldWith(compose(M, f)), M.empty())
}
module.exports = mconcatMap