secret
Created

  • Download Gist
parsecon.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
repParse !input (!st,Nothing) = case result of
(Partial parser) -> (st,Just parser)
(Done !res "") -> (res:st,Just (\input -> Done RDBNull input))
(Done !res !leftover) -> repParse leftover (res:st,Nothing)
where
!result = runGetPartial getObjInc input
 
repParse !input (!st,Just parser) = case result of
(Partial parser) -> (st,Just parser)
(Done !res "") -> (res:st,Just (\input -> Done RDBNull input))
(Done !res !leftover) -> repParse leftover (res:st,Nothing)
where
!result = parser input
 
printRDB :: ResourceIO m => Sink B8.ByteString m ()
printRDB =
sinkState Nothing
pushRDB
(\state -> return ())
 
pushRDB Nothing !input = do liftIO $ mapM_ (\x -> if x == RDBNull then return () else print x) st
return $ StateProcessing p
where
(Done r l) = runGetPartial (getBytes 9) input
(!st,!p) = repParse l ([],Nothing)
 
pushRDB (Just parser) !input = do liftIO $ mapM_ (\x -> if x == RDBNull then return () else print x) st
return $ StateProcessing p
where
(!st,!p) = repParse input ([],Just parser)
 
 
main = do
runResourceT $ C.sourceFile "./dump.rdb" $$ printRDB

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.