• simonpj@microsoft.com's avatar
    Fix Trac #2246; overhaul handling of overloaded literals · ecdaf6bc
    simonpj@microsoft.com authored
    The real work of fixing Trac #2246 is to use shortCutLit in
    MatchLit.dsOverLit, so that type information discovered late in the
    day by the type checker can still be exploited during desugaring.
    However, as usual I found myself doing some refactoring along the
    way, to tidy up the handling of overloaded literals.   The main
    change is to split HsOverLit into a record, which in turn uses
    a sum type for the three variants.  This makes the code significantly
    more modular.
    data HsOverLit id
      = OverLit {
    	ol_val :: OverLitVal, 
    	ol_rebindable :: Bool,		-- True <=> rebindable syntax
    					-- False <=> standard syntax
    	ol_witness :: SyntaxExpr id,	-- Note [Overloaded literal witnesses]
    	ol_type :: PostTcType }
    data OverLitVal
      = HsIntegral   !Integer   	-- Integer-looking literals;
      | HsFractional !Rational   	-- Frac-looking literals
      | HsIsString   !FastString 	-- String-looking literals