package provider

  1. Overview
  2. Docs
type ('t, 'module_type, 'tag) t = ..

Think of a trait as a way to identify and implement the signature of a module that contains enough functions to support some functionality. The type t allows to identify a trait within the provider system. The name was inspired from the Rust programming language construct of the same name.

  • 't is the internal state of the provider itself.
  • 'module_type is the signature of a module implementing the trait.
  • 'tag is the tag (or tags) indicating the supported trait. It's a phantom type designed to make Interface.lookup more type-safe. This relates to Trait bounds in Rust.

'module_type is expected to be a module type (Eio supports single functions but this is discouraged through the use of this library).

Dump & debug

module Info : sig ... end
val info : (_, _, _) t -> Info.t

Indexation

module Uid : sig ... end
val uid : (_, _, _) t -> Uid.t
val same : (_, _, _) t -> (_, _, _) t -> Base.bool
module Implementation : sig ... end

Representing an implementation for a trait.

val implement : ('t, 'module_type, _) t -> impl:'module_type -> 't Implementation.t

implement trait ~impl:(module Impl) says to implement trait with Impl. The module Impl provided must have the right module type as specified by the type of trait.

The tags associated with the trait are ignored at this stage. The handling of the tags happens at the interface building stage, not at the granularity of each trait. This means that the implement function focuses solely on creating the implementation, without considering the tags that indicate which traits are supported by the provider.