@@ -1,4 +1,3 @@
1−{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE ScopedTypeVariables #-}
1{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE TemplateHaskell #-}
2{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE LambdaCase #-}
3{-# LANGUAGE LambdaCase #-}
@@ -15,7 +14,6 @@ import Data.Aeson.TH
15import Data.List (nub, (\\))
14import Data.List (nub, (\\))
16import Data.Maybe (mapMaybe)
15import Data.Maybe (mapMaybe)
18−import qualified Data.Data as D
19import qualified Data.Map as M
17import qualified Data.Map as M
21import Control.Monad.Identity
19import Control.Monad.Identity
@@ -35,7 +33,8 @@ import Language.PureScript.Environment
35-- a list of declarations, and a list of the declarations that are
33-- a list of declarations, and a list of the declarations that are
36-- explicitly exported. If the export list is Nothing, everything is exported.
34-- explicitly exported. If the export list is Nothing, everything is exported.
38−data Module = Module SourceSpan [Comment] ModuleName [Declaration] (Maybe [DeclarationRef]) deriving (Show, Read, D.Data, D.Typeable)
36+data Module = Module SourceSpan [Comment] ModuleName [Declaration] (Maybe [DeclarationRef])
37+ deriving (Show, Read)
40-- | Return a module's name.
39-- | Return a module's name.
41getModuleName :: Module -> ModuleName
40getModuleName :: Module -> ModuleName
@@ -60,7 +59,7 @@ data DeclarationRef
61 -- A type constructor with data constructors
60 -- A type constructor with data constructors
63− = TypeRef ProperName (Maybe [ProperName])
62+ = TypeRef (ProperName 'TypeName) (Maybe [ProperName 'ConstructorName])
65 -- A value
64 -- A value
@@ -68,7 +67,7 @@ data DeclarationRef
69 -- A type class
68 -- A type class
71− | TypeClassRef ProperName
70+ | TypeClassRef (ProperName 'ClassName)
73 -- A type class instance, created during typeclass desugaring (name, class name, instance types)
72 -- A type class instance, created during typeclass desugaring (name, class name, instance types)
@@ -80,12 +79,12 @@ data DeclarationRef
81 -- An unspecified ProperName ref. This will be replaced with a TypeClassRef
80 -- An unspecified ProperName ref. This will be replaced with a TypeClassRef
82 -- or TypeRef during name desugaring.
81 -- or TypeRef during name desugaring.
83− | ProperRef ProperName
82+ | ProperRef String
85 -- A declaration reference with source position information
84 -- A declaration reference with source position information
87 | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef
86 | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef
88− deriving (Show, Read, D.Data, D.Typeable)
87+ deriving (Show, Read)
90instance Eq DeclarationRef where
89instance Eq DeclarationRef where
91 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
90 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
@@ -108,7 +107,7 @@ isModuleRef _ = False
108-- are the duplicate refs with data constructors elided, and then a separate
107-- are the duplicate refs with data constructors elided, and then a separate
109-- list of duplicate data constructors.
108-- list of duplicate data constructors.
111−findDuplicateRefs :: [DeclarationRef] -> ([DeclarationRef], [ProperName])
110+findDuplicateRefs :: [DeclarationRef] -> ([DeclarationRef], [ProperName 'ConstructorName])
112findDuplicateRefs refs =
111findDuplicateRefs refs =
113 let positionless = stripPosInfo `map` refs
112 let positionless = stripPosInfo `map` refs
114 simplified = simplifyTypeRefs `map` positionless
113 simplified = simplifyTypeRefs `map` positionless
@@ -141,7 +140,7 @@ data ImportDeclarationType
141 -- An import with a list of references to hide: `import M hiding (foo)`
140 -- An import with a list of references to hide: `import M hiding (foo)`
143 | Hiding [DeclarationRef]
142 | Hiding [DeclarationRef]
144− deriving (Eq, Show, Read, D.Data, D.Typeable)
143+ deriving (Eq, Show, Read)
146isImplicit :: ImportDeclarationType -> Bool
145isImplicit :: ImportDeclarationType -> Bool
147isImplicit Implicit = True
146isImplicit Implicit = True
@@ -154,7 +153,7 @@ data Declaration
155 -- A data type declaration (data or newtype, name, arguments, data constructors)
154 -- A data type declaration (data or newtype, name, arguments, data constructors)
157− = DataDeclaration DataDeclType ProperName [(String, Maybe Kind)] [(ProperName, [Type])]
156+ = DataDeclaration DataDeclType (ProperName 'TypeName) [(String, Maybe Kind)] [(ProperName 'ConstructorName, [Type])]
159 -- A minimal mutually recursive set of data type declarations
158 -- A minimal mutually recursive set of data type declarations
@@ -162,7 +161,7 @@ data Declaration
163 -- A type synonym declaration (name, arguments, type)
162 -- A type synonym declaration (name, arguments, type)
165− | TypeSynonymDeclaration ProperName [(String, Maybe Kind)] Type
164+ | TypeSynonymDeclaration (ProperName 'TypeName) [(String, Maybe Kind)] Type
167 -- A type declaration for a value (name, ty)
166 -- A type declaration for a value (name, ty)
@@ -182,7 +181,7 @@ data Declaration
183 -- A data type foreign import (name, kind)
182 -- A data type foreign import (name, kind)
185− | ExternDataDeclaration ProperName Kind
184+ | ExternDataDeclaration (ProperName 'TypeName) Kind
187 -- A fixity declaration (fixity data, operator name, value the operator is an alias for)
186 -- A fixity declaration (fixity data, operator name, value the operator is an alias for)
@@ -195,17 +194,17 @@ data Declaration
196 -- A type class declaration (name, argument, implies, member declarations)
195 -- A type class declaration (name, argument, implies, member declarations)
198− | TypeClassDeclaration ProperName [(String, Maybe Kind)] [Constraint] [Declaration]
197+ | TypeClassDeclaration (ProperName 'ClassName) [(String, Maybe Kind)] [Constraint] [Declaration]
200 -- A type instance declaration (name, dependencies, class name, instance types, member
199 -- A type instance declaration (name, dependencies, class name, instance types, member
201 -- declarations)
200 -- declarations)
203− | TypeInstanceDeclaration Ident [Constraint] (Qualified ProperName) [Type] TypeInstanceBody
202+ | TypeInstanceDeclaration Ident [Constraint] (Qualified (ProperName 'ClassName)) [Type] TypeInstanceBody
205 -- A declaration with source position information
204 -- A declaration with source position information
207 | PositionedDeclaration SourceSpan [Comment] Declaration
206 | PositionedDeclaration SourceSpan [Comment] Declaration
208− deriving (Show, Read, D.Data, D.Typeable)
207+ deriving (Show, Read)
210-- | The members of a type class instance declaration
209-- | The members of a type class instance declaration
211data TypeInstanceBody
210data TypeInstanceBody
@@ -213,7 +212,7 @@ data TypeInstanceBody
213 = DerivedInstance
212 = DerivedInstance
214 -- | This is a regular (explicit) instance
213 -- | This is a regular (explicit) instance
215 | ExplicitInstance [Declaration]
214 | ExplicitInstance [Declaration]
216− deriving (Show, Read, D.Data, D.Typeable)
215+ deriving (Show, Read)
218mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
217mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
219mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
218mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
@@ -390,7 +389,7 @@ data Expr
391 -- A data constructor
390 -- A data constructor
393− | Constructor (Qualified ProperName)
392+ | Constructor (Qualified (ProperName 'ConstructorName))
395 -- A case expression. During the case expansion phase of desugaring, top-level binders will get
394 -- A case expression. During the case expansion phase of desugaring, top-level binders will get
396 -- desugared into case expressions, hence the need for guards and multiple binders per branch here.
395 -- desugared into case expressions, hence the need for guards and multiple binders per branch here.
@@ -412,7 +411,7 @@ data Expr
412 -- An application of a typeclass dictionary constructor. The value should be
411 -- An application of a typeclass dictionary constructor. The value should be
413 -- an ObjectLiteral.
412 -- an ObjectLiteral.
415− | TypeClassDictionaryConstructorApp (Qualified ProperName) Expr
414+ | TypeClassDictionaryConstructorApp (Qualified (ProperName 'ClassName)) Expr
417 -- A placeholder for a type class dictionary to be inserted later. At the end of type checking, these
416 -- A placeholder for a type class dictionary to be inserted later. At the end of type checking, these
418 -- placeholders will be replaced with actual expressions representing type classes dictionaries which
417 -- placeholders will be replaced with actual expressions representing type classes dictionaries which
@@ -420,19 +419,20 @@ data Expr
420 -- at superclass implementations when searching for a dictionary, the type class name and
419 -- at superclass implementations when searching for a dictionary, the type class name and
421 -- instance type, and the type class dictionaries in scope.
420 -- instance type, and the type class dictionaries in scope.
423− | TypeClassDictionary Constraint (M.Map (Maybe ModuleName) (M.Map (Qualified ProperName) (M.Map (Qualified Ident) TypeClassDictionaryInScope)))
422+ | TypeClassDictionary Constraint (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)))
425 -- A typeclass dictionary accessor, the implementation is left unspecified until CoreFn desugaring.
424 -- A typeclass dictionary accessor, the implementation is left unspecified until CoreFn desugaring.
427− | TypeClassDictionaryAccessor (Qualified ProperName) Ident
426+ | TypeClassDictionaryAccessor (Qualified (ProperName 'ClassName)) Ident
429 -- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
428 -- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
431− | SuperClassDictionary (Qualified ProperName) [Type]
430+ | SuperClassDictionary (Qualified (ProperName 'ClassName)) [Type]
433 -- A value with source position information
432 -- A value with source position information
435− | PositionedValue SourceSpan [Comment] Expr deriving (Show, Read, D.Data, D.Typeable)
434+ | PositionedValue SourceSpan [Comment] Expr
435+ deriving (Show, Read)
438-- An alternative in a case statement
438-- An alternative in a case statement
@@ -446,7 +446,7 @@ data CaseAlternative = CaseAlternative
446 -- The result expression or a collect of guarded expressions
446 -- The result expression or a collect of guarded expressions
448 , caseAlternativeResult :: Either [(Guard, Expr)] Expr
448 , caseAlternativeResult :: Either [(Guard, Expr)] Expr
449− } deriving (Show, Read, D.Data, D.Typeable)
449+ } deriving (Show, Read)
452-- A statement in a do-notation block
452-- A statement in a do-notation block
@@ -467,7 +467,8 @@ data DoNotationElement
468 -- A do notation element with source position information
468 -- A do notation element with source position information
470− | PositionedDoNotationElement SourceSpan [Comment] DoNotationElement deriving (Show, Read, D.Data, D.Typeable)
470+ | PositionedDoNotationElement SourceSpan [Comment] DoNotationElement
471+ deriving (Show, Read)
472$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''DeclarationRef)
473$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''DeclarationRef)
473$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ImportDeclarationType)
474$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ImportDeclarationType)