n-ary-functor

A single typeclass for Functor, Bifunctor, Profunctor, etc.


Keywords
library, public-domain, Propose Tags , NAryFunctor, Functor, Bifunctor, Contravariant, Profunctor, convention, this blog post
License
Other
Install
cabal install n-ary-functor-0.1.0.0

Documentation

N-ary Functors

Build Status

Functor and Bifunctor are both in base, but what about Trifunctor? Quadrifunctor? There must be a better solution than creating an infinite tower of typeclasses. Here's the API I managed to implement:

> nmap <#> (+1) <#> (+2) $ (0, 0)
(1,2)

> nmap <#> (+1) <#> (+2) <#> (+3) $ (0, 0, 0)
(1,2,3)

> nmap <#> (+1) <#> (+2) <#> (+3) <#> (+4) $ (0, 0, 0, 0)
(1,2,3,4)

For more details, see the documentation and the blog post.