Haskell acid状态示例错误
我正试图开始在项目中使用Haskell acid状态示例错误,haskell,compiler-errors,acid-state,Haskell,Compiler Errors,Acid State,我正试图开始在项目中使用acid state,但在运行演示时遇到了问题 从我的64位框上运行会显示错误 acid-state.hs:26:7: No instance for (MonadState HelloWorldState (Update HelloWorldState)) arising from a use of `put' Possible fix: add an instance declara
acid state
,但在运行演示时遇到了问题
从我的64位框上运行会显示错误
acid-state.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)
acid-state.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 }
酸性状态。hs:26:7:
(MonadState)没有实例
HelloWorldState(更新HelloWorldState))
因使用“put”而产生的
可能的解决方案:
为添加实例声明
(MonadState HelloWorldState(更新HelloWorldState))
在表达式中:put(HelloWorldState newValue)
在“WriteEstate”的方程式中:
WriteEstate newValue=put(HelloWorldState newValue)
酸性状态。hs:29:43:
没有(恐怖分子)的例子
HelloWorldState(查询HelloWorldState))
由“ask”的用法引起的
可能的解决方案:
为添加实例声明
(Monader HelloWorldState(查询HelloWorldState))
在'do'块的stmt:HelloWorldState string中,这与您运行的体系结构完全无关(很抱歉得出结论)
原来我安装了一些错误的配置,或者可能是一些冲突的cabal
库。清除my.ghc
,然后重新安装相应的库,这样做是成功的。如果您使用Debian或类似软件:
rm -r ~/.ghc/*
cabal install acid-state
这个问题和您之前的一个问题(都是导入monad transformer实例的问题)让我觉得您/Debian的haskell平台安装有问题。可能无用的建议:(1)运行ghc pkg检查,(2)cabal安装hsenv
,创建一个新的项目目录和hsenv,cabal更新和&cabal安装cabal
,cabal更新
,与新cabal一起(0.16),最后是cabal安装acid state hapstack服务器
。我可以确认HelloWorld.hs
代码示例使用Debian打包的东西编译得很好。因此,可以尝试rm-rf~/.ghc
并安装libghc acid state dev
,避免自己编译任何库。