@@ -52,7 +52,7 @@ getSrcSpanInfos
5252 -> [(Located ModuleName, Maybe NormalizedFilePath)]
5353 -> TcModuleResult
5454 -> [TcModuleResult]
55− -> IO [SpanInfo]
55+ -> IO SpansInfo
5656getSrcSpanInfos env imports tc tms =
5757 runGhcEnv env $
5858 getSpanInfo imports (tmrModule tc) (map tmrModule tms)
@@ -62,7 +62,7 @@ getSpanInfo :: GhcMonad m
6262 => [(Located ModuleName, Maybe NormalizedFilePath)] -- ^ imports
6363 -> TypecheckedModule
6464 -> [TypecheckedModule]
65− -> m [SpanInfo]
65+ -> m SpansInfo
6666getSpanInfo mods tcm tcms =
6767 do let tcs = tm_typechecked_source tcm
6868 bs = listifyAllSpans tcs :: [LHsBind GhcTc]
@@ -78,13 +78,16 @@ getSpanInfo mods tcm tcms =
7878 let imports = importInfo mods
7979 let exports = getExports tcm
8080 let exprs = addEmptyInfo exports ++ addEmptyInfo imports ++ concat bts ++ concat tts ++ catMaybes (ets ++ pts)
81− return (mapMaybe toSpanInfo (sortBy cmp exprs))
81+ let constraints = map constraintToInfo (concatMap getConstraintsLHsBind bs)
82+ return $ SpansInfo (mapMaybe toSpanInfo (sortBy cmp exprs))
83+ (mapMaybe toSpanInfo (sortBy cmp constraints))
8284 where cmp (_,a,_,_) (_,b,_,_)
8385 | a `isSubspanOf` b = LT
8486 | b `isSubspanOf` a = GT
8587 | otherwise = compare (srcSpanStart a) (srcSpanStart b)
8688
8789 addEmptyInfo = map (\(a,b) -> (a,b,Nothing,emptySpanDoc))
90+ constraintToInfo (sp, ty) = (SpanS sp, sp, Just ty, emptySpanDoc)
8891
8992-- | The locations in the typechecked module are slightly messed up in some cases (e.g. HsMatchContext always
9093-- points to the first match) whereas the parsed module has the correct locations.
@@ -130,6 +133,13 @@ getTypeLHsBind tms _ (L _spn FunBind{fun_id = pid,fun_matches = MG{}}) = do
130133 return [(Named name, getLoc pid, Just (varType (unLoc pid)), docs)]
131134getTypeLHsBind _ _ _ = return []
132135
136+-- | Get information about constraints
137+getConstraintsLHsBind :: LHsBind GhcTc
138+ -> [(SrcSpan, Type)]
139+getConstraintsLHsBind (L spn AbsBinds { abs_ev_vars = vars })
140+ = map (\v -> (spn, varType v)) vars
141+getConstraintsLHsBind _ = []
142+
133143-- | Get the name and type of an expression.
134144getTypeLHsExpr :: (GhcMonad m)
135145 => [TypecheckedModule]