git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Always read UTF-8, tests
0a92e7fGary Burgess
examples/docs/src/TypeOpAliases.pursnew file+18
@@ -0,0 +1,18 @@
1+module TypeOpAliases where
2+
3+type AltFn a b = a -> b
4+
5+infixr 6 type AltFn as ~>
6+
7+foreign import test1 :: forall a b. a ~> b
8+foreign import test2 :: forall a b c. a ~> b ~> c
9+foreign import test3 :: forall a b c d. a ~> (b ~> c) ~> d
10+foreign import test4 :: forall a b c d. ((a ~> b) ~> c) ~> d
11+
12+data Tuple a b = Tuple a b
13+
14+infixl 6 Tuple as ×
15+infixl 6 type Tuple as ×
16+
17+third ∷ ∀ a b c. a × b × c → c
18+third (a × b × c) = c
hierarchy/Main.hs+2−1
@@ -30,6 +30,7 @@ import System.FilePath ((</>))
30import System.FilePath.Glob (glob)
30import System.FilePath.Glob (glob)
31import System.Exit (exitFailure, exitSuccess)
31import System.Exit (exitFailure, exitSuccess)
32import System.IO (hPutStr, stderr)
32import System.IO (hPutStr, stderr)
33+import System.IO.UTF8 (readUTF8File)
33
34
34import qualified Language.PureScript as P
35import qualified Language.PureScript as P
35import qualified Paths_purescript as Paths
36import qualified Paths_purescript as Paths
@@ -56,7 +57,7 @@ runModuleName (P.ModuleName pns) = intercalate "_" (P.runProperName `map` pns)
56
57
57readInput :: [FilePath] -> IO (Either P.MultipleErrors [P.Module])
58readInput :: [FilePath] -> IO (Either P.MultipleErrors [P.Module])
58readInput paths = do
59readInput paths = do
59− content <- mapM (\path -> (path, ) <$> readFile path) paths
60+ content <- mapM (\path -> (path, ) <$> readUTF8File path) paths
60 return $ map snd <$> P.parseModulesFromFiles id content
61 return $ map snd <$> P.parseModulesFromFiles id content
61
62
62compile :: HierarchyOptions -> IO ()
63compile :: HierarchyOptions -> IO ()
psc-bundle/Main.hs+2−1
@@ -20,6 +20,7 @@ import System.FilePath (takeFileName, takeDirectory)
20import System.FilePath.Glob (glob)
20import System.FilePath.Glob (glob)
21import System.Exit (exitFailure)
21import System.Exit (exitFailure)
22import System.IO (stderr, stdout, hPutStrLn, hSetEncoding, utf8)
22import System.IO (stderr, stdout, hPutStrLn, hSetEncoding, utf8)
23+import System.IO.UTF8 (readUTF8File)
23import System.Directory (createDirectoryIfMissing)
24import System.Directory (createDirectoryIfMissing)
24
25
25import Language.PureScript.Bundle
26import Language.PureScript.Bundle
@@ -56,7 +57,7 @@ app Options{..} = do
56 hPutStrLn stderr "psc-bundle: No input files."
57 hPutStrLn stderr "psc-bundle: No input files."
57 exitFailure
58 exitFailure
58 input <- for inputFiles $ \filename -> do
59 input <- for inputFiles $ \filename -> do
59− js <- liftIO (readFile filename)
60+ js <- liftIO (readUTF8File filename)
60 mid <- guessModuleIdentifier filename
61 mid <- guessModuleIdentifier filename
61 length js `seq` return (mid, js) -- evaluate readFile till EOF before returning, not to exhaust file handles
62 length js `seq` return (mid, js) -- evaluate readFile till EOF before returning, not to exhaust file handles
62
63
psc-docs/Main.hs+2−1
@@ -20,6 +20,7 @@ import qualified Language.PureScript as P
20import qualified Paths_purescript as Paths
20import qualified Paths_purescript as Paths
21import System.Exit (exitFailure)
21import System.Exit (exitFailure)
22import System.IO (hPutStrLn, hPrint, hSetEncoding, stderr, stdout, utf8)
22import System.IO (hPutStrLn, hPrint, hSetEncoding, stderr, stdout, utf8)
23+import System.IO.UTF8 (readUTF8File)
23import System.Directory (createDirectoryIfMissing)
24import System.Directory (createDirectoryIfMissing)
24import System.FilePath (takeDirectory)
25import System.FilePath (takeDirectory)
25import System.FilePath.Glob (glob)
26import System.FilePath.Glob (glob)
@@ -139,7 +140,7 @@ dumpTags input renderTags = do
139 ldump = mapM_ putStrLn
140 ldump = mapM_ putStrLn
140
141
141parseFile :: FilePath -> IO (FilePath, String)
142parseFile :: FilePath -> IO (FilePath, String)
142−parseFile input = (,) input <$> readFile input
143+parseFile input = (,) input <$> readUTF8File input
143
144
144inputFile :: Parser FilePath
145inputFile :: Parser FilePath
145inputFile = strArgument $
146inputFile = strArgument $
psci/PSCi.hs+4−3
@@ -33,6 +33,7 @@ import System.FilePath ((</>))
33import System.FilePath.Glob (glob)
33import System.FilePath.Glob (glob)
34import System.Process (readProcessWithExitCode)
34import System.Process (readProcessWithExitCode)
35import System.IO.Error (tryIOError)
35import System.IO.Error (tryIOError)
36+import System.IO.UTF8 (readUTF8File)
36
37
37import qualified Language.PureScript as P
38import qualified Language.PureScript as P
38import qualified Language.PureScript.Names as N
39import qualified Language.PureScript.Names as N
@@ -75,7 +76,7 @@ loop PSCiOptions{..} = do
75 historyFilename <- getHistoryFilename
76 historyFilename <- getHistoryFilename
76 let settings = defaultSettings { historyFile = Just historyFilename }
77 let settings = defaultSettings { historyFile = Just historyFilename }
77 foreignsOrError <- runMake $ do
78 foreignsOrError <- runMake $ do
78− foreignFilesContent <- forM foreignFiles (\inFile -> (inFile,) <$> makeIO (const (P.ErrorMessage [] $ P.CannotReadFile inFile)) (readFile inFile))
79+ foreignFilesContent <- forM foreignFiles (\inFile -> (inFile,) <$> makeIO (const (P.ErrorMessage [] $ P.CannotReadFile inFile)) (readUTF8File inFile))
79 P.parseForeignModulesFromFiles foreignFilesContent
80 P.parseForeignModulesFromFiles foreignFilesContent
80 case foreignsOrError of
81 case foreignsOrError of
81 Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure
82 Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure
@@ -167,7 +168,7 @@ handleCommand (LoadFile filePath) = PSCI $ whenFileExists filePath $ \absPath ->
167 Right mods -> lift $ modify (updateModules (map (absPath,) mods))
168 Right mods -> lift $ modify (updateModules (map (absPath,) mods))
168handleCommand (LoadForeign filePath) = PSCI $ whenFileExists filePath $ \absPath -> do
169handleCommand (LoadForeign filePath) = PSCI $ whenFileExists filePath $ \absPath -> do
169 foreignsOrError <- lift . lift . runMake $ do
170 foreignsOrError <- lift . lift . runMake $ do
170− foreignFile <- makeIO (const (P.ErrorMessage [] $ P.CannotReadFile absPath)) (readFile absPath)
171+ foreignFile <- makeIO (const (P.ErrorMessage [] $ P.CannotReadFile absPath)) (readUTF8File absPath)
171 P.parseForeignModulesFromFiles [(absPath, foreignFile)]
172 P.parseForeignModulesFromFiles [(absPath, foreignFile)]
172 case foreignsOrError of
173 case foreignsOrError of
173 Left err -> outputStrLn $ P.prettyPrintMultipleErrors False err
174 Left err -> outputStrLn $ P.prettyPrintMultipleErrors False err
@@ -360,7 +361,7 @@ loadUserConfig = onFirstFileMatching readCommands pathGetters
360 exists <- doesFileExist configFile
361 exists <- doesFileExist configFile
361 if exists
362 if exists
362 then do
363 then do
363− ls <- lines <$> readFile configFile
364+ ls <- lines <$> readUTF8File configFile
364 case traverse parseCommand ls of
365 case traverse parseCommand ls of
365 Left err -> print err >> exitFailure
366 Left err -> print err >> exitFailure
366 Right cs -> return $ Just cs
367 Right cs -> return $ Just cs
psci/PSCi/Module.hs+3−2
@@ -6,6 +6,7 @@ import Prelude.Compat
6import qualified Language.PureScript as P
6import qualified Language.PureScript as P
7import PSCi.Types
7import PSCi.Types
8import System.FilePath (pathSeparator)
8import System.FilePath (pathSeparator)
9+import System.IO.UTF8 (readUTF8File)
9import Control.Monad
10import Control.Monad
10
11
11-- | The name of the PSCI support module
12-- | The name of the PSCI support module
@@ -45,7 +46,7 @@ supportModule =
45--
46--
46loadModule :: FilePath -> IO (Either String [P.Module])
47loadModule :: FilePath -> IO (Either String [P.Module])
47loadModule filename = do
48loadModule filename = do
48− content <- readFile filename
49+ content <- readUTF8File filename
49 return $ either (Left . P.prettyPrintMultipleErrors False) (Right . map snd) $ P.parseModulesFromFiles id [(filename, content)]
50 return $ either (Left . P.prettyPrintMultipleErrors False) (Right . map snd) $ P.parseModulesFromFiles id [(filename, content)]
50
51
51-- |
52-- |
@@ -54,7 +55,7 @@ loadModule filename = do
54loadAllModules :: [FilePath] -> IO (Either P.MultipleErrors [(FilePath, P.Module)])
55loadAllModules :: [FilePath] -> IO (Either P.MultipleErrors [(FilePath, P.Module)])
55loadAllModules files = do
56loadAllModules files = do
56 filesAndContent <- forM files $ \filename -> do
57 filesAndContent <- forM files $ \filename -> do
57− content <- readFile filename
58+ content <- readUTF8File filename
58 return (filename, content)
59 return (filename, content)
59 return $ P.parseModulesFromFiles id filesAndContent
60 return $ P.parseModulesFromFiles id filesAndContent
60
61
src/Language/PureScript/Docs/Convert/ReExports.hs+23−2
@@ -111,13 +111,14 @@ collectDeclarations imports exports = do
111 valsAndMembers <- collect lookupValueDeclaration impVals expVals
111 valsAndMembers <- collect lookupValueDeclaration impVals expVals
112 typeClasses <- collect lookupTypeClassDeclaration impTCs expTCs
112 typeClasses <- collect lookupTypeClassDeclaration impTCs expTCs
113 types <- collect lookupTypeDeclaration impTypes expTypes
113 types <- collect lookupTypeDeclaration impTypes expTypes
114+ typeOps <- collect lookupTypeOpDeclaration impTypeOps expTypeOps
114
115
115 (vals, classes) <- handleTypeClassMembers valsAndMembers typeClasses
116 (vals, classes) <- handleTypeClassMembers valsAndMembers typeClasses
116
117
117 let filteredTypes = filterDataConstructors expCtors types
118 let filteredTypes = filterDataConstructors expCtors types
118 let filteredClasses = filterTypeClassMembers (map fst expVals) classes
119 let filteredClasses = filterTypeClassMembers (map fst expVals) classes
119
120
120− pure (Map.toList (Map.unionsWith (<>) [filteredTypes, filteredClasses, vals]))
121+ pure (Map.toList (Map.unionsWith (<>) [filteredTypes, typeOps, filteredClasses, vals]))
121
122
122 where
123 where
123 collect lookup' imps exps = do
124 collect lookup' imps exps = do
@@ -130,6 +131,9 @@ collectDeclarations imports exports = do
130 expTypes = map (first fst) (P.exportedTypes exports)
131 expTypes = map (first fst) (P.exportedTypes exports)
131 impTypes = concat (Map.elems (P.importedTypes imports))
132 impTypes = concat (Map.elems (P.importedTypes imports))
132
133
134+ expTypeOps = P.exportedTypeOps exports
135+ impTypeOps = concat (Map.elems (P.importedTypeOps imports))
136+
133 expCtors = concatMap (snd . fst) (P.exportedTypes exports)
137 expCtors = concatMap (snd . fst) (P.exportedTypes exports)
134
138
135 expTCs = P.exportedTypeClasses exports
139 expTCs = P.exportedTypeClasses exports
@@ -180,7 +184,7 @@ lookupValueDeclaration importedFrom ident = do
180 let
184 let
181 rs =
185 rs =
182 filter (\d -> declTitle d == P.showIdent ident
186 filter (\d -> declTitle d == P.showIdent ident
183− && (isValue d || isAlias d)) decls
187+ && (isValue d || isValueAlias d)) decls
184 errOther other =
188 errOther other =
185 internalErrorInModule
189 internalErrorInModule
186 ("lookupValueDeclaration: unexpected result:\n" ++
190 ("lookupValueDeclaration: unexpected result:\n" ++
@@ -243,6 +247,23 @@ lookupTypeDeclaration importedFrom ty = do
243 internalErrorInModule
247 internalErrorInModule
244 ("lookupTypeDeclaration: unexpected result: " ++ show other)
248 ("lookupTypeDeclaration: unexpected result: " ++ show other)
245
249
250+lookupTypeOpDeclaration ::
251+ (MonadState (Map P.ModuleName Module) m,
252+ MonadReader P.ModuleName m) =>
253+ P.ModuleName ->
254+ P.Ident ->
255+ m (P.ModuleName, [Declaration])
256+lookupTypeOpDeclaration importedFrom tyOp = do
257+ decls <- lookupModuleDeclarations "lookupTypeOpDeclaration" importedFrom
258+ let
259+ ds = filter (\d -> declTitle d == ("type " ++ P.showIdent tyOp) && isTypeAlias d) decls
260+ case ds of
261+ [d] ->
262+ pure (importedFrom, [d])
263+ other ->
264+ internalErrorInModule
265+ ("lookupTypeOpDeclaration: unexpected result: " ++ show other)
266+
246lookupTypeClassDeclaration ::
267lookupTypeClassDeclaration ::
247 (MonadState (Map P.ModuleName Module) m,
268 (MonadState (Map P.ModuleName Module) m,
248 MonadReader P.ModuleName m) =>
269 MonadReader P.ModuleName m) =>
src/Language/PureScript/Docs/Convert/Single.hs+10−9
@@ -108,16 +108,17 @@ addDefaultFixity decl@Declaration{..}
108 defaultFixity = P.Fixity P.Infixl (-1)
108 defaultFixity = P.Fixity P.Infixl (-1)
109
109
110getDeclarationTitle :: P.Declaration -> Maybe String
110getDeclarationTitle :: P.Declaration -> Maybe String
111−getDeclarationTitle (P.ValueDeclaration name _ _ _) = Just (P.showIdent name)
111+getDeclarationTitle (P.ValueDeclaration name _ _ _) = Just (P.showIdent name)
112−getDeclarationTitle (P.ExternDeclaration name _) = Just (P.showIdent name)
112+getDeclarationTitle (P.ExternDeclaration name _) = Just (P.showIdent name)
113−getDeclarationTitle (P.DataDeclaration _ name _ _) = Just (P.runProperName name)
113+getDeclarationTitle (P.DataDeclaration _ name _ _) = Just (P.runProperName name)
114−getDeclarationTitle (P.ExternDataDeclaration name _) = Just (P.runProperName name)
114+getDeclarationTitle (P.ExternDataDeclaration name _) = Just (P.runProperName name)
115−getDeclarationTitle (P.TypeSynonymDeclaration name _ _) = Just (P.runProperName name)
115+getDeclarationTitle (P.TypeSynonymDeclaration name _ _) = Just (P.runProperName name)
116−getDeclarationTitle (P.TypeClassDeclaration name _ _ _) = Just (P.runProperName name)
116+getDeclarationTitle (P.TypeClassDeclaration name _ _ _) = Just (P.runProperName name)
117getDeclarationTitle (P.TypeInstanceDeclaration name _ _ _ _) = Just (P.showIdent name)
117getDeclarationTitle (P.TypeInstanceDeclaration name _ _ _ _) = Just (P.showIdent name)
118−getDeclarationTitle (P.FixityDeclaration _ name _) = Just ("(" ++ name ++ ")")
118+getDeclarationTitle (P.FixityDeclaration _ name (Just (P.Qualified _ P.AliasType{}))) = Just ("type (" ++ name ++ ")")
119+getDeclarationTitle (P.FixityDeclaration _ name _) = Just ("(" ++ name ++ ")")
119−getDeclarationTitle (P.PositionedDeclaration _ _ d) = getDeclarationTitle d
120+getDeclarationTitle (P.PositionedDeclaration _ _ d) = getDeclarationTitle d
120−getDeclarationTitle _ = Nothing
121+getDeclarationTitle _ = Nothing
121
122
122-- | Create a basic Declaration value.
123-- | Create a basic Declaration value.
123mkDeclaration :: String -> DeclarationInfo -> Declaration
124mkDeclaration :: String -> DeclarationInfo -> Declaration
src/Language/PureScript/Docs/ParseAndBookmark.hs+3−1
@@ -16,6 +16,8 @@ import Control.Monad.IO.Class (MonadIO(..))
16
16
17import Web.Bower.PackageMeta (PackageName)
17import Web.Bower.PackageMeta (PackageName)
18
18
19+import System.IO.UTF8 (readUTF8File)
20+
19import qualified Language.PureScript as P
21import qualified Language.PureScript as P
20import Language.PureScript.Docs.Types
22import Language.PureScript.Docs.Types
21import Language.PureScript.Docs.Convert (collectBookmarks)
23import Language.PureScript.Docs.Convert (collectBookmarks)
@@ -80,7 +82,7 @@ fileInfoToString (Local fn) = fn
80fileInfoToString (FromDep _ fn) = fn
82fileInfoToString (FromDep _ fn) = fn
81
83
82parseFile :: FilePath -> IO (FilePath, String)
84parseFile :: FilePath -> IO (FilePath, String)
83−parseFile input' = (,) input' <$> readFile input'
85+parseFile input' = (,) input' <$> readUTF8File input'
84
86
85parseAs :: (MonadIO m) => (FilePath -> a) -> FilePath -> m (a, String)
87parseAs :: (MonadIO m) => (FilePath -> a) -> FilePath -> m (a, String)
86parseAs g = fmap (first g) . liftIO . parseFile
88parseAs g = fmap (first g) . liftIO . parseFile
src/Language/PureScript/Docs/Render.hs+5−2
@@ -58,12 +58,12 @@ renderDeclarationWithOptions opts Declaration{..} =
58 syntax "("
58 syntax "("
59 <> mintersperse (syntax "," <> sp) (map renderConstraint implies)
59 <> mintersperse (syntax "," <> sp) (map renderConstraint implies)
60 <> syntax ")" <> sp <> syntax "<="
60 <> syntax ")" <> sp <> syntax "<="
61− AliasDeclaration for (P.Fixity associativity precedence) ->
61+ AliasDeclaration for@(P.Qualified _ alias) (P.Fixity associativity precedence) ->
62 [ keywordFixity associativity
62 [ keywordFixity associativity
63 , syntax $ show precedence
63 , syntax $ show precedence
64 , ident $ renderAlias for
64 , ident $ renderAlias for
65 , keyword "as"
65 , keyword "as"
66− , ident . tail . init $ declTitle
66+ , ident $ adjustAliasName alias declTitle
67 ]
67 ]
68
68
69 where
69 where
@@ -78,6 +78,9 @@ renderDeclarationWithOptions opts Declaration{..} =
78 (("type " ++) . P.showQualified P.runProperName . P.Qualified mn)
78 (("type " ++) . P.showQualified P.runProperName . P.Qualified mn)
79 alias
79 alias
80
80
81+ adjustAliasName (P.AliasType{}) title = drop 6 (init title)
82+ adjustAliasName _ title = tail (init title)
83+
81renderChildDeclaration :: ChildDeclaration -> RenderedCode
84renderChildDeclaration :: ChildDeclaration -> RenderedCode
82renderChildDeclaration = renderChildDeclarationWithOptions defaultRenderTypeOptions
85renderChildDeclaration = renderChildDeclarationWithOptions defaultRenderTypeOptions
83
86
src/Language/PureScript/Docs/Types.hs+10−3
@@ -164,10 +164,17 @@ isType Declaration{..} =
164 ExternDataDeclaration{} -> True
164 ExternDataDeclaration{} -> True
165 _ -> False
165 _ -> False
166
166
167−isAlias :: Declaration -> Bool
167+isValueAlias :: Declaration -> Bool
168−isAlias Declaration{..} =
168+isValueAlias Declaration{..} =
169 case declInfo of
169 case declInfo of
170− AliasDeclaration{} -> True
170+ (AliasDeclaration (P.Qualified _ P.AliasConstructor{}) _) -> True
171+ (AliasDeclaration (P.Qualified _ P.AliasValue{}) _) -> True
172+ _ -> False
173+
174+isTypeAlias :: Declaration -> Bool
175+isTypeAlias Declaration{..} =
176+ case declInfo of
177+ (AliasDeclaration (P.Qualified _ P.AliasType{}) _) -> True
171 _ -> False
178 _ -> False
172
179
173-- | Discard any children which do not satisfy the given predicate.
180-- | Discard any children which do not satisfy the given predicate.
src/Language/PureScript/Ide/SourceFile.hs+2−1
@@ -35,6 +35,7 @@ import Language.PureScript.Ide.Types
35import qualified Language.PureScript.Names as N
35import qualified Language.PureScript.Names as N
36import qualified Language.PureScript.Parser as P
36import qualified Language.PureScript.Parser as P
37import System.Directory
37import System.Directory
38+import System.IO.UTF8 (readUTF8File)
38
39
39parseModuleFromFile :: (MonadIO m, MonadError PscIdeError m) =>
40parseModuleFromFile :: (MonadIO m, MonadError PscIdeError m) =>
40 FilePath -> m D.Module
41 FilePath -> m D.Module
@@ -42,7 +43,7 @@ parseModuleFromFile fp = do
42 exists <- liftIO (doesFileExist fp)
43 exists <- liftIO (doesFileExist fp)
43 if exists
44 if exists
44 then do
45 then do
45− content <- liftIO (readFile fp)
46+ content <- liftIO (readUTF8File fp)
46 let m = do tokens <- P.lex fp content
47 let m = do tokens <- P.lex fp content
47 P.runTokenParser "" P.parseModule tokens
48 P.runTokenParser "" P.parseModule tokens
48 either (throwError . (`ParseError` "File could not be parsed.")) pure m
49 either (throwError . (`ParseError` "File could not be parsed.")) pure m
tests/TestDocs.hs+17−6
@@ -285,12 +285,20 @@ testCases =
285 , ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "aNumber" (ShowFn (P.tyNumber ==))
285 , ValueShouldHaveTypeSignature (n "ExplicitTypeSignatures") "aNumber" (ShowFn (P.tyNumber ==))
286 ])
286 ])
287
287
288− , ("ConstrainedArgument",
288+ , ("ConstrainedArgument",
289− [ TypeSynonymShouldRenderAs (n "ConstrainedArgument") "WithoutArgs" "forall a. (Partial => a) -> a"
289+ [ TypeSynonymShouldRenderAs (n "ConstrainedArgument") "WithoutArgs" "forall a. (Partial => a) -> a"
290− , TypeSynonymShouldRenderAs (n "ConstrainedArgument") "WithArgs" "forall a. (Foo a => a) -> a"
290+ , TypeSynonymShouldRenderAs (n "ConstrainedArgument") "WithArgs" "forall a. (Foo a => a) -> a"
291− , TypeSynonymShouldRenderAs (n "ConstrainedArgument") "MultiWithoutArgs" "forall a. ((Partial, Partial) => a) -> a"
291+ , TypeSynonymShouldRenderAs (n "ConstrainedArgument") "MultiWithoutArgs" "forall a. ((Partial, Partial) => a) -> a"
292− , TypeSynonymShouldRenderAs (n "ConstrainedArgument") "MultiWithArgs" "forall a b. ((Foo a, Foo b) => a) -> a"
292+ , TypeSynonymShouldRenderAs (n "ConstrainedArgument") "MultiWithArgs" "forall a b. ((Foo a, Foo b) => a) -> a"
293+ ])
294+
295+ , ("TypeOpAliases",
296+ [ ValueShouldHaveTypeSignature (n "TypeOpAliases") "test1" (renderedType "forall a b. a ~> b")
297+ , ValueShouldHaveTypeSignature (n "TypeOpAliases") "test2" (renderedType "forall a b c. a ~> b ~> c")
298+ , ValueShouldHaveTypeSignature (n "TypeOpAliases") "test3" (renderedType "forall a b c d. a ~> (b ~> c) ~> d")
299+ , ValueShouldHaveTypeSignature (n "TypeOpAliases") "test4" (renderedType "forall a b c d. ((a ~> b) ~> c) ~> d")
300+ , ValueShouldHaveTypeSignature (n "TypeOpAliases") "third" (renderedType "forall a b c. a × b × c -> c")
293− ])
301+ ])
294 ]
302 ]
295
303
296 where
304 where
@@ -301,3 +309,6 @@ testCases =
301
309
302 isVar varName (P.TypeVar name) | varName == name = True
310 isVar varName (P.TypeVar name) | varName == name = True
303 isVar _ _ = False
311 isVar _ _ = False
312+
313+ renderedType expected =
314+ ShowFn $ \ty -> codeToString (Docs.renderType ty) == expected
tests/TestPsci.hs+2−1
@@ -17,6 +17,7 @@ import System.Exit (exitFailure)
17import System.Console.Haskeline
17import System.Console.Haskeline
18import System.FilePath ((</>))
18import System.FilePath ((</>))
19import System.Directory (getCurrentDirectory)
19import System.Directory (getCurrentDirectory)
20+import System.IO.UTF8 (readUTF8File)
20import qualified System.FilePath.Glob as Glob
21import qualified System.FilePath.Glob as Glob
21
22
22import Test.HUnit
23import Test.HUnit
@@ -132,7 +133,7 @@ getPSCiState = do
132 jsFiles <- supportFiles "js"
133 jsFiles <- supportFiles "js"
133
134
134 modulesOrFirstError <- loadAllModules pursFiles
135 modulesOrFirstError <- loadAllModules pursFiles
135− foreignFiles <- forM jsFiles (\f -> (f,) <$> readFile f)
136+ foreignFiles <- forM jsFiles (\f -> (f,) <$> readUTF8File f)
136 Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles foreignFiles
137 Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles foreignFiles
137 case modulesOrFirstError of
138 case modulesOrFirstError of
138 Left err ->
139 Left err ->