Template Haskell: improve lifting for strings
authorsimonpj@microsoft.com <unknown>
Wed, 27 May 2009 18:08:40 +0000 (18:08 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 27 May 2009 18:08:40 +0000 (18:08 +0000)
commit97a8fe8780307e95829034117efa98d2e27109cd
tree8b86da0dd7ea1c3ed50251f85b9e4c2dcf4e8206
parent857847a660defd9f7480894c01f0c70f611c373a
Template Haskell: improve lifting for strings

When you have a (\s::String -> ....[| s |]....), the string
's' is lifted.  We used to get a chain of single-character
Cons nodes, correct but lots and lots of code.

This patch arranges to optimise that to a string literal. It does
so in two places:
  a) In TcExpr, if we know that s::String, we generate liftString directly
  b) In DsMeta, if we find a list of character literals, we convert to
     a string.  This catches a few cases that (a) does not

There an accompanying  patch in the template-haskell package,
adding Language.Haskell.TH.Syntax.liftString
compiler/deSugar/DsMeta.hs
compiler/hsSyn/Convert.lhs
compiler/typecheck/TcExpr.lhs