X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FExts.hs;h=81a9dbb4edb399c29d2fb9fc1e96053332f39572;hb=be2750a0a11b919fb03cc070074e430f88bdfa90;hp=bc36771677559e25709af23da23a06060ef1d0a1;hpb=fb80d56c0b7617261c93a808e9001bbb25a7562e;p=ghc-base.git diff --git a/GHC/Exts.hs b/GHC/Exts.hs index bc36771..81a9dbb 100644 --- a/GHC/Exts.hs +++ b/GHC/Exts.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE MagicHash, UnboxedTuples, DeriveDataTypeable #-} + ----------------------------------------------------------------------------- -- | -- Module : GHC.Exts @@ -41,7 +43,13 @@ module GHC.Exts lazy, inline, -- * Transform comprehensions - Down(..), groupWith, sortWith, the + Down(..), groupWith, sortWith, the, + + -- * Event logging + traceEvent, + + -- * SpecConstr annotations + SpecConstrAnnotation(..) ) where @@ -49,12 +57,15 @@ import Prelude import GHC.Prim import GHC.Base +import GHC.Magic import GHC.Word import GHC.Int -import GHC.Float +-- import GHC.Float 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 @@ -92,8 +103,35 @@ groupWith :: Ord b => (a -> b) -> [a] -> [[a]] groupWith f xs = build (\c n -> groupByFB c n (\x y -> f x == f y) (sortWith f xs)) groupByFB :: ([a] -> lst -> lst) -> lst -> (a -> a -> Bool) -> [a] -> lst -groupByFB c n eq xs = groupByFBCore xs +groupByFB c n eq xs0 = groupByFBCore xs0 where groupByFBCore [] = n groupByFBCore (x:xs) = c (x:ys) (groupByFBCore zs) where (ys, zs) = span (eq x) xs + +-- ----------------------------------------------------------------------------- +-- tracing + +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 ) +