From 0646e02063bddc37dd560e35839abdbd8e7320d5 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft" Date: Thu, 19 Oct 2006 16:04:08 +0000 Subject: [PATCH] Use the new Any type for dynamics (GHC only) --- Data/Dynamic.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Data/Dynamic.hs b/Data/Dynamic.hs index 933224c..761f55f 100644 --- a/Data/Dynamic.hs +++ b/Data/Dynamic.hs @@ -99,16 +99,14 @@ instance Show Dynamic where showString ">>" #ifdef __GLASGOW_HASKELL__ -type Obj = forall a . a - -- Dummy type to hold the dynamically typed value. +type Obj = Any + -- Use GHC's primitive 'Any' type to hold the dynamically typed value. -- - -- In GHC's new eval/apply execution model this type must - -- be polymorphic. It can't be a constructor, because then - -- GHC will use the constructor convention when evaluating it, - -- and this will go wrong if the object is really a function. On - -- the other hand, if we use a polymorphic type, GHC will use + -- In GHC's new eval/apply execution model this type must not look + -- like a data type. If it did, GHC would use the constructor convention + -- when evaluating it, and this will go wrong if the object is really a + -- function. Using Any forces GHC to use -- a fallback convention for evaluating it that works for all types. - -- (using a function type here would also work). #elif !defined(__HUGS__) data Obj = Obj #endif -- 1.7.10.4