smilingbuddha
smilingbuddha

Reputation: 14660

Import modules in Haskell

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

Answers (1)

Thomas M. DuBuisson
Thomas M. DuBuisson

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

Related Questions