Opened 4 months ago

Last modified 4 months ago

#15474 new bug

Error message mentions Any

Reported by: monoidal Owned by:
Priority: normal Milestone: 8.8.1
Component: Compiler Version: 8.4.3
Keywords: TypeInType Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Poor/confusing error message Test Case:
Blocked By: Blocking:
Related Tickets: #14198 Differential Rev(s):
Wiki Page:

Description (last modified by monoidal)

I'm not sure if this is a bug. File:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeInType #-}
module T15474 where

import Data.Kind (Type)

data Proxy a

type Forall = forall t. Proxy t

f1 :: forall (t :: Type). Proxy t
f1 = f1

f2 :: Forall
f2 = f1

gives an error message mentioning Any:

    • Couldn't match type ‘GHC.Types.Any’ with ‘*’
      Expected type: Proxy t
        Actual type: Proxy t0

The appearance of Any is suspicious to me - I thought it's an implementation detail?

Change History (6)

comment:1 Changed 4 months ago by monoidal

Description: modified (diff)

comment:2 Changed 4 months ago by simonpj

Yes, this is awkward. What is happening is that we end up with this:

type Forall = forall (t :: Any). Proxy @Any t

I think that perhaps in this case we should kind-generalise the RHS of Forall to get

type Forall k = forall (t :: k) . Proxy @k t

I'm not sure why we don't do this. We certainly do some kind-generalisation; e.g. if you write

type T x = x

we end up with

type T k (x :: k) = x

So why doesn't something like that happen for Forall? Interesting.

comment:3 Changed 4 months ago by simonpj

So why doesn't something like that happen for Forall?

Ah, I think it's because

  • The kind of Forall's RHS is just Type
  • And we do kind-generalise that kind; it has no free kind variables, so no kind-generalisation actually happens.

And in any case the decl

type Forall k = forall (t :: k). Proxy @k t

gives Forall the ambiguous kind Forall :: forall k. Type, which will do no one any good.

comment:4 Changed 4 months ago by RyanGlScott

Another option, discussed in #14198, is to reject the declaration of Forall entirely after kind-generalizing its RHS, side the kind variable k is free-floating.

comment:5 Changed 4 months ago by simonpj

Yes, rejection is probably best for now -- we can always do something else later.

comment:6 Changed 4 months ago by simonpj

Keywords: TypeInType added
Priority: lownormal
Note: See TracTickets for help on using tickets.