2017-05-28 02:22:56 +00:00
|
|
|
module GhcMod.Exe.Check (
|
2014-04-26 08:54:15 +00:00
|
|
|
checkSyntax
|
|
|
|
, check
|
|
|
|
, expandTemplate
|
|
|
|
, expand
|
|
|
|
) where
|
2010-03-11 10:03:17 +00:00
|
|
|
|
2015-08-03 01:09:56 +00:00
|
|
|
import Control.Applicative
|
|
|
|
import Prelude
|
2017-05-28 02:22:56 +00:00
|
|
|
import GhcMod.DynFlags
|
|
|
|
import qualified GhcMod.Gap as Gap
|
|
|
|
import GhcMod.Logger
|
|
|
|
import GhcMod.Monad
|
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.
|
2014-07-12 09:16:16 +00:00
|
|
|
checkSyntax :: IOish m
|
|
|
|
=> [FilePath] -- ^ The target files.
|
|
|
|
-> GhcModT m String
|
2014-08-18 07:55:41 +00:00
|
|
|
checkSyntax [] = return ""
|
2014-08-19 02:49:44 +00:00
|
|
|
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.
|
2014-07-12 09:16:16 +00:00
|
|
|
check :: IOish m
|
|
|
|
=> [FilePath] -- ^ The target files.
|
|
|
|
-> GhcModT m (Either String String)
|
2015-03-03 20:12:43 +00:00
|
|
|
check files =
|
2015-03-09 21:04:04 +00:00
|
|
|
runGmlTWith
|
2015-03-03 20:12:43 +00:00
|
|
|
(map Left files)
|
|
|
|
return
|
2016-05-22 00:55:06 +00:00
|
|
|
((fmap fst <$>) . withLogger Gap.setNoMaxRelevantBindings)
|
2015-03-03 20:12:43 +00:00
|
|
|
(return ())
|
2014-04-26 08:54:15 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2014-04-26 11:24:47 +00:00
|
|
|
-- | Expanding Haskell Template.
|
2014-07-12 09:16:16 +00:00
|
|
|
expandTemplate :: IOish m
|
|
|
|
=> [FilePath] -- ^ The target files.
|
|
|
|
-> GhcModT m String
|
2014-08-18 07:55:41 +00:00
|
|
|
expandTemplate [] = return ""
|
2014-08-19 02:49:44 +00:00
|
|
|
expandTemplate files = either id id <$> expand files
|
2014-04-26 08:54:15 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2014-04-26 11:24:47 +00:00
|
|
|
-- | Expanding Haskell Template.
|
2015-03-03 20:12:43 +00:00
|
|
|
expand :: IOish m => [FilePath] -> GhcModT m (Either String String)
|
|
|
|
expand files =
|
2015-03-09 21:04:04 +00:00
|
|
|
runGmlTWith
|
2015-03-03 20:12:43 +00:00
|
|
|
(map Left files)
|
|
|
|
return
|
|
|
|
((fmap fst <$>) . withLogger (Gap.setDumpSplices . setNoWarningFlags))
|
|
|
|
(return ())
|