Skip to content

Commit cd5d8bc

Browse files
author
kokobd
committed
use foldlM1 instead of foldl1
1 parent 4d75549 commit cd5d8bc

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

plugins/hls-selection-range-plugin/hls-selection-range-plugin.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ library
3636
, mtl
3737
, text
3838
, extra
39+
, semigroupoids
3940

4041
test-suite tests
4142
type: exitcode-stdio-1.0

plugins/hls-selection-range-plugin/src/Ide/Plugin/SelectionRange/ASTPreProcess.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ module Ide.Plugin.SelectionRange.ASTPreProcess
77
) where
88

99
import Control.Monad.Reader (Reader, asks)
10-
import Data.Foldable (find, foldl', foldl1)
10+
import Data.Foldable (find, foldl')
11+
import Data.Functor.Identity (Identity (Identity, runIdentity))
1112
import Data.List (groupBy)
1213
import Data.List.NonEmpty (NonEmpty)
1314
import qualified Data.List.NonEmpty as NonEmpty
1415
import qualified Data.Map.Strict as Map
1516
import Data.Maybe (mapMaybe)
17+
import Data.Semigroup.Foldable (foldlM1)
1618
import qualified Data.Set as Set
1719
import Development.IDE.GHC.Compat (ContextInfo (MatchBind, TyDecl, ValBind),
1820
HieAST (..), Identifier,
@@ -74,7 +76,7 @@ createVirtualNode :: NonEmpty (HieAST a) -> HieAST a
7476
createVirtualNode children = mkAstNode (NodeInfo mempty mempty mempty) span' (NonEmpty.toList children)
7577
where
7678
span' :: RealSrcSpan
77-
span' = foldl1 combineRealSrcSpans . fmap nodeSpan $ children
79+
span' = runIdentity . foldlM1 (\x y -> Identity (combineRealSrcSpans x y)) . fmap nodeSpan $ children
7880

7981
{-|
8082
Combine type signature with variable definition under a new parent node, if the signature is placed right before the
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cradle:
22
direct:
33
arguments:
4-
- "A"
4+
- "Import"
5+
- "Function"

0 commit comments

Comments
 (0)