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
cdd4eccf
Commit
cdd4eccf
authored
Feb 24, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #375 from bgamari/set
Print DynFlags when :set is used without arguments
parents
b1f0d035
af688f4f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
9 deletions
+87
-9
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+7
-8
Util.hs
src/IHaskell/Eval/Util.hs
+80
-1
No files found.
src/IHaskell/Eval/Evaluate.hs
View file @
cdd4eccf
...
@@ -403,12 +403,11 @@ evalCommand _ (Module contents) state = wrapExecution state $ do
...
@@ -403,12 +403,11 @@ evalCommand _ (Module contents) state = wrapExecution state $ do
-- | Directives set via `:set`.
-- | Directives set via `:set`.
evalCommand
output
(
Directive
SetDynFlag
flags
)
state
=
evalCommand
output
(
Directive
SetDynFlag
flags
)
state
=
case
words
flags
of
case
words
flags
of
[]
->
do
[]
->
do
write
"Help for setting flags"
flags
<-
getSessionDynFlags
return
EvalOut
{
return
EvalOut
{
evalStatus
=
Success
,
evalStatus
=
Success
,
evalResult
=
Display
[
plain
"You can use the :set command to set IHaskell flags, and GHC flags"
],
evalResult
=
Display
[
plain
$
showSDoc
flags
$
vcat
[
pprDynFlags
False
flags
,
pprLanguages
False
flags
]
],
evalState
=
state
,
evalState
=
state
,
evalPager
=
""
,
evalPager
=
""
,
evalComms
=
[]
evalComms
=
[]
...
...
src/IHaskell/Eval/Util.hs
View file @
cdd4eccf
...
@@ -18,9 +18,11 @@ module IHaskell.Eval.Util (
...
@@ -18,9 +18,11 @@ module IHaskell.Eval.Util (
-- * Pretty printing
-- * Pretty printing
doc
,
doc
,
pprDynFlags
,
pprLanguages
)
where
)
where
import
ClassyPrelude
import
ClassyPrelude
hiding
((
<>
))
-- GHC imports.
-- GHC imports.
import
DynFlags
import
DynFlags
...
@@ -75,6 +77,83 @@ extensionFlag ext =
...
@@ -75,6 +77,83 @@ extensionFlag ext =
-- In that case, we disable the extension.
-- In that case, we disable the extension.
flagMatchesNo
ext
(
name
,
_
,
_
)
=
ext
==
"No"
++
name
flagMatchesNo
ext
(
name
,
_
,
_
)
=
ext
==
"No"
++
name
#
if
!
MIN_VERSION_ghc
(
7
,
10
,
0
)
flagSpecName
::
FlagSpec
a
->
String
flagSpecName
(
name
,
_
,
_
)
=
name
flagSpecFlag
::
FlagSpec
a
->
a
flagSpecFlag
(
_
,
flag
,
_
)
=
flag
#
endif
-- | Pretty-print dynamic flags (taken from 'InteractiveUI' module of `ghc-bin`)
pprDynFlags
::
Bool
-- ^ Whether to include flags which are on by default
->
DynFlags
->
SDoc
pprDynFlags
show_all
dflags
=
vcat
[
text
"GHCi-specific dynamic flag settings:"
$$
nest
2
(
vcat
(
map
(
setting
gopt
)
ghciFlags
)),
text
"other dynamic, non-language, flag settings:"
$$
nest
2
(
vcat
(
map
(
setting
gopt
)
others
)),
text
"warning settings:"
$$
nest
2
(
vcat
(
map
(
setting
wopt
)
DynFlags
.
fWarningFlags
))
]
where
setting
test
flag
|
quiet
=
empty
|
is_on
=
fstr
name
|
otherwise
=
fnostr
name
where
name
=
flagSpecName
flag
f
=
flagSpecFlag
flag
is_on
=
test
f
dflags
quiet
=
not
show_all
&&
test
f
default_dflags
==
is_on
default_dflags
=
defaultDynFlags
(
settings
dflags
)
fstr
str
=
text
"-f"
<>
text
str
fnostr
str
=
text
"-fno-"
<>
text
str
(
ghciFlags
,
others
)
=
partition
(
\
f
->
flagSpecFlag
f
`
elem
`
flgs
)
DynFlags
.
fFlags
flgs
=
[
Opt_PrintExplicitForalls
,
Opt_PrintExplicitKinds
,
Opt_PrintBindResult
,
Opt_BreakOnException
,
Opt_BreakOnError
,
Opt_PrintEvldWithShow
]
-- | Pretty-print the base language and active options (taken from `InteractiveUI` module of `ghc-bin`)
pprLanguages
::
Bool
-- ^ Whether to include flags which are on by default
->
DynFlags
->
SDoc
pprLanguages
show_all
dflags
=
vcat
[
text
"base language is: "
<>
case
language
dflags
of
Nothing
->
text
"Haskell2010"
Just
Haskell98
->
text
"Haskell98"
Just
Haskell2010
->
text
"Haskell2010"
,
(
if
show_all
then
text
"all active language options:"
else
text
"with the following modifiers:"
)
$$
nest
2
(
vcat
(
map
(
setting
xopt
)
DynFlags
.
xFlags
))
]
where
setting
test
flag
|
quiet
=
empty
|
is_on
=
text
"-X"
<>
text
name
|
otherwise
=
text
"-XNo"
<>
text
name
where
name
=
flagSpecName
flag
f
=
flagSpecFlag
flag
is_on
=
test
f
dflags
quiet
=
not
show_all
&&
test
f
default_dflags
==
is_on
default_dflags
=
defaultDynFlags
(
settings
dflags
)
`
lang_set
`
case
language
dflags
of
Nothing
->
Just
Haskell2010
other
->
other
-- | Set an extension and update flags.
-- | Set an extension and update flags.
-- Return @Nothing@ on success. On failure, return an error message.
-- Return @Nothing@ on success. On failure, return an error message.
setExtension
::
GhcMonad
m
=>
String
->
m
(
Maybe
String
)
setExtension
::
GhcMonad
m
=>
String
->
m
(
Maybe
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