@@ -38,26 +38,29 @@ import Language.PureScript.Types
3838moduleToPs :: Module -> Environment -> String
3939moduleToPs (Module _ _ _ _ Nothing) _ = error "Module exports were not elaborated in moduleToPs"
4040moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execWriter $ do
41− let exps = listExports exts
41+ let exps = listRefs exts
4242 tell ["module " ++ runModuleName moduleName ++ (if null exps then "" else " (" ++ exps ++ ")") ++ " where"]
4343 mapM_ declToPs ds
4444 mapM_ exportToPs exts
4545 where
4646
47− listExports :: [DeclarationRef] -> String
48− listExports = intercalate ", " . mapMaybe listExport
47+ listRefs :: [DeclarationRef] -> String
48+ listRefs = intercalate ", " . mapMaybe listRef
4949
50− listExport :: DeclarationRef -> Maybe String
51− listExport (PositionedDeclarationRef _ _ d) = listExport d
52− listExport (TypeRef name Nothing) = Just $ show name ++ "()"
53− listExport (TypeRef name (Just dctors)) = Just $ show name ++ "(" ++ intercalate ", " (map show dctors) ++ ")"
54− listExport (ValueRef name) = Just $ show name
55− listExport (TypeClassRef name) = Just $ show name
56− listExport (ModuleRef name) = Just $ "module " ++ show name
57− listExport _ = Nothing
50+ listRef :: DeclarationRef -> Maybe String
51+ listRef (PositionedDeclarationRef _ _ d) = listRef d
52+ listRef (TypeRef name Nothing) = Just $ show name ++ "()"
53+ listRef (TypeRef name (Just dctors)) = Just $ show name ++ "(" ++ intercalate ", " (map show dctors) ++ ")"
54+ listRef (ValueRef name) = Just $ show name
55+ listRef (TypeClassRef name) = Just $ show name
56+ listRef (ModuleRef name) = Just $ "module " ++ show name
57+ listRef _ = Nothing
5858
5959 declToPs :: Declaration -> Writer [String] ()
60− declToPs (ImportDeclaration mn _ _) = tell ["import " ++ show mn ++ " ()"]
60+ declToPs (ImportDeclaration mn imp Nothing) =
61+ tell ["import " ++ show mn ++ importToPs imp]
62+ declToPs (ImportDeclaration mn imp (Just qual)) =
63+ tell ["import qualified " ++ show mn ++ importToPs imp ++ " as " ++ show qual]
6164 declToPs (FixityDeclaration (Fixity assoc prec) op) =
6265 case find exportsOp exts of
6366 Nothing -> return ()
@@ -70,6 +73,11 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
7073 declToPs (PositionedDeclaration _ com d) = mapM_ commentToPs com >> declToPs d
7174 declToPs _ = return ()
7275
76+ importToPs :: ImportDeclarationType -> String
77+ importToPs Implicit = ""
78+ importToPs (Explicit refs) = " (" ++ listRefs refs ++ ")"
79+ importToPs (Hiding refs) = " hiding (" ++ listRefs refs ++ ")"
80+
7381 commentToPs :: Comment -> Writer [String] ()
7482 commentToPs (LineComment s) = tell ["-- " ++ s]
7583 commentToPs (BlockComment s) = tell ["{- " ++ s ++ " -}"]