chegibari has quit [Remote host closed the connection]
impy has quit [Ping timeout: 276 seconds]
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
boscop_ has joined #ocaml
boscop has quit [Ping timeout: 246 seconds]
lamawithonel has quit [Remote host closed the connection]
dgfitch has quit [Ping timeout: 240 seconds]
dgfitch has joined #ocaml
vivanov has joined #ocaml
rixed has quit [Ping timeout: 250 seconds]
rixed has joined #ocaml
vivanov has quit [Ping timeout: 252 seconds]
mjonsson has quit [Read error: Operation timed out]
__marius__ has quit [Remote host closed the connection]
vivanov has joined #ocaml
vivanov has quit [Ping timeout: 260 seconds]
jamii has joined #ocaml
ymasory has quit [Quit: Leaving]
vivanov_ has joined #ocaml
jamii has quit [Read error: Connection reset by peer]
jamii has joined #ocaml
vivanov_ has quit [Ping timeout: 260 seconds]
mcclurmc_ has quit [Ping timeout: 250 seconds]
vivanov has joined #ocaml
mcclurmc_ has joined #ocaml
dgfitch has quit [Ping timeout: 248 seconds]
dgfitch has joined #ocaml
jamii has quit [Read error: Connection reset by peer]
dnolen has quit [Quit: dnolen]
Cyanure has joined #ocaml
jderque has joined #ocaml
jamii has joined #ocaml
joelr has joined #ocaml
<joelr>
good day! how do you enable profiling with oasis?
<joelr>
gildor: ^
ygrek has joined #ocaml
jamii has quit [Ping timeout: 246 seconds]
impy has joined #ocaml
lpereira has joined #ocaml
jamii has joined #ocaml
jamii has quit [Ping timeout: 260 seconds]
jamii has joined #ocaml
jamii has quit [Ping timeout: 246 seconds]
DimitryKakadu has joined #ocaml
Snark has joined #ocaml
joelr_ has joined #ocaml
joelr__ has joined #ocaml
joelr has quit [Ping timeout: 252 seconds]
joelr__ is now known as joelr
joelr_ has quit [Ping timeout: 240 seconds]
oriba has joined #ocaml
jamii has joined #ocaml
edwin has joined #ocaml
jamii has quit [Ping timeout: 240 seconds]
jamii has joined #ocaml
jld has quit [Read error: Operation timed out]
jamii has quit [Ping timeout: 246 seconds]
Tianon has quit [Ping timeout: 260 seconds]
joelr_ has joined #ocaml
joelr has quit [Ping timeout: 260 seconds]
joelr_ is now known as joelr
ztfw has joined #ocaml
vivanov has quit [Ping timeout: 250 seconds]
vivanov_ has joined #ocaml
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
vivanov_ has quit [Ping timeout: 276 seconds]
vivanov_ has joined #ocaml
ikaros has joined #ocaml
joelr has quit [Quit: joelr]
Associat0r has joined #ocaml
Associat0r has quit [Quit: Associat0r]
jderque has quit [Quit: leaving]
boscop_ is now known as boscop
hto_ has joined #ocaml
hto has quit [Ping timeout: 248 seconds]
jld has joined #ocaml
hto_ has quit [Ping timeout: 252 seconds]
vivanov_ has quit [Quit: leaving]
vivanov has joined #ocaml
<iris1>
Dear experts, I have encountered a slightly confusing aspect of ocaml. I don't think I understand how type inference works in the presence of optional arguments. For example, if I define "let foo ?(x=0) g = g x" then ocaml infers the type of x to be int, which causes "foo ~x:[1] List.length" to fail. That seems clearly incorrect (and does not happen if I make x a non-optional argument). I assume the problem is that the type inference depen
<iris1>
the presence of x. If x is not given, then g must have type int -> 'a. If x is given, the correct type for g is 'a -> 'b, if the type of x is 'a. Ocaml picks the former, I want the latter. I've located section 4.1.2 of the manual and the solution to my problem seems to be to provide a type annotation for x. But I don't know how to do that: how do I write the above definition of foo, with the type hints that x is of type 'a and g is of typ
<iris1>
-> 'b? (I've messed around with this a bunch, but my random combinations of ~, =, :, etc did not succeed :-( ) Thank you very much!
jamii has joined #ocaml
<flux>
iris1, you need to think what is the type of 'foo' after that definition. as you may know, ocaml doesn't support overloading. would it be ?x:('a -> b) -> 'a -> 'b? or would it be ?x:(int -> 'a) -> 'a -> int?
<iris1>
I don't think I am trying to overload it. I would like the type of foo to be "?x:'a -> ('a -> 'b) -> 'b".
<zorun>
yeah, but if you specify the default value of x as 0, x is an int
<flux>
well, it would be dealable in that case. but how about let foo ?(x=0) y = x, would it be ?x:'a -> 'b -> 'a as well?
<flux>
I know that you would like that the call-site would either put in the default or not, but it doesn't work that way
<flux>
basically labels are syntactic sugar for positional arguments and optional arguments are syntactic sugar for positional arguments of type option
lopex has joined #ocaml
<flux>
so there would need to exist a function that does not use optional labeled arguments, but instead positional argument of type 'a option
<iris1>
Ah, I get it. That "foo ?(x=0) y = x" is a great example. My approach, if taken to its logical conclusion, would destroy ocaml :-(
<flux>
and this doesn't work in ocaml either: let foo x g = match x with None -> g 1 | Some x -> g x
<iris1>
zorun, flux: Thank you very much for your help!
<flux>
iris1, no problem, happy to help. this is also an instance of a problem I assume many ocaml newcomers have bumped into, including me ;)
lopex has quit [Ping timeout: 260 seconds]
lopex has joined #ocaml
impy has quit [Quit: impy]
jamii has quit [Ping timeout: 252 seconds]
emmanuelux has joined #ocaml
impy has joined #ocaml
jamii has joined #ocaml
joelr has joined #ocaml
<joelr>
any ffi experts online?
jamii has quit [Ping timeout: 252 seconds]
boscop has quit [Ping timeout: 246 seconds]
<adrien>
joelr: ask and wait
<joelr>
hehe
<joelr>
i think i figured it out
<joelr>
adrien: i have a type defined like this
<joelr>
type 'a poll_item = ('a Socket.t * event_mask)
<joelr>
And I'm passing an array of those to the C function. Which crashes when I try to get hold of the tuple elements
<joelr>
There's a bug in Pedro's code that I'm trying to ix
<joelr>
fix
<joelr>
int block = Is_block(current_elem);
<joelr>
This says it's a block
<joelr>
int tag = Tag_val(current_elem);
<joelr>
this crashes
<joelr>
And so do Field(current_elem, 0) and Field(current_elem, 1)
<joelr>
Interestingly enough, the pointers that are being accessed are 8 bytes apart. the tuple elements -are- pointers so 8 bytes long on my 64-bit machine
<joelr>
Wosize_val(pollitem_array); also works and gives me 1, exactly the # of items i'm trying to pass
<joelr>
in the array
jamii has joined #ocaml
boscop has joined #ocaml
<ygrek>
for(i = 0; i < n; i++) {
<ygrek>
current_elem = Field(pollitem_array, n);
<ygrek>
yeah, cool
<joelr>
ygrek: what?
<ygrek>
out of bounds
hto has joined #ocaml
<joelr>
ygrek: how so?
<joelr>
I'm passing 1 or 2 elements (n = 1, n = 2) and crashing on i = 0
<joelr>
oooo
<ygrek>
yeaaa
<joelr>
man, you are a genius! :D
<ygrek>
just fresh look
<joelr>
ygrek: do you subscribe to caml-list?
<joelr>
do you by chance have a solution to me "row type" question?
<ygrek>
can't find it
<ygrek>
what date
<ygrek>
?
<joelr>
just posted
<joelr>
thanks for the profiling tip, btw
vivanov_ has joined #ocaml
vivanov has quit [Ping timeout: 264 seconds]
<joelr>
ygrek: doesn't look like the message made it to subscribers yet
bzzbzz has joined #ocaml
<thelema>
joelr: regarding your wish for a polymorphic array, I don't think you can have one of those.
<joelr>
thelema: damn. did you get the email?
<thelema>
if you get an element from a ['a foo array], the result is of type ['a foo], which doesn't make sense
jamii has quit [Ping timeout: 252 seconds]
<thelema>
yes, I got your caml-list post
<joelr>
thelema: do you get the spirit of what i'm trying to do, though? there are different socket types in zeromq and i would like poll to monitor a few sockets
<joelr>
i don't care if this requires changing the socket type, actually
<joelr>
i just want to implement poll
<thelema>
use a variant type to hold each of the types
<thelema>
type foo = Pub of pub Socket.t | Pull of pull Socket.t | ...
<joelr>
thelema: that makes total sense
<joelr>
thelema: do i use phantom types then to make sure you can only pass a Pub socket to a "pub" function?
lopex has quit [Ping timeout: 276 seconds]
<joelr>
thelema: if you look at the top of ZMQ.ml, I think the idea was to make sure that types match in external create : context -> 'a kind -> 'a t = "caml_zmq_socket"
<joelr>
external create : context -> 'a kind -> 'a t = "caml_zmq_socket"
<joelr>
that's the only thing i can think of
<joelr>
I guess that restriction needs to be relaxed
__marius__ has joined #ocaml
<thelema>
joelr: if they're really phantom types, then underlying the real types are the same, and you can put these values all into an array, but you'll lose the phantom types
lopex has joined #ocaml
<joelr>
thelema: hmm
<joelr>
thelema: I really don't understand why pedro chose to type Socket this way :-(
<joelr>
unrelated question... do i need to do something special to get time values in my profile?
<joelr>
I compile with ocamlopt -p but when i run gprof the time values in the output are 0. i just get call counts
<joelr>
ygrek: ^
<ygrek>
joelr, I guess this is bug/feature of macos
<joelr>
ygrek: what makes you guess so? i vaguely recall something about this but can't pinpoint it :(
<joelr>
hmm... i distinctly remember facing this issue when profiling firefox startup on the mac... i even wrote about it...
<joelr>
ygrek: thanks for reminding me!
<ygrek>
joelr, some memories, can't find the link now
yezariaely has joined #ocaml
ymasory has joined #ocaml
joelr_ has joined #ocaml
joelr has quit [Ping timeout: 260 seconds]
joelr_ is now known as joelr
dnolen has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
vivanov_ has quit [Ping timeout: 250 seconds]
Tobu has joined #ocaml
Tobu has quit [Changing host]
Tobu has joined #ocaml
emmanuelux has quit [Ping timeout: 248 seconds]
<joelr>
is there a way to tell ocaml that the line ending is \r\n?
<joelr>
alternatively, is there a way to shorten the length of the string by 1 to skip the \r at the end?
<joelr>
without copying the string of course
<flux>
no to the second one. length of string cannot be changed.
Tobu has quit [Remote host closed the connection]
Tobu has joined #ocaml
vivanov has joined #ocaml
<adrien>
joelr: \r\n, in which context?
<joelr>
input_line
<adrien>
on windows?
<joelr>
yeah, i'm subbing
<joelr>
no, unix
<joelr>
String.sub 0 (len - 1)
<joelr>
:-(
<adrien>
ah, don't think so, you can go directly with the unix module and file_descr too
<adrien>
joelr: what do you do with the string after that?
<joelr>
adrien: not sure that would be an advantage, though
<joelr>
i pass it around
<joelr>
this is the redis protocol, everything ends with \r\n
<adrien>
if you send it to a buffer, you have Buffer.add_substring, you also have the blit operations that can help
<flux>
I've always (unfortunately) implemented my own buffering, when dealing with protocols
<joelr>
would have been much easier if they just said \n or \r\n on windows :-(
<joelr>
right, thanks
<joelr>
flux: is there an advantage?
<flux>
well, when I need to deal with protocols I also need to handle non-blocking
<flux>
and if you use Unix.select, buffered objects won't do
<flux>
which may or may not be suitable for you. it handles '\r' (by ignoring it)
<flux>
actually it just uses String.sub in that case I notice :)
<flux>
but I guess it could handle it more efficiently as well
Tobu has joined #ocaml
<joelr>
Is it better to always call Buffer.reset compared to Buffer.clear?
<joelr>
flux: ^
vivanov has quit [Quit: Lost terminal]
<adrien>
I checked the doc today and I think that clear makes the buffer size equal to 0 while clear will make it to the size you have created the buffer
<adrien>
with corrected grammar
<joelr>
i see
<joelr>
i think reset will reallocate the string
<joelr>
while clear will keep it the same size
<joelr>
clear = keep buffer size as far as it expanded, reset marker to 0
<joelr>
reset = realloc string to initial size, reset marker to 0
<flux>
oh, it would be beneficial in that case to use .clear
<adrien>
that sounds a valid interpretation too
Tobu has quit [Ping timeout: 260 seconds]
* adrien
reboots to unbreak his boot scripts
jderque has joined #ocaml
ymasory has quit [Quit: Leaving]
ymasory has joined #ocaml
Modius has joined #ocaml
Smerdyakov has joined #ocaml
Associat0r has joined #ocaml
sepp2k has joined #ocaml
__marius__ has quit [Remote host closed the connection]
__marius__ has joined #ocaml
__marius__ has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 246 seconds]
vivanov has joined #ocaml
Associat0r has quit [Quit: Associat0r]
ygrek has joined #ocaml
yezariaely has quit [Quit: Leaving.]
mcclurmc_ has quit [Ping timeout: 246 seconds]
edwin has quit [Remote host closed the connection]
mcclurmc_ has joined #ocaml
Tobu has joined #ocaml
Tobu has quit [Read error: Connection reset by peer]
mjonsson has joined #ocaml
sepp2k has quit [Quit: Leaving.]
Tobu has joined #ocaml
edwin has joined #ocaml
ymasory has quit [Quit: Leaving]
Snark has quit [Quit: Ex-Chat]
yezariaely has joined #ocaml
joelr_ has joined #ocaml
joelr__ has joined #ocaml
jderque has quit [Quit: leaving]
joelr has quit [Ping timeout: 258 seconds]
joelr__ is now known as joelr
yezariaely has left #ocaml []
joelr_ has quit [Ping timeout: 276 seconds]
impy has quit [Ping timeout: 246 seconds]
impy has joined #ocaml
__marius__ has joined #ocaml
Smerdyakov has quit [Quit: Leaving]
__marius__ has quit [Remote host closed the connection]
emmanuelux has joined #ocaml
DimitryKakadu has quit [Read error: Connection reset by peer]
ztfw has quit [Remote host closed the connection]
boscop has quit [Ping timeout: 246 seconds]
boscop has joined #ocaml
vivanov has quit [Quit: Lost terminal]
spicey has quit [Remote host closed the connection]
oriba_ has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
ygrek has joined #ocaml
oriba has quit [Ping timeout: 240 seconds]
ulfdoz has quit [Quit: deprecated]
ulfdoz has joined #ocaml
lpereira has quit [Quit: Leaving.]
ulfdoz has quit [Read error: Connection reset by peer]
ulfdoz has joined #ocaml
Cyanure has quit [Ping timeout: 248 seconds]
edwin has quit [Remote host closed the connection]
ymasory has joined #ocaml
Modius_ has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
Modius has quit [Ping timeout: 260 seconds]
Modius_ has quit [Quit: "Object-oriented design" is an oxymoron]
Modius has joined #ocaml
<adrien>
what are the browser-based interpretors available? there's ocamljava, what are the other ones?