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

Niklas Broberg niklas.broberg at gmail.com
Wed Sep 30 12:00:12 EDT 2009


Hi Peter,

sounds to me you want to have a look at "Open Data Types and Open
Functions" by Andres Löh and Ralf Hinze:

http://people.cs.uu.nl/andres/OpenDatatypes.pdf

Cheers,

/Niklas

On Wed, Sep 30, 2009 at 5:54 PM, Peter Verswyvelen <bugfact at gmail.com> wrote:
> 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
> 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?
> Cheers,
> Peter
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


More information about the Haskell-Cafe mailing list