Permalink
Browse files

fixed forgotten part of OverloadedStrings, pattern match

  • Loading branch information...
1 parent 830d2fe commit fc315b03025c7e76c6fb229681d667473a7f515d @atzedijkstra atzedijkstra committed Oct 18, 2012
Showing with 46 additions and 2 deletions.
  1. +8 −1 EHC/src/ehc/HS/ToEH.cag
  2. +5 −1 EHC/test/regress/99/OverloadedStrings2.hs
  3. +33 −0 EHC/test/regress/99/OverloadedStrings3.hs
View
@@ -1261,9 +1261,16 @@ SEM Pattern
%%][97
Literal_Int r b s -> mke r (ehExpLitInt r b s @sign @litrefnames)
%%]]
-%%[[5
+%%[[5555
Literal_String r s -> foldr (\c p -> ehPatConApp r (@litrefnames !! 0) [mkc r c,p]) (ehPatConApp r (@litrefnames !! 1) []) s
%%]]
+%%[[5
+ Literal_String r s
+%%[[99
+ | ehcOptOverloadedStrings @lhs.opts -> mke r (ehExpLitString @lhs.opts r s @litrefnames)
+%%]]
+ | otherwise -> foldr (\c p -> ehPatConApp r (@litrefnames !! 0) [mkc r c,p]) (ehPatConApp r (@litrefnames !! 1) []) s
+%%]]
%%[[97
Literal_Float r s -> mke r (ehExpLitFloat r s @sign @litrefnames)
%%]]
@@ -12,13 +12,17 @@ import Data.String
x = "aap"
data S = S String deriving Show
+newtype S2 = S2 String deriving Show
instance IsString S where
fromString = S
+instance IsString S2 where
+ fromString = S2
+
main = do
print x
print "noot" -- ambig, should default
print ("mies" :: S)
print ("klaas" :: String)
-
+ print ("vaak" :: S2)
@@ -0,0 +1,33 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+{- ----------------------------------------------------------------------------------------
+ what : overloading of strings, pattern match
+ expected: ok
+---------------------------------------------------------------------------------------- -}
+
+module OverloadedStrings3 where
+
+import Data.String
+
+data S = S String deriving (Eq,Show)
+newtype S2 = S2 String deriving (Eq,Show)
+
+instance IsString S where
+ fromString = S
+
+instance IsString S2 where
+ fromString = S2
+
+x_S :: S
+x_S = "S"
+
+x_S2 :: S2
+x_S2 = "S2"
+
+x_is_S x = case x of
+ "S" -> True
+ _ -> False
+
+main = do
+ print (x_is_S x_S)
+ print (x_is_S x_S2)

0 comments on commit fc315b0

Please sign in to comment.