Skip to content

Move HsInteger and HsRat to an extension constructor

Hassan Al-Awwadi requested to merge wip/ttg/lits into master

This patch furthers #21592. HsLit used to have the following two constructors:

HsLit = ... 
  | HsInteger SourceText Integer Type
      -- ^ Genuinely an integer; arises only
      -- from TRANSLATION (overloaded
      -- literals are done with HsOverLit)
  | HsRat FractionalLit Type
      -- ^ Genuinely a rational; arises only from
      -- TRANSLATION (overloaded literals are
      -- done with HsOverLit)

Which carried with them a Type from Ghc.Core.TyCon. As part of TTG we want to cut this edge, and since the comment seem to indicate that these constructors are really made as part of TRANSLATION and are really GHC specific, they have been moved over to extension constructors that only live during the TypeChecker pass.

type instance XXLit         GhcPs = DataConCantHappen
type instance XXLit         GhcRn = DataConCantHappen
type instance XXLit         GhcTc = HsLitTc

data HsLitTc
  = HsInteger SourceText Integer Type
      -- ^ Genuinely an integer; arises only
      -- from TRANSLATION (overloaded
      -- literals are done with HsOverLit)
  | HsRat FractionalLit Type
      -- ^ Genuinely a rational; arises only from
      -- TRANSLATION (overloaded literals are
      -- done with HsOverLit)

A little bit has shuffled around in Ghc.HsToCore.Quote as a result, but honestly those changes just feel like objective improvements to me.

The Changes are small enough that I didn't think a note was necessary, if I'm wrong I can add one 😄

Edited by Hassan Al-Awwadi

Merge request reports