Unify/throw away lmap and rmap
See original GitHub issueI will start quoting what many bloggers states about Profunctors:
A Profunctor is just a bifunctor that is contravariant in the first argument and covariant in the second.
So, if I have a type that is both a Contravariant and a Functor (covariant) at the same time, that type is a Profunctor where rmap
is map
and lmap
is contramap
.
If so, do we need that duplication?
In principle looks like we can safely throw away the LMap
and RMap
invokables, then we can define lmap
and rmap
as aliases of contramap
and map
respectively.
Or we can go even further and throw away lmap
and rmap
.
Also we can shorten contramap
to cmap
as they did in Purescript.
Finally (this might be a separate issue but let’s include it here) we can argue the same for Bifunctor’s second
and map
.
Any thoughts?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top GitHub Comments
It’s been a long time thinking about unifying
second
andmap
.At the moment, my thoughts converge in the direction that there will not be a function
third
. Actuallyfirst
implies firstOf2 andsecond
secondOf2.When dealing with more that 2, we use different names, similarly to the naming in tuples, functions available are only
fst
andsnd
but for more than that we useitemX
, same here. We already haveItemX
andMapItemX
Invokers.So we can go ahead and unify them, making
map
andsecond
aliases.Cool, I have the feeling that these abstractions are more unfamiliar to F-Sharpers so they need probably more docs and examples.