[project @ 1997-03-14 07:52:06 by simonpj]
[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 IMP_FASTSTRING() -- cheat to force fast string dependency.
17
18 data PprStyle
19   = PprForUser                  -- Pretty-print in a way that will
20                                 -- make sense to the ordinary user;
21                                 -- must be very close to Haskell
22                                 -- syntax, etc.  ToDo: how diff is
23                                 -- this from what pprInterface must
24                                 -- do?
25   | PprDebug                    -- Standard debugging output
26   | PprShowAll                  -- Debugging output which leaves
27                                 -- nothing to the imagination
28   | PprInterface                -- Interface generation
29   | PprForC                     -- must print out C-acceptable names
30   | PprUnfolding                -- for non-interface intermodule info
31                                 -- the compiler writes/reads
32   | PprForAsm                   -- must print out assembler-acceptable names
33         Bool                    -- prefix CLabel with underscore?
34         (String -> String)      -- format AsmTempLabel
35 \end{code}
36
37 Orthogonal to the above printing styles are (possibly) some
38 command-line flags that affect printing (often carried with the
39 style).  The most likely ones are variations on how much type info is
40 shown.
41
42 The following test decides whether or not we are actually generating
43 code (either C or assembly), or generating interface files.
44 \begin{code}
45 codeStyle :: PprStyle -> Bool
46
47 codeStyle PprForC         = True
48 codeStyle (PprForAsm _ _) = True
49 codeStyle _               = False
50
51 ifaceStyle :: PprStyle -> Bool
52 ifaceStyle PprInterface   = True
53 ifaceStyle other          = False
54 \end{code}
55
56 \begin{code}
57 -- True means types like   (Eq a, Text b) => a -> b
58 -- False means types like  _forall_ a b => Eq a -> Text b -> a -> b
59 showUserishTypes PprForUser   = True    
60 showUserishTypes other        = False
61 \end{code}