Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
cd941890
Commit
cd941890
authored
Jan 16, 2022
by
Falco Peijnenburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return error when evaluation failed
parent
6362b9b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
Main.hs
main/Main.hs
+5
-2
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+7
-7
No files found.
main/Main.hs
View file @
cd941890
...
...
@@ -309,7 +309,10 @@ replyTo _ interface req@ExecuteRequest { getCode = code } replyHeader state = do
-- Run code and publish to the frontend as we go.
let
widgetMessageHandler
=
widgetHandler
send
replyHeader
publish
=
publishResult
send
replyHeader
displayed
updateNeeded
pOut
(
usePager
state
)
updatedState
<-
evaluate
state
(
T
.
unpack
code
)
publish
widgetMessageHandler
(
updatedState
,
errorOccurred
)
<-
evaluate
state
(
T
.
unpack
code
)
publish
widgetMessageHandler
let
executeReplyStatus
=
case
errorOccurred
of
Success
->
Ok
Failure
->
Err
-- Take pager output if we're using the pager.
pager
<-
if
usePager
state
...
...
@@ -320,7 +323,7 @@ replyTo _ interface req@ExecuteRequest { getCode = code } replyHeader state = do
{
header
=
replyHeader
,
pagerOutput
=
pager
,
executionCounter
=
execCount
,
status
=
Ok
,
status
=
executeReplyStatus
})
-- Check for a trailing empty line. If it doesn't exist, we assume the code is incomplete,
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
cd941890
...
...
@@ -383,7 +383,7 @@ evaluate :: KernelState -- ^ The kernel state.
->
String
-- ^ Haskell code or other interpreter commands.
->
Publisher
-- ^ Function used to publish data outputs.
->
(
KernelState
->
[
WidgetMsg
]
->
IO
KernelState
)
-- ^ Function to handle widget messages
->
Interpreter
KernelState
->
Interpreter
(
KernelState
,
ErrorOccurred
)
evaluate
kernelState
code
output
widgetHandler
=
do
cmds
<-
parseString
(
cleanString
code
)
let
execCount
=
getExecutionCounter
kernelState
...
...
@@ -393,7 +393,7 @@ evaluate kernelState code output widgetHandler = do
justError
_
=
Nothing
errs
=
mapMaybe
(
justError
.
unloc
)
cmds
updated
<-
case
errs
of
(
updated
,
errorOccurred
)
<-
case
errs
of
-- Only run things if there are no parse errors.
[]
->
do
...
...
@@ -412,16 +412,16 @@ evaluate kernelState code output widgetHandler = do
liftIO
$
output
(
FinalResult
(
evalResult
out
)
[]
[]
)
(
evalStatus
out
)
return
kernelState
return
(
kernelState
,
Failure
)
return
updated
{
getExecutionCounter
=
execCount
+
1
}
return
(
updated
{
getExecutionCounter
=
execCount
+
1
},
errorOccurred
)
where
noResults
(
Display
res
)
=
null
res
noResults
(
ManyDisplay
res
)
=
all
noResults
res
runUntilFailure
::
KernelState
->
[
CodeBlock
]
->
Interpreter
KernelState
runUntilFailure
state
[]
=
return
state
runUntilFailure
::
KernelState
->
[
CodeBlock
]
->
Interpreter
(
KernelState
,
ErrorOccurred
)
runUntilFailure
state
[]
=
return
(
state
,
Success
)
runUntilFailure
state
(
cmd
:
rest
)
=
do
evalOut
<-
evalCommand
output
cmd
state
...
...
@@ -458,7 +458,7 @@ evaluate kernelState code output widgetHandler = do
case
evalStatus
evalOut
of
Success
->
runUntilFailure
newState
rest
Failure
->
return
newState
Failure
->
return
(
newState
,
Failure
)
storeItCommand
execCount
=
Statement
$
printf
"let it%d = it"
execCount
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment