informatikr / hedis

A Redis client library for Haskell.
http://hackage.haskell.org/package/hedis
BSD 3-Clause "New" or "Revised" License
329 stars 127 forks source link

Don't allow sending empty lists #44

Closed k-bx closed 1 year ago

k-bx commented 8 years ago

In most APIs, it's an error to send an empty list as an argument. For example:

sadd "test-set" []

This will give you an error. Need to think to either switch to NonEmpty type or to skip empty lists somehow. Skipping is problematic since current API is exposing too much to a user, it returns a type corresponding to a redis-response, while I think it would be more logical to only return a success response, throwing exception (or skipping error) in other case.

andyfriesen commented 8 years ago

I agree that this case should always suceed. Other solutions require every callsite to handle empty sequences in some way, which just isn't useful.

We use hedis at imvu.com and we've baked this behaviour into a layer that we have just above Hedis.

k0001 commented 8 years ago

I agree this is required. I was bitten by this too just now:

> runRedis conn (del [])
Left (Error "ERR wrong number of arguments for 'del' command")
k0001 commented 8 years ago

I favor switching to NonEmpty, by the way.