<p dir="ltr"><br>
On Jun 19, 2015 2:29 PM, "Richard Eisenberg" <<a href="mailto:eir@cis.upenn.edu">eir@cis.upenn.edu</a>> wrote:<br>
> With a closed family, you could always do something like this:<br>
><br>
> > type family Error (msg :: Symbol)     -- no instances!<br>
> > type family Sub a b where<br>
> >   -- real work<br>
> >   Sub a b = Error "Sub is undefined here"<br>
><br>
> Would that help? It still doesn't immediately error (there's no way to do that currently), but it's perhaps more telling to have an error string.</p>
<p dir="ltr">Ghc does error out right away if you give it an infinite loop:</p>
<p dir="ltr">type family Fail (x::k) (a :: *) where<br>
  Fail x a = Fail x (Fail "don't raise the context stack please" a)</p>
<p dir="ltr">-- defining f leads to compile failure, and the message includes the "msg"<br>
f :: Fail "msg" ()<br>
f = undefined</p>
<p dir="ltr">But it would be nice to have a less hacky solution, especially as this one gives error messages that suggest giving the type checker more resources.</p>
<p dir="ltr">Regards,<br>
Adam<br>
</p>