-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could monadIOLaws ever be used? #12
Comments
This is true. However, orphan instances are often common in test suites. That, or a newtype around the transformer which is given an Eq instance. One could use unsafePerformIO here, which is safe here (not generally, but in the case of running tests with hedgehog-classes it should be) |
But my point is you can't write an |
newtype EqIO a = EqIO (IO a)
instance Eq a => Eq (EqIO a) where
EqIO x == EqIO y = unsafePerformIO $ do
xVal <- x
yVal <- y
pure $ x == y This is what I was suggesting |
Ok, but now your |
That makes sense. That Eq instance is pretty lousy in lots of concurrent/asynchronous/transactional situations. I'm not really sure if it (monadIOLaws) should be removed, because you could be testing types that don't include any such computations. At the very least this should be documented, at worst monadIOLaws should be removed. |
I think it should be removed. |
To have a law-abiding
MonadIO
means that your monad must be at least as powerful asIO
- ie, be a transformer overIO
. Such a monad won't have a meaningfulEq
instance, becauseIO
has noEq
instance. CanmonadIOLaws
actually ever be used?The text was updated successfully, but these errors were encountered: