[GHC] #14354: Unexpected type inference behavior with -XTypeApplications

#14354: Unexpected type inference behavior with -XTypeApplications -------------------------------------+------------------------------------- Reporter: mbw | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 (Type checker) | Keywords: | Operating System: POSIX Architecture: x86_64 | Type of failure: None/Unknown (amd64) | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In the following snippet, type inference of the let bound identity function after applying a type unexpectedly fails: {{{#!hs 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: {{{#!hs 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14354 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14354: Unexpected type inference behavior with -XTypeApplications -------------------------------------+------------------------------------- Reporter: mbw | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: | Keywords: Operating System: POSIX | Architecture: x86_64 | (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): This is expected behavior. The [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #visible-type-application relevant section] of the GHC manual includes this sentence:
If the function is an identifier (the common case), its type is considered known only when the identifier has been given a type signature. If the identifier does not have a type signature, visible type application cannot be used.
I know this behavior can be unintuitive, but it seems that it's the best we can do. If you want to know more about ''why'' this is the case, you will find the answers in [https://repository.brynmawr.edu/cgi/viewcontent.cgi?article=1001&context=compsci_pubs the original paper]. The panic you report is due to an unrelated, fixed bug. If you're satisfied with this answer, please close the ticket. Thanks for reporting! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14354#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14354: Unexpected type inference behavior with -XTypeApplications -------------------------------------+------------------------------------- Reporter: mbw | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: invalid | Keywords: Operating System: POSIX | Architecture: x86_64 | (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mbw): * status: new => closed * resolution: => invalid -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14354#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC