Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
esjmb opened this issue Mar 1, 2017 · 0 comments
Open

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

esjmb opened this issue Mar 1, 2017 · 0 comments

Comments

@esjmb
Copy link

esjmb commented Mar 1, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant