Fix Trac #2246; overhaul handling of overloaded literals
authorsimonpj@microsoft.com <unknown>
Tue, 6 May 2008 10:25:51 +0000 (10:25 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 6 May 2008 10:25:51 +0000 (10:25 +0000)
commitecdaf6bc29d23bd704df8c65442ee08032a585fc
tree73ebcd573eb5e273caae6fdfe75a1ca4aba2c2a1
parent63a69b6790c0df41533c572bb53bc048efd48ff9
Fix Trac #2246; overhaul handling of overloaded literals

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
compiler/deSugar/Check.lhs
compiler/deSugar/DsMeta.hs
compiler/deSugar/MatchLit.lhs
compiler/hsSyn/HsLit.lhs
compiler/hsSyn/HsUtils.lhs
compiler/parser/RdrHsSyn.lhs
compiler/rename/RnPat.lhs
compiler/typecheck/Inst.lhs
compiler/typecheck/TcHsSyn.lhs
compiler/typecheck/TcPat.lhs