No subject
Wed Apr 10 17:18:51 CEST 2013
----------
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DeriveDataTypeable #-}
import Data.Typeable
data Box where
Box :: (Typeable s, Eq s) => s -> Box
deriving Typeable
instance Eq Box where
(Box s1) == (Box s2) = Just s1 == cast s2
----------
that seems to work correctly:
----------
let a = Box (2::Int)
let b = Box (2::Float)
print $ a == b
print $ a == a
----------
Is this the right way to go? Is there any other solution?
Thanks,
TP
More information about the Haskell-Cafe
mailing list