On Mar 18, 2010, at 01:27 , Darrin Chandler wrote:
On Thu, Mar 18, 2010 at 01:06:25PM +0800, Lyndon Maydwell wrote:
You could probably also use a typeclass for pointy things rather than
a data type, this would then require you to use existential
quantification to construct a hetrogenous list.

So in "normal" use Polygon list would be homogeneous, but could be made
heterogeneous with effort? If I have that right it's closer, but I'd
love to have the compiler whine if someone tried to mix them.

They can be mixed only with significant effort. And you can't really prevent it once your users know the magic of existential quantification; *but* those lists won't typecheck when passed to your routines expecting a Polygon, because you will be expecting a (Point a => Polygon [a]) but they will be passing a (Polygon [forall a. Point a => a]) or something similar.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to