]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/MIMEType/Guess.hs
Many bugfixes
[Lucu.git] / Network / HTTP / Lucu / MIMEType / Guess.hs
index 37a3ad6f25a7f1eb1a35da9e74ac7de01d7224b6..86d7df6ef48277a798bd6e46145f77222097583d 100644 (file)
@@ -1,8 +1,8 @@
 {-# LANGUAGE
     UnicodeSyntax
   #-}
--- |MIME Type guessing by a file extension. This is a poor man's way
--- of guessing MIME Types. It is simple and fast.
+-- |Guessing MIME Types by file extensions. It's not always accurate
+-- but simple and fast.
 --
 -- In general you don't have to use this module directly.
 module Network.HTTP.Lucu.MIMEType.Guess
@@ -33,10 +33,10 @@ import Network.HTTP.Lucu.MIMEType
 import Prelude.Unicode
 import System.FilePath
 
--- |'Map' from extension to 'MIMEType'.
+-- |A 'Map' from file extensions to 'MIMEType's.
 type ExtMap = Map Text MIMEType
 
--- |Guess the MIME Type of file.
+-- |Guess the MIME Type of file.
 guessTypeByFileName ∷ ExtMap → FilePath → Maybe MIMEType
 guessTypeByFileName extMap fpath
     = case takeExtension fpath of
@@ -112,8 +112,8 @@ compile = go (∅) ∘ concat ∘ map tr
 --
 -- * A definition of module named @moduleName@.
 --
--- * @variableName :: 'ExtMap'@ whose content is a serialization of
---   @extMap@.
+-- * @variableName :: 'ExtMap'@ whose content is the serialised
+-- @extMap@.
 --
 -- The module "Network.HTTP.Lucu.MIMEType.DefaultExtensionMap" is
 -- surely generated using this function.
@@ -135,6 +135,7 @@ serializeExtMap extMap moduleName variableName
           decls     = [ TypeSig (⊥) [name variableName]
                                     (TyCon (UnQual (name "ExtMap")))
                       , nameBind (⊥) (name variableName) extMapExp
+                      , InlineSig (⊥) False AlwaysActive (UnQual (name variableName))
                       ]
           comment   = concat [ "{- !!! WARNING !!!\n"
                              , "   This file is automatically generated.\n"
@@ -150,7 +151,7 @@ serializeExtMap extMap moduleName variableName
       record ∷ (Text, MIMEType) → Exp
       record (ext, mime)
           = tuple [ strE (T.unpack ext)
-                  , metaFunction "parseMIMEType" [strE $ mimeToString mime]
+                  , function "parseMIMEType" `app` strE (mimeToString mime)
                   ]
 
       mimeToString ∷ MIMEType → String