How to catch errors/unsolved constraints from GHC type checker?
Andreas Abel
abela at chalmers.se
Mon Sep 22 13:43:45 UTC 2014
Hi, I am stuck fixing issue #9582
https://ghc.haskell.org/trac/ghc/ticket/9582
I need to test whether one type is a subtype of another and throw a
custom error if this is not the case. I tried
(errMsgs, result) <- tryTcErrs $
tcSubType ctOrigin userTypeCtxt local_meth_ty sig_ty
case result of
Just _coercion -> return ()
Nothing -> badInstSigErr sel_name local_meth_ty
However, it does not seem to do what I expect. It acts as if I had not
tried to catch the error, it acts as just
tcSubType ctOrigin userTypeCtxt local_meth_ty sig_ty
My hypothetical explanations:
1. 'tryTcErrs' is not the correct function to catch errors in the
type checker. Or,
2. 'tcSubType' does not generate errors, just postponed constraints,
which are checked later in a clean-up phase. Thus, I do not get an
error now I could handle, but the error is generated later during the
constraint solving phase, where I do not have a handler in place. In
this case, I would need something like Agda's noConstraints,
tryTcErrs $ noConstraints $ tcSubType...
which forces 'tcSubType' to check without generating new unification
constraints.
Any advice how to do is or where to continue searching?
Thanks,
Andreas
--
Andreas Abel <>< Du bist der geliebte Mensch.
Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden
andreas.abel at gu.se
http://www2.tcs.ifi.lmu.de/~abel/
More information about the ghc-devs
mailing list