-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A fast, non-backtracking parser for the redis RESP3 protocol -- -- RESP is redis' serialization protocol. This package provides a -- lightweight and correct parser for RESP3, which can be used -- incrementally (eg. over a network connection). @package resp @version 2.0.0 -- | RESP is the wire protocol that Redis uses. The latest version is -- RESP3, which at time of writing seems relatively complete, but may -- still be evolving. -- -- This module parses the entire RESP3 spec (as of 2024-01-26), but also -- parses some invalid RESP forms that Redis may return, eg `-nan`, and -- parses RESP2 forms that have been removed from the spec (eg -- `$-1\r\n`). module Data.RESP -- | A message from the server (eg. Redis) to the client. This can be a -- push message (for pub/sub), or a reply to a command issued by the -- client. data RespMessage RespPush :: !ByteString -> ![RespExpr] -> RespMessage RespReply :: !RespExpr -> RespMessage -- | RESP3 Expression. -- -- This descriminates the difference between RespString and RespBlob, -- even though both contain bytestrings, in order to not throw away -- information. A caller might care whether the response was delivered -- with "+", or "$". -- -- We do not, however descriminate between the different encodings of -- null. As far as I can tell, these are considered a mistake in the -- previous versions of the RESP spec, and clients should treat the -- different encodings the same. -- -- Why don't we parse RespString into Text? Well, the -- caller might not actually need to decode it into text, and so we let -- the caller decide. This way, we don't have to deal with encoding -- errors. -- -- Similarly, we don't parse a RespMap into a HashMap, -- because that would involve imposing our choice of data structure on -- the caller. The caller might want to use HashMap, Map, -- iterate over the elements, or just use the lookup function. data RespExpr RespString :: !ByteString -> RespExpr RespBlob :: !ByteString -> RespExpr RespStreamingBlob :: !ByteString -> RespExpr RespStringError :: !ByteString -> RespExpr RespBlobError :: !ByteString -> RespExpr RespArray :: ![RespExpr] -> RespExpr RespInteger :: !Int64 -> RespExpr RespNull :: RespExpr RespBool :: !Bool -> RespExpr RespDouble :: !Double -> RespExpr RespVerbatimString :: !ByteString -> RespExpr RespVerbatimMarkdown :: !ByteString -> RespExpr RespBigInteger :: !Integer -> RespExpr RespMap :: ![(RespExpr, RespExpr)] -> RespExpr RespSet :: ![RespExpr] -> RespExpr RespAttribute :: ![(RespExpr, RespExpr)] -> RespExpr -> RespExpr -- | Parse a RESP3 message parseMessage :: Scanner RespMessage -- | Parse a RESP3 expression parseExpression :: Scanner RespExpr instance GHC.Generics.Generic Data.RESP.RespExpr instance GHC.Classes.Ord Data.RESP.RespExpr instance GHC.Classes.Eq Data.RESP.RespExpr instance GHC.Show.Show Data.RESP.RespExpr instance GHC.Generics.Generic Data.RESP.RespMessage instance GHC.Classes.Ord Data.RESP.RespMessage instance GHC.Classes.Eq Data.RESP.RespMessage instance GHC.Show.Show Data.RESP.RespMessage