rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vicfred has quit [Quit: Leaving]
<d_bot>
<mbacarella> speaking of memo
<d_bot>
<mbacarella> is there a way to memoize a multi argument function without allocating a tuple on every call?
<d_bot>
<NULL> How would you store enough information if not through a tuple ?
<d_bot>
<mbacarella> dunno!
<d_bot>
<mbacarella> I meant without allocating a tuple to a lookup
<d_bot>
<mbacarella> obviously you need to allocate to store
<d_bot>
<mbacarella> I guess this could work as a ppx
<d_bot>
<NULL> If your memoization structure is a map of maps, you could get away without allocating a tuple. Not sure it's better in the end though
<d_bot>
<NULL> Also, if you're not afraid of collisions, you could use a hash function
<d_bot>
<NULL> In any case, the first question is which map structure you want to use for that memoization
<d_bot>
<mbacarella> getting a nice interface that was low cost is the part I'm most curious about
<d_bot>
<mbacarella> if you have `val foo : a -> b -> c -> d` you can get low visual burden memoization with Memo.general from core. `let memo_foo = Memo.general (fun (a, b, c) -> foo a b c)`
<d_bot>
<mbacarella> but then you have to call it with a tuple
<d_bot>
<mbacarella> for lower memory overhead you can instead manually construct a map of map of maps and write out the logic for each lookup
<d_bot>
<mbacarella> I suppose n map lookups for n arg functions is crappy
<d_bot>
<Ambika E.> Did you have an opinion on this?
<d_bot>
<nave01314> Nvm this doesn’t work the way I misremembered it working
waleee has quit [Ping timeout: 248 seconds]
<greenbagels>
hmm
<greenbagels>
question about lwt: reading Lwt_unix.sleep, it says "sleep d is a thread that remains suspended for d seconds and then terminates."
<greenbagels>
so im writing a networked application that needs to send keepalives at a fixed time interval, so i'm thinking some kind of promise chaining of a function with itself might work
<greenbagels>
hm actually i dont think i even understand what im trying to do enough to even asked a properly formed question haha
<greenbagels>
let me just work out a simple example with just stdin/stdout
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Sankalp has quit [Ping timeout: 276 seconds]
<d_bot>
<mbacarella> is there a reasonably famous paper somewhere arguing that you should always use `match b with true -> a | false -> b` on booleans instead of `if b then a else b`?
<d_bot>
<mbacarella> (that came out weird. assume that last `b` is a `c`, nothing ore special than that going on)
<williewillus>
greenbagels: something like Lwt_engine.on_timer might be what you want?
<d_bot>
<darrenldl> greenbagels: reads like you want `select` from the unix side or `choose` from lwt
<d_bot>
<darrenldl> i.e. an event loop or sorts
shawnw has joined #ocaml
dextaa4 has joined #ocaml
dextaa4 has quit [Remote host closed the connection]
dextaa4 has joined #ocaml
hyphen has quit [Ping timeout: 256 seconds]
hyphen has joined #ocaml
gravicappa has joined #ocaml
troydm has quit [Ping timeout: 240 seconds]
troydm has joined #ocaml
olle has joined #ocaml
hsw has quit [Quit: Leaving]
dextaa4 has quit [Remote host closed the connection]
dextaa4 has joined #ocaml
hyphen has quit [Ping timeout: 256 seconds]
<gopiandcode>
anyone had any experience integrating postgres with OCaml - in particular, automating deployment + testing etc.?
<gopiandcode>
is it worthwhile setting up a docker (or should it be docker-compose?) with the postgres server
<gopiandcode>
also if that is done, how can tests be done in an automatic way?
<gopiandcode>
should I setup a custom OCaml test runner to spin up a docker environment and then run the tests inside it?
azimut has quit [Ping timeout: 240 seconds]
<d_bot>
<gantsev.denis> Your application code doesn't need to spin up docker. You have it backward : your docker must prepare environnement, and invoke a script which launches your test suit
<d_bot>
<gantsev.denis>
<d_bot>
<gantsev.denis> Ocaml has no idea it runs inside a container
<d_bot>
<gantsev.denis> You don't need docker composé if you only have 1 container to start
<gopiandcode>
gantsev.denis: no I wasn't suggesting my application code spin up a docker container
<gopiandcode>
yes indeed it should be agnostic to whether it is running in a container or not
<gopiandcode>
I'm speaking specifically about tests
<gopiandcode>
for example, maybe using a custom test runner to spin up a docker container that has a fresh untouched postgres database
<gopiandcode>
purely for testing
<d_bot>
<gantsev.denis> No
<d_bot>
<gantsev.denis> My answer remains the same
<d_bot>
<gantsev.denis>
<d_bot>
<gantsev.denis> This is doing it backwards
<d_bot>
<gantsev.denis> Your CI CD runner must start up environment, including postgres
<gopiandcode>
ah fair point
<gopiandcode>
that makes sense
<gopiandcode>
when considering CI, then it becomes obvious that the docker container should be the outermost action
<gopiandcode>
what about automating deployment + local setup?
<gopiandcode>
I've been prototyping with a sqlite db, and am now reaching the point where I need concurrent accesses to the database, and SQLITE is starting to give me busy errors, so I'm migrating to postgres
<gopiandcode>
but my schema is still in a bit of flux
dextaa4 has quit [Quit: Ping timeout (120 seconds)]
dextaa4 has joined #ocaml
<d_bot>
<gantsev.denis> My local setup is already inside a docker container, because i have incompatible lib requirements
<d_bot>
<gantsev.denis>
<d_bot>
<gantsev.denis> Sqlite can give busy errors when you aren't closing connection properly from the same application
<gopiandcode>
I'm getting BUSY errors because I have overlapping requests in Lwt presumably
<d_bot>
<gantsev.denis> Hm ok don't know about that
<gopiandcode>
using dream, I can associate each request with a SQL connection, but I also need a separate SQL connection outside of the request which is causing the issue
<d_bot>
<gantsev.denis> I don't think sqlite is a problem.. But since i haven't tried using with Lwt, i don't know
<d_bot>
<gantsev.denis>
<d_bot>
<gantsev.denis> Use the minimum setup to reproduce the same with postgres, but i bet your application is causing issues, not database
olle has quit [Ping timeout: 276 seconds]
perrierjouet has joined #ocaml
<d_bot>
<Continuation Calculus> what's the easiest way to do a single execution, of a function, in parallel, in ocaml?
<d_bot>
<Continuation Calculus> added constraint is that it has access to the memory of the main program
<d_bot>
<Continuation Calculus> it doesn't need to directly return anything, effects are enough
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
Anarchos has joined #ocaml
<Anarchos>
Is there somebody from janestreet ?
wingsorc has quit [Quit: Leaving]
<d_bot>
<octachron> @Continuation Calculus in parallel or concurrently? For the first one, access to the whole memory excludes processes (or fork), and thus the simplest option is probably OCaml 5. For concurrency, a thread (from the Thread module in the threads module) should be enough.
<d_bot>
<Continuation Calculus> in parallel
<d_bot>
<Continuation Calculus> as in, separate core
<d_bot>
<Continuation Calculus> by access to the memory though, i meant to designated pieces of memory
<d_bot>
<Continuation Calculus> not sure what you mean by _whole_ memory
<d_bot>
<octachron> Ah, that is the important distinction: if only have shared piece of memory is sufficient, you can use Bigarray to mmap a piece of memory and use that shared area to communicate between processes.
<d_bot>
<octachron> Threads are indeed implemented using time-sharing of the sequential execution of the program between threads (aka concurrency without parallelism)
<d_bot>
<Continuation Calculus> is there a lib that wraps this neatly by anychance?
<d_bot>
<Continuation Calculus> typically, spawn a new function that has access to a shared ref / bigarray
<d_bot>
<octachron> I am not sure that there are library that stops that exposes this kind of low-level primitives. Typically, https://github.com/UnixJunkie/parany implements a map/reduce api.
<d_bot>
<octachron> (ocamlnet had something similar in my memory)
<d_bot>
<Continuation Calculus> ye, i had a look at them, but seems too high level
<d_bot>
<Continuation Calculus> like, they have a notion of "returning results" and so on already
<d_bot>
<Continuation Calculus> > I am not sure that there are library that stops
<d_bot>
<Continuation Calculus> wdym? the goal is for the thing to be non stopping
<d_bot>
<octachron> I meant that people (or at least many OCaml programmers) don't like working with raw piece of memory exposed as bigarrays, so they build a higher-level API and hides the lower-level implementation details.
bartholin has joined #ocaml
<d_bot>
<Continuation Calculus> hmmmm, i see, makes sense
<d_bot>
<Continuation Calculus> so likely i should use the C API directly?
hyphen has joined #ocaml
<d_bot>
<octachron> Using the C API is another option (or nearly the same thing, mmap-ing bigarray is very close to writing C in OCaml).
<d_bot>
<Continuation Calculus> this looks super cool, thx
<d_bot>
<Continuation Calculus> so the workflow is, you create a file, `map_file` it, put it as non-shared (so that things are not flushed back to the file, throttling everything), `fork` and have both sub processes have access to the big array?
<d_bot>
<octachron> You want the shared mode to have the changes visible between processes. After verification, I was thinking of using the `MAP_ANONYMOUS|MAP_SHARED` variant to have a piece of memory not backed by a file but this not exposed in OCaml (https://github.com/ocaml/ocaml/issues/10280)
waleee has joined #ocaml
szkl has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
dextaa4 has quit [Remote host closed the connection]
zebrag has joined #ocaml
gravicappa has quit [Ping timeout: 260 seconds]
Haudegen has joined #ocaml
spip has joined #ocaml
bobo has quit [Ping timeout: 248 seconds]
waleee has quit [Quit: WeeChat 3.5]
shawnw has quit [Ping timeout: 240 seconds]
szkl has quit [Quit: Connection closed for inactivity]
gravicappa has joined #ocaml
waleee has joined #ocaml
rgrinberg has joined #ocaml
<d_bot>
<Continuation Calculus> ah, sad
<d_bot>
<Continuation Calculus> so likely C bindings then?
sparogy has quit [Ping timeout: 250 seconds]
sparogy has joined #ocaml
<d_bot>
<octachron> Yes, but it might be that the smallest binding would be to write a `map_anonymous` function by adapting the C primitive used by `map_file` .
xgqt has quit [Ping timeout: 256 seconds]
xgqt has joined #ocaml
bartholin has quit [Quit: Leaving]
Haudegen has quit [Quit: Bin weg.]
<d_bot>
<aaaaaaaaa> anyone with some knowledge in ocaml that has a few minutes to spare to help me out with switching from unit to int type?
<jtm>
aaaaaaaaa: go ahead and ask your question and someone may have an answer, no need to ask permission
<d_bot>
<ryyppy> hey! I am currently looking into ways to build OCaml binaries for m1 macs via github actions. So far GH doesn't really support M1 hardware, so I guess one needs to either host a M1 cloud server, or provide their own server with a github runner. How does the OCaml project do it? I guess there's some internal infrastructure for running M1 builds at ocamllabs. Would be interesting how they did it
<d_bot>
<octachron> For the compiler itself, we have a Jenkins CI at Inria with a handful of "exotic" hardwares and OS (or an ssh access to exotic hardwares for the s390x port).
<d_bot>
<ryyppy> @octachron so you are hosting the hardware yourself?
waleee has quit [Ping timeout: 260 seconds]
waleee has joined #ocaml
<d_bot>
<octachron> For the compiler itself, yes. (well except for IBM mainframe).
<d_bot>
<octachron> That works for the compiler since it is not a really change intensive project. We may have two or three dozen of CI runs on a very busy day?
Corbin has quit [Quit: Corbin]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Corbin has joined #ocaml
<d_bot>
<ryyppy> right
<d_bot>
<ryyppy> i am a little hesitant on hosting our own server due to security concerns on public github repos
<d_bot>
<octachron> Ah yes, we are only checking merged commits and exposing a service to check PRs that might be architecture/OS sensitive to internal contributors. So security concerns are delegated to github.
<d_bot>
<octachron> The opam-repository have a much more extensive CI setup at ocamllabs but I don't know the details.
waleee has quit [Ping timeout: 256 seconds]
azimut has joined #ocaml
Haudegen has joined #ocaml
<d_bot>
<mbacarella> i don't know. what's why i'm curious to read the paper!
<d_bot>
<EduardoRFS> We have esy running on M1 for a while
<d_bot>
<EduardoRFS> like on github actions, you can run the runner in rosetta, wrap the binary with `arch` and then it runs as arm64