[Haskell-beginners] Re: dependent types

Isaac Dupree ml at isaac.cedarswampstudios.org
Mon Jul 20 21:57:11 EDT 2009


Maurí­cio wrote:
> -- warning: untested code --
> 
> data (Eq b) => Named a b = Named a b
> 
> equivalent :: Named a b -> Named c b -> Bool
> equivalent (Named _ a1 ) (Named _ a2) = (a1 == a2)

which doesn't work.  "data (Eq b) =>" is useless broken syntax that 
should be removed from the standard.  Either you can use

data Named a b = Named a b
equivalent :: (Eq b) => Named a b -> Named c b -> Bool

or use some GHC extension (GADTs) and do

data Named a b where Named :: (Eq b) => a -> b -> Named a b
equivalent :: Named a b -> Named c b -> Bool

-Isaac


More information about the Beginners mailing list