org icon indicating copy to clipboard operation
org copied to clipboard

[RFC] Single rule for `where`

Open vrom911 opened this issue 4 years ago • 2 comments

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 avatar Dec 16 '20 15:12 vrom911

@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.

chshersh avatar Dec 16 '20 16:12 chshersh

I want to mention that using this formatting rule is a nice experience, and I like it so far 🙂

chshersh avatar Apr 08 '21 20:04 chshersh