From c0f542271da944d540faf91678c48ff856174b57 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Wed, 27 Aug 2008 15:19:26 +0000 Subject: [PATCH] Better documentation for -XLiberalTypeSynonyms, and steal forall keyword In my travels through the front end I discoverd that -XLiberalTypeSynonyms is rather thinly described. Furthermore, it alleges that you can write a forall on the RHS of a type synonym decl, so that means it should enable the forall keyword. --- compiler/parser/Lexer.x | 1 + docs/users_guide/glasgow_exts.xml | 45 ++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index f06624e..66f4fe5 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -1665,6 +1665,7 @@ mkPState buf loc flags = .|. qqBit `setBitIf` dopt Opt_QuasiQuotes flags .|. ipBit `setBitIf` dopt Opt_ImplicitParams flags .|. explicitForallBit `setBitIf` dopt Opt_ScopedTypeVariables flags + .|. explicitForallBit `setBitIf` dopt Opt_LiberalTypeSynonyms flags .|. explicitForallBit `setBitIf` dopt Opt_PolymorphicComponents flags .|. explicitForallBit `setBitIf` dopt Opt_ExistentialQuantification flags .|. explicitForallBit `setBitIf` dopt Opt_Rank2Types flags diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 4d31dd1..cb5033a 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -164,6 +164,38 @@ documentation describes all the libraries that come with GHC. + + + + + + + + + + + + + These flags control higher-rank polymorphism. + See . + New reserved words: forall. + + + + + + + + + + Allow more liberal type synonyms. + See . + New reserved words: forall. + + + + + @@ -180,8 +212,7 @@ documentation describes all the libraries that come with GHC. - See . Only relevant - if you also use . + See . @@ -1716,9 +1747,12 @@ to be written infix, very much like expressions. More specifically: Liberalised type synonyms -Type synonyms are like macros at the type level, and +Type synonyms are like macros at the type level, but Haskell 98 imposes many rules +on individual synonym declarations. +With the extension, GHC does validity checking on types only after expanding type synonyms. -That means that GHC can be very much more liberal about type synonyms than Haskell 98: +That means that GHC can be very much more liberal about type synonyms than Haskell 98. + You can write a forall (including overloading) in a type synonym, thus: @@ -1735,7 +1769,8 @@ in a type synonym, thus: -You can write an unboxed tuple in a type synonym: +If you also use , +you can write an unboxed tuple in a type synonym: type Pr = (# Int, Int #) -- 1.7.10.4