Skip to content

Commit 871d30b

Browse files
committed
Bumped utf8-string version and updated code accordingly.
1 parent b0d5551 commit 871d30b

File tree

7 files changed

+40
-46
lines changed

7 files changed

+40
-46
lines changed

hierarchy/Main.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ import Options.Applicative
2525
import System.Directory (createDirectoryIfMissing)
2626
import System.FilePath ((</>))
2727
import System.Exit (exitFailure, exitSuccess)
28-
import System.IO (stderr)
28+
import System.IO (hPutStr, stderr)
2929

3030
import Text.Parsec as Par (ParseError)
3131

3232
import qualified Language.PureScript as P
3333
import qualified Paths_purescript as Paths
34-
import qualified System.IO.UTF8 as U
3534

3635

3736
data HierarchyOptions = HierarchyOptions
@@ -56,14 +55,14 @@ runModuleName (P.ModuleName pns) = intercalate "_" (P.runProperName `map` pns)
5655

5756
readInput :: FilePath -> IO (Either Par.ParseError [P.Module])
5857
readInput filename = do
59-
content <- U.readFile filename
58+
content <- readFile filename
6059
return $ fmap (map snd) $ P.parseModulesFromFiles id [(filename, content)]
6160

6261
compile :: HierarchyOptions -> IO ()
6362
compile (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

8382
superClasses :: P.Declaration -> [SuperMap]

psc-docs/Main.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ import Options.Applicative
2727

2828
import qualified Language.PureScript as P
2929
import qualified Paths_purescript as Paths
30-
import qualified System.IO.UTF8 as U
3130
import System.Exit (exitSuccess, exitFailure)
32-
import System.IO (stderr)
31+
import System.IO (hPutStr, stderr)
3332

3433

3534
data 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

5251
parseFile :: FilePath -> IO (FilePath, String)
53-
parseFile input = (,) input <$> U.readFile input
52+
parseFile input = (,) input <$> readFile input
5453

5554
type Docs = Writer [String] ()
5655

psc-make/Main.hs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import System.IO.Error (tryIOError)
3131

3232
import qualified Language.PureScript as P
3333
import qualified Paths_purescript as Paths
34-
import qualified System.IO.UTF8 as U
3534

3635

3736
data PSCMakeOptions = PSCMakeOptions
@@ -48,7 +47,7 @@ data InputOptions = InputOptions
4847

4948
readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
5049
readInput 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

5453
newtype 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

7877
compile :: PSCMakeOptions -> IO ()
7978
compile (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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ import Options.Applicative as Opts
2626
import System.Directory (createDirectoryIfMissing)
2727
import System.FilePath (takeDirectory)
2828
import System.Exit (exitSuccess, exitFailure)
29-
import System.IO (stderr)
29+
import System.IO (hPutStr, hPutStrLn, stderr)
3030

3131
import qualified Language.PureScript as P
3232
import qualified Paths_purescript as Paths
33-
import qualified System.IO.UTF8 as U
3433

3534

3635
data PSCOptions = PSCOptions
@@ -51,27 +50,27 @@ data InputOptions = InputOptions
5150
readInput :: InputOptions -> IO [(Maybe FilePath, String)]
5251
readInput 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

5756
compile :: PSCOptions -> IO ()
5857
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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import System.Exit
4242
import System.FilePath (pathSeparator, takeDirectory, (</>), isPathSeparator)
4343
import System.IO.Error (tryIOError)
4444
import System.Process (readProcessWithExitCode)
45-
import qualified System.IO.UTF8 as U (writeFile, putStrLn, print, readFile)
4645

4746
import qualified Text.Parsec as Par (ParseError)
4847

@@ -129,7 +128,7 @@ getHistoryFilename = do
129128
--
130129
loadModule :: FilePath -> IO (Either String [P.Module])
131130
loadModule 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
138137
loadAllModules :: [FilePath] -> IO (Either Par.ParseError [(Either P.RebuildPolicy FilePath, P.Module)])
139138
loadAllModules 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

339338
mkdirp :: FilePath -> IO ()
340339
mkdirp = 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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: purescript
2-
version: 0.6.3
2+
version: 0.6.4
33
cabal-version: >=1.8
44
build-type: Simple
55
license: 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
119119
executable 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
129129
executable 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

152152
executable 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

161161
executable 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
170170
test-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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ import System.Process
2828
import System.FilePath (pathSeparator)
2929
import System.Directory (getCurrentDirectory, getTemporaryDirectory, getDirectoryContents, findExecutable)
3030
import Text.Parsec (ParseError)
31-
import qualified System.IO.UTF8 as U
3231

3332
readInput :: [FilePath] -> IO [(FilePath, String)]
3433
readInput inputFiles = forM inputFiles $ \inputFile -> do
35-
text <- U.readFile inputFile
34+
text <- readFile inputFile
3635
return (inputFile, text)
3736

3837
loadPrelude :: Either String (String, String, P.Environment)

0 commit comments

Comments
 (0)