Skip to content
  • Adowrath's avatar
    ttg: Split HsSrcBang, remove ref to DataCon from Syntax.Type · 257d1adc
    Adowrath authored and Marge Bot's avatar Marge Bot committed
    Progress towards #21592
    
    This splits HsSrcBang up, creating the new HsBang within
    `Language.Haskell.Syntax.Basic`. `HsBang` holds the unpackedness
    and strictness information, while `HsSrcBang` only adds the SourceText
    for usage within the compiler directly.
    
    Inside the AST, to preserve the SourceText, it is hidden behind the
    pre-existing extension point `XBindTy`. All other occurrences of
    `HsSrcBang` were adapted to deconstruct the inner `HsBang`, and when
    interacting with the `BindTy` constructor, the hidden `SourceText` is
    extracted/inserted into the `XBindTy` extension point.
    
    `GHC.Core.DataCon` exports both `HsSrcBang` and `HsBang` for
    convenience. A constructor function `mkHsSrcBang` that takes all
    individual components has been added.
    
    Two exceptions has been made though:
    - The `Outputable HsSrcBang` instance is replaced by
      `Outputable HsBang`. While being only GHC-internal, the only place
      it's used is in outputting `HsBangTy` constructors -- which already
      have `HsBang`. It wouldn't make sense to reconstruct a `HsSrcBang` just
      to ignore the `SourceText` anyway.
    - The error `TcRnUnexpectedAnnotation` did not use the `SourceText`,
      so it too now only holds a `HsBang`.
    257d1adc