-- 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
{-
-----------------------------------------------------------------------------
-$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.
-----------------------------------------------------------------------------
-- 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 }
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 -} { [] }
: vars '::' stype { (reverse $1, $3) }
stype :: { RdrNameBangType }
- : type { Unbanged $1 }
+ : ctype { Unbanged $1 }
| '!' atype { Banged $2 }
deriving :: { Maybe [RdrName] }