Skip to content

GHCi suggestion for instance signature (InstanceSigs) is wrong

With InstanceSigs and PolyKinds enabled and the following type with kind ĸ -> *:

    data NullableInterp a = NullI Bool

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

    instance Alternative NullableInterp where
      empty :: NullableInterp a
      empty = undefined
      (<|>) = undefined

but GHCi complains with the following error:

% 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 :: *).

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC hvr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information