git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Only use Show for debugging.
1376700Phil Freeman
psc-docs/Main.hs+4−4
@@ -152,10 +152,10 @@ inputFile = strArgument $
152 <> help "The input .purs file(s)"
152 <> help "The input .purs file(s)"
153
153
154instance Read Format where
154instance Read Format where
155− readsPrec _ "etags" = [(Etags, "")]
155+ readsPrec _ "etags" = [(Etags, "")]
156− readsPrec _ "ctags" = [(Ctags, "")]
156+ readsPrec _ "ctags" = [(Ctags, "")]
157− readsPrec _ "markdown" = [(Markdown, "")]
157+ readsPrec _ "markdown" = [(Markdown, "")]
158− readsPrec _ _ = []
158+ readsPrec _ _ = []
159
159
160format :: Parser Format
160format :: Parser Format
161format = option auto $ value Markdown
161format = option auto $ value Markdown
psc-publish/tests/Test.hs+1−1
@@ -60,7 +60,7 @@ data TestResult
60 = ParseFailed String
60 = ParseFailed String
61 | Mismatch ByteString ByteString -- ^ encoding before, encoding after
61 | Mismatch ByteString ByteString -- ^ encoding before, encoding after
62 | Pass ByteString
62 | Pass ByteString
63− deriving (Show)
63+ deriving (Show, Read)
64
64
65-- | Test JSON encoding/decoding; parse the package, roundtrip to/from JSON,
65-- | Test JSON encoding/decoding; parse the package, roundtrip to/from JSON,
66-- and check we get the same string.
66-- and check we get the same string.
psci/Completion.hs+11−11
@@ -41,7 +41,7 @@ data CompletionContext
41 | CtxIdentifier
41 | CtxIdentifier
42 | CtxType
42 | CtxType
43 | CtxFixed String
43 | CtxFixed String
44− deriving (Show)
44+ deriving (Show, Read)
45
45
46-- |
46-- |
47-- Loads module, function, and file completions.
47-- Loads module, function, and file completions.
@@ -143,34 +143,34 @@ getImportedModules = asks psciImportedModules
143getModuleNames :: CompletionM [String]
143getModuleNames :: CompletionM [String]
144getModuleNames = moduleNames <$> getLoadedModules
144getModuleNames = moduleNames <$> getLoadedModules
145
145
146−mapLoadedModulesAndQualify :: (Show a) => (P.Module -> [(a, P.Declaration)]) -> CompletionM [String]
146+mapLoadedModulesAndQualify :: (a -> String) -> (P.Module -> [(a, P.Declaration)]) -> CompletionM [String]
147−mapLoadedModulesAndQualify f = do
147+mapLoadedModulesAndQualify sho f = do
148 ms <- getLoadedModules
148 ms <- getLoadedModules
149 let argPairs = do m <- ms
149 let argPairs = do m <- ms
150 fm <- f m
150 fm <- f m
151 return (m, fm)
151 return (m, fm)
152− concat <$> traverse (uncurry getAllQualifications) argPairs
152+ concat <$> traverse (uncurry (getAllQualifications sho)) argPairs
153
153
154getIdentNames :: CompletionM [String]
154getIdentNames :: CompletionM [String]
155−getIdentNames = mapLoadedModulesAndQualify identNames
155+getIdentNames = mapLoadedModulesAndQualify P.showIdent identNames
156
156
157getDctorNames :: CompletionM [String]
157getDctorNames :: CompletionM [String]
158−getDctorNames = mapLoadedModulesAndQualify dctorNames
158+getDctorNames = mapLoadedModulesAndQualify P.runProperName dctorNames
159
159
160getTypeNames :: CompletionM [String]
160getTypeNames :: CompletionM [String]
161−getTypeNames = mapLoadedModulesAndQualify typeDecls
161+getTypeNames = mapLoadedModulesAndQualify P.runProperName typeDecls
162
162
163-- | Given a module and a declaration in that module, return all possible ways
163-- | Given a module and a declaration in that module, return all possible ways
164-- it could have been referenced given the current PSCiState - including fully
164-- it could have been referenced given the current PSCiState - including fully
165-- qualified, qualified using an alias, and unqualified.
165-- qualified, qualified using an alias, and unqualified.
166−getAllQualifications :: (Show a) => P.Module -> (a, P.Declaration) -> CompletionM [String]
166+getAllQualifications :: (a -> String) -> P.Module -> (a, P.Declaration) -> CompletionM [String]
167−getAllQualifications m (declName, decl) = do
167+getAllQualifications sho m (declName, decl) = do
168 imports <- getAllImportsOf m
168 imports <- getAllImportsOf m
169 let fullyQualified = qualifyWith (Just (P.getModuleName m))
169 let fullyQualified = qualifyWith (Just (P.getModuleName m))
170 let otherQuals = nub (concatMap qualificationsUsing imports)
170 let otherQuals = nub (concatMap qualificationsUsing imports)
171 return $ fullyQualified : otherQuals
171 return $ fullyQualified : otherQuals
172 where
172 where
173− qualifyWith mMod = show (P.Qualified mMod declName)
173+ qualifyWith mMod = P.showQualified sho (P.Qualified mMod declName)
174 referencedBy refs = P.isExported (Just refs) decl
174 referencedBy refs = P.isExported (Just refs) decl
175
175
176 qualificationsUsing (_, importType, asQ') =
176 qualificationsUsing (_, importType, asQ') =
@@ -222,7 +222,7 @@ dctorNames = nubOnFst . concatMap go . P.exportedDeclarations
222 go _ = []
222 go _ = []
223
223
224moduleNames :: [P.Module] -> [String]
224moduleNames :: [P.Module] -> [String]
225−moduleNames ms = nub [show moduleName | P.Module _ _ moduleName _ _ <- ms]
225+moduleNames ms = nub [P.runModuleName moduleName | P.Module _ _ moduleName _ _ <- ms]
226
226
227directivesFirst :: Completion -> Completion -> Ordering
227directivesFirst :: Completion -> Completion -> Ordering
228directivesFirst (Completion _ d1 _) (Completion _ d2 _) = go d1 d2
228directivesFirst (Completion _ d1 _) (Completion _ d2 _) = go d1 d2
src/Language/PureScript/AST/Binders.hs+1−1
@@ -69,7 +69,7 @@ data Binder
69 -- |
69 -- |
70 -- A binder with source position information
70 -- A binder with source position information
71 --
71 --
72− | PositionedBinder SourceSpan [Comment] Binder deriving (Show, Eq, D.Data, D.Typeable)
72+ | PositionedBinder SourceSpan [Comment] Binder deriving (Show, Read, Eq, D.Data, D.Typeable)
73
73
74-- |
74-- |
75-- Collect all names introduced in binders in an expression
75-- Collect all names introduced in binders in an expression
src/Language/PureScript/AST/Declarations.hs+8−8
@@ -42,7 +42,7 @@ import Language.PureScript.Environment
42-- a list of declarations, and a list of the declarations that are
42-- a list of declarations, and a list of the declarations that are
43-- explicitly exported. If the export list is Nothing, everything is exported.
43-- explicitly exported. If the export list is Nothing, everything is exported.
44--
44--
45−data Module = Module SourceSpan [Comment] ModuleName [Declaration] (Maybe [DeclarationRef]) deriving (Show, D.Data, D.Typeable)
45+data Module = Module SourceSpan [Comment] ModuleName [Declaration] (Maybe [DeclarationRef]) deriving (Show, Read, D.Data, D.Typeable)
46
46
47-- | Return a module's name.
47-- | Return a module's name.
48getModuleName :: Module -> ModuleName
48getModuleName :: Module -> ModuleName
@@ -76,7 +76,7 @@ data DeclarationRef
76 -- A declaration reference with source position information
76 -- A declaration reference with source position information
77 --
77 --
78 | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef
78 | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef
79− deriving (Show, D.Data, D.Typeable)
79+ deriving (Show, Read, D.Data, D.Typeable)
80
80
81instance Eq DeclarationRef where
81instance Eq DeclarationRef where
82 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
82 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
@@ -108,7 +108,7 @@ data ImportDeclarationType
108 -- An import with a list of references to hide: `import M hiding (foo)`
108 -- An import with a list of references to hide: `import M hiding (foo)`
109 --
109 --
110 | Hiding [DeclarationRef]
110 | Hiding [DeclarationRef]
111− deriving (Show, D.Data, D.Typeable)
111+ deriving (Show, Read, D.Data, D.Typeable)
112
112
113-- |
113-- |
114-- The data type of declarations
114-- The data type of declarations
@@ -171,7 +171,7 @@ data Declaration
171 -- A declaration with source position information
171 -- A declaration with source position information
172 --
172 --
173 | PositionedDeclaration SourceSpan [Comment] Declaration
173 | PositionedDeclaration SourceSpan [Comment] Declaration
174− deriving (Show, D.Data, D.Typeable)
174+ deriving (Show, Read, D.Data, D.Typeable)
175
175
176-- | The members of a type class instance declaration
176-- | The members of a type class instance declaration
177data TypeInstanceBody
177data TypeInstanceBody
@@ -179,7 +179,7 @@ data TypeInstanceBody
179 = DerivedInstance
179 = DerivedInstance
180 -- | This is a regular (explicit) instance
180 -- | This is a regular (explicit) instance
181 | ExplicitInstance [Declaration]
181 | ExplicitInstance [Declaration]
182− deriving (Show, D.Data, D.Typeable)
182+ deriving (Show, Read, D.Data, D.Typeable)
183
183
184mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
184mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
185mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
185mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
@@ -406,7 +406,7 @@ data Expr
406 -- |
406 -- |
407 -- A value with source position information
407 -- A value with source position information
408 --
408 --
409− | PositionedValue SourceSpan [Comment] Expr deriving (Show, D.Data, D.Typeable)
409+ | PositionedValue SourceSpan [Comment] Expr deriving (Show, Read, D.Data, D.Typeable)
410
410
411-- |
411-- |
412-- An alternative in a case statement
412-- An alternative in a case statement
@@ -420,7 +420,7 @@ data CaseAlternative = CaseAlternative
420 -- The result expression or a collect of guarded expressions
420 -- The result expression or a collect of guarded expressions
421 --
421 --
422 , caseAlternativeResult :: Either [(Guard, Expr)] Expr
422 , caseAlternativeResult :: Either [(Guard, Expr)] Expr
423− } deriving (Show, D.Data, D.Typeable)
423+ } deriving (Show, Read, D.Data, D.Typeable)
424
424
425-- |
425-- |
426-- A statement in a do-notation block
426-- A statement in a do-notation block
@@ -441,4 +441,4 @@ data DoNotationElement
441 -- |
441 -- |
442 -- A do notation element with source position information
442 -- A do notation element with source position information
443 --
443 --
444− | PositionedDoNotationElement SourceSpan [Comment] DoNotationElement deriving (Show, D.Data, D.Typeable)
444+ | PositionedDoNotationElement SourceSpan [Comment] DoNotationElement deriving (Show, Read, D.Data, D.Typeable)
src/Language/PureScript/AST/Operators.hs+7−7
@@ -29,20 +29,20 @@ type Precedence = Integer
29-- |
29-- |
30-- Associativity for infix operators
30-- Associativity for infix operators
31--
31--
32−data Associativity = Infixl | Infixr | Infix deriving (Eq, Ord, D.Data, D.Typeable)
32+data Associativity = Infixl | Infixr | Infix deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
33
33
34−instance Show Associativity where
34+showAssoc :: Associativity -> String
35− show Infixl = "infixl"
35+showAssoc Infixl = "infixl"
36− show Infixr = "infixr"
36+showAssoc Infixr = "infixr"
37− show Infix = "infix"
37+showAssoc Infix = "infix"
38
38
39instance A.ToJSON Associativity where
39instance A.ToJSON Associativity where
40− toJSON = A.toJSON . show
40+ toJSON = A.toJSON . showAssoc
41
41
42-- |
42-- |
43-- Fixity data for infix operators
43-- Fixity data for infix operators
44--
44--
45−data Fixity = Fixity Associativity Precedence deriving (Show, Eq, Ord, D.Data, D.Typeable)
45+data Fixity = Fixity Associativity Precedence deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
46
46
47instance A.ToJSON Fixity where
47instance A.ToJSON Fixity where
48 toJSON (Fixity associativity precedence) =
48 toJSON (Fixity associativity precedence) =
src/Language/PureScript/AST/SourcePos.hs+2−2
@@ -35,7 +35,7 @@ data SourcePos = SourcePos
35 -- Column number
35 -- Column number
36 --
36 --
37 , sourcePosColumn :: Int
37 , sourcePosColumn :: Int
38− } deriving (Eq, Ord, Show, D.Data, D.Typeable)
38+ } deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
39
39
40displaySourcePos :: SourcePos -> String
40displaySourcePos :: SourcePos -> String
41displaySourcePos sp =
41displaySourcePos sp =
@@ -58,7 +58,7 @@ data SourceSpan = SourceSpan
58 -- End of the span
58 -- End of the span
59 --
59 --
60 , spanEnd :: SourcePos
60 , spanEnd :: SourcePos
61− } deriving (Eq, Ord, Show, D.Data, D.Typeable)
61+ } deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
62
62
63displayStartEndPos :: SourceSpan -> String
63displayStartEndPos :: SourceSpan -> String
64displayStartEndPos sp =
64displayStartEndPos sp =
src/Language/PureScript/Bundle.hs+11−7
@@ -56,16 +56,20 @@ data ErrorMessage
56 | UnableToParseModule String
56 | UnableToParseModule String
57 | UnsupportedExport
57 | UnsupportedExport
58 | ErrorInModule ModuleIdentifier ErrorMessage
58 | ErrorInModule ModuleIdentifier ErrorMessage
59− deriving Show
59+ deriving (Show, Read)
60
60
61-- | Modules are either "regular modules" (i.e. those generated by psc) or foreign modules.
61-- | Modules are either "regular modules" (i.e. those generated by psc) or foreign modules.
62data ModuleType
62data ModuleType
63 = Regular
63 = Regular
64 | Foreign
64 | Foreign
65− deriving (Show, Eq, Ord)
65+ deriving (Show, Read, Eq, Ord)
66+
67+showModuleType :: ModuleType -> String
68+showModuleType Regular = "Regular"
69+showModuleType Foreign = "Foreign"
66
70
67-- | A module is identified by its module name and its type.
71-- | A module is identified by its module name and its type.
68−data ModuleIdentifier = ModuleIdentifier String ModuleType deriving (Show, Eq, Ord)
72+data ModuleIdentifier = ModuleIdentifier String ModuleType deriving (Show, Read, Eq, Ord)
69
73
70moduleName :: ModuleIdentifier -> String
74moduleName :: ModuleIdentifier -> String
71moduleName (ModuleIdentifier name _) = name
75moduleName (ModuleIdentifier name _) = name
@@ -81,7 +85,7 @@ type Key = (ModuleIdentifier, String)
81data ExportType
85data ExportType
82 = RegularExport String
86 = RegularExport String
83 | ForeignReexport
87 | ForeignReexport
84− deriving (Show, Eq, Ord)
88+ deriving (Show, Read, Eq, Ord)
85
89
86-- | There are four types of module element we are interested in:
90-- | There are four types of module element we are interested in:
87--
91--
@@ -97,10 +101,10 @@ data ModuleElement
97 | Member JSNode Bool String [JSNode] [Key]
101 | Member JSNode Bool String [JSNode] [Key]
98 | ExportsList [(ExportType, String, JSNode, [Key])]
102 | ExportsList [(ExportType, String, JSNode, [Key])]
99 | Other JSNode
103 | Other JSNode
100− deriving Show
104+ deriving (Show, Read)
101
105
102-- | A module is just a list of elements of the types listed above.
106-- | A module is just a list of elements of the types listed above.
103−data Module = Module ModuleIdentifier [ModuleElement] deriving Show
107+data Module = Module ModuleIdentifier [ModuleElement] deriving (Show, Read)
104
108
105-- | Prepare an error message for consumption by humans.
109-- | Prepare an error message for consumption by humans.
106printErrorMessage :: ErrorMessage -> [String]
110printErrorMessage :: ErrorMessage -> [String]
@@ -127,7 +131,7 @@ printErrorMessage (ErrorInModule mid e) =
127 : map (" " ++) (printErrorMessage e)
131 : map (" " ++) (printErrorMessage e)
128 where
132 where
129 displayIdentifier (ModuleIdentifier name ty) =
133 displayIdentifier (ModuleIdentifier name ty) =
130− name ++ " (" ++ show ty ++ ")"
134+ name ++ " (" ++ showModuleType ty ++ ")"
131
135
132-- | Unpack the node inside a JSNode. This is useful when pattern matching.
136-- | Unpack the node inside a JSNode. This is useful when pattern matching.
133node :: JSNode -> Node
137node :: JSNode -> Node
src/Language/PureScript/CodeGen/Externs.hs+19−19
@@ -49,22 +49,22 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
49
49
50 listRef :: DeclarationRef -> Maybe String
50 listRef :: DeclarationRef -> Maybe String
51 listRef (PositionedDeclarationRef _ _ d) = listRef d
51 listRef (PositionedDeclarationRef _ _ d) = listRef d
52− listRef (TypeRef name Nothing) = Just $ show name ++ "()"
52+ listRef (TypeRef name Nothing) = Just $ runProperName name ++ "()"
53− listRef (TypeRef name (Just dctors)) = Just $ show name ++ "(" ++ intercalate ", " (map show dctors) ++ ")"
53+ listRef (TypeRef name (Just dctors)) = Just $ runProperName name ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
54− listRef (ValueRef name) = Just $ show name
54+ listRef (ValueRef name) = Just $ showIdent name
55− listRef (TypeClassRef name) = Just $ show name
55+ listRef (TypeClassRef name) = Just $ runProperName name
56− listRef (ModuleRef name) = Just $ "module " ++ show name
56+ listRef (ModuleRef name) = Just $ "module " ++ runModuleName name
57 listRef _ = Nothing
57 listRef _ = Nothing
58
58
59 declToPs :: Declaration -> Writer [String] ()
59 declToPs :: Declaration -> Writer [String] ()
60 declToPs (ImportDeclaration mn imp Nothing) =
60 declToPs (ImportDeclaration mn imp Nothing) =
61− tell ["import " ++ show mn ++ importToPs imp]
61+ tell ["import " ++ runModuleName mn ++ importToPs imp]
62 declToPs (ImportDeclaration mn imp (Just qual)) =
62 declToPs (ImportDeclaration mn imp (Just qual)) =
63− tell ["import qualified " ++ show mn ++ importToPs imp ++ " as " ++ show qual]
63+ tell ["import qualified " ++ runModuleName mn ++ importToPs imp ++ " as " ++ runModuleName qual]
64 declToPs (FixityDeclaration (Fixity assoc prec) op) =
64 declToPs (FixityDeclaration (Fixity assoc prec) op) =
65 case find exportsOp exts of
65 case find exportsOp exts of
66 Nothing -> return ()
66 Nothing -> return ()
67− Just _ -> tell [ unwords [ show assoc, show prec, op ] ]
67+ Just _ -> tell [ unwords [ showAssoc assoc, show prec, op ] ]
68 where
68 where
69 exportsOp :: DeclarationRef -> Bool
69 exportsOp :: DeclarationRef -> Bool
70 exportsOp (PositionedDeclarationRef _ _ r) = exportsOp r
70 exportsOp (PositionedDeclarationRef _ _ r) = exportsOp r
@@ -86,14 +86,14 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
86 exportToPs (PositionedDeclarationRef _ _ r) = exportToPs r
86 exportToPs (PositionedDeclarationRef _ _ r) = exportToPs r
87 exportToPs (TypeRef pn dctors) =
87 exportToPs (TypeRef pn dctors) =
88 case Qualified (Just moduleName) pn `M.lookup` types env of
88 case Qualified (Just moduleName) pn `M.lookup` types env of
89− Nothing -> error $ show pn ++ " has no kind in exportToPs"
89+ Nothing -> error $ runProperName pn ++ " has no kind in exportToPs"
90 Just (kind, ExternData) ->
90 Just (kind, ExternData) ->
91− tell ["foreign import data " ++ show pn ++ " :: " ++ prettyPrintKind kind]
91+ tell ["foreign import data " ++ runProperName pn ++ " :: " ++ prettyPrintKind kind]
92 Just (_, DataType args tys) -> do
92 Just (_, DataType args tys) -> do
93 let dctors' = fromMaybe (map fst tys) dctors
93 let dctors' = fromMaybe (map fst tys) dctors
94 printDctor dctor = case dctor `lookup` tys of
94 printDctor dctor = case dctor `lookup` tys of
95 Nothing -> Nothing
95 Nothing -> Nothing
96− Just tyArgs -> Just $ show dctor ++ " " ++ unwords (map prettyPrintTypeAtom tyArgs)
96+ Just tyArgs -> Just $ runProperName dctor ++ " " ++ unwords (map prettyPrintTypeAtom tyArgs)
97 let dtype = if length dctors' == 1 && isNewtypeConstructor env (Qualified (Just moduleName) $ head dctors')
97 let dtype = if length dctors' == 1 && isNewtypeConstructor env (Qualified (Just moduleName) $ head dctors')
98 then "newtype"
98 then "newtype"
99 else "data"
99 else "data"
@@ -101,7 +101,7 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
101 tell [dtype ++ " " ++ typeName ++ (if null dctors' then "" else " = " ++ intercalate " | " (mapMaybe printDctor dctors'))]
101 tell [dtype ++ " " ++ typeName ++ (if null dctors' then "" else " = " ++ intercalate " | " (mapMaybe printDctor dctors'))]
102 Just (_, TypeSynonym) ->
102 Just (_, TypeSynonym) ->
103 case Qualified (Just moduleName) pn `M.lookup` typeSynonyms env of
103 case Qualified (Just moduleName) pn `M.lookup` typeSynonyms env of
104− Nothing -> error $ show pn ++ " has no type synonym info in exportToPs"
104+ Nothing -> error $ runProperName pn ++ " has no type synonym info in exportToPs"
105 Just (args, synTy) ->
105 Just (args, synTy) ->
106 let
106 let
107 typeName = prettyPrintType $ foldl TypeApp (TypeConstructor (Qualified Nothing pn)) (map toTypeVar args)
107 typeName = prettyPrintType $ foldl TypeApp (TypeConstructor (Qualified Nothing pn)) (map toTypeVar args)
@@ -110,29 +110,29 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
110
110
111 exportToPs (ValueRef ident) =
111 exportToPs (ValueRef ident) =
112 case (moduleName, ident) `M.lookup` names env of
112 case (moduleName, ident) `M.lookup` names env of
113− Nothing -> error $ show ident ++ " has no type in exportToPs"
113+ Nothing -> error $ showIdent ident ++ " has no type in exportToPs"
114 Just (ty, nk, _) | nk == Public || nk == External ->
114 Just (ty, nk, _) | nk == Public || nk == External ->
115− tell ["foreign import " ++ show ident ++ " :: " ++ prettyPrintType ty]
115+ tell ["foreign import " ++ showIdent ident ++ " :: " ++ prettyPrintType ty]
116 _ -> return ()
116 _ -> return ()
117 exportToPs (TypeClassRef className) =
117 exportToPs (TypeClassRef className) =
118 case Qualified (Just moduleName) className `M.lookup` typeClasses env of
118 case Qualified (Just moduleName) className `M.lookup` typeClasses env of
119− Nothing -> error $ show className ++ " has no type class definition in exportToPs"
119+ Nothing -> error $ runProperName className ++ " has no type class definition in exportToPs"
120 Just (args, members, implies) -> do
120 Just (args, members, implies) -> do
121 let impliesString = if null implies
121 let impliesString = if null implies
122 then ""
122 then ""
123− else "(" ++ intercalate ", " (map (\(pn, tys') -> show pn ++ " " ++ unwords (map prettyPrintTypeAtom tys')) implies) ++ ") <= "
123+ else "(" ++ intercalate ", " (map (\(pn, tys') -> showQualified runProperName pn ++ " " ++ unwords (map prettyPrintTypeAtom tys')) implies) ++ ") <= "
124 typeName = prettyPrintType $ foldl TypeApp (TypeConstructor (Qualified Nothing className)) (map toTypeVar args)
124 typeName = prettyPrintType $ foldl TypeApp (TypeConstructor (Qualified Nothing className)) (map toTypeVar args)
125 tell ["class " ++ impliesString ++ typeName ++ " where"]
125 tell ["class " ++ impliesString ++ typeName ++ " where"]
126 forM_ (filter (isValueExported . fst) members) $ \(member ,ty) ->
126 forM_ (filter (isValueExported . fst) members) $ \(member ,ty) ->
127− tell [ " " ++ show member ++ " :: " ++ prettyPrintType ty ]
127+ tell [ " " ++ showIdent member ++ " :: " ++ prettyPrintType ty ]
128
128
129 exportToPs (TypeInstanceRef ident) = do
129 exportToPs (TypeInstanceRef ident) = do
130 let TypeClassDictionaryInScope { tcdClassName = className, tcdInstanceTypes = tys, tcdDependencies = deps} =
130 let TypeClassDictionaryInScope { tcdClassName = className, tcdInstanceTypes = tys, tcdDependencies = deps} =
131 fromMaybe (error $ "Type class instance has no dictionary in exportToPs") . find (\tcd -> tcdName tcd == Qualified (Just moduleName) ident && tcdType tcd == TCDRegular) . maybe [] (M.elems >=> M.elems) . M.lookup (Just moduleName) $ typeClassDictionaries env
131 fromMaybe (error $ "Type class instance has no dictionary in exportToPs") . find (\tcd -> tcdName tcd == Qualified (Just moduleName) ident && tcdType tcd == TCDRegular) . maybe [] (M.elems >=> M.elems) . M.lookup (Just moduleName) $ typeClassDictionaries env
132 let constraintsText = case fromMaybe [] deps of
132 let constraintsText = case fromMaybe [] deps of
133 [] -> ""
133 [] -> ""
134− cs -> "(" ++ intercalate ", " (map (\(pn, tys') -> show pn ++ " " ++ unwords (map prettyPrintTypeAtom tys')) cs) ++ ") => "
134+ cs -> "(" ++ intercalate ", " (map (\(pn, tys') -> showQualified runProperName pn ++ " " ++ unwords (map prettyPrintTypeAtom tys')) cs) ++ ") => "
135− tell ["foreign import instance " ++ show ident ++ " :: " ++ constraintsText ++ show className ++ " " ++ unwords (map prettyPrintTypeAtom tys)]
135+ tell ["foreign import instance " ++ showIdent ident ++ " :: " ++ constraintsText ++ showQualified runProperName className ++ " " ++ unwords (map prettyPrintTypeAtom tys)]
136
136
137 exportToPs (ModuleRef _) = return ()
137 exportToPs (ModuleRef _) = return ()
138
138
src/Language/PureScript/CodeGen/JS.hs+3−3
@@ -172,7 +172,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ = do
172 then foreignIdent ident
172 then foreignIdent ident
173 else varToJs qi
173 else varToJs qi
174 valueToJs (Var (_, _, _, Just IsForeign) ident) =
174 valueToJs (Var (_, _, _, Just IsForeign) ident) =
175− error $ "Encountered an unqualified reference to a foreign ident " ++ show ident
175+ error $ "Encountered an unqualified reference to a foreign ident " ++ showQualified showIdent ident
176 valueToJs (Var _ ident) =
176 valueToJs (Var _ ident) =
177 return $ varToJs ident
177 return $ varToJs ident
178 valueToJs (Case (maybeSpan, _, _, _) values binders) = do
178 valueToJs (Case (maybeSpan, _, _, _) values binders) = do
@@ -320,8 +320,8 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ = do
320 done'' <- go remain done'
320 done'' <- go remain done'
321 js <- binderToJs argVar done'' binder
321 js <- binderToJs argVar done'' binder
322 return (JSVariableIntroduction argVar (Just (JSAccessor (identToJs field) (JSVar varName))) : js)
322 return (JSVariableIntroduction argVar (Just (JSAccessor (identToJs field) (JSVar varName))) : js)
323− binderToJs _ _ b@(ConstructorBinder{}) =
323+ binderToJs _ _ ConstructorBinder{} =
324− error $ "Invalid ConstructorBinder in binderToJs: " ++ show b
324+ error "binderToJs: Invalid ConstructorBinder in binderToJs"
325 binderToJs varName done (NamedBinder _ ident binder) = do
325 binderToJs varName done (NamedBinder _ ident binder) = do
326 js <- binderToJs varName done binder
326 js <- binderToJs varName done binder
327 return (JSVariableIntroduction (identToJs ident) (Just (JSVar varName)) : js)
327 return (JSVariableIntroduction (identToJs ident) (Just (JSVar varName)) : js)
src/Language/PureScript/CodeGen/JS/AST.hs+3−3
@@ -53,7 +53,7 @@ data UnaryOperator
53 -- |
53 -- |
54 -- Constructor
54 -- Constructor
55 --
55 --
56− | JSNew deriving (Show, Eq, Data, Typeable)
56+ | JSNew deriving (Show, Read, Eq, Data, Typeable)
57
57
58-- |
58-- |
59-- Built-in binary operators
59-- Built-in binary operators
@@ -134,7 +134,7 @@ data BinaryOperator
134 -- |
134 -- |
135 -- Bitwise right shift with zero-fill
135 -- Bitwise right shift with zero-fill
136 --
136 --
137− | ZeroFillShiftRight deriving (Show, Eq, Data, Typeable)
137+ | ZeroFillShiftRight deriving (Show, Read, Eq, Data, Typeable)
138
138
139-- |
139-- |
140-- Data type for simplified Javascript expressions
140-- Data type for simplified Javascript expressions
@@ -255,7 +255,7 @@ data JS
255 -- |
255 -- |
256 -- Commented Javascript
256 -- Commented Javascript
257 --
257 --
258− | JSComment [Comment] JS deriving (Show, Eq, Data, Typeable)
258+ | JSComment [Comment] JS deriving (Show, Read, Eq, Data, Typeable)
259
259
260--
260--
261-- Traversals
261-- Traversals
src/Language/PureScript/Comments.hs+1−1
@@ -22,4 +22,4 @@ import qualified Data.Data as D
22data Comment
22data Comment
23 = LineComment String
23 = LineComment String
24 | BlockComment String
24 | BlockComment String
25− deriving (Show, Eq, Ord, D.Data, D.Typeable)
25+ deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
src/Language/PureScript/CoreFn/Binders.hs+1−1
@@ -45,4 +45,4 @@ data Binder a
45 -- |
45 -- |
46 -- A binder which binds its input to an identifier
46 -- A binder which binds its input to an identifier
47 --
47 --
48− | NamedBinder a Ident (Binder a) deriving (Show, D.Data, D.Typeable, Functor)
48+ | NamedBinder a Ident (Binder a) deriving (Show, Read, D.Data, D.Typeable, Functor)
src/Language/PureScript/CoreFn/Expr.hs+3−3
@@ -64,7 +64,7 @@ data Expr a
64 -- |
64 -- |
65 -- A let binding
65 -- A let binding
66 --
66 --
67− | Let a [Bind a] (Expr a) deriving (Show, D.Data, D.Typeable, Functor)
67+ | Let a [Bind a] (Expr a) deriving (Show, Read, D.Data, D.Typeable, Functor)
68
68
69-- |
69-- |
70-- A let or module binding.
70-- A let or module binding.
@@ -77,7 +77,7 @@ data Bind a
77 -- |
77 -- |
78 -- Mutually recursive binding group for several values
78 -- Mutually recursive binding group for several values
79 --
79 --
80− | Rec [(Ident, Expr a)] deriving (Show, D.Data, D.Typeable, Functor)
80+ | Rec [(Ident, Expr a)] deriving (Show, Read, D.Data, D.Typeable, Functor)
81
81
82-- |
82-- |
83-- A guard is just a boolean-valued expression that appears alongside a set of binders
83-- A guard is just a boolean-valued expression that appears alongside a set of binders
@@ -96,7 +96,7 @@ data CaseAlternative a = CaseAlternative
96 -- The result expression or a collect of guarded expressions
96 -- The result expression or a collect of guarded expressions
97 --
97 --
98 , caseAlternativeResult :: Either [(Guard a, Expr a)] (Expr a)
98 , caseAlternativeResult :: Either [(Guard a, Expr a)] (Expr a)
99− } deriving (Show, D.Data, D.Typeable)
99+ } deriving (Show, Read, D.Data, D.Typeable)
100
100
101instance Functor CaseAlternative where
101instance Functor CaseAlternative where
102
102
src/Language/PureScript/CoreFn/Literals.hs+1−1
@@ -47,4 +47,4 @@ data Literal a
47 -- |
47 -- |
48 -- An object literal
48 -- An object literal
49 --
49 --
50− | ObjectLiteral [(String, a)] deriving (Show, D.Data, D.Typeable, Functor)
50+ | ObjectLiteral [(String, a)] deriving (Show, Read, D.Data, D.Typeable, Functor)
src/Language/PureScript/CoreFn/Meta.hs+2−2
@@ -39,7 +39,7 @@ data Meta
39 -- |
39 -- |
40 -- The contained reference is for a foreign member
40 -- The contained reference is for a foreign member
41 --
41 --
42− | IsForeign deriving (Show, D.Data, D.Typeable)
42+ | IsForeign deriving (Show, Read, D.Data, D.Typeable)
43
43
44-- |
44-- |
45-- Data constructor metadata
45-- Data constructor metadata
@@ -52,4 +52,4 @@ data ConstructorType
52 -- |
52 -- |
53 -- The constructor is for a type with multiple construcors
53 -- The constructor is for a type with multiple construcors
54 --
54 --
55− | SumType deriving (Show, D.Data, D.Typeable)
55+ | SumType deriving (Show, Read, D.Data, D.Typeable)
src/Language/PureScript/CoreFn/Module.hs+1−1
@@ -26,6 +26,6 @@ data Module a = Module
26 , moduleExports :: [Ident]
26 , moduleExports :: [Ident]
27 , moduleForeign :: [ForeignDecl]
27 , moduleForeign :: [ForeignDecl]
28 , moduleDecls :: [Bind a]
28 , moduleDecls :: [Bind a]
29− } deriving (Show)
29+ } deriving (Show, Read)
30
30
31type ForeignDecl = (Ident, Type)
31type ForeignDecl = (Ident, Type)
src/Language/PureScript/Docs/AsMarkdown.hs+1−1
@@ -98,7 +98,7 @@ childToString f decl@ChildDeclaration{..} =
98data First
98data First
99 = First
99 = First
100 | NotFirst
100 | NotFirst
101− deriving (Show, Eq, Ord)
101+ deriving (Show, Read, Eq, Ord)
102
102
103type Docs = Writer [String] ()
103type Docs = Writer [String] ()
104
104
src/Language/PureScript/Docs/Convert.hs+11−12
@@ -26,7 +26,7 @@ import Language.PureScript.Docs.Types
26--
26--
27convertModule :: P.Module -> Module
27convertModule :: P.Module -> Module
28convertModule m@(P.Module _ coms moduleName _ _) =
28convertModule m@(P.Module _ coms moduleName _ _) =
29− Module (show moduleName) comments (declarations m)
29+ Module (P.runModuleName moduleName) comments (declarations m)
30 where
30 where
31 comments = convertComments coms
31 comments = convertComments coms
32 declarations =
32 declarations =
@@ -106,13 +106,13 @@ addDefaultFixity decl@Declaration{..}
106 defaultFixity = P.Fixity P.Infixl (-1)
106 defaultFixity = P.Fixity P.Infixl (-1)
107
107
108getDeclarationTitle :: P.Declaration -> Maybe String
108getDeclarationTitle :: P.Declaration -> Maybe String
109−getDeclarationTitle (P.TypeDeclaration name _) = Just (show name)
109+getDeclarationTitle (P.TypeDeclaration name _) = Just (P.showIdent name)
110−getDeclarationTitle (P.ExternDeclaration name _) = Just (show name)
110+getDeclarationTitle (P.ExternDeclaration name _) = Just (P.showIdent name)
111−getDeclarationTitle (P.DataDeclaration _ name _ _) = Just (show name)
111+getDeclarationTitle (P.DataDeclaration _ name _ _) = Just (P.runProperName name)
112−getDeclarationTitle (P.ExternDataDeclaration name _) = Just (show name)
112+getDeclarationTitle (P.ExternDataDeclaration name _) = Just (P.runProperName name)
113−getDeclarationTitle (P.TypeSynonymDeclaration name _ _) = Just (show name)
113+getDeclarationTitle (P.TypeSynonymDeclaration name _ _) = Just (P.runProperName name)
114−getDeclarationTitle (P.TypeClassDeclaration name _ _ _) = Just (show name)
114+getDeclarationTitle (P.TypeClassDeclaration name _ _ _) = Just (P.runProperName name)
115−getDeclarationTitle (P.TypeInstanceDeclaration name _ _ _ _) = Just (show name)
115+getDeclarationTitle (P.TypeInstanceDeclaration name _ _ _ _) = Just (P.showIdent name)
116getDeclarationTitle (P.FixityDeclaration _ name) = Just ("(" ++ name ++ ")")
116getDeclarationTitle (P.FixityDeclaration _ name) = Just ("(" ++ name ++ ")")
117getDeclarationTitle (P.PositionedDeclaration _ _ d) = getDeclarationTitle d
117getDeclarationTitle (P.PositionedDeclaration _ _ d) = getDeclarationTitle d
118getDeclarationTitle _ = Nothing
118getDeclarationTitle _ = Nothing
@@ -142,7 +142,7 @@ convertDeclaration (P.DataDeclaration dtype _ args ctors) title =
142 info = DataDeclaration dtype args
142 info = DataDeclaration dtype args
143 children = map convertCtor ctors
143 children = map convertCtor ctors
144 convertCtor (ctor', tys) =
144 convertCtor (ctor', tys) =
145− ChildDeclaration (show ctor') Nothing Nothing (ChildDataConstructor tys)
145+ ChildDeclaration (P.runProperName ctor') Nothing Nothing (ChildDataConstructor tys)
146convertDeclaration (P.ExternDataDeclaration _ kind') title =
146convertDeclaration (P.ExternDataDeclaration _ kind') title =
147 basicDeclaration title (ExternDataDeclaration kind')
147 basicDeclaration title (ExternDataDeclaration kind')
148convertDeclaration (P.TypeSynonymDeclaration _ args ty) title =
148convertDeclaration (P.TypeSynonymDeclaration _ args ty) title =
@@ -155,7 +155,7 @@ convertDeclaration (P.TypeClassDeclaration _ args implies ds) title = do
155 convertClassMember (P.PositionedDeclaration _ _ d) =
155 convertClassMember (P.PositionedDeclaration _ _ d) =
156 convertClassMember d
156 convertClassMember d
157 convertClassMember (P.TypeDeclaration ident' ty) =
157 convertClassMember (P.TypeDeclaration ident' ty) =
158− ChildDeclaration (show ident') Nothing Nothing (ChildTypeClassMember ty)
158+ ChildDeclaration (P.showIdent ident') Nothing Nothing (ChildTypeClassMember ty)
159 convertClassMember _ =
159 convertClassMember _ =
160 error "Invalid argument to convertClassMember."
160 error "Invalid argument to convertClassMember."
161convertDeclaration (P.TypeInstanceDeclaration _ constraints className tys _) title = do
161convertDeclaration (P.TypeInstanceDeclaration _ constraints className tys _) title = do
@@ -163,7 +163,7 @@ convertDeclaration (P.TypeInstanceDeclaration _ constraints className tys _) tit
163 where
163 where
164 classNameString = unQual className
164 classNameString = unQual className
165 typeNameStrings = nub (concatMap (P.everythingOnTypes (++) extractProperNames) tys)
165 typeNameStrings = nub (concatMap (P.everythingOnTypes (++) extractProperNames) tys)
166− unQual x = let (P.Qualified _ y) = x in show y
166+ unQual x = let (P.Qualified _ y) = x in P.runProperName y
167
167
168 extractProperNames (P.TypeConstructor n) = [unQual n]
168 extractProperNames (P.TypeConstructor n) = [unQual n]
169 extractProperNames (P.SaturatedTypeSynonym n _) = [unQual n]
169 extractProperNames (P.SaturatedTypeSynonym n _) = [unQual n]
@@ -225,4 +225,3 @@ collectBookmarks' m =
225 map (P.getModuleName m, )
225 map (P.getModuleName m, )
226 (mapMaybe getDeclarationTitle
226 (mapMaybe getDeclarationTitle
227 (P.exportedDeclarations m))
227 (P.exportedDeclarations m))
228−
src/Language/PureScript/Docs/Render.hs+1−1
@@ -29,7 +29,7 @@ renderDeclarationWithOptions opts Declaration{..} =
29 , renderType' ty
29 , renderType' ty
30 ]
30 ]
31 DataDeclaration dtype args ->
31 DataDeclaration dtype args ->
32− [ keyword (show dtype)
32+ [ keyword (P.showDataDeclType dtype)
33 , renderType' (typeApp declTitle args)
33 , renderType' (typeApp declTitle args)
34 ]
34 ]
35 ExternDataDeclaration kind' ->
35 ExternDataDeclaration kind' ->
src/Language/PureScript/Docs/RenderedCode/Render.hs+1−1
@@ -45,7 +45,7 @@ typeLiterals = mkPattern match
45 , syntax "}"
45 , syntax "}"
46 ]
46 ]
47 match (TypeConstructor (Qualified mn name)) =
47 match (TypeConstructor (Qualified mn name)) =
48− Just (ctor (show name) (maybeToContainingModule mn))
48+ Just (ctor (runProperName name) (maybeToContainingModule mn))
49 match (ConstrainedType deps ty) =
49 match (ConstrainedType deps ty) =
50 Just $ mintersperse sp
50 Just $ mintersperse sp
51 [ syntax "(" <> constraints <> syntax ")"
51 [ syntax "(" <> constraints <> syntax ")"
src/Language/PureScript/Environment.hs+9−9
@@ -57,7 +57,7 @@ data Environment = Environment {
57 -- Type classes
57 -- Type classes
58 --
58 --
59 , typeClasses :: M.Map (Qualified ProperName) ([(String, Maybe Kind)], [(Ident, Type)], [Constraint])
59 , typeClasses :: M.Map (Qualified ProperName) ([(String, Maybe Kind)], [(Ident, Type)], [Constraint])
60− } deriving (Show)
60+ } deriving (Show, Read)
61
61
62-- |
62-- |
63-- The initial environment with no values and only the default javascript types defined
63-- The initial environment with no values and only the default javascript types defined
@@ -76,7 +76,7 @@ data NameVisibility
76 -- |
76 -- |
77 -- The name is defined in the another binding group, or has been made visible by a function binder
77 -- The name is defined in the another binding group, or has been made visible by a function binder
78 --
78 --
79− | Defined deriving (Show, Eq)
79+ | Defined deriving (Show, Read, Eq)
80
80
81-- |
81-- |
82-- A flag for whether a name is for an private or public value - only public values will be
82-- A flag for whether a name is for an private or public value - only public values will be
@@ -95,7 +95,7 @@ data NameKind
95 -- |
95 -- |
96 -- A name for member introduced by foreign import
96 -- A name for member introduced by foreign import
97 --
97 --
98− | External deriving (Show, Eq, Data, Typeable)
98+ | External deriving (Show, Read, Eq, Data, Typeable)
99
99
100-- |
100-- |
101-- The kinds of a type
101-- The kinds of a type
@@ -121,7 +121,7 @@ data TypeKind
121 -- A scoped type variable
121 -- A scoped type variable
122 --
122 --
123 | ScopedTypeVar
123 | ScopedTypeVar
124− deriving (Show, Eq, Data, Typeable)
124+ deriving (Show, Read, Eq, Data, Typeable)
125
125
126-- |
126-- |
127-- The type ('data' or 'newtype') of a data type declaration
127-- The type ('data' or 'newtype') of a data type declaration
@@ -134,14 +134,14 @@ data DataDeclType
134 -- |
134 -- |
135 -- A newtype constructor
135 -- A newtype constructor
136 --
136 --
137− | Newtype deriving (Eq, Ord, Data, Typeable)
137+ | Newtype deriving (Show, Read, Eq, Ord, Data, Typeable)
138
138
139−instance Show DataDeclType where
139+showDataDeclType :: DataDeclType -> String
140− show Data = "data"
140+showDataDeclType Data = "data"
141− show Newtype = "newtype"
141+showDataDeclType Newtype = "newtype"
142
142
143instance A.ToJSON DataDeclType where
143instance A.ToJSON DataDeclType where
144− toJSON = A.toJSON . show
144+ toJSON = A.toJSON . showDataDeclType
145
145
146instance A.FromJSON DataDeclType where
146instance A.FromJSON DataDeclType where
147 parseJSON = A.withText "DataDeclType" $ \str ->
147 parseJSON = A.withText "DataDeclType" $ \str ->
src/Language/PureScript/Errors.hs+78−78
@@ -309,7 +309,7 @@ onErrorMessages :: (ErrorMessage -> ErrorMessage) -> MultipleErrors -> MultipleE
309onErrorMessages f = MultipleErrors . map f . runMultipleErrors
309onErrorMessages f = MultipleErrors . map f . runMultipleErrors
310
310
311-- | The various types of things which might need to be relabelled in errors messages.
311-- | The various types of things which might need to be relabelled in errors messages.
312−data LabelType = TypeLabel | SkolemLabel String deriving (Show, Eq, Ord)
312+data LabelType = TypeLabel | SkolemLabel String deriving (Show, Read, Eq, Ord)
313
313
314-- | A map from rigid type variable name/unknown variable pairs to new variables.
314-- | A map from rigid type variable name/unknown variable pairs to new variables.
315type UnknownMap = M.Map (LabelType, Unknown) Unknown
315type UnknownMap = M.Map (LabelType, Unknown) Unknown
@@ -430,13 +430,13 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
430 , indent . prettyPrintParseError $ err
430 , indent . prettyPrintParseError $ err
431 ]
431 ]
432 goSimple (MissingFFIModule mn) =
432 goSimple (MissingFFIModule mn) =
433− line $ "Missing FFI implementations for module " ++ show mn
433+ line $ "Missing FFI implementations for module " ++ runModuleName mn
434 goSimple (UnnecessaryFFIModule mn path) =
434 goSimple (UnnecessaryFFIModule mn path) =
435− paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ show mn ++ ": "
435+ paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ runModuleName mn ++ ": "
436 , indent . line $ path
436 , indent . line $ path
437 ]
437 ]
438 goSimple (MultipleFFIModules mn paths) =
438 goSimple (MultipleFFIModules mn paths) =
439− paras $ [ line $ "Multiple FFI implementations have been provided for module " ++ show mn ++ ": " ]
439+ paras $ [ line $ "Multiple FFI implementations have been provided for module " ++ runModuleName mn ++ ": " ]
440 ++ map (indent . line) paths
440 ++ map (indent . line) paths
441 goSimple (InvalidExternsFile path) =
441 goSimple (InvalidExternsFile path) =
442 paras [ line "Externs file is invalid: "
442 paras [ line "Externs file is invalid: "
@@ -461,80 +461,80 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
461 , indent $ line $ prettyPrintKind ki
461 , indent $ line $ prettyPrintKind ki
462 ]
462 ]
463 goSimple (MultipleFixities name) =
463 goSimple (MultipleFixities name) =
464− line $ "Multiple fixity declarations for " ++ show name
464+ line $ "Multiple fixity declarations for " ++ showIdent name
465 goSimple (OrphanTypeDeclaration nm) =
465 goSimple (OrphanTypeDeclaration nm) =
466− line $ "Orphan type declaration for " ++ show nm
466+ line $ "Orphan type declaration for " ++ showIdent nm
467 goSimple (OrphanFixityDeclaration op) =
467 goSimple (OrphanFixityDeclaration op) =
468 line $ "Orphan fixity declaration for " ++ show op
468 line $ "Orphan fixity declaration for " ++ show op
469 goSimple (RedefinedModule name filenames) =
469 goSimple (RedefinedModule name filenames) =
470− paras $ [ line $ "Module " ++ show name ++ " has been defined multiple times:"
470+ paras $ line ("Module " ++ runModuleName name ++ " has been defined multiple times:")
471− ] ++ map (indent . line . displaySourceSpan) filenames
471+ : map (indent . line . displaySourceSpan) filenames
472 goSimple (RedefinedIdent name) =
472 goSimple (RedefinedIdent name) =
473− line $ "Name " ++ show name ++ " has been defined multiple times"
473+ line $ "Name " ++ showIdent name ++ " has been defined multiple times"
474 goSimple (UnknownModule mn) =
474 goSimple (UnknownModule mn) =
475− line $ "Unknown module " ++ show mn
475+ line $ "Unknown module " ++ runModuleName mn
476 goSimple (UnknownType name) =
476 goSimple (UnknownType name) =
477− line $ "Unknown type " ++ show name
477+ line $ "Unknown type " ++ showQualified runProperName name
478 goSimple (UnknownTypeClass name) =
478 goSimple (UnknownTypeClass name) =
479− line $ "Unknown type class " ++ show name
479+ line $ "Unknown type class " ++ showQualified runProperName name
480 goSimple (UnknownValue name) =
480 goSimple (UnknownValue name) =
481− line $ "Unknown value " ++ show name
481+ line $ "Unknown value " ++ showQualified showIdent name
482 goSimple (UnknownTypeConstructor name) =
482 goSimple (UnknownTypeConstructor name) =
483− line $ "Unknown type constructor " ++ show name
483+ line $ "Unknown type constructor " ++ showQualified runProperName name
484 goSimple (UnknownDataConstructor dc tc) =
484 goSimple (UnknownDataConstructor dc tc) =
485− line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
485+ line $ "Unknown data constructor " ++ showQualified runProperName dc ++ foldMap ((" for type constructor " ++) . showQualified runProperName) tc
486 goSimple (UnknownImportType mn name) =
486 goSimple (UnknownImportType mn name) =
487− line $ "Module " ++ show mn ++ " does not export type " ++ show name
487+ line $ "Module " ++ runModuleName mn ++ " does not export type " ++ runProperName name
488 goSimple (UnknownExportType name) =
488 goSimple (UnknownExportType name) =
489− line $ "Cannot export unknown type " ++ show name
489+ line $ "Cannot export unknown type " ++ runProperName name
490 goSimple (UnknownImportTypeClass mn name) =
490 goSimple (UnknownImportTypeClass mn name) =
491− line $ "Module " ++ show mn ++ " does not export type class " ++ show name
491+ line $ "Module " ++ runModuleName mn ++ " does not export type class " ++ runProperName name
492 goSimple (UnknownExportTypeClass name) =
492 goSimple (UnknownExportTypeClass name) =
493− line $ "Cannot export unknown type class " ++ show name
493+ line $ "Cannot export unknown type class " ++ runProperName name
494 goSimple (UnknownImportValue mn name) =
494 goSimple (UnknownImportValue mn name) =
495− line $ "Module " ++ show mn ++ " does not export value " ++ show name
495+ line $ "Module " ++ runModuleName mn ++ " does not export value " ++ showIdent name
496 goSimple (UnknownExportValue name) =
496 goSimple (UnknownExportValue name) =
497− line $ "Cannot export unknown value " ++ show name
497+ line $ "Cannot export unknown value " ++ showIdent name
498 goSimple (UnknownExportModule name) =
498 goSimple (UnknownExportModule name) =
499− line $ "Cannot export unknown module " ++ show name ++ ", it either does not exist or has not been imported by the current module"
499+ line $ "Cannot export unknown module " ++ runModuleName name ++ ", it either does not exist or has not been imported by the current module"
500 goSimple (UnknownImportDataConstructor mn tcon dcon) =
500 goSimple (UnknownImportDataConstructor mn tcon dcon) =
501− line $ "Module " ++ show mn ++ " does not export data constructor " ++ show dcon ++ " for type " ++ show tcon
501+ line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon
502 goSimple (UnknownExportDataConstructor tcon dcon) =
502 goSimple (UnknownExportDataConstructor tcon dcon) =
503− line $ "Cannot export data constructor " ++ show dcon ++ " for type " ++ show tcon ++ " as it has not been declared"
503+ line $ "Cannot export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon ++ " as it has not been declared"
504 goSimple (ConflictingImport nm mn) =
504 goSimple (ConflictingImport nm mn) =
505− line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ show mn
505+ line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ runModuleName mn
506 goSimple (ConflictingImports nm m1 m2) =
506 goSimple (ConflictingImports nm m1 m2) =
507− line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
507+ line $ "Conflicting imports for " ++ nm ++ " from modules " ++ runModuleName m1 ++ " and " ++ runModuleName m2
508 goSimple (ConflictingTypeDecls nm) =
508 goSimple (ConflictingTypeDecls nm) =
509− line $ "Conflicting type declarations for " ++ show nm
509+ line $ "Conflicting type declarations for " ++ runProperName nm
510 goSimple (ConflictingCtorDecls nm) =
510 goSimple (ConflictingCtorDecls nm) =
511− line $ "Conflicting data constructor declarations for " ++ show nm
511+ line $ "Conflicting data constructor declarations for " ++ runProperName nm
512 goSimple (TypeConflictsWithClass nm) =
512 goSimple (TypeConflictsWithClass nm) =
513− line $ "Type " ++ show nm ++ " conflicts with type class declaration of the same name"
513+ line $ "Type " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
514 goSimple (CtorConflictsWithClass nm) =
514 goSimple (CtorConflictsWithClass nm) =
515− line $ "Data constructor " ++ show nm ++ " conflicts with type class declaration of the same name"
515+ line $ "Data constructor " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
516 goSimple (ClassConflictsWithType nm) =
516 goSimple (ClassConflictsWithType nm) =
517− line $ "Type class " ++ show nm ++ " conflicts with type declaration of the same name"
517+ line $ "Type class " ++ runProperName nm ++ " conflicts with type declaration of the same name"
518 goSimple (ClassConflictsWithCtor nm) =
518 goSimple (ClassConflictsWithCtor nm) =
519− line $ "Type class " ++ show nm ++ " conflicts with data constructor declaration of the same name"
519+ line $ "Type class " ++ runProperName nm ++ " conflicts with data constructor declaration of the same name"
520 goSimple (DuplicateClassExport nm) =
520 goSimple (DuplicateClassExport nm) =
521− line $ "Duplicate export declaration for type class " ++ show nm
521+ line $ "Duplicate export declaration for type class " ++ runProperName nm
522 goSimple (DuplicateValueExport nm) =
522 goSimple (DuplicateValueExport nm) =
523− line $ "Duplicate export declaration for value " ++ show nm
523+ line $ "Duplicate export declaration for value " ++ showIdent nm
524 goSimple (CycleInDeclaration nm) =
524 goSimple (CycleInDeclaration nm) =
525− line $ "Cycle in declaration of " ++ show nm
525+ line $ "Cycle in declaration of " ++ showIdent nm
526 goSimple (CycleInModules mns) =
526 goSimple (CycleInModules mns) =
527− line $ "Cycle in module dependencies: " ++ intercalate ", " (map show mns)
527+ line $ "Cycle in module dependencies: " ++ intercalate ", " (map runModuleName mns)
528 goSimple (CycleInTypeSynonym pn) =
528 goSimple (CycleInTypeSynonym pn) =
529− line $ "Cycle in type synonym" ++ foldMap ((" " ++) . show) pn
529+ line $ "Cycle in type synonym" ++ foldMap ((" " ++) . runProperName) pn
530 goSimple (NameIsUndefined ident) =
530 goSimple (NameIsUndefined ident) =
531− line $ show ident ++ " is undefined"
531+ line $ showIdent ident ++ " is undefined"
532 goSimple (NameNotInScope ident) =
532 goSimple (NameNotInScope ident) =
533− line $ show ident ++ " may not be defined in the current scope"
533+ line $ showIdent ident ++ " may not be defined in the current scope"
534 goSimple (UndefinedTypeVariable name) =
534 goSimple (UndefinedTypeVariable name) =
535− line $ "Type variable " ++ show name ++ " is undefined"
535+ line $ "Type variable " ++ runProperName name ++ " is undefined"
536 goSimple (PartiallyAppliedSynonym name) =
536 goSimple (PartiallyAppliedSynonym name) =
537− paras [ line $ "Partially applied type synonym " ++ show name
537+ paras [ line $ "Partially applied type synonym " ++ showQualified runProperName name
538 , line "Type synonyms must be applied to all of their type arguments."
538 , line "Type synonyms must be applied to all of their type arguments."
539 ]
539 ]
540 goSimple (EscapedSkolem binding) =
540 goSimple (EscapedSkolem binding) =
@@ -561,18 +561,18 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
561 , indent $ line $ prettyPrintType t2
561 , indent $ line $ prettyPrintType t2
562 ]
562 ]
563 goSimple (OverlappingInstances nm ts (d : ds)) =
563 goSimple (OverlappingInstances nm ts (d : ds)) =
564− paras [ line $ "Overlapping instances found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
564+ paras [ line $ "Overlapping instances found for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
565− , indent $ paras (line (show d ++ " (chosen)") : map (line . show) ds)
565+ , indent $ paras (line (showQualified showIdent d ++ " (chosen)") : map (line . showQualified showIdent) ds)
566 ]
566 ]
567 goSimple OverlappingInstances{} = error "OverlappingInstances: empty instance list"
567 goSimple OverlappingInstances{} = error "OverlappingInstances: empty instance list"
568 goSimple (NoInstanceFound nm ts) =
568 goSimple (NoInstanceFound nm ts) =
569− line $ "No instance found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
569+ line $ "No instance found for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
570 goSimple (PossiblyInfiniteInstance nm ts) =
570 goSimple (PossiblyInfiniteInstance nm ts) =
571− line $ "Instance for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is possibly infinite."
571+ line $ "Instance for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is possibly infinite."
572 goSimple (CannotDerive nm ts) =
572 goSimple (CannotDerive nm ts) =
573− line $ "Cannot derive " ++ show nm ++ " instance for " ++ unwords (map prettyPrintTypeAtom ts)
573+ line $ "Cannot derive " ++ showQualified runProperName nm ++ " instance for " ++ unwords (map prettyPrintTypeAtom ts)
574 goSimple (CannotFindDerivingType nm) =
574 goSimple (CannotFindDerivingType nm) =
575− line $ "Cannot derive instance, because the type declaration for " ++ show nm ++ " could not be found."
575+ line $ "Cannot derive instance, because the type declaration for " ++ runProperName nm ++ " could not be found."
576 goSimple (DuplicateLabel l expr) =
576 goSimple (DuplicateLabel l expr) =
577 paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
577 paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
578 <> foldMap (\expr' -> [ line "Relevant expression: "
578 <> foldMap (\expr' -> [ line "Relevant expression: "
@@ -581,22 +581,22 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
581 goSimple (DuplicateTypeArgument name) =
581 goSimple (DuplicateTypeArgument name) =
582 line $ "Duplicate type argument " ++ show name
582 line $ "Duplicate type argument " ++ show name
583 goSimple (DuplicateValueDeclaration nm) =
583 goSimple (DuplicateValueDeclaration nm) =
584− line $ "Duplicate value declaration for " ++ show nm
584+ line $ "Duplicate value declaration for " ++ showIdent nm
585 goSimple (ArgListLengthsDiffer ident) =
585 goSimple (ArgListLengthsDiffer ident) =
586− line $ "Argument list lengths differ in declaration " ++ show ident
586+ line $ "Argument list lengths differ in declaration " ++ showIdent ident
587 goSimple (OverlappingArgNames ident) =
587 goSimple (OverlappingArgNames ident) =
588− line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . show) ident
588+ line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . showIdent) ident
589 goSimple (MissingClassMember ident) =
589 goSimple (MissingClassMember ident) =
590− line $ "Member " ++ show ident ++ " has not been implemented"
590+ line $ "Member " ++ showIdent ident ++ " has not been implemented"
591 goSimple (ExtraneousClassMember ident) =
591 goSimple (ExtraneousClassMember ident) =
592− line $ "Member " ++ show ident ++ " is not a member of the class being instantiated"
592+ line $ "Member " ++ showIdent ident ++ " is not a member of the class being instantiated"
593 goSimple (ExpectedType ty kind) =
593 goSimple (ExpectedType ty kind) =
594 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
594 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
595 , line $ "The error arises from the type " ++ prettyPrintType ty ++ " having the kind " ++ prettyPrintKind kind ++ " instead."
595 , line $ "The error arises from the type " ++ prettyPrintType ty ++ " having the kind " ++ prettyPrintKind kind ++ " instead."
596 ]
596 ]
597 goSimple (IncorrectConstructorArity nm) =
597 goSimple (IncorrectConstructorArity nm) =
598− line $ "Wrong number of arguments to constructor " ++ show nm
598+ line $ "Wrong number of arguments to constructor " ++ showQualified runProperName nm
599− goSimple SubsumptionCheckFailed = line $ "Unable to check type subsumption"
599+ goSimple SubsumptionCheckFailed = line "Unable to check type subsumption"
600 goSimple (ExprDoesNotHaveType expr ty) =
600 goSimple (ExprDoesNotHaveType expr ty) =
601 paras [ line "Expression"
601 paras [ line "Expression"
602 , indent $ line $ prettyPrintValue expr
602 , indent $ line $ prettyPrintValue expr
@@ -614,7 +614,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
614 goSimple TypeSynonymInstance =
614 goSimple TypeSynonymInstance =
615 line "Type synonym instances are disallowed"
615 line "Type synonym instances are disallowed"
616 goSimple (OrphanInstance nm cnm ts) =
616 goSimple (OrphanInstance nm cnm ts) =
617− paras [ line $ "Instance " ++ show nm ++ " for " ++ show cnm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is an orphan instance."
617+ paras [ line $ "Instance " ++ showIdent nm ++ " for " ++ showQualified runProperName cnm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is an orphan instance."
618 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
618 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
619 , line "Consider moving the instance, if possible, or using a newtype wrapper."
619 , line "Consider moving the instance, if possible, or using a newtype wrapper."
620 ]
620 ]
@@ -625,19 +625,19 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
625 , indent $ line $ prettyPrintType ty
625 , indent $ line $ prettyPrintType ty
626 ]
626 ]
627 goSimple (TransitiveExportError x ys) =
627 goSimple (TransitiveExportError x ys) =
628− paras $ (line $ "An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
628+ paras $ line ("An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
629 : map (line . prettyPrintExport) ys
629 : map (line . prettyPrintExport) ys
630 goSimple (ShadowedName nm) =
630 goSimple (ShadowedName nm) =
631− line $ "Name '" ++ show nm ++ "' was shadowed."
631+ line $ "Name '" ++ showIdent nm ++ "' was shadowed."
632 goSimple (ClassOperator className opName) =
632 goSimple (ClassOperator className opName) =
633− paras [ line $ "Class '" ++ show className ++ "' declares operator " ++ show opName ++ "."
633+ paras [ line $ "Class '" ++ runProperName className ++ "' declares operator " ++ showIdent opName ++ "."
634− , indent $ line $ "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
634+ , indent $ line "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
635− , indent $ line $ show opName ++ " = someMember"
635+ , indent $ line $ showIdent opName ++ " = someMember"
636 ]
636 ]
637 goSimple (MisleadingEmptyTypeImport mn name) =
637 goSimple (MisleadingEmptyTypeImport mn name) =
638− line $ "Importing type " ++ show name ++ "(..) from " ++ show mn ++ " is misleading as it has no exported data constructors"
638+ line $ "Importing type " ++ runProperName name ++ "(..) from " ++ runModuleName mn ++ " is misleading as it has no exported data constructors"
639 goSimple (ImportHidingModule name) =
639 goSimple (ImportHidingModule name) =
640− line $ "Attempted to hide module " ++ show name ++ " in import expression, this is not permitted"
640+ line $ "Attempted to hide module " ++ runModuleName name ++ " in import expression, this is not permitted"
641 goSimple (WildcardInferredType ty) =
641 goSimple (WildcardInferredType ty) =
642 line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
642 line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
643 goSimple (NotExhaustivePattern bs b) =
643 goSimple (NotExhaustivePattern bs b) =
@@ -652,7 +652,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
652 ] ++
652 ] ++
653 [ line "..." | not b ]
653 [ line "..." | not b ]
654 go (NotYetDefined names err) =
654 go (NotYetDefined names err) =
655− paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
655+ paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map showIdent names) ++ ":"
656 , indent $ go err
656 , indent $ go err
657 ]
657 ]
658 go (ErrorUnifyingTypes t1 t2 err) =
658 go (ErrorUnifyingTypes t1 t2 err) =
@@ -668,7 +668,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
668 , go err
668 , go err
669 ]
669 ]
670 go (ErrorInModule mn err) =
670 go (ErrorInModule mn err) =
671− paras [ lineWithLevel $ "in module " ++ show mn ++ ":"
671+ paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
672 , go err
672 , go err
673 ]
673 ]
674 go (ErrorInSubsumption t1 t2 err) =
674 go (ErrorInSubsumption t1 t2 err) =
@@ -679,7 +679,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
679 , go err
679 , go err
680 ]
680 ]
681 go (ErrorInInstance name ts err) =
681 go (ErrorInInstance name ts err) =
682− paras [ lineWithLevel $ "in type class instance " ++ show name ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
682+ paras [ lineWithLevel $ "in type class instance " ++ showQualified runProperName name ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
683 , go err
683 , go err
684 ]
684 ]
685 go (ErrorCheckingKind ty err) =
685 go (ErrorCheckingKind ty err) =
@@ -709,15 +709,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
709 , go err
709 , go err
710 ]
710 ]
711 go (ErrorInDataConstructor nm err) =
711 go (ErrorInDataConstructor nm err) =
712− paras [ lineWithLevel $ "in data constructor " ++ show nm ++ ":"
712+ paras [ lineWithLevel $ "in data constructor " ++ runProperName nm ++ ":"
713 , go err
713 , go err
714 ]
714 ]
715 go (ErrorInTypeConstructor nm err) =
715 go (ErrorInTypeConstructor nm err) =
716− paras [ lineWithLevel $ "in type constructor " ++ show nm ++ ":"
716+ paras [ lineWithLevel $ "in type constructor " ++ runProperName nm ++ ":"
717 , go err
717 , go err
718 ]
718 ]
719 go (ErrorInBindingGroup nms err) =
719 go (ErrorInBindingGroup nms err) =
720− paras [ lineWithLevel $ "in binding group " ++ intercalate ", " (map show nms) ++ ":"
720+ paras [ lineWithLevel $ "in binding group " ++ intercalate ", " (map showIdent nms) ++ ":"
721 , go err
721 , go err
722 ]
722 ]
723 go (ErrorInDataBindingGroup err) =
723 go (ErrorInDataBindingGroup err) =
@@ -725,15 +725,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
725 , go err
725 , go err
726 ]
726 ]
727 go (ErrorInTypeSynonym name err) =
727 go (ErrorInTypeSynonym name err) =
728− paras [ lineWithLevel $ "in type synonym " ++ show name ++ ":"
728+ paras [ lineWithLevel $ "in type synonym " ++ runProperName name ++ ":"
729 , go err
729 , go err
730 ]
730 ]
731 go (ErrorInValueDeclaration n err) =
731 go (ErrorInValueDeclaration n err) =
732− paras [ lineWithLevel $ "in value declaration " ++ show n ++ ":"
732+ paras [ lineWithLevel $ "in value declaration " ++ showIdent n ++ ":"
733 , go err
733 , go err
734 ]
734 ]
735 go (ErrorInForeignImport nm err) =
735 go (ErrorInForeignImport nm err) =
736− paras [ lineWithLevel $ "in foreign import " ++ show nm ++ ":"
736+ paras [ lineWithLevel $ "in foreign import " ++ showIdent nm ++ ":"
737 , go err
737 , go err
738 ]
738 ]
739 go (PositionedError srcSpan err) =
739 go (PositionedError srcSpan err) =
@@ -753,8 +753,8 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
753 suggestions :: ErrorMessage -> [Box.Box]
753 suggestions :: ErrorMessage -> [Box.Box]
754 suggestions = suggestions' . unwrapErrorMessage
754 suggestions = suggestions' . unwrapErrorMessage
755 where
755 where
756− suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ show im ++ ":"
756+ suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ runModuleName im ++ ":"
757− , indent . line $ "import " ++ show im ++ " hiding (" ++ nm ++ ")"
757+ , indent . line $ "import " ++ runModuleName im ++ " hiding (" ++ nm ++ ")"
758 ]
758 ]
759 suggestions' (TypesDoNotUnify t1 t2)
759 suggestions' (TypesDoNotUnify t1 t2)
760 | isObject t1 && isFunction t2 = [line "Note that function composition in PureScript is defined using (<<<)"]
760 | isObject t1 && isFunction t2 = [line "Note that function composition in PureScript is defined using (<<<)"]
@@ -768,11 +768,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
768 -- Pretty print and export declaration
768 -- Pretty print and export declaration
769 --
769 --
770 prettyPrintExport :: DeclarationRef -> String
770 prettyPrintExport :: DeclarationRef -> String
771− prettyPrintExport (TypeRef pn _) = show pn
771+ prettyPrintExport (TypeRef pn _) = runProperName pn
772− prettyPrintExport (ValueRef ident) = show ident
772+ prettyPrintExport (ValueRef ident) = showIdent ident
773− prettyPrintExport (TypeClassRef pn) = show pn
773+ prettyPrintExport (TypeClassRef pn) = runProperName pn
774− prettyPrintExport (TypeInstanceRef ident) = show ident
774+ prettyPrintExport (TypeInstanceRef ident) = showIdent ident
775− prettyPrintExport (ModuleRef name) = "module " ++ show name
775+ prettyPrintExport (ModuleRef name) = "module " ++ runModuleName name
776 prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
776 prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
777
777
778 -- |
778 -- |
src/Language/PureScript/Kinds.hs+1−1
@@ -49,7 +49,7 @@ data Kind
49 -- |
49 -- |
50 -- Function kinds
50 -- Function kinds
51 --
51 --
52− | FunKind Kind Kind deriving (Show, Eq, Ord, Data, Typeable)
52+ | FunKind Kind Kind deriving (Show, Read, Eq, Ord, Data, Typeable)
53
53
54$(A.deriveJSON A.defaultOptions ''Kind)
54$(A.deriveJSON A.defaultOptions ''Kind)
55
55
src/Language/PureScript/Linter/Exhaustive.hs+1−2
@@ -69,7 +69,7 @@ getConstructors env defmn n = extractConstructors lnte
69 getConsDataName con = qualifyName nm defmn con
69 getConsDataName con = qualifyName nm defmn con
70 where
70 where
71 nm = case getConsInfo con of
71 nm = case getConsInfo con of
72− Nothing -> error $ "ProperName " ++ show con ++ " not in the scope of the current environment in getConsDataName."
72+ Nothing -> error $ "Constructor " ++ showQualified runProperName con ++ " not in the scope of the current environment in getConsDataName."
73 Just (_, pm, _, _) -> pm
73 Just (_, pm, _, _) -> pm
74
74
75 getConsInfo :: (Qualified ProperName) -> Maybe (DataDeclType, ProperName, Type, [Ident])
75 getConsInfo :: (Qualified ProperName) -> Maybe (DataDeclType, ProperName, Type, [Ident])
@@ -280,4 +280,3 @@ checkExhaustiveDecls env mn ds =
280--
280--
281checkExhaustiveModule :: forall m. (Applicative m, MonadWriter MultipleErrors m) => Environment -> Module -> m ()
281checkExhaustiveModule :: forall m. (Applicative m, MonadWriter MultipleErrors m) => Environment -> Module -> m ()
282checkExhaustiveModule env (Module _ _ mn ds _) = censor (onErrorMessages (ErrorInModule mn)) $ checkExhaustiveDecls env mn ds
282checkExhaustiveModule env (Module _ _ mn ds _) = censor (onErrorMessages (ErrorInModule mn)) $ checkExhaustiveDecls env mn ds
283−
src/Language/PureScript/Make.hs+2−2
@@ -86,7 +86,7 @@ import qualified Paths_purescript as Paths
86-- | Progress messages from the make process
86-- | Progress messages from the make process
87data ProgressMessage
87data ProgressMessage
88 = CompilingModule ModuleName
88 = CompilingModule ModuleName
89− deriving (Show, Eq, Ord)
89+ deriving (Show, Read, Eq, Ord)
90
90
91-- | Render a progress message
91-- | Render a progress message
92renderProgressMessage :: ProgressMessage -> String
92renderProgressMessage :: ProgressMessage -> String
@@ -139,7 +139,7 @@ data RebuildPolicy
139 -- | Never rebuild this module
139 -- | Never rebuild this module
140 = RebuildNever
140 = RebuildNever
141 -- | Always rebuild this module
141 -- | Always rebuild this module
142− | RebuildAlways deriving (Show, Eq, Ord)
142+ | RebuildAlways deriving (Show, Read, Eq, Ord)
143
143
144-- |
144-- |
145-- Compiles in "make" mode, compiling each module separately to a js files and an externs file
145-- Compiles in "make" mode, compiling each module separately to a js files and an externs file
src/Language/PureScript/Names.hs+11−17
@@ -36,28 +36,25 @@ data Ident
36 -- |
36 -- |
37 -- A symbolic name for an infix operator
37 -- A symbolic name for an infix operator
38 --
38 --
39− | Op String deriving (Eq, Ord, Data, Typeable)
39+ | Op String deriving (Show, Read, Eq, Ord, Data, Typeable)
40
40
41runIdent :: Ident -> String
41runIdent :: Ident -> String
42runIdent (Ident i) = i
42runIdent (Ident i) = i
43runIdent (Op op) = op
43runIdent (Op op) = op
44
44
45−instance Show Ident where
45+showIdent :: Ident -> String
46− show (Ident s) = s
46+showIdent (Ident i) = i
47− show (Op op) = '(':op ++ ")"
47+showIdent (Op op) = '(' : op ++ ")"
48
48
49-- |
49-- |
50-- Proper names, i.e. capitalized names for e.g. module names, type//data constructors.
50-- Proper names, i.e. capitalized names for e.g. module names, type//data constructors.
51--
51--
52−newtype ProperName = ProperName { runProperName :: String } deriving (Eq, Ord, Data, Typeable)
52+newtype ProperName = ProperName { runProperName :: String } deriving (Show, Read, Eq, Ord, Data, Typeable)
53−
54−instance Show ProperName where
55− show = runProperName
56
53
57-- |
54-- |
58-- Module names
55-- Module names
59--
56--
60−data ModuleName = ModuleName [ProperName] deriving (Eq, Ord, Data, Typeable)
57+data ModuleName = ModuleName [ProperName] deriving (Show, Read, Eq, Ord, Data, Typeable)
61
58
62runModuleName :: ModuleName -> String
59runModuleName :: ModuleName -> String
63runModuleName (ModuleName pns) = intercalate "." (runProperName `map` pns)
60runModuleName (ModuleName pns) = intercalate "." (runProperName `map` pns)
@@ -70,20 +67,17 @@ moduleNameFromString = ModuleName . splitProperNames
70 s' -> ProperName w : splitProperNames s''
67 s' -> ProperName w : splitProperNames s''
71 where (w, s'') = break (== '.') s'
68 where (w, s'') = break (== '.') s'
72
69
73−instance Show ModuleName where
74− show = runModuleName
75−
76-- |
70-- |
77-- A qualified name, i.e. a name with an optional module name
71-- A qualified name, i.e. a name with an optional module name
78--
72--
79−data Qualified a = Qualified (Maybe ModuleName) a deriving (Eq, Ord, Data, Typeable, Functor)
73+data Qualified a = Qualified (Maybe ModuleName) a deriving (Show, Read, Eq, Ord, Data, Typeable, Functor)
80
74
81−instance (Show a) => Show (Qualified a) where
75+showQualified :: (a -> String) -> Qualified a -> String
82− show (Qualified Nothing a) = show a
76+showQualified f (Qualified Nothing a) = f a
83− show (Qualified (Just name) a) = show name ++ "." ++ show a
77+showQualified f (Qualified (Just name) a) = runModuleName name ++ "." ++ f a
84
78
85instance (a ~ ProperName) => A.ToJSON (Qualified a) where
79instance (a ~ ProperName) => A.ToJSON (Qualified a) where
86− toJSON = A.toJSON . show
80+ toJSON = A.toJSON . showQualified runProperName
87
81
88instance (a ~ ProperName) => A.FromJSON (Qualified a) where
82instance (a ~ ProperName) => A.FromJSON (Qualified a) where
89 parseJSON =
83 parseJSON =
src/Language/PureScript/Parser/Lexer.hs+4−4
@@ -115,7 +115,7 @@ data Token
115 | CharLiteral Char
115 | CharLiteral Char
116 | StringLiteral String
116 | StringLiteral String
117 | Number (Either Integer Double)
117 | Number (Either Integer Double)
118− deriving (Show, Eq, Ord)
118+ deriving (Show, Read, Eq, Ord)
119
119
120prettyPrintToken :: Token -> String
120prettyPrintToken :: Token -> String
121prettyPrintToken LParen = "("
121prettyPrintToken LParen = "("
@@ -153,8 +153,9 @@ data PositionedToken = PositionedToken
153 , ptComments :: [Comment]
153 , ptComments :: [Comment]
154 } deriving (Eq)
154 } deriving (Eq)
155
155
156+-- Parsec requires this instance for various token-level combinators
156instance Show PositionedToken where
157instance Show PositionedToken where
157− show = show . ptToken
158+ show = prettyPrintToken . ptToken
158
159
159lex :: FilePath -> String -> Either P.ParseError [PositionedToken]
160lex :: FilePath -> String -> Either P.ParseError [PositionedToken]
160lex filePath input = P.parse parseTokens filePath input
161lex filePath input = P.parse parseTokens filePath input
@@ -251,7 +252,7 @@ parseToken = P.choice
251 where
252 where
252 -- lookAhead doesn't consume any input if its parser succeeds
253 -- lookAhead doesn't consume any input if its parser succeeds
253 -- if notFollowedBy fails though, the consumed '0' will break the choice chain
254 -- if notFollowedBy fails though, the consumed '0' will break the choice chain
254− consumeLeadingZero = P.lookAhead (P.char '0' >>
255+ consumeLeadingZero = P.lookAhead (P.char '0' >>
255 (P.notFollowedBy P.digit P.<?> "no leading zero in number literal"))
256 (P.notFollowedBy P.digit P.<?> "no leading zero in number literal"))
256
257
257-- |
258-- |
@@ -517,4 +518,3 @@ reservedTypeNames = [ "forall", "where" ]
517--
518--
518opChars :: [Char]
519opChars :: [Char]
519opChars = ":!#$%&*+./<=>?@\\^|-~"
520opChars = ":!#$%&*+./<=>?@\\^|-~"
520−
src/Language/PureScript/Pretty/Common.hs+1−1
@@ -25,7 +25,7 @@ import Language.PureScript.Parser.Lexer (reservedPsNames, opChars)
25parens :: String -> String
25parens :: String -> String
26parens s = ('(':s) ++ ")"
26parens s = ('(':s) ++ ")"
27
27
28−newtype PrinterState = PrinterState { indent :: Int } deriving (Show, Eq, Ord)
28+newtype PrinterState = PrinterState { indent :: Int } deriving (Show, Read, Eq, Ord)
29
29
30-- |
30-- |
31-- Number of characters per identation level
31-- Number of characters per identation level
src/Language/PureScript/Pretty/Types.hs+4−4
@@ -26,6 +26,7 @@ import Control.Arrow ((<+>))
26import Control.PatternArrows
26import Control.PatternArrows
27
27
28import Language.PureScript.Types
28import Language.PureScript.Types
29+import Language.PureScript.Names
29import Language.PureScript.Kinds
30import Language.PureScript.Kinds
30import Language.PureScript.Pretty.Common
31import Language.PureScript.Pretty.Common
31import Language.PureScript.Pretty.Kinds
32import Language.PureScript.Pretty.Kinds
@@ -37,11 +38,11 @@ typeLiterals = mkPattern match
37 match TypeWildcard = Just "_"
38 match TypeWildcard = Just "_"
38 match (TypeVar var) = Just var
39 match (TypeVar var) = Just var
39 match (PrettyPrintObject row) = Just $ "{ " ++ prettyPrintRow row ++ " }"
40 match (PrettyPrintObject row) = Just $ "{ " ++ prettyPrintRow row ++ " }"
40− match (TypeConstructor ctor) = Just $ show ctor
41+ match (TypeConstructor ctor) = Just $ showQualified runProperName ctor
41 match (TUnknown u) = Just $ '_' : show u
42 match (TUnknown u) = Just $ '_' : show u
42 match (Skolem name s _) = Just $ name ++ show s
43 match (Skolem name s _) = Just $ name ++ show s
43− match (ConstrainedType deps ty) = Just $ "(" ++ intercalate ", " (map (\(pn, ty') -> show pn ++ " " ++ unwords (map prettyPrintTypeAtom ty')) deps) ++ ") => " ++ prettyPrintType ty
44+ match (ConstrainedType deps ty) = Just $ "(" ++ intercalate ", " (map (\(pn, ty') -> showQualified runProperName pn ++ " " ++ unwords (map prettyPrintTypeAtom ty')) deps) ++ ") => " ++ prettyPrintType ty
44− match (SaturatedTypeSynonym name args) = Just $ show name ++ "<" ++ intercalate "," (map prettyPrintTypeAtom args) ++ ">"
45+ match (SaturatedTypeSynonym name args) = Just $ showQualified runProperName name ++ "<" ++ intercalate "," (map prettyPrintTypeAtom args) ++ ">"
45 match REmpty = Just "()"
46 match REmpty = Just "()"
46 match row@RCons{} = Just $ '(' : prettyPrintRow row ++ ")"
47 match row@RCons{} = Just $ '(' : prettyPrintRow row ++ ")"
47 match _ = Nothing
48 match _ = Nothing
@@ -124,4 +125,3 @@ prettyPrintTypeAtom = fromMaybe (error "Incomplete pattern") . pattern matchType
124--
125--
125prettyPrintType :: Type -> String
126prettyPrintType :: Type -> String
126prettyPrintType = fromMaybe (error "Incomplete pattern") . pattern matchType () . insertPlaceholders
127prettyPrintType = fromMaybe (error "Incomplete pattern") . pattern matchType () . insertPlaceholders
127−
src/Language/PureScript/Pretty/Values.hs+16−16
@@ -50,11 +50,11 @@ literals = mkPattern' match
50 match (ObjectConstructor ps) = prettyPrintObject' ps
50 match (ObjectConstructor ps) = prettyPrintObject' ps
51 match (ObjectGetter prop) = return $ "(." ++ prop ++ ")"
51 match (ObjectGetter prop) = return $ "(." ++ prop ++ ")"
52 match (TypeClassDictionaryConstructorApp className ps) = concat <$> sequence
52 match (TypeClassDictionaryConstructorApp className ps) = concat <$> sequence
53− [ return (show className ++ "(\n")
53+ [ return (showQualified runProperName className ++ "(\n")
54 , match ps
54 , match ps
55 , return ")"
55 , return ")"
56 ]
56 ]
57− match (Constructor name) = return $ show name
57+ match (Constructor name) = return $ showQualified runProperName name
58 match (Case values binders) = concat <$> sequence
58 match (Case values binders) = concat <$> sequence
59 [ return "case "
59 [ return "case "
60 , unwords <$> forM values prettyPrintValue'
60 , unwords <$> forM values prettyPrintValue'
@@ -70,7 +70,7 @@ literals = mkPattern' match
70 , return "in "
70 , return "in "
71 , prettyPrintValue' val
71 , prettyPrintValue' val
72 ]
72 ]
73− match (Var ident) = return $ show ident
73+ match (Var ident) = return $ showQualified showIdent ident
74 match (Do els) = concat <$> sequence
74 match (Do els) = concat <$> sequence
75 [ return "do\n"
75 [ return "do\n"
76 , withIndent $ prettyPrintMany prettyPrintDoNotationElement els
76 , withIndent $ prettyPrintMany prettyPrintDoNotationElement els
@@ -78,16 +78,16 @@ literals = mkPattern' match
78 ]
78 ]
79 match (OperatorSection op (Right val)) = return $ "(" ++ prettyPrintValue op ++ " " ++ prettyPrintValue val ++ ")"
79 match (OperatorSection op (Right val)) = return $ "(" ++ prettyPrintValue op ++ " " ++ prettyPrintValue val ++ ")"
80 match (OperatorSection op (Left val)) = return $ "(" ++ prettyPrintValue val ++ " " ++ prettyPrintValue op ++ ")"
80 match (OperatorSection op (Left val)) = return $ "(" ++ prettyPrintValue val ++ " " ++ prettyPrintValue op ++ ")"
81− match (TypeClassDictionary (name, tys) _) = return $ "<<dict " ++ show name ++ " " ++ unwords (map prettyPrintTypeAtom tys) ++ ">>"
81+ match (TypeClassDictionary (name, tys) _) = return $ "<<dict " ++ showQualified runProperName name ++ " " ++ unwords (map prettyPrintTypeAtom tys) ++ ">>"
82− match (SuperClassDictionary name _) = return $ "<<superclass dict " ++ show name ++ ">>"
82+ match (SuperClassDictionary name _) = return $ "<<superclass dict " ++ showQualified runProperName name ++ ">>"
83 match (TypedValue _ val _) = prettyPrintValue' val
83 match (TypedValue _ val _) = prettyPrintValue' val
84 match (PositionedValue _ _ val) = prettyPrintValue' val
84 match (PositionedValue _ _ val) = prettyPrintValue' val
85 match _ = mzero
85 match _ = mzero
86
86
87prettyPrintDeclaration :: Declaration -> StateT PrinterState Maybe String
87prettyPrintDeclaration :: Declaration -> StateT PrinterState Maybe String
88−prettyPrintDeclaration (TypeDeclaration ident ty) = return $ show ident ++ " :: " ++ prettyPrintType ty
88+prettyPrintDeclaration (TypeDeclaration ident ty) = return $ showIdent ident ++ " :: " ++ prettyPrintType ty
89prettyPrintDeclaration (ValueDeclaration ident _ [] (Right val)) = concat <$> sequence
89prettyPrintDeclaration (ValueDeclaration ident _ [] (Right val)) = concat <$> sequence
90− [ return $ show ident ++ " = "
90+ [ return $ showIdent ident ++ " = "
91 , prettyPrintValue' val
91 , prettyPrintValue' val
92 ]
92 ]
93prettyPrintDeclaration (PositionedDeclaration _ _ d) = prettyPrintDeclaration d
93prettyPrintDeclaration (PositionedDeclaration _ _ d) = prettyPrintDeclaration d
@@ -165,7 +165,7 @@ app = mkPattern match
165lam :: Pattern PrinterState Expr (String, Expr)
165lam :: Pattern PrinterState Expr (String, Expr)
166lam = mkPattern match
166lam = mkPattern match
167 where
167 where
168− match (Abs (Left arg) val) = Just (show arg, val)
168+ match (Abs (Left arg) val) = Just (showIdent arg, val)
169 match _ = Nothing
169 match _ = Nothing
170
170
171-- |
171-- |
@@ -195,20 +195,20 @@ prettyPrintBinderAtom (CharBinder c) = show c
195prettyPrintBinderAtom (NumberBinder num) = either show show num
195prettyPrintBinderAtom (NumberBinder num) = either show show num
196prettyPrintBinderAtom (BooleanBinder True) = "true"
196prettyPrintBinderAtom (BooleanBinder True) = "true"
197prettyPrintBinderAtom (BooleanBinder False) = "false"
197prettyPrintBinderAtom (BooleanBinder False) = "false"
198−prettyPrintBinderAtom (VarBinder ident) = show ident
198+prettyPrintBinderAtom (VarBinder ident) = showIdent ident
199−prettyPrintBinderAtom (ConstructorBinder ctor []) = show ctor
199+prettyPrintBinderAtom (ConstructorBinder ctor []) = showQualified runProperName ctor
200−prettyPrintBinderAtom (ObjectBinder bs) =
200+prettyPrintBinderAtom (ObjectBinder bs) =
201− "{ "
201+ "{ "
202 ++ intercalate ", " (map prettyPrintObjectPropertyBinder bs)
202 ++ intercalate ", " (map prettyPrintObjectPropertyBinder bs)
203 ++ " }"
203 ++ " }"
204 where
204 where
205 prettyPrintObjectPropertyBinder :: (String, Binder) -> String
205 prettyPrintObjectPropertyBinder :: (String, Binder) -> String
206 prettyPrintObjectPropertyBinder (key, binder) = prettyPrintObjectKey key ++ ": " ++ prettyPrintBinder binder
206 prettyPrintObjectPropertyBinder (key, binder) = prettyPrintObjectKey key ++ ": " ++ prettyPrintBinder binder
207prettyPrintBinderAtom (ArrayBinder bs) =
207prettyPrintBinderAtom (ArrayBinder bs) =
208− "[ "
208+ "[ "
209 ++ intercalate ", " (map prettyPrintBinder bs)
209 ++ intercalate ", " (map prettyPrintBinder bs)
210 ++ " ]"
210 ++ " ]"
211−prettyPrintBinderAtom (NamedBinder ident binder) = show ident ++ "@" ++ prettyPrintBinder binder
211+prettyPrintBinderAtom (NamedBinder ident binder) = showIdent ident ++ "@" ++ prettyPrintBinder binder
212prettyPrintBinderAtom (PositionedBinder _ _ binder) = prettyPrintBinderAtom binder
212prettyPrintBinderAtom (PositionedBinder _ _ binder) = prettyPrintBinderAtom binder
213prettyPrintBinderAtom b = parens (prettyPrintBinder b)
213prettyPrintBinderAtom b = parens (prettyPrintBinder b)
214
214
@@ -216,7 +216,7 @@ prettyPrintBinderAtom b = parens (prettyPrintBinder b)
216-- Generate a pretty-printed string representing a Binder
216-- Generate a pretty-printed string representing a Binder
217--
217--
218prettyPrintBinder :: Binder -> String
218prettyPrintBinder :: Binder -> String
219−prettyPrintBinder (ConstructorBinder ctor []) = show ctor
219+prettyPrintBinder (ConstructorBinder ctor []) = showQualified runProperName ctor
220−prettyPrintBinder (ConstructorBinder ctor args) = show ctor ++ " " ++ unwords (map prettyPrintBinderAtom args)
220+prettyPrintBinder (ConstructorBinder ctor args) = showQualified runProperName ctor ++ " " ++ unwords (map prettyPrintBinderAtom args)
221prettyPrintBinder (PositionedBinder _ _ binder) = prettyPrintBinder binder
221prettyPrintBinder (PositionedBinder _ _ binder) = prettyPrintBinder binder
222prettyPrintBinder b = prettyPrintBinderAtom b
222prettyPrintBinder b = prettyPrintBinderAtom b
src/Language/PureScript/Publish.hs+2−2
@@ -147,7 +147,7 @@ getModulesAndBookmarks = do
147 renderModules bookmarks modules =
147 renderModules bookmarks modules =
148 return (bookmarks, map D.convertModule modules)
148 return (bookmarks, map D.convertModule modules)
149
149
150−data TreeStatus = Clean | Dirty deriving (Show, Eq, Ord, Enum)
150+data TreeStatus = Clean | Dirty deriving (Show, Read, Eq, Ord, Enum)
151
151
152getGitWorkingTreeStatus :: PrepareM TreeStatus
152getGitWorkingTreeStatus :: PrepareM TreeStatus
153getGitWorkingTreeStatus = do
153getGitWorkingTreeStatus = do
@@ -228,7 +228,7 @@ data DependencyStatus
228 | ResolvedVersion String
228 | ResolvedVersion String
229 -- ^ Resolved to a version. The String argument is the resolution tag (eg,
229 -- ^ Resolved to a version. The String argument is the resolution tag (eg,
230 -- "v0.1.0").
230 -- "v0.1.0").
231− deriving (Show, Eq)
231+ deriving (Show, Read, Eq)
232
232
233-- Go through all bower dependencies which contain purescript code, and
233-- Go through all bower dependencies which contain purescript code, and
234-- extract their versions.
234-- extract their versions.
src/Language/PureScript/Publish/ErrorsWarnings.hs+1−1
@@ -204,7 +204,7 @@ displayUserError e = case e of
204 ParseAndDesugarError (D.ParseError err) ->
204 ParseAndDesugarError (D.ParseError err) ->
205 vcat
205 vcat
206 [ para "Parse error:"
206 [ para "Parse error:"
207− , indented (para (show err))
207+ , indented (P.prettyPrintMultipleErrorsBox False err)
208 ]
208 ]
209 ParseAndDesugarError (D.SortModulesError err) ->
209 ParseAndDesugarError (D.SortModulesError err) ->
210 vcat
210 vcat
src/Language/PureScript/Renamer.hs+2−2
@@ -100,7 +100,7 @@ lookupIdent name = do
100 name' <- gets $ M.lookup name . rsBoundNames
100 name' <- gets $ M.lookup name . rsBoundNames
101 case name' of
101 case name' of
102 Just name'' -> return name''
102 Just name'' -> return name''
103− Nothing -> error $ "Rename scope is missing ident '" ++ show name ++ "'"
103+ Nothing -> error $ "Rename scope is missing ident '" ++ showIdent name ++ "'"
104
104
105-- |
105-- |
106-- Finds idents introduced by declarations.
106-- Finds idents introduced by declarations.
@@ -119,7 +119,7 @@ renameInModules = map go
119 where
119 where
120 go :: Module Ann -> Module Ann
120 go :: Module Ann -> Module Ann
121 go m@(Module _ _ _ _ _ decls) = m { moduleDecls = map (renameInDecl' (findDeclIdents decls)) decls }
121 go m@(Module _ _ _ _ _ decls) = m { moduleDecls = map (renameInDecl' (findDeclIdents decls)) decls }
122−
122+
123 renameInDecl' :: [Ident] -> Bind Ann -> Bind Ann
123 renameInDecl' :: [Ident] -> Bind Ann -> Bind Ann
124 renameInDecl' scope = runRename scope . renameInDecl True
124 renameInDecl' scope = runRename scope . renameInDecl True
125
125
src/Language/PureScript/Sugar/Names.hs+6−6
@@ -208,12 +208,12 @@ renameInModule env imports (Module ss coms mn decls exps) =
208 -- Update names so unqualified references become qualified, and locally
208 -- Update names so unqualified references become qualified, and locally
209 -- qualified references are replaced with their canoncial qualified names
209 -- qualified references are replaced with their canoncial qualified names
210 -- (e.g. M.Map -> Data.Map.Map).
210 -- (e.g. M.Map -> Data.Map.Map).
211− update :: (Ord a, Show a) => (Qualified a -> SimpleErrorMessage)
211+ update :: (Ord a) => (Qualified a -> SimpleErrorMessage)
212− -> M.Map (Qualified a) (Qualified a, ModuleName)
212+ -> M.Map (Qualified a) (Qualified a, ModuleName)
213− -> (Exports -> a -> Maybe (Qualified a))
213+ -> (Exports -> a -> Maybe (Qualified a))
214− -> Qualified a
214+ -> Qualified a
215− -> Maybe SourceSpan
215+ -> Maybe SourceSpan
216− -> m (Qualified a)
216+ -> m (Qualified a)
217 update unknown imps getE qname@(Qualified mn' name) pos = positioned $
217 update unknown imps getE qname@(Qualified mn' name) pos = positioned $
218 case (M.lookup qname imps, mn') of
218 case (M.lookup qname imps, mn') of
219 -- We found the name in our imports, so we return the name for it,
219 -- We found the name in our imports, so we return the name for it,
src/Language/PureScript/Sugar/Names/Env.hs+4−4
@@ -67,7 +67,7 @@ data Imports = Imports
67 -- The list of modules that have been imported into the current scope.
67 -- The list of modules that have been imported into the current scope.
68 --
68 --
69 , importedModules :: [ModuleName]
69 , importedModules :: [ModuleName]
70− } deriving (Show)
70+ } deriving (Show, Read)
71
71
72-- |
72-- |
73-- An empty 'Imports' value.
73-- An empty 'Imports' value.
@@ -95,7 +95,7 @@ data Exports = Exports
95 -- came from.
95 -- came from.
96 --
96 --
97 , exportedValues :: [(Ident, ModuleName)]
97 , exportedValues :: [(Ident, ModuleName)]
98− } deriving (Show)
98+ } deriving (Show, Read)
99
99
100-- |
100-- |
101-- An empty 'Exports' value.
101-- An empty 'Exports' value.
@@ -184,7 +184,7 @@ exportValue exps name mn = do
184-- Adds an entry to a list of exports unless it is already present, in which case an error is
184-- Adds an entry to a list of exports unless it is already present, in which case an error is
185-- returned.
185-- returned.
186--
186--
187−addExport :: (MonadError MultipleErrors m, Eq a, Show a) => (a -> SimpleErrorMessage) -> a -> ModuleName -> [(a, ModuleName)] -> m [(a, ModuleName)]
187+addExport :: (MonadError MultipleErrors m, Eq a) => (a -> SimpleErrorMessage) -> a -> ModuleName -> [(a, ModuleName)] -> m [(a, ModuleName)]
188addExport what name mn exports =
188addExport what name mn exports =
189 if any ((== name) . fst) exports
189 if any ((== name) . fst) exports
190 then throwConflictError what name
190 then throwConflictError what name
@@ -193,5 +193,5 @@ addExport what name mn exports =
193-- |
193-- |
194-- Raises an error for when there is more than one definition for something.
194-- Raises an error for when there is more than one definition for something.
195--
195--
196−throwConflictError :: (MonadError MultipleErrors m, Show a) => (a -> SimpleErrorMessage) -> a -> m b
196+throwConflictError :: (MonadError MultipleErrors m) => (a -> SimpleErrorMessage) -> a -> m b
197throwConflictError conflict = throwError . errorMessage . conflict
197throwConflictError conflict = throwError . errorMessage . conflict
src/Language/PureScript/Sugar/Names/Imports.hs+13−12
@@ -111,7 +111,7 @@ resolveImport currentModule importModule exps imps impQual =
111 check _ = error "Invalid argument to checkRefs"
111 check _ = error "Invalid argument to checkRefs"
112
112
113 -- Check that an explicitly imported item exists in the module it is being imported from
113 -- Check that an explicitly imported item exists in the module it is being imported from
114− checkImportExists :: (Eq a, Show a) => (ModuleName -> a -> SimpleErrorMessage) -> [a] -> a -> m ()
114+ checkImportExists :: (Eq a) => (ModuleName -> a -> SimpleErrorMessage) -> [a] -> a -> m ()
115 checkImportExists unknown exports item =
115 checkImportExists unknown exports item =
116 when (item `notElem` exports) $ throwError . errorMessage $ unknown importModule item
116 when (item `notElem` exports) $ throwError . errorMessage $ unknown importModule item
117
117
@@ -149,20 +149,20 @@ resolveImport currentModule importModule exps imps impQual =
149 importExplicit imp (PositionedDeclarationRef pos _ r) =
149 importExplicit imp (PositionedDeclarationRef pos _ r) =
150 rethrowWithPosition pos . warnWithPosition pos $ importExplicit imp r
150 rethrowWithPosition pos . warnWithPosition pos $ importExplicit imp r
151 importExplicit imp (ValueRef name) = do
151 importExplicit imp (ValueRef name) = do
152− values' <- updateImports (importedValues imp) (exportedValues exps) name
152+ values' <- updateImports (importedValues imp) showIdent (exportedValues exps) name
153 return $ imp { importedValues = values' }
153 return $ imp { importedValues = values' }
154 importExplicit imp (TypeRef name dctors) = do
154 importExplicit imp (TypeRef name dctors) = do
155− types' <- updateImports (importedTypes imp) (first fst `map` exportedTypes exps) name
155+ types' <- updateImports (importedTypes imp) runProperName (first fst `map` exportedTypes exps) name
156 let exportedDctors :: [(ProperName, ModuleName)]
156 let exportedDctors :: [(ProperName, ModuleName)]
157 exportedDctors = allExportedDataConstructors name
157 exportedDctors = allExportedDataConstructors name
158 dctorNames :: [ProperName]
158 dctorNames :: [ProperName]
159 dctorNames = fst `map` exportedDctors
159 dctorNames = fst `map` exportedDctors
160 maybe (return ()) (mapM_ $ checkDctorExists name dctorNames) dctors
160 maybe (return ()) (mapM_ $ checkDctorExists name dctorNames) dctors
161 when (null dctorNames && isNothing dctors) . tell . errorMessage $ MisleadingEmptyTypeImport importModule name
161 when (null dctorNames && isNothing dctors) . tell . errorMessage $ MisleadingEmptyTypeImport importModule name
162− dctors' <- foldM (flip updateImports exportedDctors) (importedDataConstructors imp) (fromMaybe dctorNames dctors)
162+ dctors' <- foldM (\m -> updateImports m runProperName exportedDctors) (importedDataConstructors imp) (fromMaybe dctorNames dctors)
163 return $ imp { importedTypes = types', importedDataConstructors = dctors' }
163 return $ imp { importedTypes = types', importedDataConstructors = dctors' }
164 importExplicit imp (TypeClassRef name) = do
164 importExplicit imp (TypeClassRef name) = do
165− typeClasses' <- updateImports (importedTypeClasses imp) (exportedTypeClasses exps) name
165+ typeClasses' <- updateImports (importedTypeClasses imp) runProperName (exportedTypeClasses exps) name
166 return $ imp { importedTypeClasses = typeClasses' }
166 return $ imp { importedTypeClasses = typeClasses' }
167 importExplicit _ _ = error "Invalid argument to importExplicit"
167 importExplicit _ _ = error "Invalid argument to importExplicit"
168
168
@@ -174,11 +174,12 @@ resolveImport currentModule importModule exps imps impQual =
174 Just ((_, dctors), mn) -> map (, mn) dctors
174 Just ((_, dctors), mn) -> map (, mn) dctors
175
175
176 -- Add something to the Imports if it does not already exist there
176 -- Add something to the Imports if it does not already exist there
177− updateImports :: (Ord a, Show a) => M.Map (Qualified a) (Qualified a, ModuleName)
177+ updateImports :: (Ord a) => M.Map (Qualified a) (Qualified a, ModuleName)
178+ -> (a -> String)
178− -> [(a, ModuleName)]
179+ -> [(a, ModuleName)]
179− -> a
180+ -> a
180− -> m (M.Map (Qualified a) (Qualified a, ModuleName))
181+ -> m (M.Map (Qualified a) (Qualified a, ModuleName))
181− updateImports imps' exps' name = case M.lookup (Qualified impQual name) imps' of
182+ updateImports imps' render exps' name = case M.lookup (Qualified impQual name) imps' of
182
183
183 -- If the name is not already present add it to the list, after looking up
184 -- If the name is not already present add it to the list, after looking up
184 -- where it was originally defined
185 -- where it was originally defined
@@ -195,8 +196,8 @@ resolveImport currentModule importModule exps imps impQual =
195 | otherwise -> throwError . errorMessage $ err
196 | otherwise -> throwError . errorMessage $ err
196 where
197 where
197 err = if currentModule `elem` [mn, importModule]
198 err = if currentModule `elem` [mn, importModule]
198− then ConflictingImport (show name) importModule
199+ then ConflictingImport (render name) importModule
199− else ConflictingImports (show name) mn importModule
200+ else ConflictingImports (render name) mn importModule
200
201
201 Just (Qualified Nothing _, _) ->
202 Just (Qualified Nothing _, _) ->
202 error "Invalid state in updateImports"
203 error "Invalid state in updateImports"
src/Language/PureScript/Sugar/Operators.hs+2−2
@@ -131,8 +131,8 @@ toAssoc Infixl = P.AssocLeft
131toAssoc Infixr = P.AssocRight
131toAssoc Infixr = P.AssocRight
132toAssoc Infix = P.AssocNone
132toAssoc Infix = P.AssocNone
133
133
134−token :: (P.Stream s Identity t, Show t) => (t -> Maybe a) -> P.Parsec s u a
134+token :: (P.Stream s Identity t) => (t -> Maybe a) -> P.Parsec s u a
135−token = P.token show (const (P.initialPos ""))
135+token = P.token (const "") (const (P.initialPos ""))
136
136
137parseValue :: P.Parsec Chain () Expr
137parseValue :: P.Parsec Chain () Expr
138parseValue = token (either Just (const Nothing)) P.<?> "expression"
138parseValue = token (either Just (const Nothing)) P.<?> "expression"
src/Language/PureScript/Sugar/TypeClasses.hs+2−2
@@ -292,10 +292,10 @@ typeClassMemberName :: Declaration -> String
292typeClassMemberName (TypeDeclaration ident _) = runIdent ident
292typeClassMemberName (TypeDeclaration ident _) = runIdent ident
293typeClassMemberName (ValueDeclaration ident _ _ _) = runIdent ident
293typeClassMemberName (ValueDeclaration ident _ _ _) = runIdent ident
294typeClassMemberName (PositionedDeclaration _ _ d) = typeClassMemberName d
294typeClassMemberName (PositionedDeclaration _ _ d) = typeClassMemberName d
295−typeClassMemberName d = error $ "Invalid declaration in type class definition: " ++ show d
295+typeClassMemberName d = error "typeClassMemberName: Invalid declaration in type class definition"
296
296
297superClassDictionaryNames :: [Constraint] -> [String]
297superClassDictionaryNames :: [Constraint] -> [String]
298superClassDictionaryNames supers =
298superClassDictionaryNames supers =
299− [ C.__superclass_ ++ show pn ++ "_" ++ show (index :: Integer)
299+ [ C.__superclass_ ++ showQualified runProperName pn ++ "_" ++ show (index :: Integer)
300 | (index, (pn, _)) <- zip [0..] supers
300 | (index, (pn, _)) <- zip [0..] supers
301 ]
301 ]
src/Language/PureScript/TypeChecker/Entailment.hs+1−1
@@ -122,7 +122,7 @@ entails env moduleName context = solve
122 dictionaryValueToValue (GlobalDictionaryValue fnName) = Var fnName
122 dictionaryValueToValue (GlobalDictionaryValue fnName) = Var fnName
123 dictionaryValueToValue (DependentDictionaryValue fnName dicts) = foldl App (Var fnName) (map dictionaryValueToValue dicts)
123 dictionaryValueToValue (DependentDictionaryValue fnName dicts) = foldl App (Var fnName) (map dictionaryValueToValue dicts)
124 dictionaryValueToValue (SubclassDictionaryValue dict superclassName index) =
124 dictionaryValueToValue (SubclassDictionaryValue dict superclassName index) =
125− App (Accessor (C.__superclass_ ++ show superclassName ++ "_" ++ show index)
125+ App (Accessor (C.__superclass_ ++ showQualified runProperName superclassName ++ "_" ++ show index)
126 (dictionaryValueToValue dict))
126 (dictionaryValueToValue dict))
127 valUndefined
127 valUndefined
128 -- Ensure that a substitution is valid
128 -- Ensure that a substitution is valid
src/Language/PureScript/TypeClassDictionaries.hs+3−3
@@ -38,7 +38,7 @@ data TypeClassDictionaryInScope
38 , tcdDependencies :: Maybe [Constraint]
38 , tcdDependencies :: Maybe [Constraint]
39 -- | The type of this dictionary
39 -- | The type of this dictionary
40 , tcdType :: TypeClassDictionaryType
40 , tcdType :: TypeClassDictionaryType
41− } deriving (Show, Data, Typeable)
41+ } deriving (Show, Read, Data, Typeable)
42
42
43-- |
43-- |
44-- The type of a type class dictionary
44-- The type of a type class dictionary
@@ -51,7 +51,7 @@ data TypeClassDictionaryType
51 -- |
51 -- |
52 -- A type class dictionary which is an alias for an imported dictionary from another module
52 -- A type class dictionary which is an alias for an imported dictionary from another module
53 --
53 --
54− | TCDAlias (Qualified Ident) deriving (Show, Eq, Data, Typeable)
54+ | TCDAlias (Qualified Ident) deriving (Show, Read, Eq, Data, Typeable)
55
55
56-- |
56-- |
57-- A simplified representation of expressions which are used to represent type
57-- A simplified representation of expressions which are used to represent type
@@ -74,7 +74,7 @@ data DictionaryValue
74 -- A subclass dictionary
74 -- A subclass dictionary
75 --
75 --
76 | SubclassDictionaryValue DictionaryValue (Qualified ProperName) Integer
76 | SubclassDictionaryValue DictionaryValue (Qualified ProperName) Integer
77− deriving (Show, Ord, Eq)
77+ deriving (Show, Read, Ord, Eq)
78
78
79-- |
79-- |
80-- Find the original dictionary which a type class dictionary in scope refers to
80-- Find the original dictionary which a type class dictionary in scope refers to
src/Language/PureScript/Types.hs+2−2
@@ -39,7 +39,7 @@ import Language.PureScript.Traversals
39-- |
39-- |
40-- An identifier for the scope of a skolem variable
40-- An identifier for the scope of a skolem variable
41--
41--
42−newtype SkolemScope = SkolemScope { runSkolemScope :: Int } deriving (Show, Eq, Ord, Data, Typeable, A.ToJSON, A.FromJSON)
42+newtype SkolemScope = SkolemScope { runSkolemScope :: Int } deriving (Show, Read, Eq, Ord, Data, Typeable, A.ToJSON, A.FromJSON)
43
43
44-- |
44-- |
45-- The type of types
45-- The type of types
@@ -105,7 +105,7 @@ data Type
105 -- |
105 -- |
106 -- A placeholder used in pretty printing
106 -- A placeholder used in pretty printing
107 --
107 --
108− | PrettyPrintForAll [String] Type deriving (Show, Eq, Ord, Data, Typeable)
108+ | PrettyPrintForAll [String] Type deriving (Show, Read,Eq, Ord, Data, Typeable)
109
109
110-- |
110-- |
111-- A typeclass constraint
111-- A typeclass constraint