[Haskell-cafe] Restrict values in type

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


>
>
> 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).
>
>
Having thought about it, it _IS_ saying that repr is an instance of both
CirclePen and RectPen, which is why I can call either circle or rectangle
in that context. The called function then decides the type, rather than the
calling function.

PS: I got out of bed with this epiphany, so I may be incoherent and tired
and not making any sense at all...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140116/393c3ea2/attachment.html>


More information about the Haskell-Cafe mailing list