GHC: Ticket #4099: Slighlty confusing error message with data families
http://ghc.haskell.org/trac/ghc/ticket/4099
<p>
Example code:
</p>
<pre class="wiki">data family T a
foo :: T a -> a
foo (Just x) = x
</pre><p>
Error message:
</p>
<pre class="wiki"> Couldn't match expected type `T a' against inferred type `Maybe a1'
NB: `T' is a type function
In the pattern: Just x
In the definition of `foo': foo (Just x) = x
</pre><p>
Calling <code>T</code> a type function is confusing, I had to double check that I hadn't accidentally declared it as a type family. I would
</p>
<ul><li>call these things type families and data families in messages and
</li></ul><ul><li>omit the message for data families altogether because it doesn't matter that <code>T</code> is one in this case.
</li></ul>en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/4099
Trac 1.2simonpjMon, 31 May 2010 16:37:59 GMTstatus changed; testcase, resolution set
http://ghc.haskell.org/trac/ghc/ticket/4099#comment:1
http://ghc.haskell.org/trac/ghc/ticket/4099#comment:1
<ul>
<li><strong>testcase</strong>
set to <em>indexed-types/should_fail/T4099</em>
</li>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
<p>
Yes good point. Fixed by
</p>
<pre class="wiki">Mon May 31 15:04:13 BST 2010 simonpj@microsoft.com
* Fix Trac #4099: better error message for type functions
Now we only want about "T is a type function and might not be
injective" when matchin (T x) against (T y), which is the case
that is really confusing.
M ./compiler/typecheck/TcTyFuns.lhs -14 +9
</pre>
Ticket