[Haskell-cafe] Type-class predicates head-normal forms

adam vogt vogt.adam at gmail.com
Fri Jul 1 13:18:16 UTC 2016


Hi Sheng,

Maybe MPTCs can be explained as syntax sugar for extensions that might be
(more easily) specified. http://lpaste.net/168659 has one version using
type equality (GADTs here), and another that depends on user discipline. I
think both translations need FlexibleInstances/FlexibleContexts.


Regards,

Adam


On Wed, Jun 22, 2016 at 1:31 AM, sheng chen <kkchensheng at gmail.com> wrote:

> Hello,
>
> I got a question about what the form of types in Haskell are allowed.
> Specifically, what are the requirements of the context of a type? The paper
>
>     Typing Haskell in Haskell
>
> required the type to be in the form P => t, where P to be in head-normal
> form or in other words shouldn't be something like Num Bool.
>
> Now what about multi-parameter classes? The paper
>
>     Type classes: an exploration of the design space
>
> listed several potential choices but didn't say exactly what.
>
> The Haskell 2010 report covered single-parameter type classes only.
>
> Given the following definition.
>
> class Collects ce e | ce -> e where
>     empty :: ce
>     insert :: e -> ce -> ce
>
> insert2 c = insert True (insert False c)
>
> The function insert2 has the following type
>
> insert2 :: Collects ce Bool => ce -> ce
>
> This shows that the definition of head-normal forms for multi-parameter
> class differs from that for single-parameter classes. Is there any definite
> specification about the context of Haskell types?
>
> Thank you,
> Sheng
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160701/a32140df/attachment.html>


More information about the Haskell-Cafe mailing list