Skip to content

Commit a6499b8

Browse files
committed
Hlint: Do not suggest fromMaybe
1 parent e21289b commit a6499b8

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

.hlint.yaml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- ignore: {name: "Use camelCase"}
2424
- ignore: {name: "Use uncurry"}
2525
- ignore: {name: "Avoid lambda using `infix`"}
26+
- ignore: {name: "Replace case with fromMaybe"}
2627

2728
# Gives at least one suggestion we don't like.
2829
- ignore: {name: "Use <=<"}
@@ -65,11 +66,11 @@
6566
- Wingman.Types
6667
- AutoTupleSpec
6768
- name: unsafeInterleaveIO
68-
within:
69+
within:
6970
- Development.IDE.LSP.LanguageServer
7071
- {name: unsafeDupablePerformIO, within: []}
7172
- name: unsafeCoerce
72-
within:
73+
within:
7374
- Ide.Plugin.Eval.Code
7475
- Development.IDE.Core.Compile
7576
- Development.IDE.Types.Shake
@@ -85,12 +86,12 @@
8586
- Compat.HieBin
8687

8788
# Partial functions
88-
89+
8990
# We need to check fucntions which
9091
# are typically exported multiple ways under both names,
9192
# see https://github.com/ndmitchell/hlint/issues/1389
9293
- name: [Prelude.head, Data.List.head]
93-
within:
94+
within:
9495
- Main
9596
- Experiments
9697
- Development.Benchmark.Rules
@@ -116,7 +117,7 @@
116117
- Wingman.Tactics
117118

118119
- name: [Prelude.tail, Data.List.tail]
119-
within:
120+
within:
120121
- Main
121122
- Development.Benchmark.Rules
122123
- Development.IDE.Plugin.CodeAction
@@ -125,7 +126,7 @@
125126
- UnificationSpec
126127

127128
- name: [Prelude.last, Data.List.last]
128-
within:
129+
within:
129130
- Main
130131
- Development.IDE.Plugin.CodeAction
131132
- Development.IDE.Plugin.CodeAction.ExactPrint
@@ -136,7 +137,7 @@
136137
- Ide.Plugin.Eval.CodeLens
137138

138139
- name: [Prelude.init, Data.List.init]
139-
within:
140+
within:
140141
- Main
141142
- Development.IDE.Spans.Common
142143
- Ide.PluginUtils
@@ -151,7 +152,7 @@
151152
within: []
152153

153154
- name: ["Prelude.!!", "Data.List.!!"]
154-
within:
155+
within:
155156
- Main
156157
- Experiments
157158
- FunctionalCodeAction
@@ -171,11 +172,11 @@
171172
within: []
172173

173174
- name: Data.Foldable.foldr1
174-
within:
175+
within:
175176
- Wingman.Tactics
176177

177-
- name: Data.Maybe.fromJust
178-
within:
178+
- name: Data.Maybe.fromJust
179+
within:
179180
- Experiments
180181
- Main
181182
- MultipleImports
@@ -193,7 +194,7 @@
193194
- Ide.Plugin.Class
194195

195196
- name: "Data.Map.!"
196-
within:
197+
within:
197198
- Wingman.LanguageServer
198199

199200
- name: "Data.IntMap.!"
@@ -210,7 +211,7 @@
210211
# Debug.Trace, because that module also
211212
# includes the eventlog tracing functions,
212213
# which are legitimate to use.
213-
- name:
214+
- name:
214215
- Debug.Trace.trace
215216
- Debug.Trace.traceId
216217
- Debug.Trace.traceShow
@@ -220,7 +221,7 @@
220221
- Debug.Trace.traceM
221222
- Debug.Trace.traceShowM
222223
- Debug.Trace.putTraceMsg
223-
within:
224+
within:
224225
- Development.IDE.Core.Compile
225226
- Development.IDE.Graph.Internal.Database
226227
- Development.IDE.GHC.Util

hie-compat/src-ghc86/Compat/HieDebug.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-
22
Functions to validate and check .hie file ASTs generated by GHC.
33
-}
4-
4+
{-# LANGUAGE StandaloneDeriving #-}
55
{-# LANGUAGE OverloadedStrings #-}
66
{-# LANGUAGE FlexibleContexts #-}
77
module Compat.HieDebug where
@@ -129,7 +129,9 @@ validateScopes asts = M.foldrWithKey (\k a b -> valid k a ++ b) [] refMap
129129
valid (Right n) refs = concatMap inScope refs
130130
where
131131
mapRef = foldMap getScopeFromContext . identInfo . snd
132-
scopes = Data.Maybe.fromMaybe [] (foldMap mapRef refs)
132+
scopes = case foldMap mapRef refs of
133+
Just xs -> xs
134+
Nothing -> []
133135
inScope (sp, dets)
134136
| definedInAsts asts n
135137
&& any isOccurrence (identInfo dets)

0 commit comments

Comments
 (0)