module Vector(T:sig val n : int end) : sig
type t = private float array
val create : float -> t
val add : t -> t -> t
end =
struct
type t = float array
let create x = Array.make T.n x
let add x y = Array.init T.n (fun i -> x.(i) +. y.(i))
end
module V3 = Vector(struct let n = 3 end)
module V4 = Vector(struct let n = 4 end)
(* let x : V3.t = [| 1. |] *)
let y = V3.add (V3.create 1.) (V3.create 2.)
let z = V3.add (V3.create 1.) (V4.create 2.)