[Haskell-cafe] existentially quantified data types - restrictions
ozgurakgun at gmail.com
Thu Mar 25 11:07:40 EDT 2010
I need to use a language feature which is explicitly documented to be a
restriction, and -even worse- I think I reasonably need to use it.
f2 (Baz1 a b) (Baz1 p q) = a==q
> It's ok to say a==b or p==q, but a==q is wrong because it equates the two
> distinct types arising from the two Baz1 constructors.
> [from *18.104.22.168. Restrictions* at
To simplify, let's say Baz is the only constructor of a data type,
data Baz = forall a. Eq a => Baz a
-- | this cannot be done:
instance Eq (Baz a) where
(Baz x) == (Baz y) = x == y
I am quite tempted to use show functions for this equality comparison, but
after trying to have a nicely type framework I really don't want to do that.
What I simply want is, haskell to be able to compare them if they belong to
the same type, and return False otherwise. (not that haskelly way of doing
things, I know.)
Any suggestions better than the following are very welcome:
(==) = (==) `on` show
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe