Commit 2f874c4c authored by chak's avatar chak
Browse files

[project @ 2002-02-12 03:52:08 by chak]

This fixes a problem with the recent clean up in the parsing of type
declarations.  The cleaned up version was correct by H98 (I think), but
unfortunately won't compile the Prelude anymore.

I made the definition a little bit more liberal as follows:
- In `tycl_hdr' allow `gtycon' instead of just `tycon' for the defined type
  constructor.  This allows beyond H98 special syntax like "[]" etc as well as
  tycon ops in parenthesis.  Moreover, it allows qualified names, but the
  renamer flags the latter as errors.
- Allow `gtycon' instead of only `qtycon' for the class name in definitions of
  the form `Eq a => T a' to avoid a whole list of s/r conflicts.  (I have *not*
  checked that the renamer flags misuse, but I would expect that it does.)

ToDo: I think, the renamer should raise an error for all these additional
      forms *unless* -fglasgow-exts is given.

In PrelBase, I needed to replace the infix notation by prefix notation in the
definition of `:+:' and `:*:'.
parent 70467775
{- -*-haskell-*-
-----------------------------------------------------------------------------
$Id: Parser.y,v 1.86 2002/02/11 15:16:26 simonpj Exp $
$Id: Parser.y,v 1.87 2002/02/12 03:52:08 chak Exp $
Haskell grammar.
......@@ -389,15 +389,25 @@ topdecl :: { RdrBinding }
-- (Eq a, Ord b) => T a b
-- Rather a lot of inlining here, else we get reduce/reduce errors
tycl_hdr :: { (RdrNameContext, RdrName, [RdrNameHsTyVar]) }
: '(' comma_types1 ')' '=>' tycon tv_bndrs {% mapP checkPred $2 `thenP` \ cxt ->
: '(' comma_types1 ')' '=>' gtycon tv_bndrs {% mapP checkPred $2 `thenP` \ cxt ->
returnP (cxt, $5, $6) }
| qtycon atypes1 '=>' tycon atypes0 {% checkTyVars $5 `thenP` \ tvs ->
-- qtycon for the class below name would lead to many s/r conflicts
-- FIXME: does the renamer pick up all wrong forms and raise an
-- error
| gtycon atypes1 '=>' gtycon atypes0 {% checkTyVars $5 `thenP` \ tvs ->
returnP ([HsClassP $1 $2], $4, tvs) }
| qtycon atypes0 {% checkTyVars $2 `thenP` \ tvs ->
| gtycon atypes0 {% checkTyVars $2 `thenP` \ tvs ->
returnP ([], $1, tvs) }
-- We have to have qtycon in this production to avoid s/r conflicts
-- with the previous one. The renamer will complain if we use
-- a qualified tycon.
-- We have to have qtycon in this production to avoid s/r
-- conflicts with the previous one. The renamer will complain
-- if we use a qualified tycon.
--
-- Using a `gtycon' throughout. This enables special syntax,
-- such as "[]" for tycons as well as tycon ops in
-- parentheses. This is beyond H98, but used repeatedly in
-- the Prelude modules. (So, it would be a good idea to raise
-- an error in the renamer if some non-H98 form is used and
-- -fglasgow-exts is not given.) -=chak
decls :: { [RdrBinding] }
: decls ';' decl { $3 : $1 }
......
% -----------------------------------------------------------------------------
% $Id: PrelBase.lhs,v 1.60 2002/01/29 09:58:19 simonpj Exp $
% $Id: PrelBase.lhs,v 1.61 2002/02/12 03:52:09 chak Exp $
%
% (c) The University of Glasgow, 1992-2000
%
......@@ -599,8 +599,8 @@ instance CReturnable () -- Why, exactly?
\begin{code}
data Unit = Unit
data a :+: b = Inl a | Inr b
data a :*: b = a :*: b
data (:+:) a b = Inl a | Inr b
data (:*:) a b = a :*: b
\end{code}
......
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