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

Heinrich Apfelmus apfelmus at quantentunnel.de
Thu Oct 1 04:17:50 EDT 2009


Peter Verswyvelen 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.

Just a nitpick: you don't have to put  Actor  and  move  into the same
module.

    module A where
        data Actor = Ball | Paddle | Wall

    module B where
        import A (Actor)

        move Ball   = ...
        move Paddle = ...
        move Wall   = ...

But that's probably not what you meant.


Regards,
apfelmus

--
http://apfelmus.nfshost.com



More information about the Haskell-Cafe mailing list