Let's say I have a module like this:
module type MyModule =
sig
type t
func1 : ... -> t
end
(* Implementation *)
module SomeModule : MyModule =
struct
type t = int
let func1 ... : t =
(* do something and return type t *)
end
Now, I called func1 somewhere outside the module and obtained a value with type MyModule.t
:
let x = SomeModule.func1 ... in
print_int x (* Which doesn't works *)
So I'm wondering is there any way to print x? Thanks for answering!
The short answer is "no". You've specifically made the type t
abstract, so there is no way to do anything with values of type t
outside SomeModule
.
There are of course sneaky ways to subvert the type system in OCaml (as in every language), but generally speaking you should avoid them like the plague.