MRP Summary & revised MRP 2ed

Akio Takano tkn.akio at gmail.com
Fri Nov 27 09:29:09 UTC 2015


On Thu, Nov 26, 2015 at 8:36 AM, Herbert Valerio Riedel <hvr at gnu.org> wrote:
> On 2015-11-26 at 09:28:32 +0100, Akio Takano wrote:
>
> [...]
>
>> I understand this, but perhaps there is a way to achieve this without
>> slowing down existing code. How about introducing a new warning
>> (enabled with -Wall) that is triggered when a type satisfies the
>> following 3 conditions?
>>
>> 1. The type has a Monad instance and an Applicative instance declared
>> in the same module, with the same set of constraints.
>> 2. (*>) is not defined as (*>) = (>>). i.e. either it has a
>> non-trivial definition or its definition is left out.
>> 3. (>>) is not defined as (>>) = (*>). i.e. either it has a
>> non-trivial definition or its definition is left out.
>>
>> This way, people can be warned when (*>) and (>>) can share an
>> implementation but they don't.
>
> Coincidentally, I've recently implemented something similar to that end
> (but it is *not* enabled via -Wall/-Wcompat by default yet), see
>
>   https://git.haskell.org/ghc.git/commitdiff/f09f2470a76bb08b7f51d2f5663daa672b86f618
>
> for details.

Thank you for the information. If I understand correctly, this
-fwarn-noncanonical-monad-instances warning doesn't address my
concern, because it won't warn about a monad that defines neither (>>)
nor (*>) explicitly, which I expect to be a common case.

- Akio

>
> Cheers,
>   hvr


More information about the Libraries mailing list