@@ -45,6 +45,7 @@ import Control.Applicative
4545import Control.Arrow ((&&&))
4646import Control.Monad.Except
4747import Control.Monad.Reader
48+import Control.Monad.Writer
4849
4950import System.FilePath ((</>))
5051
@@ -55,6 +56,7 @@ import Language.PureScript.DeadCodeElimination as P
5556import Language.PureScript.Environment as P
5657import Language.PureScript.Errors as P
5758import Language.PureScript.Kinds as P
59+import Language.PureScript.Linter as P
5860import Language.PureScript.ModuleDependencies as P
5961import Language.PureScript.Names as P
6062import Language.PureScript.Options as P
@@ -89,26 +91,27 @@ import qualified Paths_purescript as Paths
8991--
9092-- * Pretty-print the generated Javascript
9193--
92−compile :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadReader (Options Compile) m)
94+compile :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadReader (Options Compile) m)
9395 => [Module] -> [String] -> m (String, String, Environment)
9496compile = compile' initEnvironment
9597
96−compile' :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadReader (Options Compile) m)
98+compile' :: (Functor m, Applicative m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadReader (Options Compile) m)
9799 => Environment -> [Module] -> [String] -> m (String, String, Environment)
98100compile' env ms prefix = do
99101 noPrelude <- asks optionsNoPrelude
100102 additional <- asks optionsAdditional
101103 mainModuleIdent <- asks (fmap moduleNameFromString . optionsMain)
102104 (sorted, _) <- sortModules $ map importPrim $ if noPrelude then ms else map importPrelude ms
105+ mapM_ lint sorted
103106 (desugared, nextVar) <- runSupplyT 0 $ desugar sorted
104107 (elaborated, env') <- runCheck' env $ forM desugared $ typeCheckModule mainModuleIdent
105108 regrouped <- createBindingGroupsModule . collapseBindingGroupsModule $ elaborated
106109 let corefn = map (CoreFn.moduleToCoreFn env') regrouped
107− let entryPoints = moduleNameFromString `map` entryPointModules additional
108− let elim = if null entryPoints then corefn else eliminateDeadCode entryPoints corefn
109− let renamed = renameInModules elim
110− let codeGenModuleNames = moduleNameFromString `map` codeGenModules additional
111− let modulesToCodeGen = if null codeGenModuleNames then renamed else filter (\(CoreFn.Module _ mn _ _ _ _) -> mn `elem` codeGenModuleNames) renamed
110+ entryPoints = moduleNameFromString `map` entryPointModules additional
111+ elim = if null entryPoints then corefn else eliminateDeadCode entryPoints corefn
112+ renamed = renameInModules elim
113+ codeGenModuleNames = moduleNameFromString `map` codeGenModules additional
114+ modulesToCodeGen = if null codeGenModuleNames then renamed else filter (\(CoreFn.Module _ mn _ _ _ _) -> mn `elem` codeGenModuleNames) renamed
112115 js <- concat <$> (evalSupplyT nextVar $ T.traverse moduleToJs modulesToCodeGen)
113116 let exts = intercalate "\n" . map (`moduleToPs` env') $ regrouped
114117 js' <- generateMain env' js
@@ -129,7 +132,7 @@ generateMain env js = do
129132-- |
130133-- A type class which collects the IO actions we need to be able to run in "make" mode
131134--
132−class (MonadReader (P.Options P.Make) m, MonadError MultipleErrors m) => MonadMake m where
135+class (MonadReader (P.Options P.Make) m, MonadError MultipleErrors m, MonadWriter MultipleErrors m) => MonadMake m where
133136 -- |
134137 -- Get a file timestamp
135138 --
@@ -178,6 +181,8 @@ make outputDir ms prefix = do
178181
179182 (sorted, graph) <- sortModules $ map importPrim $ if noPrelude then map snd ms else map (importPrelude . snd) ms
180183
184+ mapM_ lint sorted
185+
181186 toRebuild <- foldM (\s (Module _ moduleName' _ _) -> do
182187 let filePath = runModuleName moduleName'
183188
@@ -219,8 +224,8 @@ make outputDir ms prefix = do
219224 regrouped <- createBindingGroups moduleName' . collapseBindingGroups $ elaborated
220225
221226 let mod' = Module coms moduleName' regrouped exps
222− let corefn = CoreFn.moduleToCoreFn env' mod'
223− let [renamed] = renameInModules [corefn]
227+ corefn = CoreFn.moduleToCoreFn env' mod'
228+ [renamed] = renameInModules [corefn]
224229
225230 pjs <- prettyPrintJS <$> moduleToJs renamed
226231 let js = unlines $ map ("// " ++) prefix ++ [pjs]