GHC Trac Home
GHC Git Repos
Report a bug
Working on GHC
Mailing Lists & IRC
The GHC Team
Tickets I Created
Patches for review
New Feature Req
side by side
lines around each change
Show the changes in full context
White space changes
Apr 23, 2007 4:12:49 AM (
The only remaining problem is that a type parameter to a function may itself be a type parameter got from a calling function; so similar to classes, we need to pass conversion functions with every type parameter. So, maybe we want to stick `fr` and `to` into a class after all and requires that all functions used in converted contexts have the appropriate contexts in their signatures.
=== Issues, aka rl's complaints ===
==== Non-converted versus unchanged type declarations ====
Many type declarations will not be changed by conversion, as they do not contain any arrows. Hence, it is more economic to avoid generating a `_CC` version of these declarations. I initially thought that we can ignore this for a moment, because it is only an optimisation. However, consider
data T = MkT Int
data S = MkS (Int -> Int)
As we don't convert `Int`, we cannot convert `T` and `S`, which is a shame as their conversion is simple and (in the vectorisation case may affect performance dramatically). As a matter of fact, if we identify declarations that need not be converted, then we would mark `Int` and `T` as such and can convert `S` easily.
==== FC Coercions ====
Closure conversion happens on Core, which means that constructors, such as `MkT` of
newtype T a = MkT (a -> a)
in a definition
foo :: (a -> a) -> T a
foo f = MkT f
have vanished, leaving only a coercion. As `T` is not converted, we need to notice that we need to generate `MkT (fr f)`. So, we need to spot the conversion representing `MkT`.
Generally, we need a story about treating coercions during conversion.
==== Function type constructor ====
It is clear how to treat types involving subtypes of the form `a -> b`. It is less clear how to deal with partial applications of `(->)`. Consider
data T f = T (Int -> Int) (f Int Int)
used as `T (->)` in converted code. What is `convert (T (->))`?
==== Classes ====
It might be sufficient to never convert class declarations as a whole, but only their representation types.