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
9741786d
Unverified
Commit
9741786d
authored
Jul 23, 2021
by
David Davó
Committed by
GitHub
Jul 23, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gibiansky:master' into master
parents
cc718f3e
6f1b51bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+63
-0
Parser.hs
src/IHaskell/Eval/Parser.hs
+2
-0
No files found.
src/IHaskell/Eval/Evaluate.hs
View file @
9741786d
...
...
@@ -698,6 +698,8 @@ evalCommand _ (Directive LoadFile names) state = wrapExecution state $ do
doLoadModule
filename
modName
return
(
ManyDisplay
displays
)
evalCommand
_
(
Directive
Reload
_
)
state
=
wrapExecution
state
doReload
evalCommand
publish
(
Directive
ShellCmd
cmd
)
state
=
wrapExecution
state
$
-- Assume the first character of 'cmd' is '!'.
case
words
$
drop
1
cmd
of
...
...
@@ -1151,6 +1153,67 @@ doLoadModule name modName = do
return
$
displayError
$
"Failed to load module "
++
modName
++
": "
++
show
exception
doReload
::
Ghc
Display
doReload
=
do
-- Remember which modules we've loaded before.
importedModules
<-
getContext
flip
gcatch
(
unload
importedModules
)
$
do
-- Compile loaded modules.
flags
<-
getSessionDynFlags
errRef
<-
liftIO
$
newIORef
[]
_
<-
setSessionDynFlags
$
flip
gopt_set
Opt_BuildDynamicToo
flags
{
hscTarget
=
objTarget
flags
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
,
log_action
=
\
_dflags
_warn
_sev
_srcspan
msg
->
modifyIORef'
errRef
(
showSDoc
flags
msg
:
)
#
else
,
log_action
=
\
_dflags
_sev
_srcspan
_ppr
_style
msg
->
modifyIORef'
errRef
(
showSDoc
flags
msg
:
)
#
endif
}
-- Store the old targets in case of failure.
oldTargets
<-
getTargets
result
<-
load
LoadAllTargets
-- Reset the context, since loading things screws it up.
initializeItVariable
-- Reset targets if we failed.
case
result
of
Failed
->
setTargets
oldTargets
Succeeded
{}
->
return
()
-- Add imports
setContext
importedModules
-- Switch back to interpreted mode.
_
<-
setSessionDynFlags
flags
case
result
of
Succeeded
->
return
mempty
Failed
->
do
errorStrs
<-
unlines
<$>
reverse
<$>
liftIO
(
readIORef
errRef
)
return
$
displayError
$
"Failed to reload.
\n
"
++
errorStrs
where
unload
::
[
InteractiveImport
]
->
SomeException
->
Ghc
Display
unload
imported
exception
=
do
print
$
show
exception
-- Explicitly clear targets
setTargets
[]
_
<-
load
LoadAllTargets
-- Switch to interpreted mode!
flags
<-
getSessionDynFlags
_
<-
setSessionDynFlags
flags
{
hscTarget
=
HscInterpreted
}
-- Return to old context, make sure we have `it`.
setContext
imported
initializeItVariable
return
$
displayError
$
"Failed to reload."
objTarget
::
DynFlags
->
HscTarget
#
if
MIN_VERSION_ghc
(
8
,
10
,
0
)
objTarget
=
defaultObjectTarget
...
...
src/IHaskell/Eval/Parser.hs
View file @
9741786d
...
...
@@ -65,6 +65,7 @@ data DirectiveType = GetType -- ^ Get the type of an expression via ':type'
|
GetKindBang
-- ^ Get the kind and normalised type via ':kind!'.
|
LoadModule
-- ^ Load and unload modules via ':module'.
|
SPrint
-- ^ Print without evaluating via ':sprint'.
|
Reload
-- ^ Reload.
deriving
(
Show
,
Eq
)
-- | Pragma types. Only LANGUAGE pragmas are currently supported. Other pragma types are kept around
...
...
@@ -288,6 +289,7 @@ parseDirective (':':directive) ln =
,
(
SetExtension
,
"extension"
)
,
(
GetHelp
,
"?"
)
,
(
GetHelp
,
"help"
)
,
(
Reload
,
"reload"
)
,
(
SPrint
,
"sprint"
)
]
parseDirective
_
_
=
error
"Directive must start with colon!"
...
...
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