1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
(** Examples of different features of Expansion *)
(** For details on what each of the following examples is showing,
see the explanations in the {{!page-features}Features page} *)
module Simple : sig
(** Demonstrates simple expansion with a type equality *)
module StringSet : Stdlib.Set.S with type t = string
end
module Aliases : sig
(** Demonstrates expansion when a module is an alias to a hidden module. *)
module Hidden__module : sig
type t
val f : t -> t
end
module Alias = Hidden__module
end
module ModuleTypeAliases : sig
(** Demonstrates that module types are not expanded if they're a simple path to another. *)
module type A = sig
type t
end
module type B = A
end
module ModuleTypeAliases2 : sig
(** Demonstrates that module types 'aliases' are produced by strengthening *)
module A : sig
module type A = sig
type t
end
module X : A
end
module B : module type of struct
include A
end
end
module Functors : sig
(** Demonstrates the expansion of functors *)
module type Argument = sig
type a
(** This type [a] is declared in the Argument module type *)
end
module type Result = sig
type r
(** This type [r] is declared in the Result module type *)
end
module Functor : functor (X : Argument) (Y : Argument) -> Result
end
module Include : sig
(** Demonstrates handling of include statements *)
module type ToBeIncluded = sig
type t
val f : t -> t
(** The description of [f] *)
end
module A : sig
include ToBeIncluded
val g : t -> t
end
module B : sig
include ToBeIncluded
(** @inline *)
val g : t -> t
end
end
module Shadowing : sig
(** Demonstrates shadowing of identifiers in includes *)
module type A = sig
type t = int
val f : t
end
module type B = sig
include A
type t = string
val g : t
end
end
module DeepEquality : sig
(** Demonstrates expansion involving an equation on a type in a submodule *)
module type SIG = sig
type t
end
module type MODTYPE = sig
module X : SIG
module Y : SIG
end
type foo
module M : MODTYPE with type X.t = foo
end
module DeepEquality2 : sig
(** Demonstrates expansion involving an equation on a type in a submodule, but the submodule is already a simple signature *)
module type MODTYPE = sig
module X : sig
type t
end
module Y : sig
type t
end
end
type foo
module M : MODTYPE with type X.t = foo
end
module TypeSubstitution : sig
(** Demonstrates expansion involving deep destructive type substitution. *)
module type S = sig
module M : sig
type t
end
type t = M.t
end
module type T = S with type M.t := int
end
module ModuleTypeOf : sig
(** Demonstrates expanding after recovering the type of a module *)
module A : sig
type t
(** This comment for [type t] is written in module [A] *)
end
module M : module type of A
module M' : module type of struct
include A
end
end
module ModuleTypeOfComplications : sig
(** Demonstrates the interaction of [module type of] and destructive module substitution *)
module type S = sig
module X : sig
type t
end
module type Y = module type of X
module type Z = module type of struct
include X
end
end
module X1 : sig
type t
type u
end
module type T = S with module X := X1
end
|