[project @ 2002-12-18 10:42:54 by malcolm]
[haskell-directory.git] / Data / Dynamic.hs
index 961355d..e55dae6 100644 (file)
@@ -80,6 +80,7 @@ import GHC.IOBase
 
 #ifdef __HUGS__
 import Hugs.IO
+import Hugs.IORef
 import Hugs.IOExts
 #endif
 
@@ -109,8 +110,20 @@ instance Show Dynamic where
          showsPrec 0 t   . 
          showString ">>"
 
-data Obj = Obj  
- -- dummy type to hold the dynamically typed value.
+#ifdef __GLASGOW_HASKELL__
+type Obj = forall a . a
+ -- Dummy 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
+ -- a fallback convention for evaluating it that works for all types.
+ -- (using a function type here would also work).
+#else
+data Obj = Obj
+#endif
 
 -- | A concrete representation of a (monomorphic) type.  'TypeRep'
 -- supports reasonably efficient equality.
@@ -369,3 +382,8 @@ INSTANCE_TYPEABLE0(Word64,word64Tc,"Word64")
 INSTANCE_TYPEABLE0(TyCon,tyconTc,"TyCon")
 INSTANCE_TYPEABLE0(TypeRep,typeRepTc,"TypeRep")
 INSTANCE_TYPEABLE0(Dynamic,dynamicTc,"Dynamic")
+
+#ifndef __NHC__
+#include "Dynamic.h"
+INSTANCE_TYPEABLE1(IORef,ioRefTc,"IORef")
+#endif