For the following code, when I tried to compile I get this error but I don’t know why:
----- error message -----
File “test.ml”, line 20, characters 2-8:
20 | module P = Csv(ShowInt)
^^^^^^
Error: Syntax error
----- end of error message -----
----- Code (test.ml) -------
module type SHOW = sig
type t
val show : t -> string
end
module ShowInt = struct
type t = int
let show = string_of_int
end
module Csv(S:SHOW) = struct
let rec to_csv : S.t list -> string =
function
| [] -> “”
| [x] -> S.show x
| h::t -> S.show h ^ “,” ^ to_csv t
end
let () =
module P = Csv(ShowInt)
P.to_csv [1;2;3]