Unit is a type with a single value:
One could write a printer for unit as:
let string_of_unit () = "()"
But then since a value of term unit is necessarily a constant
(), it is possible to simply remove the argument
let string_of_unit = "()"
And it is a general rule with unit: a value of type
unit does not contain any information. So when a function returns
unit, it is telling you that it does not return any meaningful information. In particular, it is a sign that the function is effectful: a pure function that only returns unit could be directly replaced by unit.
For instance, the type of
print_string: string -> unit is literally telling us that
print_string takes a
string as an argument, and then does not return any information to the caller. The implication here is that
print_string is doing an effect with its
string argument, specifically printing it.