Skip to content

Commit c992da5

Browse files
authored
Merge pull request #2 from wclr/make-cutoff
Make cutoff
2 parents ebcfc20 + a49b446 commit c992da5

27 files changed

Lines changed: 1927 additions & 467 deletions

app/Command/Compile.hs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ import Language.PureScript qualified as P
1616
import Language.PureScript.CST qualified as CST
1717
import Language.PureScript.Errors.JSON (JSONResult(..), toJSONErrors)
1818
import Language.PureScript.Glob (toInputGlobs, PSCGlobs(..), warnFileTypeNotFound)
19-
import Language.PureScript.Make (buildMakeActions, inferForeignModules, runMake)
19+
import Language.PureScript.Make (buildMakeActions, inferForeignModules, progressWithFile, printProgress, runMake)
2020
import Options.Applicative qualified as Opts
2121
import SharedCLI qualified
2222
import System.Console.ANSI qualified as ANSI
2323
import System.Exit (exitSuccess, exitFailure)
24-
import System.Directory (getCurrentDirectory)
24+
import System.FilePath ((</>))
25+
import System.Directory (createDirectoryIfMissing, getCurrentDirectory)
2526
import System.IO (hPutStr, stderr, stdout)
2627
import System.IO.UTF8 (readUTF8FilesT)
2728

@@ -68,12 +69,19 @@ compile PSCMakeOptions{..} = do
6869
]
6970
exitFailure
7071
moduleFiles <- readUTF8FilesT input
72+
73+
_ <- createDirectoryIfMissing True pscmOutputDir
74+
let logFile = pscmOutputDir </> "compile.log"
75+
let cleanFile = True
76+
7177
(makeErrors, makeWarnings) <- runMake pscmOpts $ do
7278
ms <- CST.parseModulesFromFiles id moduleFiles
7379
let filePathMap = M.fromList $ map (\(fp, pm) -> (P.getModuleName $ CST.resPartial pm, Right fp)) ms
7480
foreigns <- inferForeignModules filePathMap
75-
let makeActions = buildMakeActions pscmOutputDir filePathMap foreigns pscmUsePrefix
76-
P.make makeActions (map snd ms)
81+
logProgress <- progressWithFile logFile cleanFile
82+
let makeActions = (buildMakeActions pscmOutputDir filePathMap foreigns pscmUsePrefix)
83+
{ P.progress = (*>) <$> printProgress <*> logProgress }
84+
P.make_ makeActions (map snd ms)
7785
printWarningsAndErrors (P.optionsVerboseErrors pscmOpts) pscmJSONErrors moduleFiles makeWarnings makeErrors
7886
exitSuccess
7987

purescript.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ library
335335
Language.PureScript.Make.Actions
336336
Language.PureScript.Make.BuildPlan
337337
Language.PureScript.Make.Cache
338+
Language.PureScript.Make.ExternsDiff
338339
Language.PureScript.Make.Monad
339340
Language.PureScript.ModuleDependencies
340341
Language.PureScript.Names

src/Language/PureScript/AST/Binders.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Language.PureScript.AST.Binders where
77
import Prelude
88

99
import Control.DeepSeq (NFData)
10+
import Codec.Serialise (Serialise)
1011
import GHC.Generics (Generic)
1112
import Language.PureScript.AST.SourcePos (SourceSpan)
1213
import Language.PureScript.AST.Literals (Literal(..))
@@ -64,7 +65,7 @@ data Binder
6465
-- A binder with a type annotation
6566
--
6667
| TypedBinder SourceType Binder
67-
deriving (Show, Generic, NFData)
68+
deriving (Show, Generic, NFData, Serialise)
6869

6970
-- Manual Eq and Ord instances for `Binder` were added on 2018-03-05. Comparing
7071
-- the `SourceSpan` values embedded in some of the data constructors of `Binder`

src/Language/PureScript/AST/Declarations.hs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ data TypeSearch
5050
-- ^ Record fields that are available on the first argument to the typed
5151
-- hole
5252
}
53-
deriving (Show, Generic, NFData)
53+
deriving (Show, Generic, NFData, Serialise)
5454

5555
onTypeSearchTypes :: (SourceType -> SourceType) -> TypeSearch -> TypeSearch
5656
onTypeSearchTypes f = runIdentity . onTypeSearchTypesM (Identity . f)
@@ -90,7 +90,7 @@ data ErrorMessageHint
9090
| MissingConstructorImportForCoercible (Qualified (ProperName 'ConstructorName))
9191
| PositionedError (NEL.NonEmpty SourceSpan)
9292
| RelatedPositions (NEL.NonEmpty SourceSpan)
93-
deriving (Show, Generic, NFData)
93+
deriving (Show, Generic, NFData, Serialise)
9494

9595
-- | Categories of hints
9696
data HintCategory
@@ -112,7 +112,7 @@ data UnknownsHint
112112
= NoUnknowns
113113
| Unknowns
114114
| UnknownsWithVtaRequiringArgs (NEL.NonEmpty (Qualified Ident, [[Text]]))
115-
deriving (Show, Generic, NFData)
115+
deriving (Show, Generic, NFData, Serialise)
116116

117117
-- |
118118
-- A module declaration, consisting of comments about the module, a module name,
@@ -165,7 +165,7 @@ importPrim =
165165
. addDefaultImport (Qualified ByNullSourcePos primModName)
166166

167167
data NameSource = UserNamed | CompilerNamed
168-
deriving (Show, Generic, NFData, Serialise)
168+
deriving (Eq, Show, Generic, NFData, Serialise)
169169

170170
-- |
171171
-- An item in a list of explicit imports or exports
@@ -323,7 +323,7 @@ data RoleDeclarationData = RoleDeclarationData
323323
{ rdeclSourceAnn :: !SourceAnn
324324
, rdeclIdent :: !(ProperName 'TypeName)
325325
, rdeclRoles :: ![Role]
326-
} deriving (Show, Eq, Generic, NFData)
326+
} deriving (Show, Eq, Generic, NFData, Serialise)
327327

328328
-- | A type declaration assigns a type to an identifier, eg:
329329
--
@@ -334,7 +334,7 @@ data TypeDeclarationData = TypeDeclarationData
334334
{ tydeclSourceAnn :: !SourceAnn
335335
, tydeclIdent :: !Ident
336336
, tydeclType :: !SourceType
337-
} deriving (Show, Eq, Generic, NFData)
337+
} deriving (Show, Eq, Generic, NFData, Serialise)
338338

339339
getTypeDeclaration :: Declaration -> Maybe TypeDeclarationData
340340
getTypeDeclaration (TypeDeclaration d) = Just d
@@ -356,7 +356,7 @@ data ValueDeclarationData a = ValueDeclarationData
356356
-- ^ Whether or not this value is exported/visible
357357
, valdeclBinders :: ![Binder]
358358
, valdeclExpression :: !a
359-
} deriving (Show, Functor, Generic, NFData, Foldable, Traversable)
359+
} deriving (Show, Functor, Generic, NFData, Foldable, Traversable, Serialise)
360360

361361
getValueDeclaration :: Declaration -> Maybe (ValueDeclarationData [GuardedExpr])
362362
getValueDeclaration (ValueDeclaration d) = Just d
@@ -370,7 +370,7 @@ data DataConstructorDeclaration = DataConstructorDeclaration
370370
{ dataCtorAnn :: !SourceAnn
371371
, dataCtorName :: !(ProperName 'ConstructorName)
372372
, dataCtorFields :: ![(Ident, SourceType)]
373-
} deriving (Show, Eq, Generic, NFData)
373+
} deriving (Show, Eq, Generic, NFData, Serialise)
374374

375375
mapDataCtorFields :: ([(Ident, SourceType)] -> [(Ident, SourceType)]) -> DataConstructorDeclaration -> DataConstructorDeclaration
376376
mapDataCtorFields f DataConstructorDeclaration{..} = DataConstructorDeclaration { dataCtorFields = f dataCtorFields, .. }
@@ -445,13 +445,13 @@ data Declaration
445445
-- declaration, while the second @SourceAnn@ serves as the
446446
-- annotation for the type class and its arguments.
447447
| TypeInstanceDeclaration SourceAnn SourceAnn ChainId Integer (Either Text Ident) [SourceConstraint] (Qualified (ProperName 'ClassName)) [SourceType] TypeInstanceBody
448-
deriving (Show, Generic, NFData)
448+
deriving (Show, Generic, NFData, Serialise)
449449

450450
data ValueFixity = ValueFixity Fixity (Qualified (Either Ident (ProperName 'ConstructorName))) (OpName 'ValueOpName)
451-
deriving (Eq, Ord, Show, Generic, NFData)
451+
deriving (Eq, Ord, Show, Generic, NFData, Serialise)
452452

453453
data TypeFixity = TypeFixity Fixity (Qualified (ProperName 'TypeName)) (OpName 'TypeOpName)
454-
deriving (Eq, Ord, Show, Generic, NFData)
454+
deriving (Eq, Ord, Show, Generic, NFData, Serialise)
455455

456456
pattern ValueFixityDeclaration :: SourceAnn -> Fixity -> Qualified (Either Ident (ProperName 'ConstructorName)) -> OpName 'ValueOpName -> Declaration
457457
pattern ValueFixityDeclaration sa fixity name op = FixityDeclaration sa (Left (ValueFixity fixity name op))
@@ -462,7 +462,7 @@ pattern TypeFixityDeclaration sa fixity name op = FixityDeclaration sa (Right (T
462462
data InstanceDerivationStrategy
463463
= KnownClassStrategy
464464
| NewtypeStrategy
465-
deriving (Show, Generic, NFData)
465+
deriving (Show, Generic, NFData, Serialise)
466466

467467
-- | The members of a type class instance declaration
468468
data TypeInstanceBody
@@ -472,7 +472,7 @@ data TypeInstanceBody
472472
-- ^ This is an instance derived from a newtype
473473
| ExplicitInstance [Declaration]
474474
-- ^ This is a regular (explicit) instance
475-
deriving (Show, Generic, NFData)
475+
deriving (Show, Generic, NFData, Serialise)
476476

477477
mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
478478
mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
@@ -488,7 +488,7 @@ data KindSignatureFor
488488
| NewtypeSig
489489
| TypeSynonymSig
490490
| ClassSig
491-
deriving (Eq, Ord, Show, Generic, NFData)
491+
deriving (Eq, Ord, Show, Generic, NFData, Serialise)
492492

493493
declSourceAnn :: Declaration -> SourceAnn
494494
declSourceAnn (DataDeclaration sa _ _ _ _) = sa
@@ -625,13 +625,13 @@ flattenDecls = concatMap flattenOne
625625
--
626626
data Guard = ConditionGuard Expr
627627
| PatternGuard Binder Expr
628-
deriving (Show, Generic, NFData)
628+
deriving (Show, Generic, NFData, Serialise)
629629

630630
-- |
631631
-- The right hand side of a binder in value declarations
632632
-- and case expressions.
633633
data GuardedExpr = GuardedExpr [Guard] Expr
634-
deriving (Show, Generic, NFData)
634+
deriving (Show, Generic, NFData, Serialise)
635635

636636
pattern MkUnguarded :: Expr -> GuardedExpr
637637
pattern MkUnguarded e = GuardedExpr [] e
@@ -762,7 +762,7 @@ data Expr
762762
-- A value with source position information
763763
--
764764
| PositionedValue SourceSpan [Comment] Expr
765-
deriving (Show, Generic, NFData)
765+
deriving (Show, Generic, NFData, Serialise)
766766

767767
-- |
768768
-- Metadata that tells where a let binding originated
@@ -776,7 +776,7 @@ data WhereProvenance
776776
-- The let binding was always a let binding
777777
--
778778
| FromLet
779-
deriving (Show, Generic, NFData)
779+
deriving (Show, Generic, NFData, Serialise)
780780

781781
-- |
782782
-- An alternative in a case statement
@@ -790,7 +790,7 @@ data CaseAlternative = CaseAlternative
790790
-- The result expression or a collect of guarded expressions
791791
--
792792
, caseAlternativeResult :: [GuardedExpr]
793-
} deriving (Show, Generic, NFData)
793+
} deriving (Show, Generic, NFData, Serialise)
794794

795795
-- |
796796
-- A statement in a do-notation block
@@ -812,7 +812,7 @@ data DoNotationElement
812812
-- A do notation element with source position information
813813
--
814814
| PositionedDoNotationElement SourceSpan [Comment] DoNotationElement
815-
deriving (Show, Generic, NFData)
815+
deriving (Show, Generic, NFData, Serialise)
816816

817817

818818
-- For a record update such as:
@@ -839,15 +839,16 @@ data DoNotationElement
839839
--
840840

841841
newtype PathTree t = PathTree (AssocList PSString (PathNode t))
842-
deriving (Show, Eq, Ord, Functor, Foldable, Traversable)
843-
deriving newtype NFData
842+
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
843+
deriving newtype (NFData, Serialise)
844+
844845

845846
data PathNode t = Leaf t | Branch (PathTree t)
846-
deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable, Traversable)
847+
deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable, Traversable, Serialise)
847848

848849
newtype AssocList k t = AssocList { runAssocList :: [(k, t)] }
849-
deriving (Show, Eq, Ord, Foldable, Functor, Traversable)
850-
deriving newtype NFData
850+
deriving (Show, Eq, Ord, Foldable, Functor, Traversable, Generic)
851+
deriving newtype (NFData, Serialise)
851852

852853
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''NameSource)
853854
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExportSource)

src/Language/PureScript/AST/Declarations/ChainId.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Language.PureScript.AST.Declarations.ChainId
2-
( ChainId
2+
( ChainId(..)
33
, mkChainId
44
) where
55

src/Language/PureScript/AST/Literals.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
module Language.PureScript.AST.Literals where
66

77
import Prelude
8+
import Codec.Serialise (Serialise)
89
import Control.DeepSeq (NFData)
910
import GHC.Generics (Generic)
1011
import Language.PureScript.PSString (PSString)
@@ -38,4 +39,4 @@ data Literal a
3839
-- An object literal
3940
--
4041
| ObjectLiteral [(PSString, a)]
41-
deriving (Eq, Ord, Show, Functor, Generic, NFData)
42+
deriving (Eq, Ord, Show, Functor, Generic, NFData, Serialise)

src/Language/PureScript/AST/SourcePos.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,6 @@ widenSourceSpan (SourceSpan n1 s1 e1) (SourceSpan n2 s2 e2) =
116116

117117
widenSourceAnn :: SourceAnn -> SourceAnn -> SourceAnn
118118
widenSourceAnn (s1, _) (s2, _) = (widenSourceSpan s1 s2, [])
119+
120+
replaceSpanName :: String -> SourceSpan -> SourceSpan
121+
replaceSpanName name (SourceSpan _ sps spe) = SourceSpan name sps spe

src/Language/PureScript/Bundle.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Language.PureScript.Bundle
1919

2020
import Prelude
2121

22+
import Codec.Serialise (Serialise)
2223
import Control.DeepSeq (NFData)
2324
import Control.Monad.Error.Class (MonadError(..))
2425

@@ -46,22 +47,22 @@ data ErrorMessage
4647
| ErrorInModule ModuleIdentifier ErrorMessage
4748
| MissingEntryPoint String
4849
| MissingMainModule String
49-
deriving (Show, Generic, NFData)
50+
deriving (Show, Generic, NFData, Serialise)
5051

5152
-- | Modules are either "regular modules" (i.e. those generated by the PureScript compiler) or
5253
-- foreign modules.
5354
data ModuleType
5455
= Regular
5556
| Foreign
56-
deriving (Show, Eq, Ord, Generic, NFData)
57+
deriving (Show, Eq, Ord, Generic, NFData, Serialise)
5758

5859
showModuleType :: ModuleType -> String
5960
showModuleType Regular = "Regular"
6061
showModuleType Foreign = "Foreign"
6162

6263
-- | A module is identified by its module name and its type.
6364
data ModuleIdentifier = ModuleIdentifier String ModuleType
64-
deriving (Show, Eq, Ord, Generic, NFData)
65+
deriving (Show, Eq, Ord, Generic, NFData, Serialise)
6566

6667
instance A.ToJSON ModuleIdentifier where
6768
toJSON (ModuleIdentifier name mt) =

src/Language/PureScript/CST/Errors.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ module Language.PureScript.CST.Errors
1212

1313
import Prelude
1414

15+
import Codec.Serialise (Serialise)
1516
import Control.DeepSeq (NFData)
16-
import Data.Text qualified as Text
1717
import Data.Char (isSpace, toUpper)
18+
import Data.Text qualified as Text
1819
import GHC.Generics (Generic)
1920
import Language.PureScript.CST.Layout (LayoutStack)
2021
import Language.PureScript.CST.Print (printToken)
@@ -59,22 +60,22 @@ data ParserErrorType
5960
| ErrConstraintInForeignImportSyntax
6061
| ErrEof
6162
| ErrCustom String
62-
deriving (Show, Eq, Ord, Generic, NFData)
63+
deriving (Show, Eq, Ord, Generic, NFData, Serialise)
6364

6465
data ParserWarningType
6566
= WarnDeprecatedRowSyntax
6667
| WarnDeprecatedForeignKindSyntax
6768
| WarnDeprecatedKindImportSyntax
6869
| WarnDeprecatedKindExportSyntax
6970
| WarnDeprecatedCaseOfOffsideSyntax
70-
deriving (Show, Eq, Ord, Generic, NFData)
71+
deriving (Show, Eq, Ord, Generic, NFData, Serialise)
7172

7273
data ParserErrorInfo a = ParserErrorInfo
7374
{ errRange :: SourceRange
7475
, errToks :: [SourceToken]
7576
, errStack :: LayoutStack
7677
, errType :: a
77-
} deriving (Show, Eq, Generic, NFData)
78+
} deriving (Show, Eq, Generic, NFData, Serialise)
7879

7980
type ParserError = ParserErrorInfo ParserErrorType
8081
type ParserWarning = ParserErrorInfo ParserWarningType

src/Language/PureScript/CST/Layout.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ module Language.PureScript.CST.Layout where
171171

172172
import Prelude
173173

174+
import Codec.Serialise (Serialise)
174175
import Control.DeepSeq (NFData)
175176
import Data.DList (snoc)
176177
import Data.DList qualified as DList
@@ -204,7 +205,7 @@ data LayoutDelim
204205
| LytOf
205206
| LytDo
206207
| LytAdo
207-
deriving (Show, Eq, Ord, Generic, NFData)
208+
deriving (Show, Eq, Ord, Generic, NFData, Serialise)
208209

209210
isIndented :: LayoutDelim -> Bool
210211
isIndented = \case

0 commit comments

Comments
 (0)