Skip to content

Commit cf34aa4

Browse files
committed
Stopped using utf8-string in AllNonAsciiChars.
+ The IO library shipped with GHC 6.12.1 (base 4.2.0.0) makes the use of utf8-string unnecessary (and sometimes incorrect).
1 parent 770d255 commit cf34aa4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

AllNonAsciiChars.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
-- | This module extracts all the non-ASCII characters used by the
22
-- library code (along with how many times they are used).
33
--
4-
-- The implementation relies on the utf8-string and FileManip
5-
-- libraries which are available from Hackage.
4+
-- The implementation relies on the FileManip library which is
5+
-- available from Hackage.
66

77
module AllNonAsciiChars where
88

99
import qualified Data.List as L
1010
import Data.Char
1111
import Data.Function
1212
import Control.Applicative
13-
import System.IO.UTF8 as U
1413
import System.FilePath.Find
14+
import System.IO
15+
16+
readUTF8File :: FilePath -> IO String
17+
readUTF8File f = do
18+
h <- openFile f ReadMode
19+
hSetEncoding h utf8
20+
hGetContents h
1521

1622
main :: IO ()
1723
main = do
1824
agdaFiles <- find always
1925
(extension ~~? ".agda" ||? extension ~~? ".lagda")
2026
"src"
2127
nonAsciiChars <-
22-
filter (not . isAscii) . concat <$> mapM U.readFile agdaFiles
28+
filter (not . isAscii) . concat <$> mapM readUTF8File agdaFiles
2329
let table = reverse $
2430
L.sortBy (compare `on` snd) $
2531
map (\cs -> (head cs, length cs)) $
2632
L.group $ L.sort $ nonAsciiChars
27-
mapM_ (\(c, count) -> U.putStrLn (c : ": " ++ show count)) table
33+
mapM_ (\(c, count) -> putStrLn (c : ": " ++ show count)) table

0 commit comments

Comments
 (0)