[Haskell-beginners] case statement
Imants Cekusins
imantc at gmail.com
Tue Jul 7 10:21:54 UTC 2015
interestingly, the below test fails. May I ask:
If "case" a1 is not the same as "where" a1, what is its value?
Why does x=1 match against a1?
note: result1 indent is aligned with a1 on the previous line
------ test
module TestCase where
import Test.Hspec
main::IO()
main = hspec $ do
describe "TestCase" $ do
it "case 1 - pass" $ do
result1 1 `shouldBe` "one"
it "case 2 - fail" $ do
result1 2 `shouldBe` "two"
where a1 = 2
result1 x = case x of
a1 -> "one"
2 -> "two"
More information about the Beginners
mailing list