]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Parser/Http.hs
Supplession of unneeded imports
[Lucu.git] / Network / HTTP / Lucu / Parser / Http.hs
index ae09522b3807c65c6bca94dc6355727e52f81c38..cb21d299418671fccfe308d13a6befe3f75ed9be 100644 (file)
@@ -16,8 +16,6 @@ module Network.HTTP.Lucu.Parser.Http
     )
     where
 
-import qualified Data.ByteString.Lazy.Char8 as B
-import           Data.ByteString.Lazy.Char8 (ByteString)
 import           Data.List
 import           Network.HTTP.Lucu.Parser
 
@@ -26,11 +24,30 @@ isCtl :: Char -> Bool
 isCtl c
     | c <  '\x1f' = True
     | c >= '\x7f' = True
-    | otherwise  = False
+    | otherwise   = False
 
 -- |@'isSeparator' c@ is True iff c is one of HTTP separators.
 isSeparator :: Char -> Bool
-isSeparator c = elem c "()<>@,;:\\\"/[]?={} \t"
+isSeparator '('  = True
+isSeparator ')'  = True
+isSeparator '<'  = True
+isSeparator '>'  = True
+isSeparator '@'  = True
+isSeparator ','  = True
+isSeparator ';'  = True
+isSeparator ':'  = True
+isSeparator '\\' = True
+isSeparator '"'  = True
+isSeparator '/'  = True
+isSeparator '['  = True
+isSeparator ']'  = True
+isSeparator '?'  = True
+isSeparator '='  = True
+isSeparator '{'  = True
+isSeparator '}'  = True
+isSeparator ' '  = True
+isSeparator '\t' = True
+isSeparator _    = False
 
 -- |@'isChar' c@ is True iff @c <= 0x7f@.
 isChar :: Char -> Bool
@@ -41,21 +58,23 @@ isChar c
 -- |@'isToken' c@ is equivalent to @not ('isCtl' c || 'isSeparator'
 -- c)@
 isToken :: Char -> Bool
-isToken c = not (isCtl c || isSeparator c)
+isToken c = c `seq`
+            not (isCtl c || isSeparator c)
 
 -- |@'listOf' p@ is similar to @'Network.HTTP.Lucu.Parser.sepBy' p
 -- ('Network.HTTP.Lucu.Parser.char' \',\')@ but it allows any
 -- occurrences of LWS before and after each tokens.
 listOf :: Parser a -> Parser [a]
-listOf p = do many lws
-              sepBy p (do many lws
-                          char ','
-                          many lws)
+listOf p = p `seq`
+           do many lws
+              sepBy p $! do many lws
+                            char ','
+                            many lws
 
 -- |'token' is equivalent to @'Network.HTTP.Lucu.Parser.many1' $
 -- 'Network.HTTP.Lucu.Parser.satisfy' 'isToken'@
 token :: Parser String
-token = many1 $ satisfy isToken
+token = many1 $! satisfy isToken
 
 -- |'lws' is an HTTP LWS: @'Network.HTTP.Lucu.Parser.crlf'?
 -- ('Network.HTTP.Lucu.Parser.sp' | 'Network.HTTP.Lucu.Parser.ht')+@