[GHC] #12550: Inconsistent unicode display for kinds

#12550: Inconsistent unicode display for kinds --------------------------------------+--------------------------------- Reporter: johnleo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- With `:set -fprint-unicode-syntax`, the kind `*` should always be printed as `★`. However the output is extremely inconsistent. Here are a few examples from ghci, and I will add more as I run across them. {{{ :t fmap fmap ∷ ∀ {f ∷ ★ → ★} {a} {b}. Functor f ⇒ (a → b) → f a → f b :i fmap class Functor (f ∷ * → *) where fmap ∷ forall a b. (a → b) → f a → f b :k Functor Functor ∷ (★ → ★) → Constraint :m + GHC.Generics :i Functor -- (among other output) instance ∀ (f ∷ * → ★). Functor f ⇒ Functor (Rec1 f) -- Defined in ‘GHC.Generics’ instance Functor Par1 -- Defined in ‘GHC.Generics’ instance ∀ i (c ∷ Meta) (f ∷ * → ★). Functor f ⇒ Functor (M1 i c f) -- Defined in ‘GHC.Generics’ instance ∀ i c. Functor (K1 i c) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → *). (Functor f, Functor g) ⇒ Functor (f :.: g) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → ★). (Functor f, Functor g) ⇒ Functor (f :+: g) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → ★). (Functor f, Functor g) ⇒ Functor (f :*: g) -- Defined in ‘GHC.Generics’ :t datatypeName datatypeName ∷ ∀ {d} {t ∷ ★ → (* → *) → ★ → ★} {f ∷ * → *} {a}. Datatype ★ d ⇒ t d f a → [Char] :i datatypeName class Datatype k (d ∷ k) where datatypeName ∷ forall {k1} (t ∷ k → (* → *) → k1 → *) (f ∷ * → *) (a ∷ k1). t d f a → [Char] ... -- Defined in ‘GHC.Generics’ }}} Note that `:t datatypeName` causes a panic in 8.1; I have filed a separate bug [https://ghc.haskell.org/trac/ghc/ticket/12549] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Description changed by johnleo: @@ -12,0 +12,1 @@ + -- (note that forall is also not displayed properly as ∀ here) New description: With `:set -fprint-unicode-syntax`, the kind `*` should always be printed as `★`. However the output is extremely inconsistent. Here are a few examples from ghci, and I will add more as I run across them. {{{ :t fmap fmap ∷ ∀ {f ∷ ★ → ★} {a} {b}. Functor f ⇒ (a → b) → f a → f b :i fmap class Functor (f ∷ * → *) where fmap ∷ forall a b. (a → b) → f a → f b -- (note that forall is also not displayed properly as ∀ here) :k Functor Functor ∷ (★ → ★) → Constraint :m + GHC.Generics :i Functor -- (among other output) instance ∀ (f ∷ * → ★). Functor f ⇒ Functor (Rec1 f) -- Defined in ‘GHC.Generics’ instance Functor Par1 -- Defined in ‘GHC.Generics’ instance ∀ i (c ∷ Meta) (f ∷ * → ★). Functor f ⇒ Functor (M1 i c f) -- Defined in ‘GHC.Generics’ instance ∀ i c. Functor (K1 i c) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → *). (Functor f, Functor g) ⇒ Functor (f :.: g) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → ★). (Functor f, Functor g) ⇒ Functor (f :+: g) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → ★). (Functor f, Functor g) ⇒ Functor (f :*: g) -- Defined in ‘GHC.Generics’ :t datatypeName datatypeName ∷ ∀ {d} {t ∷ ★ → (* → *) → ★ → ★} {f ∷ * → *} {a}. Datatype ★ d ⇒ t d f a → [Char] :i datatypeName class Datatype k (d ∷ k) where datatypeName ∷ forall {k1} (t ∷ k → (* → *) → k1 → *) (f ∷ * → *) (a ∷ k1). t d f a → [Char] ... -- Defined in ‘GHC.Generics’ }}} Note that `:t datatypeName` causes a panic in 8.1; I have filed a separate bug [https://ghc.haskell.org/trac/ghc/ticket/12549] -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by johnleo): * owner: => johnleo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Description changed by johnleo: @@ -54,0 +54,4 @@ + + :t (:*:) + (:*:) ∷ ∀ {g ∷ ★ → *} {p} {f ∷ ★ → *}. f p → g p → (:*:) ★ f g p + -- Note that ★ and * are reversed from what :i displays! New description: With `:set -fprint-unicode-syntax`, the kind `*` should always be printed as `★`. However the output is extremely inconsistent. Here are a few examples from ghci, and I will add more as I run across them. {{{ :t fmap fmap ∷ ∀ {f ∷ ★ → ★} {a} {b}. Functor f ⇒ (a → b) → f a → f b :i fmap class Functor (f ∷ * → *) where fmap ∷ forall a b. (a → b) → f a → f b -- (note that forall is also not displayed properly as ∀ here) :k Functor Functor ∷ (★ → ★) → Constraint :m + GHC.Generics :i Functor -- (among other output) instance ∀ (f ∷ * → ★). Functor f ⇒ Functor (Rec1 f) -- Defined in ‘GHC.Generics’ instance Functor Par1 -- Defined in ‘GHC.Generics’ instance ∀ i (c ∷ Meta) (f ∷ * → ★). Functor f ⇒ Functor (M1 i c f) -- Defined in ‘GHC.Generics’ instance ∀ i c. Functor (K1 i c) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → *). (Functor f, Functor g) ⇒ Functor (f :.: g) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → ★). (Functor f, Functor g) ⇒ Functor (f :+: g) -- Defined in ‘GHC.Generics’ instance ∀ (f ∷ * → ★) (g ∷ * → ★). (Functor f, Functor g) ⇒ Functor (f :*: g) -- Defined in ‘GHC.Generics’ :t datatypeName datatypeName ∷ ∀ {d} {t ∷ ★ → (* → *) → ★ → ★} {f ∷ * → *} {a}. Datatype ★ d ⇒ t d f a → [Char] :i datatypeName class Datatype k (d ∷ k) where datatypeName ∷ forall {k1} (t ∷ k → (* → *) → k1 → *) (f ∷ * → *) (a ∷ k1). t d f a → [Char] ... -- Defined in ‘GHC.Generics’ :t (:*:) (:*:) ∷ ∀ {g ∷ ★ → *} {p} {f ∷ ★ → *}. f p → g p → (:*:) ★ f g p -- Note that ★ and * are reversed from what :i displays! }}} Note that `:t datatypeName` causes a panic in 8.1; I have filed a separate bug [https://ghc.haskell.org/trac/ghc/ticket/12549] -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by johnleo): Note that https://ghc.haskell.org/trac/ghc/ticket/11660 will merge the two pretty-printers so it is best to fix this (if still necessary) after that patch has been applied. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds
---------------------------------+--------------------------------------
Reporter: johnleo | Owner: johnleo
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: MacOS X | Architecture: x86_64 (amd64)
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
---------------------------------+--------------------------------------
Comment (by Ben Gamari

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by johnleo): Thanks a lot for adding the tests. I'm happy to do the Unicode fix unless you'd like to. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by bgamari): Please do! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by bgamari): * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by johnleo): Ben's fix for #11660 handled almost all of the problems. The sole remaining problem was the result of conflation between the input format of kind * (`*`, `★` or `Type`), the internal representation, and the output format. If * was inferred it was output correctly, but if it was explicitly specified in the type signature it would be output in that form, which means the output format could be a confusing mixture of `*`, `★` and `Type`. I have unified the output format to be `*` when non- unicode output is expected and `★` when `-fprint-unicode-syntax` is enabled. Note that in the future we may output `Type` in all cases instead (see #12030) but this will not happen for some time; I plan to create a proposal for this. I wanted to go further and unify the internal representations of `*`, `★` and `Type` by setting the key of all three to be `liftedTypeKindTyConKey` since internally they are all fundamentally the same thing. However this caused a panic in `PrelInfo.knownKeyNamesOkay` since apparently all keys have to be unique. I wonder if that condition could be relaxed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ----------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11660 #12030 | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by johnleo): * related: => #11660 #12030 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds ----------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11660 #12030 | Differential Rev(s): Phab:D2829 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by johnleo): * differential: => Phab:D2829 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

... since internally they are all fundamentally the same thing. However
#12550: Inconsistent unicode display for kinds ----------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11660 #12030 | Differential Rev(s): Phab:D2829 Wiki Page: | ----------------------------------+-------------------------------------- Comment (by goldfire): Replying to [comment:9 johnleo]: this caused a panic in `PrelInfo.knownKeyNamesOkay` since apparently all keys have to be unique. I wonder if that condition could be relaxed. An entity in the compiler is identified by its Unique. So if two things have the same unique, then it's just one thing. In this case, if we have both stars have the same unique, it means, essentially, that GHC will arbitrarily pick one to print whenever it is printing, as it can't tell the difference. On the other hand, it might make more sense to have a special `OccName` that prints differently depending on whether unicode syntax is enabled. But I'm not sure it's worth the bother. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12550: Inconsistent unicode display for kinds
----------------------------------+--------------------------------------
Reporter: johnleo | Owner: johnleo
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: MacOS X | Architecture: x86_64 (amd64)
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #11660 #12030 | Differential Rev(s): Phab:D2829
Wiki Page: |
----------------------------------+--------------------------------------
Comment (by Ben Gamari

#12550: Inconsistent unicode display for kinds ----------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11660 #12030 | Differential Rev(s): Phab:D2829 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12550#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC