"Could not load module ‘Control.Monad.State’ It is a member of the hidden package ‘mtl-2.2.2’" 使用 runhaskell 时出错
"Could not load module ‘Control.Monad.State’ It is a member of the hidden package ‘mtl-2.2.2’" error upon using 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
文件中,我在以下位置引用了建议的解决方案:
- Could not find module `Control.Monad.State` after updating mtl
和
- Could not find module ‘Control.Monad.State’ even though mtl is installed
都没有解决问题。
就其本身而言,runhaskell
并不能说明您的 cabal 环境。你必须 use it through cabal exec
:
cabal exec runhaskell InterpretSpec.hs
我尝试了 运行 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
文件中,我在以下位置引用了建议的解决方案:
- Could not find module `Control.Monad.State` after updating mtl
和
- Could not find module ‘Control.Monad.State’ even though mtl is installed
都没有解决问题。
就其本身而言,runhaskell
并不能说明您的 cabal 环境。你必须 use it through cabal exec
:
cabal exec runhaskell InterpretSpec.hs