From 11acd93bf651d2e52015810499ab0d44dd1b012d Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Sun, 29 Jun 2014 10:28:28 +0200 Subject: [PATCH] Try to fix for ghc < 7.8 --- Language/Haskell/GhcMod/CabalConfig.hs | 6 ++++++ Language/Haskell/GhcMod/FillSig.hs | 27 +++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Language/Haskell/GhcMod/CabalConfig.hs b/Language/Haskell/GhcMod/CabalConfig.hs index 93e6e37..7392ae4 100644 --- a/Language/Haskell/GhcMod/CabalConfig.hs +++ b/Language/Haskell/GhcMod/CabalConfig.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- | Reading cabal @dist/setup-config@ module Language.Haskell.GhcMod.CabalConfig ( CabalConfig @@ -15,7 +17,11 @@ import qualified Language.Haskell.GhcMod.Cabal18 as C18 import qualified Control.Exception as E import Control.Applicative ((<$>)) import Control.Monad (mplus) +#if MIN_VERSION_mtl(2,2,1) +import Control.Monad.Except () +#else import Control.Monad.Error () +#endif import Data.Maybe () import Data.Set () import Data.List (find,tails,isPrefixOf,isInfixOf,nub,stripPrefix) diff --git a/Language/Haskell/GhcMod/FillSig.hs b/Language/Haskell/GhcMod/FillSig.hs index 4b31e15..44f137d 100644 --- a/Language/Haskell/GhcMod/FillSig.hs +++ b/Language/Haskell/GhcMod/FillSig.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, CPP #-} module Language.Haskell.GhcMod.FillSig ( fillSig @@ -21,7 +21,11 @@ import Outputable (PprStyle) import qualified Type as Ty import qualified HsBinds as Ty import qualified Class as Ty +#if __GLASGOW_HASKELL__ >= 706 import OccName (occName) +#else +import OccName (rdrNameOcc) +#endif import qualified Language.Haskell.Exts.Annotated as HE ---------------------------------------------------------------- @@ -89,12 +93,28 @@ getSignature modSum lineNo colNo = do ,tm_checked_module_info = minfo} <- G.typecheckModule p case listifyRenamedSpans tcs (lineNo, colNo) :: [G.LInstDecl G.Name] of -- Instance declarations of sort 'instance F (G a)' +#if __GLASGOW_HASKELL__ >= 708 [L loc (G.ClsInstD (G.ClsInstDecl {G.cid_poly_ty = (L _ (G.HsForAllTy _ _ _ (L _ (G.HsAppTy (L _ (G.HsTyVar clsName)) _))))}))] -> +#elif __GLASGOW_HASKELL__ >= 706 + [L loc (G.ClsInstD + (L _ (G.HsForAllTy _ _ _ (L _ (G.HsAppTy (L _ (G.HsTyVar clsName)) _)))) _ _ _)] -> +#else + [L loc (G.InstDecl + (L _ (G.HsForAllTy _ _ _ (L _ (G.HsAppTy (L _ (G.HsTyVar clsName)) _)))) _ _ _)] -> +#endif obtainClassInfo minfo clsName loc -- Instance declarations of sort 'instance F G' (no variables) +#if __GLASGOW_HASKELL__ >= 708 [L loc (G.ClsInstD (G.ClsInstDecl {G.cid_poly_ty = (L _ (G.HsAppTy (L _ (G.HsTyVar clsName)) _))}))] -> +#elif __GLASGOW_HASKELL__ >= 706 + [L loc (G.ClsInstD + (L _ (G.HsAppTy (L _ (G.HsTyVar clsName)) _)) _ _ _)] -> +#else + [L loc (G.InstDecl + (L _ (G.HsAppTy (L _ (G.HsTyVar clsName)) _)) _ _ _)] -> +#endif obtainClassInfo minfo clsName loc _ -> return Nothing _ -> return Nothing @@ -161,6 +181,11 @@ instance FnArgsInfo (G.HsType G.RdrName) (G.RdrName) where _ -> False getFnArgs _ = [] +#if __GLASGOW_HASKELL__ < 706 +occName :: G.RdrName -> OccName +occName = rdrNameOcc +#endif + instance FnArgsInfo (HE.Type HE.SrcSpanInfo) (HE.Name HE.SrcSpanInfo) where getFnName _ _ (HE.Ident _ s) = s getFnName _ _ (HE.Symbol _ s) = s