Remove WrappedMonad
David Feuer
david.feuer at gmail.com
Thu Apr 26 02:43:26 UTC 2018
Yes. If DerivingVia is accepted, but Monad of no return is rejected,
then some people may choose to write (modulo unresolved syntax)
data M a = ... deriving (Functor via (WrappedMonad m), Applicative via
(WrappedMonad m))
instance Monad M where
return = ...
(>>=) = ...
(>>) = ...
rather than the standard
instance Functor M where
fmap = liftM
instance Applicative M where
pure = return
(<*>) = ap
liftA2 = liftM2
If, however, the Monad-of-no-return proposal goes through, there won't
be any way (using standard classes) to write a Monad instance without
hand-writing an Applicative instance.
So my earlier +1 is very much conditional on that combination *not* happening.
On Wed, Apr 25, 2018 at 9:50 PM, Dan Burton <danburton.email at gmail.com> wrote:
> I don't quite understand the comment about DerivingVia.
>
>> If Monad keeps return as a typeclass method, then DerivingVia could be
>> used to produce an Applicative instance from a Monad instance.
>
>
> Why would DerivingVia be needed for this? If you have your hands on a Monad
> instance, then you always have access to the corresponding Applicative
> instance, since Applicative is a superclass of Monad. I'm not sure how
> DerivingVia comes into play here, or how the "monad of no return" proposal
> would change anything about this. Can someone spell it out for me?
>
> -- Dan Burton
>
> On Wed, Apr 25, 2018 at 6:11 PM, Andrew Martin <andrew.thaddeus at gmail.com>
> wrote:
>>
>> Control.Applicative features a type named WrappedMonad that is used to
>> recover an Applicative instance from a Monad instance. However, since GHC
>> 7.10, it hasn't been possible to write an Monad instance without an
>> Applicative instance. Consequently, this type is useless (with one caveat
>> below). I propose removing this type.
>>
>> Trac Ticket: https://ghc.haskell.org/trac/ghc/ticket/15027
>> GitHub PR: https://github.com/ghc/ghc/pull/129
>>
>> On the PR, David Feuer suggests that the type may have some utility
>> depending on whether the monad-of-no-return proposal is accepted (and also
>> on whether DerivingVia is accepted, but this one seems more sure). If Monad
>> keeps return as a typeclass method, then DerivingVia could be used to
>> produce an Applicative instance from a Monad instance. If anyone knows the
>> status of this proposal, that could be helpful. This aside, all indication
>> of approval or disapproval of this proposal are welcome. Also, I'd really
>> love to know if anyone is even using this type.
>>
>> --
>> -Andrew Thaddeus Martin
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
More information about the Libraries
mailing list