case x of { "a" -> 1; "b" -> 2}

はうまくいくのに

str1 = "a"
str2 = "b"
case x of { str1 -> 1; str2 -> 2}

は、str1,str2がwildcardとみなされ、意図通りに動きません。
caseのpatternに変数を使う方法はないでしょうか?

ちなみに意図しているのは、以下と等価な動作です。

if x == str1 then 1 else if x == str2 then 2 else error ""