-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add From/ToFieldValue classes #78
Comments
Thanks for this code. I'm open to adding it, but I'm unsure about the use-case. In what situations do you need to construct non-trivial field-tables? |
I just see this as a tool not to have to think about types and let the compiler do the thinking instead, regardless if the table is trivial or not. In our use case we transport quite a bit of information in header fields to be able to use header exchanges. |
I think I see the appeal. But it's not clear to me whether some of the assumptions your code makes are generally good; for example your code decodes a So, I'm not opposed to adding this; I'm just not sure how exactly it should behave. We can keep this issue open and see if other people have a need for this. |
I'm exactly with you on Int and Double - I just didn't have the time to take care of variants I didn't need. If you think this is worth adding we should decide on the following points
|
Integers could look like this
and this
|
I made the run-time check on I personally would avoid using Currently |
You raise some good questions, and I'm myself not sure about some of them. For example, dynamically deciding whether Overall, I'm still unsure whether this should go into the library, and I'd suggest we wait if other people have a similar need. Right now, my guess would be that you would be the only user ever using that functionality, but I might be wrong. So if you still want to work on it and create a pull-request, I'd merge it. |
Ah, no need to hurry, let's wait for other opinions - I would not want to push something into your library you are not fully confident with. I'm just used to providing such classes - the first time I have to think about which FV.. constructor I need is the the exact moment I think 'I should be able to write toXyz' here and the 2 classes emerge... does not mean it's the only way (or even a good way) for that matter... Your thoughts on (in)deterministic behaviour are completely valid, and as a library developer you have to take care to cater for different needs. I on the other hand in this case am a library user and therefore am (almost exclusively) concerned with the system I use it for, hence the different approaches. |
There is one additional point: back in the '80s developers used to save memory by packing values in as few bits/bytes as possible, even using single bits for booleans and 2 or 3 bits for small enums. With the every increasing memory capacity of modern computers the pressure to use the smallest possible int representation has decreased to the point where we usually don't give it thought at all. RabbitMQ on the other hand is used for messaging, so header field values directly contribute not only to memory footprint but also network bandwidth - for people wanting to send gazillions of messages in the shortest possible time reducing bandwidth may be more valuable than cpu cycles, so packing integral values into the smallest possible FVInt8/16/32/64 is a valid approach. For a generic library like this it's hard to satisfy all these contradictory requirements (short of providing multiple different implementations for the user to select) - I've come to think this might better be left out of the lib for the user to do what's best for his/her project. |
I think if somebody needed that kind of control about network bandwidth and performance, they probably wouldn't be using Haskell in the first place ;) |
Thanx again for your AMQP library!
Here is something I added to my client which you might find useful:
This relies on classes
From/ToFieldValue
:and
The integer handling could definitely be improved but this is all I needed for the moment.
Please feel free to add this to your AMQP library if you think it is useful.
The text was updated successfully, but these errors were encountered: