org
org copied to clipboard
[RFC] Single rule for `where`
For now, we have a policy for where in the functions, and different rules for other places where where is used (e.g. type classes, instances, etc.).
I propose to apply the existing where rule to all wheres:
class Semigroup a
where
(<>) :: a -> a -> a
We would have:
a. A single rule – easier to remember
b. Consistent style of where usage
c. Solved problem of huge constraints in the type classes definitions
d. Discourage for writing empty wheres in instances
e. ?
I guess it would have a positive effect. Let me know what you think! 👂🏼
@vrom911 I agree here with your reasoning 👍🏻 Even though, I'm not used to writing code like this, I feel that this consistency is very beneficial. Moreover, I imagine we can even utilize Hintman here to check that spaces on each line are multiples of 4, and are multiples of 2 for lines with where to have some code style checks automatic.
The problem with huge constraints in classes and instances (and sometimes even with pragmas like {-# OVERLAPPABLE #-}) is a problem indeed. And I'm all for solving this problem consistently once and for all.
I want to mention that using this formatting rule is a nice experience, and I like it so far 🙂