Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#10939 closed bug (fixed)

Odditites regarding Any and typeclasses.

Reported by: mniip Owned by:
Priority: normal Milestone: 8.0.1
Component: Compiler (Type checker) Version: 7.10.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The typechecker seems to be unable to operate on contexts containing "naked" Any, for example:

x :: State [Any] ()
x = put []
    No instance for (MonadState [Any] (StateT [Any] Identity))
      arising from a use of ‘put’

A more minimal self-contained example would be:

{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
import GHC.Prim (Any)
class Class a b where method :: a -> b
instance Class a a where method = id
x :: Any -> Any
x = method
    No instance for (Class Any Any) arising from a use of ‘method’

It's quite obvious why this error happens (Any is not a datatype), however it also feels like it shouldn't happen. All of the above code seems to work in 7.8, which is back when Any was a datatype.

Change History (3)

comment:1 Changed 2 years ago by thomie

Your second example compiles fine with HEAD (ghc-7.11.20151002).

comment:2 Changed 2 years ago by goldfire

Resolution: fixed
Status: newclosed

Confirmed that the first example works, too. I'm not sure what the fix is, though. I'm closing as fixed. If this is holding you up and you want the fix in 7.10.3, reopen and we can try to learn more.

Thanks for reporting!

comment:3 Changed 2 years ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.