informatikr/hedis — pull request #13 by k-bx (2014-03-16 22:14:39+00:00)
Title: Switch to semigroups Data.List.NonEmpty

Hi!

I had quite a long debug-session 2 days ago before I figured out what exactly happened. Consider this piece of code:

```
{-# LANGUAGE OverloadedStrings #-}

import Database.Redis

main :: IO ()
main = do
redis <- connect defaultConnectInfo
putStrLn "Will try to add empty list into set not inside transaction"
res <- runRedis redis $ do
sadd "test-set" []
putStrLn "Done."
putStrLn $ "res: " ++ show res
putStrLn "Will try to add empty list into set inside transaction"
runRedis redis $ multiExec $ do
sadd "test-set" []
putStrLn "Success"
```

Output it produces is this:

```
➜ hedis-sadd-empty ./dist/build/hedis-sadd-empty/hedis-sadd-empty
Will try to add empty list into set not inside transaction
Done.
res: Left (Error "ERR wrong number of arguments for 'sadd' command")
Will try to add empty list into set inside transaction
hedis-sadd-empty: hedis: EXEC returned Error "EXECABORT Transaction discarded because of previous errors."
```

So, as you can see, first case is OK more or less since it just returns Left which you can skip, but if you do `sadd` with empty list inside transaction, that is kind of a disaster (runtime exception with no good hint). But of course even first case is not good also.

With this PR I propose to use `Data.List.NonEmpty` from `semigroups` package to explicitly state that argument we want should be non-empty list. I think this would improve hedis's safety quite a bit.

I know this change is quite massive API change, but I having this kind of guarantee that your code will not misbehave is much more important.

Thanks!