randomChoice :: MonadIO m => [a] -> m a
randomChoice xs
  | maxIndex < 0 = (liftIO . throwIO) (ErrorCall "randomChoice: empty list")
  | otherwise = (xs !!) `liftM` (liftIO . randomRIO) (0, maxIndex)
  where
    maxIndex = pred (length xs)
randomChoice :: MonadIO m => [a] -> m a
randomChoice xs
  | maxIndex < 0 = (liftIO . throwIO) (ErrorCall "randomChoice: empty list")
  | otherwise = (xs !!) `liftM` (liftIO . randomRIO) (0, maxIndex)
  where
    maxIndex = pred (length xs)
randomChoice xs
  | maxIndex < 0 = (liftIO . throwIO) (ErrorCall "randomChoice: empty list")
  | otherwise = (xs !!) `liftM` (liftIO . randomRIO) (0, maxIndex)
  where
    maxIndex = pred (length xs)