[GHC] #13041: Type classes in Backpack signatures are dodgy
#13041: Type classes in Backpack signatures are dodgy -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 (Type checker) | Keywords: backpack | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- At the moment, we allow exactly the same type class declarations in hsig files as we do in hs-boot files, and matching requires the type class definitions to match up exactly. But this is quite questionable. First, this means that I can't write this in a signature: {{{ class K a where f :: a -> Bool }}} but then implement K with a type class that provides a default. The matching code will say these are not compatible. That's not so useful. Second, it means that I can WRITE a default implementation in a signature file. That seems like a step too far: there are many things I might like to write in a specification of a type class, but what the default methods are seems like a step too far. So it seems we need to fix two things: 1. Relax matching so that you can add defaults post-facto in the implementation of the type class 2. Make hsig more restrictive w.r.t. what class definitions it will accept. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13041> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13041: Type classes in Backpack signatures are dodgy -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:2925 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => patch * differential: => Phab:2925 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13041#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13041: Type classes in Backpack signatures are dodgy -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:2925 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Edward Z. Yang <ezyang@…>): In [changeset:"5def07fadd386a7a7c3a12963c0736529e377a74/ghc" 5def07f/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="5def07fadd386a7a7c3a12963c0736529e377a74" Revamp Backpack/hs-boot handling of type class signatures. Summary: A basket of fixes and improvements: - The permissible things that one can write in a type class definition in an hsig file has been reduced to encompass the following things: - Methods - Default method signatures (but NOT implementation) - MINIMAL pragma It is no longer necessary nor encouraged to specify that a method has a default if it is mentioned in a MINIMAL pragma; the MINIMAL pragma is assumed to provide the base truth as to what methods need to be implemented when writing instances of a type class. - Handling of default method signatures in hsig was previously buggy, as these identifiers were not exported, so we now treat them similarly to DFuns. - Default methods are merged, where methods with defaults override those without. - MINIMAL pragmas are merged by ORing together pragmas. - Matching has been relaxed: a method with a default can be used to fill a signature which did not declare the method as having a default, and a more relaxed MINIMAL pragma can be used (we check if the signature pragma implies the final implementation pragma, on the way fixing a bug with BooleanFormula.implies, see #13073) Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2925 GHC Trac Issues: #13041 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13041#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13041: Type classes in Backpack signatures are dodgy -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Resolution: fixed | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:2925 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13041#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC