1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
module Check.Rhs (rhsCheck) where
import AST.PositionUtils
import AST.Span (Pos, start)
import AST.SpanAST
import Check.Types (CheckF, Message (..))
import Config.Types (Check (..))
import Config.ReadConfig (shallCheck)
import Utils (condMsg)
rhsCheck :: CheckF Rhs
rhsCheck rhs = case rhs of
GuardedRhs s1 ces ss _ _ -> eqs ++ bars
where
p1 = start s1
eqs = condMsg (shallCheck CRhsEq && not (validGrhsEq ces))
[Message (condExprPos $ head ces)
"GuardedRhs: Equality signs are not aligned."]
bars = condMsg (shallCheck CRhsBars && not (validGrhsBars p1 (map start ss)))
[Message p1 "GuardedRhs: Bars are not aligned."]
_ -> []
validGrhsBars :: Pos -> [Pos] -> Bool
validGrhsBars p1 ps@(p2:_) = (col p1 == col p2) && allColEq ps
validGrhsBars _ [] = True
validGrhsEq :: [CondExpr] -> Bool
validGrhsEq ces = (allColEq $ map condExprPos ces)
|