- mimeToExp :: MIMEType -> HsExp
- mimeToExp (MIMEType maj min params)
- = foldl appendParam (HsInfixApp
- (HsLit (HsString maj))
- (HsQVarOp (UnQual (HsSymbol "</>")))
- (HsLit (HsString min))) params
-
- appendParam :: HsExp -> (String, String) -> HsExp
- appendParam x param
- = HsInfixApp x (HsQVarOp (UnQual (HsSymbol "<:>"))) $ paramToExp param
-
- paramToExp :: (String, String) -> HsExp
- paramToExp (name, value)
- = HsInfixApp
- (HsLit (HsString name))
- (HsQVarOp (UnQual (HsSymbol "<=>")))
- (HsLit (HsString value))
\ No newline at end of file
+ mimeToExp ∷ MIMEType → HsExp
+ mimeToExp mt
+ = HsApp (HsVar (UnQual (HsIdent "parseMIMEType")))
+ (HsParen
+ (HsApp (HsVar (Qual (Module "A") (HsIdent "unsafeFromString")))
+ (HsLit (HsString $ mimeToString mt))))
+
+ mimeToString ∷ MIMEType → String
+ mimeToString = A.toString ∘ A.fromAsciiBuilder ∘ printMIMEType