<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Velx Dev</title>
    <description>The latest articles on DEV Community by Velx Dev (@velx).</description>
    <link>https://dev.to/velx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3824494%2F52efd733-4c2f-4ee1-8e73-33c7adeeffd7.png</url>
      <title>DEV Community: Velx Dev</title>
      <link>https://dev.to/velx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/velx"/>
    <language>en</language>
    <item>
      <title>TIL: Rust's lack of HKTs can cause inductive cycles that ICE the compiler</title>
      <dc:creator>Velx Dev</dc:creator>
      <pubDate>Sat, 14 Mar 2026 20:35:34 +0000</pubDate>
      <link>https://dev.to/velx/til-rusts-lack-of-hkts-can-cause-inductive-cycles-that-ice-the-compiler-o79</link>
      <guid>https://dev.to/velx/til-rusts-lack-of-hkts-can-cause-inductive-cycles-that-ice-the-compiler-o79</guid>
      <description>&lt;p&gt;Just spent some time reading a really wild blog post about Rust's type system and I had to share the rabbit hole it took me down.&lt;/p&gt;

&lt;p&gt;The setup: someone was writing an FP scripting language and wanted to abstract over wrapper types (like &lt;code&gt;Spanned&amp;lt;T&amp;gt;&lt;/code&gt; vs &lt;code&gt;Simple&amp;lt;T&amp;gt;&lt;/code&gt;) using a GAT-based HKT emulation pattern. Pretty standard stuff for type-fu enthusiasts.&lt;/p&gt;

&lt;p&gt;The problem: when they derived &lt;code&gt;PartialEq&lt;/code&gt; on their recursive type that used this pattern, rustc threw an E0275 overflow evaluating trait requirements. The derive was creating a circular dependency: to prove &lt;code&gt;Foo&amp;lt;W&amp;gt;: PartialEq&lt;/code&gt;, you need &lt;code&gt;W::Wrapper&amp;lt;Foo&amp;lt;W&amp;gt;&amp;gt;: PartialEq&lt;/code&gt;, which requires &lt;code&gt;Foo&amp;lt;W&amp;gt;: PartialEq&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;This is actually a coinduction problem. Rust's trait solver is inductive by default - proofs must terminate. Only auto-traits like &lt;code&gt;Send&lt;/code&gt;/&lt;code&gt;Sync&lt;/code&gt; are coinductive (allowing infinite/cyclic proof trees). So you literally cannot derive &lt;code&gt;PartialEq&lt;/code&gt; on certain recursive GAT types right now.&lt;/p&gt;

&lt;p&gt;The author went on a detour into mathematical induction vs coinduction, even writing proofs in Lean 4 to understand what was happening. Then someone found an ICE (internal compiler error) using &lt;code&gt;-Znext-solver=globally&lt;/code&gt; with these patterns.&lt;/p&gt;

&lt;p&gt;The fix is coming with the next-gen trait solver, but it's not stable yet.&lt;/p&gt;

&lt;p&gt;TIL: type theory rabbit holes can start from something as innocent as wanting to wrap AST nodes differently. Also coinduction is wild.&lt;/p&gt;

&lt;p&gt;Original article: &lt;a href="https://www.harudagondi.space/blog/torturing-rustc-by-emulating-hkts" rel="noopener noreferrer"&gt;https://www.harudagondi.space/blog/torturing-rustc-by-emulating-hkts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
