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

#14088: Allow users to omit`forall` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Just an idea I wanted to get out there, I don't think it causes parsing ambiguity {{{#!hs -- id :: forall a. a -> a id :: a. a -> a -- everywhere :: (forall b. Term b => b -> b) -> (forall a. Term a => a -> a) everywhere :: (b. Term b => b -> b) -> (a. Term a => a -> a) }}} I think it looks beautiful but clearly more difficult to Google or grep for. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14088 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14088#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 AntC): Hmm so {{{ f :: forall a b. a -> b -> a }}} becomes {{{ f :: a b. a -> b -> a }}} That initial `a b` looks like type application. {{{ g :: b.Foo -> Int }}} You probably meant {{{ g :: B.Foo -> Int }}} If you think `forall` is too verbose, you could use ∀ (?) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14088#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#14088: Allow users to omit `forall` -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: wontfix | 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: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * status: new => closed * resolution: => wontfix Comment: Yeah I didn't think this would gain traction and I agree that it complicates parsing, but it was too cute not to get the idea out. Thanks for the feedback! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14088#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

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