Skip to content

MultiWayIf should start a new layout

Currently, MultiWayIf doesn't fully replace old case () of _ form. This outputs 3:

{-# LANGUAGE MultiWayIf #-}
x = case () of
    _ | False -> case () of
                _ | False -> 1
                  | False -> 2
      | True -> 3

main = print (x :: Int)

but this errors out:

{-# LANGUAGE MultiWayIf #-}
x = if | False -> if | False -> 1
                     | False -> 2
       | True -> 3

main = print (x :: Int)

because it parses like this:

x = if | False -> if | False -> 1
                     | False -> 2
                     | True -> 3

Every other syntax introducing guards starts a layout; MultiWayIf's current behavior leads to subtle logic bugs for those unaware that MultiWayIf is special.

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information