--- |\<\:\> appends a @(name, value)@ pair to a MIME Type.
-(<:>) :: MIMEType -> (String, String) -> MIMEType
-mt@(MIMEType _ _ params) <:> pair
- = 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\".
-(<=>) :: String -> String -> (String, String)
-name <=> value = (name, value)
-
-
-mimeTypeP :: Parser MIMEType
-mimeTypeP = allowEOF $
- do maj <- token
- char '/'
- min <- token
- params <- many paramP
- return $ MIMEType maj min params
+-- |Parse 'MIMEType' from an 'Ascii'. This function throws an
+-- exception for parse error.
+parseMIMEType ∷ Ascii → MIMEType
+{-# INLINEABLE parseMIMEType #-}
+parseMIMEType str
+ = case parseOnly p $ A.toByteString str of
+ Right t → t
+ Left err → error ("unparsable MIME Type: " ⧺ A.toString str ⧺ ": " ⧺ err)