[commit: ghc] wip/gadtpm: Fixed string handling (f9f62b5)

git at git.haskell.org git at git.haskell.org
Tue Jul 7 16:32:24 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/gadtpm
Link       : http://ghc.haskell.org/trac/ghc/changeset/f9f62b50821e3cc5930da5474499cfeda095b9c5/ghc

>---------------------------------------------------------------

commit f9f62b50821e3cc5930da5474499cfeda095b9c5
Author: George Karachalias <george.karachalias at gmail.com>
Date:   Tue Jul 7 12:11:22 2015 +0200

    Fixed string handling


>---------------------------------------------------------------

f9f62b50821e3cc5930da5474499cfeda095b9c5
 compiler/deSugar/Check.hs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/compiler/deSugar/Check.hs b/compiler/deSugar/Check.hs
index 0957835..8e790d3 100644
--- a/compiler/deSugar/Check.hs
+++ b/compiler/deSugar/Check.hs
@@ -290,10 +290,14 @@ translatePat pat = case pat of
         guard = eqTrueExpr (PmExprEq (PmExprVar var) olit)
     return [VarAbs var, guard]
 
-  LitPat lit -> do
-    var <- mkPmIdSM (hsPatType pat)
-    let guard = eqTrueExpr $ PmExprEq (PmExprVar var) (PmExprLit lit)
-    return [VarAbs var, guard]
+  LitPat lit
+    | HsString src s <- lit -> -- If it is a real string convert it to a list of characters
+        foldr (mkListPmPat charTy) [nilPmPat charTy] <$>
+          translatePatVec (map (LitPat . HsChar src) (unpackFS s))
+    | otherwise -> do
+        var <- mkPmIdSM (hsPatType pat)
+        let guard = eqTrueExpr $ PmExprEq (PmExprVar var) (PmExprLit lit)
+        return [VarAbs var, guard]
 
   PArrPat ps ty -> do
     tidy_ps <-translatePatVec (map unLoc ps)



More information about the ghc-commits mailing list