Changes between Version 49 and Version 50 of DataParallel/ClosureConversion/ClassLess
 Timestamp:
 May 1, 2007 6:27:09 AM (8 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

DataParallel/ClosureConversion/ClassLess
v49 v50 14 14 2. The converted variant `T_CC` coincides with `T` (e.g., because `T` neither directly nor indirectly involves arrows). 15 15 3. The converted variant `T_CC` differs from `T`. 16 In the last two cases, we also have a ''conversion constructor'' `isoT` whose type and function is described below. 17 16 18 An 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. 17 19 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 26 20 === Converting types === 21 22 ==== The closure type ==== 23 24 We represent closures by 25 {{{ 26 data a :> b = forall e. !(e > a > b) :$ e 27 }}} 28 and define closure application as 29 {{{ 30 ($:) :: (a :> b) > a > b 31 (f :$ e) $: x = f e x 32 }}} 33 So, we have `(>)_CC == (:>)`. 34 35 ==== Conversion of type terms ==== 27 36 28 37 We determine the converted type `t^` of `t` as follows: … … 50 59 51 60 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 63 To 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 67 Conversion functions come in pairs, which we wrap with the following data type for convenience: 68 {{{ 69 data a :<>: b = (:<>:) {to :: a > b, fr ::b > a} 70 }}} 71 The functions witness the isomorphism between the two representations, as usual. 72 73 ==== Types of convercion constructors ==== 74 75 The type of a conversion constructor depends on the kind of the converted type constructor: 59 76 {{{ 60 77 isoTy (t::k1>k2) = forall a a_CC. … … 68 85 data T (f::*>*) = T1 (f Int)  T2 (f Bool) 69 86 }}} 70 The type of the conversion constructor is as follows (using more meaningful type variable names):87 The type of the conversion constructor is as follows : 71 88 {{{ 72 89 isoTy (T::(*>*)>*) = … … 80 97 isoT isof = toT :<>: frT 81 98 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) 86 103 }}} 87 104 where `isoInt` and `isoBool` are the conversion constructors for `Int`s and `Bool`s. 88 105 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 106 Moreover, the conversion constructor for function arrows is 107 {{{ 93 108 isoArr :: a :<>: a_CC  argument conversion 94 109 > b :<>: b_CC  result conversion … … 99 114 frArr (f :$ e) = frb . f e . toa 100 115 }}} 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 122 In the latter case, there is also a conversion constructor `isoT` between values inhabitating types formed from the original and converted constructor. 108 123 109 124 ==== Conversion rules ====