Menu

#261 Instance match failure on openTypeKind

open
5
2005-09-13
2003-09-16
No

Consider

instance Show (a->b) where ...

foo x = show (\ _ -> True)

This fails with:
No instance for (Show (t -> Bool))
arising from use of `show' at Foo.hs:5

Reason: the type of (\_ -> True) is (t -> Bool) where
t has an "openTypeKind". It's possible that the function
will be applied to say an Int#, and the openTypeKind
records that this is OK.

BUT, the instance decl Show (a->b) has
a::liftedTypeKind, and that doesn't match an
openTypeKind type variable.

This bug relates to GHC's unsatisfactory treatment of
the variants of kind "type", for which there are at least 2
other SourceForge bugs registered (753780 and
753777). It's very obscure, so I'm not going to fix it
today.

Discussion

  • Simon Marlow

    Simon Marlow - 2004-12-17
    • priority: 5 --> 2
     
  • Simon Peyton Jones

    • priority: 2 --> 6
     
  • Simon Peyton Jones

    Logged In: YES
    user_id=50165

    I'm bumping up the priority of this bug, because it also
    happens if, in GHCi, you say

    Prelude> :m +Text.Show.Functions
    Text.Show.Functions> print (\x -> x)

    (this elicits a no-such-instance error)

    It's even more perplexing that this does not happen if you say
    > print id

    becuase 'id' has kind-defaulted type variables in its type.
    Sigh.

     
  • Simon Peyton Jones

    • assigned_to: nobody --> simonpj
     
  • Simon Marlow

    Simon Marlow - 2005-07-11

    Logged In: YES
    user_id=48280

    ghci015 now tests for this bug.

     
  • Simon Marlow

    Simon Marlow - 2005-09-13
    • priority: 6 --> 5
     

Log in to post a comment.