Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module, that exports another ones

Is there a way to create a module that will export other modules?

For example, I have a list of modules: A, B, C. And I want them to be imported to module D.

So, I have to write:

import A
import B
import C

It works. But may be not very convenient sometimes.

Is there a way to create a Collection module that exports the content of A, B and C?

With this feature, instead of previous instructions, I'd only have to write:

import Collection -- Importing A, B, C.
like image 397
Anon Imous Avatar asked Jan 03 '14 10:01

Anon Imous


People also ask

Can a module have more than one export?

Every module can have two different types of export, named export and default export. You can have multiple named exports per module but only one default export. Each type corresponds to one of the above syntax.

What are module exports?

Module exports are the instructions that tell Node. js which bits of code (functions, objects, strings, etc.) to export from a given file so that other files are allowed to access the exported code.

What can you export with module exports?

By module. exports, we can export functions, objects, and their references from one file and can use them in other files by importing them by require() method.

Is module exports the same as export?

When we want to export a single class/variable/function from one module to another module, we use the module. exports way. When we want to export multiple variables/functions from one module to another, we use exports way.


1 Answers

Yes, but you need to use an explicit export list, specifying all functions, types, classes and modules to export from this module.

module Foo (module A, module B, myid) where

import A
import B

myid :: a -> a  -- For example
like image 116
Tom Savage Avatar answered Oct 10 '22 02:10

Tom Savage