-
-
Save esmooov/c3db0a27610d87a9a56e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment