[Haskell-cafe] typeclasses considered unnecessary/the power of the @

Anthony Clayden anthony_clayden at clear.net.nz
Fri May 18 11:44:03 UTC 2018


On 2018-05-16 04:24:15 UTC 2018, Bardur Arantsson wrote:

> An interesting post, but I don't see any mention of laws. This seems like
it could be an... issue.

>
> (Not that we specify laws in the code anyway right now, but at least there's some idea of a "thing" we can attach the laws to and where we can document them.)


Thanks Bardur, I don't see an issue. Currently the laws are specified in
terms of equivalences between method calls, not in terms of classes.
Furthermore the laws might involve methods from many different classes. So
we can attach the laws to the methods.

For example, the Monad laws mention not only `return` and (>>=) but also
`fmap`, `pure`, (*>), etc. Note that the classes in the Prelude are all
single parameter, in compliance with H98; so it's unambiguous which type
instantiation the laws are talking about.

That can all be handled I think through the 'supermethod methods' I talked
about (which play the role of superclass constraints). For example in
making the Num class redundant, we require (+) to be a supermethod of (*);
and (*) to be a supermethod of (/).


AntC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180518/fbc623fd/attachment.html>


More information about the Haskell-Cafe mailing list