Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all from ... export all with explicit exports #10369

Merged
merged 112 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
0137a25
Replace all `from ... export all` with explicit exports
Akirathan Jun 25, 2024
d7362f7
Add some missing exports
Akirathan Jun 25, 2024
2bf2f4f
Remove isAll and hiding fields from Export IR
Akirathan Jun 26, 2024
3140aaa
Test compiler errors for missing export fields
Akirathan Jun 26, 2024
4cb2bb1
Add ExportConstructorTest
Akirathan Jun 26, 2024
2844901
Add ExportedSymbolsTest
Akirathan May 30, 2024
15829b5
Add ExportCycleDetectionTest
Akirathan May 30, 2024
2252a6f
Remove ExportCycleDetectionTest
Akirathan Jun 6, 2024
bad6558
Reintroduce ExportCycleDetectionTest
Akirathan Jun 11, 2024
6351bc3
Add test for exported symbols in synthetic modules
Akirathan Jun 11, 2024
4b34b94
Add test for export cycle detection in three modules
Akirathan Jun 11, 2024
0ac44a3
Remove unnecessary imports from tests
Akirathan Jun 11, 2024
6dc51f3
Test export from different module
Akirathan Jun 27, 2024
87dc19d
Implement ProjectUtils.deleteRecursively
Akirathan Jun 27, 2024
5148403
ProjectUtils: Main module does not have to exist when creating a project
Akirathan Jun 4, 2024
e428408
Remove BindingMap.SymbolRestriction
Akirathan Jun 27, 2024
6937908
Force compilation in ExportedSymbolsTest
Akirathan Jun 27, 2024
c9f0a36
Add test for importing a constructor
Akirathan Jun 28, 2024
3a00437
Add test for exporting a constructor
Akirathan Jun 28, 2024
1c8ec12
ResolvedConsytructor is an ImportTarget
Akirathan Jun 28, 2024
7699d17
fmt
Akirathan Jun 28, 2024
3bf93ea
ResolvedMethod is ImportTarget.
Akirathan Jun 28, 2024
21218cb
Fix ExportCycleDetectionTest - reported order of module is non-determ…
Akirathan Jun 28, 2024
c9b881d
Fix ExportStaticMethodTest.
Akirathan Jun 28, 2024
02e2eb1
Enable test for module method resolution
Akirathan Jun 28, 2024
3de9c67
fmt
Akirathan Jun 28, 2024
f457a3e
Importing symbols from methods is not allowed
Akirathan Jun 28, 2024
ba52b80
Export tests use `export ...` syntax instead of `from ... export ...`.
Akirathan Jun 28, 2024
96d60b6
Remove syntax error from test
Akirathan Jun 28, 2024
2526360
Test exports resolution graph building
Akirathan Jun 28, 2024
175f18f
Test exports resolution graph for type
Akirathan Jun 28, 2024
6c1db95
Rename Node.target back to Node.module
Akirathan Jul 1, 2024
b6ed712
Fix tests - Exports graph nodes targets only modules
Akirathan Jul 1, 2024
e0a682e
Move ExportsResolution to separate package
Akirathan Jul 1, 2024
897f4a0
Rename Node.module to Node.target back again
Akirathan Jul 1, 2024
0228f50
ExportedModule contains list of symbols
Akirathan Jul 1, 2024
02481e8
Remove WIP comments from tests
Akirathan Jul 1, 2024
46c678f
ResolvedMethods have self reference in their exported symbols
Akirathan Jul 1, 2024
53a6d31
fmt
Akirathan Jul 1, 2024
5f0fed7
ResolvedType have self reference in their exported symbols
Akirathan Jul 1, 2024
62cbc9c
Remove outdated ignored tests from #6669
Akirathan Jul 1, 2024
3a0a5cc
Handle renamed exports
Akirathan Jul 1, 2024
c0b71a8
Rename and doc update
Akirathan Jul 2, 2024
ef7716b
Replace `from ... export ...` with `export ...` type of export in std…
Akirathan Jul 2, 2024
7ff1bf0
Replace `from ... export ...` with `export ...` type of export in Exp…
Akirathan Jul 2, 2024
7a3670d
Replace `from ... export ...` with `export ...` type of export in Boo…
Akirathan Jul 2, 2024
98302ac
ResolvedImport has multiple import targets
Akirathan Jul 2, 2024
e5a7273
Fix typo in exports in std base Main
Akirathan Jul 2, 2024
a346c29
ResolvedMethod's qualifiedName is consistent with imports
Akirathan Jul 2, 2024
0b37f9f
ImportResolverAlgorithm deals with extension and conversion methods
Akirathan Jul 2, 2024
6e0d992
Add import/export test for extension methods
Akirathan Jul 2, 2024
2cab531
Add tests for exporting and importing conversion methods
Akirathan Jul 3, 2024
3022f6f
Add tests for exporting and importing conversion methods
Akirathan Jul 3, 2024
a491703
Replace `from ... export ...` with `export ...` type in micro-distrib…
Akirathan Jul 3, 2024
9143c29
In micro-distribution, replace some import all by specific imports
Akirathan Jul 3, 2024
b6c0765
Use specific import/exports in tests
Akirathan Jul 3, 2024
2bc9042
Remove tests on export hiding
Akirathan Jul 3, 2024
f3d0afc
Fix Export.showCode method
Akirathan Jul 3, 2024
f454ac9
Remove export all from test
Akirathan Jul 3, 2024
fb93983
Add asert checks for consistent exported symbols
Akirathan Jul 4, 2024
409fb18
Add tests for exported symbols from synthetic modules
Akirathan Jul 4, 2024
0c371d2
ExportsResolution does not re-export symbols from resolved exports
Akirathan Jul 4, 2024
1a8a3ae
Update functions docs
Akirathan Jul 4, 2024
54299f1
Add docs for imports/exports with multiple targets
Akirathan Jul 4, 2024
a65ec1b
Remove resolvedExports field from BindingsMap.
Akirathan Jul 4, 2024
9538ae1
ExportSymbolAnalysis iterates only some exports
Akirathan Jul 4, 2024
c6ddaf5
Fix ExportExtensionMethodTests
Akirathan Jul 4, 2024
3e9cbeb
Fix ExportSymbolAnalysis to correctly resolve module from the export
Akirathan Jul 4, 2024
3f864e4
Small refactoring
Akirathan Jul 4, 2024
0916bde
ExportSymbolAnalysis is not a compiler pass.
Akirathan Jul 5, 2024
03de7c6
fmt
Akirathan Jul 5, 2024
a84c450
Move java source from scala dir
Akirathan Jul 5, 2024
6a4555b
Fix indexing errors in ExportSymbolAnalysis
Akirathan Jul 5, 2024
9ca0c39
Export cycle is not detected for self-exports
Akirathan Jul 5, 2024
717b47c
Refine "Exporting non-existing" symbol tests
Akirathan Jul 5, 2024
db4396e
ExportSymbolAnalysis handles exports with exactly 3 name items specially
Akirathan Jul 5, 2024
d1c9400
ExportsResolution.resolveExportedSymbols drops duplicate symbols
Akirathan Jul 5, 2024
427a70f
Conflicting resolutions are reported as CompilerError.
Akirathan Jul 5, 2024
142f038
Add tests for export resolution module topological sort
Akirathan Jul 5, 2024
118ebb7
fmt
Akirathan Jul 5, 2024
931c440
Constructors can be exported from the same module.
Akirathan Jul 5, 2024
fbb64d2
Add test for "importAllDoesNotImportModuleItself"
Akirathan Jul 8, 2024
57ec17b
Test that import all from type does not import the type itself
Akirathan Jul 8, 2024
da1b75c
Fix resolution export sorting test.
Akirathan Jul 8, 2024
fd23f45
ResolvedType does not list itself in exportedSymbols.
Akirathan Jul 8, 2024
99c8864
Use specific exports in Table/Main.enso
Akirathan Jul 8, 2024
f8895c9
Use specific exports in Database/Main.enso
Akirathan Jul 8, 2024
7d24114
ExportSymbolAnalysis handles submodule export
Akirathan Jul 8, 2024
eae45af
Add ExportModuleTest
Akirathan Jul 8, 2024
45d9c55
fmt
Akirathan Jul 8, 2024
3e0496e
Merge branch 'refs/heads/develop' into wip/akirathan/10258-disallow-e…
Akirathan Jul 8, 2024
b01f526
Use specific exports in more places
Akirathan Jul 8, 2024
d40e0bb
Rename StaticMethod to ExtensionMethod
Akirathan Jul 8, 2024
171ca2e
IrToTruffle consructs ImportExportScope from directly exported modules
Akirathan Jul 8, 2024
a8d8fac
Fix creation of nested submodule in ProjectUtils
Akirathan Jul 9, 2024
99bb586
Update docs of benchmarks - debugging
Akirathan Jul 9, 2024
194a4aa
Workaround for non-inserting synthetic imports in Database.Main
Akirathan Jul 9, 2024
54e8b0a
Test importing a re-exported symbol
Akirathan Jul 10, 2024
2d332ee
#10504: Ignore failing test of importing relative symbols
Akirathan Jul 10, 2024
c8e1b91
Add ExportResolutionOrderingTest
Akirathan Jul 10, 2024
29def8b
#10505: Add comment to test why it is ignored
Akirathan Jul 10, 2024
97670a3
Add helper method to ModuleUtils
Akirathan Jul 10, 2024
5c0c622
Use specific exports in Deep_Export test
Akirathan Jul 10, 2024
bfb6d56
#10504: Ignore Deep_Export test
Akirathan Jul 10, 2024
7654182
Fix ImportAndFQNConsistencyTest - use BindingsMap.exportedSymbols there.
Akirathan Jul 10, 2024
add8c78
fmt
Akirathan Jul 10, 2024
fd4f2ab
Fix error messages in ErrorCompilerTest
Akirathan Jul 10, 2024
9eabbcd
Fix error messages in ErrorCompilerTest
Akirathan Jul 10, 2024
8a7dcc4
Skip ExportSymbol analysis for non-compiled modules
Akirathan Jul 10, 2024
5b1fd5c
Update docs
Akirathan Jul 10, 2024
a4aa2b6
micro-distribution exports Boolean type
Akirathan Jul 11, 2024
4aca14c
Update RuntimeSuggestionUpdatesTest
Akirathan Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import project.Any.Any
import project.Nothing.Nothing

from project.Data.Boolean.Boolean export False, True
export project.Data.Boolean.Boolean.False
export project.Data.Boolean.Boolean.True

## A type with only two possible values.

Expand Down
96 changes: 85 additions & 11 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,88 @@ export project.System.Platform
export project.System.Process
export project.System.Process.Exit_Code.Exit_Code
export project.Warning.Warning
from project.Data.Boolean export Boolean, False, True
from project.Data.Json.Extensions export all
from project.Data.Numbers export Float, Integer, Number
from project.Data.Range.Extensions export all
from project.Data.Statistics.Extensions export all
from project.Data.Text.Extensions export all
from project.Data.Text.Regex export regex
from project.Function export all
from project.Meta.Enso_Project export enso_project
from project.Network.Extensions export all
from project.System.File_Format export Auto_Detect, Bytes, File_Format, Infer, JSON_Format, Plain_Text_Format
export project.Data.Boolean.Boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is from ... export deprecated even when it's not using all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not deprecated, they are just now suffering from #10399. Until that issue is fixed, rule of a thumb is to just use plain export ....

export project.Data.Boolean.Boolean.False
export project.Data.Boolean.Boolean.True
export project.Data.Json.Extensions.to_json
export project.Data.Json.Extensions.to_js_object
export project.Data.Numbers.Float
export project.Data.Numbers.Integer
export project.Data.Numbers.Number
export project.Data.Range.Extensions.up_to
export project.Data.Range.Extensions.down_to
export project.Data.Statistics.Extensions.compute
export project.Data.Statistics.Extensions.compute_bulk
export project.Data.Statistics.Extensions.running
export project.Data.Statistics.Extensions.running_bulk
export project.Data.Statistics.Extensions.rank_data
export project.Data.Text.Extensions.reverse
export project.Data.Text.Extensions.each
export project.Data.Text.Extensions.at
export project.Data.Text.Extensions.get
export project.Data.Text.Extensions.first
export project.Data.Text.Extensions.second
export project.Data.Text.Extensions.last
export project.Data.Text.Extensions.characters
export project.Data.Text.Extensions.find
export project.Data.Text.Extensions.find_all
export project.Data.Text.Extensions.match
export project.Data.Text.Extensions.to_regex
export project.Data.Text.Extensions.split
export project.Data.Text.Extensions.tokenize
export project.Data.Text.Extensions.replace
export project.Data.Text.Extensions.cleanse
export project.Data.Text.Extensions.words
export project.Data.Text.Extensions.lines
export project.Data.Text.Extensions.insert
export project.Data.Text.Extensions.from
export project.Data.Text.Extensions.is_digit
export project.Data.Text.Extensions.is_whitespace
export project.Data.Text.Extensions.bytes
export project.Data.Text.Extensions.from_bytes
export project.Data.Text.Extensions.utf_8
export project.Data.Text.Extensions.from_utf_8
export project.Data.Text.Extensions.char_vector
export project.Data.Text.Extensions.from_char_vector
export project.Data.Text.Extensions.codepoints
export project.Data.Text.Extensions.from_codepoints
export project.Data.Text.Extensions.starts_with
export project.Data.Text.Extensions.ends_with
export project.Data.Text.Extensions.contains
export project.Data.Text.Extensions.repeat
export project.Data.Text.Extensions.take
export project.Data.Text.Extensions.drop
export project.Data.Text.Extensions.to_case
export project.Data.Text.Extensions.pad
export project.Data.Text.Extensions.trim
export project.Data.Text.Extensions.locate
export project.Data.Text.Extensions.locate_all
export project.Data.Text.Extensions.index_of
export project.Data.Text.Extensions.last_index_of
export project.Data.Text.Extensions.parse_float
export project.Data.Text.Extensions.parse_integer
export project.Data.Text.Extensions.parse_json
export project.Data.Text.Extensions.parse_date
export project.Data.Text.Extensions.parse_date_time
export project.Data.Text.Extensions.parse_time_of_day
export project.Data.Text.Extensions.parse_time_zone
export project.Data.Text.Extensions.substring
export project.Data.Text.Extensions.slice_text
export project.Data.Text.Extensions.split_find_delimiters
export project.Data.Text.Regex.regex
export project.Function.Function
export project.Function.identity
export project.Function.flip
export project.Function.const
export project.Function.curry
export project.Function.uncurry
export project.Meta.Enso_Project.enso_project
export project.Network.Extensions.to_uri
export project.Network.Extensions.fetch
export project.Network.Extensions.post
export project.System.File_Format.Auto_Detect
export project.System.File_Format.Bytes
export project.System.File_Format.File_Format
export project.System.File_Format.Infer
export project.System.File_Format.JSON_Format
export project.System.File_Format.Plain_Text_Format
9 changes: 7 additions & 2 deletions distribution/lib/Standard/Database/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export project.Column_Description.Column_Description
import project.Connection
export project.Connection.Client_Certificate.Client_Certificate
export project.Connection.Connection_Options.Connection_Options
export project.Connection.Credentials.Credentials
Expand All @@ -9,5 +10,9 @@ export project.Connection.SQLite_Format.SQLite_Format
export project.Connection.SSL_Mode.SSL_Mode
export project.SQL_Query.SQL_Query
export project.Update_Action.Update_Action
from project.Extensions.Upload_Database_Table export all
from project.Extensions.Upload_In_Memory_Table export all
export project.Extensions.Upload_Database_Table.update_rows
export project.Extensions.Upload_Database_Table.select_into_database_table
export project.Extensions.Upload_Database_Table.delete_rows
export project.Extensions.Upload_In_Memory_Table.update_rows
export project.Extensions.Upload_In_Memory_Table.select_into_database_table
export project.Extensions.Upload_In_Memory_Table.delete_rows
2 changes: 1 addition & 1 deletion distribution/lib/Standard/Geo/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from Standard.Base import all

from Standard.Table import Table

from project.Geo_Json export geo_json_to_table
export project.Geo_Json.geo_json_to_table

## UNSTABLE
ICON location
Expand Down
15 changes: 11 additions & 4 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ export project.Table.Table
export project.Value_Type.Auto
export project.Value_Type.Bits
export project.Value_Type.Value_Type
from project.Constants export all
from project.Expression export expr
from project.Extensions.Column_Vector_Extensions export all
from project.Extensions.Table_Conversions export all
export project.Constants.Previous_Value
export project.Constants.Report_Unmatched
export project.Expression.expr
export project.Extensions.Column_Vector_Extensions.to_column
export project.Extensions.Column_Vector_Extensions.compute
export project.Extensions.Column_Vector_Extensions.compute_bulk
export project.Extensions.Column_Vector_Extensions.running
export project.Extensions.Table_Conversions.to_table
export project.Extensions.Table_Conversions.from_objects
export project.Extensions.Table_Conversions.parse_to_table
export project.Extensions.Table_Conversions.write_table
16 changes: 15 additions & 1 deletion distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,19 @@ export project.Faker.Faker
export project.Problems
export project.Suite.Suite
export project.Test.Test
from project.Extensions export all
export project.Extensions.should_fail_with
export project.Extensions.should_equal
export project.Extensions.should_equal_type
export project.Extensions.should_not_equal
export project.Extensions.should_not_equal_type
export project.Extensions.should_start_with
export project.Extensions.should_end_with
export project.Extensions.should_succeed
export project.Extensions.should_be_a
export project.Extensions.should_be_true
export project.Extensions.should_be_false
export project.Extensions.should_contain_the_same_elements_as
export project.Extensions.should_only_contain_elements_in
export project.Extensions.should_contain
export project.Extensions.should_not_contain

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export project.AI
export project.Helpers
export project.Id.Id
export project.Preprocessor
from project.File_Upload export file_uploading
export project.File_Upload.file_uploading

10 changes: 10 additions & 0 deletions docs/infrastructure/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ to 0, and to run `withDebug` command like this:
withDebug --debugger benchOnly -- <fully qualified benchmark name>
```

Another option that does not require changing the source code is to run
something like

```
sbt:runtime-benchmarks> run -w 1 -i 1 -f 1 -jvmArgs -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000 org.enso.compiler.benchmarks.module.ImportStandardLibrariesBenchmark.importStandardLibraries
```

This command will run the `importStandardLibraries` benchmark in fork waiting
for the debugger to attach.

## Standard library benchmarks

Unlike the Engine micro benchmarks, these benchmarks are written entirely in
Expand Down
18 changes: 13 additions & 5 deletions docs/syntax/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,26 @@ Number.floor self = case self of
...
```

3. **As a Function with an Explicit `self` Argument:** A function defined with
the type of the `self` argument specified to be a type.
3. **As a module method:** A function defined outside the body of a type and
without explicit `self` argument, is considered a _module method_.

```ruby
floor (self : Number) = case self of
Integer -> ...
module_method x y = x + y
```

If the user does not explicitly specify the `this` argument by name when
If the user does not explicitly specify the `self` argument by name when
defining a method (e.g. they use the `Type.name` syntax), it is implicitly added
to the start of the argument list.

Note that the following methods defined in the body of type and as an extension
method are equivalent:

```
type My_Type
method self = 42
My_Type.method self = 42
```

## Calling Functions and Methods

Enso makes the distinction between functions and methods. Methods are entities
Expand Down
129 changes: 103 additions & 26 deletions docs/syntax/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ code from modules.
- [Import Syntax](#import-syntax)
- [Qualified Imports](#qualified-imports)
- [Unqualified Imports](#unqualified-imports)
- [Imports with multiple targets](#imports-with-multiple-targets)
- [Export Syntax](#export-syntax)
- [Qualified Exports](#qualified-exports)
- [Unqualified Exports](#unqualified-exports)
- [Visibility of Export Bindings](#visibility-of-export-bindings)
- [Implicit exports](#implicit-exports)
- [Defined entities in a module](#defined-entities-in-a-module)
- [Synthetic module](#synthetic-module)
- [Exports with multiple targets](#exports-with-multiple-targets)

<!-- /MarkdownTOC -->

## Qualified Names

In the following text, **entity** shall denote a module, a method (instance,
static, foreign), type, or a type constructor. In other words, an _entity_ is
anything that can be assigned to a variable.
static, extension, conversion, foreign), type, or a type constructor. In other
words, an _entity_ is anything that can be assigned to a variable.
Akirathan marked this conversation as resolved.
Show resolved Hide resolved

Both imports and exports require the use of qualified entity names. A qualified
name consists of the library namespace (usually organization under which its
Expand Down Expand Up @@ -95,6 +100,30 @@ Imports in Enso _may_ introduce ambiguous symbols, which is treated as a
compilation error. Ideally, the error should be delayed until one of the
ambiguous symbols is _used_ in Enso code.

## Imports with multiple targets

Import of one symbol can resolve to multiple targets in case of extension or
conversion methods. For example, the following import in `Main.enso`:
`A_Module.enso`:

```
type My_Type
type Other_Type
My_Type.method = 42
Other_Type.method = 42
```

`Main.enso`:

```
import project.A_Module.method
```

imports both `My_Type.method` and `Other_Type.method` methods.

Note that `import project.A_Module.My_Type.method` would lead to a compilation
error, as it is only possible to import constructors from a type, not methods.

## Export Syntax

In order to allow for easy composition and aggregation of code, Enso provides
Expand All @@ -112,31 +141,19 @@ the name provided after the `as` keyword, if provided).

### Unqualified Exports

Unqualified exports are broken up into three main categories:
Unlike imports, exports cannot be used with the `all` and `hiding` keywords. So
the only supported syntax is to export a list of names with _restricted
exports_.
Akirathan marked this conversation as resolved.
Show resolved Hide resolved

1. **Unrestricted Exports:** These export all symbols from the module or type
into the current scope. They consist of the keyword `from`, followed by a
qualified module name, followed by an optional rename part (using the `as`
keyword), then the keywords `export all`. For example:
```
from Standard.Base.Data.List as Builtin_List export all
```
2. **Restricted Exports:** These export a specified set of names, behaving as
though they were redefined in the current scope. They consist of the keyword
`from`, followed by a qualified module or type name (with optional
`as`-rename), then the word `export` followed by a coma-separated list of
names to be exported. For example:
```
from Standard.Base.Data.List export Cons, Nil, from_vector
```
3. **Hiding Exports:** These are the inverse of restricted exports, and export
_all_ symbols other than the named ones. They consist of the `from` keyword,
followed by a qualified module or type name (with optional `as`-rename), then
the words `export all hiding`, followed by a coma-separated list of names to
be excluded from the export. For example:
```
from Standard.Base.Data.List export all hiding from_vector, Nil
```
**Restricted Exports:** These export a specified set of names, behaving as
though they were redefined in the current scope. They consist of the keyword
`from`, followed by a qualified module or type name (with optional `as`-rename),
then the word `export` followed by a coma-separated list of names to be
Akirathan marked this conversation as resolved.
Show resolved Hide resolved
exported. For example:

```
from Standard.Base.Data.List export Cons, Nil, from_vector
```

In essence, an export allows the user to "paste" the contents of the module or
type being exported into the module declaring the export. This means that
Expand All @@ -146,3 +163,63 @@ exports that create name clashes must be resolved at the _export_ site.

Bindings exported from a module `X` are available in an identical fashion to
bindings that are _defined_ in the module `X`.

### Implicit exports

The compiler inserts implicit exports for entities defined in a module and for
submodules of a _synthetic module_. A synthetic module is basically a directory
in the source structure.

#### Defined entities in a module

Entities defined in a module are automatically exported from the module. This
means that the following modules are semantically identical:

```
type My_Type
method x = x
```

```
export project.Module.My_Type
export project.Module.method
Akirathan marked this conversation as resolved.
Show resolved Hide resolved
type My_Type
method x = x
```

#### Synthetic module

Consider a project named `Proj` with the following source structure:

`Proj/src/Synthetic_Mod/Module.enso`:

```
type My_Type
```

`Proj/src/Main.enso`:

```
import project.Synthetic_Mod.Module.My_Type
```

We can import submodules of `Synthetic_Mod`, because the compiler automatically
inserts exports for them. Internally, `Synthetic_Mod` is represented as a module
with single export:

```
export project.Synthetic_Mod.Module
```

## Exports with multiple targets

Export of a single symbol can be resolved to multiple targets (entities) in case
of extension or conversion methods. Similarly to
[imports with multiple targets](#imports-with-multiple-targets), the following
export in `A_Module.enso`:

```
export project.A_Module.export
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should have been:

- export project.A_Module.export
+ export project.A_Module.method

```

exports both `My_Type.method` and `Other_Type.method` methods.
Loading
Loading