sieni has quit [Read error: 110 (Connection timed out)]
smimou has quit ["bli"]
Amorphous has quit [Connection timed out]
jer has joined #ocaml
humasect has quit ["Leaving.."]
Amorphous has joined #ocaml
Revision17 has quit [Remote closed the connection]
Amorphous has quit [Connection timed out]
Poopsmith is now known as KinkyFriedman
Smerdyakov has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
Smerdy has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
pango_ has joined #ocaml
khaladan has quit [Read error: 104 (Connection reset by peer)]
Smerdy is now known as Smerdyakov
pango has quit [Read error: 110 (Connection timed out)]
KinkyFriedman is now known as Poopsmith
Amorphous has joined #ocaml
gim has quit ["zoup"]
Schmurtz has quit ["Dodo !"]
m3ga has quit ["disappearing into the sunset"]
rillig_ has joined #ocaml
naerbnic has quit []
rillig has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
slipstream-- has joined #ocaml
slipstream has quit [Connection timed out]
perspectivet has joined #ocaml
<perspectivet>
hi, I'm new to the channel and new to ocaml, though once a regular use of sml
<perspectivet>
What is the idiomatic way to read a structured multi-type binary file?
<perspectivet>
I've found the extLib IO class to be pretty helpful so far, but reading the binary stream into a hand constructed class seems pretty weak.
<perspectivet>
record initialization oddness doesn't seem to lend itself to an elegant solution either.
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
<flux__>
hmm.. I'm thinking one elegant way would be, for type foo = { a: string; b: int}; to provide something like let foo_structure = [`A, `String (255, encode_string); `B, `Int (4, encode_int)] and then the loading function would look something like let write_foo foo = let buf = Buffer.create () in let s = encode buf foo
<flux__>
oh, that was writing, I wonder if it's more difficult for reading ;)
<flux__>
encode should also refer to foo_structure
<flux__>
sigh, I fixed my code into something that cannot work
<flux__>
let write_foo foo = let buf = Buffer.create () in let s = encode buf foo_structure; s `A foo.a; s `B foo.b was what I was thinking
<flux__>
the reading part is going to be more complex, though
<perspectivet>
I've been reading through the camlp4 tutorial. a syntax extension seem to be the way to go. though it's still not simple.
<flux__>
let read_foo () = let s = decode buffer_in foo_structure in let a = destring (s `A) in let b = destring (s `B) in { a: a; b: b}
<flux__>
yes, syntax extension would give you much cleaner code, and may be wortwhile if you're doing lots of that