Fixing Parser.y for correct infix type synonyms
Johan Glimming
glimming at kth.se
Thu Feb 17 16:17:16 EST 2005
Hi
I am looking into the ghc source code for the first time in order to
see if I can understand why type synonyms are not correctly parsed with
the ghc extension for infix :-*-: etc.
I note that the following is present in the file Parser.y in
ghc-6.4.20050216/ghc/compiler/parser and I assume it here ghc is
parsing the type declarations?
tycl_decl :: { LTyClDecl RdrName }
: 'type' syn_hdr '=' ctype
-- Note ctype, not sigtype.
-- We allow an explicit for-all but we don't insert one
-- in type Foo a = (b,b)
-- Instead we just say b is out of scope
{ sL (comb2 $1 $>) $ let (tc,tvs) = $2 in TySynonym tc
tvs $4 }
on the next line happy is probably given instructions how to parse data
declarations?
| 'data' tycl_hdr constrs deriving
{ L (comb4 $1 $2 $3 $4)
(mkTyData DataType $2 Nothing (reverse (unLoc $3))
(unLoc $4)) }
Now, can someone explain what happens here, e.g. what is the difference
between parsing of data and type synonyms?
I guess (!) that the handling of infixes is merely an issue in the
parser, and would not affect much else in ghc?
Johan Glimming.
More information about the Glasgow-haskell-users
mailing list