@@ -22,6 +22,145 @@ import Language.PureScript.Kinds
2222import Language.PureScript.TypeClassDictionaries
2323import Language.PureScript.Comments
2424import Language.PureScript.Environment
25+import qualified Language.PureScript.Bundle as Bundle
26+
27+import qualified Text.Parsec as P
28+
29+-- | A type of error messages
30+data SimpleErrorMessage
31+ = ErrorParsingFFIModule FilePath (Maybe Bundle.ErrorMessage)
32+ | ErrorParsingModule P.ParseError
33+ | MissingFFIModule ModuleName
34+ | MultipleFFIModules ModuleName [FilePath]
35+ | UnnecessaryFFIModule ModuleName FilePath
36+ | MissingFFIImplementations ModuleName [Ident]
37+ | UnusedFFIImplementations ModuleName [Ident]
38+ | InvalidFFIIdentifier ModuleName String
39+ | CannotGetFileInfo FilePath
40+ | CannotReadFile FilePath
41+ | CannotWriteFile FilePath
42+ | InfiniteType Type
43+ | InfiniteKind Kind
44+ | MultipleValueOpFixities (OpName 'ValueOpName)
45+ | MultipleTypeOpFixities (OpName 'TypeOpName)
46+ | OrphanTypeDeclaration Ident
47+ | RedefinedModule ModuleName [SourceSpan]
48+ | RedefinedIdent Ident
49+ | OverlappingNamesInLet
50+ | UnknownName (Qualified Name)
51+ | UnknownImport ModuleName Name
52+ | UnknownImportDataConstructor ModuleName (ProperName 'TypeName) (ProperName 'ConstructorName)
53+ | UnknownExport Name
54+ | UnknownExportDataConstructor (ProperName 'TypeName) (ProperName 'ConstructorName)
55+ | ScopeConflict Name [ModuleName]
56+ | ScopeShadowing Name (Maybe ModuleName) [ModuleName]
57+ | DeclConflict Name Name
58+ | ExportConflict (Qualified Name) (Qualified Name)
59+ | DuplicateModuleName ModuleName
60+ | DuplicateTypeArgument String
61+ | InvalidDoBind
62+ | InvalidDoLet
63+ | CycleInDeclaration Ident
64+ | CycleInTypeSynonym (Maybe (ProperName 'TypeName))
65+ | CycleInModules [ModuleName]
66+ | NameIsUndefined Ident
67+ | UndefinedTypeVariable (ProperName 'TypeName)
68+ | PartiallyAppliedSynonym (Qualified (ProperName 'TypeName))
69+ | EscapedSkolem (Maybe Expr)
70+ | TypesDoNotUnify Type Type
71+ | KindsDoNotUnify Kind Kind
72+ | ConstrainedTypeUnified Type Type
73+ | OverlappingInstances (Qualified (ProperName 'ClassName)) [Type] [Qualified Ident]
74+ | NoInstanceFound Constraint
75+ | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [Type]
76+ | CannotDerive (Qualified (ProperName 'ClassName)) [Type]
77+ | CannotFindDerivingType (ProperName 'TypeName)
78+ | DuplicateLabel String (Maybe Expr)
79+ | DuplicateValueDeclaration Ident
80+ | ArgListLengthsDiffer Ident
81+ | OverlappingArgNames (Maybe Ident)
82+ | MissingClassMember Ident
83+ | ExtraneousClassMember Ident (Qualified (ProperName 'ClassName))
84+ | ExpectedType Type Kind
85+ | IncorrectConstructorArity (Qualified (ProperName 'ConstructorName))
86+ | ExprDoesNotHaveType Expr Type
87+ | PropertyIsMissing String
88+ | AdditionalProperty String
89+ | CannotApplyFunction Type Expr
90+ | TypeSynonymInstance
91+ | OrphanInstance Ident (Qualified (ProperName 'ClassName)) [Type]
92+ | InvalidNewtype (ProperName 'TypeName)
93+ | InvalidInstanceHead Type
94+ | TransitiveExportError DeclarationRef [DeclarationRef]
95+ | TransitiveDctorExportError DeclarationRef (ProperName 'ConstructorName)
96+ | ShadowedName Ident
97+ | ShadowedTypeVar String
98+ | UnusedTypeVar String
99+ | WildcardInferredType Type
100+ | HoleInferredType String Type [(Ident, Type)]
101+ | MissingTypeDeclaration Ident Type
102+ | OverlappingPattern [[Binder]] Bool
103+ | IncompleteExhaustivityCheck
104+ | MisleadingEmptyTypeImport ModuleName (ProperName 'TypeName)
105+ | ImportHidingModule ModuleName
106+ | UnusedImport ModuleName
107+ | UnusedExplicitImport ModuleName [String] (Maybe ModuleName) [DeclarationRef]
108+ | UnusedDctorImport (ProperName 'TypeName)
109+ | UnusedDctorExplicitImport (ProperName 'TypeName) [ProperName 'ConstructorName]
110+ | DuplicateSelectiveImport ModuleName
111+ | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
112+ | DuplicateImportRef Name
113+ | DuplicateExportRef Name
114+ | IntOutOfRange Integer String Integer Integer
115+ | ImplicitQualifiedImport ModuleName ModuleName [DeclarationRef]
116+ | ImplicitImport ModuleName [DeclarationRef]
117+ | HidingImport ModuleName [DeclarationRef]
118+ | CaseBinderLengthDiffers Int [Binder]
119+ | IncorrectAnonymousArgument
120+ | InvalidOperatorInBinder (Qualified (OpName 'ValueOpName)) (Qualified Ident)
121+ | DeprecatedRequirePath
122+ | CannotGeneralizeRecursiveFunction Ident Type
123+ deriving (Show)
124+
125+-- | Error message hints, providing more detailed information about failure.
126+data ErrorMessageHint
127+ = ErrorUnifyingTypes Type Type
128+ | ErrorInExpression Expr
129+ | ErrorInModule ModuleName
130+ | ErrorInInstance (Qualified (ProperName 'ClassName)) [Type]
131+ | ErrorInSubsumption Type Type
132+ | ErrorCheckingAccessor Expr String
133+ | ErrorCheckingType Expr Type
134+ | ErrorCheckingKind Type
135+ | ErrorCheckingGuard
136+ | ErrorInferringType Expr
137+ | ErrorInApplication Expr Type Expr
138+ | ErrorInDataConstructor (ProperName 'ConstructorName)
139+ | ErrorInTypeConstructor (ProperName 'TypeName)
140+ | ErrorInBindingGroup [Ident]
141+ | ErrorInDataBindingGroup
142+ | ErrorInTypeSynonym (ProperName 'TypeName)
143+ | ErrorInValueDeclaration Ident
144+ | ErrorInTypeDeclaration Ident
145+ | ErrorInForeignImport Ident
146+ | ErrorSolvingConstraint Constraint
147+ | PositionedError SourceSpan
148+ deriving (Show)
149+
150+-- | Categories of hints
151+data HintCategory
152+ = ExprHint
153+ | KindHint
154+ | CheckHint
155+ | PositionHint
156+ | SolverHint
157+ | OtherHint
158+ deriving (Show, Eq)
159+
160+data ErrorMessage = ErrorMessage
161+ [ErrorMessageHint]
162+ SimpleErrorMessage
163+ deriving (Show)
25164
26165-- |
27166-- A module declaration, consisting of comments about the module, a module name,
@@ -29,7 +168,7 @@ import Language.PureScript.Environment
29168-- explicitly exported. If the export list is Nothing, everything is exported.
30169--
31170data Module = Module SourceSpan [Comment] ModuleName [Declaration] (Maybe [DeclarationRef])
32− deriving (Show, Read)
171+ deriving (Show)
33172
34173-- | Return a module's name.
35174getModuleName :: Module -> ModuleName
@@ -88,7 +227,7 @@ data DeclarationRef
88227 -- A declaration reference with source position information
89228 --
90229 | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef
91− deriving (Show, Read)
230+ deriving (Show)
92231
93232instance Eq DeclarationRef where
94233 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
@@ -149,7 +288,7 @@ data ImportDeclarationType
149288 -- An import with a list of references to hide: `import M hiding (foo)`
150289 --
151290 | Hiding [DeclarationRef]
152− deriving (Eq, Show, Read)
291+ deriving (Eq, Show)
153292
154293isImplicit :: ImportDeclarationType -> Bool
155294isImplicit Implicit = True
@@ -216,15 +355,15 @@ data Declaration
216355 -- A declaration with source position information
217356 --
218357 | PositionedDeclaration SourceSpan [Comment] Declaration
219− deriving (Show, Read)
358+ deriving (Show)
220359
221360data ValueFixity = ValueFixity Fixity (Qualified (Either Ident (ProperName 'ConstructorName))) (OpName 'ValueOpName)
222− deriving (Eq, Ord, Show, Read)
361+ deriving (Eq, Ord, Show)
223362
224363data TypeFixity = TypeFixity Fixity (Qualified (ProperName 'TypeName)) (OpName 'TypeOpName)
225− deriving (Eq, Ord, Show, Read)
364+ deriving (Eq, Ord, Show)
226365
227−pattern ValueFixityDeclaration :: Fixity -> Qualified (Either Ident (ProperName 'ConstructorName)) -> OpName 'ValueOpName -> Declaration
366+pattern ValueFixityDeclaration :: Fixity -> Qualified (Either Ident (ProperName 'ConstructorName)) -> OpName 'ValueOpName -> Declaration
228367pattern ValueFixityDeclaration fixity name op = FixityDeclaration (Left (ValueFixity fixity name op))
229368
230369pattern TypeFixityDeclaration :: Fixity -> Qualified (ProperName 'TypeName) -> OpName 'TypeOpName -> Declaration
@@ -236,7 +375,7 @@ data TypeInstanceBody
236375 = DerivedInstance
237376 -- | This is a regular (explicit) instance
238377 | ExplicitInstance [Declaration]
239− deriving (Show, Read)
378+ deriving (Show)
240379
241380mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
242381mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
@@ -421,7 +560,9 @@ data Expr
421560 -- at superclass implementations when searching for a dictionary, the type class name and
422561 -- instance type, and the type class dictionaries in scope.
423562 --
424− | TypeClassDictionary Constraint (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)))
563+ | TypeClassDictionary Constraint
564+ (M.Map (Maybe ModuleName) (M.Map (Qualified (ProperName 'ClassName)) (M.Map (Qualified Ident) TypeClassDictionaryInScope)))
565+ [ErrorMessageHint]
425566 -- |
426567 -- A typeclass dictionary accessor, the implementation is left unspecified until CoreFn desugaring.
427568 --
@@ -442,7 +583,7 @@ data Expr
442583 -- A value with source position information
443584 --
444585 | PositionedValue SourceSpan [Comment] Expr
445− deriving (Show, Read)
586+ deriving (Show)
446587
447588-- |
448589-- An alternative in a case statement
@@ -456,7 +597,7 @@ data CaseAlternative = CaseAlternative
456597 -- The result expression or a collect of guarded expressions
457598 --
458599 , caseAlternativeResult :: Either [(Guard, Expr)] Expr
459− } deriving (Show, Read)
600+ } deriving (Show)
460601
461602-- |
462603-- A statement in a do-notation block
@@ -478,7 +619,7 @@ data DoNotationElement
478619 -- A do notation element with source position information
479620 --
480621 | PositionedDoNotationElement SourceSpan [Comment] DoNotationElement
481− deriving (Show, Read)
622+ deriving (Show)
482623
483624$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''DeclarationRef)
484625$(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ImportDeclarationType)