Skip to content

Commit fde48d7

Browse files
committed
Merge pull request purescript#1325 from purescript/1276
Fix purescript#1276
2 parents 3af0231 + b3c6682 commit fde48d7

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

psc/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ compile (PSCMakeOptions inputGlob inputForeignGlob outputDir opts usePrefix) = d
6868
hPutStrLn stderr (P.prettyPrintMultipleWarnings (P.optionsVerboseErrors opts) warnings)
6969
let filePathMap = M.fromList $ map (\(fp, P.Module _ mn _ _) -> (mn, fp)) ms
7070
makeActions = buildMakeActions outputDir filePathMap foreigns usePrefix
71-
e <- runMake opts $ P.make makeActions ms
71+
e <- runMake opts $ P.make makeActions (map snd ms)
7272
case e of
7373
Left errs -> do
7474
hPutStrLn stderr (P.prettyPrintMultipleErrors (P.optionsVerboseErrors opts) errs)
7575
exitFailure
7676
Right (_, warnings') -> do
7777
when (P.nonEmpty warnings') $
78-
putStrLn (P.prettyPrintMultipleWarnings (P.optionsVerboseErrors opts) warnings')
78+
hPutStrLn stderr (P.prettyPrintMultipleWarnings (P.optionsVerboseErrors opts) warnings')
7979
exitSuccess
8080

8181
readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]

psci/PSCi.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
module PSCi where
2222

2323
import Data.Foldable (traverse_)
24-
import Data.List (intercalate, nub, sort, isPrefixOf)
24+
import Data.List (intercalate, nub, sort)
2525
import Data.Traversable (traverse)
2626
import Data.Tuple (swap)
2727
import Data.Version (showVersion)
@@ -259,11 +259,11 @@ makeIO f io = do
259259
either (throwError . P.singleError . f) return e
260260

261261
make :: PSCiState -> [(Either P.RebuildPolicy FilePath, P.Module)] -> P.Make P.Environment
262-
make PSCiState{..} ms = P.make actions' (psciLoadedModules ++ ms)
262+
make PSCiState{..} ms = P.make actions' (map snd (psciLoadedModules ++ ms))
263263
where
264264
filePathMap = M.fromList $ (first P.getModuleName . swap) `map` (psciLoadedModules ++ ms)
265265
actions = P.buildMakeActions modulesDir filePathMap psciForeignFiles False
266-
actions' = actions { P.progress = \s -> unless ("Compiling $PSCI" `isPrefixOf` s) $ liftIO . putStrLn $ s }
266+
actions' = actions { P.progress = const (return ()) }
267267

268268
-- |
269269
-- Takes a value declaration and evaluates it with the current state.

src/Language/PureScript/Make.hs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ data RebuildPolicy
136136
--
137137
make :: forall m. (Functor m, Applicative m, Monad m, MonadReader Options m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
138138
=> MakeActions m
139-
-> [(Either RebuildPolicy FilePath, Module)]
139+
-> [Module]
140140
-> m Environment
141141
make MakeActions{..} ms = do
142-
(sorted, graph) <- sortModules $ map (importPrim . snd) ms
142+
(sorted, graph) <- sortModules $ map importPrim ms
143143
mapM_ lint sorted
144144
toRebuild <- foldM (\s (Module _ moduleName' _ _) -> do
145145
inputTimestamp <- getInputTimestamp moduleName'
@@ -282,6 +282,8 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
282282
foreignFile = outputDir </> filePath </> "foreign.js"
283283
prefix = ["Generated by psc version " ++ showVersion Paths.version | usePrefix]
284284
js = unlines $ map ("// " ++) prefix ++ [pjs]
285+
verboseErrorsEnabled <- asks optionsVerboseErrors
286+
when verboseErrorsEnabled $ progress $ "Writing " ++ jsFile
285287
writeTextFile jsFile js
286288
maybe (return ()) (writeTextFile foreignFile . snd) $ mn `M.lookup` foreigns
287289
writeTextFile externsFile exts
@@ -295,16 +297,11 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
295297
traverse (const $ getModificationTime path) $ guard exists
296298

297299
readTextFile :: FilePath -> Make String
298-
readTextFile path = do
299-
verboseErrorsEnabled <- asks optionsVerboseErrors
300-
makeIO (const (SimpleErrorWrapper $ CannotReadFile path)) $ do
301-
when verboseErrorsEnabled $ putStrLn $ "Reading " ++ path
302-
readFile path
300+
readTextFile path = makeIO (const (SimpleErrorWrapper $ CannotReadFile path)) $ readFile path
303301

304302
writeTextFile :: FilePath -> String -> Make ()
305303
writeTextFile path text = makeIO (const (SimpleErrorWrapper $ CannotWriteFile path)) $ do
306304
mkdirp path
307-
putStrLn $ "Writing " ++ path
308305
writeFile path text
309306
where
310307
mkdirp :: FilePath -> IO ()

tests/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ compile :: [FilePath] -> M.Map P.ModuleName (FilePath, P.ForeignJS) -> IO (Eithe
115115
compile inputFiles foreigns = runTest $ do
116116
fs <- liftIO $ readInput inputFiles
117117
ms <- P.parseModulesFromFiles id fs
118-
P.make (makeActions foreigns) (map (\(k, v) -> (Right k, v)) ms)
118+
P.make (makeActions foreigns) (map snd ms)
119119

120120
assert :: [FilePath] ->
121121
M.Map P.ModuleName (FilePath, P.ForeignJS) ->

0 commit comments

Comments
 (0)