Utop hides type

Hello everybody!
I have test.ml with the following code (not sealed to any interface):

let char () = Char.chr 65
let uchar () = Uchar.of_char @@ char ()

For this module utop shows type a instead of Uchar.t:

# #show_module Test;;
module Test_unsealed : sig 
  val char : unit -> char 
  val uchar : unit -> a 
end

And yet I can see type with #typeof directive and use output of uchar () as input to Uchar's functions:

# #typeof "Test.uchar";;
val ( Test.uchar ) : unit -> Uchar.t

# Test.uchar ();;
- : a = <abstr>

# Uchar.to_int @@ Test.uchar ();;
- : int = 65

Could anybody please explain me why this happens and how to solve it if possible?

You should try with a fresh utop session. You have probably defined

type a = Uchar.t

somewhere and since utop uses -short-paths by default, it picks the name a as the best local name for Uchar.t.

1 Like

No, that was a fresh session ran from dune (via dune utop), but I think your answer explains this behavior. I just tried to load module directly into dune-less utop through #use directive and Uchar.t type is visible. Thanks :slightly_smiling_face:

EDIT: You were right, I actually found a place in the project where redefinition was done.