[Haskell-cafe] circular imports

Daniel Peebles pumpkingod at gmail.com
Tue Sep 7 01:06:09 EDT 2010

I was under the impression that the main reason GHC requires .hs-boot files
is that nobody has had the time or inclination to make it resolve circular
dependencies automatically, and not an intentional design decision to
encourage "good design".

On Tue, Sep 7, 2010 at 6:51 AM, Mathew de Detrich <deteego at gmail.com> wrote:

> I had the same issue zonks ago, and I resorted to using the hs-boot file
> method as well (which worked fine)
> Which I guess brings me to my second point, is this something that GHC
> should do automatically when it sees circular dependencies? When I asked
> about it earlier on #haskell, I was told that its better that way because it
> discourages making bad design through circular dependencies (yet in my case
> and I assume the other cases as well, not using the hs-boot method would
> have made the design much worse). Are there any cases in particular where
> people would be encouraged to make interface design with
> circular dependencies (and that design be deemed as horrible) as opposed to
> what seems to be more realistic case where circular dependencies rarely crop
> up, and when they do they actually make the design better?
> On Tue, Sep 7, 2010 at 1:48 PM, Ivan Lazar Miljenovic <
> ivan.miljenovic at gmail.com> wrote:
>> On 7 September 2010 03:44, Edward Z. Yang <ezyang at mit.edu> wrote:
>> > Excerpts from Evan Laforge's message of Mon Sep 06 13:30:43 -0400 2010:
>> >> I feel like the circular imports problem is worse in haskell than
>> >> other languages.  Maybe because there is a tendency to centralize all
>> >> state, since you need to define it along with your state monad.  But
>> >> the state monad module must be one of the lower level ones, since all
>> >> modules that use it must import it.  However, the tendency for bits of
>> >> typed data to migrate into the state means it's easy for it to
>> >> eventually want to import one of its importers.  And the state monad
>> >> module gets larger and larger (the largest modules in my system are
>> >> those that define state monads: 1186 lines, 706 lines, 1156
>> >> lines---the rest tend to be 100--300 lines).
>> >
>> > I have used hs-boot files to this effect.  I separated data and
>> functionality,
>> > and typeclasses, which must be in the same module as data or are
>> considered
>> > orphaned, get definitions via a circular import.
>> I'm just getting to the point where I have a similar problem.  I was
>> thinking about splitting instances off from the classes (and telling
>> GHC to not worry about orphaned instances for the instance-only
>> modules) but then realised that some instance declarations would be
>> circular as well, so I have to either use hs-boot files, define
>> everything in one big module and then re-export them in ways that make
>> sense or define all instances in one big module (at least for those
>> types which have circular deps among instances) and re-export
>> accordingly.
>> --
>> Ivan Lazar Miljenovic
>> Ivan.Miljenovic at gmail.com
>> IvanMiljenovic.wordpress.com
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100906/fea03a8e/attachment.html

More information about the Haskell-Cafe mailing list