[Haskell-cafe] Restrict values in type

Luke Clifton ltclifton at gmail.com
Thu Jan 16 14:16:58 UTC 2014

Thanks, that really cleared up a few of the questions I had about Jake
McArthurs' code as well. The link you provided was a good read and shed
some more light on the situation.

The only bit I don't quite understand is why the following code implies an
"or" relation in the type constraint of repr.

> data Stroke =
>    Line Point Point (forall repr. (CirclePen repr, RectPen repr) => repr)
>  | Arc Point Point (forall repr. (CirclePen repr) => repr)
>  | Spot Point (forall repr.
>                (CirclePen repr, RectPen repr, ArbitraryPen repr) => repr)

To me this reads that repr should be both a CirclePen and a RectPen in
order to satisfy the type constraint in the case of Line, but it seems that
it is accepting a CirclePen or a RectPen (which is the desired behaviour,
so I'm not complaining).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140116/a8f203d9/attachment.html>

More information about the Haskell-Cafe mailing list