From: simonpj Date: Thu, 25 Nov 1999 10:34:53 +0000 (+0000) Subject: [project @ 1999-11-25 10:34:52 by simonpj] X-Git-Tag: Approximately_9120_patches~5491 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=324ec54384803cd54035677ce8b2569734c4f238;p=ghc-hetmet.git [project @ 1999-11-25 10:34:52 by simonpj] Slight wibble on polytype syntax, going in the direction of allowing for-alls in more places. This one lets you say forall a. forall b. a->b --- diff --git a/ghc/compiler/hsSyn/HsTypes.lhs b/ghc/compiler/hsSyn/HsTypes.lhs index 8e3704c..b6c91ea 100644 --- a/ghc/compiler/hsSyn/HsTypes.lhs +++ b/ghc/compiler/hsSyn/HsTypes.lhs @@ -76,7 +76,7 @@ data MonoUsageAnn name -- A valid type must have one for-all at the top of the type, or of the fn arg types mkHsForAllTy (Just []) [] ty = ty -- Explicit for-all with no tyvars -mkHsForAllTy mtvs1 [] (HsForAllTy mtvs2 ctxt ty) = HsForAllTy (mtvs1 `plus` mtvs2) ctxt ty +mkHsForAllTy mtvs1 [] (HsForAllTy mtvs2 ctxt ty) = mkHsForAllTy (mtvs1 `plus` mtvs2) ctxt ty where mtvs1 `plus` Nothing = mtvs1 Nothing `plus` mtvs2 = mtvs2 diff --git a/ghc/compiler/parser/Parser.y b/ghc/compiler/parser/Parser.y index cc76e5d..44dd9e9 100644 --- a/ghc/compiler/parser/Parser.y +++ b/ghc/compiler/parser/Parser.y @@ -1,6 +1,6 @@ {- ----------------------------------------------------------------------------- -$Id: Parser.y,v 1.15 1999/11/01 17:10:23 simonpj Exp $ +$Id: Parser.y,v 1.16 1999/11/25 10:34:53 simonpj Exp $ Haskell grammar. @@ -474,7 +474,12 @@ ext_name :: { Maybe ExtName } ----------------------------------------------------------------------------- -- Types -{- ToDo: forall stuff -} +-- A ctype is a for-all type +ctype :: { RdrNameHsType } + : 'forall' tyvars '.' ctype { mkHsForAllTy (Just $2) [] $4 } + | context type { mkHsForAllTy Nothing $1 $2 } + -- A type of form (context => type) is an *implicit* HsForAllTy + | type { $1 } type :: { RdrNameHsType } : btype '->' type { MonoFunTy $1 $3 } @@ -506,14 +511,6 @@ gtycon :: { RdrName } inst_type :: { RdrNameHsType } : ctype {% checkInstType $1 } -ctype :: { RdrNameHsType } - : 'forall' tyvars '.' context type - { mkHsForAllTy (Just $2) $4 $5 } - | 'forall' tyvars '.' type { mkHsForAllTy (Just $2) [] $4 } - | context type { mkHsForAllTy Nothing $1 $2 } - -- A type of form (context => type) is an *implicit* HsForAllTy - | type { $1 } - types0 :: { [RdrNameHsType] } : types { $1 } | {- empty -} { [] } @@ -583,7 +580,7 @@ fielddecl :: { ([RdrName],RdrNameBangType) } : vars '::' stype { (reverse $1, $3) } stype :: { RdrNameBangType } - : type { Unbanged $1 } + : ctype { Unbanged $1 } | '!' atype { Banged $2 } deriving :: { Maybe [RdrName] }