]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/MIMEType.hs
Optimized as possible as I can.
[Lucu.git] / Network / HTTP / Lucu / MIMEType.hs
index 93b8f1ff38d7aeed4f388432ee5cc8463bb68166..9f653230d3597ae298cdeec99fca07276242b9f6 100644 (file)
@@ -18,9 +18,9 @@ import           Network.HTTP.Lucu.Utils
 -- |@'MIMEType' \"major\" \"minor\" [(\"name\", \"value\")]@
 -- represents \"major\/minor; name=value\".
 data MIMEType = MIMEType {
-      mtMajor  :: String
-    , mtMinor  :: String
-    , mtParams :: [ (String, String) ]
+      mtMajor  :: !String
+    , mtMinor  :: !String
+    , mtParams :: ![ (String, String) ]
     } deriving (Eq)
 
 
@@ -49,23 +49,26 @@ infixl 8 <:>
 maj </> min
     = MIMEType maj min []
 
--- |\<\:\> appends a @(name, value)@ pair to a MIME Type.
+-- |This operator appends a @(name, value)@ pair to a MIME Type.
 (<:>) :: MIMEType -> (String, String) -> MIMEType
 mt@(MIMEType _ _ params) <:> pair
-    = mt {
+    = pair `seq`
+      mt {
         mtParams = mtParams mt ++ [pair]
       }
 
--- |\<\=\> takes two strings and makes a tuple of them. So you can say
--- @\"text\" \<\/\> \"xml\" \<\:\> \"charset\" \<\=\> \"UTF-8\" \<\:\>
--- \"q\" \<\=\> \"0.9\"@ to represent \"text\/xml; charset=UTF-8;
--- q=0.9\".
+-- |This operator takes two strings and makes a tuple of them. So you
+-- can say
+--
+-- > "text" </> "xml" <:> "charset" <=> "UTF-8" <:> "q" <=> "0.9"
+--
+-- to represent \"text\/xml; charset=UTF-8; q=0.9\".
 (<=>) :: String -> String -> (String, String)
 name <=> value = (name, value)
 
 
 mimeTypeP :: Parser MIMEType
-mimeTypeP = allowEOF $
+mimeTypeP = allowEOF $!
             do maj <- token
                char '/'
                min <- token
@@ -82,4 +85,4 @@ mimeTypeP = allowEOF $
                   return (name, value)
 
 mimeTypeListP :: Parser [MIMEType]
-mimeTypeListP = allowEOF $ listOf mimeTypeP
+mimeTypeListP = allowEOF $! listOf mimeTypeP