CPP around optparse-applicative and hse conflicts

This commit is contained in:
Daniel Gröber 2017-01-16 20:56:57 +01:00
parent 5df1480309
commit 9bd39a855a
4 changed files with 28 additions and 5 deletions

View File

@ -27,7 +27,11 @@ import qualified HsBinds as Ty
import qualified Class as Ty import qualified Class as Ty
import qualified Var as Ty import qualified Var as Ty
import qualified HsPat as Ty import qualified HsPat as Ty
#if MIN_VERSION_haskell_src_exts(1,18,0)
import qualified Language.Haskell.Exts as HE import qualified Language.Haskell.Exts as HE
#else
import qualified Language.Haskell.Exts.Annotated as HE
#endif
import Djinn.GHC import Djinn.GHC
import qualified Language.Haskell.GhcMod.Gap as Gap import qualified Language.Haskell.GhcMod.Gap as Gap
@ -191,7 +195,11 @@ getSignatureFromHE file lineNo colNo = do
HE.TypeSig (HE.SrcSpanInfo s _) names ty -> HE.TypeSig (HE.SrcSpanInfo s _) names ty ->
return $ HESignature s names ty return $ HESignature s names ty
#if MIN_VERSION_haskell_src_exts(1,18,0)
HE.TypeFamDecl (HE.SrcSpanInfo s _) declHead _ _ -> HE.TypeFamDecl (HE.SrcSpanInfo s _) declHead _ _ ->
#else
HE.TypeFamDecl (HE.SrcSpanInfo s _) declHead _ ->
#endif
let (name, tys) = dHeadTyVars declHead in let (name, tys) = dHeadTyVars declHead in
return $ HEFamSignature s Open name (map cleanTyVarBind tys) return $ HEFamSignature s Open name (map cleanTyVarBind tys)

View File

@ -16,7 +16,11 @@ import qualified Var as G
import qualified Type as G import qualified Type as G
import GHC.SYB.Utils import GHC.SYB.Utils
import GhcMonad import GhcMonad
#if MIN_VERSION_haskell_src_exts(1,18,0)
import qualified Language.Haskell.Exts as HE import qualified Language.Haskell.Exts as HE
#else
import qualified Language.Haskell.Exts.Annotated as HE
#endif
import Language.Haskell.GhcMod.Doc import Language.Haskell.GhcMod.Doc
import Language.Haskell.GhcMod.Gap import Language.Haskell.GhcMod.Gap
import qualified Language.Haskell.GhcMod.Gap as Gap import qualified Language.Haskell.GhcMod.Gap as Gap
@ -175,7 +179,11 @@ fourIntsHE loc = ( HE.srcSpanStartLine loc, HE.srcSpanStartColumn loc
typeSigInRangeHE :: Int -> Int -> HE.Decl HE.SrcSpanInfo -> Bool typeSigInRangeHE :: Int -> Int -> HE.Decl HE.SrcSpanInfo -> Bool
typeSigInRangeHE lineNo colNo (HE.TypeSig (HE.SrcSpanInfo s _) _ _) = typeSigInRangeHE lineNo colNo (HE.TypeSig (HE.SrcSpanInfo s _) _ _) =
HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo) HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo)
#if MIN_VERSION_haskell_src_exts(1,18,0)
typeSigInRangeHE lineNo colNo (HE.TypeFamDecl (HE.SrcSpanInfo s _) _ _ _) = typeSigInRangeHE lineNo colNo (HE.TypeFamDecl (HE.SrcSpanInfo s _) _ _ _) =
#else
typeSigInRangeHE lineNo colNo (HE.TypeFamDecl (HE.SrcSpanInfo s _) _ _) =
#endif
HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo) HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo)
typeSigInRangeHE lineNo colNo (HE.DataFamDecl (HE.SrcSpanInfo s _) _ _ _) = typeSigInRangeHE lineNo colNo (HE.DataFamDecl (HE.SrcSpanInfo s _) _ _ _) =
HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo) HE.srcSpanStart s <= (lineNo, colNo) && HE.srcSpanEnd s >= (lineNo, colNo)

View File

@ -200,14 +200,14 @@ Library
, mtl < 2.3 && >= 2.0 , mtl < 2.3 && >= 2.0
, monad-control < 1.1 && >= 1 , monad-control < 1.1 && >= 1
, split < 0.3 , split < 0.3
, haskell-src-exts < 1.19 && >= 1.18 , haskell-src-exts < 1.19 && >= 1.16.0.1
, text < 1.3 , text < 1.3
, djinn-ghc < 0.1 && >= 0.0.2.2 , djinn-ghc < 0.1 && >= 0.0.2.2
, fclabels == 2.0.* , fclabels == 2.0.*
, extra == 1.5.* , extra == 1.5.*
, pipes == 4.3.* , pipes == 4.3.*
, safe < 0.4 && >= 0.3.9 , safe < 0.4 && >= 0.3.9
, optparse-applicative >=0.13.0 && <0.14.0 , optparse-applicative >=0.11.0 && <0.14.0
, template-haskell , template-haskell
, syb , syb
if impl(ghc < 7.8) if impl(ghc < 7.8)
@ -236,7 +236,7 @@ Executable ghc-mod
, ghc < 8.1 , ghc < 8.1
, monad-control ==1.0.* , monad-control ==1.0.*
, fclabels ==2.0.* , fclabels ==2.0.*
, optparse-applicative >=0.13.0 && <0.14.0 , optparse-applicative >=0.11.0 && <0.14.0
, semigroups < 0.19 && >= 0.10.0 , semigroups < 0.19 && >= 0.10.0
, ghc-mod , ghc-mod
@ -250,7 +250,7 @@ Executable ghc-modi
Cpp-Options: -DWINDOWS Cpp-Options: -DWINDOWS
Default-Extensions: ConstraintKinds, FlexibleContexts Default-Extensions: ConstraintKinds, FlexibleContexts
HS-Source-Dirs: src, . HS-Source-Dirs: src, .
Build-Depends: base (< 5 && > 4.7) || (>= 4.0 && < 4.7) Build-Depends: base < 5 && >= 4.0
, binary < 0.9 && >= 0.5.1.0 , binary < 0.9 && >= 0.5.1.0
, deepseq < 1.5 , deepseq < 1.5
, directory < 1.4 , directory < 1.4

View File

@ -13,12 +13,14 @@
-- --
-- You should have received a copy of the GNU Affero General Public License -- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP, OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} {-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
module GHCMod.Options.Commands where module GHCMod.Options.Commands where
#if MIN_VERSION_optparse_applicative(0,13,0)
import Data.Semigroup import Data.Semigroup
#endif
import Options.Applicative import Options.Applicative
import Options.Applicative.Types import Options.Applicative.Types
import Options.Applicative.Builder.Internal import Options.Applicative.Builder.Internal
@ -290,8 +292,13 @@ hsubparser' :: Mod CommandFields a -> Parser a
hsubparser' m = mkParser d g rdr hsubparser' m = mkParser d g rdr
where where
Mod _ d g = m `mappend` metavar "" Mod _ d g = m `mappend` metavar ""
#if MIN_VERSION_optparse_applicative(0,13,0)
(ms,cmds, subs) = mkCommand m (ms,cmds, subs) = mkCommand m
rdr = CmdReader ms cmds (fmap add_helper . subs) rdr = CmdReader ms cmds (fmap add_helper . subs)
#else
(cmds, subs) = mkCommand m
rdr = CmdReader cmds (fmap add_helper . subs)
#endif
add_helper pinfo = pinfo add_helper pinfo = pinfo
{ infoParser = infoParser pinfo <**> helper } { infoParser = infoParser pinfo <**> helper }