X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FConvert.lhs;h=56ec2d763d44a46bbcc29904c82106633b5d9fb1;hb=c7517d84fe15a202029d5a77dfaf51c87e7e7234;hp=b87c18c56dfd60c332bc83486a8b4a597a6d92f0;hpb=74fadd40c435b13da51695f0ec490e03ccce56e4;p=ghc-hetmet.git diff --git a/compiler/hsSyn/Convert.lhs b/compiler/hsSyn/Convert.lhs index b87c18c..56ec2d7 100644 --- a/compiler/hsSyn/Convert.lhs +++ b/compiler/hsSyn/Convert.lhs @@ -568,10 +568,16 @@ if it isn't a literal string allCharLs :: [TH.Exp] -> Maybe String -- Note [Converting strings] -allCharLs (LitE (CharL c) : xs) - | Just cs <- allCharLs xs = Just (c:cs) -allCharLs [] = Just [] -allCharLs _ = Nothing +-- NB: only fire up this setup for a non-empty list, else +-- there's a danger of returning "" for [] :: [Int]! +allCharLs xs + = case xs of + LitE (CharL c) : ys -> go [c] ys + _ -> Nothing + where + go cs [] = Just (reverse cs) + go cs (LitE (CharL c) : ys) = go (c:cs) ys + go _ _ = Nothing cvtLit :: Lit -> CvtM HsLit cvtLit (IntPrimL i) = do { force i; return $ HsIntPrim i }