Sorry this is a dumb question, but I cannot figure out how to put multiple modules in the same file. Suppose the file is named A.hs. If I put module B first, i.e.
module B where ...
module A where ...
it complains that it expected A when I run "ghci A" (It's not top-level, so I don't want to call "ghci A.hs"). The other way around, and it complains "parse error on input module").
There's a related bug here, http://hackage.haskell.org/trac/ghc/ticket/2428 . Is there actually no way to get this, even if the other module is only used locally?
You cannot have multiple modules in the same file. The bug you linked to is just about the error message given by GHC not being clear about this.
However, if you're using Cabal, you can still control the visibility of modules by putting the modules you want visible to users in the Exposed-Modules
section, and putting any internal modules in Other-Modules
.
I found the following bug report.
Which refers to this mailing list item, which states:
No, that's not possible because haskell will use the module name A.B.C to look the module up in path A/B/C.[l]hs.
So using modules
module A where
..
module B where
the compiler could only find one of them. (naming the file A.hs or B.hs)
You have to use one file for each module
So, I guess the answer is no.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With