[GHC] #12837: KnownNat and KnownSymbol should be abstract
#12837: KnownNat and KnownSymbol should be abstract -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: newcomer | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC accepts Unknown/Multiple | invalid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider the following patent nonsense: {{{#!hs {-# LANGUAGE FlexibleInstances #-} import GHC.TypeLits instance KnownNat n }}} This is accepted (albeit with a warning about the missing `natSing` method). I think it should be rejected, as should an instance of `KnownSymbol`. Compare doing the same thing with `Typeable`, which says: {{{ Class ‘Typeable’ does not support user-specified instances }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: KnownNat and KnownSymbol should be abstract -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by pbg): I'm a total newbie so can't comment on whether this is a desired change. However in case it is - would extending the code that was added for `Typeable` (#8132) to account for additional class names be the way to go here? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: KnownNat and KnownSymbol should be abstract -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: sean Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sean): * owner: => sean Comment: Also a newbie but I've managed to get this working in the way you described. I'll start following the submission instructions by making myself the owner, apologies if I'm mistaken in doing this. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: KnownNat and KnownSymbol should be abstract -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: sean Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): No problems so far Sean! If you need any help then feel free to ask here or on the IRC channel. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: KnownNat and KnownSymbol should be abstract -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: sean Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2898 Wiki Page: | -------------------------------------+------------------------------------- Changes (by sean): * differential: => Phab:D2898 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: Disallow users to write instances for KnownNat and KnownSymbol -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: sean Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2898 Wiki Page: | -------------------------------------+------------------------------------- Description changed by sean: @@ -9,3 +9,3 @@ - This is accepted (albeit with a warning about the missing `natSing` - method). I think it should be rejected, as should an instance of - `KnownSymbol`. Compare doing the same thing with `Typeable`, which says: + Originally this was accepted (albeit with a warning about the missing + `natSing` method). It is now rejected, as with instances of `KnownSymbol`, + in the same way as instances of `Typeable`, which says: New description: Consider the following patent nonsense: {{{#!hs {-# LANGUAGE FlexibleInstances #-} import GHC.TypeLits instance KnownNat n }}} Originally this was accepted (albeit with a warning about the missing `natSing` method). It is now rejected, as with instances of `KnownSymbol`, in the same way as instances of `Typeable`, which says: {{{ Class ‘Typeable’ does not support user-specified instances }}} -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: Disallow users to write instances for KnownNat and KnownSymbol -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: sean Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2898 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Matthew Pickering <matthewtpickering@…>): In [changeset:"c5609577fab8a214c50561bea861c70d4bfd47c7/ghc" c5609577/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="c5609577fab8a214c50561bea861c70d4bfd47c7" Disallow users to write instances of KnownNat and KnownSym As noted in #12837, these classes are special and the user should not be able to define their own instances. Test Plan: Validate Reviewers: adamgundry, goldfire, mpickering, austin, bgamari Reviewed By: goldfire, mpickering Subscribers: goldfire, mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2898 GHC Trac Issues: #12837 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12837: Disallow users to write instances for KnownNat and KnownSymbol -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: sean Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2898 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12837#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC