summaryrefslogtreecommitdiff
path: root/ghc/compiler/utils/Ubiq.lhi
blob: bb06487f1ddbcf2ef7acb0c9fdee3bd2b8372698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Things which are ubiquitous in the GHC compiler.

\begin{code}
interface Ubiq where

--import PreludePS(_PackedString)
import FastString(FastString)

import Bag		( Bag )
import BinderInfo	( BinderInfo )
import CgBindery	( CgIdInfo )
import CharSeq		( CSeq )
import CLabel		( CLabel )
import Class		( GenClass, GenClassOp, Class(..), ClassOp )
import ClosureInfo	( ClosureInfo, LambdaFormInfo )
import CmdLineOpts	( SimplifierSwitch, SwitchResult )
import CoreSyn		( GenCoreArg, GenCoreBinder, GenCoreBinding, GenCoreExpr,
			  GenCoreCaseAlts, GenCoreCaseDefault, Coercion
			)
import CoreUnfold	( Unfolding, UnfoldingGuidance )
import CostCentre	( CostCentre )
import FieldLabel	( FieldLabel )
import FiniteMap	( FiniteMap )
import HeapOffs		( HeapOffset )
import HsPat		( OutPat )
import HsPragmas	( ClassOpPragmas, ClassPragmas, DataPragmas, GenPragmas, InstancePragmas )
import Id		( StrictnessMark, GenId, Id(..) )
import IdInfo		( IdInfo, ArityInfo, DeforestInfo, StrictnessInfo, UpdateInfo )
import Demand		( Demand )
import Kind		( Kind )
import Literal		( Literal )
import MachRegs		( Reg )
import Maybes		( MaybeErr )
import MatchEnv 	( MatchEnv )
import Name		( Module(..), OccName, Name, ExportFlag, NamedThing(..) )
import Outputable	( Outputable(..) )
import PprStyle		( PprStyle )
import PragmaInfo	( PragmaInfo )
import Pretty		( PrettyRep )
import PrimOp		( PrimOp )
import PrimRep		( PrimRep )
import SMRep		( SMRep )
import SrcLoc		( SrcLoc )
import TcType		( TcMaybe )
import TyCon		( TyCon, Arity(..) )
import TyVar		( GenTyVar, TyVar(..) )
import Type		( GenType, Type(..) )
import UniqFM		( UniqFM, Uniquable(..) )
import UniqSupply	( UniqSupply )
import Unique		( Unique )
import Usage		( GenUsage, Usage(..) )
import Util		( Ord3(..) )

-- All the classes in GHC go; life is just too short
-- to try to contain their visibility.

class NamedThing a where
	getOccName :: a -> OccName
	getName    :: a -> Name

class Ord3 a where
	cmp :: a -> a -> Int#
class Outputable a where
	ppr :: PprStyle -> a -> Int -> Bool -> PrettyRep
class Uniquable a where
	uniqueOf :: a -> Unique

-- For datatypes, we ubiquitize those types that (a) are
-- used everywhere and (b) the compiler doesn't lose much
-- optimisation-wise by not seeing their pragma-gunk.

data ArityInfo
data Bag a
data BinderInfo
data CgIdInfo
data CLabel
data ClassOpPragmas a
data ClassPragmas a
data ClosureInfo
data Coercion
data CostCentre
data CSeq
data DataPragmas a
data DeforestInfo
data Demand
data ExportFlag
data FieldLabel
data FiniteMap a b
data GenClass a b
data GenClassOp a
data GenCoreArg a b c
data GenCoreBinder a b c
data GenCoreBinding a b c d
data GenCoreCaseAlts a b c d
data GenCoreCaseDefault a b c d
data GenCoreExpr a b c d
data GenId a	-- NB: fails the optimisation criterion
data GenPragmas a
data GenTyVar a	-- NB: fails the optimisation criterion
data GenType  a b
data GenUsage a
data HeapOffset
data IdInfo
data InstancePragmas a
data Kind
data LambdaFormInfo
data Literal
data MaybeErr a b
data MatchEnv a b
data Name
data OccName
data Reg
data OutPat a b c
data PprStyle
data PragmaInfo
data PrettyRep
data PrimOp
data PrimRep	-- NB: an enumeration
data SimplifierSwitch
data SMRep
data SrcLoc
data StrictnessInfo bdee
data StrictnessMark
data SwitchResult
data TcMaybe s
data TyCon
data UniqFM a
data UpdateInfo
data UniqSupply
data Unfolding
data UnfoldingGuidance
data Unique	-- NB: fails the optimisation criterion

-- don't get clever and unexpand some of these synonyms
-- (GHC 0.26 will barf)
type Module = FastString
type Arity = Int
type Class = GenClass (GenTyVar (GenUsage Unique)) Unique
type ClassOp = GenClassOp (GenType (GenTyVar (GenUsage Unique)) Unique)
type Id	   = GenId (GenType (GenTyVar (GenUsage Unique)) Unique)
type Type  = GenType (GenTyVar (GenUsage Unique)) Unique
type TyVar = GenTyVar (GenUsage Unique)
type Usage = GenUsage Unique

-- These are here only for SPECIALIZing in FiniteMap (ToDo:move?)
instance Ord Reg
instance Ord CLabel
instance Ord TyCon
instance Eq Reg
instance Eq CLabel
instance Eq TyCon
-- specializing in UniqFM, UniqSet
instance Uniquable Unique
instance Uniquable Name
-- specializing in Name
\end{code}