Skip to content

Commit 7bc5843

Browse files
committed
refactor: break pointfree
1 parent 6967f67 commit 7bc5843

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Data.Text (Text)
2525
import Data.Unique (hashUnique, newUnique)
2626

2727
import Control.Monad (replicateM)
28-
import Control.Monad.Trans.Except (except)
28+
import Control.Monad.Trans.Class (lift)
2929
import Data.Aeson (ToJSON (toJSON))
3030
import Data.List (find, intersperse)
3131
import qualified Data.Text as T
@@ -108,7 +108,6 @@ import Language.LSP.Protocol.Types (CodeAction (..),
108108
type (|?) (InL, InR))
109109

110110
#if __GLASGOW_HASKELL__ < 910
111-
import Control.Monad.Trans.Class (lift)
112111
import Development.IDE.GHC.Compat (HsExpansion (HsExpanded))
113112
#endif
114113

@@ -203,9 +202,14 @@ inlayHintProvider _ state pId InlayHintParams {_textDocument = TextDocumentIdent
203202
end <- fmap _end range
204203
names' <- names
205204
defnLocs' <- defnLocs
206-
let excludeDotDot (Location _ (Range _ pos)) = pos /= end
205+
let excludeDotDot (Location _ (Range _ end')) = end' /= end
207206
-- find location from dotdot definitions that name equal to label name
208-
findLocation t = fmap fst . find (either (const False) ((==) t) . snd) . filter (excludeDotDot . fst)
207+
findLocation name locations =
208+
let -- filter locations not within dotdot range
209+
filteredLocations = filter (excludeDotDot . fst) locations
210+
-- checks if 'a' is equal to 'Name' if the 'Either' is 'Right a', otherwise return 'False'
211+
nameEq = either (const False) ((==) name)
212+
in fmap fst $ find (nameEq . snd) filteredLocations
209213
valueWithLoc = [ (T.pack $ printName name, findLocation name defnLocs') | name <- names' ]
210214
-- use `, ` to separate labels with definition location
211215
label = intersperse (mkInlayHintLabelPart (", ", Nothing)) $ fmap mkInlayHintLabelPart valueWithLoc

0 commit comments

Comments
 (0)