+-- #prune
+
+-- |Manipulation of MIME Types.
module Network.HTTP.Lucu.MIMEType
( MIMEType(..)
- , (+/+) -- String -> String -> MIMEType
- , (+:+) -- MIMEType -> (String, String) -> MIMEType
- , (+=+) -- String -> String -> (String, String)
- , mimeTypeP -- Parser MIMEType
- , mimeTypeListP -- Parser [MIMEType]
+ , (</>)
+ , (<:>)
+ , (<=>)
+ , mimeTypeP
+ , mimeTypeListP
)
where
import Network.HTTP.Lucu.Parser.Http
import Network.HTTP.Lucu.Utils
-
+-- |@'MIMEType' \"major\" \"minor\" [(\"name\", \"value\")]@
+-- represents \"major\/minor; name=value\".
data MIMEType = MIMEType {
mtMajor :: String
, mtMinor :: String
value
-infix 9 +/+, +=+
-infixl 8 +:+
-
+infix 9 </>, <=>
+infixl 8 <:>
-(+/+) :: String -> String -> MIMEType
-maj +/+ min
+-- |@\"major\" \<\/\> \"minor\"@ constructs a MIME Type
+-- \"major\/minor\".
+(</>) :: String -> String -> MIMEType
+maj </> min
= MIMEType maj min []
-
-(+:+) :: MIMEType -> (String, String) -> MIMEType
-mt@(MIMEType _ _ params) +:+ pair
+-- |\<\:\> appends a @(name, value)@ pair to a MIME Type.
+(<:>) :: MIMEType -> (String, String) -> MIMEType
+mt@(MIMEType _ _ params) <:> pair
= mt {
mtParams = mtParams mt ++ [pair]
}
-
-(+=+) :: String -> String -> (String, String)
-name +=+ value = (name, value)
-
+-- |\<\=\> 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