@@ -23,10 +23,12 @@ import qualified Desugar
23
23
24
24
import Haskell.Ide.Engine.ArtifactMap
25
25
26
+ -- | Generate a mapping from an Interval to types.
27
+ -- Intervals may overlap and return more specific results.
26
28
genTypeMap :: GHC. GhcMonad m => TypecheckedModule -> m TypeMap
27
29
genTypeMap tm = do
28
30
let typecheckedSource = GHC. tm_typechecked_source tm
29
- hs_env <- GHC. getSession
31
+ hs_env <- GHC. getSession
30
32
liftIO $ types hs_env typecheckedSource
31
33
32
34
collectAllSpansTypes'
@@ -40,8 +42,8 @@ types hs_env = everythingInTypecheckedSourceM (ty `combineM` fun)
40
42
ty :: forall a . Data a => a -> IO TypeMap
41
43
ty term = case cast term of
42
44
(Just lhsExprGhc@ (GHC. L (GHC. RealSrcSpan spn) _)) ->
43
- getType hs_env lhsExprGhc >>= \ case
44
- Nothing -> return IM. empty
45
+ getType hs_env lhsExprGhc >>= \ case
46
+ Nothing -> return IM. empty
45
47
Just (_, typ) -> return (IM. singleton (rspToInt spn) typ)
46
48
_ -> return IM. empty
47
49
@@ -53,18 +55,15 @@ types hs_env = everythingInTypecheckedSourceM (ty `combineM` fun)
53
55
54
56
55
57
everythingInTypecheckedSourceM
56
- :: Data x
57
- => (forall a . Data a => a -> IO TypeMap )
58
- -> x
59
- -> IO TypeMap
58
+ :: Data x => (forall a . Data a => a -> IO TypeMap ) -> x -> IO TypeMap
60
59
everythingInTypecheckedSourceM f = everythingButTypeM @ GHC. Id f
61
60
62
61
-- | Combine two queries into one using alternative combinator.
63
62
combineM
64
- :: (forall a . Data a => a -> IO TypeMap )
65
- -> (forall a . Data a => a -> IO TypeMap )
66
- -> (forall a . Data a => a -> IO TypeMap )
67
- combineM f g x = do
63
+ :: (forall a . Data a => a -> IO TypeMap )
64
+ -> (forall a . Data a => a -> IO TypeMap )
65
+ -> (forall a . Data a => a -> IO TypeMap )
66
+ combineM f g x = do
68
67
a <- f x
69
68
b <- g x
70
69
return (a `IM.union` b)
0 commit comments