lspitzner / brittany

haskell source code formatter
GNU Affero General Public License v3.0
690 stars 72 forks source link

Justification of infix patterns #289

Open expipiplus1 opened 4 years ago

expipiplus1 commented 4 years ago

I know this would require knowing the fixity of patterns, nevertheless:

It would be nice if brittany would left or right justify patterns as appropriate depending on their associativity direction. For instance (given infixr :)

Currently brittany formats thusly, which at a glance implies : associates to the left

baz :: [a] -> Int
baz = \case
  _ : _ : _ -> 0
  _     : _ -> 0

Perhaps it would be nicer to format as

baz :: [a] -> Int
baz = \case
  _ : _ : _ -> 0
  _ : _      -> 0

or even

baz :: [a] -> Int
baz = \case
  _ : _ : _ -> 0
  _ :   _   -> 0

This is a very minor issue!

tfausak commented 4 years ago

This is similar to #79 and #85 except that it deals with patterns rather than expressions.