git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Only use Show for debugging.
commit1376700f1d061045c287cc57db19929ab94bdac6 authorPhil Freeman <paf31@cantab.net> dateFri 11 Sep 2015, 14:52 (11 years ago) parente0e0ea6
42 files changed+258−261
psc-docs/Main.hs+4−4 psc-publish/tests/Test.hs+1−1 psci/Completion.hs+11−11 src/Language/PureScript/AST/Binders.hs+1−1 src/Language/PureScript/AST/Declarations.hs+8−8 src/Language/PureScript/AST/Operators.hs+7−7 src/Language/PureScript/AST/SourcePos.hs+2−2 src/Language/PureScript/Bundle.hs+11−7 src/Language/PureScript/CodeGen/Externs.hs+19−19 src/Language/PureScript/CodeGen/JS.hs+3−3 src/Language/PureScript/CodeGen/JS/AST.hs+3−3 src/Language/PureScript/Comments.hs+1−1 src/Language/PureScript/CoreFn/Binders.hs+1−1 src/Language/PureScript/CoreFn/Expr.hs+3−3 src/Language/PureScript/CoreFn/Literals.hs+1−1 src/Language/PureScript/CoreFn/Meta.hs+2−2 src/Language/PureScript/CoreFn/Module.hs+1−1 src/Language/PureScript/Docs/AsMarkdown.hs+1−1 src/Language/PureScript/Docs/Convert.hs+11−12 src/Language/PureScript/Docs/Render.hs+1−1 src/Language/PureScript/Docs/RenderedCode/Render.hs+1−1 src/Language/PureScript/Environment.hs+9−9 src/Language/PureScript/Errors.hs+78−78 src/Language/PureScript/Kinds.hs+1−1 src/Language/PureScript/Linter/Exhaustive.hs+1−2 src/Language/PureScript/Make.hs+2−2 src/Language/PureScript/Names.hs+11−17 src/Language/PureScript/Parser/Lexer.hs+4−4 src/Language/PureScript/Pretty/Common.hs+1−1 src/Language/PureScript/Pretty/Types.hs+4−4 src/Language/PureScript/Pretty/Values.hs+16−16 src/Language/PureScript/Publish.hs+2−2 src/Language/PureScript/Publish/ErrorsWarnings.hs+1−1 src/Language/PureScript/Renamer.hs+2−2 src/Language/PureScript/Sugar/Names.hs+6−6 src/Language/PureScript/Sugar/Names/Env.hs+4−4 src/Language/PureScript/Sugar/Names/Imports.hs+13−12 src/Language/PureScript/Sugar/Operators.hs+2−2 src/Language/PureScript/Sugar/TypeClasses.hs+2−2 src/Language/PureScript/TypeChecker/Entailment.hs+1−1 src/Language/PureScript/TypeClassDictionaries.hs+3−3 src/Language/PureScript/Types.hs+2−2
psc-docs/Main.hs+4−4
@@ -152,10 +152,10 @@ inputFile = strArgument $
152152 <> help "The input .purs file(s)"
153153
154154instance Read Format where
155− readsPrec _ "etags" = [(Etags, "")]
156− readsPrec _ "ctags" = [(Ctags, "")]
157− readsPrec _ "markdown" = [(Markdown, "")]
158− readsPrec _ _ = []
155+ readsPrec _ "etags" = [(Etags, "")]
156+ readsPrec _ "ctags" = [(Ctags, "")]
157+ readsPrec _ "markdown" = [(Markdown, "")]
158+ readsPrec _ _ = []
159159
160160format :: Parser Format
161161format = option auto $ value Markdown
psc-publish/tests/Test.hs+1−1
@@ -60,7 +60,7 @@ data TestResult
6060 = ParseFailed String
6161 | Mismatch ByteString ByteString -- ^ encoding before, encoding after
6262 | Pass ByteString
63− deriving (Show)
63+ deriving (Show, Read)
6464
6565-- | Test JSON encoding/decoding; parse the package, roundtrip to/from JSON,
6666-- and check we get the same string.
psci/Completion.hs+11−11
@@ -41,7 +41,7 @@ data CompletionContext
4141 | CtxIdentifier
4242 | CtxType
4343 | CtxFixed String
44− deriving (Show)
44+ deriving (Show, Read)
4545
4646-- |
4747-- Loads module, function, and file completions.
@@ -143,34 +143,34 @@ getImportedModules = asks psciImportedModules
143143getModuleNames :: CompletionM [String]
144144getModuleNames = moduleNames <$> getLoadedModules
145145
146−mapLoadedModulesAndQualify :: (Show a) => (P.Module -> [(a, P.Declaration)]) -> CompletionM [String]
147−mapLoadedModulesAndQualify f = do
146+mapLoadedModulesAndQualify :: (a -> String) -> (P.Module -> [(a, P.Declaration)]) -> CompletionM [String]
147+mapLoadedModulesAndQualify sho f = do
148148 ms <- getLoadedModules
149149 let argPairs = do m <- ms
150150 fm <- f m
151151 return (m, fm)
152− concat <$> traverse (uncurry getAllQualifications) argPairs
152+ concat <$> traverse (uncurry (getAllQualifications sho)) argPairs
153153
154154getIdentNames :: CompletionM [String]
155−getIdentNames = mapLoadedModulesAndQualify identNames
155+getIdentNames = mapLoadedModulesAndQualify P.showIdent identNames
156156
157157getDctorNames :: CompletionM [String]
158−getDctorNames = mapLoadedModulesAndQualify dctorNames
158+getDctorNames = mapLoadedModulesAndQualify P.runProperName dctorNames
159159
160160getTypeNames :: CompletionM [String]
161−getTypeNames = mapLoadedModulesAndQualify typeDecls
161+getTypeNames = mapLoadedModulesAndQualify P.runProperName typeDecls
162162
163163-- | Given a module and a declaration in that module, return all possible ways
164164-- it could have been referenced given the current PSCiState - including fully
165165-- qualified, qualified using an alias, and unqualified.
166−getAllQualifications :: (Show a) => P.Module -> (a, P.Declaration) -> CompletionM [String]
167−getAllQualifications m (declName, decl) = do
166+getAllQualifications :: (a -> String) -> P.Module -> (a, P.Declaration) -> CompletionM [String]
167+getAllQualifications sho m (declName, decl) = do
168168 imports <- getAllImportsOf m
169169 let fullyQualified = qualifyWith (Just (P.getModuleName m))
170170 let otherQuals = nub (concatMap qualificationsUsing imports)
171171 return $ fullyQualified : otherQuals
172172 where
173− qualifyWith mMod = show (P.Qualified mMod declName)
173+ qualifyWith mMod = P.showQualified sho (P.Qualified mMod declName)
174174 referencedBy refs = P.isExported (Just refs) decl
175175
176176 qualificationsUsing (_, importType, asQ') =
@@ -222,7 +222,7 @@ dctorNames = nubOnFst . concatMap go . P.exportedDeclarations
222222 go _ = []
223223
224224moduleNames :: [P.Module] -> [String]
225−moduleNames ms = nub [show moduleName | P.Module _ _ moduleName _ _ <- ms]
225+moduleNames ms = nub [P.runModuleName moduleName | P.Module _ _ moduleName _ _ <- ms]
226226
227227directivesFirst :: Completion -> Completion -> Ordering
228228directivesFirst (Completion _ d1 _) (Completion _ d2 _) = go d1 d2
src/Language/PureScript/AST/Binders.hs+1−1
@@ -69,7 +69,7 @@ data Binder
6969 -- |
7070 -- A binder with source position information
7171 --
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)
7373
7474-- |
7575-- 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
4242-- a list of declarations, and a list of the declarations that are
4343-- explicitly exported. If the export list is Nothing, everything is exported.
4444--
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)
4646
4747-- | Return a module's name.
4848getModuleName :: Module -> ModuleName
@@ -76,7 +76,7 @@ data DeclarationRef
7676 -- A declaration reference with source position information
7777 --
7878 | PositionedDeclarationRef SourceSpan [Comment] DeclarationRef
79− deriving (Show, D.Data, D.Typeable)
79+ deriving (Show, Read, D.Data, D.Typeable)
8080
8181instance Eq DeclarationRef where
8282 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
@@ -108,7 +108,7 @@ data ImportDeclarationType
108108 -- An import with a list of references to hide: `import M hiding (foo)`
109109 --
110110 | Hiding [DeclarationRef]
111− deriving (Show, D.Data, D.Typeable)
111+ deriving (Show, Read, D.Data, D.Typeable)
112112
113113-- |
114114-- The data type of declarations
@@ -171,7 +171,7 @@ data Declaration
171171 -- A declaration with source position information
172172 --
173173 | PositionedDeclaration SourceSpan [Comment] Declaration
174− deriving (Show, D.Data, D.Typeable)
174+ deriving (Show, Read, D.Data, D.Typeable)
175175
176176-- | The members of a type class instance declaration
177177data TypeInstanceBody
@@ -179,7 +179,7 @@ data TypeInstanceBody
179179 = DerivedInstance
180180 -- | This is a regular (explicit) instance
181181 | ExplicitInstance [Declaration]
182− deriving (Show, D.Data, D.Typeable)
182+ deriving (Show, Read, D.Data, D.Typeable)
183183
184184mapTypeInstanceBody :: ([Declaration] -> [Declaration]) -> TypeInstanceBody -> TypeInstanceBody
185185mapTypeInstanceBody f = runIdentity . traverseTypeInstanceBody (Identity . f)
@@ -406,7 +406,7 @@ data Expr
406406 -- |
407407 -- A value with source position information
408408 --
409− | PositionedValue SourceSpan [Comment] Expr deriving (Show, D.Data, D.Typeable)
409+ | PositionedValue SourceSpan [Comment] Expr deriving (Show, Read, D.Data, D.Typeable)
410410
411411-- |
412412-- An alternative in a case statement
@@ -420,7 +420,7 @@ data CaseAlternative = CaseAlternative
420420 -- The result expression or a collect of guarded expressions
421421 --
422422 , caseAlternativeResult :: Either [(Guard, Expr)] Expr
423− } deriving (Show, D.Data, D.Typeable)
423+ } deriving (Show, Read, D.Data, D.Typeable)
424424
425425-- |
426426-- A statement in a do-notation block
@@ -441,4 +441,4 @@ data DoNotationElement
441441 -- |
442442 -- A do notation element with source position information
443443 --
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
2929-- |
3030-- Associativity for infix operators
3131--
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)
3333
34−instance Show Associativity where
35− show Infixl = "infixl"
36− show Infixr = "infixr"
37− show Infix = "infix"
34+showAssoc :: Associativity -> String
35+showAssoc Infixl = "infixl"
36+showAssoc Infixr = "infixr"
37+showAssoc Infix = "infix"
3838
3939instance A.ToJSON Associativity where
40− toJSON = A.toJSON . show
40+ toJSON = A.toJSON . showAssoc
4141
4242-- |
4343-- Fixity data for infix operators
4444--
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)
4646
4747instance A.ToJSON Fixity where
4848 toJSON (Fixity associativity precedence) =
src/Language/PureScript/AST/SourcePos.hs+2−2
@@ -35,7 +35,7 @@ data SourcePos = SourcePos
3535 -- Column number
3636 --
3737 , sourcePosColumn :: Int
38− } deriving (Eq, Ord, Show, D.Data, D.Typeable)
38+ } deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
3939
4040displaySourcePos :: SourcePos -> String
4141displaySourcePos sp =
@@ -58,7 +58,7 @@ data SourceSpan = SourceSpan
5858 -- End of the span
5959 --
6060 , spanEnd :: SourcePos
61− } deriving (Eq, Ord, Show, D.Data, D.Typeable)
61+ } deriving (Show, Read, Eq, Ord, D.Data, D.Typeable)
6262
6363displayStartEndPos :: SourceSpan -> String
6464displayStartEndPos sp =
src/Language/PureScript/Bundle.hs+11−7
@@ -56,16 +56,20 @@ data ErrorMessage
5656 | UnableToParseModule String
5757 | UnsupportedExport
5858 | ErrorInModule ModuleIdentifier ErrorMessage
59− deriving Show
59+ deriving (Show, Read)
6060
6161-- | Modules are either "regular modules" (i.e. those generated by psc) or foreign modules.
6262data ModuleType
6363 = Regular
6464 | 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"
6670
6771-- | 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)
6973
7074moduleName :: ModuleIdentifier -> String
7175moduleName (ModuleIdentifier name _) = name
@@ -81,7 +85,7 @@ type Key = (ModuleIdentifier, String)
8185data ExportType
8286 = RegularExport String
8387 | ForeignReexport
84− deriving (Show, Eq, Ord)
88+ deriving (Show, Read, Eq, Ord)
8589
8690-- | There are four types of module element we are interested in:
8791--
@@ -97,10 +101,10 @@ data ModuleElement
97101 | Member JSNode Bool String [JSNode] [Key]
98102 | ExportsList [(ExportType, String, JSNode, [Key])]
99103 | Other JSNode
100− deriving Show
104+ deriving (Show, Read)
101105
102106-- | 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)
104108
105109-- | Prepare an error message for consumption by humans.
106110printErrorMessage :: ErrorMessage -> [String]
@@ -127,7 +131,7 @@ printErrorMessage (ErrorInModule mid e) =
127131 : map (" " ++) (printErrorMessage e)
128132 where
129133 displayIdentifier (ModuleIdentifier name ty) =
130− name ++ " (" ++ show ty ++ ")"
134+ name ++ " (" ++ showModuleType ty ++ ")"
131135
132136-- | Unpack the node inside a JSNode. This is useful when pattern matching.
133137node :: JSNode -> Node
src/Language/PureScript/CodeGen/Externs.hs+19−19
@@ -49,22 +49,22 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
4949
5050 listRef :: DeclarationRef -> Maybe String
5151 listRef (PositionedDeclarationRef _ _ d) = listRef d
52− listRef (TypeRef name Nothing) = Just $ show name ++ "()"
53− listRef (TypeRef name (Just dctors)) = Just $ show name ++ "(" ++ intercalate ", " (map show dctors) ++ ")"
54− listRef (ValueRef name) = Just $ show name
55− listRef (TypeClassRef name) = Just $ show name
56− listRef (ModuleRef name) = Just $ "module " ++ show name
52+ listRef (TypeRef name Nothing) = Just $ runProperName name ++ "()"
53+ listRef (TypeRef name (Just dctors)) = Just $ runProperName name ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
54+ listRef (ValueRef name) = Just $ showIdent name
55+ listRef (TypeClassRef name) = Just $ runProperName name
56+ listRef (ModuleRef name) = Just $ "module " ++ runModuleName name
5757 listRef _ = Nothing
5858
5959 declToPs :: Declaration -> Writer [String] ()
6060 declToPs (ImportDeclaration mn imp Nothing) =
61− tell ["import " ++ show mn ++ importToPs imp]
61+ tell ["import " ++ runModuleName mn ++ importToPs imp]
6262 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]
6464 declToPs (FixityDeclaration (Fixity assoc prec) op) =
6565 case find exportsOp exts of
6666 Nothing -> return ()
67− Just _ -> tell [ unwords [ show assoc, show prec, op ] ]
67+ Just _ -> tell [ unwords [ showAssoc assoc, show prec, op ] ]
6868 where
6969 exportsOp :: DeclarationRef -> Bool
7070 exportsOp (PositionedDeclarationRef _ _ r) = exportsOp r
@@ -86,14 +86,14 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
8686 exportToPs (PositionedDeclarationRef _ _ r) = exportToPs r
8787 exportToPs (TypeRef pn dctors) =
8888 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"
9090 Just (kind, ExternData) ->
91− tell ["foreign import data " ++ show pn ++ " :: " ++ prettyPrintKind kind]
91+ tell ["foreign import data " ++ runProperName pn ++ " :: " ++ prettyPrintKind kind]
9292 Just (_, DataType args tys) -> do
9393 let dctors' = fromMaybe (map fst tys) dctors
9494 printDctor dctor = case dctor `lookup` tys of
9595 Nothing -> Nothing
96− Just tyArgs -> Just $ show dctor ++ " " ++ unwords (map prettyPrintTypeAtom tyArgs)
96+ Just tyArgs -> Just $ runProperName dctor ++ " " ++ unwords (map prettyPrintTypeAtom tyArgs)
9797 let dtype = if length dctors' == 1 && isNewtypeConstructor env (Qualified (Just moduleName) $ head dctors')
9898 then "newtype"
9999 else "data"
@@ -101,7 +101,7 @@ moduleToPs (Module _ _ moduleName ds (Just exts)) env = intercalate "\n" . execW
101101 tell [dtype ++ " " ++ typeName ++ (if null dctors' then "" else " = " ++ intercalate " | " (mapMaybe printDctor dctors'))]
102102 Just (_, TypeSynonym) ->
103103 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"
105105 Just (args, synTy) ->
106106 let
107107 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
110110
111111 exportToPs (ValueRef ident) =
112112 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"
114114 Just (ty, nk, _) | nk == Public || nk == External ->
115− tell ["foreign import " ++ show ident ++ " :: " ++ prettyPrintType ty]
115+ tell ["foreign import " ++ showIdent ident ++ " :: " ++ prettyPrintType ty]
116116 _ -> return ()
117117 exportToPs (TypeClassRef className) =
118118 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"
120120 Just (args, members, implies) -> do
121121 let impliesString = if null implies
122122 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) ++ ") <= "
124124 typeName = prettyPrintType $ foldl TypeApp (TypeConstructor (Qualified Nothing className)) (map toTypeVar args)
125125 tell ["class " ++ impliesString ++ typeName ++ " where"]
126126 forM_ (filter (isValueExported . fst) members) $ \(member ,ty) ->
127− tell [ " " ++ show member ++ " :: " ++ prettyPrintType ty ]
127+ tell [ " " ++ showIdent member ++ " :: " ++ prettyPrintType ty ]
128128
129129 exportToPs (TypeInstanceRef ident) = do
130130 let TypeClassDictionaryInScope { tcdClassName = className, tcdInstanceTypes = tys, tcdDependencies = deps} =
131131 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
132132 let constraintsText = case fromMaybe [] deps of
133133 [] -> ""
134− cs -> "(" ++ intercalate ", " (map (\(pn, tys') -> show pn ++ " " ++ unwords (map prettyPrintTypeAtom tys')) cs) ++ ") => "
135− tell ["foreign import instance " ++ show ident ++ " :: " ++ constraintsText ++ show className ++ " " ++ unwords (map prettyPrintTypeAtom tys)]
134+ cs -> "(" ++ intercalate ", " (map (\(pn, tys') -> showQualified runProperName pn ++ " " ++ unwords (map prettyPrintTypeAtom tys')) cs) ++ ") => "
135+ tell ["foreign import instance " ++ showIdent ident ++ " :: " ++ constraintsText ++ showQualified runProperName className ++ " " ++ unwords (map prettyPrintTypeAtom tys)]
136136
137137 exportToPs (ModuleRef _) = return ()
138138
src/Language/PureScript/CodeGen/JS.hs+3−3
@@ -172,7 +172,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ = do
172172 then foreignIdent ident
173173 else varToJs qi
174174 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
176176 valueToJs (Var _ ident) =
177177 return $ varToJs ident
178178 valueToJs (Case (maybeSpan, _, _, _) values binders) = do
@@ -320,8 +320,8 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ = do
320320 done'' <- go remain done'
321321 js <- binderToJs argVar done'' binder
322322 return (JSVariableIntroduction argVar (Just (JSAccessor (identToJs field) (JSVar varName))) : js)
323− binderToJs _ _ b@(ConstructorBinder{}) =
324− error $ "Invalid ConstructorBinder in binderToJs: " ++ show b
323+ binderToJs _ _ ConstructorBinder{} =
324+ error "binderToJs: Invalid ConstructorBinder in binderToJs"
325325 binderToJs varName done (NamedBinder _ ident binder) = do
326326 js <- binderToJs varName done binder
327327 return (JSVariableIntroduction (identToJs ident) (Just (JSVar varName)) : js)
src/Language/PureScript/CodeGen/JS/AST.hs+3−3
@@ -53,7 +53,7 @@ data UnaryOperator
5353 -- |
5454 -- Constructor
5555 --
56− | JSNew deriving (Show, Eq, Data, Typeable)
56+ | JSNew deriving (Show, Read, Eq, Data, Typeable)
5757
5858-- |
5959-- Built-in binary operators
@@ -134,7 +134,7 @@ data BinaryOperator
134134 -- |
135135 -- Bitwise right shift with zero-fill
136136 --
137− | ZeroFillShiftRight deriving (Show, Eq, Data, Typeable)
137+ | ZeroFillShiftRight deriving (Show, Read, Eq, Data, Typeable)
138138
139139-- |
140140-- Data type for simplified Javascript expressions
@@ -255,7 +255,7 @@ data JS
255255 -- |
256256 -- Commented Javascript
257257 --
258− | JSComment [Comment] JS deriving (Show, Eq, Data, Typeable)
258+ | JSComment [Comment] JS deriving (Show, Read, Eq, Data, Typeable)
259259
260260--
261261-- Traversals
src/Language/PureScript/Comments.hs+1−1
@@ -22,4 +22,4 @@ import qualified Data.Data as D
2222data Comment
2323 = LineComment String
2424 | 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
4545 -- |
4646 -- A binder which binds its input to an identifier
4747 --
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
6464 -- |
6565 -- A let binding
6666 --
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)
6868
6969-- |
7070-- A let or module binding.
@@ -77,7 +77,7 @@ data Bind a
7777 -- |
7878 -- Mutually recursive binding group for several values
7979 --
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)
8181
8282-- |
8383-- A guard is just a boolean-valued expression that appears alongside a set of binders
@@ -96,7 +96,7 @@ data CaseAlternative a = CaseAlternative
9696 -- The result expression or a collect of guarded expressions
9797 --
9898 , caseAlternativeResult :: Either [(Guard a, Expr a)] (Expr a)
99− } deriving (Show, D.Data, D.Typeable)
99+ } deriving (Show, Read, D.Data, D.Typeable)
100100
101101instance Functor CaseAlternative where
102102
src/Language/PureScript/CoreFn/Literals.hs+1−1
@@ -47,4 +47,4 @@ data Literal a
4747 -- |
4848 -- An object literal
4949 --
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
3939 -- |
4040 -- The contained reference is for a foreign member
4141 --
42− | IsForeign deriving (Show, D.Data, D.Typeable)
42+ | IsForeign deriving (Show, Read, D.Data, D.Typeable)
4343
4444-- |
4545-- Data constructor metadata
@@ -52,4 +52,4 @@ data ConstructorType
5252 -- |
5353 -- The constructor is for a type with multiple construcors
5454 --
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
2626 , moduleExports :: [Ident]
2727 , moduleForeign :: [ForeignDecl]
2828 , moduleDecls :: [Bind a]
29− } deriving (Show)
29+ } deriving (Show, Read)
3030
3131type ForeignDecl = (Ident, Type)
src/Language/PureScript/Docs/AsMarkdown.hs+1−1
@@ -98,7 +98,7 @@ childToString f decl@ChildDeclaration{..} =
9898data First
9999 = First
100100 | NotFirst
101− deriving (Show, Eq, Ord)
101+ deriving (Show, Read, Eq, Ord)
102102
103103type Docs = Writer [String] ()
104104
src/Language/PureScript/Docs/Convert.hs+11−12
@@ -26,7 +26,7 @@ import Language.PureScript.Docs.Types
2626--
2727convertModule :: P.Module -> Module
2828convertModule m@(P.Module _ coms moduleName _ _) =
29− Module (show moduleName) comments (declarations m)
29+ Module (P.runModuleName moduleName) comments (declarations m)
3030 where
3131 comments = convertComments coms
3232 declarations =
@@ -106,13 +106,13 @@ addDefaultFixity decl@Declaration{..}
106106 defaultFixity = P.Fixity P.Infixl (-1)
107107
108108getDeclarationTitle :: P.Declaration -> Maybe String
109−getDeclarationTitle (P.TypeDeclaration name _) = Just (show name)
110−getDeclarationTitle (P.ExternDeclaration name _) = Just (show name)
111−getDeclarationTitle (P.DataDeclaration _ name _ _) = Just (show name)
112−getDeclarationTitle (P.ExternDataDeclaration name _) = Just (show name)
113−getDeclarationTitle (P.TypeSynonymDeclaration name _ _) = Just (show name)
114−getDeclarationTitle (P.TypeClassDeclaration name _ _ _) = Just (show name)
115−getDeclarationTitle (P.TypeInstanceDeclaration name _ _ _ _) = Just (show name)
109+getDeclarationTitle (P.TypeDeclaration name _) = Just (P.showIdent name)
110+getDeclarationTitle (P.ExternDeclaration name _) = Just (P.showIdent name)
111+getDeclarationTitle (P.DataDeclaration _ name _ _) = Just (P.runProperName name)
112+getDeclarationTitle (P.ExternDataDeclaration name _) = Just (P.runProperName name)
113+getDeclarationTitle (P.TypeSynonymDeclaration name _ _) = Just (P.runProperName name)
114+getDeclarationTitle (P.TypeClassDeclaration name _ _ _) = Just (P.runProperName name)
115+getDeclarationTitle (P.TypeInstanceDeclaration name _ _ _ _) = Just (P.showIdent name)
116116getDeclarationTitle (P.FixityDeclaration _ name) = Just ("(" ++ name ++ ")")
117117getDeclarationTitle (P.PositionedDeclaration _ _ d) = getDeclarationTitle d
118118getDeclarationTitle _ = Nothing
@@ -142,7 +142,7 @@ convertDeclaration (P.DataDeclaration dtype _ args ctors) title =
142142 info = DataDeclaration dtype args
143143 children = map convertCtor ctors
144144 convertCtor (ctor', tys) =
145− ChildDeclaration (show ctor') Nothing Nothing (ChildDataConstructor tys)
145+ ChildDeclaration (P.runProperName ctor') Nothing Nothing (ChildDataConstructor tys)
146146convertDeclaration (P.ExternDataDeclaration _ kind') title =
147147 basicDeclaration title (ExternDataDeclaration kind')
148148convertDeclaration (P.TypeSynonymDeclaration _ args ty) title =
@@ -155,7 +155,7 @@ convertDeclaration (P.TypeClassDeclaration _ args implies ds) title = do
155155 convertClassMember (P.PositionedDeclaration _ _ d) =
156156 convertClassMember d
157157 convertClassMember (P.TypeDeclaration ident' ty) =
158− ChildDeclaration (show ident') Nothing Nothing (ChildTypeClassMember ty)
158+ ChildDeclaration (P.showIdent ident') Nothing Nothing (ChildTypeClassMember ty)
159159 convertClassMember _ =
160160 error "Invalid argument to convertClassMember."
161161convertDeclaration (P.TypeInstanceDeclaration _ constraints className tys _) title = do
@@ -163,7 +163,7 @@ convertDeclaration (P.TypeInstanceDeclaration _ constraints className tys _) tit
163163 where
164164 classNameString = unQual className
165165 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
167167
168168 extractProperNames (P.TypeConstructor n) = [unQual n]
169169 extractProperNames (P.SaturatedTypeSynonym n _) = [unQual n]
@@ -225,4 +225,3 @@ collectBookmarks' m =
225225 map (P.getModuleName m, )
226226 (mapMaybe getDeclarationTitle
227227 (P.exportedDeclarations m))
228−
src/Language/PureScript/Docs/Render.hs+1−1
@@ -29,7 +29,7 @@ renderDeclarationWithOptions opts Declaration{..} =
2929 , renderType' ty
3030 ]
3131 DataDeclaration dtype args ->
32− [ keyword (show dtype)
32+ [ keyword (P.showDataDeclType dtype)
3333 , renderType' (typeApp declTitle args)
3434 ]
3535 ExternDataDeclaration kind' ->
src/Language/PureScript/Docs/RenderedCode/Render.hs+1−1
@@ -45,7 +45,7 @@ typeLiterals = mkPattern match
4545 , syntax "}"
4646 ]
4747 match (TypeConstructor (Qualified mn name)) =
48− Just (ctor (show name) (maybeToContainingModule mn))
48+ Just (ctor (runProperName name) (maybeToContainingModule mn))
4949 match (ConstrainedType deps ty) =
5050 Just $ mintersperse sp
5151 [ syntax "(" <> constraints <> syntax ")"
src/Language/PureScript/Environment.hs+9−9
@@ -57,7 +57,7 @@ data Environment = Environment {
5757 -- Type classes
5858 --
5959 , typeClasses :: M.Map (Qualified ProperName) ([(String, Maybe Kind)], [(Ident, Type)], [Constraint])
60− } deriving (Show)
60+ } deriving (Show, Read)
6161
6262-- |
6363-- The initial environment with no values and only the default javascript types defined
@@ -76,7 +76,7 @@ data NameVisibility
7676 -- |
7777 -- The name is defined in the another binding group, or has been made visible by a function binder
7878 --
79− | Defined deriving (Show, Eq)
79+ | Defined deriving (Show, Read, Eq)
8080
8181-- |
8282-- A flag for whether a name is for an private or public value - only public values will be
@@ -95,7 +95,7 @@ data NameKind
9595 -- |
9696 -- A name for member introduced by foreign import
9797 --
98− | External deriving (Show, Eq, Data, Typeable)
98+ | External deriving (Show, Read, Eq, Data, Typeable)
9999
100100-- |
101101-- The kinds of a type
@@ -121,7 +121,7 @@ data TypeKind
121121 -- A scoped type variable
122122 --
123123 | ScopedTypeVar
124− deriving (Show, Eq, Data, Typeable)
124+ deriving (Show, Read, Eq, Data, Typeable)
125125
126126-- |
127127-- The type ('data' or 'newtype') of a data type declaration
@@ -134,14 +134,14 @@ data DataDeclType
134134 -- |
135135 -- A newtype constructor
136136 --
137− | Newtype deriving (Eq, Ord, Data, Typeable)
137+ | Newtype deriving (Show, Read, Eq, Ord, Data, Typeable)
138138
139−instance Show DataDeclType where
140− show Data = "data"
141− show Newtype = "newtype"
139+showDataDeclType :: DataDeclType -> String
140+showDataDeclType Data = "data"
141+showDataDeclType Newtype = "newtype"
142142
143143instance A.ToJSON DataDeclType where
144− toJSON = A.toJSON . show
144+ toJSON = A.toJSON . showDataDeclType
145145
146146instance A.FromJSON DataDeclType where
147147 parseJSON = A.withText "DataDeclType" $ \str ->
src/Language/PureScript/Errors.hs+78−78
@@ -309,7 +309,7 @@ onErrorMessages :: (ErrorMessage -> ErrorMessage) -> MultipleErrors -> MultipleE
309309onErrorMessages f = MultipleErrors . map f . runMultipleErrors
310310
311311-- | 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)
313313
314314-- | A map from rigid type variable name/unknown variable pairs to new variables.
315315type UnknownMap = M.Map (LabelType, Unknown) Unknown
@@ -430,13 +430,13 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
430430 , indent . prettyPrintParseError $ err
431431 ]
432432 goSimple (MissingFFIModule mn) =
433− line $ "Missing FFI implementations for module " ++ show mn
433+ line $ "Missing FFI implementations for module " ++ runModuleName mn
434434 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 ++ ": "
436436 , indent . line $ path
437437 ]
438438 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 ++ ": " ]
440440 ++ map (indent . line) paths
441441 goSimple (InvalidExternsFile path) =
442442 paras [ line "Externs file is invalid: "
@@ -461,80 +461,80 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
461461 , indent $ line $ prettyPrintKind ki
462462 ]
463463 goSimple (MultipleFixities name) =
464− line $ "Multiple fixity declarations for " ++ show name
464+ line $ "Multiple fixity declarations for " ++ showIdent name
465465 goSimple (OrphanTypeDeclaration nm) =
466− line $ "Orphan type declaration for " ++ show nm
466+ line $ "Orphan type declaration for " ++ showIdent nm
467467 goSimple (OrphanFixityDeclaration op) =
468468 line $ "Orphan fixity declaration for " ++ show op
469469 goSimple (RedefinedModule name filenames) =
470− paras $ [ line $ "Module " ++ show name ++ " has been defined multiple times:"
471− ] ++ map (indent . line . displaySourceSpan) filenames
470+ paras $ line ("Module " ++ runModuleName name ++ " has been defined multiple times:")
471+ : map (indent . line . displaySourceSpan) filenames
472472 goSimple (RedefinedIdent name) =
473− line $ "Name " ++ show name ++ " has been defined multiple times"
473+ line $ "Name " ++ showIdent name ++ " has been defined multiple times"
474474 goSimple (UnknownModule mn) =
475− line $ "Unknown module " ++ show mn
475+ line $ "Unknown module " ++ runModuleName mn
476476 goSimple (UnknownType name) =
477− line $ "Unknown type " ++ show name
477+ line $ "Unknown type " ++ showQualified runProperName name
478478 goSimple (UnknownTypeClass name) =
479− line $ "Unknown type class " ++ show name
479+ line $ "Unknown type class " ++ showQualified runProperName name
480480 goSimple (UnknownValue name) =
481− line $ "Unknown value " ++ show name
481+ line $ "Unknown value " ++ showQualified showIdent name
482482 goSimple (UnknownTypeConstructor name) =
483− line $ "Unknown type constructor " ++ show name
483+ line $ "Unknown type constructor " ++ showQualified runProperName name
484484 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
486486 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
488488 goSimple (UnknownExportType name) =
489− line $ "Cannot export unknown type " ++ show name
489+ line $ "Cannot export unknown type " ++ runProperName name
490490 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
492492 goSimple (UnknownExportTypeClass name) =
493− line $ "Cannot export unknown type class " ++ show name
493+ line $ "Cannot export unknown type class " ++ runProperName name
494494 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
496496 goSimple (UnknownExportValue name) =
497− line $ "Cannot export unknown value " ++ show name
497+ line $ "Cannot export unknown value " ++ showIdent name
498498 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"
500500 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
502502 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"
504504 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
506506 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
508508 goSimple (ConflictingTypeDecls nm) =
509− line $ "Conflicting type declarations for " ++ show nm
509+ line $ "Conflicting type declarations for " ++ runProperName nm
510510 goSimple (ConflictingCtorDecls nm) =
511− line $ "Conflicting data constructor declarations for " ++ show nm
511+ line $ "Conflicting data constructor declarations for " ++ runProperName nm
512512 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"
514514 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"
516516 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"
518518 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"
520520 goSimple (DuplicateClassExport nm) =
521− line $ "Duplicate export declaration for type class " ++ show nm
521+ line $ "Duplicate export declaration for type class " ++ runProperName nm
522522 goSimple (DuplicateValueExport nm) =
523− line $ "Duplicate export declaration for value " ++ show nm
523+ line $ "Duplicate export declaration for value " ++ showIdent nm
524524 goSimple (CycleInDeclaration nm) =
525− line $ "Cycle in declaration of " ++ show nm
525+ line $ "Cycle in declaration of " ++ showIdent nm
526526 goSimple (CycleInModules mns) =
527− line $ "Cycle in module dependencies: " ++ intercalate ", " (map show mns)
527+ line $ "Cycle in module dependencies: " ++ intercalate ", " (map runModuleName mns)
528528 goSimple (CycleInTypeSynonym pn) =
529− line $ "Cycle in type synonym" ++ foldMap ((" " ++) . show) pn
529+ line $ "Cycle in type synonym" ++ foldMap ((" " ++) . runProperName) pn
530530 goSimple (NameIsUndefined ident) =
531− line $ show ident ++ " is undefined"
531+ line $ showIdent ident ++ " is undefined"
532532 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"
534534 goSimple (UndefinedTypeVariable name) =
535− line $ "Type variable " ++ show name ++ " is undefined"
535+ line $ "Type variable " ++ runProperName name ++ " is undefined"
536536 goSimple (PartiallyAppliedSynonym name) =
537− paras [ line $ "Partially applied type synonym " ++ show name
537+ paras [ line $ "Partially applied type synonym " ++ showQualified runProperName name
538538 , line "Type synonyms must be applied to all of their type arguments."
539539 ]
540540 goSimple (EscapedSkolem binding) =
@@ -561,18 +561,18 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
561561 , indent $ line $ prettyPrintType t2
562562 ]
563563 goSimple (OverlappingInstances nm ts (d : ds)) =
564− paras [ line $ "Overlapping instances found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
565− , indent $ paras (line (show d ++ " (chosen)") : map (line . show) ds)
564+ paras [ line $ "Overlapping instances found for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
565+ , indent $ paras (line (showQualified showIdent d ++ " (chosen)") : map (line . showQualified showIdent) ds)
566566 ]
567567 goSimple OverlappingInstances{} = error "OverlappingInstances: empty instance list"
568568 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)
570570 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."
572572 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)
574574 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."
576576 goSimple (DuplicateLabel l expr) =
577577 paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
578578 <> foldMap (\expr' -> [ line "Relevant expression: "
@@ -581,22 +581,22 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
581581 goSimple (DuplicateTypeArgument name) =
582582 line $ "Duplicate type argument " ++ show name
583583 goSimple (DuplicateValueDeclaration nm) =
584− line $ "Duplicate value declaration for " ++ show nm
584+ line $ "Duplicate value declaration for " ++ showIdent nm
585585 goSimple (ArgListLengthsDiffer ident) =
586− line $ "Argument list lengths differ in declaration " ++ show ident
586+ line $ "Argument list lengths differ in declaration " ++ showIdent ident
587587 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
589589 goSimple (MissingClassMember ident) =
590− line $ "Member " ++ show ident ++ " has not been implemented"
590+ line $ "Member " ++ showIdent ident ++ " has not been implemented"
591591 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"
593593 goSimple (ExpectedType ty kind) =
594594 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
595595 , line $ "The error arises from the type " ++ prettyPrintType ty ++ " having the kind " ++ prettyPrintKind kind ++ " instead."
596596 ]
597597 goSimple (IncorrectConstructorArity nm) =
598− line $ "Wrong number of arguments to constructor " ++ show nm
599− goSimple SubsumptionCheckFailed = line $ "Unable to check type subsumption"
598+ line $ "Wrong number of arguments to constructor " ++ showQualified runProperName nm
599+ goSimple SubsumptionCheckFailed = line "Unable to check type subsumption"
600600 goSimple (ExprDoesNotHaveType expr ty) =
601601 paras [ line "Expression"
602602 , indent $ line $ prettyPrintValue expr
@@ -614,7 +614,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
614614 goSimple TypeSynonymInstance =
615615 line "Type synonym instances are disallowed"
616616 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."
618618 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
619619 , line "Consider moving the instance, if possible, or using a newtype wrapper."
620620 ]
@@ -625,19 +625,19 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
625625 , indent $ line $ prettyPrintType ty
626626 ]
627627 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: ")
629629 : map (line . prettyPrintExport) ys
630630 goSimple (ShadowedName nm) =
631− line $ "Name '" ++ show nm ++ "' was shadowed."
631+ line $ "Name '" ++ showIdent nm ++ "' was shadowed."
632632 goSimple (ClassOperator className opName) =
633− paras [ line $ "Class '" ++ show className ++ "' declares operator " ++ show 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:"
635− , indent $ line $ show opName ++ " = someMember"
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:"
635+ , indent $ line $ showIdent opName ++ " = someMember"
636636 ]
637637 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"
639639 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"
641641 goSimple (WildcardInferredType ty) =
642642 line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
643643 goSimple (NotExhaustivePattern bs b) =
@@ -652,7 +652,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
652652 ] ++
653653 [ line "..." | not b ]
654654 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) ++ ":"
656656 , indent $ go err
657657 ]
658658 go (ErrorUnifyingTypes t1 t2 err) =
@@ -668,7 +668,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
668668 , go err
669669 ]
670670 go (ErrorInModule mn err) =
671− paras [ lineWithLevel $ "in module " ++ show mn ++ ":"
671+ paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
672672 , go err
673673 ]
674674 go (ErrorInSubsumption t1 t2 err) =
@@ -679,7 +679,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
679679 , go err
680680 ]
681681 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) ++ ":"
683683 , go err
684684 ]
685685 go (ErrorCheckingKind ty err) =
@@ -709,15 +709,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
709709 , go err
710710 ]
711711 go (ErrorInDataConstructor nm err) =
712− paras [ lineWithLevel $ "in data constructor " ++ show nm ++ ":"
712+ paras [ lineWithLevel $ "in data constructor " ++ runProperName nm ++ ":"
713713 , go err
714714 ]
715715 go (ErrorInTypeConstructor nm err) =
716− paras [ lineWithLevel $ "in type constructor " ++ show nm ++ ":"
716+ paras [ lineWithLevel $ "in type constructor " ++ runProperName nm ++ ":"
717717 , go err
718718 ]
719719 go (ErrorInBindingGroup nms err) =
720− paras [ lineWithLevel $ "in binding group " ++ intercalate ", " (map show nms) ++ ":"
720+ paras [ lineWithLevel $ "in binding group " ++ intercalate ", " (map showIdent nms) ++ ":"
721721 , go err
722722 ]
723723 go (ErrorInDataBindingGroup err) =
@@ -725,15 +725,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
725725 , go err
726726 ]
727727 go (ErrorInTypeSynonym name err) =
728− paras [ lineWithLevel $ "in type synonym " ++ show name ++ ":"
728+ paras [ lineWithLevel $ "in type synonym " ++ runProperName name ++ ":"
729729 , go err
730730 ]
731731 go (ErrorInValueDeclaration n err) =
732− paras [ lineWithLevel $ "in value declaration " ++ show n ++ ":"
732+ paras [ lineWithLevel $ "in value declaration " ++ showIdent n ++ ":"
733733 , go err
734734 ]
735735 go (ErrorInForeignImport nm err) =
736− paras [ lineWithLevel $ "in foreign import " ++ show nm ++ ":"
736+ paras [ lineWithLevel $ "in foreign import " ++ showIdent nm ++ ":"
737737 , go err
738738 ]
739739 go (PositionedError srcSpan err) =
@@ -753,8 +753,8 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
753753 suggestions :: ErrorMessage -> [Box.Box]
754754 suggestions = suggestions' . unwrapErrorMessage
755755 where
756− suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ show im ++ ":"
757− , indent . line $ "import " ++ show im ++ " hiding (" ++ nm ++ ")"
756+ suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ runModuleName im ++ ":"
757+ , indent . line $ "import " ++ runModuleName im ++ " hiding (" ++ nm ++ ")"
758758 ]
759759 suggestions' (TypesDoNotUnify t1 t2)
760760 | isObject t1 && isFunction t2 = [line "Note that function composition in PureScript is defined using (<<<)"]
@@ -768,11 +768,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
768768 -- Pretty print and export declaration
769769 --
770770 prettyPrintExport :: DeclarationRef -> String
771− prettyPrintExport (TypeRef pn _) = show pn
772− prettyPrintExport (ValueRef ident) = show ident
773− prettyPrintExport (TypeClassRef pn) = show pn
774− prettyPrintExport (TypeInstanceRef ident) = show ident
775− prettyPrintExport (ModuleRef name) = "module " ++ show name
771+ prettyPrintExport (TypeRef pn _) = runProperName pn
772+ prettyPrintExport (ValueRef ident) = showIdent ident
773+ prettyPrintExport (TypeClassRef pn) = runProperName pn
774+ prettyPrintExport (TypeInstanceRef ident) = showIdent ident
775+ prettyPrintExport (ModuleRef name) = "module " ++ runModuleName name
776776 prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
777777
778778 -- |
src/Language/PureScript/Kinds.hs+1−1
@@ -49,7 +49,7 @@ data Kind
4949 -- |
5050 -- Function kinds
5151 --
52− | FunKind Kind Kind deriving (Show, Eq, Ord, Data, Typeable)
52+ | FunKind Kind Kind deriving (Show, Read, Eq, Ord, Data, Typeable)
5353
5454$(A.deriveJSON A.defaultOptions ''Kind)
5555
src/Language/PureScript/Linter/Exhaustive.hs+1−2
@@ -69,7 +69,7 @@ getConstructors env defmn n = extractConstructors lnte
6969 getConsDataName con = qualifyName nm defmn con
7070 where
7171 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."
7373 Just (_, pm, _, _) -> pm
7474
7575 getConsInfo :: (Qualified ProperName) -> Maybe (DataDeclType, ProperName, Type, [Ident])
@@ -280,4 +280,3 @@ checkExhaustiveDecls env mn ds =
280280--
281281checkExhaustiveModule :: forall m. (Applicative m, MonadWriter MultipleErrors m) => Environment -> Module -> m ()
282282checkExhaustiveModule 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
8686-- | Progress messages from the make process
8787data ProgressMessage
8888 = CompilingModule ModuleName
89− deriving (Show, Eq, Ord)
89+ deriving (Show, Read, Eq, Ord)
9090
9191-- | Render a progress message
9292renderProgressMessage :: ProgressMessage -> String
@@ -139,7 +139,7 @@ data RebuildPolicy
139139 -- | Never rebuild this module
140140 = RebuildNever
141141 -- | Always rebuild this module
142− | RebuildAlways deriving (Show, Eq, Ord)
142+ | RebuildAlways deriving (Show, Read, Eq, Ord)
143143
144144-- |
145145-- 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
3636 -- |
3737 -- A symbolic name for an infix operator
3838 --
39− | Op String deriving (Eq, Ord, Data, Typeable)
39+ | Op String deriving (Show, Read, Eq, Ord, Data, Typeable)
4040
4141runIdent :: Ident -> String
4242runIdent (Ident i) = i
4343runIdent (Op op) = op
4444
45−instance Show Ident where
46− show (Ident s) = s
47− show (Op op) = '(':op ++ ")"
45+showIdent :: Ident -> String
46+showIdent (Ident i) = i
47+showIdent (Op op) = '(' : op ++ ")"
4848
4949-- |
5050-- Proper names, i.e. capitalized names for e.g. module names, type//data constructors.
5151--
52−newtype ProperName = ProperName { runProperName :: String } deriving (Eq, Ord, Data, Typeable)
53−
54−instance Show ProperName where
55− show = runProperName
52+newtype ProperName = ProperName { runProperName :: String } deriving (Show, Read, Eq, Ord, Data, Typeable)
5653
5754-- |
5855-- Module names
5956--
60−data ModuleName = ModuleName [ProperName] deriving (Eq, Ord, Data, Typeable)
57+data ModuleName = ModuleName [ProperName] deriving (Show, Read, Eq, Ord, Data, Typeable)
6158
6259runModuleName :: ModuleName -> String
6360runModuleName (ModuleName pns) = intercalate "." (runProperName `map` pns)
@@ -70,20 +67,17 @@ moduleNameFromString = ModuleName . splitProperNames
7067 s' -> ProperName w : splitProperNames s''
7168 where (w, s'') = break (== '.') s'
7269
73−instance Show ModuleName where
74− show = runModuleName
75−
7670-- |
7771-- A qualified name, i.e. a name with an optional module name
7872--
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)
8074
81−instance (Show a) => Show (Qualified a) where
82− show (Qualified Nothing a) = show a
83− show (Qualified (Just name) a) = show name ++ "." ++ show a
75+showQualified :: (a -> String) -> Qualified a -> String
76+showQualified f (Qualified Nothing a) = f a
77+showQualified f (Qualified (Just name) a) = runModuleName name ++ "." ++ f a
8478
8579instance (a ~ ProperName) => A.ToJSON (Qualified a) where
86− toJSON = A.toJSON . show
80+ toJSON = A.toJSON . showQualified runProperName
8781
8882instance (a ~ ProperName) => A.FromJSON (Qualified a) where
8983 parseJSON =
src/Language/PureScript/Parser/Lexer.hs+4−4
@@ -115,7 +115,7 @@ data Token
115115 | CharLiteral Char
116116 | StringLiteral String
117117 | Number (Either Integer Double)
118− deriving (Show, Eq, Ord)
118+ deriving (Show, Read, Eq, Ord)
119119
120120prettyPrintToken :: Token -> String
121121prettyPrintToken LParen = "("
@@ -153,8 +153,9 @@ data PositionedToken = PositionedToken
153153 , ptComments :: [Comment]
154154 } deriving (Eq)
155155
156+-- Parsec requires this instance for various token-level combinators
156157instance Show PositionedToken where
157− show = show . ptToken
158+ show = prettyPrintToken . ptToken
158159
159160lex :: FilePath -> String -> Either P.ParseError [PositionedToken]
160161lex filePath input = P.parse parseTokens filePath input
@@ -251,7 +252,7 @@ parseToken = P.choice
251252 where
252253 -- lookAhead doesn't consume any input if its parser succeeds
253254 -- 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' >>
255256 (P.notFollowedBy P.digit P.<?> "no leading zero in number literal"))
256257
257258-- |
@@ -517,4 +518,3 @@ reservedTypeNames = [ "forall", "where" ]
517518--
518519opChars :: [Char]
519520opChars = ":!#$%&*+./<=>?@\\^|-~"
520−
src/Language/PureScript/Pretty/Common.hs+1−1
@@ -25,7 +25,7 @@ import Language.PureScript.Parser.Lexer (reservedPsNames, opChars)
2525parens :: String -> String
2626parens s = ('(':s) ++ ")"
2727
28−newtype PrinterState = PrinterState { indent :: Int } deriving (Show, Eq, Ord)
28+newtype PrinterState = PrinterState { indent :: Int } deriving (Show, Read, Eq, Ord)
2929
3030-- |
3131-- Number of characters per identation level
src/Language/PureScript/Pretty/Types.hs+4−4
@@ -26,6 +26,7 @@ import Control.Arrow ((<+>))
2626import Control.PatternArrows
2727
2828import Language.PureScript.Types
29+import Language.PureScript.Names
2930import Language.PureScript.Kinds
3031import Language.PureScript.Pretty.Common
3132import Language.PureScript.Pretty.Kinds
@@ -37,11 +38,11 @@ typeLiterals = mkPattern match
3738 match TypeWildcard = Just "_"
3839 match (TypeVar var) = Just var
3940 match (PrettyPrintObject row) = Just $ "{ " ++ prettyPrintRow row ++ " }"
40− match (TypeConstructor ctor) = Just $ show ctor
41+ match (TypeConstructor ctor) = Just $ showQualified runProperName ctor
4142 match (TUnknown u) = Just $ '_' : show u
4243 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 (SaturatedTypeSynonym name args) = Just $ show name ++ "<" ++ intercalate "," (map prettyPrintTypeAtom args) ++ ">"
44+ match (ConstrainedType deps ty) = Just $ "(" ++ intercalate ", " (map (\(pn, ty') -> showQualified runProperName pn ++ " " ++ unwords (map prettyPrintTypeAtom ty')) deps) ++ ") => " ++ prettyPrintType ty
45+ match (SaturatedTypeSynonym name args) = Just $ showQualified runProperName name ++ "<" ++ intercalate "," (map prettyPrintTypeAtom args) ++ ">"
4546 match REmpty = Just "()"
4647 match row@RCons{} = Just $ '(' : prettyPrintRow row ++ ")"
4748 match _ = Nothing
@@ -124,4 +125,3 @@ prettyPrintTypeAtom = fromMaybe (error "Incomplete pattern") . pattern matchType
124125--
125126prettyPrintType :: Type -> String
126127prettyPrintType = fromMaybe (error "Incomplete pattern") . pattern matchType () . insertPlaceholders
127−
src/Language/PureScript/Pretty/Values.hs+16−16
@@ -50,11 +50,11 @@ literals = mkPattern' match
5050 match (ObjectConstructor ps) = prettyPrintObject' ps
5151 match (ObjectGetter prop) = return $ "(." ++ prop ++ ")"
5252 match (TypeClassDictionaryConstructorApp className ps) = concat <$> sequence
53− [ return (show className ++ "(\n")
53+ [ return (showQualified runProperName className ++ "(\n")
5454 , match ps
5555 , return ")"
5656 ]
57− match (Constructor name) = return $ show name
57+ match (Constructor name) = return $ showQualified runProperName name
5858 match (Case values binders) = concat <$> sequence
5959 [ return "case "
6060 , unwords <$> forM values prettyPrintValue'
@@ -70,7 +70,7 @@ literals = mkPattern' match
7070 , return "in "
7171 , prettyPrintValue' val
7272 ]
73− match (Var ident) = return $ show ident
73+ match (Var ident) = return $ showQualified showIdent ident
7474 match (Do els) = concat <$> sequence
7575 [ return "do\n"
7676 , withIndent $ prettyPrintMany prettyPrintDoNotationElement els
@@ -78,16 +78,16 @@ literals = mkPattern' match
7878 ]
7979 match (OperatorSection op (Right val)) = return $ "(" ++ prettyPrintValue op ++ " " ++ prettyPrintValue val ++ ")"
8080 match (OperatorSection op (Left val)) = return $ "(" ++ prettyPrintValue val ++ " " ++ prettyPrintValue op ++ ")"
81− match (TypeClassDictionary (name, tys) _) = return $ "<<dict " ++ show name ++ " " ++ unwords (map prettyPrintTypeAtom tys) ++ ">>"
82− match (SuperClassDictionary name _) = return $ "<<superclass dict " ++ show name ++ ">>"
81+ match (TypeClassDictionary (name, tys) _) = return $ "<<dict " ++ showQualified runProperName name ++ " " ++ unwords (map prettyPrintTypeAtom tys) ++ ">>"
82+ match (SuperClassDictionary name _) = return $ "<<superclass dict " ++ showQualified runProperName name ++ ">>"
8383 match (TypedValue _ val _) = prettyPrintValue' val
8484 match (PositionedValue _ _ val) = prettyPrintValue' val
8585 match _ = mzero
8686
8787prettyPrintDeclaration :: 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
8989prettyPrintDeclaration (ValueDeclaration ident _ [] (Right val)) = concat <$> sequence
90− [ return $ show ident ++ " = "
90+ [ return $ showIdent ident ++ " = "
9191 , prettyPrintValue' val
9292 ]
9393prettyPrintDeclaration (PositionedDeclaration _ _ d) = prettyPrintDeclaration d
@@ -165,7 +165,7 @@ app = mkPattern match
165165lam :: Pattern PrinterState Expr (String, Expr)
166166lam = mkPattern match
167167 where
168− match (Abs (Left arg) val) = Just (show arg, val)
168+ match (Abs (Left arg) val) = Just (showIdent arg, val)
169169 match _ = Nothing
170170
171171-- |
@@ -195,20 +195,20 @@ prettyPrintBinderAtom (CharBinder c) = show c
195195prettyPrintBinderAtom (NumberBinder num) = either show show num
196196prettyPrintBinderAtom (BooleanBinder True) = "true"
197197prettyPrintBinderAtom (BooleanBinder False) = "false"
198−prettyPrintBinderAtom (VarBinder ident) = show ident
199−prettyPrintBinderAtom (ConstructorBinder ctor []) = show ctor
200−prettyPrintBinderAtom (ObjectBinder bs) =
201− "{ "
198+prettyPrintBinderAtom (VarBinder ident) = showIdent ident
199+prettyPrintBinderAtom (ConstructorBinder ctor []) = showQualified runProperName ctor
200+prettyPrintBinderAtom (ObjectBinder bs) =
201+ "{ "
202202 ++ intercalate ", " (map prettyPrintObjectPropertyBinder bs)
203203 ++ " }"
204204 where
205205 prettyPrintObjectPropertyBinder :: (String, Binder) -> String
206206 prettyPrintObjectPropertyBinder (key, binder) = prettyPrintObjectKey key ++ ": " ++ prettyPrintBinder binder
207207prettyPrintBinderAtom (ArrayBinder bs) =
208− "[ "
208+ "[ "
209209 ++ intercalate ", " (map prettyPrintBinder bs)
210210 ++ " ]"
211−prettyPrintBinderAtom (NamedBinder ident binder) = show ident ++ "@" ++ prettyPrintBinder binder
211+prettyPrintBinderAtom (NamedBinder ident binder) = showIdent ident ++ "@" ++ prettyPrintBinder binder
212212prettyPrintBinderAtom (PositionedBinder _ _ binder) = prettyPrintBinderAtom binder
213213prettyPrintBinderAtom b = parens (prettyPrintBinder b)
214214
@@ -216,7 +216,7 @@ prettyPrintBinderAtom b = parens (prettyPrintBinder b)
216216-- Generate a pretty-printed string representing a Binder
217217--
218218prettyPrintBinder :: Binder -> String
219−prettyPrintBinder (ConstructorBinder ctor []) = show ctor
220−prettyPrintBinder (ConstructorBinder ctor args) = show ctor ++ " " ++ unwords (map prettyPrintBinderAtom args)
219+prettyPrintBinder (ConstructorBinder ctor []) = showQualified runProperName ctor
220+prettyPrintBinder (ConstructorBinder ctor args) = showQualified runProperName ctor ++ " " ++ unwords (map prettyPrintBinderAtom args)
221221prettyPrintBinder (PositionedBinder _ _ binder) = prettyPrintBinder binder
222222prettyPrintBinder b = prettyPrintBinderAtom b
src/Language/PureScript/Publish.hs+2−2
@@ -147,7 +147,7 @@ getModulesAndBookmarks = do
147147 renderModules bookmarks modules =
148148 return (bookmarks, map D.convertModule modules)
149149
150−data TreeStatus = Clean | Dirty deriving (Show, Eq, Ord, Enum)
150+data TreeStatus = Clean | Dirty deriving (Show, Read, Eq, Ord, Enum)
151151
152152getGitWorkingTreeStatus :: PrepareM TreeStatus
153153getGitWorkingTreeStatus = do
@@ -228,7 +228,7 @@ data DependencyStatus
228228 | ResolvedVersion String
229229 -- ^ Resolved to a version. The String argument is the resolution tag (eg,
230230 -- "v0.1.0").
231− deriving (Show, Eq)
231+ deriving (Show, Read, Eq)
232232
233233-- Go through all bower dependencies which contain purescript code, and
234234-- extract their versions.
src/Language/PureScript/Publish/ErrorsWarnings.hs+1−1
@@ -204,7 +204,7 @@ displayUserError e = case e of
204204 ParseAndDesugarError (D.ParseError err) ->
205205 vcat
206206 [ para "Parse error:"
207− , indented (para (show err))
207+ , indented (P.prettyPrintMultipleErrorsBox False err)
208208 ]
209209 ParseAndDesugarError (D.SortModulesError err) ->
210210 vcat
src/Language/PureScript/Renamer.hs+2−2
@@ -100,7 +100,7 @@ lookupIdent name = do
100100 name' <- gets $ M.lookup name . rsBoundNames
101101 case name' of
102102 Just name'' -> return name''
103− Nothing -> error $ "Rename scope is missing ident '" ++ show name ++ "'"
103+ Nothing -> error $ "Rename scope is missing ident '" ++ showIdent name ++ "'"
104104
105105-- |
106106-- Finds idents introduced by declarations.
@@ -119,7 +119,7 @@ renameInModules = map go
119119 where
120120 go :: Module Ann -> Module Ann
121121 go m@(Module _ _ _ _ _ decls) = m { moduleDecls = map (renameInDecl' (findDeclIdents decls)) decls }
122−
122+
123123 renameInDecl' :: [Ident] -> Bind Ann -> Bind Ann
124124 renameInDecl' scope = runRename scope . renameInDecl True
125125
src/Language/PureScript/Sugar/Names.hs+6−6
@@ -208,12 +208,12 @@ renameInModule env imports (Module ss coms mn decls exps) =
208208 -- Update names so unqualified references become qualified, and locally
209209 -- qualified references are replaced with their canoncial qualified names
210210 -- (e.g. M.Map -> Data.Map.Map).
211− update :: (Ord a, Show a) => (Qualified a -> SimpleErrorMessage)
212− -> M.Map (Qualified a) (Qualified a, ModuleName)
213− -> (Exports -> a -> Maybe (Qualified a))
214− -> Qualified a
215− -> Maybe SourceSpan
216− -> m (Qualified a)
211+ update :: (Ord a) => (Qualified a -> SimpleErrorMessage)
212+ -> M.Map (Qualified a) (Qualified a, ModuleName)
213+ -> (Exports -> a -> Maybe (Qualified a))
214+ -> Qualified a
215+ -> Maybe SourceSpan
216+ -> m (Qualified a)
217217 update unknown imps getE qname@(Qualified mn' name) pos = positioned $
218218 case (M.lookup qname imps, mn') of
219219 -- 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
6767 -- The list of modules that have been imported into the current scope.
6868 --
6969 , importedModules :: [ModuleName]
70− } deriving (Show)
70+ } deriving (Show, Read)
7171
7272-- |
7373-- An empty 'Imports' value.
@@ -95,7 +95,7 @@ data Exports = Exports
9595 -- came from.
9696 --
9797 , exportedValues :: [(Ident, ModuleName)]
98− } deriving (Show)
98+ } deriving (Show, Read)
9999
100100-- |
101101-- An empty 'Exports' value.
@@ -184,7 +184,7 @@ exportValue exps name mn = do
184184-- Adds an entry to a list of exports unless it is already present, in which case an error is
185185-- returned.
186186--
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)]
188188addExport what name mn exports =
189189 if any ((== name) . fst) exports
190190 then throwConflictError what name
@@ -193,5 +193,5 @@ addExport what name mn exports =
193193-- |
194194-- Raises an error for when there is more than one definition for something.
195195--
196−throwConflictError :: (MonadError MultipleErrors m, Show a) => (a -> SimpleErrorMessage) -> a -> m b
196+throwConflictError :: (MonadError MultipleErrors m) => (a -> SimpleErrorMessage) -> a -> m b
197197throwConflictError conflict = throwError . errorMessage . conflict
src/Language/PureScript/Sugar/Names/Imports.hs+13−12
@@ -111,7 +111,7 @@ resolveImport currentModule importModule exps imps impQual =
111111 check _ = error "Invalid argument to checkRefs"
112112
113113 -- 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 ()
115115 checkImportExists unknown exports item =
116116 when (item `notElem` exports) $ throwError . errorMessage $ unknown importModule item
117117
@@ -149,20 +149,20 @@ resolveImport currentModule importModule exps imps impQual =
149149 importExplicit imp (PositionedDeclarationRef pos _ r) =
150150 rethrowWithPosition pos . warnWithPosition pos $ importExplicit imp r
151151 importExplicit imp (ValueRef name) = do
152− values' <- updateImports (importedValues imp) (exportedValues exps) name
152+ values' <- updateImports (importedValues imp) showIdent (exportedValues exps) name
153153 return $ imp { importedValues = values' }
154154 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
156156 let exportedDctors :: [(ProperName, ModuleName)]
157157 exportedDctors = allExportedDataConstructors name
158158 dctorNames :: [ProperName]
159159 dctorNames = fst `map` exportedDctors
160160 maybe (return ()) (mapM_ $ checkDctorExists name dctorNames) dctors
161161 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)
163163 return $ imp { importedTypes = types', importedDataConstructors = dctors' }
164164 importExplicit imp (TypeClassRef name) = do
165− typeClasses' <- updateImports (importedTypeClasses imp) (exportedTypeClasses exps) name
165+ typeClasses' <- updateImports (importedTypeClasses imp) runProperName (exportedTypeClasses exps) name
166166 return $ imp { importedTypeClasses = typeClasses' }
167167 importExplicit _ _ = error "Invalid argument to importExplicit"
168168
@@ -174,11 +174,12 @@ resolveImport currentModule importModule exps imps impQual =
174174 Just ((_, dctors), mn) -> map (, mn) dctors
175175
176176 -- 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)
178− -> [(a, ModuleName)]
179− -> a
180− -> m (M.Map (Qualified a) (Qualified a, ModuleName))
181− updateImports imps' exps' name = case M.lookup (Qualified impQual name) imps' of
177+ updateImports :: (Ord a) => M.Map (Qualified a) (Qualified a, ModuleName)
178+ -> (a -> String)
179+ -> [(a, ModuleName)]
180+ -> a
181+ -> m (M.Map (Qualified a) (Qualified a, ModuleName))
182+ updateImports imps' render exps' name = case M.lookup (Qualified impQual name) imps' of
182183
183184 -- If the name is not already present add it to the list, after looking up
184185 -- where it was originally defined
@@ -195,8 +196,8 @@ resolveImport currentModule importModule exps imps impQual =
195196 | otherwise -> throwError . errorMessage $ err
196197 where
197198 err = if currentModule `elem` [mn, importModule]
198− then ConflictingImport (show name) importModule
199− else ConflictingImports (show name) mn importModule
199+ then ConflictingImport (render name) importModule
200+ else ConflictingImports (render name) mn importModule
200201
201202 Just (Qualified Nothing _, _) ->
202203 error "Invalid state in updateImports"
src/Language/PureScript/Sugar/Operators.hs+2−2
@@ -131,8 +131,8 @@ toAssoc Infixl = P.AssocLeft
131131toAssoc Infixr = P.AssocRight
132132toAssoc Infix = P.AssocNone
133133
134−token :: (P.Stream s Identity t, Show t) => (t -> Maybe a) -> P.Parsec s u a
135−token = P.token show (const (P.initialPos ""))
134+token :: (P.Stream s Identity t) => (t -> Maybe a) -> P.Parsec s u a
135+token = P.token (const "") (const (P.initialPos ""))
136136
137137parseValue :: P.Parsec Chain () Expr
138138parseValue = token (either Just (const Nothing)) P.<?> "expression"
src/Language/PureScript/Sugar/TypeClasses.hs+2−2
@@ -292,10 +292,10 @@ typeClassMemberName :: Declaration -> String
292292typeClassMemberName (TypeDeclaration ident _) = runIdent ident
293293typeClassMemberName (ValueDeclaration ident _ _ _) = runIdent ident
294294typeClassMemberName (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"
296296
297297superClassDictionaryNames :: [Constraint] -> [String]
298298superClassDictionaryNames supers =
299− [ C.__superclass_ ++ show pn ++ "_" ++ show (index :: Integer)
299+ [ C.__superclass_ ++ showQualified runProperName pn ++ "_" ++ show (index :: Integer)
300300 | (index, (pn, _)) <- zip [0..] supers
301301 ]
src/Language/PureScript/TypeChecker/Entailment.hs+1−1
@@ -122,7 +122,7 @@ entails env moduleName context = solve
122122 dictionaryValueToValue (GlobalDictionaryValue fnName) = Var fnName
123123 dictionaryValueToValue (DependentDictionaryValue fnName dicts) = foldl App (Var fnName) (map dictionaryValueToValue dicts)
124124 dictionaryValueToValue (SubclassDictionaryValue dict superclassName index) =
125− App (Accessor (C.__superclass_ ++ show superclassName ++ "_" ++ show index)
125+ App (Accessor (C.__superclass_ ++ showQualified runProperName superclassName ++ "_" ++ show index)
126126 (dictionaryValueToValue dict))
127127 valUndefined
128128 -- Ensure that a substitution is valid
src/Language/PureScript/TypeClassDictionaries.hs+3−3
@@ -38,7 +38,7 @@ data TypeClassDictionaryInScope
3838 , tcdDependencies :: Maybe [Constraint]
3939 -- | The type of this dictionary
4040 , tcdType :: TypeClassDictionaryType
41− } deriving (Show, Data, Typeable)
41+ } deriving (Show, Read, Data, Typeable)
4242
4343-- |
4444-- The type of a type class dictionary
@@ -51,7 +51,7 @@ data TypeClassDictionaryType
5151 -- |
5252 -- A type class dictionary which is an alias for an imported dictionary from another module
5353 --
54− | TCDAlias (Qualified Ident) deriving (Show, Eq, Data, Typeable)
54+ | TCDAlias (Qualified Ident) deriving (Show, Read, Eq, Data, Typeable)
5555
5656-- |
5757-- A simplified representation of expressions which are used to represent type
@@ -74,7 +74,7 @@ data DictionaryValue
7474 -- A subclass dictionary
7575 --
7676 | SubclassDictionaryValue DictionaryValue (Qualified ProperName) Integer
77− deriving (Show, Ord, Eq)
77+ deriving (Show, Read, Ord, Eq)
7878
7979-- |
8080-- 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
3939-- |
4040-- An identifier for the scope of a skolem variable
4141--
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)
4343
4444-- |
4545-- The type of types
@@ -105,7 +105,7 @@ data Type
105105 -- |
106106 -- A placeholder used in pretty printing
107107 --
108− | PrettyPrintForAll [String] Type deriving (Show, Eq, Ord, Data, Typeable)
108+ | PrettyPrintForAll [String] Type deriving (Show, Read,Eq, Ord, Data, Typeable)
109109
110110-- |
111111-- A typeclass constraint