some refactoring

This commit is contained in:
Nicolas Rolland 2015-11-27 11:12:30 +01:00
parent e1d2de96c8
commit bff86be69f
3 changed files with 5 additions and 11 deletions

View File

@ -100,8 +100,7 @@ stackCradle wdir = do
-- If dist/setup-config already exists the user probably wants to use cabal
-- rather than stack, or maybe that's just me ;)
whenM (liftIO $ doesFileExist $ setupConfigPath "dist") $ do
gmLog GmWarning "" $ (text
"'dist/setup-config' exists, ignoring Stack and using cabal-install instead.")
gmLog GmWarning "" $ text "'dist/setup-config' exists, ignoring Stack and using cabal-install instead."
mzero
senv <- MaybeT $ getStackEnv cabalDir

View File

@ -85,14 +85,9 @@ gmLog level loc' doc = do
-- | Appends a collection of logs to the logging environment, with effects
-- | if their log level specifies it should
gmLog' :: (MonadIO m, GmLog m, GmOut m) => GhcModLog -> m ()
gmLog' GhcModLog { gmLogMessages } = do
GhcModLog { gmLogLevel = Just level' } <- gmlHistory
mapM_ (\(level, _, msgDoc) -> when (level <= level') $ gmErrStrLn (docToString msgDoc)) gmLogMessages
-- instance Monoid GhcModLog takes the second debug level for some reason, so we need to force this to nothing
gmlJournal (GhcModLog Nothing (Last Nothing) gmLogMessages)
where
docToString msgDoc = dropWhileEnd isSpace $ gmRenderDoc msgDoc
gmAppendLog :: (MonadIO m, GmLog m, GmOut m) => GhcModLog -> m ()
gmAppendLog GhcModLog { gmLogMessages } = (\(level, loc, msgDoc) -> gmLog level loc msgDoc) `mapM_` gmLogMessages
gmVomit :: (MonadIO m, GmLog m, GmOut m, GmEnv m) => String -> Doc -> String -> m ()
gmVomit filename doc content = do

View File

@ -100,7 +100,7 @@ runGhcModT opt action = liftIO (getCurrentDirectory >>= canonicalizePath) >>= \d
withGhcModEnv dir' opt $ \(env,lg) ->
first (fst <$>) <$> runGhcModT' env defaultGhcModState
(gmSetLogLevel (ooptLogLevel $ optOutput opt) >>
gmLog' lg >>
gmAppendLog lg >>
action)
-- | @hoistGhcModT result@. Embed a GhcModT computation's result into a GhcModT