[Haskell-beginners] Linking modules

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Dec 11 20:56:23 CET 2010


On Sat, Dec 11, 2010 at 7:37 PM, Russ Abbott <russ.abbott at gmail.com> wrote:
> I have two modules Structure and Component.  Module Structure defines
>      data Structure = Component ...
> Module Component defines
>     data Component = ...
> I would like Structure to import Component.  But Component
> includes functions that take a Structure as an argument. So I have (or would
> like) something like this organization.
>
> [snip]
>
> The functions in Component are really very Component related and should not
> be moved to Structure. So how can I set up this circular relationship?

GHC allows you to compile mutually recursive modules, see
http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#mutual-recursion
for how to do it.

-- 
Jedaï



More information about the Beginners mailing list