contravariant
v0.2.0
Published
Contravariant functors in JS with Flow.
Downloads
5
Maintainers
Readme
contravariant
Contravariant functors in JavaScript with Flow.
Mainly inspired by haskell contravariant.
See src/index.js and test/index.test.js.
Installation
$ npm install contravariant
API
interface IContravariant<-A>
contramap<B>(fn: B => A): IContravariant<B>
class Predicate<-A>
constructor(f: A => boolean)
getPredicate(): A => boolean
contramap<B>(fn: B => A): Predicate<B>
class Comparison<-A>
constructor(f: (A, A) => number)
getComparison(): (A, A) => number
contramap<B>(fn: B => A): Comparison<B>
function defaultComparison(): Comparison<number>
class Equivalence<-A>
constructor(f: (A, A) => boolean)
getEquivalence(): (A, A) => boolean
contramap<B>(fn: B => A): Equivalence<B>
function defaultEquivalence<A>(): Equivalence<A>
class Op<+A, -B>
constructor(f: B => A)
getOp(): B => A
contramap<BB>(fn: BB => B): Op<A, BB>
Profunctors
interface IProfunctor<-B, +C>
promap<A, D>(fn1: A => B, fn2: C => D): IProfunctor<A, D>
class Arrow<-B, +C>
constructor(f: B => C)
getArrow(): B => C
promap<A, D>(fn1: A => B, fn2: C => D): Arrow<A, D>
lmap<A>(fn1: A => B): Arrow<A, C>
rmap<D>(fn2: C => D): Arrow<B, D>
See also
- https://hackage.haskell.org/package/contravariant-1.5/docs/Data-Functor-Contravariant.html
- https://github.com/fantasyland/fantasy-land#contravariant
- https://gist.github.com/Bannerets/07a71802e3468d252924091a65ac2b3c
- https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/profunctors
- https://hackage.haskell.org/package/profunctors-5.3/docs/Data-Profunctor.html
- https://github.com/fantasyland/fantasy-land#profunctor