haskell - “无法加载模块'Control.Monad.State'它是隐藏包'mtl-2.2.2'的成员”使用runhaskell时出错
问题描述
我尝试运行runhaskell InterpretSpec.hs
,然后从中提取Interpret.hs
:
-- Look at how testing is set up in FORTH project and emulate here
-- Make sure you unit test every function you write
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import Pascal.Data
import Pascal.Interpret
import Control.Monad.State
import Data.Map (Map)
import qualified Data.Map as Map
main :: IO ()
main = hspec $ do
let startscope=SymbolTable{variables=Map.empty, global=Map.empty, loop=["notrunning"], functions=Map.empty, procedures=Map.empty, returnstring="", inmain=True}
describe "eval" $ do
it "takes the square root" $ do
evalState (eval(Op1 "sqrt" (Real1 25.0))) startscope `shouldBe` (5.0)
it "takes the cos" $ do
evalState (eval(Op1 "cos" (Real1 0.0))) startscope `shouldBe` (1.0)
it "takes the sin" $ do
evalState (eval(Op1 "sin" (Real1 0.0))) startscope `shouldBe` (0.0)
it "takes the sin" $ do
evalState (eval(Op1 "sin" (Real1 0.0))) startscope `shouldBe` (0.0)
it "takes the sin" $ do
evalState (eval(Op1 "sin" (Real1 0.0))) startscope `shouldBe` (0.0)
mtl 包含在.cabal
文件中,我在以下位置引用了建议的解决方案:
和
也没有解决问题。
解决方案
就其本身而言,runhaskell
不考虑您的阴谋集团环境。您必须通过以下方式使用它cabal exec
:
cabal exec runhaskell InterpretSpec.hs
推荐阅读
- django - 如何在 wagtail/django 中获取一个类别中的项目数?
- bytecode - Jasminbytecode 说它缺少指令 goto 的参数
- java - @Transactional(propagation = Propagation.SUPPORTS) 没有正在进行的事务
- json - 如何在字段值中转义 $
- java - 应用程序关闭后服务内部的功能停止
- angular - NgModules 和 Router Tree 选项卡在 Augury 中不可见
- python - scikit-learn GridSearchCV 返回 ValueError:不支持连续
- javascript - JS Regex - 字符串可以以句点开头/结尾,但不应连续包含多个句点
- python - 在函数内部时调用 FuncAnimation()
- django - 在 Django Rest 框架视图中存储与计算权限