[GHC] #9833: GHCi suggestion for instance signature (InstanceSigs) is wrong

GHC ghc-devs at haskell.org
Tue Nov 25 11:56:42 UTC 2014


#9833: GHCi suggestion for instance signature (InstanceSigs) is wrong
-------------------------------------+-------------------------------------
       Reporter:  Iceland_jack       |                   Owner:
           Type:  bug                |                  Status:  new
       Priority:  normal             |               Milestone:
      Component:  GHCi               |                 Version:  7.8.2
       Keywords:                     |        Operating System:  Linux
   Architecture:  Unknown/Multiple   |         Type of failure:  GHC
     Difficulty:  Unknown            |  rejects valid program
     Blocked By:                     |               Test Case:
Related Tickets:                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 With `InstanceSigs` and `PolyKinds` enabled and the following type with
 kind `ĸ -> *`:

 {{{#!hs
     data NullableInterp a = NullI Bool
 }}}

 I want to make it an instance of `Alternative` and I decide to supply a
 signature for `empty`:

 {{{#!hs
     instance Alternative NullableInterp where
       empty :: NullableInterp a
       empty = undefined
       (<|>) = undefined
 }}}

 but GHCi complains with the following error:

 {{{#!hs
 % ghci -ignore-dot-ghci error.hs
 GHCi, version 7.8.2: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 [1 of 1] Compiling Main             ( error.hs, interpreted )

 error.hs:14:12:
     Method signature does not match class; it should be
       empty :: forall a. NullableInterp a
     In the instance declaration for ‘Alternative NullableInterp’
 Failed, modules loaded: none.
 Prelude>
 }}}

 Trying GHCi's suggestion (with appropriate extensions) doesn't help and I
 have to write `empty :: NullableInterp (a :: *)` for it to work. I'm not
 sure which behaviour is the right one but either it should have compiled
 or GHCi's suggestion should be `empty :: forall a. NullableInterp (a ::
 *)`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9833>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list