Skip to content

GHCi HEAD silently accepts ill-kinded visible type applications with :type

If you try something nonsensical like id @Maybe in GHCi 8.6.3, it will be properly rejected:

$ ghci -XTypeApplications
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :t id @Maybe

<interactive>:1:5: error:
    • Expecting one more argument to ‘Maybe’
      Expected a type, but ‘Maybe’ has kind ‘* -> *’
    • In the type ‘Maybe’
      In the expression: id @Maybe

On GHC HEAD, however, this is seemingly accepted!

$ ~/Software/ghc/inplace/bin/ghc-stage2 --interactive -XTypeApplications
GHCi, version 8.9.20190224: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :t id @Maybe
λ>

No error message, just... a newline. Quite bizarre. Even more bizarrely, this phenomenon doesn't appear to happen with :kind:

λ> :set -XDataKinds -XPolyKinds 
λ> type Id (a :: k) = a
λ> :k Id @Maybe

<interactive>:1:5: error:
    • Expecting one more argument to ‘Maybe’
      Expected a type, but ‘Maybe’ has kind ‘* -> *’
    • In the first argument of ‘Id’, namely ‘Maybe’
      In the type ‘Id @Maybe’
Trac metadata
Trac field Value
Version 8.9
Type Bug
TypeOfFailure OtherFailure
Priority highest
Resolution Unresolved
Component GHCi
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