[GHC] #10749: Boot file instances should imply superclasses

#10749: Boot file instances should imply superclasses -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.11 Keywords: backpack | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Currently, if I write the following program: {{{ -- A.hs-boot module A where data T instance Ord T -- B.hs module B where import {-# SOURCE #-} A f :: T -> T -> Bool f x y = x == y }}} I get: {{{ B.hs:4:11: No instance for (Eq T) arising from a use of `==' Possible fix: add an instance declaration for (Eq T) In the expression: x == y In an equation for `f': f x y = x == y }}} This is a bit confusing, because Ord instances are supposed to imply Eq instances. GHC should either: 1. Reject A.hs-boot (claiming that it could not find evidence that T had an Eq instance), or 2. Accept B.hs, since the instance requirement for Ord should imply Eq. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10749 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10749: Boot file instances should imply superclasses -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): I vote for (1). A.hs-boot is wrong. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10749#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10749: Boot file instances should imply superclasses -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 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): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * priority: low => normal Comment: Something that I've noticed is that (1) is not consistent with how superclasses work. For example, if I say: `Ord a => a -> a -> Bool`, I DO get an `Eq` instance in scope (because Eq is a superclass of Ord). So in practice, when I'm writing instances for modules in Backpack, I end up having to list a lot of instances, e.g., `Functor`, `Applicative`, `Monad`, `MonadFix`, etc. when, in the source code I was looking at, there was only `MonadFix`. Food for thought. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10749#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10749: Boot file instances should imply superclasses -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 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): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): I took a look into solving this, but I realized that I don't actually know how we normally report an error when an instance declaration is made but the superclasses do not hold. The error isn't reported until late when we're discharging top-level wanteds so I actually have no idea where the wanted is coming from (or why it's not coming in the case of hs-boot.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10749#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC