Commit 324ec543 authored by simonpj's avatar simonpj
Browse files

[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
parent 1ea67691
......@@ -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
......
{-
-----------------------------------------------------------------------------
$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] }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment