Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell exporting large number of functions

I am writing a module which has rather large number of functions that need to be exported. Also this module has a large number of data constructions.

Suppose my module contains the following:

module MyUtils (A(..), B(..),C(..),D(..),f1,f2,f3,f4,f5,f6) where
--Data constructors
data A = ...
data B = ...
data C = ...
data D = ...
--functions
f1 :: A -> B
f2 :: A -> B -> C
f3 :: A -> B -> D
f4 :: A -> B -> A
f5 :: A -> B -> B
f6 :: A -> B

I saw the Data.Map source here It shows it is exporting a large number of functions in a very big list.

But If I want to export everything, can it be done with a yet shortcut method, something like,

module MyUtils (..) where

?

like image 821
Tem Pora Avatar asked Jul 07 '13 16:07

Tem Pora


2 Answers

You can also also do it the following way:

module MyUtiles (module MyUtiles) where

It is sometimes desirable (or required) to use an export list. For example if you want to export everything in the current module and re-export bindings from another module.

like image 98
hzp Avatar answered Oct 07 '22 03:10

hzp


Yes, just leave out the (..) entirely. By default, all names are exported.

module MyUtiles where
...

If there are a large number of functions you want to export alongside a small number of functions you want to hide, it's best to put the hidden ones in another module and import it.

like image 26
J. Abrahamson Avatar answered Oct 07 '22 03:10

J. Abrahamson