@@ -23,10 +23,12 @@ import qualified Desugar
2323
2424import Haskell.Ide.Engine.ArtifactMap
2525
26+ -- | Generate a mapping from an Interval to types.
27+ -- Intervals may overlap and return more specific results.
2628genTypeMap :: GHC. GhcMonad m => TypecheckedModule -> m TypeMap
2729genTypeMap tm = do
2830 let typecheckedSource = GHC. tm_typechecked_source tm
29- hs_env <- GHC. getSession
31+ hs_env <- GHC. getSession
3032 liftIO $ types hs_env typecheckedSource
3133
3234collectAllSpansTypes'
@@ -40,8 +42,8 @@ types hs_env = everythingInTypecheckedSourceM (ty `combineM` fun)
4042 ty :: forall a . Data a => a -> IO TypeMap
4143 ty term = case cast term of
4244 (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
4547 Just (_, typ) -> return (IM. singleton (rspToInt spn) typ)
4648 _ -> return IM. empty
4749
@@ -53,18 +55,15 @@ types hs_env = everythingInTypecheckedSourceM (ty `combineM` fun)
5355
5456
5557everythingInTypecheckedSourceM
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
6059everythingInTypecheckedSourceM f = everythingButTypeM @ GHC. Id f
6160
6261-- | Combine two queries into one using alternative combinator.
6362combineM
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
6867 a <- f x
6968 b <- g x
7069 return (a `IM.union` b)
0 commit comments