1import qualified Streamly.Prelude as S
2import qualified Streamly.Data.Fold as FL
3import qualified Streamly.Memory.Array as A
5import qualified Streamly.Internal.Data.Fold as FL
6import qualified Streamly.Internal.Prelude as IP
7import qualified Streamly.Internal.FileSystem.File as File
10import System.Environment (getArgs)
12cat :: FilePath -> IO ()
14 File.fromChunks "/dev/stdout"
15 $ File.toChunksWithBufferOf (256*1024) src
17cp :: FilePath -> FilePath -> IO ()
20 $ File.toChunksWithBufferOf (256*1024) src
22append :: FilePath -> FilePath -> IO ()
25 $ File.toChunksWithBufferOf (256*1024) src
27ord' :: Num a => Char -> a
28ord' = (fromIntegral . ord)
30wcl :: FilePath -> IO ()
31wcl src = print =<< (S.length
32 $ S.splitOnSuffix (== ord' '\n') FL.drain
35grepc :: String -> FilePath -> IO ()
36grepc pat src = print . (subtract 1) =<< (S.length
37 $ IP.splitOnSeq (A.fromList (map ord' pat)) FL.drain
40avgll :: FilePath -> IO ()
41avgll src = print =<< (S.fold avg
42 $ S.splitOnSuffix (== ord' '\n') FL.length
44 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
45 toDouble = fmap (fromIntegral :: Int -> Double)
47llhisto :: FilePath -> IO ()
48llhisto src = print =<< (S.fold (FL.classify FL.length)
50 $ S.splitOnSuffix (== ord' '\n') FL.length
53 bucket n = let i = n `mod` 10 in if i > 9 then (9,n) else (i,n)
57 src <- fmap head getArgs
59 putStrLn "cat" >> cat src -- Unix cat program
60 putStr "wcl " >> wcl src -- Unix wc -l program
61 putStr "grepc " >> grepc "aaaa" src -- Unix grep -c program
62 putStr "avgll " >> avgll src -- get average line length
63 putStr "llhisto " >> llhisto src -- get line length histogram
64 putStr "cp " >> cp src "dst-xyz.txt" -- Unix cp program
65 putStr "append " >> append src "dst-xyz.txt" -- Appending to file
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list