[GHC] #12390: List rules for `Coercible` instances
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- `:info` on [https://downloads.haskell.org/~ghc/7.8.2/docs/html/libraries/base-4.7.0.0 /Data-Coerce.html#t:Coercible Data.Coerce.Coercible] doesn't display any instances, it's a special class so it should be special-cased {{{ ghci> :i Coercible type role Coercible representational representational class a ~R# b => Coercible (a :: k) (b :: k) -- Defined in ‘GHC.Types’ }}} The base case would be easy to display: {{{#!hs instance Coercible a a -- Generated on the fly }}} but it's trickier to describe the … instance succinctly: {{{#!hs instance Coercible b b' => Coercible (D a b c) (D a b' c') }}} same for newtypes. ---- Maybe it's better to list concrete examples {{{#!hs coerce @(Reader _ _) :: Reader a b -> (a -> Identity b) }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): The Coercible class is special in other ways too, there is also [https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries /ghc-prim/GHC/Types.hs;54c95ffcb2cf392df33d2ec397e2301c005ca406$84 no syntax for ~#R] {{{#!hs class a ~R# b => Coercible (a :: k) (b :: k) }}} making it difficult to get more information about `~R#`. (#12023) Some of this might be worth noting in `:info`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Maybe it would work better if a symbol could have an text field attatched for “arbitrary text to be displayed on `:info`”, and `:info` would show that. It could simply say
Coercible is a special constraint with custom solving rules. Please see section ... of the user’s guide for details.
Note that we stopped calling `Coercible` a class; as it is not a class. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): +1 to comment:2. `Coercible` is not a class. Any resemblance it has to a class is purely historical. That said, I'm very sympathetic to the original motivation of having `:info Coercible` print something more useful. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * keywords: => newcomer Comment: The idea on comment:2 could reasonably just added to the code in `:info`, as the most mundane approach. As such, this is a newcomer-compatible patch. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tellah): Newcomer here who has been poking around this a bit. From my initial impressions of the `:info` code, it would appear that the only place such an info string could be stored is in the TyThing. This is because the input string is converted String -> Name -> TyThing, and then the TyThing is converted to an IfaceDecl for printing. So then the question is: where does the suggested info string come from? I have some basic code that can store arbitrary text for `:info` but I am not sure what the front end for this should look like. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack):
Note that we stopped calling Coercible a class; as '''it is not a class'''.
If it's all the same I would like `:info` to mention that -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Changes (by tellah): * testcase: => ghci059 * status: new => patch * differential: => Phab:D3634 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: tellah Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Changes (by tellah): * owner: (none) => tellah -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: tellah Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Comment (by duog): The haddocks for Data.Coerce say it is a class, and include the ~R# constraint. Should this string also appear in the haddocks? Attaching the haddocks for Data.Coerce from HEAD. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: tellah Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Changes (by duog): * Attachment "Data-Coerce.html" added. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: tellah Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Here are some design notes off the top of my head: I don't want to clutter `TyThing` with this, as it's unclear where within `TyThing` the documentation should go. In `TyCon`? Perhaps, but I don't love it. Instead, `InteractiveEval.getInfo` could return 5 things instead of 4; the fifth is an `SDoc` with extra text that should be printed. (It would normally be `empty`.) Naturally, you will have to add the fifth return value to `HscMain.hscTcRnGetInfo` and `TcRnDriver.tcRnGetInfo`. That last function can just call a new `lookupCustomDoc` function. That function can be defined in `PrelInfo`; it would refer to a `UniqFM SDoc` that associates `Unique`s with `SDoc`s. The `SDoc`s could (for now) just be hard-coded in `PrelInfo`. Certainly baked-in goodies other than `Coercible` can benefit from this new behavior. Perhaps it would be better to store the printed strings outside of a Haskell source file, but we don't have to over-design to begin with. Before implementing this, @tellah, perhaps someone else who is not a newcomer can opine on my design choices here. And, thanks! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: tellah Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"905dc8bc74bebf5370eb9237cc8756cd9fe871ae/ghc" 905dc8b/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="905dc8bc74bebf5370eb9237cc8756cd9fe871ae" Make ':info Coercible' display an arbitrary string (fixes #12390) This change enables the addition of an arbitrary string to the output of GHCi's ':info'. It was made for Coercible in particular but could be extended if desired. Updates haddock submodule. Test Plan: Modified test 'ghci059' to match new output. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #12390 Differential Revision: https://phabricator.haskell.org/D3634 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12390: List rules for `Coercible` instances -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: tellah Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: ghci059 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3634 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12390#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC