On Feb 22, 2022, at 2:42 PM, Benjamin Redelings <benjamin.redelings@gmail.com> wrote:Then, in order to handle the difference between these two types, we call `tcSubTypeSigma actual_type more_quantified_type`, which
... It may (I think) eliminate predicates by defaulting, and it can eliminate types by substituting an ANY type, at least sometimes. This wrapper is stored inside abe_wrap field of ABE objects, inside the abs_exports field of the AbsBinds.
II. I am still not completely sure how the wrapper is actually applied in code generation, or how the wrapper is computed from the two types. But, I'm not quite done reading yet.
For example, in the case above, suppose that `tuple` represents all combined binders inside the AbsBinds, and is quantified by ALL the type variables and ALL the (given) dictionaries. One approach would be something like:
tuple = /\a./\b.\(dNum :: Num b). let ...CODE... in (f,g)
f' = /\a./\b.\(dNum :: b). case (tuple @a @b dNum) of f
f = /\a. f' @a @ANY dNum = apply wrapper to f' ?
In that approach, then we would FIRST extract an "f'" from the tuple without applying any wrapper. Then, SECOND, we would SECOND apply the wrapper to f' to get f.
III. I am also still working through tcMonoBinds. I'm curious what happens in a pattern binding, when the pattern has a type signature with predicates:
f:: forall a.Num a -> a->a->a
(f,g) = ...rhs...
It looks like the type signature for gets instantiated on the LHS, and.... I presume the predicate Num a is added to the local instance environment, just like if f was instantiated on the RHS? I will think about this more...
Anyway, thanks for the encouragement. I am not stuck, yet...
All this does make me think that, perhaps, some kind of updated version of Typing Haskell in Haskell would be appropriate. I'm not sure how much of this is in the Report, either.