Reputation: 14660
For a Haskell project I've just started, I have two files Main.hs
and Lib.hs
However, I often find myself reaching for some modules that I've imported inside Lib
while working in Main
.
Is there a way to automatically load in Main.hs
all the modules already imported inside Lib?
Lib.hs
import System.Random
import Data.List
{-
Lib code here
-}
Main.hs
import Lib -- Importing should automatically imports System.Random and Data.List
main = undefined
Upvotes: 4
Views: 1701
Reputation: 64740
Modules can export other modules, including themselves (meaning they export all top level definitions instead of an explicit list of symbols you'd otherwise need to rely on).
module Lib ( module System.Random, module Data.List, module Lib) where
import System.Random
import Data.List
{-
Lib code here
-}
Upvotes: 11