On Tue, Jul 19, 2005 at 08:16:35PM +1000, Ben Lippmeier wrote:
> Bulat Ziganshin wrote:
> 
> >reading GHC sources is always very interesting :)
> >that is from GHC/Base.hs :
> 
> >getTag :: a -> Int#
> >getTag x = x `seq` dataToTag# x
> 
> ! This is just what I was looking for, thankyou.
> 
> My shallowEq function is now simply:
> 
> shallowEq :: a -> a -> Bool
> shallowEq a b = getTag a ==# getTag b
> 
> My project is already totally reliant on GHC, and this will save me the 
> heartache of hacking DrIFT (which I was in the process of setting up 
> when I saw this mail) into my makefile.
> 
> Portability be damned!
> 
> Ben.

You might increase portability a bit by using

import Data.Generics

shallowEq :: Data a => a -> a -> Bool
shallowEq x y = toConstr x == toConstr y

it does introduce a dependency on Data though

Groeten,
Remi

-- 
Nobody can be exactly like me. Even I have trouble doing it.

Attachment: pgpyTyB9kylSx.pgp
Description: PGP signature

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

Reply via email to