
Johannes Waldmann
As for recursive module imports, could you perhaps show an example where this occurs. I found that in my code, I can re-arrange things so as to remove the cyclic dependency. Best regards,
Consider the following situation, which often happens. * A function f calls for g and for h, each g and h calls for f. * f is a large implementation, gathered in the module F. * g and h are the two important special cases for f, each implemented as a large source, according to its very particular principles. * Each of these three functions needs only a small part of the name space needed for other two functions (modules are also for structuring the name space).
From the conceptual point of view, we need at least three modules in this case. This way this program is easier to write and to understand. But the module import occurs cyclic.
----------------- Serge Mechveliani mechvel@botik.ru

On Wed, Jun 07, 2006 at 11:26:34AM +0200, Christian Maeder wrote:
Serge D. Mechveliani wrote:
Consider the following situation, which often happens. * A function f calls for g and for h, each g and h calls for f.
How about adding a parameter to g and h (instead of calling f directly)?
I do not know. Will the source look natural? Can you explain this more precisely: what to change in f, g, and h ? Let it be f, g, h :: Int -> Int. ----------------- Serge Mechveliani mechvel@botik.ru

Serge D. Mechveliani wrote:
I do not know. Will the source look natural?
That depends on g and h, a generalization can look natural or artifical.
Can you explain this more precisely: what to change in f, g, and h ? Let it be f, g, h :: Int -> Int.
new situtation: module F where import G import H f :: Int -> Int f x = ... g f (... x ...) ... h f (... x ...) module G where g :: (Int -> Int) -> Int -> Int g f x = ... module H ...

Concering adding an argument to a function intstead of using recursive import, Christian Maeder wrote on Jun 07, 2006
I do not know. Will the source look natural?
That depends on g and h, a generalization can look natural or artifical.
Can you explain this more precisely: what to change in f, g, and h ? Let it be f, g, h :: Int -> Int.
new situtation:
module F where import G import H
f :: Int -> Int
f x = ... g f (... x ...) ... h f (... x ...)
module G where
g :: (Int -> Int) -> Int -> Int
g f x = ...
module H ...
Thank you for pointing at such possibility. Still I think, such a program looks more natural when it uses recursive modules rather than adding extra arguments to functions. Also this is not only for functions. Instances often use each other in a recursive way: module A where ... instance Foo1 Data1 where ... module B where ... instance Foo2 Data2 where ... module C where ... instance Foo3 Data3 where ... ----------------- Serge Mechveliani mechvel@botik.ru
participants (2)
-
Christian Maeder
-
Serge D. Mechveliani