Changes between Version 64 and Version 65 of DataParallel/ClosureConversion/ClassLess


Ignore:
Timestamp:
May 7, 2007 10:58:02 AM (7 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/ClosureConversion/ClassLess

    v64 v65  
    33 
    44The 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 
     8We represent closures by 
     9{{{ 
     10data a :-> b = forall e. !(e -> a -> b) :$ e 
     11}}} 
     12and define closure creation and application as 
     13{{{ 
     14lam :: (a -> b) -> (a :-> b) 
     15lam f = const f :$ () 
     16 
     17($:) :: (a :-> b) -> a -> b 
     18(f :$ e) $: x = f e x 
     19}}} 
     20So, we have `(->)_CC == (:->)`. 
     21 
     22=== Overview and invariants === 
     23 
     24The meta-function "`^`", written postfix, converts from normal code to closure-converted code.  
     25 
     26 * For each function `f::ty`, create a closure-converted function `f_cc::ty^`, where `ty^` is the closure-converted version of `ty`.   
     27 
     28 * For each data type `T`, create a closure-converted 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 
     32Invariants: 
     33{{{ 
     34  e :: ty     implies       e^ :: ty^ 
     35 
     36  to iso<ty> :: ty -> ty^ 
     37  fr iso<ty> :: ty^ -> ty 
     38}}} 
     39 
    540 
    641=== Conversion status === 
     
    2055=== Converting types === 
    2156 
    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 creation and application as 
    29 {{{ 
    30 lam :: (a -> b) -> (a :-> b) 
    31 lam f = const f :$ () 
    32  
    33 ($:) :: (a :-> b) -> a -> b 
    34 (f :$ e) $: x = f e x 
    35 }}} 
    36 So, we have `(->)_CC == (:->)`. 
    3757 
    3858==== Conversion of type terms ====