[GHC] #13401: GHCi gives conflicting information about visible type application
GHC
ghc-devs at haskell.org
Thu Mar 9 15:00:23 UTC 2017
#13401: GHCi gives conflicting information about visible type application
-------------------------------------+-------------------------------------
Reporter: crockeea | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 8.0.1
Resolution: | Keywords:
| TypeApplications
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
What is happening here is that `:type` is regeneralizing the type of the
expression `foo`. In the regeneralized type, `a` is now properly invisible
(i.e., not available for type application), which is why `:type foo` will
give you `forall {a}. a` regardless of whether you declared foo with `foo
= undefined` or `foo :: a; foo = undefined`.
If you wish to see the type of `foo` that preserves the visibility of its
type parameters, you need to use the `:type +v` GHCi command (which is
currently only available in GHC HEAD):
{{{
λ> let foo = undefined
λ> :type +v foo
foo :: forall {a}. a
λ> let foo :: a; foo = undefined
λ> :type +v foo
foo :: forall a. a
}}}
So I don't think there's a GHC bug here—just slightly misleading
documentation at worst. I think including a mention of `:type +v` in the
users' guide section on `-XTypeApplications` might dispel this confusion.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13401#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list