Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Synopsis
- data RespReply
- = RespPush !ByteString ![RespExpr]
- | RespExpr !RespExpr
- data RespExpr
- = RespString !ByteString
- | RespBlob !ByteString
- | RespStreamingBlob !LazyByteString
- | RespStringError !ByteString
- | RespBlobError !ByteString
- | RespArray ![RespExpr]
- | RespInteger !Int64
- | RespNull
- | RespBool !Bool
- | RespDouble !Double
- | RespVerbatimString !ByteString
- | RespVerbatimMarkdown !ByteString
- | RespBigInteger !Integer
- | RespMap ![(RespExpr, RespExpr)]
- | RespSet ![RespExpr]
- | RespAttribute ![(RespExpr, RespExpr)] RespExpr
- parseReply :: Scanner RespReply
- parseExpression :: Scanner RespExpr
Documentation
Top-level resp reply. Cannot be nested.
Instances
Generic RespReply Source # | |
Show RespReply Source # | |
Eq RespReply Source # | |
Ord RespReply Source # | |
Defined in Data.RESP | |
type Rep RespReply Source # | |
Defined in Data.RESP type Rep RespReply = D1 ('MetaData "RespReply" "Data.RESP" "resp-1.0.0-LYF9uNboG4jCMPZqHytGRd" 'False) (C1 ('MetaCons "RespPush" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [RespExpr])) :+: C1 ('MetaCons "RespExpr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RespExpr))) |
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.
They might want to use HashMap
, Map
, or just use the lookup
function.
Given these choices, our purview is simple: Parse the text protocol into a Haskell datatype, maintaining all useful information, and not imposing our taste onto the caller.