You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Category hierarchy principally contains the definitions RawFunctor, RawApplicative, and RawMonad. The RawMonad module contains a definition rawApplicative, showing that from a RawMonad, one can get a RawApplicative. In turn, the RawApplicative module contains a definition rawFunctor. Furthermore, the members of rawApplicative and rawFunctor are reexported, meaning that RawMonad exports definitions of _<$>_, pure, and _⊛_.
These exported definitions are defined in terms of return and _>>=_. This means that often, a user will write implementations for all three structures, but their RawFunctor will have a definitionally different implementation of _<$>_ than their RawMonad gives rise to.
It is perhaps useful to be able to derive functors and applicatives just from the monad data, but it also causes problems. There needs somewhere to be a definition of RawMonad containing a RawApplicative field, which itself contains a RawFunctor field. This would provide more coherence to the hierarchy.
I've started working on this. I'm tempted to additionally drop the exotic unicode combinators for Applicative and Alternative in favour of their haskell counterparts.
In #636 I defined MonadZero and MonadPlus by combining Monad with ApplicativeZero and Alternative respectively. But now that Monad packs
an Applicative, we have a diamond problem with two potentially unrelated
instances of Applicative contained in each.
But rolling back #636 to have once more duplicated empty and _<|>_ in
both the applicative & monad hierarchies is not really satisfactory as we'll
really easily get ambiguities.
So what I'm considering is a parallel hierarchy with records packing empy : F A
alone first and combined with _<|>_ : F A -> F A -> F A second.
But I need names for these.
Let's say Empty & Sum as placeholder for now
Empty = empty
Sum = Empty + _<|>_
ApplicativeZero = Applicative + Empty
Alternative = Applicative + Sum
MonadZero = Monad + Empty
MonadPlus = Applicative + Sum
Intuitively I was thinking Pointed for Empty but from what I can read for functors
it's A -> F A rather than F A (even though for sets it's 1 -> X!).
My long-term bias definitely is to structure things as per this suggestion, with empty : F A first, then combined with _<|>_.
Pointed is a confusing thing. Pointed objects are quite different from pointed endofunctors. And it's not quite "has a point".
I'm not seriously suggesting this, but element-less is closer than empty. But let's not even consider names for the method, just for the record. Try as I might, I can't improve on Empty. However, I think Sum is misleading. I'd prefer Choose or Choice. Choice is likely better. There might be better still.
Activity
MatthewDaggitt commentedon Sep 12, 2022
So the non-indexed versions should not be defined in terms of the indexed ones.
gallais commentedon Sep 27, 2022
I've started working on this. I'm tempted to additionally drop the exotic unicode combinators for
ApplicativeandAlternativein favour of their haskell counterparts.gallais commentedon Sep 27, 2022
Hmmm this is really annoying.
In #636 I defined
MonadZeroandMonadPlusby combiningMonadwithApplicativeZeroandAlternativerespectively. But now thatMonadpacksan
Applicative, we have a diamond problem with two potentially unrelatedinstances of
Applicativecontained in each.But rolling back #636 to have once more duplicated
emptyand_<|>_inboth the applicative & monad hierarchies is not really satisfactory as we'll
really easily get ambiguities.
So what I'm considering is a parallel hierarchy with records packing
empy : F Aalone first and combined with
_<|>_ : F A -> F A -> F Asecond.But I need names for these.
Let's say Empty & Sum as placeholder for now
Intuitively I was thinking
PointedforEmptybut from what I can read for functorsit's
A -> F Arather thanF A(even though for sets it's1 -> X!).JacquesCarette commentedon Oct 1, 2022
My long-term bias definitely is to structure things as per this suggestion, with
empty : F Afirst, then combined with_<|>_.Pointedis a confusing thing. Pointed objects are quite different from pointed endofunctors. And it's not quite "has a point".I'm not seriously suggesting this, but
element-lessis closer thanempty. But let's not even consider names for the method, just for the record. Try as I might, I can't improve onEmpty. However, I thinkSumis misleading. I'd preferChooseorChoice.Choiceis likely better. There might be better still.[ re #952, #356, #939, #1530 ] Overhaul of Functor/Applicative/Monad (#…