Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f639484

Browse files
committed
Use compat for older ghcs
1 parent d55d890 commit f639484

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

hie-plugin-api/Haskell/Ide/Engine/Compat.hs

+19
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,25 @@ pattern FunBindType t <-
134134
GHC.FunBind (GHC.L _ (Var.varType -> t)) _ _ _ _
135135
#endif
136136

137+
pattern FunBindGen :: Type.Type -> GHC.MatchGroup GhcTc (GHC.LHsExpr GhcTc) -> GHC.HsBindLR GhcTc GhcTc
138+
pattern FunBindGen t fmatches <-
139+
#if MIN_VERSION_ghc(8, 6, 0)
140+
GHC.FunBind _ (GHC.L _ (Var.varType -> t)) fmatches _ _
141+
#elif MIN_VERSION_ghc(8, 4, 0)
142+
GHC.FunBind (GHC.L _ (Var.varType -> t)) fmatches _ _ _
143+
#else
144+
GHC.FunBind (GHC.L _ (Var.varType -> t)) fmatches _ _ _
145+
#endif
146+
147+
pattern AbsBinds :: GHC.LHsBinds GhcTc -> GHC.HsBindLR GhcTc GhcTc
148+
pattern AbsBinds bs <-
149+
#if MIN_VERSION_ghc(8, 6, 0)
150+
GHC.AbsBinds _ _ _ _ _ bs _
151+
#elif MIN_VERSION_ghc(8, 4, 0)
152+
GHC.AbsBinds _ _ _ _ bs _
153+
#else
154+
GHC.AbsBinds _ _ _ _ bs _
155+
#endif
137156

138157
#if MIN_VERSION_ghc(8, 6, 0)
139158
matchGroupType :: GHC.MatchGroupTc -> GHC.Type

hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import qualified GHC
1212
import GHC ( TypecheckedModule, GhcMonad )
1313
import Bag
1414
import BasicTypes
15-
import Var
1615

1716
import Data.Data as Data
1817
import Control.Monad.IO.Class
@@ -43,13 +42,13 @@ everythingInTypecheckedSourceM xs = bs
4342
processBind :: GhcMonad m => GHC.LHsBindLR Compat.GhcTc Compat.GhcTc -> m TypeMap
4443
processBind x@(GHC.L (GHC.RealSrcSpan spn) b) =
4544
case b of
46-
GHC.FunBind _ fid fmatches _ _ ->
45+
Compat.FunBindGen t fmatches ->
4746
case GHC.mg_origin fmatches of
4847
Generated -> return IM.empty
4948
FromSource -> do
5049
im <- types fmatches
51-
return $ (IM.singleton (rspToInt spn) (varType (GHC.unLoc fid))) `IM.union` im
52-
GHC.AbsBinds _ _ _ _ _ bs _ -> everythingInTypecheckedSourceM bs
50+
return $ IM.singleton (rspToInt spn) t `IM.union` im
51+
Compat.AbsBinds bs -> everythingInTypecheckedSourceM bs
5352
_ -> types x
5453
processBind _ = return IM.empty
5554

0 commit comments

Comments
 (0)