Opened 3 years ago

Closed 16 months ago

#12601 closed bug (fixed)

explicit foralls do not distinguish applicable types

Reported by: dmwit Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1
Keywords: TypeApplications Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #13401 Differential Rev(s):
Wiki Page:

Description

From the documentation for TypeApplications:

"When printing types with -fprint-explicit-foralls enabled, type variables not available for visible type application are printed in braces. Thus, if you write myLength = length without a type signature, myLength‘s inferred type will be forall {f} {a}. Foldable f => f a -> Int."

This implies that type variables that are available for type application are not printed braces (though I admit that it doesn't say so outright!). With that in mind, I find the following behavior confusing:

> :set -XTypeApplications -fprint-explicit-foralls
> :t (1 :: Num a => a)
(1 :: Num a => a) :: forall {a}. Num a => a
> (1 :: Num a => a) @Int
1

The :t query seems to indicate that the type variable is not available, but the evaluation query seems to indicate that it is.

Change History (1)

comment:1 Changed 16 months ago by RyanGlScott

Keywords: TypeApplications added
Resolution: fixed
Status: newclosed

The users' guide documentation for TypeApplications has been improved since 8.0.1, and that section now properly mentions that if you wish to learn which types are available for visible type application, then you should use :type +v, not :type. See https://downloads.haskell.org/~ghc/8.4.2/docs/html/users_guide/glasgow_exts.html#visible-type-application (the result of #13401).

Note: See TracTickets for help on using tickets.