Skip to content

Warn about missing forall when -XScopedTypeVariables is on

I've ran into a situation where I forgot to put an explicit forall to actually make type variables scoped, resulting in something like

Could not deduce (PacketTypeId s0 t0 a0)
      arising from a use of ‘fromPacketTypeId’
    from the context (PacketTypeId s t n)

with code like

getPacketTypeId :: PacketTypeId s t n => KnxPacket d s t -> Integer
getPacketTypeId _ = fromPacketTypeId (Proxy :: Proxy s) (Proxy :: Proxy t)) :: Integer

It'd be nice if GHC printed an extra suggestion "Did you forget to include an explicit forall?" when something like that arises? Maybe even suggest ScopedTypeVariables if they're not on.

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