<div>I still don&#39;t know whether I like this idea or not, but here is the simplest definition I can think of about what it promises.</div><div><br></div>Using TDNR, it will be possible to write the following code:<div><br>
</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">data Foo = Foo { name :: String }</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">data Bar = Bar { name :: String }</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">getName :: Either Foo Bar -&gt; String</font></div><div>
<font class="Apple-style-span" face="&#39;courier new&#39;, monospace">getName (Left  f) = name f</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">getName (Right b) = name b</font></div>
<div><br></div><div>However, currently you cannot: &quot;Multiple declarations of &#39;name&#39;&quot;</div><div><br></div><div>There are basically two things you can do to solve this &quot;problem&quot;.</div><div> - Use different names for your functions, a la &quot;fooName, barName&quot;. This clutters up your code, and sometimes you may not have access to that part of the code.</div>
<div> - Define these 2 data types in different modules and import qualified, a la &quot;Foo.name, Bar.name&quot;. One might still think this clutters up your code.</div><div><br></div><div>In any case, as a programmer you need to resolve which function to use depending on types while defining &#39;getName&#39;. However compiler has enough information to automate this decision for you. This is not a way to do polymorphism, this is merely a way to allow programmers define more than one function with the same name, but different types.</div>
<div><br></div><div>This kinda sounds like what java people think polymorphism is :P</div><br>-- <br>Ozgur Akgun<br>
</div>