[Haskell-cafe] Avoiding Dependency loops

martin martin.drautzburg at web.de
Sun Oct 25 08:36:17 UTC 2015

Hello all,

I just split up a program I'm working on into several source files and ran into the following difficulty:

module Process implements Process which has a field Runner. Runner is a basically a function which alters a 'System'
state. So Process needs Runner, Runner needs System and thus Process needs System.

module System implements among others a collection of Processes (because Processes can alter their states). So System
needs Process.

Eh voila, I have a loop.

What I did was to leave the type of the Runner unspecified in Process, i.e. I now have (Process r) where r is the type
of the Runner. Thus Process no longer needs to know about System.

This does work, but it feels strange and I'm a bit worried that this is an indication for a design flaw, but I cannot
see it.

More information about the Haskell-Cafe mailing list