Remove unused imports
[ghc-prim.git] / GHC / Debug.hs
1
2 module GHC.Debug (debugLn) where
3
4 import GHC.Prim
5 import GHC.Types
6 import GHC.Unit ()
7
8 debugLn :: [Char] -> IO ()
9 debugLn xs = IO (\s0 ->
10                  -- Start with 1 so that we have space to put in a \0 at
11                  -- the end
12                  case len 1# xs of
13                  l ->
14                      case newByteArray# l s0 of
15                      (# s1, mba #) ->
16                          case write mba 0# xs s1 of
17                          s2 ->
18                              case c_debugLn mba of
19                              IO f -> f s2)
20     where len l [] = l
21           len l (_ : xs') = len (l +# 1#) xs'
22
23           write mba offset [] s = writeCharArray# mba offset '\0'# s
24           write mba offset (C# x : xs') s
25               = case writeCharArray# mba offset x s of
26                 s' ->
27                     write mba (offset +# 1#) xs' s'
28
29 foreign import ccall unsafe "debugLn"
30     c_debugLn :: MutableByteArray# RealWorld -> IO ()
31