Skip to content

Commit

Permalink
Merge pull request #40 from dhil/master
Browse files Browse the repository at this point in the history
OCaml 4.06.0 compatibility fix
  • Loading branch information
vasilisp committed Dec 19, 2017
2 parents d0c7194 + 407ea05 commit 943612f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lib/deriving_Dump.ml
Expand Up @@ -142,7 +142,7 @@ module Dump_string = Defaults (
for i = 0 to len - 1 do
Bytes.unsafe_set s i (Stream.next stream)
done;
s
Bytes.to_string s
end
)

Expand Down Expand Up @@ -226,8 +226,8 @@ module Dump_alpha(P: sig type a end) = Defaults(struct
let from_stream _ = assert false
end)

module Dump_undumpable (P : sig type a val tname : string end) = Defaults (
struct
module Dump_undumpable (P : sig type a val tname : string end) = Defaults (
struct
type a = P.a
let to_buffer _ _ = failwith ("Dump: attempt to serialise a value of unserialisable type : " ^ P.tname)
let from_stream _ = failwith ("Dump: attempt to deserialise a value of unserialisable type : " ^ P.tname)
Expand All @@ -241,8 +241,8 @@ module Dump_via_marshal (P : sig type a end) = Defaults (
struct
include P
let to_buffer buffer obj = Buffer.add_string buffer (Marshal.to_string obj [Marshal.Closures])
let from_stream stream =
let readn n =
let from_stream stream =
let readn n =
let s = Bytes.create n in
for i = 0 to n - 1 do
Bytes.set s i (Stream.next stream)
Expand All @@ -252,5 +252,5 @@ module Dump_via_marshal (P : sig type a end) = Defaults (
let header = readn Marshal.header_size in
let datasize = Marshal.data_size header 0 in
let datapart = readn datasize in
Marshal.from_string (header ^ datapart) 0
Marshal.from_bytes (Bytes.cat header datapart) 0
end)
9 changes: 5 additions & 4 deletions lib/deriving_interned.ml
Expand Up @@ -14,15 +14,16 @@ type t = int * string
deriving (Show)

let intern s =
try BytesMap.find s !map
let bs = Bytes.of_string s in
try BytesMap.find bs !map
with Not_found ->
let fresh = (!counter, Bytes.of_string s) in begin
map := BytesMap.add s fresh !map;
let fresh = (!counter, s) in begin
map := BytesMap.add bs fresh !map;
incr counter;
fresh
end

let to_string (_,s) = Bytes.to_string s
let to_string (_,s) = s
let name = snd
let compare (l,_) (r,_) = compare l r
let eq (l,_) (r,_) = l = r
2 changes: 1 addition & 1 deletion syntax/common/utils.ml
Expand Up @@ -216,7 +216,7 @@ let random_id length =
for i = 0 to length - 1 do
Bytes.set s i idchars.[Random.int nidchars]
done;
s
Bytes.to_string s

(* The function used in OCaml to convert variant labels to their
integer representations. The formula is given in Jacques
Expand Down

0 comments on commit 943612f

Please sign in to comment.