[Haskell-cafe] Type-class predicates head-normal forms
sheng chen
kkchensheng at gmail.com
Wed Jun 22 05:31:15 UTC 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160622/d6df08e3/attachment.html>
More information about the Haskell-Cafe
mailing list