Changes between Version 21 and Version 22 of DataParallel/ClosureConversion/ClassLess
 Timestamp:
 Apr 27, 2007 5:37:31 AM (9 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

DataParallel/ClosureConversion/ClassLess
v21 v22 21 21 Conversion functions come in pairs, which we wrap with the following data type for convenience: 22 22 {{{ 23 data TF a b = TF {to :: a > b; fr ::b > a}23 data a :<>: b = (:<>:) {to :: a > b, fr ::b > a} 24 24 }}} 25 25 … … 28 28 ==== Preliminaries ==== 29 29 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: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, 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: 31 31 {{{ 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))32 isoTy (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) 35 35 }}} 36 36 (The type variables beginning with underscores are bound here; we add one underscore for each level of kinding.) … … 42 42 The type of the conversion constructor is as follows (using more meaningful type variable names): 43 43 {{{ 44 tfTy (T::(*>*)>*) =44 isoTy (T::(*>*)>*) = 45 45 forall f f_CC. 46 46 (forall a a_CC. 47 ( TF a a_CC) > (TF (f a) (f_CC a_CC))) >48 T F (T f) (T_CC f_CC)47 (a :<>: a_CC) > (f a :<>: f_CC a_CC)) > 48 T f :<>: T_CC f_CC 49 49 }}} 50 50 The conversion constructor might be implemented as 51 51 {{{ 52 tfT tff = TF toTfrT52 isoT isof = toT :<>: frT 53 53 where 54 54 toT (T1 x) = T1 (to (tff tfInt ) x) … … 57 57 frT (T2 y) = T2 (fr (tff tfBool) y) 58 58 }}} 59 where ` tfInt` and `tfBool` are the conversion constructors for `Int`s and `Bool`s.59 where `isoInt` and `isoBool` are the conversion constructors for `Int`s and `Bool`s. 60 60 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. 61 Moreover, we represent closures  the converted form of function arrows  as follows: 62 {{{ 63 data a :> b = forall e. !(e > a > b) :$ e 64 65 isoArr :: a :<>: a_CC > b :<>: b_CC > (a > b) :<>: (a_CC :> b_CC) 66 isoArr (toa :<>: fra) (tob :<>: frb) = toArr :<>: frArr 67 where 68 toArr f = const (tob . f . fra) :$ () 69 frArr (f :$ e) = frb . f e . toa 70 }}} 62 71 63 72 ==== Conversion rules ====