I'm trying acid-state
. The documentation states that Update st
is an instance of MonadState st
. I tried different things, but my compiler doesn't want to see that :( I tried the HelloWorld.hs
from examples, but got the same issue:
HelloWorld.hs:26:7:
No instance for (MonadState
HelloWorldState (Update HelloWorldState))
arising from a use of `put'
Possible fix:
add an instance declaration for
(MonadState HelloWorldState (Update HelloWorldState))
In the expression: put (HelloWorldState newValue)
In an equation for `writeState':
writeState newValue = put (HelloWorldState newValue)
HelloWorld.hs:29:43:
No instance for (MonadReader
HelloWorldState (Query HelloWorldState))
arising from a use of `ask'
Possible fix:
add an instance declaration for
(MonadReader HelloWorldState (Query HelloWorldState))
In a stmt of a 'do' block: HelloWorldState string <- ask
In the expression:
do { HelloWorldState string <- ask;
return string }
In an equation for `queryState':
queryState
= do { HelloWorldState string <- ask;
return string }
What I'm doing wrong? How to make it work?
I'm using
acid-state-0.6.4
,
ghc-7.4.2
,
debian-6.0.5
(amd64)
Thanks, Yuras
ADDED: Looks like it works in ghc-7.4.1 and doesn't work in ghc-7.4.2. Could anybody both compilers?
I tried reinstalling acid-state, but it didn't help. Either a bug in ghc-7.4.2 or my environment id broken.
Ok, I finally solved it.
The issue was with two different mtl
versions installed. Hiding the wrong one fixed everything.
The interesting part is how I got it :)
Prelude Data.Acid Control.Monad.State> :i Update
newtype Update st a
= acid-state-0.6.4:Data.Acid.Common.Update {acid-state-0.6.4:Data.Acid.Common.unUpdate :: transformers-0.2.2.0:Control.Monad.Trans.State.Lazy.State
st a}
-- Defined in `acid-state-0.6.4:Data.Acid.Common'
instance Monad (Update st)
-- Defined in `acid-state-0.6.4:Data.Acid.Common'
instance Functor (Update st)
-- Defined in `acid-state-0.6.4:Data.Acid.Common'
Prelude Data.Acid Control.Monad.State>
Control.Monad.State
reexports State
, but you can see that ghci still shows transformers-0.2.2.0:Control.Monad.Trans.State.Lazy.State
fully qualified.