
3 Jun
2018
3 Jun
'18
3:46 a.m.
On Jun 3, 2018, at 3:32 AM, Benjamin Fox
wrote: Here is the counterexample:
instance MonadReader (IORef Int) IO where ask = newIORef 0 local _ = id
This obeys law (1): (newIORef 0 >> newIORef 0) == newIORef 0.
Can you explain what you mean? Prelude> :m + Data.IORef Prelude Data.IORef> let z = 0 :: Int Prelude Data.IORef> a <- newIORef z Prelude Data.IORef> b <- newIORef z Prelude Data.IORef> let c = newIORef z Prelude Data.IORef> let d = newIORef z Prelude Data.IORef> a == b False Prelude Data.IORef> c == d <interactive>:8:1: error: • No instance for (Eq (IO (IORef Int))) arising from a use of ‘==’ • In the expression: c == d In an equation for ‘it’: it = c == d -- Viktor.