
Yitzchak Gale wrote:
OK. Here's a simplified real-world example. Say you want to write a simple library that interfaces the text-to-speech facilities available on multiple platforms. To play nicely with programs written in a monadic style, the interface might be something like:
class MonadIO m => Speech m where sayText :: String -> m () runSpeech :: m a -> IO a
You meant ma -> m a here, right?
instance Speech SomeSpeechSystem where sayText t = ... runSpeech x = do liftIO startSomeSpeechSystem ret <- x liftIO stopSomeSpeechSystem return ret
I think MonadIO is the wrong type class here. For example, ListT IO is an instance of MonadIO, and may cause stopSomeSpeechSystem to be never called, or several times, per startSomeSpeechSytem call, which is clearly not what you wanted (this is still true for the 'ListT done right' versions of ListT). ContT should also be interesting.
But the proposal here is to raise the exception in a common situation that will definitely occur in regular usage. That may be fine in Java or Python, but it is a bad idea for IO exceptions in Haskell.
I agree with that though. regards, Bertram