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
f51efb3f
Commit
f51efb3f
authored
Mar 28, 2017
by
Andrei Barbu
Committed by
GitHub
Mar 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from vaibhavsagar/execStmt
Replace runStmt with execStmt
parents
5f88dcbe
3f9a4226
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+23
-23
No files found.
src/IHaskell/Eval/Evaluate.hs
View file @
f51efb3f
...
...
@@ -179,7 +179,7 @@ interpret libdir allowedStdin action = runGhc (Just libdir) $ do
dir
<-
liftIO
getIHaskellDir
let
cmd
=
printf
"IHaskell.IPython.Stdin.fixStdin
\"
%s
\"
"
dir
when
(
allowedStdin
&&
hasSupportLibraries
)
$
void
$
runStmt
cmd
RunToCompletion
execStmt
cmd
execOptions
initializeItVariable
...
...
@@ -279,7 +279,7 @@ initializeItVariable :: Interpreter ()
initializeItVariable
=
-- This is required due to the way we handle `it` in the wrapper statements - if it doesn't exist,
-- the first statement will fail.
void
$
runStmt
"let it = ()"
RunToCompletion
void
$
execStmt
"let it = ()"
execOptions
-- | Publisher for IHaskell outputs. The first argument indicates whether this output is final
-- (true) or intermediate (false).
...
...
@@ -694,7 +694,7 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
let
cmd
=
printf
"IHaskellDirectory.setCurrentDirectory
\"
%s
\"
"
$
replace
" "
"
\\
"
$
replace
"
\"
"
"
\\\"
"
directory
runStmt
cmd
RunToCompletion
execStmt
cmd
execOptions
return
mempty
else
return
$
displayError
$
printf
"No such directory: '%s'"
directory
cmd
->
liftIO
$
do
...
...
@@ -1119,7 +1119,7 @@ keepingItVariable act = do
gen
<-
liftIO
getStdGen
let
rand
=
take
20
$
randomRs
(
'0'
,
'9'
)
gen
var
name
=
name
++
rand
goStmt
s
=
runStmt
s
RunToCompletion
goStmt
s
=
execStmt
s
execOptions
itVariable
=
var
"it_var_temp_"
goStmt
$
printf
"let %s = it"
itVariable
...
...
@@ -1132,7 +1132,7 @@ data Captured a = CapturedStmt String
capturedEval
::
(
String
->
IO
()
)
-- ^ Function used to publish intermediate output.
->
Captured
a
-- ^ Statement to evaluate.
->
Interpreter
(
String
,
Run
Result
)
-- ^ Return the output and result.
->
Interpreter
(
String
,
Exec
Result
)
-- ^ Return the output and result.
capturedEval
output
stmt
=
do
-- Generate random variable names to use so that we cannot accidentally override the variables by
-- using the right names in the terminal.
...
...
@@ -1173,16 +1173,16 @@ capturedEval output stmt = do
,
printf
"let it = %s"
itVariable
]
goStmt
::
String
->
Ghc
Run
Result
goStmt
s
=
runStmt
s
RunToCompletion
goStmt
::
String
->
Ghc
Exec
Result
goStmt
s
=
execStmt
s
execOptions
runWithResult
(
CapturedStmt
str
)
=
goStmt
str
runWithResult
(
CapturedIO
io
)
=
do
status
<-
gcatch
(
liftIO
io
>>
return
NoException
)
(
return
.
AnyException
)
return
$
case
status
of
NoException
->
RunOk
[]
AnyException
e
->
RunException
e
NoException
->
ExecComplete
(
Right
[]
)
0
AnyException
e
->
ExecComplete
(
Left
e
)
0
-- Initialize evaluation context.
results
<-
forM
initStmts
goStmt
...
...
@@ -1295,7 +1295,7 @@ evalStatementOrIO publish state cmd = do
(
printed
,
result
)
<-
capturedEval
output
cmd
case
result
of
RunOk
names
->
do
ExecComplete
(
Right
names
)
_
->
do
dflags
<-
getSessionDynFlags
let
allNames
=
map
(
showPpr
dflags
)
names
...
...
@@ -1327,8 +1327,8 @@ evalStatementOrIO publish state cmd = do
-- Return plain and html versions. Previously there was only a plain version.
text
->
Display
[
plain
$
joined
++
"
\n
"
++
text
,
html
$
htmled
++
mono
text
]
RunException
exception
->
throw
exception
Run
Break
{}
->
error
"Should not break."
ExecComplete
(
Left
exception
)
_
->
throw
exception
Exec
Break
{}
->
error
"Should not break."
-- Read from a file handle until we hit a delimiter or until we've read as many characters as
-- requested
...
...
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