forked from lamdu/lamdu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.hlint.yaml
96 lines (89 loc) · 4.51 KB
/
.hlint.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
- warn: { name: Use DerivingStrategies }
- warn: { name: Redundant bracket due to operator fixities }
- ignore: { name: Too strict if }
- ignore: { name: Functor law }
- ignore: { name: Fuse traverse/<&> }
- ignore: { name: Fuse traverse_/<&> }
- ignore: { name: Fuse foldMap/<&> }
- ignore: { name: Fuse foldr/<&> }
- fixity: "infixl 9 |||"
- group:
name: default
rules:
- warn: {lhs: traverse (pure . a), rhs: (fmap . fmap) a}
- warn: {lhs: foldr (\a b c -> d c >>= b) pure, rhs: flip (foldM (flip (\a -> d)))}
- warn: {lhs: "(<>) <$> a <*> b", rhs: "a <> b", note: "Requires Semigroup instance"}
- group:
name: lamdu-style
enabled: true
imports:
- package base
- package lens
rules:
- warn: {lhs: a <&> ($), rhs: a}
- hint: {lhs: mapM, rhs: traverse}
- hint: {lhs: mapM_, rhs: traverse_}
- hint: {lhs: a `mappend` b, rhs: a <> b}
- hint: {lhs: mappend a b, rhs: a <> b}
- hint: {lhs: Control.Lens.filtered (Control.Lens.has a), rhs: filteredBy a}
- hint: {lhs: \x -> a $ b x, rhs: a . b}
- ignore: {name: Use tuple-section}
- hint: {lhs: "case a of {Nothing -> mempty; Just b -> c}", rhs: foldMap (\b -> c) a }
- hint: {lhs: "Data.Set.member a", rhs: "(^. Control.Lens.contains a)"}
- hint: {lhs: "zipWith a [0..]", rhs: "Control.Lens.imap a"}
- hint: {lhs: "zipWith a [0::Int ..]", rhs: "Control.Lens.imap a"}
- hint: {lhs: "map (uncurry a) (Data.Map.toList b)", rhs: "Control.Lens.imap a b ^.. Control.Lens.folded"}
- hint: {lhs: "(Control.Lens.at a ?~ b) mempty", rhs: "a Control.Lens.Extended.~~> b"}
- warn: {lhs: "do { a <- b; pure c }", rhs: b <&> \a -> c}
- warn: {lhs: "sequenceA [a]", rhs: "a <&> pure"}
- warn: {lhs: "lift a >>= lift . b", rhs: "a >>= b & lift"}
- warn: {lhs: "pure a <&> b", rhs: "pure (b a)"}
- warn: {lhs: "lift a <&> b >>= lift . c", rhs: "a <&> b >>= c & lift"}
- warn: {lhs: "either (Left . a) (Right . b)", rhs: "bimap a b"}
- group:
name: generalise-for-conciseness
enabled: true
- group:
name: future
enabled: true
- group:
name: monomorphic
enabled: true
- group:
name: use-lens
enabled: true
rules:
- warn: {lhs: "head (a ++ [b])", rhs: "fromMaybe b (a ^? traverse)"}
- warn: {lhs: "head (a <> [b])", rhs: "fromMaybe b (a ^? traverse)"}
- warn: {lhs: "mconcat [a | x <- take 1 b]", rhs: "foldMap (\\x -> a) (b ^? traverse)"}
- warn: {lhs: "Data.Map.keys", rhs: "(^.. Control.Lens.itraversed . Control.Lens.asIndex)"}
- warn: {lhs: "Data.Map.toList", rhs: "(^@.. Control.Lens.itraversed)", note: more general types}
- warn: {lhs: "Data.Set.toList", rhs: "(^.. Control.Lens.folded)", note: more general types}
- warn: {lhs: "a ^. b ^.. y", rhs: "a ^.. b . y", note: "may change results"}
# extend existing group
- group:
name: lens
rules:
- warn: {lhs: "a <&> (<&> b)", rhs: "a <&> Lens.mapped %~ b"}
- warn: {lhs: "a ^? b <&> (^. c)", rhs: "a ^? (b . c)"}
- warn: {lhs: "a ^? Control.Lens.failing b c", rhs: "a ^? b <> c"}
- warn: {lhs: "a ^.. b <> a ^.. c", rhs: "a ^.. b <> c"}
- warn: {lhs: "a ^.. b . c <> a ^.. b . d", rhs: "a ^.. b . (c <> d)"}
- warn: {lhs: "mconcat (a ^.. b)", rhs: "a ^. b"}
- warn: {lhs: "a ^.. b & mconcat", rhs: "a ^. b"}
- warn: {lhs: "Control.Lens.at a . Control.Lens._Just", rhs: "Control.Lens.ix a"}
- warn: {lhs: "(b .~ (a ^. b)) a", rhs: "a"}
- warn: {lhs: "(c .~ (a ^. (b . c))) (a ^. b)", rhs: "a ^. b"}
- warn: {lhs: "a ^.. (b . Control.Lens.withIndex)", rhs: "a ^@.. b"}
- warn: {lhs: "Control.Lens.has a b || Control.Lens.has c b", rhs: "Control.Lens.has (a . Control.Lens.united <> c . Control.Lens.united) b"}
- warn: {lhs: Control.Lens.reversed . Control.Lens.ix 0, rhs: Control.Lens._last}
- error: {lhs: "(^. Control.Lens.folded) . fmap a", rhs: "foldMap a"}
- error: {lhs: "(a <&> b) ^. Control.Lens.folded", rhs: "foldMap b a"}
- error: {lhs: "a %%~ \\b -> pure c", rhs: "pure (a %~ \\b -> c)"}
- error: {lhs: "Control.Lens.has c (a ^. b)", rhs: "Control.Lens.has (b . c) a"}
- error: {lhs: "Control.Lens.has (Control.Lens.at a)", rhs: "True"}
- error: {lhs: "Control.Lens.has (a . Control.Lens.at b)", rhs: "Control.Lens.has a"}
- error: {lhs: "Control.Lens.nullOf (Control.Lens.at a)", rhs: "False"}
- error: {lhs: "Control.Lens.nullOf (a . Control.Lens.at b)", rhs: "Control.Lens.nullOf a"}
- warn: {lhs: "Control.Monad.Reader.local (a %~ b)", rhs: "Control.Lens.locally a b"}
- warn: {lhs: "Control.Lens.mapped .~ a", rhs: "(a <$)"}