2 module GHC.Debug (debugLn, debugErrLn) where
8 debugLn :: [Char] -> IO ()
9 debugLn xs = IO (\s0 ->
15 debugErrLn :: [Char] -> IO ()
16 debugErrLn xs = IO (\s0 ->
19 case c_debugErrLn mba of
22 foreign import ccall unsafe "debugLn"
23 c_debugLn :: MutableByteArray# RealWorld -> IO ()
25 foreign import ccall unsafe "debugErrLn"
26 c_debugErrLn :: MutableByteArray# RealWorld -> IO ()
28 mkMBA :: State# RealWorld -> [Char] ->
29 (# State# RealWorld, MutableByteArray# RealWorld #)
30 mkMBA s0 xs = -- Start with 1 so that we have space to put in a \0 at
34 case newByteArray# l s0 of
36 case write mba 0# xs s1 of
39 len l (_ : xs') = len (l +# 1#) xs'
41 write mba offset [] s = writeCharArray# mba offset '\0'# s
42 write mba offset (C# x : xs') s
43 = case writeCharArray# mba offset x s of
45 write mba (offset +# 1#) xs' s'