[GHC] #14088: Allow users to omit `forall`

GHC ghc-devs at haskell.org
Fri Aug 4 15:50:57 UTC 2017


#14088: Allow users to omit `forall`
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:
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):

 I don't support this idea. The issue is that in a type signature like
 `forall a b. a b`, there are two different varieties of type variables.
 There are type variable //binders// which appear between the `forall` and
 the dot (e.g., the `a` and `b` in `forall a b.`), and type variable
 //types//, which occur to right of the dot (e.g., the `a` and `b` in `. a
 b`).

 Syntactically, however, the difference between these two is not always so
 clear. This is where the `forall` keyword is extremely helpful to the
 reader. It gives a clear indication that what follows are type variable
 binders and not proper types. If we allow `forall` to be omitted, however,
 mentally parsing type signatures will become more of a chore. For
 instance, if you have this type signature:

 {{{#!hs
 f :: a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff
 gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz. a b c d e f g
 h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll
 mm nn oo pp qq rr ss tt uu vv ww xx yy zz
 }}}

 When I start reading the type of `f`, I have no idea if I'm looking at
 binders or types. I have to reserve extra lookahead to figure out what I'm
 looking at. With `forall`, this isn't an issue, because I can know
 instantly where the binders start.

 I'm not even sure what omitting `forall` even buys you. As AntC says, if
 you wish to write terser code, this is a perfectly cromulent thing to do:

 {{{
 {-# LANGUAGE RankNTypes #-}
 {-# LANGUAGE UnicodeSyntax #-}

 id :: ∀ a. a -> a
 id x = x
 }}}

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


More information about the ghc-tickets mailing list