[Haskell-cafe] GHC optimizations and unsafePerformIO - Was: Data.Typeable TypeRep Ord instance.
Andreas Baldeau
andreas at baldeau.net
Sat Jan 1 13:38:18 CET 2011
Thinking about this there might be one problem:
Without having looked further into this I think perfomance might not
be as expected. Using unsafePerformIO affects ghc's optimzations,
doesn't it?
So I wonder if it's a good idea (from a performance point of view) to
use this.
> 2010/12/30 Andreas Baldeau <andreas at baldeau.net>:
> > instance Ord TypeRep where
> > compare t1 t2 =
> > compare
> > (unsafePerformIO (typeRepKey t1))
> > (unsafePerformIO (typeRepKey t2))
> > typeRepKey :: TypeRep -> IO Int
> > typeRepKey (TypeRep (Key i) _ _) = return i
So the question is, if ghc could transform this to simply compare the
keys throwing away unsafePerformIO and return.
More information about the Haskell-Cafe
mailing list