[project @ 2005-04-04 11:55:11 by simonpj]
This commit combines three overlapping things:
1. Make rebindable syntax work for do-notation. The idea
here is that, in particular, (>>=) can have a type that
has class constraints on its argument types, e.g.
(>>=) :: (Foo m, Baz a) => m a -> (a -> m b) -> m b
The consequence is that a BindStmt and ExprStmt must have
individual evidence attached -- previously it was one
batch of evidence for the entire Do
Sadly, we can't do this for MDo, because we use bind at
a polymorphic type (to tie the knot), so we still use one
blob of evidence (now in the HsStmtContext) for MDo.
For arrow syntax, the evidence is in the HsCmd.
For list comprehensions, it's all built-in anyway.
So the evidence on a BindStmt is only used for ordinary
do-notation.
2. Tidy up HsSyn. In particular:
- Eliminate a few "Out" forms, which we can manage
without (e.g.
- It ought to be the case that the type checker only
decorates the syntax tree, but doesn't change one
construct into another. That wasn't true for NPat,
LitPat, NPlusKPat, so I've fixed that.
- Eliminate ResultStmts from Stmt. They always had
to be the last Stmt, which led to awkward pattern
matching in some places; and the benefits didn't seem
to outweigh the costs. Now each construct that uses
[Stmt] has a result expression too (e.g. GRHS).
3. Make 'deriving( Ix )' generate a binding for unsafeIndex,
rather than for index. This is loads more efficient.
(This item only affects TcGenDeriv, but some of point (2)
also affects TcGenDeriv, so it has to be in one commit.)
43 files changed: