companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Haudegen has quit [Quit: Bin weg.]
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 252 seconds]
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
LainIwakura has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 248 seconds]
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 252 seconds]
myrkraverk_ has joined #ocaml
chiselfuse has quit [Ping timeout: 264 seconds]
myrkraverk has quit [Ping timeout: 248 seconds]
bartholin has joined #ocaml
Tuplanolla has joined #ocaml
Serpent7776 has joined #ocaml
gentauro has joined #ocaml
chiselfuse has joined #ocaml
pi3ce has quit [Ping timeout: 248 seconds]
pi3ce has joined #ocaml
Serpent7776 has quit [Ping timeout: 245 seconds]
Haudegen has joined #ocaml
wbooze has quit [Ping timeout: 248 seconds]
wbooze has joined #ocaml
<discocaml> <lost.ray> Any problems with OCaml on MacOS with ARM chips? Thinking about buying M4 Pro...
<discocaml> <octachron> There are quite few core maintainers on MacOS ARM64, so there are no major issues. There are from time to time ephemeral minors issue after Xcode update because Apple is bit too keen on breaking backward compatibility on their compiler toolchain.
<hanker> Hey hey
<hanker> for anyone pro with Lwt, is there a way to turn an `'a -> 'b Lwt.t` into an `('a -> 'b) Lwt.t` ?
<octachron> That doesn't sound possible in general: if the monadic effect of "'a -> 'b Monad.t" is dependent on the input "'a", you cannot compute before the input is available.
Serpent7776 has joined #ocaml
<hanker> Oh, yeah, that makes sense
<hanker> What about the more specific case `unit -> 'a Lwt.t` to `(unit -> 'a) Lwt.t` ?
<hanker> I have an interface that needs an `f` to call repeatedly to get elements, and I'd like to feed these elements from an `Lwt_stream`
CalimeroTeknik has quit [Changing host]
CalimeroTeknik has joined #ocaml
<octachron> `f () >>| fun x () -> x` (or `f () >>= Fun.const`) aka starts the effect and wraps the result inside a `fun () -> ... ` lambda.
LainIwakura has quit [Ping timeout: 240 seconds]
LainIwakura has joined #ocaml
<hanker> Ohh, thanks a lot!
<hanker> oh, err-
<hanker> that's slightly different from what I was looking for
<hanker> basically, it wraps the return of `f ()` into the `Fun.const`, so calling the generated function repeatedly yields the same result every time
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 248 seconds]
<hanker> I'm not sure that'd be possible though
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
Anarchos has joined #ocaml
LainIwakura has quit [Ping timeout: 240 seconds]
LainIwakura41 has quit [Ping timeout: 240 seconds]
_jbrown_ has joined #ocaml
itszor has quit [Ping timeout: 276 seconds]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 252 seconds]
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 276 seconds]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Tuplanolla has quit [Quit: Leaving.]
CalimeroTeknik has quit [Ping timeout: 252 seconds]
CalimeroTeknik has joined #ocaml
<discocaml> <gabyfle> Hello. I'm using the OCaml FFI to build up a Bigarray. I'm also using ASAN to check for possible leaks.
<discocaml> <gabyfle> I'm allocating the bigarray using this:
<discocaml> <gabyfle> ```cpp
<discocaml> <gabyfle> barray = caml_ba_alloc(type_flag | CAML_BA_C_LAYOUT, ndims, NULL, dims);
<discocaml> <gabyfle> ```
<discocaml> <gabyfle> from the documentation, it says that if the `data` pointer is null, the memory will be managed by OCaml. However, using ASAN, it detects that the memory that should've been managed by OCaml has leaked:
<discocaml> <gabyfle>
<discocaml> <gabyfle> ```
<discocaml> <gabyfle> ==279035==ERROR: LeakSanitizer: detected memory leaks
<discocaml> <gabyfle>
<discocaml> <gabyfle> Direct leak of 10274952 byte(s) in 2 object(s) allocated from:
<discocaml> <gabyfle> #0 0x7f4d5a9649c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
<discocaml> <gabyfle> #1 0x55cb82d6af30 in caml_ba_alloc runtime/bigarray.c:246
<discocaml> <gabyfle> #2 0x55cb825f95eb in long caml_read_audio_file<float>(long, long) /home/gabyfle/Code/soundml/_build/default/src/io/soundml_io.cxx:348
<discocaml> <gabyfle> #3 0x55cb82dd2bbe in caml_c_call runtime/amd64.S:736
<discocaml> <gabyfle>
<discocaml> <gabyfle> Direct leak of 40 byte(s) in 1 object(s) allocated from:
<discocaml> <gabyfle> #0 0x7f4d5a9649c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
<discocaml> <gabyfle> #1 0x55cb82dc4dfc in sync_mutex_create runtime/sync_posix.h:44
<discocaml> <gabyfle> #2 0x55cb82dc4dfc in caml_ml_mutex_new runtime/sync.c:77
<discocaml> <gabyfle> #3 0x55cb82dd2bbe in caml_c_call runtime/amd64.S:736
<discocaml> <gabyfle>
<discocaml> <gabyfle> Direct leak of 32 byte(s) in 1 object(s) allocated from:
<discocaml> <gabyfle> #0 0x7f4d5a9649c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
<discocaml> <gabyfle> #1 0x55cb82d6af30 in caml_ba_alloc runtime/bigarray.c:246
<discocaml> <gabyfle> #2 0x55cb82d6b42b in caml_ba_create runtime/bigarray.c:671
<discocaml> <gabyfle> #3 0x55cb82dd2bbe in caml_c_call runtime/amd64.S:736
<discocaml> <gabyfle>
<discocaml> <gabyfle> SUMMARY: AddressSanitizer: 10275024 byte(s) leaked in 4 allocation(s).
<discocaml> <gabyfle> ```
<discocaml> <gabyfle>
<discocaml> <gabyfle> Hello. I'm using the OCaml FFI to build up a Bigarray. I'm also using ASAN to check for possible leaks.
<discocaml> <gabyfle> I'm allocating the bigarray using this:
<discocaml> <gabyfle> ```cpp
<discocaml> <gabyfle> barray = caml_ba_alloc(type_flag | CAML_BA_C_LAYOUT, ndims, NULL, dims);
<discocaml> <gabyfle> ```
<discocaml> <gabyfle> from the documentation, it says that if the `data` pointer is null, the memory will be managed by OCaml. However, using ASAN, it detects that the memory that should've been managed by OCaml has leaked:
<discocaml> <gabyfle>
<discocaml> <gabyfle> ```
<discocaml> <gabyfle> ==279035==ERROR: LeakSanitizer: detected memory leaks
<discocaml> <gabyfle>
<discocaml> <gabyfle> Direct leak of 10274952 byte(s) in 2 object(s) allocated from:
<discocaml> <gabyfle> #0 0x7f4d5a9649c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
<discocaml> <gabyfle> #1 0x55cb82d6af30 in caml_ba_alloc runtime/bigarray.c:246
<discocaml> <gabyfle> #2 0x55cb825f95eb in long caml_read_audio_file<float>(long, long) /home/gabyfle/Code/soundml/_build/default/src/io/soundml_io.cxx:348
<discocaml> <gabyfle> #3 0x55cb82dd2bbe in caml_c_call runtime/amd64.S:736
<discocaml> <gabyfle>
<discocaml> <octachron> The OCaml garbage collector and runtime don't clean up at exit (because this would delay closing the program). So if the array was still alive at the end of the process this is the expected behavior. There is cleanup at exit mode for OCaml 4 (which should be back with OCaml 5.4).
<discocaml> <gabyfle> nice, thanks you :p I was afraid I was misusing the allocation of bigarrays somewhere
LainIwakura has joined #ocaml
<discocaml> <octachron> An option to remove this false positive might be to make sure that the array is not alive and call `Gc.full_major` before exiting.
wickedshell has quit [Read error: Connection reset by peer]
LainIwakura has quit [Ping timeout: 240 seconds]
LainIwakura has joined #ocaml
Serpent7776 has quit [Ping timeout: 265 seconds]
<discocaml> <tornato> alright i just wrote a rudimentary datalog interpreter in Ocaml, and I gotta say, I really like this language
<discocaml> <tornato> alright i just wrote a rudimentary datalog interpreter in Ocaml, and I gotta say, I really like this language (Ocaml)
<discocaml> <tornato> alright i just vibe coded a rudimentary datalog interpreter in a couple hours in Ocaml, and I gotta say, I really like this language (OCaml)
<discocaml> <yawaramin> it hits a sweet spot
<discocaml> <tornato> I was skeptical at first but the tooling is actually phenomenal
Tuplanolla has joined #ocaml
<discocaml> <yawaramin> they've put in a huge amount of work into it over the past few years
<discocaml> <tornato> indeed, also, the little things like being able to do
<discocaml> <tornato>
<discocaml> <tornato> ```
<discocaml> <tornato> match something with
<discocaml> <tornato> | Const c | Ident c -> ... -- this thing here, I forget what this is called
<discocaml> <tornato> | Str c -> ...
<discocaml> <tornato> ```
<discocaml> <yawaramin> i think or-patterns
bartholin has quit [Quit: Leaving]