Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
e2467dbd
by Ryan Hendrickson at 2025-06-09T13:07:05-04:00
13 changed files:
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/Parser/PostProcess.hs
- testsuite/tests/ghci/scripts/T12550.stdout
- testsuite/tests/ghci/scripts/T8959b.stderr
- testsuite/tests/ghci/scripts/all.T
- + testsuite/tests/ghci/scripts/print-unicode-syntax.script
- + testsuite/tests/ghci/scripts/print-unicode-syntax.stderr
- + testsuite/tests/ghci/scripts/print-unicode-syntax.stdout
- testsuite/tests/ghci/should_run/T11825.stdout
Changes:
... | ... | @@ -627,9 +627,9 @@ instance (OutputableBndrId l, OutputableBndrId r) |
627 | 627 | GhcTc -> ppr v
|
628 | 628 | |
629 | 629 | ppr_rhs = case dir of
|
630 | - Unidirectional -> ppr_simple (text "<-")
|
|
630 | + Unidirectional -> ppr_simple larrow
|
|
631 | 631 | ImplicitBidirectional -> ppr_simple equals
|
632 | - ExplicitBidirectional mg -> ppr_simple (text "<-") <+> text "where" $$
|
|
632 | + ExplicitBidirectional mg -> ppr_simple larrow <+> text "where" $$
|
|
633 | 633 | (nest 2 $ pprFunBind mg)
|
634 | 634 | |
635 | 635 | pprTicks :: SDoc -> SDoc -> SDoc
|
... | ... | @@ -699,7 +699,7 @@ instance OutputableBndrId p |
699 | 699 | TyVarSig _ tv_bndr -> text "=" <+> ppr tv_bndr
|
700 | 700 | pp_inj = case mb_inj of
|
701 | 701 | Just (L _ (InjectivityAnn _ lhs rhs)) ->
|
702 | - hsep [ vbar, ppr lhs, text "->", hsep (map ppr rhs) ]
|
|
702 | + hsep [ vbar, ppr lhs, arrow, hsep (map ppr rhs) ]
|
|
703 | 703 | Nothing -> empty
|
704 | 704 | (pp_where, pp_eqns) = case info of
|
705 | 705 | ClosedTypeFamily mb_eqns ->
|
... | ... | @@ -868,7 +868,7 @@ instance OutputableBndrId p |
868 | 868 | instance OutputableBndrId p
|
869 | 869 | => Outputable (StandaloneKindSig (GhcPass p)) where
|
870 | 870 | ppr (StandaloneKindSig _ v ki)
|
871 | - = text "type" <+> pprPrefixOcc (unLoc v) <+> text "::" <+> ppr ki
|
|
871 | + = text "type" <+> pprPrefixOcc (unLoc v) <+> dcolon <+> ppr ki
|
|
872 | 872 | |
873 | 873 | pp_condecls :: forall p. OutputableBndrId p => [LConDecl (GhcPass p)] -> SDoc
|
874 | 874 | pp_condecls cs
|
... | ... | @@ -956,7 +956,7 @@ ppr_expr (HsIf _ e1 e2 e3) |
956 | 956 | ppr_expr (HsMultiIf _ alts)
|
957 | 957 | = hang (text "if") 3 (vcat $ toList $ NE.map ppr_alt alts)
|
958 | 958 | where ppr_alt (L _ (GRHS _ guards expr)) =
|
959 | - hang vbar 2 (hang (interpp'SP guards) 2 (text "->" <+> pprDeeper (ppr expr)))
|
|
959 | + hang vbar 2 (hang (interpp'SP guards) 2 (arrow <+> pprDeeper (ppr expr)))
|
|
960 | 960 | ppr_alt (L _ (XGRHS x)) = ppr x
|
961 | 961 | |
962 | 962 | -- special case: let ... in let ...
|
... | ... | @@ -1029,7 +1029,7 @@ ppr_expr (HsUntypedBracket b q) |
1029 | 1029 | ppr rnq `ppr_with_pending_tc_splices` ps
|
1030 | 1030 | |
1031 | 1031 | ppr_expr (HsProc _ pat (L _ (HsCmdTop _ cmd)))
|
1032 | - = hsep [text "proc", ppr pat, text "->", ppr cmd]
|
|
1032 | + = hsep [text "proc", ppr pat, arrow, ppr cmd]
|
|
1033 | 1033 | |
1034 | 1034 | ppr_expr (HsStatic _ e)
|
1035 | 1035 | = hsep [text "static", ppr e]
|
... | ... | @@ -1844,10 +1844,10 @@ pp_rhs ctxt rhs = matchSeparator ctxt <+> pprDeeper (ppr rhs) |
1844 | 1844 | |
1845 | 1845 | matchSeparator :: HsMatchContext fn -> SDoc
|
1846 | 1846 | matchSeparator FunRhs{} = text "="
|
1847 | -matchSeparator CaseAlt = text "->"
|
|
1848 | -matchSeparator LamAlt{} = text "->"
|
|
1849 | -matchSeparator IfAlt = text "->"
|
|
1850 | -matchSeparator ArrowMatchCtxt{} = text "->"
|
|
1847 | +matchSeparator CaseAlt = arrow
|
|
1848 | +matchSeparator LamAlt{} = arrow
|
|
1849 | +matchSeparator IfAlt = arrow
|
|
1850 | +matchSeparator ArrowMatchCtxt{} = arrow
|
|
1851 | 1851 | matchSeparator PatBindRhs = text "="
|
1852 | 1852 | matchSeparator PatBindGuards = text "="
|
1853 | 1853 | matchSeparator StmtCtxt{} = text "<-"
|
... | ... | @@ -1377,7 +1377,7 @@ pprIfaceDecl ss decl@(IfaceFamily { ifName = tycon |
1377 | 1377 | |
1378 | 1378 | pp_inj_cond res inj = case filterByList inj binders of
|
1379 | 1379 | [] -> empty
|
1380 | - tvs -> hsep [vbar, ppr res, text "->", interppSP (map ifTyConBinderName tvs)]
|
|
1380 | + tvs -> hsep [vbar, ppr res, arrow, interppSP (map ifTyConBinderName tvs)]
|
|
1381 | 1381 | |
1382 | 1382 | pp_rhs IfaceDataFamilyTyCon
|
1383 | 1383 | = ppShowIface ss (text "data")
|
... | ... | @@ -1464,7 +1464,7 @@ pprRoles suppress_if tyCon bndrs roles |
1464 | 1464 | text "type role" <+> tyCon <+> hsep (map ppr froles)
|
1465 | 1465 | |
1466 | 1466 | pprStandaloneKindSig :: SDoc -> IfaceType -> SDoc
|
1467 | -pprStandaloneKindSig tyCon ty = text "type" <+> tyCon <+> text "::" <+> ppr ty
|
|
1467 | +pprStandaloneKindSig tyCon ty = text "type" <+> tyCon <+> dcolon <+> ppr ty
|
|
1468 | 1468 | |
1469 | 1469 | pprInfixIfDeclBndr :: ShowHowMuch -> OccName -> SDoc
|
1470 | 1470 | pprInfixIfDeclBndr (ShowSome _ (AltPpr (Just ppr_bndr))) name
|
... | ... | @@ -1747,7 +1747,7 @@ pprTyTcApp ctxt_prec tc tys = |
1747 | 1747 | , IA_Arg (IfaceLitTy (IfaceStrTyLit n))
|
1748 | 1748 | Required (IA_Arg ty Required IA_Nil) <- tys
|
1749 | 1749 | -> maybeParen ctxt_prec funPrec
|
1750 | - $ char '?' <> ftext (getLexicalFastString n) <> text "::" <> ppr_ty topPrec ty
|
|
1750 | + $ char '?' <> ftext (getLexicalFastString n) <> dcolon <> ppr_ty topPrec ty
|
|
1751 | 1751 | |
1752 | 1752 | | IfaceTupleTyCon arity sort <- ifaceTyConSort info
|
1753 | 1753 | , not debug
|
... | ... | @@ -1935,7 +1935,7 @@ instance DisambECP (HsCmd GhcPs) where |
1935 | 1935 | mkHsLitPV (L l a) = cmdFail l (ppr a)
|
1936 | 1936 | mkHsOverLitPV (L l a) = cmdFail (locA l) (ppr a)
|
1937 | 1937 | mkHsWildCardPV l = cmdFail l (text "_")
|
1938 | - mkHsTySigPV l a sig _ = cmdFail (locA l) (ppr a <+> text "::" <+> ppr sig)
|
|
1938 | + mkHsTySigPV l a sig _ = cmdFail (locA l) (ppr a <+> dcolon <+> ppr sig)
|
|
1939 | 1939 | mkHsExplicitListPV l xs _ = cmdFail l $
|
1940 | 1940 | brackets (pprWithCommas ppr xs)
|
1941 | 1941 | mkHsSplicePV (L l sp) = cmdFail l (pprUntypedSplice True Nothing sp)
|
... | ... | @@ -11,13 +11,13 @@ f ∷ ∀ (a ∷ ★ → ★) b. C a ⇒ a b |
11 | 11 | f ∷ ∀ (a ∷ ★ → ★) b. C a ⇒ a b
|
12 | 12 | f ∷ ∀ (a ∷ ★ → ★) b. C a ⇒ a b
|
13 | 13 | fmap ∷ ∀ (f ∷ ★ → ★) a b. Functor f ⇒ (a → b) → f a → f b
|
14 | -type Functor :: (★ → ★) → Constraint
|
|
14 | +type Functor ∷ (★ → ★) → Constraint
|
|
15 | 15 | class Functor f where
|
16 | 16 | fmap ∷ ∀ a b. (a → b) → f a → f b
|
17 | 17 | ...
|
18 | 18 | -- Defined in ‘GHC.Internal.Base’
|
19 | 19 | Functor ∷ (★ → ★) → Constraint
|
20 | -type Functor :: (★ → ★) → Constraint
|
|
20 | +type Functor ∷ (★ → ★) → Constraint
|
|
21 | 21 | class Functor f where
|
22 | 22 | fmap ∷ ∀ a b. (a → b) → f a → f b
|
23 | 23 | (<$) ∷ ∀ a b. a → f b → f a
|
... | ... | @@ -77,7 +77,7 @@ datatypeName |
77 | 77 | (a ∷ k1).
|
78 | 78 | Datatype d ⇒
|
79 | 79 | t d f a → [Char]
|
80 | -type Datatype :: ∀ {k}. k → Constraint
|
|
80 | +type Datatype ∷ ∀ {k}. k → Constraint
|
|
81 | 81 | class Datatype d where
|
82 | 82 | datatypeName ∷ ∀ k1 (t ∷ k → (k1 → ★) → k1 → ★) (f ∷ k1 → ★)
|
83 | 83 | (a ∷ k1).
|
1 | - |
|
2 | 1 | T8959b.hs:5:7: error: [GHC-83865]
|
3 | 2 | • Couldn't match expected type ‘Int → Int’ with actual type ‘()’
|
4 | 3 | • In the expression: ()
|
... | ... | @@ -6,11 +5,12 @@ T8959b.hs:5:7: error: [GHC-83865] |
6 | 5 | |
7 | 6 | T8959b.hs:8:7: error: [GHC-83865]
|
8 | 7 | • Couldn't match expected type ‘()’ with actual type ‘t0 → m0 t0’
|
9 | - • In the expression: proc x -> do return ⤙ x
|
|
10 | - In an equation for ‘bar’: bar = proc x -> do return ⤙ x
|
|
8 | + • In the expression: proc x → do return ⤙ x
|
|
9 | + In an equation for ‘bar’: bar = proc x → do return ⤙ x
|
|
11 | 10 | |
12 | 11 | T8959b.hs:10:7: error: [GHC-83865]
|
13 | 12 | • Couldn't match expected type ‘(∀ a. a → a) → a1’
|
14 | 13 | with actual type ‘()’
|
15 | 14 | • In the expression: () ∷ (∀ a. a → a) → a
|
16 | 15 | In an equation for ‘baz’: baz = () ∷ (∀ a. a → a) → a
|
16 | + |
... | ... | @@ -357,6 +357,7 @@ test('T20101', normal, ghci_script, ['T20101.script']) |
357 | 357 | test('T20206', normal, ghci_script, ['T20206.script'])
|
358 | 358 | test('T20217', normal, ghci_script, ['T20217.script'])
|
359 | 359 | test('T20455', normal, ghci_script, ['T20455.script'])
|
360 | +test('print-unicode-syntax', normal, ghci_script, ['print-unicode-syntax.script'])
|
|
360 | 361 | test('shadow-bindings', normal, ghci_script, ['shadow-bindings.script'])
|
361 | 362 | test('T925', normal, ghci_script, ['T925.script'])
|
362 | 363 | test('T7388', normal, ghci_script, ['T7388.script'])
|
1 | +:set -fprint-unicode-syntax
|
|
2 | +:set -XArrows -XImplicitParams -XMultiWayIf -XPatternSynonyms -XTemplateHaskell -XTypeFamilyDependencies
|
|
3 | + |
|
4 | +---------------------------------------
|
|
5 | +-- Double-colon checks
|
|
6 | + |
|
7 | +import Data.Kind
|
|
8 | +[d| type Foo :: Type |]
|
|
9 | + |
|
10 | +:{
|
|
11 | +foo :: (?imp :: Int) => Int
|
|
12 | +foo = ?imp
|
|
13 | +:}
|
|
14 | +:t foo
|
|
15 | + |
|
16 | +proc x -> (_ -< _) :: _
|
|
17 | + |
|
18 | +---------------------------------------
|
|
19 | +-- Rightwards arrow checks
|
|
20 | + |
|
21 | +[d| type family Foo a = b | b -> c |]
|
|
22 | + |
|
23 | +type family Foo a = b | b -> a
|
|
24 | +:i Foo
|
|
25 | + |
|
26 | +\_ -> [] 0
|
|
27 | + |
|
28 | +case () of [] -> 0
|
|
29 | + |
|
30 | +if | [] -> 0
|
|
31 | + |
|
32 | +:{
|
|
33 | +if | True -> 0
|
|
34 | + | True -> 1
|
|
35 | +:}
|
|
36 | + |
|
37 | +proc _ -> \_ -> undefined -< 0
|
|
38 | + |
|
39 | +---------------------------------------
|
|
40 | +-- Leftwards arrow checks
|
|
41 | + |
|
42 | +[d| pattern Foo x <- Nothing |]
|
|
43 | + |
|
44 | +[d| pattern Foo x <- Nothing where Foo _ = Nothing |] |
1 | +<interactive>:8:10: error: [GHC-44432]
|
|
2 | + • The standalone kind signature for ‘Foo’
|
|
3 | + lacks an accompanying binding
|
|
4 | + • In the Template Haskell quotation: [d| type Foo ∷ Type |]
|
|
5 | + |
|
6 | +<interactive>:16:11: error: [GHC-03790]
|
|
7 | + Parse error in command: (_ ⤙ _) ∷ _
|
|
8 | + |
|
9 | +<interactive>:21:5: error: [GHC-76037]
|
|
10 | + • Not in scope: type variable ‘c’
|
|
11 | + • In the Template Haskell quotation:
|
|
12 | + [d| type family Foo a = b | b → c |]
|
|
13 | + |
|
14 | +<interactive>:26:7: error: [GHC-83865]
|
|
15 | + • Couldn't match expected type: t0 → t
|
|
16 | + with actual type: [a0]
|
|
17 | + • The function ‘[]’ is applied to one visible argument,
|
|
18 | + but its type ‘[a]’ has none
|
|
19 | + In the expression: [] 0
|
|
20 | + In the expression: \ _ → [] 0
|
|
21 | + • Relevant bindings include
|
|
22 | + it ∷ p → t (bound at <interactive>:26:1)
|
|
23 | + |
|
24 | +<interactive>:28:12: error: [GHC-83865]
|
|
25 | + • Couldn't match expected type ‘()’ with actual type ‘[a0]’
|
|
26 | + • In the pattern: []
|
|
27 | + In a case alternative: [] → 0
|
|
28 | + In the expression: case () of [] → 0
|
|
29 | + |
|
30 | +<interactive>:30:6: error: [GHC-83865]
|
|
31 | + • Couldn't match expected type ‘Bool’ with actual type ‘[a0]’
|
|
32 | + • In the expression: []
|
|
33 | + In a stmt of a pattern guard for
|
|
34 | + a multi-way if alternative:
|
|
35 | + []
|
|
36 | + In the expression: if | [] → 0
|
|
37 | + |
|
38 | +<interactive>:34:6: warning: [GHC-53633] [-Woverlapping-patterns (in -Wdefault)]
|
|
39 | + Pattern match is redundant
|
|
40 | + In a multi-way if alternative: | True → ...
|
|
41 | + |
|
42 | +<interactive>:37:11: error: [GHC-83865]
|
|
43 | + • Couldn't match expected type ‘()’ with actual type ‘(a0, b0)’
|
|
44 | + • In the expression: proc _ → \ _ → undefined ⤙ 0
|
|
45 | + In an equation for ‘it’: it = proc _ → \ _ → undefined ⤙ 0
|
|
46 | + |
|
47 | +<interactive>:42:17: error: [GHC-76037]
|
|
48 | + • Not in scope: ‘x’
|
|
49 | + • In the Template Haskell quotation: [d| pattern Foo x ← Nothing |]
|
|
50 | + |
|
51 | +<interactive>:44:17: error: [GHC-76037]
|
|
52 | + • Not in scope: ‘x’
|
|
53 | + • In the Template Haskell quotation:
|
|
54 | + [d| pattern Foo x ← Nothing where
|
|
55 | + Foo _ = Nothing |]
|
|
56 | + |
1 | +foo ∷ (?imp∷Int) ⇒ Int
|
|
2 | +type Foo ∷ ★ → ★
|
|
3 | +type family Foo a = b | b → a
|
|
4 | + -- Defined at <interactive>:23:1
|
|
5 | +0 |
1 | -type X :: ★ → ★ → Constraint
|
|
1 | +type X ∷ ★ → ★ → Constraint
|
|
2 | 2 | class X a b | a → b where
|
3 | 3 | to ∷ a → b
|
4 | 4 | {-# MINIMAL to #-}
|