Thanks for the suggestions. The #include worked but I will look for ways to remove the circular dependency altogether.
Jennifer On Friday, April 25, 2008, at 02:48PM, "Henning Thielemann" <[EMAIL PROTECTED]> wrote: > >On Fri, 25 Apr 2008, Jennifer Miller wrote: > >> I have a graph where the nodes contain a number of fields of various types. >> The values for one of those fields -- call it Mass -- need to reside in a >> separate file from the main graph definition (this is for workflow reasons >> and is given to me as a constraint). In order to set the Mass for a >> particular node, I need access to the other fields of that node. The other >> constraint is that the graph needs to be available in an interpreter (eg >> GHCi). >> >> So, I have a circular dependency in my modules that I don't know how to >> resolve in Haskell. I went looking for the equivalent of #include which is >> how I would have solved this in C++. I'm sure there is a simple answer to >> this and I'm hoping this group can point me in the right direction. > > >Sometimes circular module dependencies can be solved by using a type parameter. > > >mutually recursive: > >module A where > >data LabeledTree label = LabeledTree label (Tree label) > > >module B where > >data Tree label = Branch (LabeledTree label) (LabeledTree label) | Leaf > > > > >no mutual recursion: > >module A where > >data LabeledTreeGen tree label = LabeledTree label (tree label) > > >module B where > >type LabeledTree label = LabeledTreeGen Tree label > >data Tree label = Branch (LabeledTree label) (LabeledTree label) | Leaf > > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
