]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Request.hs
Cosmetic changes suggested by hlint
[Lucu.git] / Network / HTTP / Lucu / Request.hs
index 1645b5bc60df3f97e6ae4e77074a6bab09eefd5a..044ba2241dbd039dc373710ef473adc23eccf6d8 100644 (file)
@@ -1,4 +1,4 @@
--- #prune
+{-# OPTIONS_HADDOCK prune #-}
 
 -- |Definition of things related on HTTP request.
 --
@@ -10,8 +10,6 @@ module Network.HTTP.Lucu.Request
     )
     where
 
-import qualified Data.ByteString.Lazy.Char8 as B
-import           Data.ByteString.Lazy.Char8 (ByteString)
 import           Network.HTTP.Lucu.Headers
 import           Network.HTTP.Lucu.HttpVersion
 import           Network.HTTP.Lucu.Parser
@@ -28,16 +26,16 @@ data Method = OPTIONS
             | DELETE
             | TRACE
             | CONNECT
-            | ExtensionMethod String
+            | ExtensionMethod !String
               deriving (Eq, Show)
 
 -- |This is the definition of HTTP reqest.
 data Request
     = Request {
-        reqMethod  :: Method
-      , reqURI     :: URI
-      , reqVersion :: HttpVersion
-      , reqHeaders :: Headers
+        reqMethod  :: !Method
+      , reqURI     :: !URI
+      , reqVersion :: !HttpVersion
+      , reqHeaders :: !Headers
       }
     deriving (Show, Eq)
 
@@ -69,23 +67,23 @@ requestLineP = do method <- methodP
 
 
 methodP :: Parser Method
-methodP = (let methods = [ ("OPTIONS", OPTIONS)
-                         , ("GET"    , GET    )
-                         , ("HEAD"   , HEAD   )
-                         , ("POST"   , POST   )
-                         , ("PUT"    , PUT    )
-                         , ("DELETE" , DELETE )
-                         , ("TRACE"  , TRACE  )
-                         , ("CONNECT", CONNECT)
-                         ]
-           in foldl (<|>) (fail "") $ map (\ (str, mth)
-                                           -> string str >> return mth) methods)
+methodP = ( let methods = [ ("OPTIONS", OPTIONS)
+                          , ("GET"    , GET    )
+                          , ("HEAD"   , HEAD   )
+                          , ("POST"   , POST   )
+                          , ("PUT"    , PUT    )
+                          , ("DELETE" , DELETE )
+                          , ("TRACE"  , TRACE  )
+                          , ("CONNECT", CONNECT)
+                          ]
+            in choice $ map (\ (str, mth)
+                                 -> string str >> return mth) methods )
           <|>
-          token >>= return . ExtensionMethod
+          fmap ExtensionMethod token
 
 
 uriP :: Parser URI
 uriP = do str <- many1 $ satisfy (\ c -> not (isCtl c || c == ' '))
           case parseURIReference str of
-            Nothing  -> fail ""
+            Nothing  -> failP
             Just uri -> return uri
\ No newline at end of file