@@ -1,6 +1,5 @@
1{-# LANGUAGE GeneralizedNewtypeDeriving #-}
1{-# LANGUAGE GeneralizedNewtypeDeriving #-}
2{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE RecordWildCards #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
3{-# LANGUAGE MultiParamTypeClasses #-}
6module Language.PureScript.Errors where
5module Language.PureScript.Errors where
@@ -9,6 +8,7 @@ import Prelude ()
9import Prelude.Compat
8import Prelude.Compat
11import Data.Ord (comparing)
10import Data.Ord (comparing)
11+import Data.Char (isSpace)
12import Data.Either (lefts, rights)
12import Data.Either (lefts, rights)
13import Data.List (intercalate, transpose, nub, nubBy, sortBy)
13import Data.List (intercalate, transpose, nub, nubBy, sortBy)
14import Data.Foldable (fold)
14import Data.Foldable (fold)
@@ -24,6 +24,7 @@ import Control.Arrow ((&&&))
24import Language.PureScript.Crash
24import Language.PureScript.Crash
25import Language.PureScript.AST
25import Language.PureScript.AST
26import Language.PureScript.Pretty
26import Language.PureScript.Pretty
27+import Language.PureScript.Pretty.Common (before)
27import Language.PureScript.Types
28import Language.PureScript.Types
28import Language.PureScript.Names
29import Language.PureScript.Names
29import Language.PureScript.Kinds
30import Language.PureScript.Kinds
@@ -53,65 +54,67 @@ data SimpleErrorMessage
53 | RedefinedIdent Ident
54 | RedefinedIdent Ident
54 | OverlappingNamesInLet
55 | OverlappingNamesInLet
55 | UnknownModule ModuleName
56 | UnknownModule ModuleName
56− | UnknownType (Qualified ProperName)
57+ | UnknownType (Qualified (ProperName 'TypeName))
57− | UnknownTypeClass (Qualified ProperName)
58+ | UnknownTypeClass (Qualified (ProperName 'ClassName))
58 | UnknownValue (Qualified Ident)
59 | UnknownValue (Qualified Ident)
59− | UnknownDataConstructor (Qualified ProperName) (Maybe (Qualified ProperName))
60+ | UnknownDataConstructor (Qualified (ProperName 'ConstructorName)) (Maybe (Qualified (ProperName 'ConstructorName)))
60− | UnknownTypeConstructor (Qualified ProperName)
61+ | UnknownTypeConstructor (Qualified (ProperName 'TypeName))
61− | UnknownImportType ModuleName ProperName
62+ | UnknownImportType ModuleName (ProperName 'TypeName)
62− | UnknownExportType ProperName
63+ | UnknownExportType (ProperName 'TypeName)
63− | UnknownImportTypeClass ModuleName ProperName
64+ | UnknownImportTypeClass ModuleName (ProperName 'ClassName)
64− | UnknownExportTypeClass ProperName
65+ | UnknownExportTypeClass (ProperName 'ClassName)
65 | UnknownImportValue ModuleName Ident
66 | UnknownImportValue ModuleName Ident
66 | UnknownExportValue Ident
67 | UnknownExportValue Ident
67 | UnknownExportModule ModuleName
68 | UnknownExportModule ModuleName
68− | UnknownImportDataConstructor ModuleName ProperName ProperName
69+ | UnknownImportDataConstructor ModuleName (ProperName 'TypeName) (ProperName 'ConstructorName)
69− | UnknownExportDataConstructor ProperName ProperName
70+ | UnknownExportDataConstructor (ProperName 'TypeName) (ProperName 'ConstructorName)
70 | ScopeConflict String [ModuleName]
71 | ScopeConflict String [ModuleName]
72+ | ScopeShadowing String (Maybe ModuleName) [ModuleName]
71− | ConflictingTypeDecls ProperName
73+ | ConflictingTypeDecls (ProperName 'TypeName)
72− | ConflictingCtorDecls ProperName
74+ | ConflictingCtorDecls (ProperName 'ConstructorName)
73− | TypeConflictsWithClass ProperName
75+ | TypeConflictsWithClass (ProperName 'TypeName)
74− | CtorConflictsWithClass ProperName
76+ | CtorConflictsWithClass (ProperName 'ConstructorName)
75− | ClassConflictsWithType ProperName
77+ | ClassConflictsWithType (ProperName 'ClassName)
76− | ClassConflictsWithCtor ProperName
78+ | ClassConflictsWithCtor (ProperName 'ClassName)
77 | DuplicateModuleName ModuleName
79 | DuplicateModuleName ModuleName
78− | DuplicateClassExport ProperName
80+ | DuplicateClassExport (ProperName 'ClassName)
79 | DuplicateValueExport Ident
81 | DuplicateValueExport Ident
80 | DuplicateTypeArgument String
82 | DuplicateTypeArgument String
81 | InvalidDoBind
83 | InvalidDoBind
82 | InvalidDoLet
84 | InvalidDoLet
83 | CycleInDeclaration Ident
85 | CycleInDeclaration Ident
84− | CycleInTypeSynonym (Maybe ProperName)
86+ | CycleInTypeSynonym (Maybe (ProperName 'TypeName))
85 | CycleInModules [ModuleName]
87 | CycleInModules [ModuleName]
86 | NameIsUndefined Ident
88 | NameIsUndefined Ident
87− | UndefinedTypeVariable ProperName
89+ | UndefinedTypeVariable (ProperName 'TypeName)
88− | PartiallyAppliedSynonym (Qualified ProperName)
90+ | PartiallyAppliedSynonym (Qualified (ProperName 'TypeName))
89 | EscapedSkolem (Maybe Expr)
91 | EscapedSkolem (Maybe Expr)
90 | TypesDoNotUnify Type Type
92 | TypesDoNotUnify Type Type
91 | KindsDoNotUnify Kind Kind
93 | KindsDoNotUnify Kind Kind
92 | ConstrainedTypeUnified Type Type
94 | ConstrainedTypeUnified Type Type
93− | OverlappingInstances (Qualified ProperName) [Type] [Qualified Ident]
95+ | OverlappingInstances (Qualified (ProperName 'ClassName)) [Type] [Qualified Ident]
94− | NoInstanceFound (Qualified ProperName) [Type]
96+ | NoInstanceFound (Qualified (ProperName 'ClassName)) [Type]
95− | PossiblyInfiniteInstance (Qualified ProperName) [Type]
97+ | PossiblyInfiniteInstance (Qualified (ProperName 'ClassName)) [Type]
96− | CannotDerive (Qualified ProperName) [Type]
98+ | CannotDerive (Qualified (ProperName 'ClassName)) [Type]
97− | CannotFindDerivingType ProperName
99+ | CannotFindDerivingType (ProperName 'TypeName)
98 | DuplicateLabel String (Maybe Expr)
100 | DuplicateLabel String (Maybe Expr)
99 | DuplicateValueDeclaration Ident
101 | DuplicateValueDeclaration Ident
100 | ArgListLengthsDiffer Ident
102 | ArgListLengthsDiffer Ident
101 | OverlappingArgNames (Maybe Ident)
103 | OverlappingArgNames (Maybe Ident)
102 | MissingClassMember Ident
104 | MissingClassMember Ident
103− | ExtraneousClassMember Ident (Qualified ProperName)
105+ | ExtraneousClassMember Ident (Qualified (ProperName 'ClassName))
104 | ExpectedType Type Kind
106 | ExpectedType Type Kind
105− | IncorrectConstructorArity (Qualified ProperName)
107+ | IncorrectConstructorArity (Qualified (ProperName 'ConstructorName))
106 | ExprDoesNotHaveType Expr Type
108 | ExprDoesNotHaveType Expr Type
107 | PropertyIsMissing String
109 | PropertyIsMissing String
108 | AdditionalProperty String
110 | AdditionalProperty String
109 | CannotApplyFunction Type Expr
111 | CannotApplyFunction Type Expr
110 | TypeSynonymInstance
112 | TypeSynonymInstance
111− | OrphanInstance Ident (Qualified ProperName) [Type]
113+ | OrphanInstance Ident (Qualified (ProperName 'ClassName)) [Type]
112− | InvalidNewtype ProperName
114+ | InvalidNewtype (ProperName 'TypeName)
113 | InvalidInstanceHead Type
115 | InvalidInstanceHead Type
114 | TransitiveExportError DeclarationRef [DeclarationRef]
116 | TransitiveExportError DeclarationRef [DeclarationRef]
117+ | TransitiveDctorExportError DeclarationRef (ProperName 'ConstructorName)
115 | ShadowedName Ident
118 | ShadowedName Ident
116 | ShadowedTypeVar String
119 | ShadowedTypeVar String
117 | UnusedTypeVar String
120 | UnusedTypeVar String
@@ -120,17 +123,18 @@ data SimpleErrorMessage
120 | NotExhaustivePattern [[Binder]] Bool
123 | NotExhaustivePattern [[Binder]] Bool
121 | OverlappingPattern [[Binder]] Bool
124 | OverlappingPattern [[Binder]] Bool
122 | IncompleteExhaustivityCheck
125 | IncompleteExhaustivityCheck
123− | ClassOperator ProperName Ident
126+ | ClassOperator (ProperName 'ClassName) Ident
124− | MisleadingEmptyTypeImport ModuleName ProperName
127+ | MisleadingEmptyTypeImport ModuleName (ProperName 'TypeName)
125 | ImportHidingModule ModuleName
128 | ImportHidingModule ModuleName
126 | UnusedImport ModuleName
129 | UnusedImport ModuleName
127− | UnusedExplicitImport ModuleName [String]
130+ | UnusedExplicitImport ModuleName [String] (Maybe ModuleName) [DeclarationRef]
128− | UnusedDctorImport ProperName
131+ | UnusedDctorImport (ProperName 'TypeName)
129− | UnusedDctorExplicitImport ProperName [ProperName]
132+ | UnusedDctorExplicitImport (ProperName 'TypeName) [ProperName 'ConstructorName]
130 | DeprecatedOperatorDecl String
133 | DeprecatedOperatorDecl String
134+ | DeprecatedOperatorSection Expr (Either Expr Expr)
131 | DeprecatedQualifiedSyntax ModuleName ModuleName
135 | DeprecatedQualifiedSyntax ModuleName ModuleName
132− | DeprecatedClassImport ModuleName ProperName
136+ | DeprecatedClassImport ModuleName (ProperName 'ClassName)
133− | DeprecatedClassExport ProperName
137+ | DeprecatedClassExport (ProperName 'ClassName)
134 | RedundantUnqualifiedImport ModuleName ImportDeclarationType
138 | RedundantUnqualifiedImport ModuleName ImportDeclarationType
135 | DuplicateSelectiveImport ModuleName
139 | DuplicateSelectiveImport ModuleName
136 | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
140 | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
@@ -138,8 +142,12 @@ data SimpleErrorMessage
138 | DuplicateExportRef String
142 | DuplicateExportRef String
139 | IntOutOfRange Integer String Integer Integer
143 | IntOutOfRange Integer String Integer Integer
140 | RedundantEmptyHidingImport ModuleName
144 | RedundantEmptyHidingImport ModuleName
145+ | ImplicitQualifiedImport ModuleName ModuleName [DeclarationRef]
141 | ImplicitImport ModuleName [DeclarationRef]
146 | ImplicitImport ModuleName [DeclarationRef]
147+ | HidingImport ModuleName [DeclarationRef]
142 | CaseBinderLengthDiffers Int [Binder]
148 | CaseBinderLengthDiffers Int [Binder]
149+ | IncorrectAnonymousArgument
150+ | InvalidOperatorInBinder Ident Ident
143 deriving (Show)
151 deriving (Show)
145-- | Error message hints, providing more detailed information about failure.
153-- | Error message hints, providing more detailed information about failure.
@@ -147,7 +155,7 @@ data ErrorMessageHint
147 = ErrorUnifyingTypes Type Type
155 = ErrorUnifyingTypes Type Type
148 | ErrorInExpression Expr
156 | ErrorInExpression Expr
149 | ErrorInModule ModuleName
157 | ErrorInModule ModuleName
150− | ErrorInInstance (Qualified ProperName) [Type]
158+ | ErrorInInstance (Qualified (ProperName 'ClassName)) [Type]
151 | ErrorInSubsumption Type Type
159 | ErrorInSubsumption Type Type
152 | ErrorCheckingAccessor Expr String
160 | ErrorCheckingAccessor Expr String
153 | ErrorCheckingType Expr Type
161 | ErrorCheckingType Expr Type
@@ -155,11 +163,11 @@ data ErrorMessageHint
155 | ErrorCheckingGuard
163 | ErrorCheckingGuard
156 | ErrorInferringType Expr
164 | ErrorInferringType Expr
157 | ErrorInApplication Expr Type Expr
165 | ErrorInApplication Expr Type Expr
158− | ErrorInDataConstructor ProperName
166+ | ErrorInDataConstructor (ProperName 'ConstructorName)
159− | ErrorInTypeConstructor ProperName
167+ | ErrorInTypeConstructor (ProperName 'TypeName)
160 | ErrorInBindingGroup [Ident]
168 | ErrorInBindingGroup [Ident]
161 | ErrorInDataBindingGroup
169 | ErrorInDataBindingGroup
162− | ErrorInTypeSynonym ProperName
170+ | ErrorInTypeSynonym (ProperName 'TypeName)
163 | ErrorInValueDeclaration Ident
171 | ErrorInValueDeclaration Ident
164 | ErrorInTypeDeclaration Ident
172 | ErrorInTypeDeclaration Ident
165 | ErrorInForeignImport Ident
173 | ErrorInForeignImport Ident
@@ -177,6 +185,8 @@ data HintCategory
178data ErrorMessage = ErrorMessage [ErrorMessageHint] SimpleErrorMessage deriving (Show)
186data ErrorMessage = ErrorMessage [ErrorMessageHint] SimpleErrorMessage deriving (Show)
188+newtype ErrorSuggestion = ErrorSuggestion String
180-- | Get the source span for an error
190-- | Get the source span for an error
181errorSpan :: ErrorMessage -> Maybe SourceSpan
191errorSpan :: ErrorMessage -> Maybe SourceSpan
182errorSpan = findHint matchSpan
192errorSpan = findHint matchSpan
@@ -239,6 +249,7 @@ errorCode em = case unwrapErrorMessage em of
239 UnknownImportDataConstructor{} -> "UnknownImportDataConstructor"
249 UnknownImportDataConstructor{} -> "UnknownImportDataConstructor"
240 UnknownExportDataConstructor{} -> "UnknownExportDataConstructor"
250 UnknownExportDataConstructor{} -> "UnknownExportDataConstructor"
241 ScopeConflict{} -> "ScopeConflict"
251 ScopeConflict{} -> "ScopeConflict"
252+ ScopeShadowing{} -> "ScopeShadowing"
242 ConflictingTypeDecls{} -> "ConflictingTypeDecls"
253 ConflictingTypeDecls{} -> "ConflictingTypeDecls"
243 ConflictingCtorDecls{} -> "ConflictingCtorDecls"
254 ConflictingCtorDecls{} -> "ConflictingCtorDecls"
244 TypeConflictsWithClass{} -> "TypeConflictsWithClass"
255 TypeConflictsWithClass{} -> "TypeConflictsWithClass"
@@ -283,6 +294,7 @@ errorCode em = case unwrapErrorMessage em of
283 InvalidNewtype{} -> "InvalidNewtype"
294 InvalidNewtype{} -> "InvalidNewtype"
284 InvalidInstanceHead{} -> "InvalidInstanceHead"
295 InvalidInstanceHead{} -> "InvalidInstanceHead"
285 TransitiveExportError{} -> "TransitiveExportError"
296 TransitiveExportError{} -> "TransitiveExportError"
297+ TransitiveDctorExportError{} -> "TransitiveDctorExportError"
286 ShadowedName{} -> "ShadowedName"
298 ShadowedName{} -> "ShadowedName"
287 ShadowedTypeVar{} -> "ShadowedTypeVar"
299 ShadowedTypeVar{} -> "ShadowedTypeVar"
288 UnusedTypeVar{} -> "UnusedTypeVar"
300 UnusedTypeVar{} -> "UnusedTypeVar"
@@ -299,6 +311,7 @@ errorCode em = case unwrapErrorMessage em of
299 UnusedDctorImport{} -> "UnusedDctorImport"
311 UnusedDctorImport{} -> "UnusedDctorImport"
300 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
312 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
301 DeprecatedOperatorDecl{} -> "DeprecatedOperatorDecl"
313 DeprecatedOperatorDecl{} -> "DeprecatedOperatorDecl"
314+ DeprecatedOperatorSection{} -> "DeprecatedOperatorSection"
302 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
315 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
303 DeprecatedClassImport{} -> "DeprecatedClassImport"
316 DeprecatedClassImport{} -> "DeprecatedClassImport"
304 DeprecatedClassExport{} -> "DeprecatedClassExport"
317 DeprecatedClassExport{} -> "DeprecatedClassExport"
@@ -309,8 +322,12 @@ errorCode em = case unwrapErrorMessage em of
309 DuplicateExportRef{} -> "DuplicateExportRef"
322 DuplicateExportRef{} -> "DuplicateExportRef"
310 IntOutOfRange{} -> "IntOutOfRange"
323 IntOutOfRange{} -> "IntOutOfRange"
311 RedundantEmptyHidingImport{} -> "RedundantEmptyHidingImport"
324 RedundantEmptyHidingImport{} -> "RedundantEmptyHidingImport"
325+ ImplicitQualifiedImport{} -> "ImplicitQualifiedImport"
312 ImplicitImport{} -> "ImplicitImport"
326 ImplicitImport{} -> "ImplicitImport"
327+ HidingImport{} -> "HidingImport"
313 CaseBinderLengthDiffers{} -> "CaseBinderLengthDiffers"
328 CaseBinderLengthDiffers{} -> "CaseBinderLengthDiffers"
329+ IncorrectAnonymousArgument -> "IncorrectAnonymousArgument"
330+ InvalidOperatorInBinder{} -> "InvalidOperatorInBinder"
316-- A stack trace for an error
333-- A stack trace for an error
@@ -412,14 +429,48 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
412 gHint (ErrorInInstance cl ts) = ErrorInInstance cl <$> traverse f ts
429 gHint (ErrorInInstance cl ts) = ErrorInInstance cl <$> traverse f ts
413 gHint other = pure other
430 gHint other = pure other
415−prettyPrintSingleError' :: Bool -> Level -> ErrorMessage ->Box.Box
432+wikiUri :: ErrorMessage -> String
416−prettyPrintSingleError' full level = flip evalState defaultUnknownMap . prettyPrintSingleError full level
433+wikiUri e = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
435+-- TODO Other possible suggestions:
436+-- WildcardInferredType - source span not small enough
437+-- DuplicateSelectiveImport - would require 2 ranges to remove and 1 insert
438+-- DeprecatedClassExport, DeprecatedClassImport, DeprecatedOperatorSection, would want to replace smaller span?
439+errorSuggestion :: SimpleErrorMessage -> Maybe ErrorSuggestion
440+errorSuggestion err = case err of
441+ UnusedImport{} -> emptySuggestion
442+ RedundantEmptyHidingImport{} -> emptySuggestion
443+ DuplicateImport{} -> emptySuggestion
444+ RedundantUnqualifiedImport{} -> emptySuggestion
445+ DeprecatedQualifiedSyntax name qualName -> suggest $
446+ "import " ++ runModuleName name ++ " as " ++ runModuleName qualName
447+ UnusedExplicitImport mn _ qual refs -> suggest $ importSuggestion mn refs qual
448+ ImplicitImport mn refs -> suggest $ importSuggestion mn refs Nothing
449+ ImplicitQualifiedImport mn asModule refs -> suggest $ importSuggestion mn refs (Just asModule)
453+ emptySuggestion = Just $ ErrorSuggestion ""
454+ suggest = Just . ErrorSuggestion
456+ importSuggestion :: ModuleName -> [ DeclarationRef ] -> Maybe ModuleName -> String
457+ importSuggestion mn refs qual =
458+ "import " ++ runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")" ++ qstr qual
460+ qstr :: Maybe ModuleName -> String
461+ qstr (Just mn) = " as " ++ runModuleName mn
464+showSuggestion :: SimpleErrorMessage -> String
465+showSuggestion suggestion = case errorSuggestion suggestion of
466+ Just (ErrorSuggestion x) -> x
419-- Pretty print a single error, simplifying if necessary
470-- Pretty print a single error, simplifying if necessary
421−prettyPrintSingleError :: Bool -> Level -> ErrorMessage -> State TypeMap Box.Box
472+prettyPrintSingleError :: Bool -> Level -> Bool -> ErrorMessage -> Box.Box
422−prettyPrintSingleError full level e = do
473+prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap $ do
423 em <- onTypesInErrorMessageM replaceUnknowns (if full then e else simplifyErrorMessage e)
474 em <- onTypesInErrorMessageM replaceUnknowns (if full then e else simplifyErrorMessage e)
424 um <- get
475 um <- get
425 return (prettyPrintErrorMessage um em)
476 return (prettyPrintErrorMessage um em)
@@ -428,20 +479,19 @@ prettyPrintSingleError full level e = do
428 -- Pretty print an ErrorMessage
479 -- Pretty print an ErrorMessage
429 prettyPrintErrorMessage :: TypeMap -> ErrorMessage -> Box.Box
480 prettyPrintErrorMessage :: TypeMap -> ErrorMessage -> Box.Box
430 prettyPrintErrorMessage typeMap (ErrorMessage hints simple) =
481 prettyPrintErrorMessage typeMap (ErrorMessage hints simple) =
432 [ foldr renderHint (indent (renderSimpleErrorMessage simple)) hints
483 [ foldr renderHint (indent (renderSimpleErrorMessage simple)) hints
433− , Box.moveDown 1 typeInformation
485+ maybe [] (return . Box.moveDown 1) typeInformation ++
434− , Box.moveDown 1 $ paras [ line $ "See " ++ wikiUri ++ " for more information, "
486+ [ Box.moveDown 1 $ paras [ line $ "See " ++ wikiUri e ++ " for more information, "
435− , line $ "or to contribute content related to this " ++ levelText ++ "."
487+ , line $ "or to contribute content related to this " ++ levelText ++ "."
439− wikiUri :: String
492+ typeInformation :: Maybe Box.Box
440− wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
442− typeInformation :: Box.Box
443− typeInformation | not (null types) = Box.hsep 1 Box.left [ line "where", paras types]
493+ typeInformation | not (null types) = Just $ Box.hsep 1 Box.left [ line "where", paras types ]
444− | otherwise = Box.emptyBox 0 0
494+ | otherwise = Nothing
446 types :: [Box.Box]
496 types :: [Box.Box]
447 types = map skolemInfo (M.elems (umSkolemMap typeMap)) ++
497 types = map skolemInfo (M.elems (umSkolemMap typeMap)) ++
@@ -556,6 +606,13 @@ prettyPrintSingleError full level e = do
556 paras [ line $ "Conflicting definitions are in scope for " ++ nm ++ " from the following modules:"
606 paras [ line $ "Conflicting definitions are in scope for " ++ nm ++ " from the following modules:"
557 , indent $ paras $ map (line . runModuleName) ms
607 , indent $ paras $ map (line . runModuleName) ms
609+ renderSimpleErrorMessage (ScopeShadowing nm exmn ms) =
610+ paras [ line $ "Shadowed definitions are in scope for " ++ nm ++ " from the following open imports:"
611+ , indent $ paras $ map (line . ("import " ++) . runModuleName) ms
612+ , line $ "These will be ignored and the " ++ case exmn of
613+ Just exmn' -> "declaration from " ++ runModuleName exmn' ++ " will be used."
614+ Nothing -> "local declaration will be used."
559 renderSimpleErrorMessage (ConflictingTypeDecls nm) =
616 renderSimpleErrorMessage (ConflictingTypeDecls nm) =
560 line $ "Conflicting type declarations for " ++ runProperName nm
617 line $ "Conflicting type declarations for " ++ runProperName nm
561 renderSimpleErrorMessage (ConflictingCtorDecls nm) =
618 renderSimpleErrorMessage (ConflictingCtorDecls nm) =
@@ -745,6 +802,10 @@ prettyPrintSingleError full level e = do
745 paras [ line $ "An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: "
802 paras [ line $ "An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: "
746 , indent $ paras $ map (line . prettyPrintExport) ys
803 , indent $ paras $ map (line . prettyPrintExport) ys
805+ renderSimpleErrorMessage (TransitiveDctorExportError x ctor) =
806+ paras [ line $ "An export for " ++ prettyPrintExport x ++ " requires the following data constructor to also be exported: "
807+ , indent $ line $ runProperName ctor
748 renderSimpleErrorMessage (ShadowedName nm) =
809 renderSimpleErrorMessage (ShadowedName nm) =
749 line $ "Name '" ++ showIdent nm ++ "' was shadowed."
810 line $ "Name '" ++ showIdent nm ++ "' was shadowed."
750 renderSimpleErrorMessage (ShadowedTypeVar tv) =
811 renderSimpleErrorMessage (ShadowedTypeVar tv) =
@@ -759,7 +820,7 @@ prettyPrintSingleError full level e = do
759 renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
820 renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
760 line $ "Importing type " ++ runProperName name ++ "(..) from " ++ runModuleName mn ++ " is misleading as it has no exported data constructors."
821 line $ "Importing type " ++ runProperName name ++ "(..) from " ++ runModuleName mn ++ " is misleading as it has no exported data constructors."
761 renderSimpleErrorMessage (ImportHidingModule name) =
822 renderSimpleErrorMessage (ImportHidingModule name) =
762− paras [ line $ "'hiding' imports cannot be used to hide modules."
823+ paras [ line "'hiding' imports cannot be used to hide modules."
763 , line $ "An attempt was made to hide the import of " ++ runModuleName name
824 , line $ "An attempt was made to hide the import of " ++ runModuleName name
765 renderSimpleErrorMessage (WildcardInferredType ty) =
826 renderSimpleErrorMessage (WildcardInferredType ty) =
@@ -773,14 +834,14 @@ prettyPrintSingleError full level e = do
773 , indent $ typeAsBox ty
834 , indent $ typeAsBox ty
775 renderSimpleErrorMessage (NotExhaustivePattern bs b) =
836 renderSimpleErrorMessage (NotExhaustivePattern bs b) =
776− paras $ [ line "A case expression could not be determined to cover all inputs."
837+ paras [ line "A case expression could not be determined to cover all inputs."
777− , line "The following additional cases are required to cover all inputs:\n"
838+ , line "The following additional cases are required to cover all inputs:\n"
778− , indent $ paras $
839+ , indent $ paras $
779− [ Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs)) ]
840+ [ Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs)) ]
780− ++ [ line "..." | not b ]
841+ ++ [ line "..." | not b ]
781− , line "Or alternatively, add a Partial constraint to the type of the enclosing value."
842+ , line "Or alternatively, add a Partial constraint to the type of the enclosing value."
782− , line "Non-exhaustive patterns for values without a `Partial` constraint will be disallowed in PureScript 0.9."
843+ , line "Non-exhaustive patterns for values without a `Partial` constraint will be disallowed in PureScript 0.9."
784 renderSimpleErrorMessage (OverlappingPattern bs b) =
845 renderSimpleErrorMessage (OverlappingPattern bs b) =
785 paras $ [ line "A case expression contains unreachable cases:\n"
846 paras $ [ line "A case expression contains unreachable cases:\n"
786 , Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
847 , Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
@@ -793,9 +854,11 @@ prettyPrintSingleError full level e = do
793 renderSimpleErrorMessage (UnusedImport name) =
854 renderSimpleErrorMessage (UnusedImport name) =
794 line $ "The import of module " ++ runModuleName name ++ " is redundant"
855 line $ "The import of module " ++ runModuleName name ++ " is redundant"
796− renderSimpleErrorMessage (UnusedExplicitImport name names) =
857+ renderSimpleErrorMessage msg@(UnusedExplicitImport mn names _ _) =
797− paras [ line $ "The import of module " ++ runModuleName name ++ " contains the following unused references:"
858+ paras [ line $ "The import of module " ++ runModuleName mn ++ " contains the following unused references:"
798− , indent $ paras $ map line names ]
859+ , indent $ paras $ map line names
860+ , line "It could be replaced with:"
861+ , indent $ line $ showSuggestion msg ]
800 renderSimpleErrorMessage (UnusedDctorImport name) =
863 renderSimpleErrorMessage (UnusedDctorImport name) =
801 line $ "The import of type " ++ runProperName name ++ " includes data constructors but only the type is used"
864 line $ "The import of type " ++ runProperName name ++ " includes data constructors but only the type is used"
@@ -808,15 +871,39 @@ prettyPrintSingleError full level e = do
808 paras [ line $ "The operator (" ++ name ++ ") was declared as a value rather than an alias for a named function."
871 paras [ line $ "The operator (" ++ name ++ ") was declared as a value rather than an alias for a named function."
809 , line "Operator aliases are declared by using a fixity declaration, for example:"
872 , line "Operator aliases are declared by using a fixity declaration, for example:"
810 , indent $ line $ "infixl 9 someFunction as " ++ name
873 , indent $ line $ "infixl 9 someFunction as " ++ name
811− , line $ "Support for value-declared operators will be removed in PureScript 0.9."
874+ , line "Support for value-declared operators will be removed in PureScript 0.9."
877+ renderSimpleErrorMessage (DeprecatedOperatorSection op val) =
878+ paras [ line "An operator section uses legacy syntax. Operator sections are now written using anonymous function syntax:"
879+ , indent $ foldr1 before $
883+ , prettyPrintValue valueDepth l
892+ , prettyPrintValue valueDepth r
895+ , line "Support for legacy operator sections will be removed in PureScript 0.9."
898+ renderOperator (PositionedValue _ _ ex) = renderOperator ex
899+ renderOperator (Var (Qualified _ (Op ident))) = line ident
900+ renderOperator other = Box.hcat Box.top [ line "`", prettyPrintValue valueDepth other, line "`" ]
814 renderSimpleErrorMessage (DeprecatedQualifiedSyntax name qualName) =
901 renderSimpleErrorMessage (DeprecatedQualifiedSyntax name qualName) =
815− paras [ line $ "Import uses the deprecated 'qualified' syntax:"
902+ paras [ line "Import uses the deprecated 'qualified' syntax:"
816 , indent $ line $ "import qualified " ++ runModuleName name ++ " as " ++ runModuleName qualName
903 , indent $ line $ "import qualified " ++ runModuleName name ++ " as " ++ runModuleName qualName
817 , line "Should instead use the form:"
904 , line "Should instead use the form:"
818 , indent $ line $ "import " ++ runModuleName name ++ " as " ++ runModuleName qualName
905 , indent $ line $ "import " ++ runModuleName name ++ " as " ++ runModuleName qualName
819− , line $ "The deprecated syntax will be removed in PureScript 0.9."
906+ , line "The deprecated syntax will be removed in PureScript 0.9."
822 renderSimpleErrorMessage (DeprecatedClassImport mn name) =
909 renderSimpleErrorMessage (DeprecatedClassImport mn name) =
@@ -824,15 +911,15 @@ prettyPrintSingleError full level e = do
824 , indent $ line $ runProperName name
911 , indent $ line $ runProperName name
825 , line "Should instead use the form:"
912 , line "Should instead use the form:"
826 , indent $ line $ "class " ++ runProperName name
913 , indent $ line $ "class " ++ runProperName name
827− , line $ "The deprecated syntax will be removed in PureScript 0.9."
914+ , line "The deprecated syntax will be removed in PureScript 0.9."
830 renderSimpleErrorMessage (DeprecatedClassExport name) =
917 renderSimpleErrorMessage (DeprecatedClassExport name) =
831− paras [ line $ "Class export uses deprecated syntax that omits the 'class' keyword:"
918+ paras [ line "Class export uses deprecated syntax that omits the 'class' keyword:"
832 , indent $ line $ runProperName name
919 , indent $ line $ runProperName name
833 , line "Should instead use the form:"
920 , line "Should instead use the form:"
834 , indent $ line $ "class " ++ runProperName name
921 , indent $ line $ "class " ++ runProperName name
835− , line $ "The deprecated syntax will be removed in PureScript 0.9."
922+ , line "The deprecated syntax will be removed in PureScript 0.9."
838 renderSimpleErrorMessage (RedundantUnqualifiedImport name imp) =
925 renderSimpleErrorMessage (RedundantUnqualifiedImport name imp) =
@@ -857,15 +944,35 @@ prettyPrintSingleError full level e = do
857 renderSimpleErrorMessage (RedundantEmptyHidingImport mn) =
944 renderSimpleErrorMessage (RedundantEmptyHidingImport mn) =
858 line $ "The import for module " ++ runModuleName mn ++ " is redundant as all members have been explicitly hidden."
945 line $ "The import for module " ++ runModuleName mn ++ " is redundant as all members have been explicitly hidden."
860− renderSimpleErrorMessage (ImplicitImport mn refs) =
947+ renderSimpleErrorMessage msg@(ImplicitQualifiedImport importedModule asModule _) =
948+ paras [ line $ "Module " ++ runModuleName importedModule ++ " was imported as " ++ runModuleName asModule ++ " with unspecified imports."
949+ , line $ "As there are multiple modules being imported as " ++ runModuleName asModule ++ ", consider using the explicit form:"
950+ , indent $ line $ showSuggestion msg
953+ renderSimpleErrorMessage msg@(ImplicitImport mn _) =
861 paras [ line $ "Module " ++ runModuleName mn ++ " has unspecified imports, consider using the explicit form: "
954 paras [ line $ "Module " ++ runModuleName mn ++ " has unspecified imports, consider using the explicit form: "
955+ , indent $ line $ showSuggestion msg
958+ renderSimpleErrorMessage (HidingImport mn refs) =
959+ paras [ line $ "Module " ++ runModuleName mn ++ " has unspecified imports, consider using the inclusive form: "
862 , indent $ line $ "import " ++ runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")"
960 , indent $ line $ "import " ++ runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")"
865 renderSimpleErrorMessage (CaseBinderLengthDiffers l bs) =
963 renderSimpleErrorMessage (CaseBinderLengthDiffers l bs) =
866− paras $ [ line $ "Binder list length differs in case alternative:"
964+ paras [ line "Binder list length differs in case alternative:"
867− , indent $ line $ intercalate ", " $ fmap prettyPrintBinderAtom bs
965+ , indent $ line $ intercalate ", " $ fmap prettyPrintBinderAtom bs
868− , line $ "Expecting " ++ show l ++ " binder" ++ (if l == 1 then "" else "s") ++ "." ]
966+ , line $ "Expecting " ++ show l ++ " binder" ++ (if l == 1 then "" else "s") ++ "."
969+ renderSimpleErrorMessage IncorrectAnonymousArgument =
970+ line "An anonymous function argument appears in an invalid context."
972+ renderSimpleErrorMessage (InvalidOperatorInBinder op fn) =
973+ paras $ [ line $ "Operator " ++ showIdent op ++ " cannot be used in a pattern as it is an alias for function " ++ showIdent fn ++ "."
974+ , line "Only aliases for data constructors may be used in patterns."
870 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
977 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
871 renderHint (ErrorUnifyingTypes t1 t2) detail =
978 renderHint (ErrorUnifyingTypes t1 t2) detail =
@@ -995,38 +1102,13 @@ prettyPrintSingleError full level e = do
995 paras :: [Box.Box] -> Box.Box
1102 paras :: [Box.Box] -> Box.Box
996 paras = Box.vcat Box.left
1103 paras = Box.vcat Box.left
998− -- Pretty print and export declaration
999− prettyPrintExport :: DeclarationRef -> String
1000− prettyPrintExport (TypeRef pn _) = runProperName pn
1001− prettyPrintExport ref = prettyPrintRef ref
1003− prettyPrintRef :: DeclarationRef -> String
1004− prettyPrintRef (TypeRef pn Nothing) = runProperName pn ++ "(..)"
1005− prettyPrintRef (TypeRef pn (Just [])) = runProperName pn
1006− prettyPrintRef (TypeRef pn (Just dctors)) = runProperName pn ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
1007− prettyPrintRef (ValueRef ident) = showIdent ident
1008− prettyPrintRef (TypeClassRef pn) = "class " ++ runProperName pn
1009− prettyPrintRef (ProperRef pn) = runProperName pn
1010− prettyPrintRef (TypeInstanceRef ident) = showIdent ident
1011− prettyPrintRef (ModuleRef name) = "module " ++ runModuleName name
1012− prettyPrintRef (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
1014− prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> String
1015− prettyPrintImport mn idt qual =
1016− let i = case idt of
1017− Implicit True -> runModuleName mn ++ " (..)"
1018− Implicit False -> runModuleName mn
1019− Explicit refs -> runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")"
1020− Hiding refs -> runModuleName mn ++ " hiding (" ++ intercalate "," (map prettyPrintRef refs) ++ ")"
1021− in i ++ maybe "" (\q -> " as " ++ runModuleName q) qual
1023 -- | Simplify an error message
1105 -- | Simplify an error message
1024 simplifyErrorMessage :: ErrorMessage -> ErrorMessage
1106 simplifyErrorMessage :: ErrorMessage -> ErrorMessage
1025 simplifyErrorMessage (ErrorMessage hints simple) = ErrorMessage (simplifyHints hints) simple
1107 simplifyErrorMessage (ErrorMessage hints simple) = ErrorMessage (simplifyHints hints) simple
1027 -- Take the last instance of each "hint category"
1109 -- Take the last instance of each "hint category"
1028 simplifyHints :: [ErrorMessageHint] -> [ErrorMessageHint]
1110 simplifyHints :: [ErrorMessageHint] -> [ErrorMessageHint]
1029− simplifyHints = reverse . nubBy categoriesEqual . reverse
1111+ simplifyHints = reverse . nubBy categoriesEqual . stripRedudantHints simple . reverse
1031 -- Don't remove hints in the "other" category
1113 -- Don't remove hints in the "other" category
1032 categoriesEqual :: ErrorMessageHint -> ErrorMessageHint -> Bool
1114 categoriesEqual :: ErrorMessageHint -> ErrorMessageHint -> Bool
@@ -1036,6 +1118,30 @@ prettyPrintSingleError full level e = do
1036 (_, OtherHint) -> False
1118 (_, OtherHint) -> False
1037 (c1, c2) -> c1 == c2
1119 (c1, c2) -> c1 == c2
1121+ -- | See https://github.com/purescript/purescript/issues/1802
1122+ stripRedudantHints :: SimpleErrorMessage -> [ErrorMessageHint] -> [ErrorMessageHint]
1123+ stripRedudantHints CannotApplyFunction{} = stripFirst isApplicationHint
1125+ isApplicationHint ErrorInApplication{} = True
1126+ isApplicationHint _ = False
1127+ stripRedudantHints ExprDoesNotHaveType{} = stripFirst isCheckHint
1129+ isCheckHint ErrorCheckingType{} = True
1130+ isCheckHint _ = False
1131+ stripRedudantHints TypesDoNotUnify{} = stripFirst isUnifyHint
1133+ isUnifyHint ErrorUnifyingTypes{} = True
1134+ isUnifyHint _ = False
1135+ stripRedudantHints _ = id
1137+ stripFirst :: (ErrorMessageHint -> Bool) -> [ErrorMessageHint] -> [ErrorMessageHint]
1138+ stripFirst p (PositionedError pos : hs) = PositionedError pos : stripFirst p hs
1139+ stripFirst p (ErrorInModule mn : hs) = ErrorInModule mn : stripFirst p hs
1140+ stripFirst p (hint : hs)
1142+ | otherwise = hint : hs
1143+ stripFirst _ [] = []
1039 hintCategory :: ErrorMessageHint -> HintCategory
1145 hintCategory :: ErrorMessageHint -> HintCategory
1040 hintCategory ErrorCheckingType{} = ExprHint
1146 hintCategory ErrorCheckingType{} = ExprHint
1041 hintCategory ErrorInferringType{} = ExprHint
1147 hintCategory ErrorInferringType{} = ExprHint
@@ -1047,36 +1153,60 @@ prettyPrintSingleError full level e = do
1047 hintCategory PositionedError{} = PositionHint
1153 hintCategory PositionedError{} = PositionHint
1048 hintCategory _ = OtherHint
1154 hintCategory _ = OtherHint
1156+-- Pretty print and export declaration
1157+prettyPrintExport :: DeclarationRef -> String
1158+prettyPrintExport (TypeRef pn _) = runProperName pn
1159+prettyPrintExport ref = prettyPrintRef ref
1161+prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> String
1162+prettyPrintImport mn idt qual =
1163+ let i = case idt of
1164+ Implicit -> runModuleName mn
1165+ Explicit refs -> runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")"
1166+ Hiding refs -> runModuleName mn ++ " hiding (" ++ intercalate "," (map prettyPrintRef refs) ++ ")"
1167+ in i ++ maybe "" (\q -> " as " ++ runModuleName q) qual
1169+prettyPrintRef :: DeclarationRef -> String
1170+prettyPrintRef (TypeRef pn Nothing) = runProperName pn ++ "(..)"
1171+prettyPrintRef (TypeRef pn (Just [])) = runProperName pn
1172+prettyPrintRef (TypeRef pn (Just dctors)) = runProperName pn ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
1173+prettyPrintRef (ValueRef ident) = showIdent ident
1174+prettyPrintRef (TypeClassRef pn) = "class " ++ runProperName pn
1175+prettyPrintRef (ProperRef name) = name
1176+prettyPrintRef (TypeInstanceRef ident) = showIdent ident
1177+prettyPrintRef (ModuleRef name) = "module " ++ runModuleName name
1178+prettyPrintRef (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
1051-- Pretty print multiple errors
1181-- Pretty print multiple errors
1053prettyPrintMultipleErrors :: Bool -> MultipleErrors -> String
1183prettyPrintMultipleErrors :: Bool -> MultipleErrors -> String
1054−prettyPrintMultipleErrors full = renderBox . prettyPrintMultipleErrorsBox full
1184+prettyPrintMultipleErrors full = unlines . map renderBox . prettyPrintMultipleErrorsBox full
1057-- Pretty print multiple warnings
1187-- Pretty print multiple warnings
1059−prettyPrintMultipleWarnings :: Bool -> MultipleErrors -> String
1189+prettyPrintMultipleWarnings :: Bool -> MultipleErrors -> String
1060−prettyPrintMultipleWarnings full = renderBox . prettyPrintMultipleWarningsBox full
1190+prettyPrintMultipleWarnings full = unlines . map renderBox . prettyPrintMultipleWarningsBox full
1062-- | Pretty print warnings as a Box
1192-- | Pretty print warnings as a Box
1063−prettyPrintMultipleWarningsBox :: Bool -> MultipleErrors -> Box.Box
1193+prettyPrintMultipleWarningsBox :: Bool -> MultipleErrors -> [Box.Box]
1064−prettyPrintMultipleWarningsBox full = flip evalState defaultUnknownMap . prettyPrintMultipleErrorsWith Warning "Warning found:" "Warning" full
1194+prettyPrintMultipleWarningsBox full = prettyPrintMultipleErrorsWith Warning "Warning found:" "Warning" full
1066-- | Pretty print errors as a Box
1196-- | Pretty print errors as a Box
1067−prettyPrintMultipleErrorsBox :: Bool -> MultipleErrors -> Box.Box
1197+prettyPrintMultipleErrorsBox :: Bool -> MultipleErrors -> [Box.Box]
1068−prettyPrintMultipleErrorsBox full = flip evalState defaultUnknownMap . prettyPrintMultipleErrorsWith Error "Error found:" "Error" full
1198+prettyPrintMultipleErrorsBox full = prettyPrintMultipleErrorsWith Error "Error found:" "Error" full
1070−prettyPrintMultipleErrorsWith :: Level -> String -> String -> Bool -> MultipleErrors -> State TypeMap Box.Box
1200+prettyPrintMultipleErrorsWith :: Level -> String -> String -> Bool -> MultipleErrors -> [Box.Box]
1071−prettyPrintMultipleErrorsWith level intro _ full (MultipleErrors [e]) = do
1201+prettyPrintMultipleErrorsWith level intro _ full (MultipleErrors [e]) =
1072− result <- prettyPrintSingleError full level e
1202+ let result = prettyPrintSingleError full level True e
1074− Box.vcat Box.left [ Box.text intro
1203+ in [ Box.vcat Box.left [ Box.text intro
1075− , result
1204+ , result
1077−prettyPrintMultipleErrorsWith level _ intro full (MultipleErrors es) = do
1207+prettyPrintMultipleErrorsWith level _ intro full (MultipleErrors es) =
1078− result <- forM es $ prettyPrintSingleError full level
1208+ let result = map (prettyPrintSingleError full level True) es
1079− return $ Box.vsep 1 Box.left $ concat $ zipWith withIntro [1 :: Int ..] result
1209+ in concat $ zipWith withIntro [1 :: Int ..] result
1081 withIntro i err = [ Box.text (intro ++ " " ++ show i ++ " of " ++ show (length es) ++ ":")
1211 withIntro i err = [ Box.text (intro ++ " " ++ show i ++ " of " ++ show (length es) ++ ":")
1082 , Box.moveRight 2 err
1212 , Box.moveRight 2 err
@@ -1138,9 +1268,15 @@ line :: String -> Box.Box
1138line = Box.text
1268line = Box.text
1140renderBox :: Box.Box -> String
1270renderBox :: Box.Box -> String
1141−renderBox = unlines . map trimEnd . lines . Box.render
1271+renderBox = unlines
1272+ . map (dropWhileEnd isSpace)
1273+ . dropWhile whiteSpace
1274+ . dropWhileEnd whiteSpace
1143− trimEnd = reverse . dropWhile (== ' ') . reverse
1278+ dropWhileEnd p = reverse . dropWhile p . reverse
1279+ whiteSpace = all isSpace
1146-- Rethrow an error with a more detailed error message in the case of failure
1282-- Rethrow an error with a more detailed error message in the case of failure
@@ -1148,7 +1284,7 @@ renderBox = unlines . map trimEnd . lines . Box.render
1148rethrow :: (MonadError e m) => (e -> e) -> m a -> m a
1284rethrow :: (MonadError e m) => (e -> e) -> m a -> m a
1149rethrow f = flip catchError $ \e -> throwError (f e)
1285rethrow f = flip catchError $ \e -> throwError (f e)
1151−reifyErrors :: (Functor m, MonadError e m) => m a -> m (Either e a)
1287+reifyErrors :: (MonadError e m) => m a -> m (Either e a)
1152reifyErrors ma = catchError (fmap Right ma) (return . Left)
1288reifyErrors ma = catchError (fmap Right ma) (return . Left)
1154reflectErrors :: (MonadError e m) => m (Either e a) -> m a
1290reflectErrors :: (MonadError e m) => m (Either e a) -> m a
@@ -1175,13 +1311,13 @@ withPosition pos (ErrorMessage hints se) = ErrorMessage (PositionedError pos : h
1176-- Collect errors in in parallel
1312-- Collect errors in in parallel
1178−parU :: (MonadError MultipleErrors m, Functor m) => [a] -> (a -> m b) -> m [b]
1314+parU :: (MonadError MultipleErrors m) => [a] -> (a -> m b) -> m [b]
1179parU xs f = forM xs (withError . f) >>= collectErrors
1315parU xs f = forM xs (withError . f) >>= collectErrors
1181− withError :: (MonadError MultipleErrors m, Functor m) => m a -> m (Either MultipleErrors a)
1317+ withError :: (MonadError MultipleErrors m) => m a -> m (Either MultipleErrors a)
1182 withError u = catchError (Right <$> u) (return . Left)
1318 withError u = catchError (Right <$> u) (return . Left)
1184− collectErrors :: (MonadError MultipleErrors m, Functor m) => [Either MultipleErrors a] -> m [a]
1320+ collectErrors :: (MonadError MultipleErrors m) => [Either MultipleErrors a] -> m [a]
1185 collectErrors es = case lefts es of
1321 collectErrors es = case lefts es of
1186 [] -> return $ rights es
1322 [] -> return $ rights es
1187 errs -> throwError $ fold errs
1323 errs -> throwError $ fold errs