From a4592a399181aa27bde2ff954eb1077735474566 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Mon, 22 Jun 2015 21:51:59 -0400 Subject: Serialization, refactoring... --- Codec/LineReady.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Codec/LineReady.hs') 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 = let as = zip [0..] (B.unpack blob) bs = filter ((=='\n') . snd) as is = map fst bs - in B.pack (show is) <> foldl' (replaceCharStrIndex '#') blob is <> B.singleton '\n' + in B.pack (show is) <> foldl' (replaceCharStrIndex '#') blob is replaceCharStrIndex :: Char -> B.ByteString -> Int -> B.ByteString replaceCharStrIndex c str i = a <> B.singleton c <> B.drop 1 b @@ -20,4 +20,4 @@ fromLineReady :: B.ByteString -> B.ByteString fromLineReady str = foldl' (replaceCharStrIndex '\n') (B.drop 1 str') is where is = map fst . mapMaybe B.readInt $ B.groupBy (\c d -> (c/=',')&&(d/=',')) ls - (ls,str') = B.break (==']') (B.tail str) + (ls,str') = B.break (==']') (B.drop 1 str) -- cgit v1.2.3