
Hello cafe, I have some problem setting up an appropriate .hs-boot module. I attach a .tar.gz'd cabal folder, so you can immediately test it with `cabal new-repl`. I had a file like this -- datatypes data A = A { _i :: Int, _b :: B } type AS a = State A a data B = B (AS ()) makeLenses ''A -- functions f :: B f = B $ i .= 18 So I decided to split it up in 2 files to test hs-boot in the wild: -- A.hs ------- data A = A { _i :: Int, _b :: B } type AS a = State A a makeLenses ''A -- B.hs ------- data B = B (AS ()) f :: B f = B $ i .= 18 Well, I don't know how to write A.hs-boot. I tried this: module A where import Lens.Micro.Platform data A b :: Lens' A B but ghc rightfully complains that he doesn't know about B, and if I slap an `import B` in the .hs-boot then I have another import-cycle. What's the way out of that? The project I am dealing with is bigger than this problem and I would really love to keep functions and related datatypes nearby for mental sanity. As I wrote above, attached you can find a .tar.gz with everything set up to replicate this -F

Hi Francesco,
I have some problem setting up an appropriate .hs-boot module.
I don't know Haskell lenses, I don't know GHC circular module importing, but I know you :-) So I tried this https://github.com/massimo-zaniboni/example-of-circular-module In the first version you have a parameter on type A "A._b :: b", and then B imports A, "specializing" "A._b :: B" In the second version you have B.hs-boot instead of A.hs-boot. They both compile.
The project I am dealing with is bigger than this problem and I would really love to keep functions and related datatypes nearby for mental sanity.
If you add some example of A and B usage, simulating the usage you have in your real project, it will became more clear if one of these two work-around is good-enough. Best regards, Massimo
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Fri, Aug 03, 2018 at 09:46:48AM +0200, Massimo Zaniboni wrote:
I don't know Haskell lenses, I don't know GHC circular module importing, but I know you :-) So I tried this
https://github.com/massimo-zaniboni/example-of-circular-module
Many thanks for the working example, Massimo! Interesting to see how where to break the cycle with .hs-boot is meaningful. They solved the problem, but due to the codebase being large/stinky enough, I decided to go the "unholy evil" path [1]. I promise I'll choose the sensible solution from the start next time -F [1] http://www.ariis.it/static/articles/haskell-circular-imports/page.html
participants (2)
-
Francesco Ariis
-
Massimo Zaniboni