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
20aa688a
Commit
20aa688a
authored
Feb 12, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding :m + and :m -. Closes #298.
parent
7bff2be3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+16
-0
Parser.hs
src/IHaskell/Eval/Parser.hs
+3
-1
Util.hs
src/IHaskell/Eval/Util.hs
+13
-0
No files found.
src/IHaskell/Eval/Evaluate.hs
View file @
20aa688a
...
...
@@ -452,6 +452,22 @@ evalCommand output (Directive SetExtension opts) state = do
let
set
=
concatMap
(
" -X"
++
)
$
words
opts
evalCommand
output
(
Directive
SetDynFlag
set
)
state
evalCommand
output
(
Directive
LoadModule
mods
)
state
=
wrapExecution
state
$
do
write
$
"Load Module: "
++
mods
let
stripped
@
(
firstChar
:
remainder
)
=
mods
(
modules
,
removeModule
)
=
case
firstChar
of
'+'
->
(
words
remainder
,
False
)
'-'
->
(
words
remainder
,
True
)
_
->
(
words
stripped
,
False
)
forM_
modules
$
\
modl
->
if
removeModule
then
removeImport
modl
else
evalImport
$
"import "
++
modl
return
mempty
evalCommand
a
(
Directive
SetOption
opts
)
state
=
do
write
$
"Option: "
++
opts
let
(
existing
,
nonExisting
)
=
partition
optionExists
$
words
opts
...
...
src/IHaskell/Eval/Parser.hs
View file @
20aa688a
...
...
@@ -67,6 +67,7 @@ data DirectiveType
|
SearchHoogle
-- ^ Search for something via Hoogle.
|
GetDoc
-- ^ Get documentation for an identifier via Hoogle.
|
GetKind
-- ^ Get the kind of a type via ':kind'.
|
LoadModule
-- ^ Load and unload modules via ':module'.
deriving
(
Show
,
Eq
)
-- | Pragma types. Only LANGUAGE pragmas are currently supported.
...
...
@@ -268,7 +269,8 @@ parseDirective (':':directive) line = case find rightDirective directives of
[]
->
False
dir
:
_
->
dir
`
elem
`
tail
(
inits
dirname
)
directives
=
[
(
GetType
,
"type"
)
[
(
LoadModule
,
"module"
)
,
(
GetType
,
"type"
)
,
(
GetKind
,
"kind"
)
,
(
GetInfo
,
"info"
)
,
(
SearchHoogle
,
"hoogle"
)
...
...
src/IHaskell/Eval/Util.hs
View file @
20aa688a
...
...
@@ -11,6 +11,7 @@ module IHaskell.Eval.Util (
-- * Code Evaluation
evalImport
,
removeImport
,
evalDeclarations
,
getType
,
getDescription
,
...
...
@@ -196,6 +197,18 @@ evalImport imports = do
Just
(
True
,
_
)
->
True
_
->
False
removeImport
::
GhcMonad
m
=>
String
->
m
()
removeImport
moduleName
=
do
flags
<-
getSessionDynFlags
ctx
<-
getContext
let
ctx'
=
filter
(
not
.
(
isImportOf
$
mkModuleName
moduleName
))
ctx
setContext
ctx'
where
isImportOf
::
ModuleName
->
InteractiveImport
->
Bool
isImportOf
name
(
IIModule
modName
)
=
name
==
modName
isImportOf
name
(
IIDecl
impDecl
)
=
name
==
unLoc
(
ideclName
impDecl
)
-- | Evaluate a series of declarations.
-- Return all names which were bound by these declarations.
evalDeclarations
::
GhcMonad
m
=>
String
->
m
[
String
]
...
...
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