`Coercible` ought to work for recursive newtypes
|Reported by:||nomeata||Owned by:||nomeata|
|Component:||Compiler (Type checker)||Version:||7.6.3|
|Keywords:||Cc:||dimitris@…, sweirich@…, diatchki|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
Description (last modified by simonpj)
The approach (developed by SPJ and me) is to
A) Add a feature to the constraint solver to prevent recursive dictionaries for specially marked instances (for now only used for Coercible). Rationale: Such dictionaries (which are fine for most classes like Show) would make coerce diverge. Implementation: Use the depth counter and do not use lower depths to solver constraints with a higher depth. This is of course a very conservative approximation, but should be sufficient.
B) Use the regular constraint depth bound to prevent looping at compile time. In order for that to be more useful, count constraint solving and type function resolving separately.