Commit 54df07fd authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Extended qualification to export specification

parent ad65ed56
......@@ -252,13 +252,10 @@ transModule opts env mdl = (env5, ilCaseComp, dumps)
writeOutput :: Options -> FilePath -> (CompilerEnv, CS.Module) -> IO ()
writeOutput opts fn (env, modul) = do
writeParsed opts fn modul
let (env1, qlfd) = qual opts env modul
let (qlfd, env1) = qual opts env modul
doDump (optDebugOpts opts) (DumpQualified, env1, show $ CS.ppModule qlfd)
writeAbstractCurry opts fn env1 qlfd
when withFlat $ do
-- checkModule checks types, and then transModule introduces new
-- functions (by lambda lifting in 'desugar'). Consequence: The
-- types of the newly introduced functions are not inferred (hsi)
let (env2, il, dumps) = transModule opts env1 qlfd
-- dump intermediate results
mapM_ (doDump (optDebugOpts opts)) dumps
......
......@@ -55,12 +55,12 @@ lift :: Module -> CompilerEnv -> (Module, CompilerEnv)
lift mdl env = (mdl', env { valueEnv = tyEnv' })
where (mdl', tyEnv') = L.lift (valueEnv env) mdl
-- |Fully qualify used constructors and functions
qual :: Options -> CompilerEnv -> Module -> (CompilerEnv, Module)
qual opts env (Module ps m es is ds) = (qualifyEnv opts env, Module ps m es is ds')
where ds' = Q.qual (moduleIdent env) (tyConsEnv env) (valueEnv env) ds
-- |Fully qualify used constructors and functions.
qual :: Options -> CompilerEnv -> Module -> (Module, CompilerEnv)
qual opts env mdl = (mdl', qualifyEnv opts env)
where mdl' = Q.qual (moduleIdent env) (tyConsEnv env) (valueEnv env) mdl
-- |Simplify the source code
-- |Simplify the source code.
simplify :: Bool -> Module -> CompilerEnv -> (Module, CompilerEnv)
simplify flat mdl env = (mdl', env { valueEnv = tyEnv' })
where (mdl', tyEnv') = S.simplify flat (valueEnv env) mdl
......@@ -44,8 +44,25 @@ data QualEnv = QualEnv
type Qual a = a -> R.Reader QualEnv a
qual :: ModuleIdent -> TCEnv -> ValueEnv -> [Decl] -> [Decl]
qual m tcEnv tyEnv ds = R.runReader (mapM qDecl ds) (QualEnv m tcEnv tyEnv)
qual :: ModuleIdent -> TCEnv -> ValueEnv -> Module -> Module
qual m tcEnv tyEnv mdl = R.runReader (qModule mdl) (QualEnv m tcEnv tyEnv)
qModule :: Qual Module
qModule (Module ps m es is ds) = do
es' <- qExportSpec es
ds' <- mapM qDecl ds
return (Module ps m es' is ds')
qExportSpec :: Qual (Maybe ExportSpec)
qExportSpec Nothing = return Nothing
qExportSpec (Just (Exporting p es)) = (Just . Exporting p)
`liftM` mapM qExport es
qExport :: Qual Export
qExport (Export x) = Export `liftM` qIdent x
qExport (ExportTypeWith t cs) = flip ExportTypeWith cs `liftM` qConstr t
qExport (ExportTypeAll t) = ExportTypeAll `liftM` qConstr t
qExport m@(ExportModule _) = return m
qDecl :: Qual Decl
qDecl i@(InfixDecl _ _ _ _) = return i
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment