compilation of pattern-matching?

Claus Reinke claus.reinke at
Mon Mar 23 19:16:42 EDT 2009

I just noticed that GHC (6.11.20090320) seems to compile both

f (a:b:c) =
f (a:[]) = 
f [] = 


f [] = 
f (a:[]) = 
f (a:b:c) =

to something like (looking at Core, but writing source)

f x = case x of { [] -> ..; (a:t) -> case t of { [] ->..; (b:c) ->..}}

That doesn't seem right to me: if I try to give the patterns in
the order from frequent to rare, in order to reduce jumps, I
don't expect GHC to rearrange things. What is the rationale
for this? And where can I read about GHC's pattern match
compilation approach in general?


More information about the Glasgow-haskell-users mailing list