lpsmith / postgresql-libpq

Low-level Haskell bindings for libpq
BSD 3-Clause "New" or "Revised" License
19 stars 18 forks source link

Add more Eq and Show instances #4

Closed joeyadams closed 12 years ago

joeyadams commented 12 years ago

Some data types missed the first wave of Eq, Show instance additions (commit 16a7b14), either because I overlooked them, or they were added recently. Show instances are really useful for testing stuff in GHCi. Eq instances make testing a result against a single expected value more convenient (e.g. if status == PQ.ConnectionOk).

The procedure I used to decide what types get Eq and Show instances is:

The decision to give result data types Eq instances is questionable. If the Eq instance is omitted, the user is forced to handle all cases exhaustively (which is good, especially if the API changes in the future!). However, I doubt the API will actually change much, and assuming users stick to comparisons of the form x == NullaryThing (and use case matching for more complex needs), the risk of API changes introducing bugs in peoples' code should be minimal. I went ahead and added the Eq instances.