Define SpecConstrAnnotation in GHC.Exts, and import it from there
authorsimonpj@microsoft.com <unknown>
Mon, 18 Oct 2010 13:58:57 +0000 (13:58 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 18 Oct 2010 13:58:57 +0000 (13:58 +0000)
Reason: avoid having to link the entire ghc package in modules
that use compile-time annotations:

       import GHC.Exts( SpecConstrAnnotation )
       {-# ANN type T ForceSpecConstr #-}

It's a kind of bug that the package exporting SpecConstrAnnotation
is linked even though it is only needed at compile time, but putting
the data type declaration in GHC.Exts is a simple way to sidestep
the problem

See See Note [SpecConstrAnnotation] in SpecConstr

GHC/Exts.hs

index 661f5aa..ea4b8ff 100644 (file)
@@ -44,7 +44,10 @@ module GHC.Exts
         Down(..), groupWith, sortWith, the,
 
         -- * Event logging
-        traceEvent
+        traceEvent,
+
+        -- * SpecConstr annotations
+        SpecConstrAnnotation(..)
 
        ) where
 
@@ -60,6 +63,7 @@ import GHC.Ptr
 import Data.String
 import Data.List
 import Foreign.C
+import Data.Data
 
 -- XXX This should really be in Data.Tuple, where the definitions are
 maxTupleSize :: Int
@@ -110,3 +114,22 @@ traceEvent :: String -> IO ()
 traceEvent msg = do
   withCString msg $ \(Ptr p) -> IO $ \s ->
     case traceEvent# p s of s' -> (# s', () #)
+
+
+
+{- **********************************************************************
+*                                                                      *
+*              SpecConstr annotation                                    *
+*                                                                      *
+********************************************************************** -}
+
+-- Annotating a type with NoSpecConstr will make SpecConstr 
+-- not specialise for arguments of that type.
+
+-- This data type is defined here, rather than in the SpecConstr module
+-- itself, so that importing it doesn't force stupidly linking the
+-- entire ghc package at runtime
+
+data SpecConstrAnnotation = NoSpecConstr | ForceSpecConstr
+                deriving( Data, Typeable, Eq )
+