Skip to content

Issue with Data Structure of form: A | B Y Z #8

Description

@esjmb

Hi,
I have noticed an odd error in a derived instance of FromBSON (and possibly ToBSON) for a type with a particular structure. I illustrate below.

type Token = ByteString
type Secret = ByteString
data RateLimiting = NoLimiting | AnonLimiting | AuthorizedLimiting Token Secret
                     deriving (Eq, Ord, Read, Show, Generic, Typeable, Hashable, Binary, NFData)

ToBSON seems to work ok, the following being an example of what is generated (ie. show $ toBSON x):

[ : [ ByteString: Binary "jdfjf3j4jh3jh4"], : [ ByteString: Binary "jhj34j300"], _co: "AuthorizedLimiting"]

(I've changed the contents of each binary string value, but note that they are stored correctly). However, I note that the two name-value elements of AuthorizedLimiting both have an empty name.

If FromBSON is called on this BSON document, then what results is an instance of AuthorizedLimiting with both token and secret bytestrings set to the value associated with the first name-value pair.

A possible fix I guess might be to explicitly name the token and secret in the declaration, but I thought I'd raise this with you first, as I guess this is an example of a failure to correctly generate or extract from BSON.

thanks,
Stephen.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions