blob: c174d44bc280514c07675a68922babf3f348e446 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
import Data.Word
import GHC.Base
import GHC.Ptr
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as BU
main :: IO ()
main = do
traceBinaryEventIO "0123456789"
traceBinaryEventIO $ B.replicate 10 0
traceBinaryEventIO $ B.replicate (maxSize + 1) 0
maxSize :: Int
maxSize = fromIntegral (maxBound :: Word16)
traceBinaryEventIO :: B.ByteString -> IO ()
traceBinaryEventIO bytes =
BU.unsafeUseAsCStringLen bytes $ \(Ptr p, I# n) -> IO $ \s -> do
case traceBinaryEvent# p n s of
s' -> (# s', () #)
|