optimization question

John Meacham john at repetae.net
Sun Feb 22 00:20:35 EST 2004


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

The reason I ask is I am writing someting which will generate large case
statements like the first form and want to know if I should bother
pre-optimizing it to the second.
        John

-- 
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john at foo.net
---------------------------------------------------------------------------


More information about the Glasgow-haskell-users mailing list