Skip to content
  • Rodrigo Mesquita's avatar
    7975202b
    TTG: Rework and improve splices · 7975202b
    Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
    This commit redefines the structure of Splices in the AST.
    
    We get rid of `HsSplice` which used to represent typed and untyped
    splices, quasi quotes, and the result of splicing either an expression,
    a type or a pattern.
    
    Instead we have `HsUntypedSplice` which models an untyped splice or a
    quasi quoter, which works in practice just like untyped splices.
    
    The `HsExpr` constructor `HsSpliceE` which used to be constructed with
    an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The
    former is directly constructed with an `HsExpr` and the latter now takes
    an `HsUntypedSplice`.
    
    Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now
    take an `HsUntypedSplice` instead of a `HsSplice` (remember only
    /untyped splices/ can be spliced as types or patterns).
    
    The result of splicing an expression, type, or pattern is now
    comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`,
    `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType
    GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult
    (HsExpr GhcRn)`
    
    Overall the TTG extension points are now better used to
    make invalid states unrepresentable and model the progression between
    stages better.
    
    See Note [Lifecycle of an untyped splice, and PendingRnSplice]
    and Note [Lifecycle of an typed splice, and PendingTcSplice] for more
    details.
    
    Updates haddock submodule
    
    Fixes #21263
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
    7975202b
    TTG: Rework and improve splices
    Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
    This commit redefines the structure of Splices in the AST.
    
    We get rid of `HsSplice` which used to represent typed and untyped
    splices, quasi quotes, and the result of splicing either an expression,
    a type or a pattern.
    
    Instead we have `HsUntypedSplice` which models an untyped splice or a
    quasi quoter, which works in practice just like untyped splices.
    
    The `HsExpr` constructor `HsSpliceE` which used to be constructed with
    an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The
    former is directly constructed with an `HsExpr` and the latter now takes
    an `HsUntypedSplice`.
    
    Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now
    take an `HsUntypedSplice` instead of a `HsSplice` (remember only
    /untyped splices/ can be spliced as types or patterns).
    
    The result of splicing an expression, type, or pattern is now
    comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`,
    `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType
    GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult
    (HsExpr GhcRn)`
    
    Overall the TTG extension points are now better used to
    make invalid states unrepresentable and model the progression between
    stages better.
    
    See Note [Lifecycle of an untyped splice, and PendingRnSplice]
    and Note [Lifecycle of an typed splice, and PendingTcSplice] for more
    details.
    
    Updates haddock submodule
    
    Fixes #21263
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
Loading