https://wiki.haskell.org/index.php?title=Talk:Generalised_algebraic_datatype&feed=atom&action=historyTalk:Generalised algebraic datatype - Revision history2024-03-19T10:35:46ZRevision history for this page on the wikiMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Talk:Generalised_algebraic_datatype&diff=5017&oldid=prevEricKow at 17:37, 26 July 20062006-07-26T17:37:53Z<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:37, 26 July 2006</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== Pattern Match Warnings ==</div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Sort of a practical question here...</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Sort of a practical question here...</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">Line 13:</td>
<td colspan="2" class="diff-lineno">Line 15:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>If I try to compile the above code with all warnings on, I get a pattern match non-exhaustive warning on safeHead because I'm not matching on Nil. This is pretty annoying. Is this the kind of thing that can easily be fixed? Can the compiler somehow magically recognise that if I've got a <code>List x NonEmpty</code>, then the only patterns to match on are <code>Cons</code> (because those are the only ones that return List x NonEmpty)? Or is there some theoretical barrier to this?</div></td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>If I try to compile the above code with all warnings on, I get a pattern match non-exhaustive warning on safeHead because I'm not matching on Nil. This is pretty annoying. Is this the kind of thing that can easily be fixed? Can the compiler somehow magically recognise that if I've got a <code>List x NonEmpty</code>, then the only patterns to match on are <code>Cons</code> (because those are the only ones that return List x NonEmpty)? Or is there some theoretical barrier to this?<ins class="diffchange diffchange-inline"> -- [[User:EricKow|EricKow]] 17:37, 26 July 2006 (UTC)</ins></div></td>
</tr>
</table>EricKowhttps://wiki.haskell.org/index.php?title=Talk:Generalised_algebraic_datatype&diff=5016&oldid=prevEricKow at 17:37, 26 July 20062006-07-26T17:37:23Z<p></p>
<p><b>New page</b></p><div>Sort of a practical question here...<br />
<br />
<pre><br />
data Empty<br />
data NonEmpty<br />
<br />
data List x y where<br />
Nil :: List a Empty<br />
Cons:: a -> List a b -> List a NonEmpty<br />
<br />
safeHead:: List x NonEmpty -> x<br />
safeHead (Cons a b) = a<br />
</pre><br />
<br />
If I try to compile the above code with all warnings on, I get a pattern match non-exhaustive warning on safeHead because I'm not matching on Nil. This is pretty annoying. Is this the kind of thing that can easily be fixed? Can the compiler somehow magically recognise that if I've got a <code>List x NonEmpty</code>, then the only patterns to match on are <code>Cons</code> (because those are the only ones that return List x NonEmpty)? Or is there some theoretical barrier to this?</div>EricKow