Visibility
Private visibility
A private declaration is visible within the same module and nowhere else.
To mark any declaration as private, put a - in front of the name.
(It is not a part of the name.)
Functions, types, and specs can all be made private.
Even the individual fields of a record can be made private.
By default, the implicit new function for a record is as visible as the least-visible field.
That means that if there is a private field, new defaults to private.
If all fields are at the default visibility, so is new.
It's possible to make new private even when the fields are not:
Internal visibility
The default visibility is called internal.
An internal declaration is visible if imported using a relative import path like ./foo,
but not if imported using a non-relative import path like foo/bar.
(See "config.kid" for how to set up non-relative imports.)
The assumption is that relative imports indicate a closer relationship between modules.
Non-relative imports are intended for libraries, which may want to hide implementation details.
Public visibility
To make a declaration visible to all importers, make it public with +.
Explicit internal visibility
A declaration may be marked explicitly internal using ~.
This is rarely needed, except in these cases:
- When defining a function named
-,~, or+, a visibility mark is mandatory, since otherwise the function name looks like the visibility mark.
So you might declare:~-my-type(amy-type).
This declares a function-with internal (~) visibility. - You may want an internal field on a public record:
Ignoring visibility
If you don't want to deal with visibility,
you can just leave everything at the default internal visibility.
This won't be a problem so long as you import your own code using relative imports.
However, if you are writing a library for use by others, you should mark the public API with +.