dfb4ec27ad596f9d615f069249b76393d9f6e022
[ghc-hetmet.git] / ghc / compiler / utils / PprStyle.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1996
3 %
4 \section[PprStyle]{Pretty-printing `styles'}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module PprStyle (
10         PprStyle(..),
11         codeStyle, ifaceStyle,
12         showUserishTypes
13     ) where
14
15 CHK_Ubiq() -- debugging consistency check
16
17 data PprStyle
18   = PprForUser                  -- Pretty-print in a way that will
19                                 -- make sense to the ordinary user;
20                                 -- must be very close to Haskell
21                                 -- syntax, etc.  ToDo: how diff is
22                                 -- this from what pprInterface must
23                                 -- do?
24   | PprDebug                    -- Standard debugging output
25   | PprShowAll                  -- Debugging output which leaves
26                                 -- nothing to the imagination
27   | PprInterface                -- Interface generation
28   | PprForC                     -- must print out C-acceptable names
29   | PprUnfolding                -- for non-interface intermodule info
30                                 -- the compiler writes/reads
31   | PprForAsm                   -- must print out assembler-acceptable names
32         Bool                    -- prefix CLabel with underscore?
33         (String -> String)      -- format AsmTempLabel
34 \end{code}
35
36 Orthogonal to the above printing styles are (possibly) some
37 command-line flags that affect printing (often carried with the
38 style).  The most likely ones are variations on how much type info is
39 shown.
40
41 The following test decides whether or not we are actually generating
42 code (either C or assembly), or generating interface files.
43 \begin{code}
44 codeStyle :: PprStyle -> Bool
45
46 codeStyle PprForC         = True
47 codeStyle (PprForAsm _ _) = True
48 codeStyle _               = False
49
50 ifaceStyle :: PprStyle -> Bool
51 ifaceStyle PprInterface   = True
52 ifaceStyle other          = False
53 \end{code}
54
55 \begin{code}
56 -- True means types like   (Eq a, Text b) => a -> b
57 -- False means types like  _forall_ a b => Eq a -> Text b -> a -> b
58 showUserishTypes PprForUser   = True    
59 showUserishTypes other        = False
60 \end{code}