Jelajahi Sumber

Fixed bugs in case insensitive parsers

Marcos Dumay de Medeiros 8 tahun lalu
induk
melakukan
2396a0ab29
1 mengubah file dengan 4 tambahan dan 5 penghapusan
  1. 4 5
      src/Data/Attoparsec/ByteString/Char8/Extras.hs

+ 4 - 5
src/Data/Attoparsec/ByteString/Char8/Extras.hs

@@ -28,7 +28,6 @@ import qualified Data.ByteString.Base64 as B64
 import qualified Codec.Binary.UTF8.String as UTF8
 import qualified Data.ByteString as BS
 
-
 utf8bs :: String -> ByteString
 utf8bs = BS.pack . UTF8.encode
 
@@ -97,7 +96,7 @@ parseShow (s:ss) = ((string . utf8bs . show $ s) *> return s) <|> parseShow ss
 -- | Like parseShow, but case insensitive.
 parseShowCI :: Show a => [a] -> Parser a
 parseShowCI [] = failParser
-parseShowCI (s:ss) = ((stringCI . utf8bs . show $ s) *> return s) <|> parseShow ss
+parseShowCI (s:ss) = ((A.stringCI . utf8bs . show $ s) *> return s) <|> parseShowCI ss
 
 {- |
 Given a list of options and a printing function, returns the first option that is
@@ -105,12 +104,12 @@ printed like the input.
 -}
 parsePrintable :: (a -> String) -> [a] -> Parser a
 parsePrintable _ [] = failParser
-parsePrintable f (s:ss) = ((stringCI . utf8bs . f $ s) *> return s) <|> parsePrintable f ss
+parsePrintable f (s:ss) = ((string . utf8bs . f $ s) *> return s) <|> parsePrintable f ss
 
 -- | Like parsePrintable, but case insensitive
 parsePrintableCI :: (a -> String) -> [a] -> Parser a
 parsePrintableCI _ [] = failParser
-parsePrintableCI f (s:ss) = ((stringCI . utf8bs . f $ s) *> return s) <|> parsePrintable f ss
+parsePrintableCI f (s:ss) = ((A.stringCI . utf8bs . f $ s) *> return s) <|> parsePrintableCI f ss
 
 -- | Acts like parseShow, trying every possible value
 parseEnum :: (Enum a, Bounded a, Show a) => Parser a
@@ -122,7 +121,7 @@ parseEnum = let
 parseEnumCI :: (Enum a, Bounded a, Show a) => Parser a
 parseEnumCI = let
   l = [minBound .. maxBound]
-  in parseShow l
+  in parseShowCI l
 
 -- | Consumes base64 encoded text, returning its binary decoded value.
 decodeBase64 :: Parser ByteString