hspec do块中的“ where”给出语法问题

时间:2018-10-06 18:24:15

标签: haskell syntax hspec

我正在hspec中为QTextEdit函数运行Haskell测试。测试如下:

zipWith3

这按预期工作。但是,如果我将main = hspec $ do ... some tests ... describe "#zipWith3" $ do it "zipWith but 3-ary" $ do let f x y z = x + y + z zipWith3 f [1,2] [4,5,6] [7,8,9] `shouldBe` [12,15] ... other tests ... 绑定更改为let绑定,就像这样:

where

然后我得到main = hspec $ do ... some tests ... describe "#zipWith3" $ do it "zipWith but 3-ary" $ do zipWith3 f [1,2] [4,5,6] [7,8,9] `shouldBe` [12,15] where f x y z = x + y + z ... other tests ... 。然后,如果我删除后续测试,则测试通过。因此,有关Chapter7Spec.hs:134:3:error: parse error on input ‘describe’绑定的内容会干扰后续的where块。但是我不知道。我很高兴以describe的方式编写它,但我想知道:为什么let会产生这种行为?

0 个答案:

没有答案