Is there an OCaml equivalent of the [<RequireQualifiedAccess>] attribute for DUs in F#? -
in f# programs prefer use
[<requirequalifiedaccess>] type mytype = | firstoption of string | secondoption of int
so in code uses mytype
forced write mytype.firstoption
instead of firstoption
. there way force in ocaml?
you can similar effect defining type in module.
$ ocaml ocaml version 4.02.1 # module mytype = struct type t = firstoption of string | secondoption of int end ;; module mytype : sig type t = firstoption of string | secondoption of int end # mytype.firstoption "abc";; - : mytype.t = mytype.firstoption "abc" # firstoption "abc";; error: unbound constructor firstoption #
if way, name of type (as can see) mytype.t.
Comments
Post a Comment