[Haskell-cafe] Re: some ideas for Haskell', from Python
ChrisK
haskell at list.mightyreason.com
Mon Jan 19 14:00:52 EST 2009
Manlio Perillo wrote:
> Brandon S. Allbery KF8NH ha scritto:
> >
>> ...in theory. In practice GHC needs help with circular imports, and
>> some cycles might be impossible to resolve.
>>
>
> This is interesting.
> Where can I find some examples?
>
> Is this explained in the Real World Haskell book?
>
I have no idea about RWH, but there are certainly mutual import cycles that
cannot be resolved by using hs-boot files with GHC.
Consider three modules A and B and C, which are A-B-C permutations of
> module A(A,AKBC, AKCB)
> import B(B,BKAC)
> import C(C,CKAB)
>
> data A
> AKBC :: Either B C
> AKCB :: Either C B
>
> instance Show (A,BKAC,CKAB) where ...
There is no way to break the ?K?? import cycle with just hs-boot files. I had
to solve this by generating "helper" modules.
Call the "data A" the rank-1 declarations. Then the ?K?? are built on rank-1
types such as "B" and "C" and are rank-2 declarations. The rank-1 declarations
can all be put in hs-boot files but the rank-2 declaration import cycle cannot
be broken with the same hs-boot files. Some of these need to be put in separate
modules.
It may be possible to make a useful definition of rank-3 and higher declarations.
--
Chris
More information about the Haskell-Cafe
mailing list