Open safareli opened 7 years ago
Ah, I wanted to just ask the same. My confusion was especially about Bifunctor
s, because stating that map
can be derived from bimap
(or that "Bifunctor needs to implement Functor") isn't enough, it would also need to say how. Is a.map = f => a.bimap(f, identity)
(not .bimap(identity, f)
) a valid Functor? The laws say yes, but e.g. in Haskell it doesn't work to make Mydatatype a b
to be a Functor over a
.
Speaking of which, Haskells Bifunctor doesn't state that second ≡ map
, although it would make sense to me (and I haven't found counterexample implementations). Could there be a reason for the omission?
The list in this issue is just an outline of derivations we have. if we move them into algebras we should also show default derivation.
In case of bimap
, in derivations we have map = function(f) { return this.bimap(a => a, f); }
and this will work in haskell too as it's deriving map from last parameter (second
).
I have just taken look at bimap and indeed there is no word about map
being equal to second
and as i said:
we should investigate if other derivations should be moved to corresponding algebras
One thing i know is that <*> = ap
is for sure a law and others need investigation.
Maybe what we should do is:
<*> = ap
as far as I understand), and keep adding as we find more.ap
. There is no harm in having them.
Currently this are derivations separately from algebras but I think we can move them to algebras:
map
may be derived frombimap
=> BiFunctormap
may be derived frompromap
=> ProFunctormap
may be derived fromtraverse
=> Traversablereduce
may be derived fromtraverse
=> Traversablemap
may be derived fromap
andof
=> Applicativemap
may be derived fromchain
andof
=> Monadap
may be derived fromchain
=> ChainAs discussed in #179 we should at least state that
<*> = ap
in Apply and Chain (or Applicative and Monad) but we should also investigate if other derivations should be moved to corresponding algebras.