According to Real World OCaml, the type of "abc"
should be string
. But actually in my utop
REPL, it's of type bytes
.
I've already opened Core.Std
. Why is that?
(The version of OCaml
is 4.02.2
; Core
is 112.24.01
; utop
is 1.18
.)
You must enable safe string mode explicitly. Just start utop with:
$ utop -safe-string
Before the introduction of type bytes
in OCaml 4.02, strings were mutable. Now, strings are intended to be immutable, and bytes
is the type to be used for "mutable strings".
In order not to break too much existing code, this distinction is not yet enabled by default. In default mode, bytes
and string
are synonymous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With