On Wed, Sep 30, 2009 at 8:54 AM, Peter Verswyvelen <span dir="ltr">&lt;<a href="mailto:bugfact@gmail.com">bugfact@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I guess this is related to the expression problem.<div></div></blockquote><div><br>Actually, this is exactly the expression problem :)<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Suppose I have a datatype</div><div><br></div><div><b>data Actor = Ball ... | Paddle ... | Wall ...</b></div><div><br></div><div>and a function</div><div>
<br></div><div><b>move (Ball ...) = </b></div><div><div><b>move (Paddle ...) = </b></div><div><div><b>move (Wall ...) = </b></div><div><br></div><div>in Haskell one must put <b>Actor</b> and <b>move</b> into a single file.</div>

<div><br></div><div><div>This is rather cumbersome if you work with multiple people or want to keep the files small and readable.</div><div><br></div></div><div>Surely it is possible to use type classes, existentials, etc to split the data type into multiple ones, but that&#39;s already advanced stuff in a sense.</div>
</div></div></blockquote><div><br>Yes, and type classes are the current solution.  I think the most elegant solution right now is provided by Data Types a la Carte; see <a href="http://www.cse.chalmers.se/~wouter/publications.html">http://www.cse.chalmers.se/~wouter/publications.html</a><br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div>
<div>But wouldn&#39;t it be possible to allow these to be put into multiple files, and let the compiler merge them back into one? A bit like C#&#39;s partial keyword:</div><div><br></div><div>in file Ball.hs:</div>
<div><b>partial data Actor = Ball ...</b></div><div><b>move (Ball ...) =</b></div><div><br></div><div>in Paddle.hs</div><div><div><b>partial data Actor = Paddle ...</b></div><div><b>move (Paddle ...) =</b></div><div><br>
</div>
<div>The compiler would then merge all partial data types and functions into one.</div><div><br></div><div>As far as no overlap exists in the pattern matches in move, so that the order of the pattern matches does not matter at all, the partial trick should be possible no?</div>
</div></div></div></blockquote><div><br>Yes, that&#39;s true.  There&#39;s some good reading about this proposal here: <a href="http://www.haskell.org/haskellwiki/Extensible_datatypes">http://www.haskell.org/haskellwiki/Extensible_datatypes</a><br>
<br>  -- ryan<br><br></div></div>