summaryrefslogtreecommitdiff
path: root/Codec
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2016-04-28 17:25:01 -0400
committerJames Crayne <jim.crayne@gmail.com>2016-04-28 17:25:01 -0400
commit4ec9cc5e6e1c71184c0537fb2fbd4387f27b3ac2 (patch)
tree67b144c4d839cd617cb4a9233b78802ad315f63c /Codec
parente7db95eb413a311dbeddd8bf2474f3710b9258c0 (diff)
remove kikid, moved to separate repo
Diffstat (limited to 'Codec')
-rw-r--r--Codec/LineReady.hs23
1 files changed, 0 insertions, 23 deletions
diff --git a/Codec/LineReady.hs b/Codec/LineReady.hs
deleted file mode 100644
index a6961ca..0000000
--- a/Codec/LineReady.hs
+++ /dev/null
@@ -1,23 +0,0 @@
1module Codec.LineReady where
2
3import qualified Data.ByteString.Char8 as B
4import Data.Monoid
5import Data.List (foldl')
6import Data.Maybe
7
8toLineReady :: B.ByteString -> B.ByteString
9toLineReady blob =
10 let as = zip [0..] (B.unpack blob)
11 bs = filter ((=='\n') . snd) as
12 is = map fst bs
13 in B.pack (show is) <> foldl' (replaceCharStrIndex '#') blob is
14
15replaceCharStrIndex :: Char -> B.ByteString -> Int -> B.ByteString
16replaceCharStrIndex c str i = a <> B.singleton c <> B.drop 1 b
17 where (a,b) = B.splitAt i str
18
19fromLineReady :: B.ByteString -> B.ByteString
20fromLineReady str = foldl' (replaceCharStrIndex '\n') (B.drop 1 str') is
21 where is = map fst . mapMaybe B.readInt $
22 B.groupBy (\c d -> (c/=',')&&(d/=',')) ls
23 (ls,str') = B.break (==']') (B.drop 1 str)