[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
This commit is contained in:
Nikolay Yakimov 2016-06-05 06:59:39 +03:00
parent 31e3c0b500
commit f2c7b01e37

View File

@ -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