git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #826 from aspidites/update-utf8-string

Bumped utf8-string version and updated code accordingly.

commit9ce6ef8c79c5bfe4511a6e69a3656fe5f6572da9 authorPhil Freeman <paf31@cantab.net> dateFri 23 Jan 2015, 09:07 (12 years ago) parentb0d5551871d30b
7 files changed+40−46
hierarchy/Main.hs+5−6 psc-docs/Main.hs+4−5 psc-make/Main.hs+8−9 psc/Main.hs+7−8 psci/Main.hs+7−8 purescript.cabal+8−8 tests/Main.hs+1−2
hierarchy/Main.hs+5−6
@@ -25,13 +25,12 @@ import Options.Applicative
2525import System.Directory (createDirectoryIfMissing)
2626import System.FilePath ((</>))
2727import System.Exit (exitFailure, exitSuccess)
28−import System.IO (stderr)
28+import System.IO (hPutStr, stderr)
2929
3030import Text.Parsec as Par (ParseError)
3131
3232import qualified Language.PureScript as P
3333import qualified Paths_purescript as Paths
34−import qualified System.IO.UTF8 as U
3534
3635
3736data HierarchyOptions = HierarchyOptions
@@ -56,14 +55,14 @@ runModuleName (P.ModuleName pns) = intercalate "_" (P.runProperName `map` pns)
5655
5756readInput :: FilePath -> IO (Either Par.ParseError [P.Module])
5857readInput filename = do
59− content <- U.readFile filename
58+ content <- readFile filename
6059 return $ fmap (map snd) $ P.parseModulesFromFiles id [(filename, content)]
6160
6261compile :: HierarchyOptions -> IO ()
6362compile (HierarchyOptions input mOutput) = do
6463 modules <- readInput input
6564 case modules of
66− Left err -> U.hPutStr stderr (show err) >> exitFailure
65+ Left err -> hPutStr stderr (show err) >> exitFailure
6766 Right ms -> do
6867 for_ ms $ \(P.Module moduleName decls _) ->
6968 let name = runModuleName moduleName
@@ -76,8 +75,8 @@ compile (HierarchyOptions input mOutput) = do
7675 in unless (null supers) $ case mOutput of
7776 Just output -> do
7877 createDirectoryIfMissing True output
79− U.writeFile (output </> name) hier
80− Nothing -> U.putStrLn hier
78+ writeFile (output </> name) hier
79+ Nothing -> putStrLn hier
8180 exitSuccess
8281
8382superClasses :: P.Declaration -> [SuperMap]
psc-docs/Main.hs+4−5
@@ -27,9 +27,8 @@ import Options.Applicative
2727
2828import qualified Language.PureScript as P
2929import qualified Paths_purescript as Paths
30−import qualified System.IO.UTF8 as U
3130import System.Exit (exitSuccess, exitFailure)
32−import System.IO (stderr)
31+import System.IO (hPutStr, stderr)
3332
3433
3534data PSCDocsOptions = PSCDocsOptions
@@ -43,14 +42,14 @@ docgen (PSCDocsOptions showHierarchy input) = do
4342 e <- P.parseModulesFromFiles (fromMaybe "") <$> mapM (fmap (first Just) . parseFile) (nub input)
4443 case e of
4544 Left err -> do
46− U.hPutStr stderr $ show err
45+ hPutStr stderr $ show err
4746 exitFailure
4847 Right ms -> do
49− U.putStrLn . runDocs $ (renderModules showHierarchy) (map snd ms)
48+ putStrLn . runDocs $ (renderModules showHierarchy) (map snd ms)
5049 exitSuccess
5150
5251parseFile :: FilePath -> IO (FilePath, String)
53−parseFile input = (,) input <$> U.readFile input
52+parseFile input = (,) input <$> readFile input
5453
5554type Docs = Writer [String] ()
5655
psc-make/Main.hs+8−9
@@ -31,7 +31,6 @@ import System.IO.Error (tryIOError)
3131
3232import qualified Language.PureScript as P
3333import qualified Paths_purescript as Paths
34−import qualified System.IO.UTF8 as U
3534
3635
3736data PSCMakeOptions = PSCMakeOptions
@@ -48,7 +47,7 @@ data InputOptions = InputOptions
4847
4948readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
5049readInput InputOptions{..} = do
51− content <- forM ioInputFiles $ \inFile -> (Right inFile, ) <$> U.readFile inFile
50+ content <- forM ioInputFiles $ \inFile -> (Right inFile, ) <$> readFile inFile
5251 return (if ioNoPrelude then content else (Left P.RebuildNever, P.prelude) : content)
5352
5453newtype Make a = Make { unMake :: ErrorT String IO a } deriving (Functor, Applicative, Monad, MonadIO, MonadError String)
@@ -66,27 +65,27 @@ instance P.MonadMake Make where
6665 True -> Just <$> getModificationTime path
6766 False -> return Nothing
6867 readTextFile path = makeIO $ do
69− U.putStrLn $ "Reading " ++ path
70− U.readFile path
68+ putStrLn $ "Reading " ++ path
69+ readFile path
7170 writeTextFile path text = makeIO $ do
7271 mkdirp path
73− U.putStrLn $ "Writing " ++ path
74− U.writeFile path text
72+ putStrLn $ "Writing " ++ path
73+ writeFile path text
7574 liftError = either throwError return
76− progress = makeIO . U.putStrLn
75+ progress = makeIO . putStrLn
7776
7877compile :: PSCMakeOptions -> IO ()
7978compile (PSCMakeOptions input outputDir opts usePrefix) = do
8079 modules <- P.parseModulesFromFiles (either (const "") id) <$> readInput (InputOptions (P.optionsNoPrelude opts) input)
8180 case modules of
8281 Left err -> do
83− U.print err
82+ print err
8483 exitFailure
8584 Right ms -> do
8685 e <- runMake $ P.make outputDir opts ms prefix
8786 case e of
8887 Left err -> do
89− U.putStrLn err
88+ putStrLn err
9089 exitFailure
9190 Right _ -> do
9291 exitSuccess
psc/Main.hs+7−8
@@ -26,11 +26,10 @@ import Options.Applicative as Opts
2626import System.Directory (createDirectoryIfMissing)
2727import System.FilePath (takeDirectory)
2828import System.Exit (exitSuccess, exitFailure)
29−import System.IO (stderr)
29+import System.IO (hPutStr, hPutStrLn, stderr)
3030
3131import qualified Language.PureScript as P
3232import qualified Paths_purescript as Paths
33−import qualified System.IO.UTF8 as U
3433
3534
3635data PSCOptions = PSCOptions
@@ -51,7 +50,7 @@ data InputOptions = InputOptions
5150readInput :: InputOptions -> IO [(Maybe FilePath, String)]
5251readInput InputOptions{..}
5352 | ioUseStdIn = return . (Nothing ,) <$> getContents
54− | otherwise = do content <- forM ioInputFiles $ \inFile -> (Just inFile, ) <$> U.readFile inFile
53+ | otherwise = do content <- forM ioInputFiles $ \inFile -> (Just inFile, ) <$> readFile inFile
5554 return (if ioNoPrelude then content else (Nothing, P.prelude) : content)
5655
5756compile :: PSCOptions -> IO ()
@@ -59,19 +58,19 @@ compile (PSCOptions input opts stdin output externs usePrefix) = do
5958 modules <- P.parseModulesFromFiles (fromMaybe "") <$> readInput (InputOptions (P.optionsNoPrelude opts) stdin input)
6059 case modules of
6160 Left err -> do
62− U.hPutStr stderr $ show err
61+ hPutStr stderr $ show err
6362 exitFailure
6463 Right ms -> do
6564 case P.compile opts (map snd ms) prefix of
6665 Left err -> do
67− U.hPutStrLn stderr err
66+ hPutStrLn stderr err
6867 exitFailure
6968 Right (js, exts, _) -> do
7069 case output of
71− Just path -> mkdirp path >> U.writeFile path js
72− Nothing -> U.putStrLn js
70+ Just path -> mkdirp path >> writeFile path js
71+ Nothing -> putStrLn js
7372 case externs of
74− Just path -> mkdirp path >> U.writeFile path exts
73+ Just path -> mkdirp path >> writeFile path exts
7574 Nothing -> return ()
7675 exitSuccess
7776 where
psci/Main.hs+7−8
@@ -42,7 +42,6 @@ import System.Exit
4242import System.FilePath (pathSeparator, takeDirectory, (</>), isPathSeparator)
4343import System.IO.Error (tryIOError)
4444import System.Process (readProcessWithExitCode)
45−import qualified System.IO.UTF8 as U (writeFile, putStrLn, print, readFile)
4645
4746import qualified Text.Parsec as Par (ParseError)
4847
@@ -129,7 +128,7 @@ getHistoryFilename = do
129128--
130129loadModule :: FilePath -> IO (Either String [P.Module])
131130loadModule filename = do
132− content <- U.readFile filename
131+ content <- readFile filename
133132 return $ either (Left . show) (Right . map snd) $ P.parseModulesFromFiles id [(filename, content)]
134133
135134-- |
@@ -138,7 +137,7 @@ loadModule filename = do
138137loadAllModules :: [FilePath] -> IO (Either Par.ParseError [(Either P.RebuildPolicy FilePath, P.Module)])
139138loadAllModules files = do
140139 filesAndContent <- forM files $ \filename -> do
141− content <- U.readFile filename
140+ content <- readFile filename
142141 return (Right filename, content)
143142 return $ P.parseModulesFromFiles (either (const "") id) $ (Left P.RebuildNever, P.prelude) : filesAndContent
144143
@@ -329,12 +328,12 @@ instance P.MonadMake Make where
329328 if exists
330329 then Just <$> getModificationTime path
331330 else return Nothing
332− readTextFile path = makeIO $ U.readFile path
331+ readTextFile path = makeIO $ readFile path
333332 writeTextFile path text = makeIO $ do
334333 mkdirp path
335− U.writeFile path text
334+ writeFile path text
336335 liftError = either throwError return
337− progress s = unless (s == "Compiling $PSCI") $ makeIO . U.putStrLn $ s
336+ progress s = unless (s == "Compiling $PSCI") $ makeIO . putStrLn $ s
338337
339338mkdirp :: FilePath -> IO ()
340339mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -579,9 +578,9 @@ loadUserConfig = do
579578 exists <- doesFileExist configFile
580579 if exists
581580 then do
582− ls <- lines <$> U.readFile configFile
581+ ls <- lines <$> readFile configFile
583582 case mapM parseCommand ls of
584− Left err -> U.print err >> exitFailure
583+ Left err -> print err >> exitFailure
585584 Right cs -> return $ Just cs
586585 else
587586 return Nothing
purescript.cabal+8−8
@@ -1,5 +1,5 @@
11name: purescript
2−version: 0.6.3
2+version: 0.6.4
33cabal-version: >=1.8
44build-type: Simple
55license: MIT
@@ -32,7 +32,7 @@ library
3232 mtl >= 2.1.0 && < 2.3.0,
3333 parsec -any,
3434 transformers >= 0.3 && < 0.5,
35− utf8-string -any,
35+ utf8-string >= 1,
3636 pattern-arrows >= 0.0.2 && < 0.1,
3737 monad-unify >= 0.2.2 && < 0.3,
3838 file-embed >= 0.0.7 && < 0.0.8,
@@ -119,7 +119,7 @@ library
119119executable psc
120120 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
121121 mtl -any, optparse-applicative >= 0.10.0, parsec -any, purescript -any,
122− transformers -any, utf8-string -any
122+ transformers -any, utf8-string >= 1
123123 main-is: Main.hs
124124 buildable: True
125125 hs-source-dirs: psc
@@ -129,7 +129,7 @@ executable psc
129129executable psc-make
130130 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
131131 mtl -any, optparse-applicative >= 0.10.0, parsec -any, purescript -any,
132− transformers -any, utf8-string -any
132+ transformers -any, utf8-string >= 1
133133 main-is: Main.hs
134134 buildable: True
135135 hs-source-dirs: psc-make
@@ -140,7 +140,7 @@ executable psci
140140 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
141141 mtl -any, optparse-applicative >= 0.10.0, parsec -any,
142142 haskeline >= 0.7.0.0, purescript -any, transformers -any,
143− utf8-string -any, process -any
143+ utf8-string >= 1, process -any
144144
145145 main-is: Main.hs
146146 buildable: True
@@ -150,7 +150,7 @@ executable psci
150150 ghc-options: -Wall -fno-warn-warnings-deprecations -O2
151151
152152executable psc-docs
153− build-depends: base >=4 && <5, purescript -any, utf8-string -any,
153+ build-depends: base >=4 && <5, purescript -any, utf8-string >= 1,
154154 optparse-applicative >= 0.10.0, process -any, mtl -any
155155 main-is: Main.hs
156156 buildable: True
@@ -159,7 +159,7 @@ executable psc-docs
159159 ghc-options: -Wall -fno-warn-warnings-deprecations -O2
160160
161161executable hierarchy
162− build-depends: base >=4 && <5, purescript -any, utf8-string -any, optparse-applicative >= 0.10.0,
162+ build-depends: base >=4 && <5, purescript -any, utf8-string >= 1, optparse-applicative >= 0.10.0,
163163 process -any, mtl -any, parsec -any, filepath -any, directory -any
164164 main-is: Main.hs
165165 buildable: True
@@ -170,7 +170,7 @@ executable hierarchy
170170test-suite tests
171171 build-depends: base >=4 && <5, containers -any, directory -any,
172172 filepath -any, mtl -any, parsec -any, purescript -any,
173− transformers -any, utf8-string -any, process -any
173+ transformers -any, utf8-string >= 1, process -any
174174 type: exitcode-stdio-1.0
175175 main-is: Main.hs
176176 buildable: True
tests/Main.hs+1−2
@@ -28,11 +28,10 @@ import System.Process
2828import System.FilePath (pathSeparator)
2929import System.Directory (getCurrentDirectory, getTemporaryDirectory, getDirectoryContents, findExecutable)
3030import Text.Parsec (ParseError)
31−import qualified System.IO.UTF8 as U
3231
3332readInput :: [FilePath] -> IO [(FilePath, String)]
3433readInput inputFiles = forM inputFiles $ \inputFile -> do
35− text <- U.readFile inputFile
34+ text <- readFile inputFile
3635 return (inputFile, text)
3736
3837loadPrelude :: Either String (String, String, P.Environment)