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

Commit

Permalink
Use compat for older ghcs
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Aug 27, 2019
1 parent d55d890 commit b14a3f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
19 changes: 19 additions & 0 deletions hie-plugin-api/Haskell/Ide/Engine/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,25 @@ pattern FunBindType t <-
GHC.FunBind (GHC.L _ (Var.varType -> t)) _ _ _ _
#endif

pattern FunBindGen :: Type.Type -> GHC.MatchGroup GhcTc (GHC.LHsExpr GhcTc) -> GHC.HsBindLR GhcTc GhcTc
pattern FunBindGen t fmatches <-
#if MIN_VERSION_ghc(8, 6, 0)
GHC.FunBind _ (GHC.L _ (Var.varType -> t)) fmatches _ _
#elif MIN_VERSION_ghc(8, 4, 0)
GHC.FunBind (GHC.L _ (Var.varType -> t)) fmatches _ _ _
#else
GHC.FunBind (GHC.L _ (Var.varType -> t)) fmatches _ _ _
#endif

pattern AbsBinds :: GHC.LHsBinds GhcTc -> GHC.HsBindLR GhcTc GhcTc
pattern AbsBinds bs <-
#if MIN_VERSION_ghc(8, 6, 0)
GHC.AbsBinds _ _ _ _ _ bs _
#elif MIN_VERSION_ghc(8, 4, 0)
GHC.AbsBinds _ _ _ _ bs _
#else
GHC.AbsBinds _ _ _ _ bs
#endif

#if MIN_VERSION_ghc(8, 6, 0)
matchGroupType :: GHC.MatchGroupTc -> GHC.Type
Expand Down
7 changes: 3 additions & 4 deletions hie-plugin-api/Haskell/Ide/Engine/TypeMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import qualified GHC
import GHC ( TypecheckedModule, GhcMonad )
import Bag
import BasicTypes
import Var

import Data.Data as Data
import Control.Monad.IO.Class
Expand Down Expand Up @@ -43,13 +42,13 @@ everythingInTypecheckedSourceM xs = bs
processBind :: GhcMonad m => GHC.LHsBindLR Compat.GhcTc Compat.GhcTc -> m TypeMap
processBind x@(GHC.L (GHC.RealSrcSpan spn) b) =
case b of
GHC.FunBind _ fid fmatches _ _ ->
Compat.FunBindGen t fmatches ->
case GHC.mg_origin fmatches of
Generated -> return IM.empty
FromSource -> do
im <- types fmatches
return $ (IM.singleton (rspToInt spn) (varType (GHC.unLoc fid))) `IM.union` im
GHC.AbsBinds _ _ _ _ _ bs _ -> everythingInTypecheckedSourceM bs
return $ IM.singleton (rspToInt spn) t `IM.union` im
Compat.AbsBinds bs -> everythingInTypecheckedSourceM bs
_ -> types x
processBind _ = return IM.empty

Expand Down

0 comments on commit b14a3f8

Please sign in to comment.