[project @ 1999-11-25 10:34:52 by simonpj]
authorsimonpj <unknown>
Thu, 25 Nov 1999 10:34:53 +0000 (10:34 +0000)
committersimonpj <unknown>
Thu, 25 Nov 1999 10:34:53 +0000 (10:34 +0000)
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

ghc/compiler/hsSyn/HsTypes.lhs
ghc/compiler/parser/Parser.y

index 8e3704c..b6c91ea 100644 (file)
@@ -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 
index cc76e5d..44dd9e9 100644 (file)
@@ -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] }