<Guest24313>
When I create a thread with Lwt.wait, I get a thread of 'a Lwt.t. which say is named sleeper. Now in the function that I created this, say I Want to give back a hashtbl.t lwt.t, how can I give back that hashtbl and the sleeper? I want to give back sleeper since I created this for a Lwt_timeout
Guest92020 has quit [Ping timeout: 256 seconds]
<Guest24313>
the type definitions seems odd because the Lwt.wakeup take a Lwt.u and a 'a which I then can pick whatever, so I guess I also want to know how I can set the 'a of the corresponding Lwt.t created by Lwt.wait
damason has quit [Remote host closed the connection]
damason has joined #ocaml
johnelse has joined #ocaml
johnelse is now known as Guest78389
Sorella has quit [Quit: Connection closed for inactivity]
Bahman has joined #ocaml
<struk|desk>
Guest24313: still there? what do you mean by set the 'a? You can pass any type as a second argument, when that happens, 'a is then fixed to that type, but not before then
<Guest24313>
if you do let (sleeper, wakeup) = Lwt.wait (), then you can do Lwt.wakeup wakeup (), and () becomes the 'a for the wakeup in the initial pair. I'm asking how I can set the 'a of the sleeper thread.
<struk|desk>
Guest24313: you set the alpha when it wakes up. that is the semantic. Do "Lwt.wakeup wakeup my_hashtbl" Then "Lwt.state sleeper" will contain it
<struk|desk>
having said that, I don't use lwt extensively
<Guest24313>
I see, so to set the 'a of sleeper I have to go through the wakeup
<struk|desk>
Guest24313: awesome, glad to help, Mr 24313, or should I call you Guest?
<Guest24313>
ah, you can call be Algebr. erc is messing up and I'm being lazy
pierpa has quit [Ping timeout: 260 seconds]
<struk|desk>
Guest24313: ah I remember you. hi again
Ravana has joined #ocaml
teknozulu has joined #ocaml
<Guest24313>
I'm trying to find the best way to say that want a thread to only run for x period of time and playing with Lwt_unix.with_timeout and Lwt_timeout.*
ril has quit [Ping timeout: 264 seconds]
MercurialAlchemi has joined #ocaml
darkf has joined #ocaml
struk|desk is now known as struk|desk|away
pyon has quit [Quit: WeeChat 1.3]
ril has joined #ocaml
ril has quit [Ping timeout: 250 seconds]
struktured has joined #ocaml
<Guest24313>
Does a larger default buffer size for Lwt_io make a difference? Say one uses 8192 instead of the default 4096.
JacobEdelman has quit [Quit: Connection closed for inactivity]
<teknozulu>
Trying to use Core's Set with a string * string. What should my comparator look like?
<teknozulu>
actually Set.Poly.t is probably the move here
Mercuria1Alchemi has joined #ocaml
zpe has joined #ocaml
<Guest24313>
Using Lwt_daemon.daemonize but my program doesn't dameonize, it just exits with no exceptions...this was in a Lwt.t thread.
grai has quit [Ping timeout: 240 seconds]
slash^ has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
mcint has quit [Quit: hibernating...]
palomer has quit [Quit: palomer]
palomer has joined #ocaml
Bahman has quit [Read error: Connection reset by peer]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
lazyMonster has joined #ocaml
lazyMonster is now known as lzyMnster
lzyMnster has left #ocaml [#ocaml]
zpe has quit [Ping timeout: 260 seconds]
palomer has quit [Quit: palomer]
mcint has joined #ocaml
Bahman has joined #ocaml
lzyMnster has joined #ocaml
lzyMnster has quit []
lzyMnster has joined #ocaml
lzyMnster has left #ocaml [#ocaml]
damason has quit [Ping timeout: 256 seconds]
Simn has joined #ocaml
Haudegen has quit [Ping timeout: 272 seconds]
cody` has quit [Quit: Connection closed for inactivity]
Haudegen has joined #ocaml
Mercuria1Alchemi has quit [Ping timeout: 260 seconds]
Mercuria1Alchemi has joined #ocaml
ely-se has joined #ocaml
ely-se has quit [Client Quit]
ely-se has joined #ocaml
teknozulu has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Bye.]
zpe has joined #ocaml
BitPuffin|osx has quit [Ping timeout: 255 seconds]
freehck has joined #ocaml
Maelan has quit [Ping timeout: 250 seconds]
tobiasBora has quit [Ping timeout: 272 seconds]
sgnb has quit [Read error: Connection reset by peer]
sgnb has joined #ocaml
Bahman has quit [Remote host closed the connection]
Bahman has joined #ocaml
Guest24313 has quit [Remote host closed the connection]
slash^ has quit [Quit: Leaving.]
freehck has quit [Quit: rcirc on GNU Emacs 24.4.1]
freehck has joined #ocaml
ggole has joined #ocaml
Madars has quit [Ping timeout: 260 seconds]
yomimono has joined #ocaml
lolisa has joined #ocaml
inr_ has joined #ocaml
patronus has joined #ocaml
c-c_ has joined #ocaml
bernardo1pc has joined #ocaml
Mandus_ has joined #ocaml
haelix_ has joined #ocaml
sivoais_ has joined #ocaml
Snark_ has joined #ocaml
tvaalen_ has joined #ocaml
hnrgrgr_ has joined #ocaml
yomimono has quit [Quit: Leaving]
profan_ has joined #ocaml
artart78_ has joined #ocaml
artart78_ has joined #ocaml
eagleflo_ has joined #ocaml
boegel|quassel has joined #ocaml
octachron has joined #ocaml
edwin2 has joined #ocaml
Bahman has quit [Remote host closed the connection]
alpen- has joined #ocaml
julienXX_ has joined #ocaml
Bahman has joined #ocaml
Intensity has quit [*.net *.split]
profan has quit [*.net *.split]
edwin has quit [*.net *.split]
dmiller has quit [*.net *.split]
Mandus has quit [*.net *.split]
patronus_ has quit [*.net *.split]
Snark has quit [*.net *.split]
boegel has quit [*.net *.split]
srax has quit [*.net *.split]
haelix has quit [*.net *.split]
cantstanya has quit [*.net *.split]
yawnt has quit [*.net *.split]
hnrgrgr has quit [*.net *.split]
inr has quit [*.net *.split]
c-c has quit [*.net *.split]
sivoais has quit [*.net *.split]
tvaalen has quit [*.net *.split]
julienXX has quit [*.net *.split]
eagleflo has quit [*.net *.split]
artart78 has quit [*.net *.split]
bernardofpc has quit [*.net *.split]
jave has quit [*.net *.split]
iZsh has quit [*.net *.split]
alpen has quit [*.net *.split]
edwin2 is now known as edwin
julienXX_ is now known as julienXX
yawnt has joined #ocaml
Bahman has quit [Remote host closed the connection]
iZsh has joined #ocaml
tvaalen_ has quit [Changing host]
tvaalen_ has joined #ocaml
tvaalen_ is now known as tvaalen
sivoais_ has quit [Ping timeout: 272 seconds]
jave has joined #ocaml
sivoais has joined #ocaml
srax has joined #ocaml
Madars has joined #ocaml
cantstanya has joined #ocaml
dmiller has joined #ocaml
i0sys has joined #ocaml
_andre has joined #ocaml
slash^ has joined #ocaml
seliopou_ has joined #ocaml
sivoais has quit [Ping timeout: 246 seconds]
Kakadu has joined #ocaml
ely-se has quit [Quit: leaving]
djellemah_ has joined #ocaml
hay207 has joined #ocaml
sivoais has joined #ocaml
theblatt1 has joined #ocaml
artart78_ is now known as artart78
PigDude_ has joined #ocaml
M-Illandan1 has joined #ocaml
jerith_ has joined #ocaml
mcint has quit [Quit: hibernating...]
Intensity has joined #ocaml
hay207__ has quit [*.net *.split]
iosys has quit [*.net *.split]
theblatte has quit [*.net *.split]
PigDude has quit [*.net *.split]
M-Illandan has quit [*.net *.split]
jerith has quit [*.net *.split]
DanielRichman has quit [*.net *.split]
djellemah has quit [*.net *.split]
hbar has quit [*.net *.split]
seliopou has quit [*.net *.split]
MasseR has quit [*.net *.split]
relrod has quit [*.net *.split]
i0sys is now known as iosys
sivoais has quit [Ping timeout: 240 seconds]
dsheets has joined #ocaml
MasseR has joined #ocaml
DanielRichman has joined #ocaml
nicoo has quit [Remote host closed the connection]
mcint has joined #ocaml
nicoo has joined #ocaml
orbifx has joined #ocaml
sivoais has joined #ocaml
ely-se has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kakadu has quit [Quit: Page closed]
sivoais has quit [Read error: Connection reset by peer]
sivoais has joined #ocaml
Kakadu has joined #ocaml
Madars has quit [Ping timeout: 264 seconds]
sivoais has quit [Ping timeout: 255 seconds]
sivoais has joined #ocaml
ely-se has quit [Quit: leaving]
ely-se has joined #ocaml
sbrouf has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
dsheets has quit [Ping timeout: 240 seconds]
sivoais has joined #ocaml
sivoais has quit [Read error: Connection reset by peer]
sivoais has joined #ocaml
ely-se has quit [Quit: leaving]
sivoais has quit [Ping timeout: 276 seconds]
sivoais has joined #ocaml
dsheets has joined #ocaml
keep_learning has joined #ocaml
sivoais has quit [Ping timeout: 264 seconds]
sivoais has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
sivoais has quit [Ping timeout: 264 seconds]
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
inr_ is now known as inr
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 240 seconds]
sivoais has joined #ocaml
JacobEdelman has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
govg has quit [Ping timeout: 260 seconds]
sivoais has joined #ocaml
ely-se has joined #ocaml
hbar has joined #ocaml
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
hnrgrgr_ is now known as hnrgrgr
Haudegen has quit [Ping timeout: 265 seconds]
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
sivoais has quit [Ping timeout: 265 seconds]
Sorella has joined #ocaml
Haudegen has joined #ocaml
Maelan has joined #ocaml
mcint has quit [Quit: hibernating...]
theblatt1 is now known as theblatte
keep_learning has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
jpdeplaix has joined #ocaml
keep_learning has joined #ocaml
Akshay has joined #ocaml
Maelan has quit [Quit: Reconnecting]
Maelan has joined #ocaml
d0nn1e has quit [Ping timeout: 260 seconds]
jerith_ is now known as jerith
d0nn1e has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
Akshya_ has joined #ocaml
struk|desk|away is now known as struk|desk
Akshay has quit [Ping timeout: 265 seconds]
Akshya_ has quit [Quit: Leaving]
lolisa has quit [Ping timeout: 246 seconds]
n1ftyn8_ has quit [Quit: Connection closed for inactivity]
PigDude_ has quit [Quit: leaving]
struk|desk is now known as struk|desk|away
dsheets has joined #ocaml
pierpa has joined #ocaml
RandomThrowaway has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
igoroliveira has joined #ocaml
sbrouf has quit [Ping timeout: 245 seconds]
teratorn has quit [Read error: No route to host]
kaustuv has joined #ocaml
<kaustuv>
This is triggering warning 52 in 4.03.0 when it didn't in 4.02.3. How do I work around it?
<kaustuv>
let second l = try Some (List.nth l 1) with Failure "nth" -> None
<companion_cube>
don't use Failure "nth"
<companion_cube>
Failure _ -> None
<companion_cube>
this is more robust
<companion_cube>
(anyway, I'd write let second = function | _::x::_ -> Some x | _ -> None)
<kaustuv>
But it is also not what I want. There are multiple failures that may be raised and I just want to guard List.nth
<kaustuv>
(My actual code is not this trivial, obviously.)
<flux>
is it a feature though to raise a warning there, though?
<flux>
I mean, you're bound to not handle some exceptions.
<kaustuv>
Exactly!
<edwin>
what does warning 52 say?
<flux>
52 is a new warning, though. maybe you can just disable it?
<kaustuv>
> Warning 52: the argument of this constructor should not be matched against a
<kaustuv>
> constant pattern; the actual value of the argument could change
<kaustuv>
> in the future
<companion_cube>
kaustuv: you still shouldn't rely on List.nth to raise exactly this failure
<flux>
ok, so it's actually a a specific feature for Failure?-)
<flux>
somehow I think it ain't gonna change.. because code does rely on it ;-)
<kaustuv>
companion_cube: this is not my code. I agree with you, but I don't want do do major refactoring now just to get it to compile in 4.03.0
<companion_cube>
-_-
<companion_cube>
does the code raise several flavors of Failure ? :s
<flux>
welll, ignore that -warning- then?
sbrouf has joined #ocaml
<flux>
or are you compiling with all warnings enabled and "error on warning"?
<kaustuv>
companion_cube: several is putting it mildly. It's got only failwiths for errors
<companion_cube>
:(
<companion_cube>
disgusting
<companion_cube>
I'd say: keep the warning, don't silence it, and someday refactor the failwith away
<flux>
companion_cube, you don't think it's a nice goal to catch as narrowly as possible?-(
<flux>
just put catch _ there, it works just as well.
<companion_cube>
I think it's a nice goal not to depend on the exact string in Failure
<companion_cube>
it might change
<kaustuv>
But realistically, since it's part of the public API, it won't ever change.
<ggole>
let nth_exn : 'a list -> int -> 'a option = ... and then use that?
<companion_cube>
^
<companion_cube>
good point, ggole
<companion_cube>
kaustuv: what's your codebase, if I may ask?
<edwin>
from the Changes file it looks like you can apply this attribute to any exception, not just Failure: - GPR#254: @ocaml.warn_on_literal_pattern attribute on constructors to warn when the argument is matches against a constant pattern. This attribute is applied on predefined exception constructors which take an purely informational (with no stability guarantee) message. (Alain Frisch)
<companion_cube>
hmm ok, fun, never heard of this prover
<kaustuv>
I'm just wondering why warning 52 is being triggered in try ... with clauses. It makes sense for match ... with, sure, but exception handlers are not intended to be exhaustive!
<companion_cube>
it's still dangerous, because if the messages of List.nth changes then you will not catch the exception
<flux>
it's funny, though, how List.nth throws an exception, and then it's impossible to catch that in a future-proof fashion, _unless_ you catch it exactly after calling it.. which is sort of counters what the exceptions are there in the first place.
<flux>
s/what the/why the/
<companion_cube>
well it's 20 years-old design colliding with modern coding practices
<kaustuv>
You can always catch all failures and then write a big if-then-else on messages
<flux>
in the 20 years, how many times has the Failure message changed for List.nth.. :-)
<flux>
sadly the ocaml exceptions aren't very extensible in a backward-compatible fashion
<kaustuv>
The public API for List.nth says that it raises (Failure "nth") and (Invalid_argument "List.nth"). This should give you an idea of changing API norms...
<companion_cube>
it would return an option, if it was written now
keep_learning has joined #ocaml
<flux>
compared to a class hierarchy, where there is a way to express compatibility
<flux>
in fact, objects would make fine ocaml exceptions :P
Mercuria1Alchemi has quit [Ping timeout: 260 seconds]
<sphinxo>
This is ocaml day 1 so I have no idea what i'm doing
sivoais has joined #ocaml
<ggole>
sphinxo: ^ doesn't modify either of its arguments. It returns a new string.
<ggole>
You probably want to use a Buffer here
<sphinxo>
How can i make eval return body?
<ggole>
For a start, you're ignoring the return value
<Drup>
sphinxo: there are some syntax errors too, you don't need the ";" after the strings on line 32/36
<Drup>
and you need parens against the arguments on line 40
<Drup>
around*
<sphinxo>
How do I make eval return body?
<Drup>
sphinxo: the last expression of a function is returned
<Drup>
"let f x = .... ; x"
<Drup>
it returns x
<sphinxo>
ahh that makes sense ofc
<sphinxo>
How would I use a buffer? ggole
<companion_cube>
for a start, you should just use ^ , I think
sivoais has quit [Ping timeout: 244 seconds]
<companion_cube>
to understand how it works
<sphinxo>
Creates a new string companion_cube
<sphinxo>
eg let foobar = foo ^ bar
<sphinxo>
right?
<companion_cube>
yes
<companion_cube>
let put_parenthesis s = "(" ^ s ^ ")" for instance
<sphinxo>
Nice
<ggole>
let buf = Buffer.create size in let rec loop ... = Buffer.add_char buf char; loop ... in loop ...; Buffer.contents buf
mcint has joined #ocaml
<companion_cube>
ggole: if sphinxo is trying to learn functional programming then that's not helping
<companion_cube>
although I agree it's better in practicve
<ggole>
I don't believe in suggesting quadratic code to people.
<companion_cube>
:(
<sphinxo>
quadratic code? what does that mean?
sivoais has joined #ocaml
<companion_cube>
sphinxo: do you know other programming languages?
Denommus has joined #ocaml
<sphinxo>
functional? done some haskell and fsharp
<sphinxo>
otherwise rust, python and c
<companion_cube>
oh, so it should be close to f#
<ggole>
Because ^ creates a new string of length equal to both of its arguments, using ^ to add a character to an accumulated string in a loop takes time quadratic in the length of the input
<companion_cube>
match l with | a :: b :: _ -> foo | [_] | [] -> bar ?
<sphinxo>
ooh, that looks like it'll work
<Korhonen>
Is thre any way to make an explicit type declration or a function argument taking an object that uses row polymorphism. As in say I have a "'a listobj" type that has the hd and tl methods, is there any way to define a function that takes an object that implements hd and tl + any other number of unspecified methods.
<companion_cube>
val foo : <hd: 'a ; tl: 'a ; ..> -> bar
<Korhonen>
Something like "let f (x : int list ..)" or whatever
<companion_cube>
let f (x : <hd:'a ; tl:'a ; ..>) = ...
<Korhonen>
Yeah, I know but that requires you to type out the entire declration every time.
<Korhonen>
Iwonder if you can use the 'a list name you already have and add the dots to it
<sphinxo>
companion_cube: can I use _ in foo?
<companion_cube>
oh, yes, just give it a name
<Korhonen>
Since the actual type I have uses quite a lot more methods, this is just an example and typing it out every time maes the code unreadable.
<companion_cube>
a :: b :: tail -> ...
<Korhonen>
Well, I have a name right now, but the name is closed. If I give something that is opened a name then it complains.
<companion_cube>
Korhonen: sadly you cannot manipulate or name the .. itself
<Korhonen>
Hmm, so there's no way to declare an obect type that is another already named object type + extra methods?
tane has quit [Remote host closed the connection]
rpg has quit [Ping timeout: 246 seconds]
octachron has joined #ocaml
<companion_cube>
Korhonen: you can use classes
<companion_cube>
it's not exactly the same thing though
<companion_cube>
class + inheritance allows to add methods to an already existing class
ygrek has quit [Ping timeout: 245 seconds]
<octachron>
Korhonen, maybe "type 'a t = < hd:'b; .. > as 'a" and "f (x:'a t) = ..."
<Korhonen>
Ahhh
dretnx has joined #ocaml
<Korhonen>
You need to add "as 'a"
<ggole>
You can "join" class types and arbitrary methods in a type, but it's a bit of a hack
<Korhonen>
Got it
<ggole>
It's something like type 'a t = #foo as 'a constraint 'a = <zonk : int; blap : int; ...>
<ggole>
'a t will then be the type of #foo plus the methods zonk and blap
rand_ has joined #ocaml
dretnx has quit [Client Quit]
<ggole>
I don't think that works for plain object types though
<sphinxo>
What does this error mean? This expression has type (directive * directive) list but an expression was expected of type directive list
<octachron>
sphinxo, the type of the element list in your list is the tuple type directive * directive rather than a simple directive
<octachron>
you might have a [x, y ] list when you meant [x; y]
<sphinxo>
yep :) new to ocaml
mcint has joined #ocaml
palomer has joined #ocaml
struktured has quit [Ping timeout: 240 seconds]
nullcatxxx_ has joined #ocaml
Madars has joined #ocaml
struk|desk is now known as struk|desk|away
ril has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kakadu has joined #ocaml
ril has joined #ocaml
groovy2shoes has joined #ocaml
yomimono has joined #ocaml
<sphinxo>
How can I map a list to a function and remove all none values in the returned list?
yomimono has quit [Client Quit]
ollehar has quit [Ping timeout: 255 seconds]
<companion_cube>
look for some "filter_map" functions in alternative stdlibs
<companion_cube>
or you can write one yourself, it's 3 or 4 lines
<pierpa>
or you use List.fold_left
<sphinxo>
How would I use List.fold_left?
<pierpa>
List.fold_right even better :)
<sphinxo>
fold_right?
<sphinxo>
How would I use it?
<pierpa>
first you read the documentation in the manual, then if something is not clear you ask
<Algebr`>
sphinxo: here's an example: List.fold_left (fun accum value -> if value < 2 then value :: accum else accum) [] some_list
rpg has joined #ocaml
Haudegen has quit [Ping timeout: 255 seconds]
<sphinxo>
I'm trying to use String.map to map over every char and it doesn't seem to work? http://lpaste.net/147600
larhat1 has quit [Read error: Connection reset by peer]
larhat1 has joined #ocaml
<Algebr`>
because map first argument is a function that is supposed to give back char
<Algebr`>
and you are giving back char option
Lasher` has quit [Ping timeout: 260 seconds]
<Algebr`>
rather, you're giving back an instruction option
<sphinxo>
How would I fix that?
<Algebr`>
well this approache doesn't work right, so you need to think of another one?
<sphinxo>
oh, ok
Lasher` has joined #ocaml
<Algebr`>
think of other things that can map easily, where the return type of the map function isn't so restrained
<Algebr`>
like List.map
<sphinxo>
so seperate the string into a list of chars?
<Algebr`>
yup, that's what i was thinking
Madars has quit [Ping timeout: 260 seconds]
<Algebr`>
at least that's what i probably would have done and then List.map on them
ollehar has joined #ocaml
<sphinxo>
String.explode?
<Algebr`>
how you do it is up to you.
<sphinxo>
What way do you think is best?
<octachron>
another option would be to convert to an instruction array with Array.init
<sphinxo>
how? octachron
<Algebr`>
sphinxo: i think the best way is the one you come up with one your own.
<octachron>
sphinxo, your initial problem stems to the fact that String is specialized to char elements
<octachron>
so a way to go around this problem is to get back to the general array type by constructing a new array
Haudegen has joined #ocaml
tane has joined #ocaml
<octachron>
and an array can be constructed with either Array.make and Array.init.
<octachron>
Array.init allows you to construct an array from an int -> element function
<sphinxo>
int?
_andre has quit [Quit: leaving]
<octachron>
the type of integers?
<sphinxo>
I want to go from char -> element
ygrek has joined #ocaml
<octachron>
fortunately, you also have an int -> char function laying around
keep_learning has quit [Quit: This computer has gone to sleep]
ely-se has joined #ocaml
<sphinxo>
Ok, i'm stuck
<sphinxo>
So i need to work out the ints for my chars and modify the function so it matches against them?
orbifx2 has joined #ocaml
orbifx has quit [Read error: Connection reset by peer]
<octachron>
sorry, I was talking about the String.get(:int->char) function
<octachron>
if you have a string and you want to construct a general array , you want the k-th element of the new array to be "f (k-th element of the char)"