Re: [Haskell-cafe] n00b circular dep question
On Sat, Apr 26, 2008 at 4:07 AM, Bulat Ziganshin [EMAIL PROTECTED] wrote: 2. ghc supports this part of standard in a rather awkward way - you need to generate .hs-boot files using some switch (look into docs). which is like .h files generated automatic from .cpp. once these files aregenerated, your circular deps will be ok Are you sure? I would be very interested in a switch that automatically generates hs-boot files, but I've been unable to find any mention of it. Stuart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b circular dep question
On Apr 25, 2008, at 11:54 AM, Jennifer Miller wrote: I have a circular dependency in my modules that I don't know how to resolve in Haskell. I'm pretty sure that GHC will sort out those dependencies for you as long as you are exporting the correct things from each module. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b circular dep question
On Apr 25, 2008, at 9:54 AM, Jennifer Miller wrote: 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. GHC supports CPP, so you could take the same approach in Haskell. # cat Main.hs data Foo = Foo { x :: Int, y :: Int } deriving Show foo = Foo { x = 2, #include y.hs } # cat y.hs y = (x foo) + 2 # ghci -cpp Main.hs GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( Main.hs, interpreted ) Ok, modules loaded: Main. *Main foo Foo {x = 2, y = 4} *Main Aaron ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b circular dep question
Hello Jennifer, Friday, April 25, 2008, 8:54:42 PM, you wrote: So, I have a circular dependency in my modules that I don't know how to resolve in Haskell. 1. haskell standard allows circular deps between modules 2. ghc supports this part of standard in a rather awkward way - you need to generate .hs-boot files using some switch (look into docs). which is like .h files generated automatic from .cpp. once these files aregenerated, your circular deps will be ok -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b circular dep question
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 Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b circular dep question
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 Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe