简体   繁体   English

使用runhaskell时出现“无法加载模块'Control.Monad.State'它是隐藏包'mtl-2.2.2'的成员”错误

[英]"Could not load module ‘Control.Monad.State’ It is a member of the hidden package ‘mtl-2.2.2’" error upon using runhaskell

I tried running runhaskell InterpretSpec.hs , which then pulls from Interpret.hs this:我尝试运行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 is included in the .cabal file, and I've referenced the suggested solutions at: mtl 包含在.cabal文件中,我在以下位置引用了建议的解决方案:

and

and neither solves the issue.并且都不能解决问题。

On its own, runhaskell doesn't account for your cabal environment.就其本身而言, runhaskell不考虑您的阴谋集团环境。 You have to use it through cabal exec :您必须通过cabal exec使用它

cabal exec runhaskell InterpretSpec.hs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM