From 2966db997f43c063389285ddc40579acad5c6a29 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Mon, 22 Jun 2015 18:58:47 -0400 Subject: kikid: Serialization... --- Codec/SafeBlob.hs | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Codec/SafeBlob.hs (limited to 'Codec/SafeBlob.hs') diff --git a/Codec/SafeBlob.hs b/Codec/SafeBlob.hs deleted file mode 100644 index a6db80e..0000000 --- a/Codec/SafeBlob.hs +++ /dev/null @@ -1,22 +0,0 @@ -{-# LANGUAGE ViewPatterns #-} -module Codec.SafeBlob where - -import qualified Data.ByteString.Char8 as B -import Data.Monoid -import Data.List (foldl') -import Data.Maybe - -toSafe :: B.ByteString -> B.ByteString -toSafe 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 - -replaceCharStrIndex :: Char -> B.ByteString -> Int -> B.ByteString -replaceCharStrIndex c str i = a <> B.singleton c <> b - where (a,B.uncons -> Just (_,b)) = B.splitAt i str - -fromSafe 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) -- cgit v1.2.3