mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-19 12:56:08 +00:00
Merge pull request #359 from houshuang/cleaner
Ignoring > in front of code lines
This commit is contained in:
commit
a8dc21459d
@ -228,13 +228,26 @@ data EvalOut = EvalOut {
|
||||
evalComms :: [CommInfo]
|
||||
}
|
||||
|
||||
cleanString :: String -> String
|
||||
cleanString x = if allBrackets then clean else str
|
||||
where
|
||||
str = strip x
|
||||
l = lines str
|
||||
allBrackets = all (fAny [isPrefixOf ">", null]) l
|
||||
fAny fs x = any ($x) fs
|
||||
clean = unlines $ map removeBracket l
|
||||
removeBracket ('>':xs) = xs
|
||||
removeBracket [] = []
|
||||
-- should never happen:
|
||||
removeBracket other = error $ "Expected bracket as first char, but got string: " ++ other
|
||||
|
||||
-- | Evaluate some IPython input code.
|
||||
evaluate :: KernelState -- ^ The kernel state.
|
||||
-> String -- ^ Haskell code or other interpreter commands.
|
||||
-> (EvaluationResult -> IO ()) -- ^ Function used to publish data outputs.
|
||||
-> Interpreter KernelState
|
||||
evaluate kernelState code output = do
|
||||
cmds <- parseString (strip code)
|
||||
cmds <- parseString (cleanString code)
|
||||
let execCount = getExecutionCounter kernelState
|
||||
|
||||
when (getLintStatus kernelState /= LintOff) $ liftIO $ do
|
||||
|
Loading…
x
Reference in New Issue
Block a user