mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-19 12:56:08 +00:00
Merge branch 'master' of github.com:gibiansky/IHaskell
This commit is contained in:
commit
8a37d1e656
@ -70,15 +70,19 @@ data Profile = Profile { ip :: IP -- ^ The IP on which to li
|
||||
|
||||
-- Convert the kernel profile to and from JSON.
|
||||
instance FromJSON Profile where
|
||||
parseJSON (Object v) =
|
||||
Profile <$> v .: "ip"
|
||||
<*> v .: "transport"
|
||||
<*> v .: "stdin_port"
|
||||
<*> v .: "control_port"
|
||||
<*> v .: "hb_port"
|
||||
<*> v .: "shell_port"
|
||||
<*> v .: "iopub_port"
|
||||
<*> (Text.encodeUtf8 <$> v .: "key")
|
||||
parseJSON (Object v) = do
|
||||
signatureScheme <- v .: "signature_scheme"
|
||||
case signatureScheme of
|
||||
"hmac-sha256" ->
|
||||
Profile <$> v .: "ip"
|
||||
<*> v .: "transport"
|
||||
<*> v .: "stdin_port"
|
||||
<*> v .: "control_port"
|
||||
<*> v .: "hb_port"
|
||||
<*> v .: "shell_port"
|
||||
<*> v .: "iopub_port"
|
||||
<*> (Text.encodeUtf8 <$> v .: "key")
|
||||
sig -> error $ "Unexpected signature scheme: " ++ sig
|
||||
parseJSON _ = fail "Expecting JSON object."
|
||||
|
||||
instance ToJSON Profile where
|
||||
|
@ -79,10 +79,6 @@ import Data.Version (versionBranch)
|
||||
|
||||
data ErrorOccurred = Success | Failure deriving (Show, Eq)
|
||||
|
||||
-- | Enable debugging output
|
||||
debug :: Bool
|
||||
debug = False
|
||||
|
||||
-- | Set GHC's verbosity for debugging
|
||||
ghcVerbosity :: Maybe Int
|
||||
ghcVerbosity = Nothing -- Just 5
|
||||
@ -257,12 +253,27 @@ evaluate kernelState code output = do
|
||||
cmds <- parseString (cleanString code)
|
||||
let execCount = getExecutionCounter kernelState
|
||||
|
||||
when (getLintStatus kernelState /= LintOff) $ liftIO $ do
|
||||
lintSuggestions <- lint cmds
|
||||
unless (noResults lintSuggestions) $
|
||||
output $ FinalResult lintSuggestions "" []
|
||||
-- Extract all parse errors.
|
||||
let justError x@ParseError{} = Just x
|
||||
justError _ = Nothing
|
||||
errs = mapMaybe (justError . unloc) cmds
|
||||
|
||||
updated <- case errs of
|
||||
-- Only run things if there are no parse errors.
|
||||
[] -> do
|
||||
when (getLintStatus kernelState /= LintOff) $ liftIO $ do
|
||||
lintSuggestions <- lint cmds
|
||||
unless (noResults lintSuggestions) $
|
||||
output $ FinalResult lintSuggestions "" []
|
||||
|
||||
runUntilFailure kernelState (map unloc cmds ++ [storeItCommand execCount])
|
||||
-- Print all parse errors.
|
||||
errs -> do
|
||||
forM_ errs $ \err -> do
|
||||
out <- evalCommand output err kernelState
|
||||
liftIO $ output $ FinalResult (evalResult out) "" []
|
||||
return kernelState
|
||||
|
||||
updated <- runUntilFailure kernelState (map unloc cmds ++ [storeItCommand execCount])
|
||||
return updated {
|
||||
getExecutionCounter = execCount + 1
|
||||
}
|
||||
@ -408,7 +419,7 @@ evalCommand _ (Module contents) state = wrapExecution state $ do
|
||||
Nothing -> doLoadModule modName modName
|
||||
|
||||
-- | Directives set via `:set`.
|
||||
evalCommand output (Directive SetDynFlag flags) state =
|
||||
evalCommand output (Directive SetDynFlag flags) state = safely state $
|
||||
case words flags of
|
||||
[] -> do
|
||||
flags <- getSessionDynFlags
|
||||
|
Loading…
x
Reference in New Issue
Block a user