2017-01-12 16:36:47 +01:00
|
|
|
module GhcMod.Check (
|
2014-04-26 17:54:15 +09:00
|
|
|
checkSyntax
|
|
|
|
|
, check
|
|
|
|
|
, expandTemplate
|
|
|
|
|
, expand
|
|
|
|
|
) where
|
2010-03-11 19:03:17 +09:00
|
|
|
|
2015-08-03 03:09:56 +02:00
|
|
|
import Control.Applicative
|
|
|
|
|
import Prelude
|
2014-07-12 03:30:06 +02:00
|
|
|
import Language.Haskell.GhcMod.DynFlags
|
2014-04-26 17:54:15 +09:00
|
|
|
import qualified Language.Haskell.GhcMod.Gap as Gap
|
2014-04-28 21:47:08 +09:00
|
|
|
import Language.Haskell.GhcMod.Logger
|
2015-03-03 21:12:43 +01:00
|
|
|
import Language.Haskell.GhcMod.Monad
|
2010-03-11 19:03:17 +09:00
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
2013-05-20 14:28:56 +09:00
|
|
|
-- | Checking syntax of a target file using GHC.
|
|
|
|
|
-- Warnings and errors are returned.
|
2014-07-12 11:16:16 +02:00
|
|
|
checkSyntax :: IOish m
|
|
|
|
|
=> [FilePath] -- ^ The target files.
|
|
|
|
|
-> GhcModT m String
|
2014-08-18 16:55:41 +09:00
|
|
|
checkSyntax [] = return ""
|
2014-08-19 04:49:44 +02:00
|
|
|
checkSyntax files = either id id <$> check files
|
2010-04-28 21:43:32 +09:00
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
2013-05-20 14:28:56 +09:00
|
|
|
-- | Checking syntax of a target file using GHC.
|
|
|
|
|
-- Warnings and errors are returned.
|
2014-07-12 11:16:16 +02:00
|
|
|
check :: IOish m
|
|
|
|
|
=> [FilePath] -- ^ The target files.
|
|
|
|
|
-> GhcModT m (Either String String)
|
2015-03-03 21:12:43 +01:00
|
|
|
check files =
|
2015-03-09 22:04:04 +01:00
|
|
|
runGmlTWith
|
2015-03-03 21:12:43 +01:00
|
|
|
(map Left files)
|
|
|
|
|
return
|
2016-05-22 02:55:06 +02:00
|
|
|
((fmap fst <$>) . withLogger Gap.setNoMaxRelevantBindings)
|
2015-03-03 21:12:43 +01:00
|
|
|
(return ())
|
2014-04-26 17:54:15 +09:00
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
2014-04-26 20:24:47 +09:00
|
|
|
-- | Expanding Haskell Template.
|
2014-07-12 11:16:16 +02:00
|
|
|
expandTemplate :: IOish m
|
|
|
|
|
=> [FilePath] -- ^ The target files.
|
|
|
|
|
-> GhcModT m String
|
2014-08-18 16:55:41 +09:00
|
|
|
expandTemplate [] = return ""
|
2014-08-19 04:49:44 +02:00
|
|
|
expandTemplate files = either id id <$> expand files
|
2014-04-26 17:54:15 +09:00
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
2014-04-26 20:24:47 +09:00
|
|
|
-- | Expanding Haskell Template.
|
2015-03-03 21:12:43 +01:00
|
|
|
expand :: IOish m => [FilePath] -> GhcModT m (Either String String)
|
|
|
|
|
expand files =
|
2015-03-09 22:04:04 +01:00
|
|
|
runGmlTWith
|
2015-03-03 21:12:43 +01:00
|
|
|
(map Left files)
|
|
|
|
|
return
|
|
|
|
|
((fmap fst <$>) . withLogger (Gap.setDumpSplices . setNoWarningFlags))
|
|
|
|
|
(return ())
|