Changes between Version 1 and Version 2 of Restricted


Ignore:
Timestamp:
Jan 27, 2015 1:14:21 AM (5 years ago)
Author:
GregWeber
Comment:

wrong page name

Legend:

Unmodified
Added
Removed
Modified
  • Restricted

    v1 v2  
    1 A Proposal for Restricted Template Haskell
    2 
    3 Just so we aren't being so negative, we can also call this Macro Template Haskell.
    4 
    5 
    6 == Problem ==
    7 
    8 The major complaints of Template Haskell are that
    9 
    10 * it is difficult to reason about what is going on (reasoning)
    11 * it adds complexity to the build process (building)
    12 
    13 
    14 === Reasoning ===
    15 
    16 The biggest problem for reasoning is actually a lack of visibility into the generated code. There are changes in 7.10 and 7.12 that improve this situation.
    17 
    18 But even if one could easily view the generated code, it would be nice to have a better understanding of the Template Haskell splicing function that creates it without even delving into the source code for the function.
    19 We have a notion of purity in Haskell. When we see a pure function, we already know a lot about it.
    20 But we do not carry this notion into Template Haskell. Any Template Haskell splice can operate in the Q monad, which has access to `runIO`.
    21 So we are violating referential transparency. To make matters worse, what IO means at compile time is not well-defined (for example, cross-compilation, although there is a proposal to address that).
    22 
    23 Because TH can run arbitrary code and [https://github.com/dterei/SafeHaskellExamples/tree/master/thReify break module boundaries], that also makes it impossible for SafeHaskell to deal with.
    24 
    25 
    26 === Building ===
    27 
    28 Template Haskell can make for a complex extra build phase. Recent changes to the linker have improved the situation greatly, but at a minimum it incurs a lot of overhead.
    29 
    30 
    31 == Proposal ==
    32 
    33 We can define different levels of restriction
    34 
    35   * level 1: no runIO
    36   * level 2: no Q Monad (I think we still need newName though). no reify, because that gets into looking outside the module making compilation more difficult and subverting SafeHaskell
    37   * level 3: no mkName
    38 
    39 
    40 === Syntax ===
    41 
    42 We may be out of dollar signs to use for this. Suggestions are very welcome!
    43