Changes between Version 49 and Version 50 of DataParallel/ClosureConversion/ClassLess


Ignore:
Timestamp:
May 1, 2007 6:27:09 AM (8 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/ClosureConversion/ClassLess

    v49 v50  
    1414 2. The converted variant `T_CC` coincides with `T` (e.g., because `T` neither directly nor indirectly involves arrows).
    1515 3. The converted variant `T_CC` differs from `T`.
     16In the last two cases, we also have a ''conversion constructor'' `isoT` whose type and function is described below.
     17
    1618An example of a feature that prevents conversion are unboxed values.  We cannot make a closure from a function that has an unboxed argument, as we can neither instantiate the parametric polymorphic closure type with unboxed types, nor can we put unboxed values into the existentially quantified environment of a closure.
    1719
    18 === Conversion pairs ===
    19 
    20 Conversion functions come in pairs, which we wrap with the following data type for convenience:
    21 {{{
    22 data a :<->: b = (:<->:) {to :: a -> b, fr ::b -> a}
    23 }}}
    24 The functions witness the isomorphism between the two representations, as usual.
    25 
    2620=== Converting types ===
     21
     22==== The closure type ====
     23
     24We represent closures by
     25{{{
     26data a :-> b = forall e. !(e -> a -> b) :$ e
     27}}}
     28and define closure application as
     29{{{
     30($:) :: (a :-> b) -> a -> b
     31(f :$ e) $: x = f e x
     32}}}
     33So, we have `(->)_CC == (:->)`.
     34
     35==== Conversion of type terms ====
    2736
    2837We determine the converted type `t^` of `t` as follows:
     
    5059
    5160
    52 
    53 
    54 === Converting type declarations ===
    55 
    56 ==== Preliminaries ====
    57 
    58 The alternatives of `TyCon.TyCon` get a new field `tyConCC :: StatusCC TyCon`.  This field is `NoCC` for data constructors for which we have no conversion and `ConvCC T_CC` if we have a conversion, where the converted declaration `T_CC` may coincide with `T`.  In the latter case, there is also a ''conversion constructor'' `isoT` between values inhabitating types formed from the original and converted constructor.  The type of a conversion constructor is determined by the kind of the converted type, as follows:
     61=== Conversion constructors ===
     62
     63To move between `t` and `t^` we use conversion functions.  And to deal with type constructors, we need ''conversion constructors''; i.e., functions that map conversion functions for type arguments to conversion functions for compound types.
     64
     65==== Conversion pairs ====
     66
     67Conversion functions come in pairs, which we wrap with the following data type for convenience:
     68{{{
     69data a :<->: b = (:<->:) {to :: a -> b, fr ::b -> a}
     70}}}
     71The functions witness the isomorphism between the two representations, as usual.
     72
     73==== Types of convercion constructors ====
     74
     75The type of a conversion constructor depends on the kind of the converted type constructor:
    5976{{{
    6077isoTy (t::k1->k2) = forall a a_CC.
     
    6885data T (f::*->*) = T1 (f Int) | T2 (f Bool)
    6986}}}
    70 The type of the conversion constructor is as follows (using more meaningful type variable names):
     87The type of the conversion constructor is as follows :
    7188{{{
    7289isoTy (T::(*->*)->*) =
     
    8097isoT isof = toT :<->: frT
    8198  where
    82     toT (T1 x) = T1 (to (tff tfInt ) x)
    83     toT (T2 y) = T2 (to (tff tfBool) y)
    84     frT (T1 x) = T1 (fr (tff tfInt ) x)
    85     frT (T2 y) = T2 (fr (tff tfBool) y)
     99    toT (T1 x) = T1 (to (isof isoInt ) x)
     100    toT (T2 y) = T2 (to (isof isoBool) y)
     101    frT (T1 x) = T1 (fr (isof isoInt ) x)
     102    frT (T2 y) = T2 (fr (isof isoBool) y)
    86103}}}
    87104where `isoInt` and `isoBool` are the conversion constructors for `Int`s and `Bool`s.
    88105
    89 Moreover, we represent closures - the converted form of function arrows - as follows:
    90 {{{
    91 data a :-> b = forall e. !(e -> a -> b) :$ e
    92 
     106Moreover, the conversion constructor for function arrows is
     107{{{
    93108isoArr :: a :<->: a_CC   -- argument conversion
    94109       -> b :<->: b_CC   -- result conversion
     
    99114    frArr (f :$ e) = frb . f e . toa
    100115}}}
    101 So, the function array constructor `(->)::*->*->*` has a `StatusCC` value of `ConvCC ((:->)` with `isoArr` as the conversion constructor.
    102 
    103 Closure application is defined as
    104 {{{
    105 ($:) :: (a :-> b) -> a -> b
    106 (f :$ e) $: x = f e x
    107 }}}
     116
     117
     118=== Converting type declarations ===
     119
     120==== Preliminaries ====
     121
     122In the latter case, there is also a conversion constructor `isoT` between values inhabitating types formed from the original and converted constructor. 
    108123
    109124==== Conversion rules ====