[GHC] #10886: Remove the magic from `Any`

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- The `Any` type used to be very highly magical: a poly-kinded type in a mono-kinded world. Then it became only normally magical: a datatype with a return kind of `k` (instead of `*`). Then it became only a bit magical: a closed type family with no equations. Now that we have non-magical empty closed type families, I believe that we can remove the last bit of magic and just define {{{ type family Any :: k where { } }}} somewhere (`GHC.Types`?), wire it in (like, e.g., `Bool`), and be done with it. Objections? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): {{{ There is Richard, when needed the most He writes up a patch, and the magic is lost Tells me this built-ins will not stay Tells me poly kindness is now okay And I don’t need to build it in “Any” stands in the line, it’s the next to go It was changing its kind, but that’s normal now You tell me its life used to be out of line T’was strange to be used every time Now I don’t need to build it in? Cause you had an insight You're taking one down You write a small patch just to turn it around You say you know how You tell me don't sigh You work at a smile and you go for “Any” You had an insight The testsuite don't lie You're pushing a change and we really don't mind Cause you had an insight Cause you had an insight Well you need a closed type family The point is that it’s definintion is empty Now I don’t need to build it in? Cause you had an insight You're taking one down You write a small patch just to turn it around You say you know how You tell me don't sigh You work at a smile and you go for “Any” You had an insight The testsuite don't lie You're pushing a change and we really don't mind Sometimes the system goes on the blink And the whole thing turns out wrong You might just take it back and you know That all could be well oh that strong But you’re not wrong (Yeah,yeah,yeah,yeah) So there is the Richard when we need him the most Oh you and types You write up a patch, and the magic is lost Cause you had an insight You're taking one down You write a small patch just to turn it around You say you know how You tell me don't sigh You work at a smile and you go for “Any” You had an insight The testsuite don't lie You're pushing a change and we really don't mind Cause you had an insight Cause you had an insight Had an insight Had an insight Had an insight Had an insight }}} (With apologies to Daniel Powter.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): I'm all for it -- go for it. Obviously add some relevant notes etc. You'll still need it in `knownKeyNames`, though, since GHC uses it during zonking and elsewhere. I love the song but I'm missing the soundtrack. You should put it up on Youtube with you singing it to a backing track :-) Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata):
You should put it up on Youtube with you singing it to a backing track :-)
Pity with humanity prohibits me from singing in public. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.1 => 8.2.1 Comment: Won't happen for GHC 8.0. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: patch Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D2049 @@ -8,1 +8,1 @@ - {{{ + {{{#!hs New description: The `Any` type used to be very highly magical: a poly-kinded type in a mono-kinded world. Then it became only normally magical: a datatype with a return kind of `k` (instead of `*`). Then it became only a bit magical: a closed type family with no equations. Now that we have non-magical empty closed type families, I believe that we can remove the last bit of magic and just define {{{#!hs type family Any :: k where { } }}} somewhere (`GHC.Types`?), wire it in (like, e.g., `Bool`), and be done with it. Objections? -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any`
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: goldfire
Type: task | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 7.10.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2049
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): This should probably be mentioned in release notes and migration guide. This breaks for example the `constraints` package (it uses `Any` from `Prim`). These kind of little breakages are annoying, and seem so unnecessary. Can we do something about it? A suggestion: * Rename `GHC.Prim` to something else, and make `GHC.Prim` a backward compatible module that exports `GHC.Exts` (including `Any` and `Constraints` for example). This seems less work than replacing `GHC.Prim` to `GHC.Exts` across hackage. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): While of course it can be mentioned in the migration guide on the wiki, I specifically chose not to mention this in the release notes. (Actually, looking through the history on this ticket, Ben did the heavy lifting. Thanks, Ben. But there were other definitions that I moved out of `GHC.Prim` for 8.0.) The reason is this sentence from the module documentation on `GHC.Prim`: "Use GHC.Exts from the base package instead of importing this module directly." I thus assumed that `GHC.Prim` was entirely an internal implementation artifact and did not think a change notification was necessary. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari):
Rename `GHC.Prim` to something else, and make `GHC.Prim` a backward compatible module that exports `GHC.Exts` (including `Any` and `Constraints` for example).
As Richard mentioned, this is actually backwards. Currently users are advised to use `GHC.Exts`, which should re-export anything of use provided by `GHC.Prim`. Unfortunately, it seems that this message perhaps isn't as widely known as it should be. I'm not sure how else to convey it, however.
I thus assumed that `GHC.Prim` was entirely an internal implementation artifact
Indeed it is. In fact, it is quite a magical module (e.g. it has no object code; the source Haskell module generated by `mkPrimOps` is actually merely for consumption by Haddock), so renaming it as thomie suggests would require a fair number of changes in the compiler. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): It doesn't matter that there is a small comment in the documentation that says to use `GHC.Exts` instead. `GHC.Prim` is out there, visible on hackage, and people are using it. There are ~375 modules importing `GHC.Prim` across 163 hackage packages. With GHC 8.0 and 8.2 some of those packages will be broken. What about 8.4? Breaking user code is bad, especially if there is zero benefit to users, and just causes busywork for users and maintainers. I run into these problems all the time when trying to reproduce bug reports with HEAD, and it's really quite annoying.
renaming it [..] would require a fair number of changes in the compiler
I don't understand. But I guess there are a million more urgent GHC problems to work on, so I guess I should let it rest. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): The widespread use of GHC.Prim is primarily an accident induced by documentation: https://hackage.haskell.org/package/base-4.9.0.0/docs/GHC- Exts.html does not list all of the GHC.Prim functions; instead there's just a little "module GHC.Prim" deep inside. So if I'm looking up a function, the only Haddock page it is going to be on is GHC.Prim, and then of course I'm going to import GHC.Prim (if I am not paying close attention). So I guess what could be done is to change what the magical module is called, turn GHC.Prim into a real module, DON'T expose it, and this time correctly configure Haddock to inline the description so that whatever your real module is called never gets exposed. A bit of faffing about but probably not fundamentally hard. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Replying to [comment:12 ezyang]:
The widespread use of GHC.Prim is primarily an accident induced by documentation: https://hackage.haskell.org/package/base-4.9.0.0/docs/GHC- Exts.html does not list all of the GHC.Prim functions; instead there's just a little "module GHC.Prim" deep inside. So if I'm looking up a function, the only Haddock page it is going to be on is GHC.Prim, and then of course I'm going to import GHC.Prim (if I am not paying close attention).
Indeed, our intent was that people should import `GHC.Exts` precisely to insulate them from the vaguaries of which module actually defines the thing. While that horse seems to have well and truly bolted, I wonder whether we could fix Haddock (or something) for the future, explain the intent, and encourage library authors to future-proof their code by updating their imports? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10886: Remove the magic from `Any` -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2049 Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): According to https://www.haskell.org/haddock/doc/html/ch03s04.html Haddock will only inline the documentation if the module is not completely reexported, or the module being reexported is marked with the hidden attribute. So Haddock DOES support inlining the documentation here; it's a matter of changing the default. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10886#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC