
John Meacham wrote:
I was wondering if:
case x of "foo" -> Foo "bar" -> Bar "fuzz" -> Fuzz "fuzo" -> Fuzo x -> other .. thing
would optimize to
let z = other .. thing in case x of ('f':x) -> case x of ('u':'z': x) -> "z" -> Fuzz "o" -> Fuzo _ -> z "oo" -> Foo _ -> z "bar" -> Bar _ -> z
String literals are handled in a special way in GHC, so your example is essentially converted into an if-cascade, which is not what you want. OTOH, if you write the strings in their expanded form like ['f','o','o'], you get your optimized version automatically. Perhaps Simon^2 can comment on the rationale behind this, I can't remember the reason... Cheers, S.