X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FMIMEType.hs;h=93b8f1ff38d7aeed4f388432ee5cc8463bb68166;hp=bd799e0d58f840dc9cb700be51e33e19e6496057;hb=175e14b3b144537644e65ca76f1fca5c56fd44e9;hpb=b340a77fa7bd051dd13a41d0a5b1ad30220bc6b6 diff --git a/Network/HTTP/Lucu/MIMEType.hs b/Network/HTTP/Lucu/MIMEType.hs index bd799e0..93b8f1f 100644 --- a/Network/HTTP/Lucu/MIMEType.hs +++ b/Network/HTTP/Lucu/MIMEType.hs @@ -1,10 +1,13 @@ +-- #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 @@ -12,7 +15,8 @@ import Network.HTTP.Lucu.Parser 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 @@ -36,25 +40,28 @@ instance Show MIMEType where 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