- tr :: (MIMEType, [String]) -> [ (String, MIMEType) ]
- tr (mime, exts) = [ (ext, mime) | ext <- exts ]
-
-
-outputExtMapAsHS :: ExtMap -> FilePath -> IO ()
-outputExtMapAsHS extMap fpath
- = let hsModule = HsModule undefined modName (Just exports) imports decls
- modName = Module "Network.HTTP.Lucu.MIMEType.DefaultExtensionMap"
- exports = [HsEVar (UnQual (HsIdent "defaultExtensionMap"))]
- imports = [ HsImportDecl undefined (Module "Network.HTTP.Lucu.MIMEType") False Nothing Nothing
- , HsImportDecl undefined (Module "Data.Map") True (Just (Module "M")) Nothing
- , HsImportDecl undefined (Module "Data.Map") False Nothing (Just (False, [HsIAbs (HsIdent "Map")]))
+ tr ∷ (MIMEType, [Text]) → [ (Text, MIMEType) ]
+ tr (mime, exts) = [ (ext, mime) | ext ← exts ]
+
+-- |@'serializeExtMap' extMap moduleName variableName@ generates a
+-- Haskell source code which contains the following things:
+--
+-- * A definition of module named @moduleName@.
+--
+-- * @variableName ∷ 'ExtMap'@ whose content is a serialization of
+-- @extMap@.
+--
+-- The module "Network.HTTP.Lucu.MIMEType.DefaultExtensionMap" is
+-- surely generated using this function.
+serializeExtMap ∷ ExtMap → String → String → String
+serializeExtMap extMap moduleName variableName
+ = let hsModule = HsModule (⊥) modName (Just exports) imports decls
+ modName = Module moduleName
+ exports = [HsEVar (UnQual (HsIdent variableName))]
+ imports = [ HsImportDecl (⊥) (Module "Network.HTTP.Lucu.MIMEType") False Nothing Nothing
+ , HsImportDecl (⊥) (Module "Network.HTTP.Lucu.MIMEType.Guess") False Nothing Nothing
+ , HsImportDecl (⊥) (Module "Data.Ascii") True (Just (Module "A")) Nothing
+ , HsImportDecl (⊥) (Module "Data.Map") True (Just (Module "M")) Nothing
+ , HsImportDecl (⊥) (Module "Data.Text") True (Just (Module "T")) Nothing