[Haskell-cafe] Splitting data and function declarations over multiple files

Peter Verswyvelen bugfact at gmail.com
Wed Sep 30 11:54:22 EDT 2009

I guess this is related to 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.

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

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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090930/8dd89420/attachment.html

More information about the Haskell-Cafe mailing list