[Haskell-cafe] How come pattern match does not recognize this code style?

Daniel Fischer daniel.is.fischer at web.de
Sun Oct 25 23:27:26 EDT 2009


Am Montag 26 Oktober 2009 03:39:13 schrieb Magicloud Magiclouds:
> Hi,
>   In case of this:
> case bala of
>   [ bala
>   , bala
>   , bala ] -> bala bala bala
>   _ -> bala
>   ghc 6.10.4 would fail to compile, because of the wrong indent of
> line ", bala".

Yes. It must, because the `of' opens a new layout block, so a line indented to the same 
level as the opening square bracket starts a new definition and it tries to parse it as

case bala of
    { [ bala;
      , bala;
      , bala ] -> bala bala bala;
      _ -> bala;
    }

What about

case bala of
    [ bala, bala, bala ]
        -> bala bala bala
    _ -> bala

?


More information about the Haskell-Cafe mailing list