diff options
Diffstat (limited to 'Codec/LineReady.hs')
-rw-r--r-- | Codec/LineReady.hs | 23 |
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 @@ | |||
1 | module Codec.LineReady where | ||
2 | |||
3 | import qualified Data.ByteString.Char8 as B | ||
4 | import Data.Monoid | ||
5 | import Data.List (foldl') | ||
6 | import Data.Maybe | ||
7 | |||
8 | toLineReady :: B.ByteString -> B.ByteString | ||
9 | toLineReady 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 | |||
15 | replaceCharStrIndex :: Char -> B.ByteString -> Int -> B.ByteString | ||
16 | replaceCharStrIndex c str i = a <> B.singleton c <> B.drop 1 b | ||
17 | where (a,b) = B.splitAt i str | ||
18 | |||
19 | fromLineReady :: B.ByteString -> B.ByteString | ||
20 | fromLineReady 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) | ||