Make/build cut-off by wclr · Pull Request #4477 · purescript/purescript · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions app/Command/Compile.hs
2 changes: 2 additions & 0 deletions purescript.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ library
Language.PureScript.Make.Actions
Language.PureScript.Make.BuildPlan
Language.PureScript.Make.Cache
Language.PureScript.Make.ExternsDiff
Language.PureScript.Make.Monad
Language.PureScript.Make.Patch
Language.PureScript.ModuleDependencies
Language.PureScript.Names
Language.PureScript.Options
Expand Down
6 changes: 4 additions & 2 deletions src/Language/PureScript/AST/Binders.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveAnyClass, DeriveDataTypeable #-}
-- |
-- Case binders
--
Expand All @@ -7,12 +7,14 @@ module Language.PureScript.AST.Binders where
import Prelude

import Control.DeepSeq (NFData)
import Codec.Serialise (Serialise)
import GHC.Generics (Generic)
import Language.PureScript.AST.SourcePos (SourceSpan)
import Language.PureScript.AST.Literals (Literal(..))
import Language.PureScript.Names (Ident, OpName, OpNameType(..), ProperName, ProperNameType(..), Qualified)
import Language.PureScript.Comments (Comment)
import Language.PureScript.Types (SourceType)
import Data.Data (Data)

-- |
-- Data type for binders
Expand Down Expand Up @@ -64,7 +66,7 @@ data Binder
-- A binder with a type annotation
--
| TypedBinder SourceType Binder
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

-- Manual Eq and Ord instances for `Binder` were added on 2018-03-05. Comparing
-- the `SourceSpan` values embedded in some of the data constructors of `Binder`
Expand Down
62 changes: 32 additions & 30 deletions src/Language/PureScript/AST/Declarations.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveAnyClass, DeriveDataTypeable #-}
{-# LANGUAGE TemplateHaskell #-}

-- |
Expand Down Expand Up @@ -33,6 +33,7 @@ import Language.PureScript.TypeClassDictionaries (NamedDict)
import Language.PureScript.Comments (Comment)
import Language.PureScript.Environment (DataDeclType, Environment, FunctionalDependency, NameKind)
import Language.PureScript.Constants.Prim qualified as C
import Data.Data (Data)

-- | A map of locally-bound names in scope.
type Context = [(Ident, SourceType)]
Expand All @@ -50,7 +51,7 @@ data TypeSearch
-- ^ Record fields that are available on the first argument to the typed
-- hole
}
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

onTypeSearchTypes :: (SourceType -> SourceType) -> TypeSearch -> TypeSearch
onTypeSearchTypes f = runIdentity . onTypeSearchTypesM (Identity . f)
Expand Down Expand Up @@ -90,7 +91,7 @@ data ErrorMessageHint
| MissingConstructorImportForCoercible (Qualified (ProperName 'ConstructorName))
| PositionedError (NEL.NonEmpty SourceSpan)
| RelatedPositions (NEL.NonEmpty SourceSpan)
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

-- | Categories of hints
data HintCategory
Expand All @@ -101,7 +102,7 @@ data HintCategory
| SolverHint
| DeclarationHint
| OtherHint
deriving (Show, Eq)
deriving (Show, Eq, Generic, NFData, Data)

-- |
-- In constraint solving, indicates whether there were `TypeUnknown`s that prevented
Expand All @@ -112,7 +113,7 @@ data UnknownsHint
= NoUnknowns
| Unknowns
| UnknownsWithVtaRequiringArgs (NEL.NonEmpty (Qualified Ident, [[Text]]))
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

-- |
-- A module declaration, consisting of comments about the module, a module name,
Expand Down Expand Up @@ -165,7 +166,7 @@ importPrim =
. addDefaultImport (Qualified ByNullSourcePos primModName)

data NameSource = UserNamed | CompilerNamed
deriving (Show, Generic, NFData, Serialise)
deriving (Eq, Show, Generic, NFData, Data, Serialise)

-- |
-- An item in a list of explicit imports or exports
Expand Down Expand Up @@ -204,7 +205,7 @@ data DeclarationRef
-- elaboration in name desugaring.
--
| ReExportRef SourceSpan ExportSource DeclarationRef
deriving (Show, Generic, NFData, Serialise)
deriving (Show, Generic, NFData, Serialise, Data)

instance Eq DeclarationRef where
(TypeClassRef _ name) == (TypeClassRef _ name') = name == name'
Expand Down Expand Up @@ -244,7 +245,7 @@ data ExportSource =
{ exportSourceImportedFrom :: Maybe ModuleName
, exportSourceDefinedIn :: ModuleName
}
deriving (Eq, Ord, Show, Generic, NFData, Serialise)
deriving (Eq, Ord, Show, Generic, NFData, Data, Serialise)

declRefSourceSpan :: DeclarationRef -> SourceSpan
declRefSourceSpan (TypeRef ss _ _) = ss
Expand Down Expand Up @@ -306,7 +307,7 @@ data ImportDeclarationType
-- An import with a list of references to hide: `import M hiding (foo)`
--
| Hiding [DeclarationRef]
deriving (Eq, Show, Generic, Serialise, NFData)
deriving (Eq, Show, Generic, Serialise, NFData, Data)

isExplicit :: ImportDeclarationType -> Bool
isExplicit (Explicit _) = True
Expand All @@ -323,7 +324,7 @@ data RoleDeclarationData = RoleDeclarationData
{ rdeclSourceAnn :: !SourceAnn
, rdeclIdent :: !(ProperName 'TypeName)
, rdeclRoles :: ![Role]
} deriving (Show, Eq, Generic, NFData)
} deriving (Show, Eq, Generic, NFData, Data, Serialise)

-- | A type declaration assigns a type to an identifier, eg:
--
Expand All @@ -334,7 +335,7 @@ data TypeDeclarationData = TypeDeclarationData
{ tydeclSourceAnn :: !SourceAnn
, tydeclIdent :: !Ident
, tydeclType :: !SourceType
} deriving (Show, Eq, Generic, NFData)
} deriving (Show, Eq, Generic, NFData, Data, Serialise)

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

getValueDeclaration :: Declaration -> Maybe (ValueDeclarationData [GuardedExpr])
getValueDeclaration (ValueDeclaration d) = Just d
Expand All @@ -370,7 +371,7 @@ data DataConstructorDeclaration = DataConstructorDeclaration
{ dataCtorAnn :: !SourceAnn
, dataCtorName :: !(ProperName 'ConstructorName)
, dataCtorFields :: ![(Ident, SourceType)]
} deriving (Show, Eq, Generic, NFData)
} deriving (Show, Eq, Generic, NFData, Data, Serialise)

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

data ValueFixity = ValueFixity Fixity (Qualified (Either Ident (ProperName 'ConstructorName))) (OpName 'ValueOpName)
deriving (Eq, Ord, Show, Generic, NFData)
deriving (Eq, Ord, Show, Generic, NFData, Data, Serialise)

data TypeFixity = TypeFixity Fixity (Qualified (ProperName 'TypeName)) (OpName 'TypeOpName)
deriving (Eq, Ord, Show, Generic, NFData)
deriving (Eq, Ord, Show, Generic, NFData, Data, Serialise)

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

-- | The members of a type class instance declaration
data TypeInstanceBody
Expand All @@ -472,7 +473,7 @@ data TypeInstanceBody
-- ^ This is an instance derived from a newtype
| ExplicitInstance [Declaration]
-- ^ This is a regular (explicit) instance
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
Expand All @@ -488,7 +489,7 @@ data KindSignatureFor
| NewtypeSig
| TypeSynonymSig
| ClassSig
deriving (Eq, Ord, Show, Generic, NFData)
deriving (Eq, Ord, Show, Generic, NFData, Data, Serialise)

declSourceAnn :: Declaration -> SourceAnn
declSourceAnn (DataDeclaration sa _ _ _ _) = sa
Expand Down Expand Up @@ -625,13 +626,13 @@ flattenDecls = concatMap flattenOne
--
data Guard = ConditionGuard Expr
| PatternGuard Binder Expr
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

-- |
-- The right hand side of a binder in value declarations
-- and case expressions.
data GuardedExpr = GuardedExpr [Guard] Expr
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

pattern MkUnguarded :: Expr -> GuardedExpr
pattern MkUnguarded e = GuardedExpr [] e
Expand Down Expand Up @@ -762,7 +763,7 @@ data Expr
-- A value with source position information
--
| PositionedValue SourceSpan [Comment] Expr
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

-- |
-- Metadata that tells where a let binding originated
Expand All @@ -776,7 +777,7 @@ data WhereProvenance
-- The let binding was always a let binding
--
| FromLet
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)

-- |
-- An alternative in a case statement
Expand All @@ -790,7 +791,7 @@ data CaseAlternative = CaseAlternative
-- The result expression or a collect of guarded expressions
--
, caseAlternativeResult :: [GuardedExpr]
} deriving (Show, Generic, NFData)
} deriving (Show, Generic, NFData, Data, Serialise)

-- |
-- A statement in a do-notation block
Expand All @@ -812,7 +813,7 @@ data DoNotationElement
-- A do notation element with source position information
--
| PositionedDoNotationElement SourceSpan [Comment] DoNotationElement
deriving (Show, Generic, NFData)
deriving (Show, Generic, NFData, Data, Serialise)


-- For a record update such as:
Expand All @@ -839,15 +840,16 @@ data DoNotationElement
--

newtype PathTree t = PathTree (AssocList PSString (PathNode t))
deriving (Show, Eq, Ord, Functor, Foldable, Traversable)
deriving newtype NFData
deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Generic, Data)
deriving newtype (NFData, Serialise)


data PathNode t = Leaf t | Branch (PathTree t)
deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable, Traversable)
deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable, Traversable, Data, Serialise)

newtype AssocList k t = AssocList { runAssocList :: [(k, t)] }
deriving (Show, Eq, Ord, Foldable, Functor, Traversable)
deriving newtype NFData
deriving (Show, Eq, Ord, Foldable, Functor, Traversable, Generic, Data)
deriving newtype (NFData, Serialise)

$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''NameSource)
$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExportSource)
Expand Down
6 changes: 4 additions & 2 deletions src/Language/PureScript/AST/Declarations/ChainId.hs
Loading
Loading