Merge branch 'ghc-8' of https://github.com/cocreature/ghc-mod into ghc-8

This commit is contained in:
Daniel Gröber 2016-05-19 21:44:40 +02:00
commit cfadbc6cb8
6 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
module Language.Haskell.GhcMod.Browse ( module Language.Haskell.GhcMod.Browse (
browse, browse,
BrowseOpts(..) BrowseOpts(..)
@ -25,6 +26,9 @@ import TyCon (isAlgTyCon)
import Type (dropForAlls, splitFunTy_maybe, mkFunTy, isPredTy) import Type (dropForAlls, splitFunTy_maybe, mkFunTy, isPredTy)
import Exception (ExceptionMonad, ghandle) import Exception (ExceptionMonad, ghandle)
import Prelude import Prelude
#if __GLASGOW_HASKELL__ >= 800
import PatSyn (pprPatSynType)
#endif
---------------------------------------------------------------- ----------------------------------------------------------------
@ -131,6 +135,9 @@ showThing' dflag (GtA a) = Just $ formatType dflag a
showThing' _ (GtT t) = unwords . toList <$> tyType t showThing' _ (GtT t) = unwords . toList <$> tyType t
where where
toList t' = t' : getOccString t : map getOccString (G.tyConTyVars t) toList t' = t' : getOccString t : map getOccString (G.tyConTyVars t)
#if __GLASGOW_HASKELL__ >= 800
showThing' dflag (GtPatSyn p) = Just $ showSDoc dflag $ pprPatSynType p
#endif
showThing' _ _ = Nothing showThing' _ _ = Nothing
formatType :: DynFlags -> Type -> String formatType :: DynFlags -> Type -> String

View File

@ -62,7 +62,11 @@ import Language.Haskell.GhcMod.Gap
import Prelude import Prelude
debugLogAction :: (String -> IO ()) -> GmLogAction debugLogAction :: (String -> IO ()) -> GmLogAction
#if __GLASGOW_HASKELL__ >= 800
debugLogAction putErr dflags _reason severity srcSpan style' msg
#else
debugLogAction putErr dflags severity srcSpan style' msg debugLogAction putErr dflags severity srcSpan style' msg
#endif
= case severity of = case severity of
SevOutput -> printSDoc putErr msg style' SevOutput -> printSDoc putErr msg style'

View File

@ -16,7 +16,11 @@ import Prelude
setEmptyLogger :: DynFlags -> DynFlags setEmptyLogger :: DynFlags -> DynFlags
setEmptyLogger df = setEmptyLogger df =
#if __GLASGOW_HASKELL__ >= 800
Gap.setLogAction df $ \_ _ _ _ _ _ -> return ()
#else
Gap.setLogAction df $ \_ _ _ _ _ -> return () Gap.setLogAction df $ \_ _ _ _ _ -> return ()
#endif
setDebugLogger :: (String -> IO ()) -> DynFlags -> DynFlags setDebugLogger :: (String -> IO ()) -> DynFlags -> DynFlags
setDebugLogger put df = do setDebugLogger put df = do

View File

@ -83,7 +83,11 @@ import CoAxiom (coAxiomTyCon)
#if __GLASGOW_HASKELL__ >= 708 #if __GLASGOW_HASKELL__ >= 708
import FamInstEnv import FamInstEnv
import ConLike (ConLike(..)) import ConLike (ConLike(..))
#if __GLASGOW_HASKELL__ >= 800
import PatSyn (PatSyn)
#else
import PatSyn (patSynType) import PatSyn (patSynType)
#endif
#else #else
import TcRnTypes import TcRnTypes
#endif #endif
@ -460,12 +464,19 @@ deSugar tcm e hs_env = snd <$> deSugarExpr hs_env modu rn_env ty_env e
---------------------------------------------------------------- ----------------------------------------------------------------
data GapThing = GtA Type | GtT TyCon | GtN data GapThing = GtA Type | GtT TyCon | GtN
#if __GLASGOW_HASKELL__ >= 800
| GtPatSyn PatSyn
#endif
fromTyThing :: TyThing -> GapThing fromTyThing :: TyThing -> GapThing
fromTyThing (AnId i) = GtA $ varType i fromTyThing (AnId i) = GtA $ varType i
#if __GLASGOW_HASKELL__ >= 708 #if __GLASGOW_HASKELL__ >= 708
fromTyThing (AConLike (RealDataCon d)) = GtA $ dataConRepType d fromTyThing (AConLike (RealDataCon d)) = GtA $ dataConRepType d
#if __GLASGOW_HASKELL__ >= 800
fromTyThing (AConLike (PatSynCon p)) = GtPatSyn p
#else
fromTyThing (AConLike (PatSynCon p)) = GtA $ patSynType p fromTyThing (AConLike (PatSynCon p)) = GtA $ patSynType p
#endif
#else #else
fromTyThing (ADataCon d) = GtA $ dataConRepType d fromTyThing (ADataCon d) = GtA $ dataConRepType d
#endif #endif

View File

@ -25,6 +25,9 @@ import HscTypes
import Outputable import Outputable
import qualified GHC as G import qualified GHC as G
import Bag import Bag
#if __GLASGOW_HASKELL__ >= 800
import DynFlags (WarnReason)
#endif
import Language.Haskell.GhcMod.Convert import Language.Haskell.GhcMod.Convert
import Language.Haskell.GhcMod.Doc (showPage) import Language.Haskell.GhcMod.Doc (showPage)
@ -59,8 +62,13 @@ readAndClearLogRef (LogRef ref) = do
writeIORef ref emptyLog writeIORef ref emptyLog
return $ b [] return $ b []
#if __GLASGOW_HASKELL__ >= 800
appendLogRef :: (FilePath -> FilePath) -> DynFlags -> LogRef -> DynFlags -> WarnReason -> Severity -> SrcSpan -> PprStyle -> SDoc -> IO ()
appendLogRef rfm df (LogRef ref) _ _reason sev src st msg = do
#else
appendLogRef :: (FilePath -> FilePath) -> DynFlags -> LogRef -> DynFlags -> Severity -> SrcSpan -> PprStyle -> SDoc -> IO () appendLogRef :: (FilePath -> FilePath) -> DynFlags -> LogRef -> DynFlags -> Severity -> SrcSpan -> PprStyle -> SDoc -> IO ()
appendLogRef rfm df (LogRef ref) _ sev src st msg = do appendLogRef rfm df (LogRef ref) _ sev src st msg = do
#endif
modifyIORef ref update modifyIORef ref update
where where
gpe = GmPprEnv { gpe = GmPprEnv {

View File

@ -1,5 +1,5 @@
-- TODO: remove CPP once Gap(ed) -- TODO: remove CPP once Gap(ed)
{-# LANGUAGE CPP, TupleSections, FlexibleInstances, Rank2Types, ImpredicativeTypes #-} {-# LANGUAGE CPP, TupleSections, FlexibleInstances, Rank2Types #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
module Language.Haskell.GhcMod.SrcUtils where module Language.Haskell.GhcMod.SrcUtils where