ghc-mod/Language/Haskell/GhcMod/Check.hs

59 lines
1.9 KiB
Haskell
Raw Normal View History

module Language.Haskell.GhcMod.Check (
checkSyntax
, check
, expandTemplate
, expand
) where
2010-03-11 10:03:17 +00:00
2014-04-28 04:52:28 +00:00
import Control.Applicative ((<$>))
import Language.Haskell.GhcMod.DynFlags
import qualified Language.Haskell.GhcMod.Gap as Gap
2014-04-28 12:47:08 +00:00
import Language.Haskell.GhcMod.Logger
2014-09-22 02:32:28 +00:00
import Language.Haskell.GhcMod.Monad (IOish, GhcModT)
2014-07-18 05:05:20 +00:00
import Language.Haskell.GhcMod.Target (setTargetFiles)
2010-03-11 10:03:17 +00:00
----------------------------------------------------------------
2013-05-20 05:28:56 +00:00
-- | Checking syntax of a target file using GHC.
-- Warnings and errors are returned.
checkSyntax :: IOish m
=> [FilePath] -- ^ The target files.
-> GhcModT m String
2014-08-18 07:55:41 +00:00
checkSyntax [] = return ""
checkSyntax files = either id id <$> check files
2010-04-28 12:43:32 +00:00
----------------------------------------------------------------
2013-05-20 05:28:56 +00:00
-- | Checking syntax of a target file using GHC.
-- Warnings and errors are returned.
check :: IOish m
=> [FilePath] -- ^ The target files.
-> GhcModT m (Either String String)
{-
check fileNames = overrideGhcUserOptions $ \ghcOpts -> do
2014-08-19 08:18:36 +00:00
withLogger (setAllWarningFlags . setNoMaxRelevantBindings . Gap.setWarnTypedHoles . Gap.setDeferTypeErrors) $ do
_ <- G.setSessionDynFlags =<< addCmdOpts ghcOpts =<< G.getSessionDynFlags
setTargetFiles fileNames
-}
check fileNames =
withLogger (setAllWarningFlags . setNoMaxRelevantBindings) $
setTargetFiles fileNames
----------------------------------------------------------------
2014-04-26 11:24:47 +00:00
-- | Expanding Haskell Template.
expandTemplate :: IOish m
=> [FilePath] -- ^ The target files.
-> GhcModT m String
2014-08-18 07:55:41 +00:00
expandTemplate [] = return ""
expandTemplate files = either id id <$> expand files
----------------------------------------------------------------
2014-04-26 11:24:47 +00:00
-- | Expanding Haskell Template.
expand :: IOish m
=> [FilePath] -- ^ The target files.
-> GhcModT m (Either String String)
2014-08-19 08:18:36 +00:00
expand fileNames = withLogger (Gap.setDumpSplices . setNoWarningFlags) $
2014-04-28 04:52:28 +00:00
setTargetFiles fileNames