On Wed, Sep 30, 2009 at 8:54 AM, Peter Verswyvelen <[email protected]>wrote:
> I guess this is related to the expression problem. > Actually, this is exactly the expression problem :) > Suppose I have a datatype > > *data Actor = Ball ... | Paddle ... | Wall ...* > > and a function > > *move (Ball ...) = * > *move (Paddle ...) = * > *move (Wall ...) = * > > in Haskell one must put *Actor* and *move* into a single file. > > This is rather cumbersome if you work with multiple people or want to keep > the files small and readable. > > Surely it is possible to use type classes, existentials, etc to split the > data type into multiple ones, but that's already advanced stuff in a sense. > 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 http://www.cse.chalmers.se/~wouter/publications.html > But wouldn'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#'s partial > keyword: > > in file Ball.hs: > *partial data Actor = Ball ...* > *move (Ball ...) =* > > in Paddle.hs > *partial data Actor = Paddle ...* > *move (Paddle ...) =* > > The compiler would then merge all partial data types and functions into > one. > > 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? > Yes, that's true. There's some good reading about this proposal here: http://www.haskell.org/haskellwiki/Extensible_datatypes -- ryan
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
