Remove use of managed for starting the scenario service (#1508)

Ironically `managed` didn't turn out to make our code more manageable
and we ended up mostly using it in very isolated places only to then
immediately convert it back to bracket-style functions using `with`.

This PR also removes the use of `managed` from the GcpLogger which was
the only other place where we are using it and it finally kills the
rather silly logic that starting up the scenario service was tied to
having an event logger.
This commit is contained in:
Moritz Kiefer 2019-06-04 17:17:05 +02:00 committed by GitHub
parent 30b531a51f
commit b6fd3c1a75
3 changed files with 3 additions and 7 deletions

View File

@ -24,7 +24,6 @@ import Control.Monad.Except
import Development.IDE.Types.Options (IdeOptions(..)) import Development.IDE.Types.Options (IdeOptions(..))
import Development.IDE.State.FileStore import Development.IDE.State.FileStore
import qualified Development.IDE.Logger as Logger import qualified Development.IDE.Logger as Logger
import Data.Maybe
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as Set import qualified Data.Set as Set
import Development.IDE.Functions.GHCError import Development.IDE.Functions.GHCError
@ -70,14 +69,14 @@ unsafeClearDiagnostics = unsafeClearAllDiagnostics
-- | Initialise the Compiler Service. -- | Initialise the Compiler Service.
initialise :: Rules () initialise :: Rules ()
-> Maybe (Event -> IO ()) -> (Event -> IO ())
-> Logger.Handle -> Logger.Handle
-> IdeOptions -> IdeOptions
-> VFSHandle -> VFSHandle
-> IO IdeState -> IO IdeState
initialise mainRule toDiags logger options vfs = initialise mainRule toDiags logger options vfs =
shakeOpen shakeOpen
(fromMaybe (const $ pure ()) toDiags) toDiags
logger logger
(setProfiling options $ (setProfiling options $
shakeOptions { shakeThreads = optThreads options shakeOptions { shakeThreads = optThreads options

View File

@ -52,7 +52,4 @@ data Event
| EventFileValidation Int Int | EventFileValidation Int Int
-- ^ @EventFileValidation finishedValidations totalValidations @ -- ^ @EventFileValidation finishedValidations totalValidations @
-- How many validations have we finished of how many total. -- How many validations have we finished of how many total.
| EventFatalError !T.Text
-- ^ @EventFatalError reason@: A fatal error occurred in the compiler and
-- the compiler cannot continue.
deriving Show deriving Show

View File

@ -42,7 +42,7 @@ main = do
vfs <- makeVFSHandle vfs <- makeVFSHandle
ide <- initialise ide <- initialise
mainRule mainRule
(Just $ showEvent lock) (showEvent lock)
(makeOneHandle $ withLock lock . T.putStrLn) (makeOneHandle $ withLock lock . T.putStrLn)
IdeOptions IdeOptions
{optPreprocessor = (,) [] {optPreprocessor = (,) []