Changes between Version 8 and Version 9 of DataParallel/ClosureConversion


Ignore:
Timestamp:
Apr 20, 2007 12:24:39 PM (7 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/ClosureConversion

    v8 v9  
    2525data T_CC = MkT_CC (Clo Int Int) 
    2626}}} 
     27Note how this also introduces new constructor names. 
    2728 
    2829''Classes.'' 
     
    5455Here the result of `foo` needs to be converted before we can call `appT` in `bar`.  In other words, we need conversion functions between converted and unconverted versions of data types. 
    5556 
    56 ==== An alternative: one-the-fly closure conversion ==== 
     57A problem becomes apparent when we change the example slightly: 
     58{{{ 
     59-- unconverted code 
     60data T = MkT (Int -> Int) 
     61foo = MkT ((+) (1::Int)) 
     62 
     63-- converted code 
     64appT :: T -> Int -> Int 
     65appT (MkT f) x = f x 
     66 
     67bar = appT foo 
     68}}} 
     69Now, we don't have a converted version of T available.  Converting it on the fly might be problematic.  If `appT` and `bar` reside in different modules, we convert `T` twice and need to make sure the two versions are compatible.  Even worse, the module holding `bar` may only import `T` abstractly and hence can neither derive the converted version of `T` nor can it infer  suitable conversion functions.  In this case, we have to give up on converting `appT foo` (and maybe all of `bar`). 
     70 
     71Alternatively, we might decide that we do not convert the case expression in `appT`'s Core code that scrutinises its first argument.  Then, the type of the converted function would be 
     72{{{ 
     73appT_CC :: Clo T (Clo Int Int) 
     74}}} 
     75i.e., it still uses `T`, not `T_CC`.  As callers of `appT_CC` also will '''not''' have a converted version of `T` available, everything still fits together nicely.  This appears to be a simpler scheme than on-the-fly type conversions. 
     76 
     77The same should work for classes and their dictionaries.  If we can use unconverted functions in converted code, we can also select from unconverted dictionaries and use the unconverted methods. 
    5778 
    5879----