It seems isn’t a question but I just cannot figure out. As the example below, how to refer to type ‘t’ which is defined before the module scope. many thanks
type t = {count:int; value:float} module Temp = struct type t = {record: t above; ...} end
Use the nonrec keyword: OCaml - The OCaml language
nonrec
Alternatively, you can also use a more general approach, a type alias:
type t = {count:int; value:float} module Temp = struct type t_above = t type t = {record: t_above; …} end
Btw, your code formatting didn’t work, you would need to use triple-backticks to make it work.
type alias seems more intuitive and both works. thx: )