Changes between Version 64 and Version 65 of DataParallel/ClosureConversion/ClassLess
 Timestamp:
 May 7, 2007 10:58:02 AM (8 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

DataParallel/ClosureConversion/ClassLess
v64 v65 3 3 4 4 The following scheme approaches the problem of mixing converted and unconverted code from the point of view of GHC's Core representation, avoiding the use of classes as much as possible. In particular, the scheme gracefully handles any declarations that themselves cannot be converted, but occur in a converted module. The two essential ideas are that (1) we move between converted and unconverted values/code using a conversion isomorphism and (2) we treat unconverted declarations differently depending on whether or not they involve arrows; e.g., the definition of `Int` by way of unboxed values (which we cannot convert) doesn't prevent us from using `Int`s ''as is'' in converted code. 5 6 ==== The closure type ==== 7 8 We represent closures by 9 {{{ 10 data a :> b = forall e. !(e > a > b) :$ e 11 }}} 12 and define closure creation and application as 13 {{{ 14 lam :: (a > b) > (a :> b) 15 lam f = const f :$ () 16 17 ($:) :: (a :> b) > a > b 18 (f :$ e) $: x = f e x 19 }}} 20 So, we have `(>)_CC == (:>)`. 21 22 === Overview and invariants === 23 24 The metafunction "`^`", written postfix, converts from normal code to closureconverted code. 25 26 * For each function `f::ty`, create a closureconverted function `f_cc::ty^`, where `ty^` is the closureconverted version of `ty`. 27 28 * For each data type `T`, create a closureconverted data type `T_CC`, whose constructors use `(:>)` instead of `(>)`. 29 30 * The value `iso<ty>` is a pair of functions, converting to and fro between `ty` and `ty^`. 31 32 Invariants: 33 {{{ 34 e :: ty implies e^ :: ty^ 35 36 to iso<ty> :: ty > ty^ 37 fr iso<ty> :: ty^ > ty 38 }}} 39 5 40 6 41 === Conversion status === … … 20 55 === Converting types === 21 56 22 ==== The closure type ====23 24 We represent closures by25 {{{26 data a :> b = forall e. !(e > a > b) :$ e27 }}}28 and define closure creation and application as29 {{{30 lam :: (a > b) > (a :> b)31 lam f = const f :$ ()32 33 ($:) :: (a :> b) > a > b34 (f :$ e) $: x = f e x35 }}}36 So, we have `(>)_CC == (:>)`.37 57 38 58 ==== Conversion of type terms ====