[Haskell-cafe] Mutually recursive modules
Roman Cheplyaka
roma at ro-che.info
Wed May 8 08:46:08 CEST 2013
I wonder whether it's always possible to break cycles using GHC's
.hs-boot files.
Consider the following schematic example:
module A where
import B
data A
f :: B -> A
f = undefined B.g
module B where
import A
data B
g :: A -> B
g = undefined A.f
A.hs-boot must give a type signature for f, and since the signature
contains 'B', it must import 'B'. Ditto for B.hs-boot — it must import
'A'.
Even if we treat all imports as {-# SOURCE #-}, there is still a cycle
between the hs-boot files.
So, am I right in understanding that these recursive modules cannot be
compiled by GHC at all?
Roman
More information about the Haskell-Cafe
mailing list