Unsearchable type colon equals?

HI yall,
No idea how to find out more about this, but i have seen in places:
module X: X with type t := int

A normal equal also works but it looks like := exposes more?
Where can I find out about that?


Ahh. looks like it fully replaces the type in the module, and consumes the inner type declaration.

// // externally type t = int
module Int: X with type t := int = {
	type t = int
	let x: t = 1
	let increment: t => t =  x => x + 1


module Int = { 
  let x: int = 1
  let increment: int => int = x + 1

Im wondering how that works when the inner type is consumed?
It seems to me like inner types are the crux of module types.
If these types are consumed by := these then become effectively “Terminal” modules that cannot participate in successive functors?
I have also been using the inner type t to join multiple Functor arguments.

It’s called destructive substitution. That link has an example (in OCaml, but you can get the idea) of when you might want to use it, e.g., to clean up the type signatures of modules resulting from functor application.

Here is another common use for destructive substitution: merging signatures that share a type name.

module type Comparable = {
  type t

  let compare: (t, t) => int

module type Stringable = {
  type t

  let fromString: string => t
  let toString: t => string

module MyThing: {
  type t

  include Comparable with type t := t
  include Stringable with type t := t
} = {
  type t = int

  let compare = (a, b) => failwith("...")
  let fromString = s => failwith("...")
  let toString = t => failwith("...")