companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
azimut has joined #ocaml
neiluj has joined #ocaml
Haudegen has quit [Ping timeout: 276 seconds]
masterbuilder has quit [Ping timeout: 248 seconds]
masterbuilder has joined #ocaml
spip has quit [Quit: Konversation terminated!]
<neiluj> hmmm... got an executable compiling fine with dune containing some print statements but nothing is printed
<neiluj> but with dune utop the print statements are working
<discocaml> <masterbuilder> did you flush the output buffer?
<neiluj> yep
<neiluj> oh gosh stupid mistake
<neiluj> was running dune build, not exec
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
rf has quit [Quit: Leaving]
chrisz has quit [Ping timeout: 268 seconds]
chrisz has joined #ocaml
mbuf has joined #ocaml
Haudegen has joined #ocaml
trev has joined #ocaml
bgs has joined #ocaml
Serpent7776 has joined #ocaml
bartholin has joined #ocaml
noonien has quit [Ping timeout: 250 seconds]
chrisz has quit [Ping timeout: 248 seconds]
bartholin has quit [Quit: Leaving]
hornhack has joined #ocaml
chrisz has joined #ocaml
olle has joined #ocaml
horninghack has joined #ocaml
hornhack has quit [Ping timeout: 256 seconds]
horninghack has quit [Remote host closed the connection]
horninghack has joined #ocaml
mro has joined #ocaml
hornhack has joined #ocaml
wingsorc has quit [Ping timeout: 246 seconds]
horninghack has quit [Ping timeout: 246 seconds]
noonien has joined #ocaml
chrisz has quit [Ping timeout: 252 seconds]
olle has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
chrisz has joined #ocaml
neiluj has quit [Ping timeout: 265 seconds]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
spip has joined #ocaml
mro has quit [Remote host closed the connection]
Anarchos has quit [Ping timeout: 252 seconds]
neiluj has joined #ocaml
olle has joined #ocaml
mro has joined #ocaml
mro has quit [Quit: Leaving...]
Anarchos has joined #ocaml
Anarchos has quit [Ping timeout: 252 seconds]
Anarchos has joined #ocaml
<neiluj> hellow :)
<neiluj> got an idea to generate ctypes bindings given C headers file: write a transpiler from C headers to a ctypes module, using a lexer for C headers then modify the AST to match the one from a ctype module then write the ctypes module
<neiluj> do you think that's doable, if some ocaml libraries could help?
Haudegen has quit [Quit: Bin weg.]
Anarchos has quit [Ping timeout: 276 seconds]
<discocaml> <val patate: unit Lazy.t> It should be doable, but will probably not do an elegant translation...
<discocaml> <val patate: unit Lazy.t> I was thinking about that some time ago, and I was wondering if it was not possible to do even simpler with a series of pass of regexps...
<discocaml> <val patate: unit Lazy.t>
<discocaml> <val patate: unit Lazy.t> Then refine the result based on API's conventions, for example, you may know that in your particular API, functions like
<discocaml> <val patate: unit Lazy.t> ```c
<discocaml> <val patate: unit Lazy.t> int f (t * arg);```
<discocaml> <val patate: unit Lazy.t> really mean
<discocaml> <val patate: unit Lazy.t> ```ocaml
<discocaml> <val patate: unit Lazy.t> f: t -> (t, string) result```
<discocaml> <val patate: unit Lazy.t> as your function returns `-1` on error, and sets the error message for you to get with `get_error`...
<discocaml> <val patate: unit Lazy.t> So you can automatically write better bindings, by specifying rules that your header follows...
<discocaml> <val patate: unit Lazy.t> It should be doable, but will probably not do an elegant translation...
<discocaml> <val patate: unit Lazy.t> I was thinking about that some time ago, and I was wondering if it was not possible to do even simpler with a series of pass of regexps...
<discocaml> <val patate: unit Lazy.t>
<discocaml> <val patate: unit Lazy.t> Then refine the result based on API's conventions, for example, you may know that in your particular API, functions like
<discocaml> <val patate: unit Lazy.t> ```c
<discocaml> <val patate: unit Lazy.t> int f (t * arg);```
<discocaml> <val patate: unit Lazy.t> really mean
<discocaml> <val patate: unit Lazy.t> ```ocaml
<discocaml> <val patate: unit Lazy.t> f: t -> (t, string) result```
<discocaml> <val patate: unit Lazy.t> as your function tries and modify the argument on-place, and returns `-1` on error, and sets the error message for you to get with `get_error`...
<discocaml> <val patate: unit Lazy.t> So you can automatically write better bindings, by specifying rules that your header follows...
<olle> That username.....
<neiluj> hehe
<discocaml> <val patate: unit Lazy.t> ?
<neiluj> thanks val patate: unit Lazy.t :)
<discocaml> <val patate: unit Lazy.t> My username is nice, what's the matter? ^^
<olle> Looks noisy in IRC chat
<discocaml> <val patate: unit Lazy.t> I should try IRC someday... Is it easy to use?
<discocaml> <reynir> It's really a protocol so depends on the client you use
<olle> Protocol is minimal so you can use it from anywhere
<reynir> I would say it is easy, but you can tell it's a protocol from the late eighties
<olle> Including command line
<neiluj> speaking of bindings. I've been able to write a simple ctypes binding printing the version of the C lib. But now there are some issues with includes. Basically added a stanza (headers (include "pari.h")) where pari.h includes paridecl.h, but somehow paridecl.h is not included
<discocaml> <val patate: unit Lazy.t> Yeah, installed Quassel to try it out, but didn't give it a go yet :/
<neiluj> because there's this error from dune: Fatal error: exception Dl.DL_error("./libpari__function_gen__Function_description__Function.exe: undefined symbol: ellinit")
<neiluj> where ellinit is defined in paridecl.h, which is imported by pari.h
<discocaml> <val patate: unit Lazy.t> T fix includes, I did something dirty.
<discocaml> <val patate: unit Lazy.t> I used the C preprocessor to do them for me.
<neiluj> how?
<neiluj> that's weird I added the proper paths to the header files with -I
<discocaml> <val patate: unit Lazy.t> keep in mind dune aims for ocaml projects
<neiluj> my dirty dune looks like this: https://bpa.st/PQV5A
<discocaml> <val patate: unit Lazy.t> I think it's `cpp -P <file>`
<discocaml> <val patate: unit Lazy.t> (but I can't find what -P stands for ^^ )
Haudegen has joined #ocaml
<neiluj> oh was able to fix the problem with some #pragma once, there were some redeclarations apparently
<neiluj> pragma once is not very standard, but its fine for now
count3rmeasure has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Ping timeout: 246 seconds]
rf has joined #ocaml
mbuf has quit [Quit: Leaving]
Haudegen has quit [Quit: Bin weg.]
Serpent7776 has quit [Ping timeout: 265 seconds]
Anarchos has joined #ocaml
hrberg has joined #ocaml
<neiluj> got a function with Ctypes: let output = foreign "output" (gen @-> returning void) which is supposed to print an object (gen type)
<neiluj> but when testing it it prints nothing to the standard output
<neiluj> how would you debug it?
neiluj has quit [Quit: WeeChat 3.7.1]
<Anarchos> is it possible to patch and use .opam/.../.opam-switch/build/ocaml-variants...+trunk/runtime.io.c
Anarchos has quit [Ping timeout: 268 seconds]
rak has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
rak has quit [Client Quit]
Anarchos has joined #ocaml
count3rmeasur3 has joined #ocaml
count3rmeasure has quit [Read error: Connection reset by peer]
rak has joined #ocaml
<Anarchos> is it possible to patch and use .opam/.../.opam-switch/build/ocaml-variants...+trunk/runtime.io.c ??
count3rmeasure has joined #ocaml
count3rmeasur3 has quit [Ping timeout: 260 seconds]
<companion_cube> what in heaven are you doing
<Anarchos> companion_cube i want to debug why a caml_read_fd-->>read() is blocking
deadmarshal_ has quit [Ping timeout: 260 seconds]
<Anarchos> companion_cube and as i use establish_server(), i can't put the underlying socket in non blocking mode
Haudegen has joined #ocaml
<Anarchos> companion_cube only if i comment my calculation fucntion, the read() call succeeds. I don't understand that behaviour
<companion_cube> Why would you use non blocking IOs with establish server? Iirc it starts a full process for each connection
<companion_cube> But otherwise you can just use Unix.file_descr_of_channel (or something like that)
bartholin has joined #ocaml
<companion_cube> You might want to read about how to do basic networking. Both ends should either agree on a framing format, or use a self delimited format, btw.
<companion_cube> But you probably don't need non blocking IOs
<Anarchos> companion_cube file_descr_of_channel doesn't exist, surprisingly
<Anarchos> my format is delimited by two \n. that is what i lookf for with repeated input()
<companion_cube> val descr_of_in_channel : in_channel -> file_descr
<companion_cube> val descr_of_out_channel : out_channel -> file_descr
<companion_cube> there you go
<companion_cube> use `input_line` and there you go
<Anarchos> ah descr_of_in_channel exists
<companion_cube> You haven't explained why you need non blocking IO
<Anarchos> companion_cube i want to investigate why it blocks
<companion_cube> Because it should block?
<Anarchos> so i will look what non blocking read will change
<companion_cube> It will return EAGAIN
<companion_cube> 🤷‍♂️
<Anarchos> it shoudn't block cause the send is sending a log of data
<companion_cube> Use Wireshark to see what actually goes on the wire
<companion_cube> It might be a bug in the sender
<Anarchos> companion_cube the sender is netcat, so i think there is no bug on this side
<companion_cube> Just use Wireshark man
<companion_cube> Get the actual evidence
<companion_cube> Reading lines from a socket isn't hard and it doesn't require non blocking io
<Anarchos> companion_cube it works if i do no long calculations on the data read...
<companion_cube> (??)
<companion_cube> Do you mean, you read one thing, compute with it, and then the next read fails?
<Anarchos> companion_cube yes
<Anarchos> not at first read, but actually it does that
neiluj has joined #ocaml
<companion_cube> Does the computation touch the socket in any way?
<Anarchos> no
<Anarchos> cvause the data read in the socket are copied in another command buffer
<Anarchos> and the calculation fucntion only treats the command buffer
<neiluj> (actually the binding to the function output was working)
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
<companion_cube> Does the computation function run in a thread or something?
<Anarchos> no, in same thread
<companion_cube> (you use Str?!!)
<companion_cube> seriously, use input_line, read 2 lines, and life will be 5× easier
<Anarchos> companion_cube i develop this code for more than 10years, so way before bytes...
<Anarchos> companion_cube an haikuos hacker tells me to try this code on linux
<Anarchos> companion_cube though i never tried to compile it on another os
<companion_cube> it's probably a buffer management issue
<companion_cube> (using Str for that is mega suspect)
<Anarchos> why suspect ?
<companion_cube> because you don't need Str to read lines, it's slow, non thread safe, and generally has an atrocious API
<Anarchos> companion_cube ok i will refactor htis code with 2 input_lines
<companion_cube> should get you rid of dozens of lines of buffer management
<companion_cube> read a line, read a second line, which should be empty; process the first one
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
hornhack has quit [Ping timeout: 264 seconds]
Anarchos has quit [Read error: Connection reset by peer]
<discocaml> <cemerick> what are folks using for oauth clients? I see basically nothing in opam. I guess I can ezcurl my way around 😅
<discocaml> <cemerick> lol, insert documentation examples joke here
<discocaml> <anmonteiro> 🙂 that's fair
<discocaml> <cemerick> I now remember stringing my own oauth clients together even in java and clojure, just because tying all the pieces together in the generic libraries was unreasonably confusing
oriba has joined #ocaml
<discocaml> <cemerick> even trickier in this case is determining whether the service I'm trying to call is OpenID Connect or "regular" (🤔) oauth
<discocaml> <anmonteiro> this is exactly my experience
<discocaml> <anmonteiro> I like ocaml-oidc because it let's you assemble the requests you need to send at the different parts in the flow
<discocaml> <cemerick> yeah, I can see it if I squint
<discocaml> <anmonteiro> I think there are some examples of oidc out there, perhaps @ulrikstrid remembers where they are
<discocaml> <cemerick> right this moment, I guess I'm just going to curl away, since I already went through this vendor's process with `curl` in a terminal, and it's clear what's going on with that perspective
<discocaml> <cemerick> it doesn't help that its API happens to need some weird authentication header formatting, and other unusual stuff
<discocaml> <cemerick> <rant>mandatory oauth for vanilla two-party API integrations was a massive mistake</rant>
Stumpfenstiel has joined #ocaml
<discocaml> <cemerick> ech, yeah, vendor states that the API is _not_ OIDC-compliant
<discocaml> <cemerick> sad_trombone.gif
<discocaml> <anmonteiro> OIDC compliance is about returning the userinfo endpoint I think
<discocaml> <cemerick> @anmonteiro thanks tho, will keep ocaml-oidc in my back pocket
<discocaml> <anmonteiro> you can still use the OIDC library and just do the oauth flow
<discocaml> <anmonteiro> i.e. instead of getting the discovery URLs and such, you can hardcode the endpoints yourself
<discocaml> <ulrikstrid> Hey, I think there's actually a full example in the .mli but the library has not gotten the love it deserves lately. And I've always been bad at writing docs 😬
Anarchos has joined #ocaml
<discocaml> <ulrikstrid> You can probably still use the library of they are at least somewhat compliant to oauth and I'm willing to answer questions if you have any
curium has quit [Quit: Gateway shutdown]
<discocaml> <cemerick> much appreciated 🙏
<Anarchos> companion_cube i change for 2 input_line(). same trouble
<companion_cube> (???)
<Anarchos> companion_cube the read still block
<companion_cube> Then try Wireshark
curium has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
wingsorc has joined #ocaml
count3rmeasure has quit [Quit: Leaving]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
Tuplanolla has joined #ocaml
bartholin has quit [Quit: Leaving]
bgs has quit [Remote host closed the connection]
trev has quit [Ping timeout: 250 seconds]
trev has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Stumpfenstiel has quit [Ping timeout: 255 seconds]
<discocaml> <darrenldl> neiluj: i am going to ask a very silly question - stdout flushed?
<companion_cube> I was bitten by that yesterday actually, not flushing a channel
<companion_cube> Scrambling to debug my maze of Unix.dup/dup2 and it was just flush
<discocaml> <darrenldl> im always bitten by that, sometimes in tcp land
<discocaml> <darrenldl> anyhow, Anarchos's issue reads like not flushing the stream at the right place too
azimut has joined #ocaml
trev has quit [Remote host closed the connection]