projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doc updates in System.IO
[ghc-base.git]
/
GHC
/
Exts.hs
diff --git
a/GHC/Exts.hs
b/GHC/Exts.hs
index
bc36771
..
661f5aa
100644
(file)
--- a/
GHC/Exts.hs
+++ b/
GHC/Exts.hs
@@
-41,7
+41,10
@@
module GHC.Exts
lazy, inline,
-- * Transform comprehensions
lazy, inline,
-- * Transform comprehensions
- Down(..), groupWith, sortWith, the
+ Down(..), groupWith, sortWith, the,
+
+ -- * Event logging
+ traceEvent
) where
) where
@@
-49,12
+52,14
@@
import Prelude
import GHC.Prim
import GHC.Base
import GHC.Prim
import GHC.Base
+import GHC.Magic
import GHC.Word
import GHC.Int
import GHC.Word
import GHC.Int
-import GHC.Float
+-- import GHC.Float
import GHC.Ptr
import Data.String
import Data.List
import GHC.Ptr
import Data.String
import Data.List
+import Foreign.C
-- XXX This should really be in Data.Tuple, where the definitions are
maxTupleSize :: Int
-- XXX This should really be in Data.Tuple, where the definitions are
maxTupleSize :: Int
@@
-92,8
+97,16
@@
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
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
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', () #)