[GHC] #12085: Premature defaulting and variable not in scope

GHC ghc-devs at haskell.org
Thu May 19 17:18:40 UTC 2016


#12085: Premature defaulting and variable not in scope
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              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 Iceland_jack):

 Ah they are both by design, interesting!

 Replying to [comment:1 simonpj]:
 > So I think everything is behaving as designed there.  (You may want to
 propose a design change.)

 If I were to propose one, it would look something like this:

 {{{
 ghci> :type todo
 todo :: String
 ghci> :set -XAllowAmbiguousTypes
 ghci> :type todo
 todo :: forall a. (Read a, Show a) => String
 }}}

 I haven't read #11376 (as well as being out of my depth) so I defer to the
 judgment of GHC developers.

 ----

 Replying to [comment:2 simonpj]:
 > For the second, a type signature brings into scope ''only'' the type
 variables in the ''leading'' or top-level `forall`.  So in

 I'm not familiar with the terminology, what is a ‘''leading''’ forall?

 > But for ''non-top-level'' foralls, nothing is brought into scope
 >
 > `[…]`
 >
 > This is again by design, and I think it's documented.

 Searching for “''non-top-level'' foralls” only gives this thread, I guess
 there isn't a formal name for it.

 I found these references in the user guide

 > `[…]` it is possible to declare type arguments somewhere other than the
 beginning of a type” regarding `RankNTypes`.

 > That is, you can nest foralls arbitrarily deep in function arrows

 > The `-XRankNTypes` option is also required for any type with a forall or
 context to the right of an arrow (e.g. `f :: Int -> forall a. a->a`, or `g
 :: Int -> Ord a => a -> a`).

 but I didn't find information about scoping. Is there a fundamental reason
 this couldn't work:

 {{{#!hs
 one :: forall a. Int -> ...
 one in_scope = {- ‘a’ is in scope -}

 two :: Int -> forall a. ...
 two not_in_scope = {- ‘a’ is in scope -}
 }}}

 This is not a feature I desperately need

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12085#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list