File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
-- | This module extracts all the non-ASCII characters used by the
2
2
-- library code (along with how many times they are used).
3
3
--
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.
6
6
7
7
module AllNonAsciiChars where
8
8
9
9
import qualified Data.List as L
10
10
import Data.Char
11
11
import Data.Function
12
12
import Control.Applicative
13
- import System.IO.UTF8 as U
14
13
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
15
21
16
22
main :: IO ()
17
23
main = do
18
24
agdaFiles <- find always
19
25
(extension ~~? " .agda" ||? extension ~~? " .lagda" )
20
26
" src"
21
27
nonAsciiChars <-
22
- filter (not . isAscii) . concat <$> mapM U. readFile agdaFiles
28
+ filter (not . isAscii) . concat <$> mapM readUTF8File agdaFiles
23
29
let table = reverse $
24
30
L. sortBy (compare `on` snd ) $
25
31
map (\ cs -> (head cs, length cs)) $
26
32
L. group $ L. sort $ nonAsciiChars
27
- mapM_ (\ (c, count) -> U. putStrLn (c : " : " ++ show count)) table
33
+ mapM_ (\ (c, count) -> putStrLn (c : " : " ++ show count)) table
You can’t perform that action at this time.
0 commit comments