diff options
author | James Crayne <jim.crayne@gmail.com> | 2015-06-22 21:51:59 -0400 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2015-06-22 21:51:59 -0400 |
commit | a4592a399181aa27bde2ff954eb1077735474566 (patch) | |
tree | b383eeca3c78996c3c311491f332a36d7a56dab7 /Codec | |
parent | ceec3fd413272bb47336ef2f7af42e1e44c9cc97 (diff) |
Serialization, refactoring...
Diffstat (limited to 'Codec')
-rw-r--r-- | Codec/LineReady.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Codec/LineReady.hs b/Codec/LineReady.hs index ca2cde3..a6961ca 100644 --- a/Codec/LineReady.hs +++ b/Codec/LineReady.hs | |||
@@ -10,7 +10,7 @@ toLineReady blob = | |||
10 | let as = zip [0..] (B.unpack blob) | 10 | let as = zip [0..] (B.unpack blob) |
11 | bs = filter ((=='\n') . snd) as | 11 | bs = filter ((=='\n') . snd) as |
12 | is = map fst bs | 12 | is = map fst bs |
13 | in B.pack (show is) <> foldl' (replaceCharStrIndex '#') blob is <> B.singleton '\n' | 13 | in B.pack (show is) <> foldl' (replaceCharStrIndex '#') blob is |
14 | 14 | ||
15 | replaceCharStrIndex :: Char -> B.ByteString -> Int -> B.ByteString | 15 | replaceCharStrIndex :: Char -> B.ByteString -> Int -> B.ByteString |
16 | replaceCharStrIndex c str i = a <> B.singleton c <> B.drop 1 b | 16 | replaceCharStrIndex c str i = a <> B.singleton c <> B.drop 1 b |
@@ -20,4 +20,4 @@ fromLineReady :: B.ByteString -> B.ByteString | |||
20 | fromLineReady str = foldl' (replaceCharStrIndex '\n') (B.drop 1 str') is | 20 | fromLineReady str = foldl' (replaceCharStrIndex '\n') (B.drop 1 str') is |
21 | where is = map fst . mapMaybe B.readInt $ | 21 | where is = map fst . mapMaybe B.readInt $ |
22 | B.groupBy (\c d -> (c/=',')&&(d/=',')) ls | 22 | B.groupBy (\c d -> (c/=',')&&(d/=',')) ls |
23 | (ls,str') = B.break (==']') (B.tail str) | 23 | (ls,str') = B.break (==']') (B.drop 1 str) |