2

I tried running runhaskell InterpretSpec.hs, which then pulls from Interpret.hs this:

-- 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:

and

and neither solves the issue.

duplode
  • 33,731
  • 7
  • 79
  • 150
  • 1
    Consider using stack. –  Mar 30 '20 at 23:51
  • 2
    @MichaelLitchard Using bare `runhaskell` on a Stack project would likely fail in the same way. The solution would then be using `stack runghc`, which is analogous to `cabal exec runhaskell`. – duplode Mar 31 '20 at 00:02
  • 6
    It's odd to me how often that type of response happens these days. "I've no advice on your tooling, use another tooling on which I might help." It seems unproductive and likely head-spinning to the asker. – Thomas M. DuBuisson Mar 31 '20 at 00:20

1 Answers1

3

On its own, runhaskell doesn't account for your cabal environment. You have to use it through cabal exec:

cabal exec runhaskell InterpretSpec.hs
duplode
  • 33,731
  • 7
  • 79
  • 150