Error handling in the renamer
Jan Stolarek
jan.stolarek at p.lodz.pl
Thu Nov 13 09:26:38 UTC 2014
I'm improving my patch for injective type families and I have a question about error handling in
the renamer. If I write this incorrect definition:
type family F a b = r | r -> c
I get these errors:
T6018rnfail.hs:36:1: Not in scope: type variable ‘c’
T6018rnfail.hs:36:26:
Unexpected type variable on the RHS of injectivity condition: ‘c’
All variables should be bound in type family head and appear at most once in exactly the same
order as they were bound.
I don't want to report two errors here, just the first one. This means I have to first run the
renaming using RnTypes.rnTyVar and check if it reports errors. If it does I don't report the
extra error. The question is how do I check if this piece of code returns errors:
injFrom' <- rnTyVar True injFrom
injTo' <- mapM (rnTyVar True) injTo
I found some combinators in TcRnMonad (tryTc and friends) but I don't know how to use them.
Ideally I'd want `TcRn a -> TcRn (Messages, a)` + isEmptyMessages but the existing combinators
return `TcRn a -> TcRn (Messages, Maybe a)`. I'm not at all happy with getting Nothing - even if
renaming fails my function has to return a result.
Jan
More information about the ghc-devs
mailing list