Closed mheinzel closed 4 years ago
Thanks!
Tricky issue. There's a heuristic trying to figure out the operator precedence, which gets confused when the same operator is used in two different ways. In this case, (.)
is both used as the beginning of a line which suggests lower associativity, but then used inline which suggests the opposite. So the heuristic can not decide consistently.
One solution I can think of is to try to decide on the operator precedence just according to the first use of that specific operator instead of averaging all uses. But this might also have another set of corner cases.
I'll spend some time thinking about it.
Another example:
foo n
| x || y && z || n ** x
|| x && n =
42
Another example from Idris:
prettyBv env op sc n t v debug =
text op <> pretty n <+> colon <+> prettySe 10 env t debug <+> text "=" <+>
prettySe 10 env v debug <> text sc
Yet another example form Idris:
prettyPs all g bnd ((n, _, Let rig t v) : bs) =
line <> bindingOf n False <+> text "=" <+> tPretty bnd v <+> colon <+>
align (tPretty bnd t) <> prettyPs all g ((n, False):bnd) bs
I saw https://github.com/tweag/ormolu/issues/451, but there is a related PR that claims to solve the issue.
Minimal example:
first turns into
and then
Version: