@@ -1,7 +1,8 @@
1import qualified Streamly.Prelude as S
1import qualified Streamly.Prelude as S
2−import qualified Streamly.Fold as FL
2+import qualified Streamly.Data.Fold as FL
3import qualified Streamly.Memory.Array as A
3import qualified Streamly.Memory.Array as A
4−import qualified Streamly.FileSystem.File as File
4+import qualified Streamly.Internal.Prelude as IP
5+import qualified Streamly.Internal.FileSystem.File as File
6import Data.Char (ord)
7import Data.Char (ord)
7import System.Environment (getArgs)
8import System.Environment (getArgs)
@@ -20,25 +21,25 @@ ord' = (fromIntegral . ord)
21wcl :: FilePath -> IO ()
22wcl :: FilePath -> IO ()
22wcl src = print =<< (S.length
23wcl src = print =<< (S.length
23− $ FL.splitSuffixBy (== ord' '\n') FL.drain
24+ $ S.splitOnSuffix (== ord' '\n') FL.drain
24 $ File.read src)
25 $ File.read src)
26grepc :: String -> FilePath -> IO ()
27grepc :: String -> FilePath -> IO ()
27grepc pat src = print . (subtract 1) =<< (S.length
28grepc pat src = print . (subtract 1) =<< (S.length
28− $ FL.splitOn (A.fromList (map ord' pat)) FL.drain
29+ $ IP.splitOnSeq (A.fromList (map ord' pat)) FL.drain
29 $ File.read src)
30 $ File.read src)
31avgll :: FilePath -> IO ()
32avgll :: FilePath -> IO ()
32−avgll src = print =<< (FL.foldl' avg
33+avgll src = print =<< (S.runFold avg
33− $ FL.splitSuffixBy (== ord' '\n') FL.length
34+ $ S.splitOnSuffix (== ord' '\n') FL.length
34 $ File.read src)
35 $ File.read src)
35 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
36 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
36 toDouble = fmap (fromIntegral :: Int -> Double)
37 toDouble = fmap (fromIntegral :: Int -> Double)
38llhisto :: FilePath -> IO ()
39llhisto :: FilePath -> IO ()
39−llhisto src = print =<< (FL.foldl' (FL.classify FL.length)
40+llhisto src = print =<< (S.runFold (FL.classify FL.length)
40 $ S.map bucket
41 $ S.map bucket
41− $ FL.splitSuffixBy (== ord' '\n') FL.length
42+ $ S.splitOnSuffix (== ord' '\n') FL.length
42 $ File.read src)
43 $ File.read src)
44 bucket n = let i = n `div` 10 in if i > 9 then (9,n) else (i,n)
45 bucket n = let i = n `div` 10 in if i > 9 then (9,n) else (i,n)