Reputation: 2721
I'm embarrassed with a library problem with Haskell. I finished a library made of several files
src/MyLib/Firstbib.hs
src/MyLib/Secondbib.hs
...
src/MyLib/Lastbib.hs
At this time, After cabal install
I can import each file separatly with
import MyLib.Firstbib
import MyLib.Secondbib
import MyLib.Lastbib
every thing is OK
Now, I would like to import all these part of MyLib in a simple import :
import MyLib
and I can't reach to make it.
I tried to create a file named src/MyLib.hs
containing :
module MyLib where
import MyLib.Types
import MyLib.Functions
import MyLib.Algo.Line
import MyLib.Algo.Point
and expose it with Cabal
Library
-- Modules exported by the library.
Hs-Source-Dirs: src
Exposed-modules: MyLib
, MyLib.Functions
, MyLib.Types
, MyLib.Algo.Line
, MyLib.Algo.Point
but it doesn't work.!
What it the correct way to import many files with only one module import (as for Gtk2Hs for example)?
Upvotes: 2
Views: 147
Reputation: 21286
This is how MyLib
should look like -- maybe with different indentation:
module MyLib
(module MyLib.Types
,module MyLib.Functions
,module MyLib.Algo.Line
,module MyLib.Algo.Point
) where
import MyLib.Types
import MyLib.Functions
import MyLib.Algo.Line
import MyLib.Algo.Point
What happens is that when you put a module like that in your export list, you export all the symbols that your module knows about it.
You could potentially scope what part of this module you export, for example:
module ExampleLib
(module Data.Maybe
) where
import Data.Maybe (fromJust)
The above will just re-export fromJust
from Data.Maybe
, not the whole Data.Maybe
module.
Upvotes: 6