UNPKG

@markandrus/effect-derive

Version:

Derive Covariant (Functor), Foldable, and Traversable instances, as well as base functors, for algebraic data types (ADTs)

11 lines (10 loc) 305 B
export const mapComposition = (F) => { return function map(self, f) { switch (self.type) { case 'Pure': return { type: 'Pure', a: f(self.a) }; case 'Free': return { type: 'Free', fa: F.map(self.fa, _ => map(_, f)) }; } }; };