8c1ca63b6b0293a06845f3d307a1fdefa30b7e63
[mate.git] / Mate / Debug.hs
1 {-# LANGUAGE CPP #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 #include "debug.h"
4
5 module Mate.Debug where
6
7 {- we cannot use `PrintfType' from Text.Printf, as it isn't exported.
8  - so we implement a `VarArgsFake' here.
9  - http://www.haskell.org/haskellwiki/Varargs -}
10 class VarArgsFake t where
11   varFake :: [String] -> t
12
13 instance VarArgsFake (IO a) where
14   varFake _ = return undefined
15
16 instance (Show a, VarArgsFake r) => VarArgsFake (a -> r) where
17   varFake _ _ = varFake []
18
19 printfFake :: String -> (VarArgsFake t) => t
20 printfFake _ = varFake []
21
22
23 -- see counterpart at `debug.h'
24 #ifndef DBG_JIT
25 printfJit :: String -> (VarArgsFake t) => t
26 printfJit = printfFake
27 #endif
28
29 #ifndef DBG_BB
30 printfBb :: String -> (VarArgsFake t) => t
31 printfBb = printfFake
32 #endif
33
34 #ifndef DBG_MP
35 printfMp :: String -> (VarArgsFake t) => t
36 printfMp = printfFake
37 #endif
38
39 #ifndef DBG_CP
40 printfCp :: String -> (VarArgsFake t) => t
41 printfCp = printfFake
42 #endif
43
44 #ifndef DBG_STR
45 printfStr :: String -> (VarArgsFake t) => t
46 printfStr = printfFake
47 #endif