How to debug type-level programs : <p>I'm trying to do some hoopy type-level programming, and it just doesn't work. I'm tearing my hair out trying to figure out why the heck GHC utterly fails to infer the type signatures I want.</p>

<p>Is there some way to make GHC <em>tell me</em> what it's doing?</p>

<p>I tried <code>-ddump-tc</code>, which just prints out the final type signatures. (Yes, they're wrong. Thanks, I already knew that.)</p>

<p>I also tried <code>-ddump-tc-trace</code>, which dumps out ~70KB of unintelligible gibberish. (In particular, I can't see any user-written identifiers mentioned <em>anywhere</em>.)</p>

<p>My code is <em>so close</em> to working, but somehow an extra type variable keeps appearing. For some reason, GHC can't see that this variable should be completely determined. Indeed, if I <em>manually</em> write the five-mile type signature, GHC happily accepts it. So I'm clearly just missing a constraint somewhere... <em>but where?!?</em> >_&lt;</p>
