git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Parallel builds
commit6d1b5ec3af12812810701b766a12f7c9aceabe75 authorPhil Freeman <paf31@cantab.net> dateSat 26 Sep 2015, 17:14 (11 years ago) parenta88ca7b
7 files changed+285−142
LICENSE+167−68 license-generator/generate+3 psci/PSCi.hs+4−4 purescript.cabal+4−1 src/Language/PureScript/AST/Traversals.hs+3−3 src/Language/PureScript/Make.hs+95−59 src/Language/PureScript/ModuleDependencies.hs+9−7
LICENSE+167−68
@@ -31,6 +31,7 @@ PureScript uses the following Haskell library packages. Their license files foll
3131 array
3232 attoparsec
3333 base
34+ binary
3435 blaze-builder
3536 bower-json
3637 boxes
@@ -45,9 +46,10 @@ PureScript uses the following Haskell library packages. Their license files foll
4546 haskeline
4647 integer-gmp
4748 language-javascript
49+ lifted-base
50+ monad-control
4851 mtl
4952 nats
50− old-locale
5153 optparse-applicative
5254 parsec
5355 pattern-arrows
@@ -59,12 +61,14 @@ PureScript uses the following Haskell library packages. Their license files foll
5961 scientific
6062 semigroups
6163 split
64+ stm
6265 syb
6366 template-haskell
6467 terminfo
6568 text
6669 time
6770 transformers
71+ transformers-base
6872 transformers-compat
6973 unix
7074 unordered-containers
@@ -449,6 +453,39 @@ base LICENSE file:
449453
450454 -----------------------------------------------------------------------------
451455
456+binary LICENSE file:
457+
458+ Copyright (c) Lennart Kolmodin
459+
460+ All rights reserved.
461+
462+ Redistribution and use in source and binary forms, with or without
463+ modification, are permitted provided that the following conditions
464+ are met:
465+
466+ 1. Redistributions of source code must retain the above copyright
467+ notice, this list of conditions and the following disclaimer.
468+
469+ 2. Redistributions in binary form must reproduce the above copyright
470+ notice, this list of conditions and the following disclaimer in the
471+ documentation and/or other materials provided with the distribution.
472+
473+ 3. Neither the name of the author nor the names of his contributors
474+ may be used to endorse or promote products derived from this software
475+ without specific prior written permission.
476+
477+ THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
478+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
479+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
480+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
481+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
482+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
483+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
484+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
485+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
486+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
487+ POSSIBILITY OF SUCH DAMAGE.
488+
452489blaze-builder LICENSE file:
453490
454491 Copyright Jasper Van der Jeugt 2010, Simon Meier 2010 & 2011
@@ -967,6 +1004,70 @@ language-javascript LICENSE file:
9671004 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
9681005 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9691006
1007+lifted-base LICENSE file:
1008+
1009+ Copyright © 2010-2012, Bas van Dijk, Anders Kaseorg
1010+ All rights reserved.
1011+
1012+ Redistribution and use in source and binary forms, with or without
1013+ modification, are permitted provided that the following conditions are
1014+ met:
1015+
1016+ • Redistributions of source code must retain the above copyright
1017+ notice, this list of conditions and the following disclaimer.
1018+
1019+ • Redistributions in binary form must reproduce the above copyright
1020+ notice, this list of conditions and the following disclaimer in the
1021+ documentation and/or other materials provided with the distribution.
1022+
1023+ • Neither the name of the author nor the names of other contributors
1024+ may be used to endorse or promote products derived from this
1025+ software without specific prior written permission.
1026+
1027+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1028+ “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1029+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1030+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1031+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1032+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1033+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1034+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1035+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1036+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1037+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1038+
1039+monad-control LICENSE file:
1040+
1041+ Copyright © 2010, Bas van Dijk, Anders Kaseorg
1042+ All rights reserved.
1043+
1044+ Redistribution and use in source and binary forms, with or without
1045+ modification, are permitted provided that the following conditions are
1046+ met:
1047+
1048+ • Redistributions of source code must retain the above copyright
1049+ notice, this list of conditions and the following disclaimer.
1050+
1051+ • Redistributions in binary form must reproduce the above copyright
1052+ notice, this list of conditions and the following disclaimer in the
1053+ documentation and/or other materials provided with the distribution.
1054+
1055+ • Neither the name of the author nor the names of other contributors
1056+ may be used to endorse or promote products derived from this
1057+ software without specific prior written permission.
1058+
1059+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1060+ “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1061+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1062+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1063+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1064+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1065+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1066+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1067+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1068+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1069+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1070+
9701071mtl LICENSE file:
9711072
9721073 The Glasgow Haskell Compiler License
@@ -1034,72 +1135,6 @@ nats LICENSE file:
10341135 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
10351136 POSSIBILITY OF SUCH DAMAGE.
10361137
1037−old-locale LICENSE file:
1038−
1039− This library (libraries/base) is derived from code from two
1040− sources:
1041−
1042− * Code from the GHC project which is largely (c) The University of
1043− Glasgow, and distributable under a BSD-style license (see below),
1044−
1045− * Code from the Haskell 98 Report which is (c) Simon Peyton Jones
1046− and freely redistributable (but see the full license for
1047− restrictions).
1048−
1049− The full text of these licenses is reproduced below. Both of the
1050− licenses are BSD-style or compatible.
1051−
1052− -----------------------------------------------------------------------------
1053−
1054− The Glasgow Haskell Compiler License
1055−
1056− Copyright 2004, The University Court of the University of Glasgow.
1057− All rights reserved.
1058−
1059− Redistribution and use in source and binary forms, with or without
1060− modification, are permitted provided that the following conditions are met:
1061−
1062− - Redistributions of source code must retain the above copyright notice,
1063− this list of conditions and the following disclaimer.
1064−
1065− - Redistributions in binary form must reproduce the above copyright notice,
1066− this list of conditions and the following disclaimer in the documentation
1067− and/or other materials provided with the distribution.
1068−
1069− - Neither name of the University nor the names of its contributors may be
1070− used to endorse or promote products derived from this software without
1071− specific prior written permission.
1072−
1073− THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
1074− GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
1075− INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1076− FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1077− UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
1078− FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1079− DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1080− SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1081− CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1082− LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1083− OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
1084− DAMAGE.
1085−
1086− -----------------------------------------------------------------------------
1087−
1088− Code derived from the document "Report on the Programming Language
1089− Haskell 98", is distributed under the following license:
1090−
1091− Copyright (c) 2002 Simon Peyton Jones
1092−
1093− The authors intend this Report to belong to the entire Haskell
1094− community, and so we grant permission to copy and distribute it for
1095− any purpose, provided that it is reproduced in its entirety,
1096− including this Notice. Modified versions of this Report may also be
1097− copied and distributed for any purpose, provided that the modified
1098− version is clearly presented as such, and that it does not claim to
1099− be a definition of the Haskell 98 Language.
1100−
1101− -----------------------------------------------------------------------------
1102−
11031138optparse-applicative LICENSE file:
11041139
11051140 Copyright (c) 2012, Paolo Capriotti
@@ -1450,6 +1485,40 @@ split LICENSE file:
14501485 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
14511486 SUCH DAMAGE.
14521487
1488+stm LICENSE file:
1489+
1490+ The Glasgow Haskell Compiler License
1491+
1492+ Copyright 2004, The University Court of the University of Glasgow.
1493+ All rights reserved.
1494+
1495+ Redistribution and use in source and binary forms, with or without
1496+ modification, are permitted provided that the following conditions are met:
1497+
1498+ - Redistributions of source code must retain the above copyright notice,
1499+ this list of conditions and the following disclaimer.
1500+
1501+ - Redistributions in binary form must reproduce the above copyright notice,
1502+ this list of conditions and the following disclaimer in the documentation
1503+ and/or other materials provided with the distribution.
1504+
1505+ - Neither name of the University nor the names of its contributors may be
1506+ used to endorse or promote products derived from this software without
1507+ specific prior written permission.
1508+
1509+ THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
1510+ GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
1511+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1512+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1513+ UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
1514+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1515+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1516+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1517+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1518+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1519+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
1520+ DAMAGE.
1521+
14531522syb LICENSE file:
14541523
14551524 This library (libraries/syb) is derived from code from several
@@ -1674,6 +1743,36 @@ transformers LICENSE file:
16741743 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
16751744 DAMAGE.
16761745
1746+transformers-base LICENSE file:
1747+
1748+ Copyright (c) 2011, Mikhail Vorozhtsov, Bas van Dijk
1749+ All rights reserved.
1750+
1751+ Redistribution and use in source and binary forms, with or without
1752+ modification, are permitted provided that the following conditions are met:
1753+
1754+ - Redistributions of source code must retain the above copyright notice,
1755+ this list of conditions and the following disclaimer.
1756+ - Redistributions in binary form must reproduce the above copyright
1757+ notice, this list of conditions and the following disclaimer in the
1758+ documentation and/or other materials provided with the distribution.
1759+ - Neither the names of the copyright owners nor the names of the
1760+ contributors may be used to endorse or promote products derived
1761+ from this software without specific prior written permission.
1762+
1763+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1764+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1765+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1766+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1767+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1768+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1769+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1770+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1771+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1772+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1773+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1774+
1775+
16771776transformers-compat LICENSE file:
16781777
16791778 Copyright 2012 Edward Kmett
@@ -1836,7 +1935,7 @@ vector LICENSE file:
18361935
18371936void LICENSE file:
18381937
1839− Copyright 2013 Edward Kmett
1938+ Copyright 2015 Edward Kmett
18401939
18411940 All rights reserved.
18421941
license-generator/generate+3
@@ -9,6 +9,9 @@ set -e # exit on error
99set -u # exit on undefined variable
1010set -o pipefail # propagate nonzero exit codes through pipelines
1111
12+export LC_CTYPE=C
13+export LANG=C
14+
1215if ! which cabal-dependency-licenses >/dev/null; then
1316 echo "$0: the program 'cabal-dependency-licenses' is required." >&2
1417 echo "$0: see Hackage: https://hackage.haskell.org/package/cabal-dependency-licenses" >&2
psci/PSCi.hs+4−4
@@ -263,10 +263,10 @@ makeIO f io = do
263263
264264make :: PSCiState -> [(Either P.RebuildPolicy FilePath, P.Module)] -> P.Make P.Environment
265265make PSCiState{..} ms = P.make actions' (map snd (psciLoadedModules ++ ms))
266− where
267− filePathMap = M.fromList $ (first P.getModuleName . swap) `map` (psciLoadedModules ++ ms)
268− actions = P.buildMakeActions modulesDir filePathMap psciForeignFiles False
269− actions' = actions { P.progress = const (return ()) }
266+ where
267+ filePathMap = M.fromList $ (first P.getModuleName . swap) `map` (psciLoadedModules ++ ms)
268+ actions = P.buildMakeActions modulesDir filePathMap psciForeignFiles False
269+ actions' = actions { P.progress = const (return ()) }
270270
271271-- |
272272-- Takes a value declaration and evaluates it with the current state.
purescript.cabal+4−1
@@ -32,6 +32,9 @@ source-repository head
3232
3333library
3434 build-depends: base >=4.6 && <5,
35+ lifted-base >= 0.2.3 && < 0.2.4,
36+ monad-control >= 1.0.0.0 && < 1.1,
37+ transformers-base >= 0.4.0 && < 0.5,
3538 containers -any,
3639 unordered-containers -any,
3740 dlist -any,
@@ -175,7 +178,7 @@ executable psc
175178 main-is: Main.hs
176179 buildable: True
177180 hs-source-dirs: psc
178− ghc-options: -Wall -O2 -fno-warn-unused-do-bind
181+ ghc-options: -Wall -O2 -fno-warn-unused-do-bind -threaded -rtsopts "-with-rtsopts=-N"
179182
180183executable psci
181184 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
src/Language/PureScript/AST/Traversals.hs+3−3
@@ -216,10 +216,10 @@ everythingOnValues (<>) f g h i j = (f', g', h', i', j')
216216 f' d = f d
217217
218218 g' v@(UnaryMinus v1) = g v <> g' v1
219− g' v@(BinaryNoParens op v1 v2) = g v <> g op <> g' v1 <> g' v2
219+ g' v@(BinaryNoParens op v1 v2) = g v <> g' op <> g' v1 <> g' v2
220220 g' v@(Parens v1) = g v <> g' v1
221− g' v@(OperatorSection op (Left v1)) = g v <> g op <> g' v1
222− g' v@(OperatorSection op (Right v1)) = g v <> g op <> g' v1
221+ g' v@(OperatorSection op (Left v1)) = g v <> g' op <> g' v1
222+ g' v@(OperatorSection op (Right v1)) = g v <> g' op <> g' v1
223223 g' v@(ArrayLiteral vs) = foldl (<>) (g v) (map g' vs)
224224 g' v@(ObjectLiteral vs) = foldl (<>) (g v) (map (g' . snd) vs)
225225 g' v@(ObjectConstructor vs) = foldl (<>) (g v) (map g' (mapMaybe snd vs))
src/Language/PureScript/Make.hs+95−59
@@ -19,6 +19,8 @@
1919{-# LANGUAGE RankNTypes #-}
2020{-# LANGUAGE RecordWildCards #-}
2121{-# LANGUAGE ScopedTypeVariables #-}
22+{-# LANGUAGE MultiParamTypeClasses #-}
23+{-# LANGUAGE TypeFamilies #-}
2224{-# LANGUAGE CPP #-}
2325
2426module Language.PureScript.Make
@@ -39,29 +41,31 @@ module Language.PureScript.Make
3941#if __GLASGOW_HASKELL__ < 710
4042import Control.Applicative
4143#endif
42−import Control.Arrow ((&&&))
4344import Control.Monad
4445import Control.Monad.Error.Class (MonadError(..))
4546import Control.Monad.Trans.Except
4647import Control.Monad.Reader
4748import Control.Monad.Writer.Strict
4849import Control.Monad.Supply
50+import Control.Monad.Base (MonadBase(..))
51+import Control.Monad.Trans.Control (MonadBaseControl(..))
4952
50−import Data.Function (on)
51−import Data.Either (partitionEithers)
52−import Data.List (sortBy, groupBy, foldl')
53−import Data.Maybe (fromMaybe)
53+import Control.Concurrent.Lifted as C
54+
55+import Data.List (foldl')
56+import Data.Maybe (fromMaybe, catMaybes)
5457import Data.Time.Clock
5558import Data.String (fromString)
5659import Data.Foldable (for_)
5760#if __GLASGOW_HASKELL__ < 710
5861import Data.Traversable (traverse)
5962#endif
63+import Data.Traversable (for)
6064import Data.Version (showVersion)
6165import Data.Aeson (encode, decode)
6266import qualified Data.ByteString.Lazy as B
63−import qualified Data.Map as M
6467import qualified Data.Set as S
68+import qualified Data.Map as M
6569
6670import System.Directory
6771 (doesFileExist, getModificationTime, createDirectoryIfMissing)
@@ -150,65 +154,89 @@ data RebuildPolicy
150154-- If timestamps have not changed, the externs file can be used to provide the module's types without
151155-- having to typecheck the module again.
152156--
153−make :: forall m. (Functor m, Applicative m, Monad m, MonadReader Options m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
157+make :: forall m. (Functor m, Applicative m, Monad m, MonadBaseControl IO m, MonadReader Options m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
154158 => MakeActions m
155159 -> [Module]
156160 -> m Environment
157161make MakeActions{..} ms = do
158− (sorted, graph) <- sortModules $ map importPrim ms
159− toRebuild <- foldM (\s (Module _ _ moduleName' _ _) -> do
160− inputTimestamp <- getInputTimestamp moduleName'
161− outputTimestamp <- getOutputTimestamp moduleName'
162− return $ case (inputTimestamp, outputTimestamp) of
163− (Right (Just t1), Just t2) | t1 < t2 -> s
164− (Left RebuildNever, Just _) -> s
165− _ -> S.insert moduleName' s) S.empty sorted
166−
167− (externs, toBuild) <- partitionEithers <$> rebuildIfNecessary (reverseDependencies graph) toRebuild sorted
168− for_ toBuild lint
169− (desugared, nextVar) <- runSupplyT 0 $ desugar externs toBuild
170− let env = foldl' (flip applyExternsFileToEnvironment) initEnvironment externs
171− evalSupplyT nextVar $ go env desugared
172− where
162+ (sorted, graph) <- sortModules ms
163+
164+ barriers <- zip (map getModuleName sorted) <$> replicateM (length ms) ((,) <$> C.newEmptyMVar <*> C.newEmptyMVar)
165+
166+ for_ sorted $ \m -> fork $ do
167+ let deps = fromMaybe (error "make: module not found in dependency graph.") (lookup (getModuleName m) graph)
168+ buildModule barriers (importPrim m) (deps `inOrderOf` map getModuleName sorted)
169+
170+ -- Wait for all threads to complete, and collect errors.
171+ errors <- catMaybes <$> for barriers (takeMVar . snd . snd)
172+
173+ -- All threads have completed, rethrow any caught errors.
174+ unless (null errors) $ throwError (mconcat errors)
175+
176+ -- Bundle up all the externs and return them as an Environment
177+ externs <- sequence <$> for barriers (takeMVar . fst . snd)
178+ return $ foldl' (flip applyExternsFileToEnvironment) initEnvironment (fromMaybe (error "make: externs were missing but no errors reported.") externs)
173179
174− go :: Environment -> [Module] -> SupplyT m Environment
175− go env [] = return env
176− go env (m@(Module ss coms moduleName' _ exps) : ms') = do
177− lift . progress $ CompilingModule moduleName'
178− (checked@(Module _ _ _ elaborated _), env') <- lift . runCheck' env $ typeCheckModule Nothing m
179− checkExhaustiveModule env' checked
180− regrouped <- createBindingGroups moduleName' . collapseBindingGroups $ elaborated
181− let mod' = Module ss coms moduleName' regrouped exps
182− corefn = CF.moduleToCoreFn env' mod'
183− [renamed] = renameInModules [corefn]
184− exts = encode $ moduleToExternsFile mod' env'
185− codegen renamed env' exts
186− go env' ms'
187−
188− rebuildIfNecessary :: M.Map ModuleName [ModuleName] -> S.Set ModuleName -> [Module] -> m [Either ExternsFile Module]
189− rebuildIfNecessary graph = rebuildIfNecessary'
190− where
191− rebuildIfNecessary' :: S.Set ModuleName -> [Module] -> m [Either ExternsFile Module]
192− rebuildIfNecessary' _ [] = return []
193− rebuildIfNecessary' toRebuild (m@(Module _ _ moduleName' _ _) : ms')
194− | moduleName' `S.member` toRebuild = rebuild toRebuild m moduleName' ms'
195− rebuildIfNecessary' toRebuild (m@(Module _ _ moduleName' _ _) : ms') = do
196− (_, externsJson) <- readExterns moduleName'
197− case decode externsJson of
198− Just externs
199− | efVersion externs == showVersion Paths.version -> (Left externs :) <$> rebuildIfNecessary' toRebuild ms'
200− _ -> rebuild toRebuild m moduleName' ms'
201−
202− rebuild :: S.Set ModuleName -> Module -> ModuleName -> [Module] -> m [Either ExternsFile Module]
203− rebuild toRebuild m moduleName ms' = do
204− let deps = fromMaybe [] $ moduleName `M.lookup` graph
205− (Right m :) <$> rebuildIfNecessary' (toRebuild `S.union` S.fromList deps) ms'
206−
207−reverseDependencies :: ModuleGraph -> M.Map ModuleName [ModuleName]
208−reverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ]
209180 where
210− combine :: (Ord a) => [(a, b)] -> M.Map a [b]
211− combine = M.fromList . map ((fst . head) &&& map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst)
181+ -- Sort a list so its elements appear in the same order as in another list.
182+ inOrderOf :: (Ord a) => [a] -> [a] -> [a]
183+ inOrderOf xs ys = let s = S.fromList xs in filter (`S.member` s) ys
184+
185+ buildModule :: [(ModuleName, (C.MVar (Maybe ExternsFile), C.MVar (Maybe MultipleErrors)))] -> Module -> [ModuleName] -> m ()
186+ buildModule barriers m@(Module _ _ moduleName _ _) deps = flip catchError (markComplete Nothing . Just) $ do
187+ outputTimestamp <- getOutputTimestamp moduleName
188+ dependencyTimestamp <- maximumMaybe <$> mapM (fmap shouldExist . getOutputTimestamp) deps
189+ inputTimestamp <- getInputTimestamp moduleName
190+
191+ let shouldRebuild = case (inputTimestamp, dependencyTimestamp, outputTimestamp) of
192+ (Right (Just t1), Just t3, Just t2) -> t1 > t2 || t3 > t2
193+ (Right (Just t1), Nothing, Just t2) -> t1 > t2
194+ (Left RebuildNever, _, Just _) -> False
195+ _ -> True
196+
197+ exts <- if shouldRebuild
198+ then do
199+ mexterns <- sequence <$> mapM (readMVar . fst . fromMaybe (error "make: no barrier") . flip lookup barriers) deps
200+
201+ for mexterns $ \externs -> do
202+ progress $ CompilingModule moduleName
203+ let env = foldl' (flip applyExternsFileToEnvironment) initEnvironment externs
204+ lint m
205+ ([desugared], nextVar) <- runSupplyT 0 $ desugar externs [m]
206+ (checked@(Module ss coms _ elaborated exps), env') <- runCheck' env $ typeCheckModule Nothing desugared
207+ checkExhaustiveModule env' checked
208+ regrouped <- createBindingGroups moduleName . collapseBindingGroups $ elaborated
209+ let mod' = Module ss coms moduleName regrouped exps
210+ corefn = CF.moduleToCoreFn env' mod'
211+ [renamed] = renameInModules [corefn]
212+ exts = moduleToExternsFile mod' env'
213+ evalSupplyT nextVar $ codegen renamed env' $ encode exts
214+ return exts
215+ else do
216+ mexts <- decodeExterns . snd <$> readExterns moduleName
217+ return $ Just $ fromMaybe (error "make: externs files are out of date. Try 'rm output/*/externs.json'.") mexts
218+
219+ markComplete exts Nothing
220+ where
221+ markComplete :: Maybe ExternsFile -> Maybe MultipleErrors -> m ()
222+ markComplete externs errors = do
223+ putMVar (fst $ fromMaybe (error "make: no barrier") $ lookup moduleName barriers) externs
224+ putMVar (snd $ fromMaybe (error "make: no barrier") $ lookup moduleName barriers) errors
225+
226+ maximumMaybe :: (Ord a) => [a] -> Maybe a
227+ maximumMaybe [] = Nothing
228+ maximumMaybe xs = Just $ maximum xs
229+
230+ -- Make sure a dependency exists
231+ shouldExist :: Maybe UTCTime -> UTCTime
232+ shouldExist (Just t) = t
233+ shouldExist _ = error "make: dependency should already have been built."
234+
235+ decodeExterns :: B.ByteString -> Maybe ExternsFile
236+ decodeExterns bs = do
237+ externs <- decode bs
238+ guard $ efVersion externs == showVersion Paths.version
239+ return externs
212240
213241-- |
214242-- Add an import declaration for a module if it does not already explicitly import it.
@@ -231,6 +259,14 @@ importPrim = addDefaultImport (ModuleName [ProperName C.prim])
231259newtype Make a = Make { unMake :: ReaderT Options (WriterT MultipleErrors (ExceptT MultipleErrors IO)) a }
232260 deriving (Functor, Applicative, Monad, MonadIO, MonadError MultipleErrors, MonadWriter MultipleErrors, MonadReader Options)
233261
262+instance MonadBase IO Make where
263+ liftBase = liftIO
264+
265+instance MonadBaseControl IO Make where
266+ type StM Make a = Either MultipleErrors (a, MultipleErrors)
267+ liftBaseWith f = Make $ liftBaseWith $ \q -> f (q . unMake)
268+ restoreM = Make . restoreM
269+
234270-- |
235271-- Execute a 'Make' monad, returning either errors, or the result of the compile plus any warnings.
236272--
src/Language/PureScript/ModuleDependencies.hs+9−7
@@ -23,20 +23,17 @@ import Control.Monad.Error.Class (MonadError(..))
2323
2424import Data.Graph
2525import Data.List (nub)
26−import Data.Maybe (mapMaybe)
26+import Data.Maybe (fromMaybe, mapMaybe)
2727
2828import Language.PureScript.AST
2929import Language.PureScript.Names
3030import Language.PureScript.Types
3131import Language.PureScript.Errors
3232
33−-- |
34−-- A list of modules with their dependencies
35−--
33+-- | A list of modules with their transitive dependencies
3634type ModuleGraph = [(ModuleName, [ModuleName])]
3735
38−-- |
39−-- Sort a collection of modules based on module dependencies.
36+-- | Sort a collection of modules based on module dependencies.
4037--
4138-- Reports an error if the module graph contains a cycle.
4239--
@@ -44,7 +41,12 @@ sortModules :: (MonadError MultipleErrors m) => [Module] -> m ([Module], ModuleG
4441sortModules ms = do
4542 let verts = map (\m@(Module _ _ _ ds _) -> (m, getModuleName m, nub (concatMap usedModules ds))) ms
4643 ms' <- mapM toModule $ stronglyConnComp verts
47− let moduleGraph = map (\(_, mn, deps) -> (mn, deps)) verts
44+ let (graph, fromVertex, toVertex) = graphFromEdges verts
45+ moduleGraph = do (_, mn, _) <- verts
46+ let v = fromMaybe (error "sortModules: vertex not found") (toVertex mn)
47+ deps = reachable graph v
48+ toKey i = case fromVertex i of (_, key, _) -> key
49+ return (mn, filter (/= mn) (map toKey deps))
4850 return (ms', moduleGraph)
4951
5052-- |