compilation of pattern-matching?

Lennart Augustsson lennart at augustsson.net
Mon Mar 23 19:37:12 EDT 2009


How could you match the first case with less than two case constructs?
There are two (:) to check for, so I'm not sure what you are complaining about.

  -- Lennart


On Tue, Mar 24, 2009 at 12:16 AM, Claus Reinke <claus.reinke at talk21.com> wrote:
> I just noticed that GHC (6.11.20090320) seems to compile both
>
> f (a:b:c) =
> f (a:[]) = f [] =
> and
> 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?
>
> Claus
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>


More information about the Glasgow-haskell-users mailing list