Three Recursively defined modules
Chris Kuklewicz
haskell at list.mightyreason.com
Mon Dec 8 14:16:24 EST 2008
Hi,
As "hs-boot" is ghc specific method I am asking on this glasgow-haskell-users
mailing list first.
My hprotoc program converts message definitions into Haskell modules, and
mimicking the expected OOP-like namespaces has been successful so far.
It is possible to define messages and keys that create recursive modules
dependencies, and I have left fixing this to the user. For the examples I have
run across this has been possible to do manually.
But I can easily write a file which generates three recursively defined modules
with keys that I have not been able to fix with hs-boot files.
I have created toy versions of the 3 modules and their "key"s which contain the
problem.
Can anyone see how to use hs-boot files to compile the three modules below?
Note: The 3 modules ought to be the same aside from cyclic [a,b,c] replacement:
> module A(A(..),akeybc,akeycb) where
>
> import B(B)
> import B(bkeyac)
> import C(C)
> import C(ckeyab)
>
> data A = A { name :: String }
>
> akeybc :: Either B (Maybe C)
> akeybc = Right Nothing
>
> akeycb :: Either C (Maybe B)
> akeycb = Right Nothing
>
> instance Show A where
> show a = concat [name a,show bkeyac,show ckeyab]
> module B(B(..),bkeyca,bkeyac) where
>
> import A(A)
> import A(akeybc)
> import C(C)
> import C(ckeyba)
>
> data B = B { name :: String }
>
> bkeyca :: Either C (Maybe A)
> bkeyca = Right Nothing
>
> bkeyac :: Either A (Maybe C)
> bkeyac = Right Nothing
>
> instance Show B where
> show b = concat [name b,show ckeyba,show akeybc]
> module C(C(..),ckeyab,ckeyba) where
>
> import A(A)
> import A(akeycb)
> import B(B)
> import B(bkeyca)
>
> data C = C { name :: String }
>
> ckeyab :: Either A (Maybe B)
> ckeyab = Right Nothing
>
> ckeyba :: Either B (Maybe A)
> ckeyba = Right Nothing
>
> instance Show C where
> show c = concat [name c,show akeycb,show bkeyca]
It would be disappointing if I had to move the "key"s into separate
modules/namespaces to allow for a solution using hs-boot files.
Thanks,
Chris
More information about the Glasgow-haskell-users
mailing list