I'm writing hspec test suite which uses binding as follows:
it "should take the x component" $ do
(getX $ coord $ [1,0,2]) `shouldBe` 1
However, for more complicated statement, one-liner is not conveniently readable so I try to strip the variable out in where expression:
it "should take the x component" $ do
(getX c) `shouldBe` 1
where c = coord $ [1,0,2]
But this turns out illegal statement in Haskell. Using let does not succeed either.
it "should take the x component" $ do
let c = coord $ [1,0,2]
in (getX c) `shouldBe` 1
How can I assign a helper variable for the same purpose as let or where within do binding? Exploring the documentations but can't find a good example though.