From f2c7b01e372dd8c516b1ccbe5a1025cc7814347c Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 5 Jun 2016 06:59:39 +0300 Subject: [PATCH] [Type-constraints][GHC-8] Fix for explicit sigs GHC 8 added `AbsBindsSig` for polymorphic bindings with explicit signatures. For more information on the topic, see * https://ghc.haskell.org/trac/ghc/ticket/11405 * https://git.haskell.org/ghc.git/commitdiff/3c6635ef4561ab53e51d7187c966b628a972b261 --- Language/Haskell/GhcMod/SrcUtils.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Language/Haskell/GhcMod/SrcUtils.hs b/Language/Haskell/GhcMod/SrcUtils.hs index b1688a1..fb36289 100644 --- a/Language/Haskell/GhcMod/SrcUtils.hs +++ b/Language/Haskell/GhcMod/SrcUtils.hs @@ -66,6 +66,20 @@ collectSpansTypes withConstraints tcs lc = hsBind (L _ G.AbsBinds{abs_exports = es'}) s | withConstraints = (return [], foldr insExp s es') | otherwise = (return [], s) +#if __GLASGOW_HASKELL__ >= 800 + -- TODO: move to Gap + -- Note: this deals with bindings with explicit type signature, e.g. + -- double :: Num a => a -> a + -- double x = 2*x + hsBind (L _ G.AbsBindsSig{abs_sig_export = poly, abs_sig_bind = bind}) s + | withConstraints = + let new_s = + case bind of + G.L _ G.FunBind{fun_id = i} -> M.insert (G.unLoc i) (G.varType poly) s + _ -> s + in (return [], new_s) + | otherwise = (return [], s) +#endif -- Otherwise, it's the same as other cases hsBind x s = genericCT x s -- Generic SYB function to get type