Commit 6dd2765a authored by Bertram Felgenhauer's avatar Bertram Felgenhauer Committed by Austin Seipp

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's avatarBertram Felgenhauer <int-e@gmx.de>

Reviewed By: nomeata, austin

Differential Revision: https://phabricator.haskell.org/D807

GHC Trac Issues: #8959
parent 5fded20c
......@@ -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,
......
......@@ -37,16 +37,22 @@
</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>
......
......@@ -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>
......@@ -944,6 +945,15 @@ MkT :: forall (k :: BOX) (a :: k). T a
ghci> :set -fprint-explicit-foralls
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 (>>)
(>>) :: &forall; (m :: * &rarr; *) a b. Monad m &rArr; m a &rarr; m b &rarr; m b
</screen>
</para>
</listitem>
......
......@@ -2073,6 +2073,7 @@ showDynFlags show_all dflags = do
DynFlags.fFlags
flgs = [ Opt_PrintExplicitForalls
, Opt_PrintExplicitKinds
, Opt_PrintUnicodeSyntax
, Opt_PrintBindResult
, Opt_BreakOnException
, Opt_BreakOnError
......
......@@ -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
......
......@@ -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'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment