package MlFront_Core

  1. Overview
  2. Docs

Module MlFront_Core.UnitIdSource

Unit ids are modules that can appear in the filesystem, whether or not a developer wrote the module or MlFront generated the module or the module has been bundled with many others into a library archive. All modules ids and all package ids are unit ids.

A UnitId is the information available purely from the file path in the file system. As a special case, a module bundled into a library archive is a file path with a segment; for example: "share/DkSDKCoder_Us/DkDriver/dkproject.jsonc#DkDriver_ExecO__".

Some modules, like implicit and optimistic modules, can't be identified purely from the file system. Use a ModuleId.t if the module identity is fully known or a PackageId.t if the package identity is fully known.

See PackageId for a Venn Diagram.

Sourcetype t = [
  1. | `PackageId of PackageId.t
  2. | `SpecialModuleId of SpecialModuleId.t
]

The type of unit identifiers.

Sourceval pp : Format.formatter -> t -> unit
Sourceval compare : t -> t -> int
Sourceval hash : t -> int
Sourceval of_library_id : LibraryId.t -> t

of_library_id library_id is the unit representing the library library_id.

Sourceval parse_peer : t -> string -> (t, [ `Msg of string ]) result

parse_peer unit_id s parses the string s and returns the standard unit id that is a sibling of the unit unit_id.

For example, if unit_id = "DkHello_Std.A.B" and s = "C.D" then the standard peer would be unit_id = "DkHello_Std.A.C.D".

The conventional use is to fully qualify missing modules that are referenced in unit_id.

There is no peer for a library (ex. unit_id = "DkHello_Std"); an error will be returned if unit_id is a library.

Sourceval parse_reversibly : ?sep:string -> string -> (t, [ `Msg of string ]) result

parse_reversibly ?sep s should be able to invert any path on the filesystem that conforms to MlFront conventions. So any open__ or Open__ will translate to the special libopen module, etc.

By default the separator sep is "__".

Known Issues:

1. The string "MlStd_StdO__" will be translated to the special module Open__ for the library "MlStd_Std" incorrectly. The string "MlStd_StdO____Open__" is translated correctly as the special module. You should use LibraryId.parse_special before using this function.

Accessors

Sourceval is_library_id : t -> bool

is_library_id unit_id is true if and only if the unit is a library.

Sourceval owner_library_id : t -> LibraryId.t

owner_library_id unit_id is the library that owns the unit unit_id.

If the unit unit_id is a library, then owner library is the library itself.

Sourceval effective_package_id : t -> PackageId.t option

effective_package_id unit_id is the package id when the unit unit_id is a `PackageId or the proxy package id when the unit is a `SpecialModuleId with the proxy module type SpecialModuleId.typ.ProxyModule.

Only the special library modules SpecialModuleId.typ.SignatureModule and SpecialModuleId.typ.LibOpenModule have no effective package id; those will return None.

Sourceval effective_standard_module_id : t -> StandardModuleId.t option

effective_standard_module_id unit_id is the standard module id when the unit unit_id is a standard module `PackageId or the proxy id when the unit is a `SpecialModuleId with the proxy module type SpecialModuleId.typ.ProxyModule.