| | 23 | The `[Inst]` currently includes equalities, but they are ignored. The `Avails` passed in are free of equalities, but the outgoing ones includes equalities (which come from the `[Inst]`). Moreover, we have the post-processing of `Avails` by |
| | 24 | {{{ |
| | 25 | extractResults :: Avails |
| | 26 | -> [Inst] -- Wanted |
| | 27 | -> TcM (TcDictBinds, -- Bindings |
| | 28 | [Inst], -- The insts bound by the bindings |
| | 29 | [Inst]) -- Irreducible ones |
| | 30 | -- Note [Reducing implication constraints] |
| | 31 | }}} |
| | 32 | The irreducible `Inst`s will include all equalities that are passed in as wanteds. |
| | 33 | |
| | 34 | === Integration === |
| | 35 | |
| | 36 | Both the equality and class solver have a pre-processing and post-processing phase as well as the main solving phase. (All three phases are structurally more complicated for equalities.) |
| | 37 | |
| | 38 | ==== Pre-processing ==== |
| | 39 | |
| | 40 | The two tasks: |
| | 41 | * Classes: computation of the initial `Avails` value (called `init_state` in `reduceContext`). |
| | 42 | * Equalities: normalisation of equalities and class constraints. |
| | 43 | I'd suggest to do normalisation first (basically in the same way as it done now) and then build the initial `Avails` from the normalised constraints. |
| | 44 | |
| | 45 | ==== Main solver ==== |
| | 46 | |
| | 47 | We can probably leave the solving of class constraints much as it is now. How much the solving of equalities will have to change depends on how we handle `Avails` and whether we keep local equalities in `Avails`, too. (At the moment, the code in `TcTyFuns` doesn't use the `Avails` data type.) We need to integrate the loops of `TcSimplify.reduceList`/`TCSimplify.reduce` with those of `TcTyFuns.propagate`. |
| | 48 | |
| | 49 | ==== Post-processing ==== |
| | 50 | |
| | 51 | The two tasks: |
| | 52 | * Classes: Extract bindings, bound insts, and irreducible insts from the final `Avails` (i.e., work of `extractResult`). |
| | 53 | * Equalities: Finalisation phase. |
| | 54 | I'd suggest to extract results first and then finalise on the insts as usual. That way, the code for both probably doesn't have to change much. It's also conceptually simpler, I think. |
| | 55 | |
| | 56 | ==== Open questions ==== |
| | 57 | |
| | 58 | 0. During solving we maintain the local equalities and local class constraints in rather different structures. In particular, we don't use `Avails` for equalities. How do we want to integrate this? |
| | 59 | 0. Integration of loops of `TcSimplify.reduceList`/`TCSimplify.reduce` with those of `TcTyFuns.propagate`. |