NJBS has quit [Read error: Connection reset by peer]
inr has quit [Read error: Connection reset by peer]
riveter has quit [Ping timeout: 240 seconds]
rcabaco has quit [Read error: Connection reset by peer]
rcabaco has joined #ocaml
flx has joined #ocaml
jcloud has quit [Ping timeout: 240 seconds]
ansiwen has quit [Quit: No Ping reply in 180 seconds.]
ggherdov has quit [Ping timeout: 240 seconds]
caw has quit [Ping timeout: 240 seconds]
menasw has quit [Read error: Connection reset by peer]
inr has joined #ocaml
menasw has joined #ocaml
nicoo has quit [Ping timeout: 240 seconds]
iZsh has quit [Ping timeout: 240 seconds]
ahf has quit [Ping timeout: 245 seconds]
andreypopp has quit [Ping timeout: 240 seconds]
lobo has quit [Ping timeout: 240 seconds]
ansiwen has joined #ocaml
DanielRichman has quit [Ping timeout: 240 seconds]
mattg has quit [Ping timeout: 240 seconds]
Khady has quit [Remote host closed the connection]
apache3 has joined #ocaml
apache3_ has quit [Ping timeout: 240 seconds]
ggherdov has joined #ocaml
Khady has joined #ocaml
Khady has joined #ocaml
Khady has quit [Changing host]
DanielRichman has joined #ocaml
flux has quit [Ping timeout: 240 seconds]
flx is now known as flux
caw has joined #ocaml
govg has quit [Ping timeout: 256 seconds]
riveter has joined #ocaml
ahf has joined #ocaml
iZsh has joined #ocaml
nicoo has joined #ocaml
mattg has joined #ocaml
lobo has joined #ocaml
hcarty has quit [Ping timeout: 252 seconds]
apache3 has quit [Remote host closed the connection]
apache3_ has joined #ocaml
nicoo has quit [Excess Flood]
nicoo has joined #ocaml
tmtwd has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
silver has quit [Quit: rakede]
snhmib has quit [Ping timeout: 258 seconds]
P4Titan has joined #ocaml
nomicflux has quit [Quit: nomicflux]
P4Titan` has joined #ocaml
<P4Titan`>
Hi all
<Algebr``>
hi
<P4Titan`>
I am writing a simple server/client pair of programs using LWT
<P4Titan`>
Now, LWT makes sense for the server in order to enable it to be multi-client
<P4Titan`>
but for the client, having coroutines don't make sense
<P4Titan`>
and even complicate things a little more since I may need to have a lock in a section
P4Titan has quit [Ping timeout: 240 seconds]
<P4Titan`>
That said, LWT has a very nice `with_connection` function clearly meant to be used for client side code
<P4Titan`>
What should I do about this? Any thoughts/recommendations?
wtetzner has quit [Remote host closed the connection]
nomicflux has joined #ocaml
bigs_ has joined #ocaml
nomicflux has quit [Ping timeout: 245 seconds]
<cheater>
hey guys
<cheater>
i need to be able to write to a data structure from two Lwt callbacks, without data races, how can i do that?
<cheater>
i need something like a hash table of lists
<cheater>
of maybe strings
<cheater>
i guess i could use an mvar
al-damiri has quit [Quit: Connection closed for inactivity]
<aantron>
cheater: if your writing code does not call back into lwt, you don't need to worry about data races, as that code will run to completion before lwt calls any other "callback"
<cheater>
i'm not even sure if i should be using an mvar?
<aantron>
but if that's not the case, there are options like lwt_mutex
<cheater>
so what i have here is...
<cheater>
let me type up the structure of this code
<aantron>
what i am saying is if your data structure modifying code does not call back into lwt, there is no chance for anything else scheduled by lwt to interfere
<cheater>
i basically have let rec loop () = Lwt.choose [ ... stuff ... ] >>= function (handle packet) worker_loop ()
<cheater>
and i'd like the function handling the packets to be able to share data between the handlers for two packets coming in
<cheater>
oh sorry that should have been..
<cheater>
let rec loop () = Lwt.choose [ ... stuff ... ] >>= function (handle packet) loop ()
<cheater>
right
<cheater>
so anyways, why wouldn't i just create a simple list or something just before i define and launch loop, and just append and remove from that list inside the packet handler?
<cheater>
should i use mutex and other stuff like that?
<aantron>
i don't know, why not?
<aantron>
cheater
<aantron>
i just told you what the rule is
<aantron>
please respond to that
<cheater>
you have but i didn't understand what you said because i don't really know how lwt relates to the terms you used
<aantron>
then ask for clarification
<aantron>
because i dont know what you are missing or that you are missing
<cheater>
so for example... is the packet handler code that calls back into lwt or not?
<aantron>
it
<aantron>
i don't know, it depends on how you wrote it
<aantron>
basically if your data structure update does not use any functions from Lwt
wu_ng has joined #ocaml
<aantron>
e.g.
<aantron>
you are doing a List.iter over some mutable record list, and just updating the fields
<cheater>
ok let me tell you what the packet handler does
<aantron>
without calling any functions from lwt in the function you passed to .iter
wu_ng has quit [Read error: Connection reset by peer]
<aantron>
then that whole List.iter cannot be "descheduled" by lwt
wu_ng has joined #ocaml
<aantron>
that is by design
<aantron>
so you don't have to protect it
<cheater>
right because it's not cooperative
<aantron>
so as long as you are interacting with your shared data structure in this way, you don't need to take any special measures
<cheater>
aha
<cheater>
that makes sense, thanks!
tmtwd has quit [Ping timeout: 256 seconds]
<cheater>
ok, i guess i might need to call into lwt after all
<aantron>
this is also easy to guarantee statically, if you wrap all the ways to mess with your data structure in a module, and that module has no Lwt.t in the interface (and does not abuse Lwt.async internally)
<cheater>
because sometimes i'll need to send out network io
<aantron>
(or starting lwt threads and ignoring them, etc.)
<cheater>
aha
<cheater>
that's pretty good then
<cheater>
thank you
jcloud has joined #ocaml
<aantron>
cheater: it might not be a problem as long as you are doing the io in between well-defined, independent interactions with that shared data. if that's not possible, then you might need lwt_mutex, lwt_condition, and/or other approaches
<flux>
I have limited Haskell knowledge, but it looks like the gridzipper should be a parametrized type
<flux>
as in the Haskell code there is GridZipper a <- a is a type variable
<flux>
and I don't see 'left' defined in the haskell code
<flux>
I understand 'case left' would be like 'match left' in OCaml
<ocaml252>
Previous code before the Haskell function has those record types
<flux>
the last line would be like | hd::tl -> Some ( focus = hd; left = tl; right = focus :: right }
<flux>
except the first ( should have been {
<flux>
hmm, ok so if 'left' is a record field, then in haskell 'left' should take the record as an argument to 'left', right?
<flux>
but there is no argument in that code
<ocaml252>
| hd::tl -> Some ( let newgridzipper = { g with focus = hd, left = tl, right = focus :: right })
<flux>
should read case left g perhaps?
<ocaml252>
Thought they were updating part of a record type.
<ocaml252>
to move left
<flux>
your "let newgridzipper = " does nothing as is invalid
<flux>
statements of form let a = b are only legal in the top level
<flux>
and the expression form "let a = b in c" only sets a = b in the expression c, not outside it
<ocaml252>
| hd::tl -> let newgridzipper = { g with focus = hd, left = tl, right = focus :: right } in Some(newgridzipper)
<flux>
ah now I notice the haskell code has this 'g { ..'. I don't quite know what that does. is that the haskell way to return a new record while sharing some old values? in that case your { g with .. } is correct
<flux>
yes, that wold be proper
<flux>
except for , need to be ;
<ocaml252>
I guess so. It is the zipper pattern.
<flux>
I think your code with that most recent change is on the right track
govg has quit [Quit: leaving]
<flux>
I need to be moving, good luck with your zipper!
<flux>
could have maybe started with a simpler zipper to get a hang of it?-)
<ocaml252>
As I understand it is a list of lists. Thought can't be simpler.
<ocaml252>
let newgridzipper = { g with focus = hd; left = tl; right = g.right @ [g.focus] } in Some(newgridzipper)
<ocaml252>
Does g.focus at the end reflect the new value of focus or old ?
<ocaml252>
focus = hd
myst|fon has joined #ocaml
AltGr has joined #ocaml
lambda_foo has quit [Quit: Connection closed for inactivity]
nkhodyunya has joined #ocaml
freusque has quit [Ping timeout: 240 seconds]
malc_ has joined #ocaml
mfp has joined #ocaml
AlexRussia has quit [Ping timeout: 248 seconds]
trepta has quit [Ping timeout: 240 seconds]
larhat has joined #ocaml
kakadu has joined #ocaml
mpenet has joined #ocaml
sz0 has quit [Quit: Connection closed for inactivity]
<Leonidas>
ocaml252: in the haskell code? looks like it's the new head
<Leonidas>
also the let in the ocaml code is ???
<Leonidas>
also, containers has zippers, just sayin' ;-)
snhmib has joined #ocaml
mpenet has left #ocaml ["ERC (IRC client for Emacs 26.0.50.2)"]
<Leonidas>
turns out .. is a GHC extension
silver has joined #ocaml
Guest26 has joined #ocaml
<ocaml252>
Leonidas: Was away.
<ocaml252>
What did you mean about hd ?
<ocaml252>
let newgridzipper = { g with focus = hd; left = tl; right = g.right @ [g.focus] } in Some(newgridzipper)
<ocaml252>
Does g.focus at the end the updated "g with focus = hd; "
<ocaml252>
x and x' are just used to differentiate ?
<lyxia>
It's two different variable names, like x and x1.
ltadeu has joined #ocaml
<bernardofpc>
I'm getting .opam/4.03.0/lib/ocaml/libasmrun.a(custom.o): relocation R_X86_64_32 against symbol `caml_custom_table' can not be used when making a shared object; recompile with -fPIC
<bernardofpc>
does anyone know how to recompile a switch with -fPIC ?
nkhodyunya has quit [Quit: Leaving.]
<bernardofpc>
(google did not help me)
<flux>
bernardofpc, I had the same issue, I switched to an opam switch with fPIC
<companion_cube>
I think there is a special switch for fpic
<flux>
bernardofpc, opam switch -a | grep PIC and choose one you want
<flux>
I wonder what has changed in debian as my old switches (without fPIC) also broke
<bernardofpc>
thanks
<flux>
the number of opam switches does make me think that maybe parametrized switches would be cool.. :)
<bernardofpc>
(that's rather horrible since no PIC switch appears on the main choices, and this seems to be required by ocmlfind/camlp4 ... not strange packages)
nkhodyunya has joined #ocaml
<flux>
I wonder if fPIC will become the default at some point. I understand it costs some % of performance, though.
<flux>
but I think the default should be working. there could be separate switches for -no-fPIC
<companion_cube>
so this problem appeared recently for you? I never had that
<flux>
after last debian upgrade, maybe, I noticed my ocaml environment doesn't produce executables anymore
<flux>
switching to fPIC fixed it
<companion_cube>
maybe just recompiling the switch would do? :?
<companion_cube>
:/
<companion_cube>
that's weird though
<flux>
I'm not sure if I tried it, but the errors before the final linker error complained about missing fPIC
<flux>
oh and the problem was with native binaries, not with ocamlc ones
<companion_cube>
(have you submitted a bug report?)
<flux>
no.. fixed.. works on my machine :)
<companion_cube>
if "fixed" requires to use fpic, it's not really a fix, is it?
<flux>
how is it not a fix?
<flux>
seems like some other people have had the same issue as well, judging from the google of the first error
<companion_cube>
well, ocamlopt should work without fpic too, should it not?
<flux>
not sure, perhaps there's something in recent debian that requires fPIC
_andre has joined #ocaml
Guest26 has quit [Read error: Connection reset by peer]
infinity0 has quit [Ping timeout: 240 seconds]
infinity0 has joined #ocaml
dhil has quit [Quit: Quit]
<bernardofpc>
opam: "tcgetattr" failed: Inappropriate ioctl for device -> :(
<bernardofpc>
hum, xargs problem
<bernardofpc>
opam -y to the rescue
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
rcabaco has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
dhil has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
sepp2k has joined #ocaml
dhil has quit [Ping timeout: 240 seconds]
freusque has quit [Quit: WeeChat 1.6]
silver has quit [Read error: Connection reset by peer]
silver has joined #ocaml
dhil has joined #ocaml
AlexRussia has joined #ocaml
freusque has joined #ocaml
hcarty has joined #ocaml
hcarty has quit [Ping timeout: 258 seconds]
nkhodyunya has quit [Quit: Leaving.]
<ocaml252>
type grid = {gamegrid : cell list} How do I pattern match grid into hd :: tl ?
<ocaml252>
I am able to match only like this. | {gamegrid = g}
<Drup>
{gamegrid = h :: t}
<ocaml252>
Oh!
<Drup>
(or you just get rid of the record, because it's not very useful here
<ocaml252>
Yes. But I learnt something new :-)
<Drup>
indeed. It's nice to be able to nest patterns
freusque has quit [Ping timeout: 258 seconds]
<ocaml252>
Didn't know such nested patterns existed.
sz0 has joined #ocaml
al-damiri has joined #ocaml
malc_ has quit [Quit: ERC (IRC client for Emacs 25.0.50.2)]
AlexRussia has quit [Read error: Connection reset by peer]
wtetzner has joined #ocaml
wu_ng has quit [Remote host closed the connection]
larhat has quit [Quit: Leaving.]
nkhodyunya has joined #ocaml
dhil has quit [Ping timeout: 258 seconds]
shinnya has joined #ocaml
rpip has quit [Ping timeout: 255 seconds]
govg has joined #ocaml
nkhodyunya has quit [Quit: Leaving.]
<ocaml252>
let focuscell celllist n = let rec loop acc n l = match l,n with | hd :: tl,n when n > 0 -> loop (hd :: acc) (n - 1) tl | [],_ -> None | hd :: tl,0 -> Some (acc, hd, tl) in loop [] 0 celllist ;;
<ocaml252>
_::_,1 is unmatched according to the error. Why ?
larhat has joined #ocaml
freusque has joined #ocaml
sh0t has quit [Ping timeout: 256 seconds]
wtetzner has quit [Remote host closed the connection]
ocaml252 has quit [Ping timeout: 260 seconds]
shinnya has quit [Ping timeout: 255 seconds]
theblatt1 is now known as theblatte
dhil has joined #ocaml
yurug has joined #ocaml
yurug has quit [Client Quit]
moei has quit [Quit: Leaving...]
nomicflux has joined #ocaml
govg has quit [Quit: leaving]
rgrinberg has joined #ocaml
snhmib has quit [Read error: Connection reset by peer]
copy` has joined #ocaml
chindy has joined #ocaml
sh0t has joined #ocaml
th5 has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
rgrinberg has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
<orbitz>
Ugh, bytes + ocamldebug do not mix
sz0 has quit [Quit: Connection closed for inactivity]
myst|fon has joined #ocaml
<def`>
Algebr``: if you have no custom equality/comparison/hashing/marshalling functions
<Algebr``>
Hmm, I was more interested in the GC aspect
<Algebr``>
anything more besides one gives you a hook on collection ?
<Algebr``>
def`:
<def`>
no
<def`>
If you want a value that is not moved, that doesn't exist in OCaml (I suggested the feature a few time informally, as it would help complex bindings, but it has not been considered yet :))
<flux>
you can register a gc root, can't you?
<Algebr``>
right
<def`>
yes, so that it is moved.
<def`>
but non moving values are not possible :o
octachron has joined #ocaml
<def`>
the problem with gc root is that it keeps the value alive. You might want to manage liveness on OCaml side and yet be able to refer to the heap from C-side
<def`>
(a simple recursion in a value used by a C-binding, e.g a closure in labgtk, is likely to cause a memory leak; it is possible to work around that, but it would be much easier with some support from GC)
octarin has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
Flerex has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<flux>
it is too darn easy to make buggy C-bindings for OCaml
<flux>
my program uses fftw3 and pulseaudio and there are some problems with it :)
soultadu has joined #ocaml
<def`>
I don't know :).
<def`>
The GC FFI is quite simple, but not well specified I feel.
jnavila has quit [Remote host closed the connection]
ia0 has quit [Quit: reboot]
ia0 has joined #ocaml
<octachron>
I didn't notice that the optional argument syntax is partially white space sensitive: "let f ?x= …" ≡ "let f ? x = … " but "let f ? x:y = …" ≠ "let f ?x:y = …"
<octachron>
I wonder if there is a reason for this difference
<companion_cube>
oh, I always write `let f ?(x=y)`
<octachron>
companion_cube, which is also fine with a white space f ? (x=y)
<companion_cube>
:D
<companion_cube>
terrible
<octachron>
given that it is only the less used form of optional argument that is whitespace sensitive, I would tend to infer an oversight
yomimono has quit [Ping timeout: 260 seconds]
octarin has quit [Quit: leaving]
boojinks has quit [Quit: byeeee]
larhat has joined #ocaml
larhat has quit [Ping timeout: 240 seconds]
th5 has quit [Remote host closed the connection]
<def`>
what differs in the second case?
<cheater>
is there a good set impl in ocaml with fast lookup?
<cheater>
i was told i should be using a set based on a balanced tree.
<hcarty1>
cheater: Is the stdlib's Set fast enough for you?
al-damiri has quit [Quit: Connection closed for inactivity]
<hcarty1>
Rather, have you tested with the OCaml stdlib's sets?
<octachron>
def`, the first is seen as "(f ? label):type_expr", eg "let f ? x:int = 0", the second as "f ?label:pattern", e.g " let f ?x:y = y "
<def`>
ah. But it is the same with labelled arguments, no?
<cheater>
hcarty1: i don't know. i haven't. i didn't know stdlib had sets.
<cheater>
The implementation uses balanced binary trees, and is therefore reasonably efficient: insertion and membership take time logarithmic in the size of the set
<cheater>
should be fine
<cheater>
:)
<cheater>
thanks hcarty :)
<hcarty>
Have fun!
jrslepak has quit [Remote host closed the connection]
jrslepak has joined #ocaml
rgrinberg has quit [Ping timeout: 256 seconds]
kakadu has quit [Remote host closed the connection]
octachron has quit [Quit: Leaving]
orbifx has joined #ocaml
<orbifx>
I get a warning when building: findlib: [WARNING] Interface topdirs.cmi occurs in several directories: ...
<orbifx>
and it says the two directories
<orbifx>
compiler-libs and the directory above
<orbifx>
In the past I was told to delete one, but which?