Missing `Monad` constraint in Quick Start section of README?
Hi, thanks for this library, it is exactly what I was looking for! When I was mocking effectful code in the past I ended up manually writing a lot of boilerplate in order to create mocks that track how they were called, and always wanted to have an automatic (TH) solution.
I was going through Quick Start, and it says:
Define classes for the functionality you need to mock. To mock anything with HMock, it needs to be implemented using a Monad subclass.
And then you have examples of code:
import Prelude hiding (readFile, writeFile)
import qualified Prelude
class MonadFilesystem m where
readFile :: FilePath -> m String
writeFile :: FilePath -> String -> m ()
instance MonadFilesystem IO where
readFile = Prelude.readFile
writeFile = Prelude.writeFile
copyFile :: MonadFilesystem m => FilePath -> FilePath -> m ()
copyFile a b = readFile a >>= writeFile b
How is that you don't have a Monad constraint in the class MonadFilesystem m where ? I would expect it to be class (Monad m) => MonadFilesystem m where? How would otherwise copyFile infer that it is ok to do >>= (unless it had constraint itself, but it doesn't)?
I am guessing there is a fair chance this is not mistake on your side but a case of me missing something, in which case I would appreciate any help!
Thanks!
No, you're right. There should be a Monad constraint there. I'll update the docs.
Oops, forgot about this. I'll try to do an update this weekend.