Created
February 19, 2022 15:29
-
-
Save EduardoRFS/a451c737eda3aa186db981a5ac9e35cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fixed_array (P : sig | |
val length : int | |
end) : sig | |
type 'a t | |
val length : 'a t -> int | |
val make : 'a -> 'a t | |
val get : 'a t -> int -> 'a | |
val set : 'a t -> int -> 'a -> unit | |
end = struct | |
type 'a t = 'a array | |
let length _ = P.length | |
let make x = Array.make P.length x | |
let get = Array.get | |
let set = Array.set | |
end | |
module Array_2 = Fixed_array (struct | |
let length = 2 | |
end) | |
module Array_3 = Fixed_array (struct | |
let length = 3 | |
end) | |
let f (arr : int Array_3.t) = Array_3.set arr 2 3 | |
let arr = Array_2.make 0 | |
let () = f arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment