Skip to content

Unexpected type inference behavior with -XTypeApplications

In the following snippet, type inference of the let bound identity function after applying a type unexpectedly fails:

GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
[...]
*Main> :set -XTypeApplications 
*Main> :t id @Int
id @Int :: Int -> Int
*Main> let the = id
*Main> :t the @Int

<interactive>:1:1: error:
     Cannot apply expression of type a0 -> a0
      to a visible type argument Int
     In the expression: the @Int
*Main> :t _ @Int

Note that it works with id, but not with the. I would expect to be able to write something like the @Double 42, for instance.

For completeness' sake and since I don't know if it is related or relevant, with GHC 8.0.2, a panic is easily triggered:

Prelude> :set -XTypeApplications 
Prelude> :t _ @Int
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
	initTc: unsolved constraints
  WC {wc_insol = [W] __a15d :: t_a15c[tau:3] (CHoleCan: _)}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

This however does not happen with GHC 8.2.1.

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
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