@@ -18,10 +18,12 @@ import Data.Char (isSpace)
18import Data.Either (lefts, rights)
18import Data.Either (lefts, rights)
19import Data.Foldable (fold)
19import Data.Foldable (fold)
20import Data.Functor.Identity (Identity(..))
20import Data.Functor.Identity (Identity(..))
21−import Data.List (intercalate, transpose, nub, nubBy, sortBy, partition)
21+import Data.List (transpose, nub, nubBy, sortBy, partition)
22import Data.Maybe (maybeToList, fromMaybe, mapMaybe)
22import Data.Maybe (maybeToList, fromMaybe, mapMaybe)
23import Data.Ord (comparing)
23import Data.Ord (comparing)
24import qualified Data.Map as M
24import qualified Data.Map as M
25+import qualified Data.Text as T
26+import Data.Text (Text)
26import Language.PureScript.AST
28import Language.PureScript.AST
27import Language.PureScript.Crash
29import Language.PureScript.Crash
@@ -43,7 +45,7 @@ import qualified Text.PrettyPrint.Boxes as Box
43import qualified Language.PureScript.Publish.BoxesHelpers as BoxHelpers
45import qualified Language.PureScript.Publish.BoxesHelpers as BoxHelpers
44import Text.Parsec.Error (Message(..))
46import Text.Parsec.Error (Message(..))
46−newtype ErrorSuggestion = ErrorSuggestion String
48+newtype ErrorSuggestion = ErrorSuggestion Text
48-- | Get the source span for an error
50-- | Get the source span for an error
49errorSpan :: ErrorMessage -> Maybe SourceSpan
51errorSpan :: ErrorMessage -> Maybe SourceSpan
@@ -73,7 +75,7 @@ stripModuleAndSpan (ErrorMessage hints e) = ErrorMessage (filter (not . shouldSt
74-- Get the error code for a particular error type
76-- Get the error code for a particular error type
76−errorCode :: ErrorMessage -> String
78+errorCode :: ErrorMessage -> Text
77errorCode em = case unwrapErrorMessage em of
79errorCode em = case unwrapErrorMessage em of
78 ErrorParsingFFIModule{} -> "ErrorParsingFFIModule"
80 ErrorParsingFFIModule{} -> "ErrorParsingFFIModule"
79 ErrorParsingModule{} -> "ErrorParsingModule"
81 ErrorParsingModule{} -> "ErrorParsingModule"
@@ -245,7 +247,7 @@ replaceUnknowns = everywhereOnTypesM replaceTypes
245 case M.lookup s (umSkolemMap m) of
247 case M.lookup s (umSkolemMap m) of
246 Nothing -> do
248 Nothing -> do
247 let s' = umNextIndex m
249 let s' = umNextIndex m
248− put $ m { umSkolemMap = M.insert s (name, s', ss) (umSkolemMap m), umNextIndex = s' + 1 }
250+ put $ m { umSkolemMap = M.insert s (T.unpack name, s', ss) (umSkolemMap m), umNextIndex = s' + 1 }
249 return (Skolem name s' sko ss)
251 return (Skolem name s' sko ss)
250 Just (_, s', _) -> return (Skolem name s' sko ss)
252 Just (_, s', _) -> return (Skolem name s' sko ss)
251 replaceTypes other = return other
253 replaceTypes other = return other
@@ -287,8 +289,8 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
287 gTypeSearch (TSBefore env) = pure (TSBefore env)
289 gTypeSearch (TSBefore env) = pure (TSBefore env)
288 gTypeSearch (TSAfter result) = TSAfter <$> traverse (traverse f) result
290 gTypeSearch (TSAfter result) = TSAfter <$> traverse (traverse f) result
290−wikiUri :: ErrorMessage -> String
292+wikiUri :: ErrorMessage -> Text
291−wikiUri e = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
293+wikiUri e = "https://github.com/purescript/purescript/wiki/Error-Code-" <> errorCode e
293-- TODO Other possible suggestions:
295-- TODO Other possible suggestions:
294-- WildcardInferredType - source span not small enough
296-- WildcardInferredType - source span not small enough
@@ -304,19 +306,19 @@ errorSuggestion err =
304 ImplicitImport mn refs -> suggest $ importSuggestion mn refs Nothing
306 ImplicitImport mn refs -> suggest $ importSuggestion mn refs Nothing
305 ImplicitQualifiedImport mn asModule refs -> suggest $ importSuggestion mn refs (Just asModule)
307 ImplicitQualifiedImport mn asModule refs -> suggest $ importSuggestion mn refs (Just asModule)
306 HidingImport mn refs -> suggest $ importSuggestion mn refs Nothing
308 HidingImport mn refs -> suggest $ importSuggestion mn refs Nothing
307− MissingTypeDeclaration ident ty -> suggest $ showIdent ident ++ " :: " ++ prettyPrintSuggestedType ty
309+ MissingTypeDeclaration ident ty -> suggest $ showIdent ident <> " :: " <> T.pack (prettyPrintSuggestedType ty)
308− WildcardInferredType ty _ -> suggest $ prettyPrintSuggestedType ty
310+ WildcardInferredType ty _ -> suggest $ T.pack (prettyPrintSuggestedType ty)
309 _ -> Nothing
311 _ -> Nothing
311 emptySuggestion = Just $ ErrorSuggestion ""
313 emptySuggestion = Just $ ErrorSuggestion ""
312 suggest = Just . ErrorSuggestion
314 suggest = Just . ErrorSuggestion
314− importSuggestion :: ModuleName -> [ DeclarationRef ] -> Maybe ModuleName -> String
316+ importSuggestion :: ModuleName -> [ DeclarationRef ] -> Maybe ModuleName -> Text
315 importSuggestion mn refs qual =
317 importSuggestion mn refs qual =
316− "import " ++ runModuleName mn ++ " (" ++ intercalate ", " (mapMaybe prettyPrintRef refs) ++ ")" ++ qstr qual
318+ "import " <> runModuleName mn <> " (" <> T.intercalate ", " (mapMaybe prettyPrintRef refs) <> ")" <> qstr qual
318− qstr :: Maybe ModuleName -> String
320+ qstr :: Maybe ModuleName -> Text
319− qstr (Just mn) = " as " ++ runModuleName mn
321+ qstr (Just mn) = " as " <> runModuleName mn
320 qstr Nothing = ""
322 qstr Nothing = ""
322suggestionSpan :: ErrorMessage -> Maybe SourceSpan
324suggestionSpan :: ErrorMessage -> Maybe SourceSpan
@@ -330,7 +332,7 @@ suggestionSpan e =
330 MissingTypeDeclaration{} -> startOnly ss
332 MissingTypeDeclaration{} -> startOnly ss
333−showSuggestion :: SimpleErrorMessage -> String
335+showSuggestion :: SimpleErrorMessage -> Text
334showSuggestion suggestion = case errorSuggestion suggestion of
336showSuggestion suggestion = case errorSuggestion suggestion of
335 Just (ErrorSuggestion x) -> x
337 Just (ErrorSuggestion x) -> x
@@ -343,10 +345,10 @@ ansiColorReset :: String
343ansiColorReset =
345ansiColorReset =
344 ANSI.setSGRCode [ANSI.Reset]
346 ANSI.setSGRCode [ANSI.Reset]
346−colorCode :: Maybe (ANSI.ColorIntensity, ANSI.Color) -> String -> String
348+colorCode :: Maybe (ANSI.ColorIntensity, ANSI.Color) -> Text -> Text
347colorCode codeColor code = case codeColor of
349colorCode codeColor code = case codeColor of
348 Nothing -> code
350 Nothing -> code
349− Just cc -> concat [ansiColor cc, code, ansiColorReset]
351+ Just cc -> T.pack (ansiColor cc) <> code <> T.pack ansiColorReset
351colorCodeBox :: Maybe (ANSI.ColorIntensity, ANSI.Color) -> Box.Box -> Box.Box
353colorCodeBox :: Maybe (ANSI.ColorIntensity, ANSI.Color) -> Box.Box -> Box.Box
352colorCodeBox codeColor b = case codeColor of
354colorCodeBox codeColor b = case codeColor of
@@ -403,8 +405,8 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
404 maybe [] (return . Box.moveDown 1) typeInformation ++
406 maybe [] (return . Box.moveDown 1) typeInformation ++
405 [ Box.moveDown 1 $ paras
407 [ Box.moveDown 1 $ paras
406− [ line $ "See " ++ wikiUri e ++ " for more information, "
408+ [ line $ "See " <> wikiUri e <> " for more information, "
407− , line $ "or to contribute content related to this " ++ levelText ++ "."
409+ , line $ "or to contribute content related to this " <> levelText <> "."
409 | showWiki
411 | showWiki
@@ -420,59 +422,59 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
420 skolemInfo :: (String, Int, Maybe SourceSpan) -> Box.Box
422 skolemInfo :: (String, Int, Maybe SourceSpan) -> Box.Box
421 skolemInfo (name, s, ss) =
423 skolemInfo (name, s, ss) =
423− line (markCode (name ++ show s) ++ " is a rigid type variable")
425+ line (markCode (T.pack (name <> show s)) <> " is a rigid type variable")
424− : foldMap (return . line . (" bound at " ++) . displayStartEndPos) ss
426+ : foldMap (return . line . (" bound at " <>) . displayStartEndPos) ss
426 unknownInfo :: Int -> Box.Box
428 unknownInfo :: Int -> Box.Box
427− unknownInfo u = line $ markCode ("t" ++ show u) ++ " is an unknown type"
429+ unknownInfo u = line $ markCode ("t" <> T.pack (show u)) <> " is an unknown type"
429 renderSimpleErrorMessage :: SimpleErrorMessage -> Box.Box
431 renderSimpleErrorMessage :: SimpleErrorMessage -> Box.Box
430 renderSimpleErrorMessage (CannotGetFileInfo path) =
432 renderSimpleErrorMessage (CannotGetFileInfo path) =
431 paras [ line "Unable to read file info: "
433 paras [ line "Unable to read file info: "
432− , indent . line $ path
434+ , indent . lineS $ path
434 renderSimpleErrorMessage (CannotReadFile path) =
436 renderSimpleErrorMessage (CannotReadFile path) =
435 paras [ line "Unable to read file: "
437 paras [ line "Unable to read file: "
436− , indent . line $ path
438+ , indent . lineS $ path
438 renderSimpleErrorMessage (CannotWriteFile path) =
440 renderSimpleErrorMessage (CannotWriteFile path) =
439 paras [ line "Unable to write file: "
441 paras [ line "Unable to write file: "
440− , indent . line $ path
442+ , indent . lineS $ path
442 renderSimpleErrorMessage (ErrorParsingFFIModule path extra) =
444 renderSimpleErrorMessage (ErrorParsingFFIModule path extra) =
443 paras $ [ line "Unable to parse foreign module:"
445 paras $ [ line "Unable to parse foreign module:"
444− , indent . line $ path
446+ , indent . lineS $ path
446− map (indent . line) (concatMap Bundle.printErrorMessage (maybeToList extra))
448+ map (indent . lineS) (concatMap Bundle.printErrorMessage (maybeToList extra))
447 renderSimpleErrorMessage (ErrorParsingModule err) =
449 renderSimpleErrorMessage (ErrorParsingModule err) =
448 paras [ line "Unable to parse module: "
450 paras [ line "Unable to parse module: "
449 , prettyPrintParseError err
451 , prettyPrintParseError err
451 renderSimpleErrorMessage (MissingFFIModule mn) =
453 renderSimpleErrorMessage (MissingFFIModule mn) =
452− line $ "The foreign module implementation for module " ++ markCode (runModuleName mn) ++ " is missing."
454+ line $ "The foreign module implementation for module " <> markCode (runModuleName mn) <> " is missing."
453 renderSimpleErrorMessage (UnnecessaryFFIModule mn path) =
455 renderSimpleErrorMessage (UnnecessaryFFIModule mn path) =
454− paras [ line $ "An unnecessary foreign module implementation was provided for module " ++ markCode (runModuleName mn) ++ ": "
456+ paras [ line $ "An unnecessary foreign module implementation was provided for module " <> markCode (runModuleName mn) <> ": "
455− , indent . line $ path
457+ , indent . lineS $ path
456− , line $ "Module " ++ markCode (runModuleName mn) ++ " does not contain any foreign import declarations, so a foreign module is not necessary."
458+ , line $ "Module " <> markCode (runModuleName mn) <> " does not contain any foreign import declarations, so a foreign module is not necessary."
458 renderSimpleErrorMessage (MissingFFIImplementations mn idents) =
460 renderSimpleErrorMessage (MissingFFIImplementations mn idents) =
459− paras [ line $ "The following values are not defined in the foreign module for module " ++ markCode (runModuleName mn) ++ ": "
461+ paras [ line $ "The following values are not defined in the foreign module for module " <> markCode (runModuleName mn) <> ": "
460 , indent . paras $ map (line . runIdent) idents
462 , indent . paras $ map (line . runIdent) idents
462 renderSimpleErrorMessage (UnusedFFIImplementations mn idents) =
464 renderSimpleErrorMessage (UnusedFFIImplementations mn idents) =
463− paras [ line $ "The following definitions in the foreign module for module " ++ markCode (runModuleName mn) ++ " are unused: "
465+ paras [ line $ "The following definitions in the foreign module for module " <> markCode (runModuleName mn) <> " are unused: "
464 , indent . paras $ map (line . runIdent) idents
466 , indent . paras $ map (line . runIdent) idents
466 renderSimpleErrorMessage (InvalidFFIIdentifier mn ident) =
468 renderSimpleErrorMessage (InvalidFFIIdentifier mn ident) =
467− paras [ line $ "In the FFI module for " ++ markCode (runModuleName mn) ++ ":"
469+ paras [ line $ "In the FFI module for " <> markCode (runModuleName mn) <> ":"
468 , indent . paras $
470 , indent . paras $
469− [ line $ "The identifier " ++ markCode ident ++ " is not valid in PureScript."
471+ [ line $ "The identifier " <> markCode ident <> " is not valid in PureScript."
470 , line "Note that exported identifiers in FFI modules must be valid PureScript identifiers."
472 , line "Note that exported identifiers in FFI modules must be valid PureScript identifiers."
473 renderSimpleErrorMessage (MultipleFFIModules mn paths) =
475 renderSimpleErrorMessage (MultipleFFIModules mn paths) =
474− paras [ line $ "Multiple foreign module implementations have been provided for module " ++ markCode (runModuleName mn) ++ ": "
476+ paras [ line $ "Multiple foreign module implementations have been provided for module " <> markCode (runModuleName mn) <> ": "
475− , indent . paras $ map line paths
477+ , indent . paras $ map lineS paths
477 renderSimpleErrorMessage InvalidDoBind =
479 renderSimpleErrorMessage InvalidDoBind =
478 line "The last statement in a 'do' block must be an expression, but this block ends with a binder."
480 line "The last statement in a 'do' block must be an expression, but this block ends with a binder."
@@ -489,63 +491,63 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
489 , indent $ line $ markCode $ prettyPrintKind ki
491 , indent $ line $ markCode $ prettyPrintKind ki
491 renderSimpleErrorMessage (MultipleValueOpFixities op) =
493 renderSimpleErrorMessage (MultipleValueOpFixities op) =
492− line $ "There are multiple fixity/precedence declarations for operator " ++ markCode (showOp op)
494+ line $ "There are multiple fixity/precedence declarations for operator " <> markCode (showOp op)
493 renderSimpleErrorMessage (MultipleTypeOpFixities op) =
495 renderSimpleErrorMessage (MultipleTypeOpFixities op) =
494− line $ "There are multiple fixity/precedence declarations for type operator " ++ markCode (showOp op)
496+ line $ "There are multiple fixity/precedence declarations for type operator " <> markCode (showOp op)
495 renderSimpleErrorMessage (OrphanTypeDeclaration nm) =
497 renderSimpleErrorMessage (OrphanTypeDeclaration nm) =
496− line $ "The type declaration for " ++ markCode (showIdent nm) ++ " should be followed by its definition."
498+ line $ "The type declaration for " <> markCode (showIdent nm) <> " should be followed by its definition."
497 renderSimpleErrorMessage (RedefinedIdent name) =
499 renderSimpleErrorMessage (RedefinedIdent name) =
498− line $ "The value " ++ markCode (showIdent name) ++ " has been defined multiple times"
500+ line $ "The value " <> markCode (showIdent name) <> " has been defined multiple times"
499 renderSimpleErrorMessage (UnknownName name) =
501 renderSimpleErrorMessage (UnknownName name) =
500− line $ "Unknown " ++ printName name
502+ line $ "Unknown " <> printName name
501 renderSimpleErrorMessage (UnknownImport mn name) =
503 renderSimpleErrorMessage (UnknownImport mn name) =
502− paras [ line $ "Cannot import " ++ printName (Qualified Nothing name) ++ " from module " ++ markCode (runModuleName mn)
504+ paras [ line $ "Cannot import " <> printName (Qualified Nothing name) <> " from module " <> markCode (runModuleName mn)
503 , line "It either does not exist or the module does not export it."
505 , line "It either does not exist or the module does not export it."
505 renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
507 renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
506− line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ markCode (runProperName dcon) ++ " for type " ++ markCode (runProperName tcon)
508+ line $ "Module " <> runModuleName mn <> " does not export data constructor " <> markCode (runProperName dcon) <> " for type " <> markCode (runProperName tcon)
507 renderSimpleErrorMessage (UnknownExport name) =
509 renderSimpleErrorMessage (UnknownExport name) =
508− line $ "Cannot export unknown " ++ printName (Qualified Nothing name)
510+ line $ "Cannot export unknown " <> printName (Qualified Nothing name)
509 renderSimpleErrorMessage (UnknownExportDataConstructor tcon dcon) =
511 renderSimpleErrorMessage (UnknownExportDataConstructor tcon dcon) =
510− line $ "Cannot export data constructor " ++ markCode (runProperName dcon) ++ " for type " ++ markCode (runProperName tcon) ++ ", as it has not been declared."
512+ line $ "Cannot export data constructor " <> markCode (runProperName dcon) <> " for type " <> markCode (runProperName tcon) <> ", as it has not been declared."
511 renderSimpleErrorMessage (ScopeConflict nm ms) =
513 renderSimpleErrorMessage (ScopeConflict nm ms) =
512− paras [ line $ "Conflicting definitions are in scope for " ++ printName (Qualified Nothing nm) ++ " from the following modules:"
514+ paras [ line $ "Conflicting definitions are in scope for " <> printName (Qualified Nothing nm) <> " from the following modules:"
513 , indent $ paras $ map (line . markCode . runModuleName) ms
515 , indent $ paras $ map (line . markCode . runModuleName) ms
515 renderSimpleErrorMessage (ScopeShadowing nm exmn ms) =
517 renderSimpleErrorMessage (ScopeShadowing nm exmn ms) =
516− paras [ line $ "Shadowed definitions are in scope for " ++ printName (Qualified Nothing nm) ++ " from the following open imports:"
518+ paras [ line $ "Shadowed definitions are in scope for " <> printName (Qualified Nothing nm) <> " from the following open imports:"
517− , indent $ paras $ map (line . markCode . ("import " ++) . runModuleName) ms
519+ , indent $ paras $ map (line . markCode . ("import " <>) . runModuleName) ms
518− , line $ "These will be ignored and the " ++ case exmn of
520+ , line $ "These will be ignored and the " <> case exmn of
519− Just exmn' -> "declaration from " ++ markCode (runModuleName exmn') ++ " will be used."
521+ Just exmn' -> "declaration from " <> markCode (runModuleName exmn') <> " will be used."
520 Nothing -> "local declaration will be used."
522 Nothing -> "local declaration will be used."
522 renderSimpleErrorMessage (DeclConflict new existing) =
524 renderSimpleErrorMessage (DeclConflict new existing) =
523− line $ "Declaration for " ++ printName (Qualified Nothing new) ++ " conflicts with an existing " ++ nameType existing ++ " of the same name."
525+ line $ "Declaration for " <> printName (Qualified Nothing new) <> " conflicts with an existing " <> nameType existing <> " of the same name."
524 renderSimpleErrorMessage (ExportConflict new existing) =
526 renderSimpleErrorMessage (ExportConflict new existing) =
525− line $ "Export for " ++ printName new ++ " conflicts with " ++ runName existing
527+ line $ "Export for " <> printName new <> " conflicts with " <> runName existing
526 renderSimpleErrorMessage (DuplicateModule mn ss) =
528 renderSimpleErrorMessage (DuplicateModule mn ss) =
527− paras [ line ("Module " ++ markCode (runModuleName mn) ++ " has been defined multiple times:")
529+ paras [ line ("Module " <> markCode (runModuleName mn) <> " has been defined multiple times:")
528 , indent . paras $ map (line . displaySourceSpan) ss
530 , indent . paras $ map (line . displaySourceSpan) ss
530 renderSimpleErrorMessage (CycleInDeclaration nm) =
532 renderSimpleErrorMessage (CycleInDeclaration nm) =
531− line $ "The value of " ++ markCode (showIdent nm) ++ " is undefined here, so this reference is not allowed."
533+ line $ "The value of " <> markCode (showIdent nm) <> " is undefined here, so this reference is not allowed."
532 renderSimpleErrorMessage (CycleInModules mns) =
534 renderSimpleErrorMessage (CycleInModules mns) =
533 paras [ line "There is a cycle in module dependencies in these modules: "
535 paras [ line "There is a cycle in module dependencies in these modules: "
534 , indent $ paras (map (line . markCode . runModuleName) mns)
536 , indent $ paras (map (line . markCode . runModuleName) mns)
536 renderSimpleErrorMessage (CycleInTypeSynonym name) =
538 renderSimpleErrorMessage (CycleInTypeSynonym name) =
537 paras [ line $ case name of
539 paras [ line $ case name of
538− Just pn -> "A cycle appears in the definition of type synonym " ++ markCode (runProperName pn)
540+ Just pn -> "A cycle appears in the definition of type synonym " <> markCode (runProperName pn)
539 Nothing -> "A cycle appears in a set of type synonym definitions."
541 Nothing -> "A cycle appears in a set of type synonym definitions."
540 , line "Cycles are disallowed because they can lead to loops in the type checker."
542 , line "Cycles are disallowed because they can lead to loops in the type checker."
541 , line "Consider using a 'newtype' instead."
543 , line "Consider using a 'newtype' instead."
543 renderSimpleErrorMessage (NameIsUndefined ident) =
545 renderSimpleErrorMessage (NameIsUndefined ident) =
544− line $ "Value " ++ markCode (showIdent ident) ++ " is undefined."
546+ line $ "Value " <> markCode (showIdent ident) <> " is undefined."
545 renderSimpleErrorMessage (UndefinedTypeVariable name) =
547 renderSimpleErrorMessage (UndefinedTypeVariable name) =
546− line $ "Type variable " ++ markCode (runProperName name) ++ " is undefined."
548+ line $ "Type variable " <> markCode (runProperName name) <> " is undefined."
547 renderSimpleErrorMessage (PartiallyAppliedSynonym name) =
549 renderSimpleErrorMessage (PartiallyAppliedSynonym name) =
548− paras [ line $ "Type synonym " ++ markCode (showQualified runProperName name) ++ " is partially applied."
550+ paras [ line $ "Type synonym " <> markCode (showQualified runProperName name) <> " is partially applied."
549 , line "Type synonyms must be applied to all of their type arguments."
551 , line "Type synonyms must be applied to all of their type arguments."
551 renderSimpleErrorMessage (EscapedSkolem binding) =
553 renderSimpleErrorMessage (EscapedSkolem binding) =
@@ -561,12 +563,12 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
561 sortRows t1 t2 = (t1, t2)
563 sortRows t1 t2 = (t1, t2)
563 -- Put the common labels last
565 -- Put the common labels last
564− sortRows' :: ([(String, Type)], Type) -> ([(String, Type)], Type) -> (Type, Type)
566+ sortRows' :: ([(Text, Type)], Type) -> ([(Text, Type)], Type) -> (Type, Type)
565 sortRows' (s1, r1) (s2, r2) =
567 sortRows' (s1, r1) (s2, r2) =
566− let common :: [(String, (Type, Type))]
568+ let common :: [(Text, (Type, Type))]
567 common = sortBy (comparing fst) [ (name, (t1, t2)) | (name, t1) <- s1, (name', t2) <- s2, name == name' ]
569 common = sortBy (comparing fst) [ (name, (t1, t2)) | (name, t1) <- s1, (name', t2) <- s2, name == name' ]
569− sd1, sd2 :: [(String, Type)]
571+ sd1, sd2 :: [(Text, Type)]
570 sd1 = [ (name, t1) | (name, t1) <- s1, name `notElem` map fst s2 ]
572 sd1 = [ (name, t1) | (name, t1) <- s1, name `notElem` map fst s2 ]
571 sd2 = [ (name, t2) | (name, t2) <- s2, name `notElem` map fst s1 ]
573 sd2 = [ (name, t2) | (name, t2) <- s2, name `notElem` map fst s1 ]
572 in ( rowFromList (sortBy (comparing fst) sd1 ++ map (fst &&& fst . snd) common, r1)
574 in ( rowFromList (sortBy (comparing fst) sd1 ++ map (fst &&& fst . snd) common, r1)
@@ -597,7 +599,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
597 , Box.vcat Box.left (map typeAtomAsBox ts)
599 , Box.vcat Box.left (map typeAtomAsBox ts)
599 , line "The following instances were found:"
601 , line "The following instances were found:"
600− , indent $ paras (line (showQualified showIdent d ++ " (chosen)") : map (line . showQualified showIdent) ds)
602+ , indent $ paras (line (showQualified showIdent d <> " (chosen)") : map (line . showQualified showIdent) ds)
601 , line "Overlapping type class instances can lead to different behavior based on the order of module imports, and for that reason are not recommended."
603 , line "Overlapping type class instances can lead to different behavior based on the order of module imports, and for that reason are not recommended."
602 , line "They may be disallowed completely in a future version of the compiler."
604 , line "They may be disallowed completely in a future version of the compiler."
@@ -667,26 +669,26 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
667 , line "Make sure this is a newtype."
669 , line "Make sure this is a newtype."
669 renderSimpleErrorMessage (CannotFindDerivingType nm) =
671 renderSimpleErrorMessage (CannotFindDerivingType nm) =
670− line $ "Cannot derive a type class instance, because the type declaration for " ++ markCode (runProperName nm) ++ " could not be found."
672+ line $ "Cannot derive a type class instance, because the type declaration for " <> markCode (runProperName nm) <> " could not be found."
671 renderSimpleErrorMessage (DuplicateLabel l expr) =
673 renderSimpleErrorMessage (DuplicateLabel l expr) =
672− paras $ [ line $ "Label " ++ markCode l ++ " appears more than once in a row type." ]
674+ paras $ [ line $ "Label " <> markCode l <> " appears more than once in a row type." ]
673 <> foldMap (\expr' -> [ line "Relevant expression: "
675 <> foldMap (\expr' -> [ line "Relevant expression: "
674 , markCodeBox $ indent $ prettyPrintValue valueDepth expr'
676 , markCodeBox $ indent $ prettyPrintValue valueDepth expr'
676 renderSimpleErrorMessage (DuplicateTypeArgument name) =
678 renderSimpleErrorMessage (DuplicateTypeArgument name) =
677− line $ "Type argument " ++ markCode name ++ " appears more than once."
679+ line $ "Type argument " <> markCode name <> " appears more than once."
678 renderSimpleErrorMessage (DuplicateValueDeclaration nm) =
680 renderSimpleErrorMessage (DuplicateValueDeclaration nm) =
679− line $ "Multiple value declarations exist for " ++ markCode (showIdent nm) ++ "."
681+ line $ "Multiple value declarations exist for " <> markCode (showIdent nm) <> "."
680 renderSimpleErrorMessage (ArgListLengthsDiffer ident) =
682 renderSimpleErrorMessage (ArgListLengthsDiffer ident) =
681− line $ "Argument list lengths differ in declaration " ++ markCode (showIdent ident)
683+ line $ "Argument list lengths differ in declaration " <> markCode (showIdent ident)
682 renderSimpleErrorMessage (OverlappingArgNames ident) =
684 renderSimpleErrorMessage (OverlappingArgNames ident) =
683− line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration " ++) . showIdent) ident
685+ line $ "Overlapping names in function/binder" <> foldMap ((" in declaration " <>) . showIdent) ident
684 renderSimpleErrorMessage (MissingClassMember ident) =
686 renderSimpleErrorMessage (MissingClassMember ident) =
685− line $ "Type class member " ++ markCode (showIdent ident) ++ " has not been implemented."
687+ line $ "Type class member " <> markCode (showIdent ident) <> " has not been implemented."
686 renderSimpleErrorMessage (ExtraneousClassMember ident className) =
688 renderSimpleErrorMessage (ExtraneousClassMember ident className) =
687− line $ "" ++ markCode (showIdent ident) ++ " is not a member of type class " ++ markCode (showQualified runProperName className)
689+ line $ "" <> markCode (showIdent ident) <> " is not a member of type class " <> markCode (showQualified runProperName className)
688 renderSimpleErrorMessage (ExpectedType ty kind) =
690 renderSimpleErrorMessage (ExpectedType ty kind) =
689− paras [ line $ "In a type-annotated expression " ++ markCode "x :: t" ++ ", the type " ++ markCode "t" ++ " must have kind " ++ markCode "*" ++ "."
691+ paras [ line $ "In a type-annotated expression " <> markCode "x :: t" <> ", the type " <> markCode "t" <> " must have kind " <> markCode "*" <> "."
690 , line "The error arises from the type"
692 , line "The error arises from the type"
691 , markCodeBox $ indent $ typeAsBox ty
693 , markCodeBox $ indent $ typeAsBox ty
692 , line "having the kind"
694 , line "having the kind"
@@ -694,7 +696,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
694 , line "instead."
696 , line "instead."
696 renderSimpleErrorMessage (IncorrectConstructorArity nm) =
698 renderSimpleErrorMessage (IncorrectConstructorArity nm) =
697− line $ "Data constructor " ++ markCode (showQualified runProperName nm) ++ " was given the wrong number of arguments in a case expression."
699+ line $ "Data constructor " <> markCode (showQualified runProperName nm) <> " was given the wrong number of arguments in a case expression."
698 renderSimpleErrorMessage (ExprDoesNotHaveType expr ty) =
700 renderSimpleErrorMessage (ExprDoesNotHaveType expr ty) =
699 paras [ line "Expression"
701 paras [ line "Expression"
700 , markCodeBox $ indent $ prettyPrintValue valueDepth expr
702 , markCodeBox $ indent $ prettyPrintValue valueDepth expr
@@ -702,13 +704,13 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
702 , markCodeBox $ indent $ typeAsBox ty
704 , markCodeBox $ indent $ typeAsBox ty
704 renderSimpleErrorMessage (PropertyIsMissing prop) =
706 renderSimpleErrorMessage (PropertyIsMissing prop) =
705− line $ "Type of expression lacks required label " ++ markCode prop ++ "."
707+ line $ "Type of expression lacks required label " <> markCode prop <> "."
706 renderSimpleErrorMessage (AdditionalProperty prop) =
708 renderSimpleErrorMessage (AdditionalProperty prop) =
707− line $ "Type of expression contains additional label " ++ markCode prop ++ "."
709+ line $ "Type of expression contains additional label " <> markCode prop <> "."
708 renderSimpleErrorMessage TypeSynonymInstance =
710 renderSimpleErrorMessage TypeSynonymInstance =
709 line "Type class instances for type synonyms are disallowed."
711 line "Type class instances for type synonyms are disallowed."
710 renderSimpleErrorMessage (OrphanInstance nm cnm ts) =
712 renderSimpleErrorMessage (OrphanInstance nm cnm ts) =
711− paras [ line $ "Type class instance " ++ markCode (showIdent nm) ++ " for "
713+ paras [ line $ "Type class instance " <> markCode (showIdent nm) <> " for "
712 , markCodeBox $ indent $ Box.hsep 1 Box.left
714 , markCodeBox $ indent $ Box.hsep 1 Box.left
713 [ line (showQualified runProperName cnm)
715 [ line (showQualified runProperName cnm)
714 , Box.vcat Box.left (map typeAtomAsBox ts)
716 , Box.vcat Box.left (map typeAtomAsBox ts)
@@ -718,7 +720,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
718 , line "Consider moving the instance, if possible, or using a newtype wrapper."
720 , line "Consider moving the instance, if possible, or using a newtype wrapper."
720 renderSimpleErrorMessage (InvalidNewtype name) =
722 renderSimpleErrorMessage (InvalidNewtype name) =
721− paras [ line $ "Newtype " ++ markCode (runProperName name) ++ " is invalid."
723+ paras [ line $ "Newtype " <> markCode (runProperName name) <> " is invalid."
722 , line "Newtypes must define a single constructor with a single argument."
724 , line "Newtypes must define a single constructor with a single argument."
724 renderSimpleErrorMessage (InvalidInstanceHead ty) =
726 renderSimpleErrorMessage (InvalidInstanceHead ty) =
@@ -727,29 +729,29 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
727 , line "All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form."
729 , line "All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form."
729 renderSimpleErrorMessage (TransitiveExportError x ys) =
731 renderSimpleErrorMessage (TransitiveExportError x ys) =
730− paras [ line $ "An export for " ++ markCode (prettyPrintExport x) ++ " requires the following to also be exported: "
732+ paras [ line $ "An export for " <> markCode (prettyPrintExport x) <> " requires the following to also be exported: "
731 , indent $ paras $ map (line . markCode . prettyPrintExport) ys
733 , indent $ paras $ map (line . markCode . prettyPrintExport) ys
733 renderSimpleErrorMessage (TransitiveDctorExportError x ctor) =
735 renderSimpleErrorMessage (TransitiveDctorExportError x ctor) =
734− paras [ line $ "An export for " ++ markCode (prettyPrintExport x) ++ " requires the following data constructor to also be exported: "
736+ paras [ line $ "An export for " <> markCode (prettyPrintExport x) <> " requires the following data constructor to also be exported: "
735 , indent $ line $ markCode $ runProperName ctor
737 , indent $ line $ markCode $ runProperName ctor
737 renderSimpleErrorMessage (ShadowedName nm) =
739 renderSimpleErrorMessage (ShadowedName nm) =
738− line $ "Name " ++ markCode (showIdent nm) ++ " was shadowed."
740+ line $ "Name " <> markCode (showIdent nm) <> " was shadowed."
739 renderSimpleErrorMessage (ShadowedTypeVar tv) =
741 renderSimpleErrorMessage (ShadowedTypeVar tv) =
740− line $ "Type variable " ++ markCode tv ++ " was shadowed."
742+ line $ "Type variable " <> markCode tv <> " was shadowed."
741 renderSimpleErrorMessage (UnusedTypeVar tv) =
743 renderSimpleErrorMessage (UnusedTypeVar tv) =
742− line $ "Type variable " ++ markCode tv ++ " was declared but not used."
744+ line $ "Type variable " <> markCode tv <> " was declared but not used."
743 renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
745 renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
744− line $ "Importing type " ++ markCode (runProperName name ++ "(..)") ++ " from " ++ markCode (runModuleName mn) ++ " is misleading as it has no exported data constructors."
746+ line $ "Importing type " <> markCode (runProperName name <> "(..)") <> " from " <> markCode (runModuleName mn) <> " is misleading as it has no exported data constructors."
745 renderSimpleErrorMessage (ImportHidingModule name) =
747 renderSimpleErrorMessage (ImportHidingModule name) =
746 paras [ line "hiding imports cannot be used to hide modules."
748 paras [ line "hiding imports cannot be used to hide modules."
747− , line $ "An attempt was made to hide the import of " ++ markCode (runModuleName name)
749+ , line $ "An attempt was made to hide the import of " <> markCode (runModuleName name)
749 renderSimpleErrorMessage (WildcardInferredType ty ctx) =
751 renderSimpleErrorMessage (WildcardInferredType ty ctx) =
750 paras $ [ line "Wildcard type definition has the inferred type "
752 paras $ [ line "Wildcard type definition has the inferred type "
751 , markCodeBox $ indent $ typeAsBox ty
753 , markCodeBox $ indent $ typeAsBox ty
752− ] ++ renderContext ctx
754+ ] <> renderContext ctx
753 renderSimpleErrorMessage (HoleInferredType name ty ctx ts) =
755 renderSimpleErrorMessage (HoleInferredType name ty ctx ts) =
755 maxTSResults = 15
757 maxTSResults = 15
@@ -758,7 +760,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
759 formatTS (names, types) =
761 formatTS (names, types) =
761− idBoxes = Box.text . showQualified runIdent <$> names
763+ idBoxes = Box.text . T.unpack . showQualified runIdent <$> names
762 tyBoxes = (\t -> BoxHelpers.indented
764 tyBoxes = (\t -> BoxHelpers.indented
763 (Box.text ":: " Box.<> typeAsBox t)) <$> types
765 (Box.text ":: " Box.<> typeAsBox t)) <$> types
764 longestId = maximum (map Box.cols idBoxes)
766 longestId = maximum (map Box.cols idBoxes)
@@ -772,13 +774,13 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
775− paras $ [ line $ "Hole '" ++ markCode name ++ "' has the inferred type "
777+ paras $ [ line $ "Hole '" <> markCode name <> "' has the inferred type "
776 , markCodeBox (indent (typeAsBox ty))
778 , markCodeBox (indent (typeAsBox ty))
777 ] ++ tsResult ++ renderContext ctx
779 ] ++ tsResult ++ renderContext ctx
778 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
780 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
779− paras [ line $ "No type declaration was provided for the top-level declaration of " ++ markCode (showIdent ident) ++ "."
781+ paras [ line $ "No type declaration was provided for the top-level declaration of " <> markCode (showIdent ident) <> "."
780 , line "It is good practice to provide type declarations as a form of documentation."
782 , line "It is good practice to provide type declarations as a form of documentation."
781− , line $ "The inferred type of " ++ markCode (showIdent ident) ++ " was:"
783+ , line $ "The inferred type of " <> markCode (showIdent ident) <> " was:"
782 , markCodeBox $ indent $ typeAsBox ty
784 , markCodeBox $ indent $ typeAsBox ty
784 renderSimpleErrorMessage (OverlappingPattern bs b) =
786 renderSimpleErrorMessage (OverlappingPattern bs b) =
@@ -791,70 +793,70 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
791 , line "You may want to decompose your data types into smaller types."
793 , line "You may want to decompose your data types into smaller types."
793 renderSimpleErrorMessage (UnusedImport name) =
795 renderSimpleErrorMessage (UnusedImport name) =
794− line $ "The import of module " ++ markCode (runModuleName name) ++ " is redundant"
796+ line $ "The import of module " <> markCode (runModuleName name) <> " is redundant"
796 renderSimpleErrorMessage msg@(UnusedExplicitImport mn names _ _) =
798 renderSimpleErrorMessage msg@(UnusedExplicitImport mn names _ _) =
797− paras [ line $ "The import of module " ++ markCode (runModuleName mn) ++ " contains the following unused references:"
799+ paras [ line $ "The import of module " <> markCode (runModuleName mn) <> " contains the following unused references:"
798 , indent $ paras $ map (line . markCode . runName . Qualified Nothing) names
800 , indent $ paras $ map (line . markCode . runName . Qualified Nothing) names
799 , line "It could be replaced with:"
801 , line "It could be replaced with:"
800 , indent $ line $ markCode $ showSuggestion msg ]
802 , indent $ line $ markCode $ showSuggestion msg ]
802 renderSimpleErrorMessage msg@(UnusedDctorImport mn name _ _) =
804 renderSimpleErrorMessage msg@(UnusedDctorImport mn name _ _) =
803− paras [line $ "The import of type " ++ markCode (runProperName name)
805+ paras [line $ "The import of type " <> markCode (runProperName name)
804− ++ " from module " ++ markCode (runModuleName mn) ++ " includes data constructors but only the type is used"
806+ <> " from module " <> markCode (runModuleName mn) <> " includes data constructors but only the type is used"
805 , line "It could be replaced with:"
807 , line "It could be replaced with:"
806 , indent $ line $ markCode $ showSuggestion msg ]
808 , indent $ line $ markCode $ showSuggestion msg ]
808 renderSimpleErrorMessage msg@(UnusedDctorExplicitImport mn name names _ _) =
810 renderSimpleErrorMessage msg@(UnusedDctorExplicitImport mn name names _ _) =
809− paras [ line $ "The import of type " ++ markCode (runProperName name)
811+ paras [ line $ "The import of type " <> markCode (runProperName name)
810− ++ " from module " ++ markCode (runModuleName mn) ++ " includes the following unused data constructors:"
812+ <> " from module " <> markCode (runModuleName mn) <> " includes the following unused data constructors:"
811 , indent $ paras $ map (line . markCode . runProperName) names
813 , indent $ paras $ map (line . markCode . runProperName) names
812 , line "It could be replaced with:"
814 , line "It could be replaced with:"
813 , indent $ line $ markCode $ showSuggestion msg ]
815 , indent $ line $ markCode $ showSuggestion msg ]
815 renderSimpleErrorMessage (DuplicateSelectiveImport name) =
817 renderSimpleErrorMessage (DuplicateSelectiveImport name) =
816− line $ "There is an existing import of " ++ markCode (runModuleName name) ++ ", consider merging the import lists"
818+ line $ "There is an existing import of " <> markCode (runModuleName name) <> ", consider merging the import lists"
818 renderSimpleErrorMessage (DuplicateImport name imp qual) =
820 renderSimpleErrorMessage (DuplicateImport name imp qual) =
819− line $ "Duplicate import of " ++ markCode (prettyPrintImport name imp qual)
821+ line $ "Duplicate import of " <> markCode (prettyPrintImport name imp qual)
821 renderSimpleErrorMessage (DuplicateImportRef name) =
823 renderSimpleErrorMessage (DuplicateImportRef name) =
822− line $ "Import list contains multiple references to " ++ printName (Qualified Nothing name)
824+ line $ "Import list contains multiple references to " <> printName (Qualified Nothing name)
824 renderSimpleErrorMessage (DuplicateExportRef name) =
826 renderSimpleErrorMessage (DuplicateExportRef name) =
825− line $ "Export list contains multiple references to " ++ printName (Qualified Nothing name)
827+ line $ "Export list contains multiple references to " <> printName (Qualified Nothing name)
827 renderSimpleErrorMessage (IntOutOfRange value backend lo hi) =
829 renderSimpleErrorMessage (IntOutOfRange value backend lo hi) =
828− paras [ line $ "Integer value " ++ markCode (show value) ++ " is out of range for the " ++ backend ++ " backend."
830+ paras [ line $ "Integer value " <> markCode (T.pack (show value)) <> " is out of range for the " <> backend <> " backend."
829− , line $ "Acceptable values fall within the range " ++ markCode (show lo) ++ " to " ++ markCode (show hi) ++ " (inclusive)." ]
831+ , line $ "Acceptable values fall within the range " <> markCode (T.pack (show lo)) <> " to " <> markCode (T.pack (show hi)) <> " (inclusive)." ]
831 renderSimpleErrorMessage msg@(ImplicitQualifiedImport importedModule asModule _) =
833 renderSimpleErrorMessage msg@(ImplicitQualifiedImport importedModule asModule _) =
832− paras [ line $ "Module " ++ markCode (runModuleName importedModule) ++ " was imported as " ++ markCode (runModuleName asModule) ++ " with unspecified imports."
834+ paras [ line $ "Module " <> markCode (runModuleName importedModule) <> " was imported as " <> markCode (runModuleName asModule) <> " with unspecified imports."
833− , line $ "As there are multiple modules being imported as " ++ markCode (runModuleName asModule) ++ ", consider using the explicit form:"
835+ , line $ "As there are multiple modules being imported as " <> markCode (runModuleName asModule) <> ", consider using the explicit form:"
834 , indent $ line $ markCode $ showSuggestion msg
836 , indent $ line $ markCode $ showSuggestion msg
837 renderSimpleErrorMessage msg@(ImplicitImport mn _) =
839 renderSimpleErrorMessage msg@(ImplicitImport mn _) =
838− paras [ line $ "Module " ++ markCode (runModuleName mn) ++ " has unspecified imports, consider using the explicit form: "
840+ paras [ line $ "Module " <> markCode (runModuleName mn) <> " has unspecified imports, consider using the explicit form: "
839 , indent $ line $ markCode $ showSuggestion msg
841 , indent $ line $ markCode $ showSuggestion msg
842 renderSimpleErrorMessage msg@(HidingImport mn _) =
844 renderSimpleErrorMessage msg@(HidingImport mn _) =
843− paras [ line $ "Module " ++ markCode (runModuleName mn) ++ " has unspecified imports, consider using the inclusive form: "
845+ paras [ line $ "Module " <> markCode (runModuleName mn) <> " has unspecified imports, consider using the inclusive form: "
844 , indent $ line $ markCode $ showSuggestion msg
846 , indent $ line $ markCode $ showSuggestion msg
847 renderSimpleErrorMessage (CaseBinderLengthDiffers l bs) =
849 renderSimpleErrorMessage (CaseBinderLengthDiffers l bs) =
848 paras [ line "Binder list length differs in case alternative:"
850 paras [ line "Binder list length differs in case alternative:"
849− , indent $ line $ intercalate ", " $ fmap prettyPrintBinderAtom bs
851+ , indent $ line $ T.intercalate ", " $ fmap prettyPrintBinderAtom bs
850− , line $ "Expecting " ++ show l ++ " binder" ++ (if l == 1 then "" else "s") ++ "."
852+ , line $ "Expecting " <> T.pack (show l) <> " binder" <> (if l == 1 then "" else "s") <> "."
853 renderSimpleErrorMessage IncorrectAnonymousArgument =
855 renderSimpleErrorMessage IncorrectAnonymousArgument =
854 line "An anonymous function argument appears in an invalid context."
856 line "An anonymous function argument appears in an invalid context."
856 renderSimpleErrorMessage (InvalidOperatorInBinder op fn) =
858 renderSimpleErrorMessage (InvalidOperatorInBinder op fn) =
857− paras [ line $ "Operator " ++ markCode (showQualified showOp op) ++ " cannot be used in a pattern as it is an alias for function " ++ showQualified showIdent fn ++ "."
859+ paras [ line $ "Operator " <> markCode (showQualified showOp op) <> " cannot be used in a pattern as it is an alias for function " <> showQualified showIdent fn <> "."
858 , line "Only aliases for data constructors may be used in patterns."
860 , line "Only aliases for data constructors may be used in patterns."
@@ -862,18 +864,18 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
862 line "The require-path option is deprecated and will be removed in PureScript 0.9."
864 line "The require-path option is deprecated and will be removed in PureScript 0.9."
864 renderSimpleErrorMessage (CannotGeneralizeRecursiveFunction ident ty) =
866 renderSimpleErrorMessage (CannotGeneralizeRecursiveFunction ident ty) =
865− paras [ line $ "Unable to generalize the type of the recursive function " ++ markCode (showIdent ident) ++ "."
867+ paras [ line $ "Unable to generalize the type of the recursive function " <> markCode (showIdent ident) <> "."
866− , line $ "The inferred type of " ++ markCode (showIdent ident) ++ " was:"
868+ , line $ "The inferred type of " <> markCode (showIdent ident) <> " was:"
867 , markCodeBox $ indent $ typeAsBox ty
869 , markCodeBox $ indent $ typeAsBox ty
868 , line "Try adding a type signature."
870 , line "Try adding a type signature."
871 renderSimpleErrorMessage (CannotDeriveNewtypeForData tyName) =
873 renderSimpleErrorMessage (CannotDeriveNewtypeForData tyName) =
872− paras [ line $ "Cannot derive an instance of the " ++ markCode "Newtype" ++ " class for non-newtype " ++ markCode (runProperName tyName) ++ "."
874+ paras [ line $ "Cannot derive an instance of the " <> markCode "Newtype" <> " class for non-newtype " <> markCode (runProperName tyName) <> "."
875 renderSimpleErrorMessage (ExpectedWildcard tyName) =
877 renderSimpleErrorMessage (ExpectedWildcard tyName) =
876− paras [ line $ "Expected a type wildcard (_) when deriving an instance for " ++ markCode (runProperName tyName) ++ "."
878+ paras [ line $ "Expected a type wildcard (_) when deriving an instance for " <> markCode (runProperName tyName) <> "."
879 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
881 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
@@ -893,7 +895,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
895 renderHint (ErrorInModule mn) detail =
897 renderHint (ErrorInModule mn) detail =
896− paras [ line $ "in module " ++ markCode (runModuleName mn)
898+ paras [ line $ "in module " <> markCode (runModuleName mn)
899 renderHint (ErrorInSubsumption t1 t2) detail =
901 renderHint (ErrorInSubsumption t1 t2) detail =
@@ -958,15 +960,15 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
959 renderHint (ErrorInDataConstructor nm) detail =
961 renderHint (ErrorInDataConstructor nm) detail =
960 paras [ detail
962 paras [ detail
961− , line $ "in data constructor " ++ markCode (runProperName nm)
963+ , line $ "in data constructor " <> markCode (runProperName nm)
963 renderHint (ErrorInTypeConstructor nm) detail =
965 renderHint (ErrorInTypeConstructor nm) detail =
964 paras [ detail
966 paras [ detail
965− , line $ "in type constructor " ++ markCode (runProperName nm)
967+ , line $ "in type constructor " <> markCode (runProperName nm)
967 renderHint (ErrorInBindingGroup nms) detail =
969 renderHint (ErrorInBindingGroup nms) detail =
968 paras [ detail
970 paras [ detail
969− , line $ "in binding group " ++ intercalate ", " (map showIdent nms)
971+ , line $ "in binding group " <> T.intercalate ", " (map showIdent nms)
971 renderHint (ErrorInDataBindingGroup nms) detail =
973 renderHint (ErrorInDataBindingGroup nms) detail =
972 paras [ detail
974 paras [ detail
@@ -974,15 +976,15 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
975 renderHint (ErrorInTypeSynonym name) detail =
977 renderHint (ErrorInTypeSynonym name) detail =
976 paras [ detail
978 paras [ detail
977− , line $ "in type synonym " ++ markCode (runProperName name)
979+ , line $ "in type synonym " <> markCode (runProperName name)
979 renderHint (ErrorInValueDeclaration n) detail =
981 renderHint (ErrorInValueDeclaration n) detail =
980 paras [ detail
982 paras [ detail
981− , line $ "in value declaration " ++ markCode (showIdent n)
983+ , line $ "in value declaration " <> markCode (showIdent n)
983 renderHint (ErrorInTypeDeclaration n) detail =
985 renderHint (ErrorInTypeDeclaration n) detail =
984 paras [ detail
986 paras [ detail
985− , line $ "in type declaration for " ++ markCode (showIdent n)
987+ , line $ "in type declaration for " <> markCode (showIdent n)
987 renderHint (ErrorInTypeClassDeclaration name) detail =
989 renderHint (ErrorInTypeClassDeclaration name) detail =
988 paras [ detail
990 paras [ detail
@@ -990,7 +992,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
991 renderHint (ErrorInForeignImport nm) detail =
993 renderHint (ErrorInForeignImport nm) detail =
992 paras [ detail
994 paras [ detail
993− , line $ "in foreign import " ++ markCode (showIdent nm)
995+ , line $ "in foreign import " <> markCode (showIdent nm)
995 renderHint (ErrorSolvingConstraint (Constraint nm ts _)) detail =
997 renderHint (ErrorSolvingConstraint (Constraint nm ts _)) detail =
996 paras [ detail
998 paras [ detail
@@ -1001,7 +1003,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
1003 renderHint (PositionedError srcSpan) detail =
1005 renderHint (PositionedError srcSpan) detail =
1004− paras [ line $ "at " ++ displaySourceSpan srcSpan
1006+ paras [ line $ "at " <> displaySourceSpan srcSpan
1005 , detail
1007 , detail
@@ -1010,17 +1012,17 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
1010 renderContext ctx =
1012 renderContext ctx =
1011 [ line "in the following context:"
1013 [ line "in the following context:"
1012 , indent $ paras
1014 , indent $ paras
1013− [ Box.hcat Box.left [ Box.text (showIdent ident <> " :: ")
1015+ [ Box.hcat Box.left [ Box.text (T.unpack (showIdent ident) ++ " :: ")
1014 , markCodeBox $ typeAsBox ty'
1016 , markCodeBox $ typeAsBox ty'
1016 | (ident, ty') <- take 5 ctx
1018 | (ident, ty') <- take 5 ctx
1020− printName :: Qualified Name -> String
1022+ printName :: Qualified Name -> Text
1021− printName qn = nameType (disqualify qn) ++ " " ++ markCode (runName qn)
1023+ printName qn = nameType (disqualify qn) <> " " <> markCode (runName qn)
1023− nameType :: Name -> String
1025+ nameType :: Name -> Text
1024 nameType (IdentName _) = "value"
1026 nameType (IdentName _) = "value"
1025 nameType (ValOpName _) = "operator"
1027 nameType (ValOpName _) = "operator"
1026 nameType (TyName _) = "type"
1028 nameType (TyName _) = "type"
@@ -1029,7 +1031,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
1029 nameType (TyClassName _) = "type class"
1031 nameType (TyClassName _) = "type class"
1030 nameType (ModName _) = "module"
1032 nameType (ModName _) = "module"
1032− runName :: Qualified Name -> String
1034+ runName :: Qualified Name -> Text
1033 runName (Qualified mn (IdentName name)) =
1035 runName (Qualified mn (IdentName name)) =
1034 showQualified showIdent (Qualified mn name)
1036 showQualified showIdent (Qualified mn name)
1035 runName (Qualified mn (ValOpName op)) =
1037 runName (Qualified mn (ValOpName op)) =
@@ -1051,7 +1053,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
1051 valueDepth | full = 1000
1053 valueDepth | full = 1000
1052 | otherwise = 3
1054 | otherwise = 3
1054− levelText :: String
1056+ levelText :: Text
1055 levelText = case level of
1057 levelText = case level of
1056 Error -> "error"
1058 Error -> "error"
1057 Warning -> "warning"
1059 Warning -> "warning"
@@ -1112,40 +1114,40 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
1112 hintCategory _ = OtherHint
1114 hintCategory _ = OtherHint
1114-- Pretty print and export declaration
1116-- Pretty print and export declaration
1115−prettyPrintExport :: DeclarationRef -> String
1117+prettyPrintExport :: DeclarationRef -> Text
1116prettyPrintExport (TypeRef pn _) = runProperName pn
1118prettyPrintExport (TypeRef pn _) = runProperName pn
1117prettyPrintExport ref =
1119prettyPrintExport ref =
1118 fromMaybe
1120 fromMaybe
1119 (internalError "prettyPrintRef returned Nothing in prettyPrintExport")
1121 (internalError "prettyPrintRef returned Nothing in prettyPrintExport")
1120 (prettyPrintRef ref)
1122 (prettyPrintRef ref)
1122−prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> String
1124+prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> Text
1123prettyPrintImport mn idt qual =
1125prettyPrintImport mn idt qual =
1124 let i = case idt of
1126 let i = case idt of
1125 Implicit -> runModuleName mn
1127 Implicit -> runModuleName mn
1126− Explicit refs -> runModuleName mn ++ " (" ++ intercalate ", " (mapMaybe prettyPrintRef refs) ++ ")"
1128+ Explicit refs -> runModuleName mn <> " (" <> T.intercalate ", " (mapMaybe prettyPrintRef refs) <> ")"
1127− Hiding refs -> runModuleName mn ++ " hiding (" ++ intercalate "," (mapMaybe prettyPrintRef refs) ++ ")"
1129+ Hiding refs -> runModuleName mn <> " hiding (" <> T.intercalate "," (mapMaybe prettyPrintRef refs) <> ")"
1128− in i ++ maybe "" (\q -> " as " ++ runModuleName q) qual
1130+ in i <> maybe "" (\q -> " as " <> runModuleName q) qual
1130−prettyPrintRef :: DeclarationRef -> Maybe String
1132+prettyPrintRef :: DeclarationRef -> Maybe Text
1131prettyPrintRef (TypeRef pn Nothing) =
1133prettyPrintRef (TypeRef pn Nothing) =
1132− Just $ runProperName pn ++ "(..)"
1134+ Just $ runProperName pn <> "(..)"
1133prettyPrintRef (TypeRef pn (Just [])) =
1135prettyPrintRef (TypeRef pn (Just [])) =
1134 Just $ runProperName pn
1136 Just $ runProperName pn
1135prettyPrintRef (TypeRef pn (Just dctors)) =
1137prettyPrintRef (TypeRef pn (Just dctors)) =
1136− Just $ runProperName pn ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
1138+ Just $ runProperName pn <> "(" <> T.intercalate ", " (map runProperName dctors) <> ")"
1137prettyPrintRef (TypeOpRef op) =
1139prettyPrintRef (TypeOpRef op) =
1138− Just $ "type " ++ showOp op
1140+ Just $ "type " <> showOp op
1139prettyPrintRef (ValueRef ident) =
1141prettyPrintRef (ValueRef ident) =
1140 Just $ showIdent ident
1142 Just $ showIdent ident
1141prettyPrintRef (ValueOpRef op) =
1143prettyPrintRef (ValueOpRef op) =
1142 Just $ showOp op
1144 Just $ showOp op
1143prettyPrintRef (TypeClassRef pn) =
1145prettyPrintRef (TypeClassRef pn) =
1144− Just $ "class " ++ runProperName pn
1146+ Just $ "class " <> runProperName pn
1145prettyPrintRef (TypeInstanceRef ident) =
1147prettyPrintRef (TypeInstanceRef ident) =
1146 Just $ showIdent ident
1148 Just $ showIdent ident
1147prettyPrintRef (ModuleRef name) =
1149prettyPrintRef (ModuleRef name) =
1148− Just $ "module " ++ runModuleName name
1150+ Just $ "module " <> runModuleName name
1149prettyPrintRef (ReExportRef _ _) =
1151prettyPrintRef (ReExportRef _ _) =
1151prettyPrintRef (PositionedDeclarationRef _ _ ref) =
1153prettyPrintRef (PositionedDeclarationRef _ _ ref) =
@@ -1238,8 +1240,11 @@ prettyPrintParseErrorMessages msgOr msgUnknown msgExpecting msgUnExpected msgEnd
1238indent :: Box.Box -> Box.Box
1240indent :: Box.Box -> Box.Box
1239indent = Box.moveUp 1 . Box.moveDown 1 . Box.moveRight 2
1241indent = Box.moveUp 1 . Box.moveDown 1 . Box.moveRight 2
1243+line :: Text -> Box.Box
1244+line = Box.text . T.unpack
1241−line :: String -> Box.Box
1246+lineS :: String -> Box.Box
1242−line = Box.text
1247+lineS = Box.text
1244renderBox :: Box.Box -> String
1249renderBox :: Box.Box -> String
1245renderBox = unlines
1250renderBox = unlines
@@ -1253,7 +1258,7 @@ renderBox = unlines
1253 whiteSpace = all isSpace
1258 whiteSpace = all isSpace
1255toTypelevelString :: Type -> Maybe Box.Box
1260toTypelevelString :: Type -> Maybe Box.Box
1256−toTypelevelString (TypeLevelString s) = Just $ Box.text s
1261+toTypelevelString (TypeLevelString s) = Just $ Box.text (T.unpack s)
1257toTypelevelString (TypeApp (TypeConstructor f) x)
1262toTypelevelString (TypeApp (TypeConstructor f) x)
1258 | f == primName "TypeString" = Just $ typeAsBox x
1263 | f == primName "TypeString" = Just $ typeAsBox x
1259toTypelevelString (TypeApp (TypeApp (TypeConstructor f) x) ret)
1264toTypelevelString (TypeApp (TypeApp (TypeConstructor f) x) ret)