moving #if to Gap.hs.
This commit is contained in:
parent
be9a67f02a
commit
84c3cec0f1
@ -8,9 +8,8 @@ import Data.List (find, intercalate)
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.IO as T (readFile)
|
import qualified Data.Text.IO as T (readFile)
|
||||||
import Exception (ghandle, SomeException(..))
|
import Exception (ghandle, SomeException(..))
|
||||||
import GHC (GhcMonad, LHsBind, LHsExpr, LPat, Id, ParsedModule(..), TypecheckedModule(..), DynFlags, SrcSpan, Type, GenLocated(L))
|
import GHC (GhcMonad, LHsBind, LPat, Id, ParsedModule(..), TypecheckedModule(..), DynFlags, SrcSpan, Type, GenLocated(L))
|
||||||
import qualified GHC as G
|
import qualified GHC as G
|
||||||
import Language.Haskell.GhcMod.Gap (HasType(..))
|
|
||||||
import qualified Language.Haskell.GhcMod.Gap as Gap
|
import qualified Language.Haskell.GhcMod.Gap as Gap
|
||||||
import Language.Haskell.GhcMod.Monad
|
import Language.Haskell.GhcMod.Monad
|
||||||
import Language.Haskell.GhcMod.SrcUtils
|
import Language.Haskell.GhcMod.SrcUtils
|
||||||
@ -60,17 +59,12 @@ getSrcSpanTypeForSplit modSum lineNo colNo = do
|
|||||||
tcm@TypecheckedModule{tm_typechecked_source = tcs} <- G.typecheckModule p
|
tcm@TypecheckedModule{tm_typechecked_source = tcs} <- G.typecheckModule p
|
||||||
let bs:_ = listifySpans tcs (lineNo, colNo) :: [LHsBind Id]
|
let bs:_ = listifySpans tcs (lineNo, colNo) :: [LHsBind Id]
|
||||||
varPat = find isPatternVar $ listifySpans tcs (lineNo, colNo) :: Maybe (LPat Id)
|
varPat = find isPatternVar $ listifySpans tcs (lineNo, colNo) :: Maybe (LPat Id)
|
||||||
match:_ = listifyParsedSpans pms (lineNo, colNo)
|
match:_ = listifyParsedSpans pms (lineNo, colNo) :: [Gap.GLMatch]
|
||||||
#if __GLASGOW_HASKELL__ < 708
|
|
||||||
:: [G.LMatch G.RdrName]
|
|
||||||
#else
|
|
||||||
:: [G.LMatch G.RdrName (LHsExpr G.RdrName)]
|
|
||||||
#endif
|
|
||||||
case varPat of
|
case varPat of
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
Just varPat' -> do
|
Just varPat' -> do
|
||||||
varT <- getType tcm varPat' -- Finally we get the type of the var
|
varT <- Gap.getType tcm varPat' -- Finally we get the type of the var
|
||||||
bsT <- getType tcm bs
|
bsT <- Gap.getType tcm bs
|
||||||
case (varT, bsT) of
|
case (varT, bsT) of
|
||||||
(Just varT', Just (_,bsT')) ->
|
(Just varT', Just (_,bsT')) ->
|
||||||
let (L matchL (G.Match _ _ (G.GRHSs rhsLs _))) = match
|
let (L matchL (G.Match _ _ (G.GRHSs rhsLs _))) = match
|
||||||
|
@ -36,6 +36,7 @@ module Language.Haskell.GhcMod.Gap (
|
|||||||
, benchmarkBuildInfo
|
, benchmarkBuildInfo
|
||||||
, benchmarkTargets
|
, benchmarkTargets
|
||||||
, toModuleString
|
, toModuleString
|
||||||
|
, GLMatch
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative hiding (empty)
|
import Control.Applicative hiding (empty)
|
||||||
@ -426,3 +427,12 @@ toModuleString mn = fromFilePath $ M.toFilePath mn
|
|||||||
where
|
where
|
||||||
fromFilePath :: FilePath -> String
|
fromFilePath :: FilePath -> String
|
||||||
fromFilePath fp = map (\c -> if c=='/' then '.' else c) fp
|
fromFilePath fp = map (\c -> if c=='/' then '.' else c) fp
|
||||||
|
|
||||||
|
----------------------------------------------------------------
|
||||||
|
----------------------------------------------------------------
|
||||||
|
|
||||||
|
#if __GLASGOW_HASKELL__ >= 708
|
||||||
|
type GLMatch = LMatch RdrName (LHsExpr RdrName)
|
||||||
|
#else
|
||||||
|
type GLMatch = LMatch RdrName
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user