Type checking for type synonym families
[ghc-hetmet.git] / compiler / NOTES
1 Type functions
2 ~~~~~~~~~~~~~~
3 * A Given inst should be a CoVar, not a coercion
4
5 * finaliseEqInst should not need to call zonk
6
7 * Why do we need fromGivenEqDict?  How could we construct       
8         a Dict that had an EqPred?
9         newDictBndr should make an EqInst directly
10
11 * tc_co should be accessed only inside Inst
12
13 * Inst.mkImplicTy needs a commment about filtering out EqInsts
14   How *do* we deal with wanted equalities?
15
16 * Inst.instType behaves inconsistently for EqInsts: it should
17   return an EqPred, like the instType' hack in pprDictsTheta
18
19   Consequences: adjust the uses of instType in TcSimplify
20
21 * tcDeref* functions are unused, except in tcGenericNormalizeFamInst, when
22   we can equally well use TcMType.lookupTcTyVar
23
24 * Coercion.mkEqPredCoI looks very peculiar.
25
26
27
28
29 -------------------------
30 *** unexpected failure for jtod_circint(opt)
31
32
33         New back end thoughts
34
35 -----------------------------------------------------------------------------
36 Codegen notes
37
38 * jumps to ImpossibleBranch should be removed.
39
40 * Profiling:
41         - when updating a closure with an indirection to a function,
42           we should make a permanent indirection.
43
44         - check that we're bumping the scc count appropriately
45
46 * check perf & binary sizes against the HEAD
47
48 -----------------------------------------------------------------------------
49 C backend notes
50
51 * use STGCALL macros for foreign calls (doesn't look like volatile regs
52   are handled properly at the mo).
53
54 -----------------------------------------------------------------------------
55 Cmm parser notes
56
57 * switches
58
59 * need to cater for unexported procedures/info tables?
60
61 * We should be able to get rid of entry labels, use info labels only.
62   - we need a %ENTRY_LBL(info_lbl) macro, so that instead of
63      JMP_(foo_entry) we can write jump %ENTRY_LBL(foo_info).
64
65 -----------------------------------------------------------------------------
66
67 * Move arg-descr from LFInfo to ClosureInfo? 
68   But: only needed for functions
69
70 * Move all of CgClosure.link_caf into NewCaf, and newDynCaf
71
72 * If the case binder is dead, and the constr is nullary,
73   do we need to assign to Node?
74
75
76 -------------------------------
77 NB: all floats are let-binds, but some non-rec lets
78     may be unlifted (with RHS ok-for-speculation)
79
80
81 simplArg:  [use strictness]
82            [used for non-top-lvl non-rec RHS or function arg]
83   if strict-type || demanded
84         simplStrictExpr
85   else
86         simplExpr ---> (floats,expr)
87         float all the floats if exposes constr app, return expr
88
89 simpl (applied lambda)      ==> simplNonRecBind
90 simpl (Let (NonRec ...) ..) ==> simplNonRecBind
91
92 simpl (Let (Rec ...)    ..) ==> simplRecBind
93
94 simplRecBind:
95   simplify binders (but not its IdInfo)
96   simplify the pairs one at a time
97         using simplRecPair
98
99 simplNonRecBind:        [was simplBeta]
100         [used for non-top-lvl non-rec bindings]
101   - check for PreInlineUnconditionally
102   - simplify binder, including its IdInfo
103   - simplArg
104   - if strict-type 
105         addCaseBind [which makes a let if ok-for-spec]
106     else
107         completeLazyBind
108
109 simplLazyBind:  [binder already simplified, but not its IdInfo]
110                 [used for both rec and top-lvl non-rec]
111                 [must not be strict/unboxed; case not allowed]
112   - check for PreInlineUnconditionally
113   - substituteIdInfo and add result to in-scope 
114         [so that rules are available in rec rhs]
115   - simplExpr --> (floats,expr)
116   - float: lifted floats only
117         if exposes constructor or pap (even if non-triv args)
118         or if top level
119   - completeLazyBind
120   
121
122 completeLazyBind:       [given a simplified RHS]
123         [used for both rec and non-rec bindings, top level and not]
124   - try discarding dead
125   - try PostInlineUnconditionally
126   - let-bind coerce arg and repeat
127   - try rhs tylam (float)
128   - try eta expand (float)    [not if any float is unlifted && (non-spec || top_lvl || rec)]
129   - let-bind constructor args [not if any float is ..as above..]
130
131   - add unfolding [this is the only place we add an unfolding]
132     add arity
133
134
135
136
137 Eta expansion
138 ~~~~~~~~~~~~~~
139 For eta expansion, we want to catch things like
140
141         case e of (a,b) -> \x -> case a of (p,q) -> \y -> r
142
143 If the \x was on the RHS of a let, we'd eta expand to bring the two
144 lambdas together.  And in general that's a good thing to do.  Perhaps
145 we should eta expand wherever we find a (value) lambda?  Then the eta
146 expansion at a let RHS can concentrate solely on the PAP case.