Changes between Version 21 and Version 22 of DataParallel/ClosureConversion/ClassLess


Ignore:
Timestamp:
Apr 27, 2007 5:37:31 AM (8 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/ClosureConversion/ClassLess

    v21 v22  
    2121Conversion functions come in pairs, which we wrap with the following data type for convenience: 
    2222{{{ 
    23 data TF a b = TF {to :: a -> b; fr :: b -> a} 
     23data a :<->: b = (:<->:) {to :: a -> b, fr ::b -> a} 
    2424}}} 
    2525 
     
    2828==== Preliminaries ==== 
    2929 
    30 The alternatives of `TyCon.TyCon` get a new field `tyConCC :: StatusCC (TyCon, Id)`.  This field is `NoCC` for data constructors for which we have no conversion and `ConvCC (T_CC, tf_T)` if we have a conversion, where the converted declaration `T_CC` may coincide with `T`.  The value `tf_T` is a ''conversion constructor'' for values inhabitating types formed from the original and converted constructor.  The type of these functions is as follows: 
     30The alternatives of `TyCon.TyCon` get a new field `tyConCC :: StatusCC (TyCon, Id)`.  This field is `NoCC` for data constructors for which we have no conversion and `ConvCC (T_CC, iso_T)` if we have a conversion, where the converted declaration `T_CC` may coincide with `T`.  The value `iso_T` is a ''conversion constructor'' for values inhabitating types formed from the original and converted constructor.  The type of these functions is as follows: 
    3131{{{ 
    32 tfTy (T::k1->..->kn->*) = forall _1 .. _n _1_CC .. _n_CC. 
    33   tfTy (_1::k1) -> .. -> tfTy (_n::kn) ->  
    34   (TF (C _1 .. _n) (C_CC _1_CC .. _n_CC)) 
     32isoTy (T::k1->..->kn->*) = forall _1 .. _n _1_CC .. _n_CC. 
     33  isoTy (_1::k1) -> .. -> isoTy (_n::kn) ->  
     34  (C _1 .. _n :<->: C_CC _1_CC .. _n_CC) 
    3535}}} 
    3636(The type variables beginning with underscores are bound here; we add one underscore for each level of kinding.) 
     
    4242The type of the conversion constructor is as follows (using more meaningful type variable names): 
    4343{{{ 
    44 tfTy (T::(*->*)->*) = 
     44isoTy (T::(*->*)->*) = 
    4545  forall f f_CC.  
    4646    (forall a a_CC.  
    47        (TF a a_CC) -> (TF (f a) (f_CC a_CC))) -> 
    48     TF (T f) (T_CC f_CC) 
     47       (a :<->: a_CC) -> (f a :<->: f_CC a_CC)) -> 
     48    T f :<->: T_CC f_CC 
    4949}}} 
    5050The conversion constructor might be implemented as 
    5151{{{ 
    52 tfT tff = TF toT frT 
     52isoT isof = toT :<->: frT 
    5353  where 
    5454    toT (T1 x) = T1 (to (tff tfInt ) x) 
     
    5757    frT (T2 y) = T2 (fr (tff tfBool) y) 
    5858}}} 
    59 where `tfInt` and `tfBool` are the conversion constructors for `Int`s and `Bool`s. 
     59where `isoInt` and `isoBool` are the conversion constructors for `Int`s and `Bool`s. 
    6060 
    61 Moreover, we have a type constructor `(-->)` that represents closures and we assume that the field `tyConCC` of `(->)` has the value `ConvCC ((-->), fr_fun, to_fun)`, where `fr_fun` and `to_fun` are appropriate conversion functions. 
     61Moreover, we represent closures - the converted form of function arrows - as follows: 
     62{{{ 
     63data a :-> b = forall e. !(e -> a -> b) :$ e 
     64 
     65isoArr :: a :<->: a_CC -> b :<->: b_CC -> (a -> b) :<->: (a_CC :-> b_CC) 
     66isoArr (toa :<->: fra) (tob :<->: frb) = toArr :<->: frArr 
     67  where 
     68    toArr f        = const (tob . f . fra) :$ () 
     69    frArr (f :$ e) = frb . f e . toa 
     70}}} 
    6271 
    6372==== Conversion rules ====