X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FMIMEType%2FGuess.hs;h=3e3df1631b7af87c29012159681bc2474df5c10f;hb=ca338174155913a969808d7b20193973394e474e;hp=3344f4b7351f1d545dc5a908f40457f65ad34cfe;hpb=05f49fae07dfcac0c039f25c8a51123603918a93;p=Lucu.git diff --git a/Network/HTTP/Lucu/MIMEType/Guess.hs b/Network/HTTP/Lucu/MIMEType/Guess.hs index 3344f4b..3e3df16 100644 --- a/Network/HTTP/Lucu/MIMEType/Guess.hs +++ b/Network/HTTP/Lucu/MIMEType/Guess.hs @@ -17,7 +17,7 @@ module Network.HTTP.Lucu.MIMEType.Guess import Control.Applicative import qualified Data.Ascii as A import Data.Attoparsec.Char8 as P -import qualified Data.Attoparsec.Lazy as AL +import qualified Data.Attoparsec.Lazy as LP import qualified Data.ByteString.Lazy.Char8 as B import qualified Data.Map as M import Data.Map (Map) @@ -45,9 +45,9 @@ guessTypeByFileName !extMap !fpath parseExtMapFile ∷ FilePath → IO ExtMap parseExtMapFile fpath = do file ← B.readFile fpath - case AL.parse extMapP file of - AL.Done _ xs → return $ compile xs - AL.Fail _ _ e → fail ("Failed to parse: " ⧺ fpath ⧺ ": " ⧺ e) + case LP.parse extMapP file of + LP.Done _ xs → return $ compile xs + LP.Fail _ _ e → fail ("Failed to parse: " ⧺ fpath ⧺ ": " ⧺ e) extMapP ∷ Parser [ (MIMEType, [Text]) ] extMapP = do xs ← P.many (comment <|> validLine <|> emptyLine) @@ -115,11 +115,11 @@ serializeExtMap extMap moduleName variableName [] (HsUnGuardedRhs extMapExp) []] ] extMapExp = HsApp (HsVar (Qual (Module "M") (HsIdent "fromList"))) (HsList records) - comment = "{- !!! WARNING !!!\n" - ++ " This file is automatically generated.\n" - ++ " DO NOT EDIT BY HAND OR YOU WILL REGRET -}\n\n" + comment = "{- !!! WARNING !!!\n" + ⧺ " This file is automatically generated.\n" + ⧺ " DO NOT EDIT BY HAND OR YOU WILL REGRET -}\n\n" in - comment ++ prettyPrint hsModule ++ "\n" + comment ⧺ prettyPrint hsModule ⧺ "\n" where records ∷ [HsExp] records = map record $ M.assocs extMap @@ -137,4 +137,7 @@ serializeExtMap extMap moduleName variableName = HsApp (HsVar (UnQual (HsIdent "parseMIMEType"))) (HsParen (HsApp (HsVar (Qual (Module "A") (HsIdent "unsafeFromString"))) - (HsLit (HsString $ A.toString $ printMIMEType mt)))) + (HsLit (HsString $ mimeToString mt)))) + + mimeToString ∷ MIMEType → String + mimeToString = A.toString ∘ A.fromAsciiBuilder ∘ printMIMEType