[commit: ghc] master: Implement -f[no-]print-unicode-syntax flag for unicode syntax output (#8959) (6dd2765)
git at git.haskell.org
git at git.haskell.org
Tue Apr 14 14:11:21 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/6dd2765a300bb139b4ab67688dbc6f48de66969b/ghc
>---------------------------------------------------------------
commit 6dd2765a300bb139b4ab67688dbc6f48de66969b
Author: Bertram Felgenhauer <int-e at gmx.de>
Date: Tue Apr 14 09:10:52 2015 -0500
Implement -f[no-]print-unicode-syntax flag for unicode syntax output (#8959)
There is currently no way to separate whether UnicodeSyntax is accepted
for input from the corresponding output syntax using unicode symbols.
This patch implements a separate flag for affecting ghc(i)'s output.
Signed-off-by: Bertram Felgenhauer <int-e at gmx.de>
Reviewed By: nomeata, austin
Differential Revision: https://phabricator.haskell.org/D807
GHC Trac Issues: #8959
>---------------------------------------------------------------
6dd2765a300bb139b4ab67688dbc6f48de66969b
compiler/main/DynFlags.hs | 5 ++++-
docs/users_guide/flags.xml | 10 ++++++++--
docs/users_guide/using.xml | 14 ++++++++++++--
ghc/InteractiveUI.hs | 1 +
testsuite/tests/ghci/scripts/T8959.script | 4 ++--
testsuite/tests/ghci/scripts/T8959b.script | 1 +
testsuite/tests/ghci/scripts/all.T | 2 +-
7 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index f3e3066..446381e 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -329,6 +329,7 @@ data GeneralFlag
| Opt_PrintExplicitForalls
| Opt_PrintExplicitKinds
+ | Opt_PrintUnicodeSyntax
-- optimisation opts
| Opt_CallArity
@@ -1767,8 +1768,9 @@ lang_set dflags lang =
extensionFlags = flattenExtensionFlags lang (extensions dflags)
}
+-- | Check whether to use unicode syntax for output
useUnicodeSyntax :: DynFlags -> Bool
-useUnicodeSyntax = xopt Opt_UnicodeSyntax
+useUnicodeSyntax = gopt Opt_PrintUnicodeSyntax
-- | Set the Haskell language standard to use
setLanguage :: Language -> DynP ()
@@ -2972,6 +2974,7 @@ fFlags = [
flagGhciSpec "print-evld-with-show" Opt_PrintEvldWithShow,
flagSpec "print-explicit-foralls" Opt_PrintExplicitForalls,
flagSpec "print-explicit-kinds" Opt_PrintExplicitKinds,
+ flagSpec "print-unicode-syntax" Opt_PrintUnicodeSyntax,
flagSpec "prof-cafs" Opt_AutoSccsOnIndividualCafs,
flagSpec "prof-count-entries" Opt_ProfCountEntries,
flagSpec "regs-graph" Opt_RegsGraph,
diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
index 4d4706b..f62fe22 100644
--- a/docs/users_guide/flags.xml
+++ b/docs/users_guide/flags.xml
@@ -37,17 +37,23 @@
</row>
<row>
<entry><option>-fprint-explicit-foralls</option></entry>
- <entry>print explicit <literal>forall</literal> quantification in types</entry>
+ <entry>Print explicit <literal>forall</literal> quantification in types. See also <option>-XExplicitForAll</option></entry>
<entry>dynamic</entry>
<entry>-fno-print-explicit-foralls</entry>
</row>
<row>
<entry><option>-fprint-explicit-kinds</option></entry>
- <entry>print explicit kind foralls and kind arguments in types</entry>
+ <entry>Print explicit kind foralls and kind arguments in types. See also <option>-XKindSignature</option></entry>
<entry>dynamic</entry>
<entry>-fno-print-explicit-kinds</entry>
</row>
<row>
+ <entry><option>-fprint-unicode-syntax</option></entry>
+ <entry>Use unicode syntax when printing expressions, types and kinds. See also <option>-XUnicodeSyntax</option></entry>
+ <entry>dynamic</entry>
+ <entry>-fno-print-unicode-syntax</entry>
+ </row>
+ <row>
<entry><option>-ferror-spans</option></entry>
<entry>output full span in error messages</entry>
<entry>dynamic</entry>
diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml
index 68d2752..2ac51f6 100644
--- a/docs/users_guide/using.xml
+++ b/docs/users_guide/using.xml
@@ -896,12 +896,13 @@ ghc -c Foo.hs
<varlistentry>
- <term><option>--fprint-explicit-foralls, -fprint-explicit-kinds</option>
+ <term><option>--fprint-explicit-foralls, -fprint-explicit-kinds, -fprint-unicode-syntax</option>
<indexterm><primary><option>-fprint-explicit-foralls</option></primary></indexterm>
<indexterm><primary><option>-fprint-explicit-kinds</option></primary></indexterm>
+ <indexterm><primary><option>-fprint-unicode-syntax</option></primary></indexterm>
</term>
<listitem>
- <para>These two flags control the way in which GHC displays types, in error messages and in GHCi.
+ <para>These three flags control the way in which GHC displays types, in error messages and in GHCi.
Using <option>-fprint-explicit-foralls</option> makes GHC print explicit <literal>forall</literal>
quantification at the top level of a type; normally this is suppressed. For example, in GHCi:
<screen>
@@ -946,6 +947,15 @@ ghci> :t MkT
MkT :: forall (k :: BOX) (a :: k). T k a
</screen>
</para>
+ <para>
+ When <option>-fprint-unicode-syntax</option> is enabled, GHC prints type signatures using
+ the unicode symbols from the <option>-XUnicodeSyntax</option> extension.
+<screen>
+ghci> :set -fprint-unicode-syntax
+ghci> :t (>>)
+(>>) :: ∀ (m :: * → *) a b. Monad m ⇒ m a → m b → m b
+</screen>
+ </para>
</listitem>
</varlistentry>
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index fc2883f..f5b69ae 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -2073,6 +2073,7 @@ showDynFlags show_all dflags = do
DynFlags.fFlags
flgs = [ Opt_PrintExplicitForalls
, Opt_PrintExplicitKinds
+ , Opt_PrintUnicodeSyntax
, Opt_PrintBindResult
, Opt_BreakOnException
, Opt_BreakOnError
diff --git a/testsuite/tests/ghci/scripts/T8959.script b/testsuite/tests/ghci/scripts/T8959.script
index 124b2ab..da60aeb 100644
--- a/testsuite/tests/ghci/scripts/T8959.script
+++ b/testsuite/tests/ghci/scripts/T8959.script
@@ -5,14 +5,14 @@
:t () >- () -< () >>- () -<< ()
let fun foo | True <- () = ()
-:set -XUnicodeSyntax
+:set -fprint-unicode-syntax
:t lookup
:t undefined :: (forall a. a -> a) -> a
:t () >- () -< () >>- () -<< ()
let fun foo | True <- () = ()
-:set -XNoUnicodeSyntax
+:set -fno-print-unicode-syntax
:t lookup
:t undefined :: (forall a. a -> a) -> a
diff --git a/testsuite/tests/ghci/scripts/T8959b.script b/testsuite/tests/ghci/scripts/T8959b.script
index f3c23c9..e4d0df6 100644
--- a/testsuite/tests/ghci/scripts/T8959b.script
+++ b/testsuite/tests/ghci/scripts/T8959b.script
@@ -1 +1,2 @@
+:set -fprint-unicode-syntax
:l T8959b.hs
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index b576a63..b97eede 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -187,7 +187,7 @@ test('T8831', normal, ghci_script, ['T8831.script'])
test('T8917', normal, ghci_script, ['T8917.script'])
test('T8931', normal, ghci_script, ['T8931.script'])
test('T8959', normal, ghci_script, ['T8959.script'])
-test('T8959b', expect_broken(8959), ghci_script, ['T8959b.script'])
+test('T8959b', normal, ghci_script, ['T8959b.script'])
test('T9181', normal, ghci_script, ['T9181.script'])
test('T9086b', normal, ghci_script, ['T9086b.script'])
test('T9140', combined_output, ghci_script, ['T9140.script'])
More information about the ghc-commits
mailing list