Hi,
Using LambdaCase extension, you can write something quite elegant:
{-# LANGUAGE LambdaCase #-}
f :: Int -> IO String
f x = getDBRecord x >>= \case
dbOutput
| null dbOutput -> return "no db record"
| otherwise -> return "we got some db records"
Or better:
f :: Int -> IO String
f x = getDBRecord x >>= \case
[] -> return "no db record"
_ -> return "we got some db records"
But you can also use another function for the pure part:
recordMsg :: [a] -> String
recordMsg [] = "no db record"
recordMsg _ = "we got some db records"
f :: Int -> IO String
f = fmap recordMsg . getDBRecord
Regards,
Sylvain