[GHC] #14288: ScopedTypeVariables with nested foralls broken since 8.0.2
GHC
ghc-devs at haskell.org
Fri Sep 29 11:15:34 UTC 2017
#14288: ScopedTypeVariables with nested foralls broken since 8.0.2
-------------------------------------+-------------------------------------
Reporter: MikolajKonarski | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.2.1
checker) |
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: GHC rejects | (amd64)
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Richard and I both think we should stick with the current behaviour, and
specify it in the user manual. That is, with `-XScopedTypeVariables`,
and a signature
{{{
f :: forall a b c. blah
<definition of f>
}}}
then `a`, `b` and `c` scope over f's definition, but no other type
variables do. This applies unconditionally, even if `blah` starts with
another `forall`.
The `forall` must appear literally, not hidden by a type synonym. Eg. no
variables scope here
{{{
type Foo = forall a b. a -> b -> Int
f :: Foo
f = e -- a and b are not in scope here
}}}
This rule is simple, and does not restrict expressiveness. Otherwise we
land up trying to decide where to draw the line (and having to explain
where it is drawn, in the user manual). Eg
{{{
f :: forall a. forall b. blah
f :: forall a. a -> forall b. blah
f :: forall a. Eq a => forall b. blah
}}}
Would someone care to update the user manual?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14288#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list