[Haskell-cafe] Assorted AT fun and games

Brandon S Allbery KF8NH allbery at ece.cmu.edu
Sun Aug 15 12:30:33 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/15/10 09:00 , Andrew Coppin wrote:
>  class (Vector (Point x)) => HasSpace x where
>    type Point x :: *
(...)
> And now things get *really* interesting. Consider this:
> 
>  data Foo x = Foo !x !(Point x)
> 
> Surprisingly, GHC accepts this. This despite the rather obvious fact that
> "Point x" can exist if and only if "x" has a HasSpace instance. And yet, the
> type definition appears to say that "x" is simply an unconstrained type
> variable. Intriguing...

Maybe I'm missing something in all the type machinery I elided, but it looks
to me like you have that backwards:  HasSpace x requires Point x but not
vice versa.  Your actual usage may require the reverse association, but the
definition of Foo won't be modified by that usage --- only applications of
that definition.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxoFikACgkQIn7hlCsL25VIJgCbB/3zqsATPssYNFsCD/H5fMOO
DnUAn2+gBqlHyD0FyGFANSyVxWdI0PQR
=/SmY
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list