wiki:ExplicitForall

Version 1 (modified by NiklasBroberg, 5 years ago) (diff)

--

Proposal: ExplicitForall

Ticket #999
Dependencies
Related Rank2Types, RankNTypes, LiberalTypeSynonyms, PolymorphicComponents, ScopedTypeVariables

Compiler support

GHC [ full (Rank2Types etc) ]
nhc98 [ none ]
Hugs [ full (+98) ]
UHC [ full (none) ]
JHC [ none ]
LHC [ none ]

Description

ExplicitForall enables the use of the keyword 'forall' to make a type explicitly polymorphic. Syntactically, it would mean the following change to Haskell 98:

  • forall becomes a reserved word.
  • . (dot) becomes a special (not reserved) operator.
  • The following syntactic rule changes:

type → forall tyvars . type

| context => type

| ftype

ftypebtype -> type

| btype

gendeclvars :: type

It does not allow the use of explicitly polymorphic types in any way not already allowed by Haskell 98 for implicitly polymorphic types.

References

http://www.haskell.org/pipermail/haskell-prime/2009-June/002786.html

Pros

  • Small and simple syntactic extension.
  • Simplifies the later inclusion of semantic extensions that depend on it, e.g. Rank2Types.
  • Easy to implement in tools that don't yet support the semantic extensions.
  • The Report already mentions types using the explicit forall-quantified form, so only the grammar changes above are needed.

Cons

  • A small and incremental extension with little value of its own, only serving as a stepping stone for the various semantic extensions.