Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.1.1 released: https://ocaml.org/releases/5.1.1 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
nabelchol has joined #ocaml
nabelchol has quit [Client Quit]
jabuxas has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
gzar has quit [Quit: WeeChat 4.2.2]
<discocaml> <yunha9816> Can I turn off double semicolon in utop?
<discocaml> <hockletock> you can make a keyboard shortcut that adds ;; and submits the phrase but that's about it
<discocaml> <yunha9816> Oh thanks
<discocaml> <yunha9816> Is shortcut configured in ocaml or my system wide?
<discocaml> <yunha9816> Thank you
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
waleee has quit [Quit: WeeChat 4.1.2]
jabuxas has quit [Ping timeout: 256 seconds]
tri has joined #ocaml
mima has joined #ocaml
tri has quit [Remote host closed the connection]
tri has joined #ocaml
tri has quit [Ping timeout: 255 seconds]
mbuf has joined #ocaml
Tuplanolla has joined #ocaml
bartholin has joined #ocaml
<discocaml> <yunha9816> Does anybody have a experience in advent of code switch to ocaml from python?
dnh has joined #ocaml
bartholin has quit [Quit: Leaving]
Serpent7776 has joined #ocaml
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
<discocaml> <holmdunc> An implicit `;;` can be toggled on and off: https://gist.github.com/hcarty/b2dab5324d0d4344d771
torretto has quit [Ping timeout: 260 seconds]
torretto has joined #ocaml
<discocaml> <JM> Where has this been all my life 😍
<discocaml> <JM> (it goes in ~/.config/utop/init.ml in my config)
<discocaml> <holmdunc> I tweaked it a bit, including making the prompt reflect whether it's enabled: https://gist.github.com/frou/8ab47a7b10b6999329c6f37fe4144c85
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
<discocaml> <shoebum_kumar> where can I ask questions about eio?
chiselfuse has quit [Ping timeout: 260 seconds]
chiselfuse has joined #ocaml
<discocaml> <JM> There is no eio specific channel, so here is a good place to start. That would also allow whoever is using the IRC bridge to chime it.
* mbuf Reminder: OCaml Sequences module Twitch stream starting in an hour's time, today, Monday, April 29, 2024 at 2000 IST | 1630 CEST | 1530 GMT https://www.twitch.tv/shakthimaan
<discocaml> <shoebum_kumar> ok cool! so my problem is I want to create a repl using Eio and I want inputs to have a specific format and output to have a specific format using stdin and stdout from the `Stdenv` helps but I cannot modify the string.
<discocaml> <shoebum_kumar> ie. I want
<discocaml> <shoebum_kumar> ```bash
<discocaml> <shoebum_kumar> >> shubham
<discocaml> <shoebum_kumar> --||output||--> shubham
<discocaml> <shoebum_kumar> ```
<discocaml> <shoebum_kumar> I am getting this
<discocaml> <shoebum_kumar> ```bash
<discocaml> <shoebum_kumar> ❯ dune exec -- ./bin/main.exe
<discocaml> <shoebum_kumar> sad
<discocaml> <shoebum_kumar> +--||output||--> : wrote "sad"
<discocaml> <shoebum_kumar> sadasd
<discocaml> <shoebum_kumar> +--||output||--> : wrote "sadasd"
<discocaml> <shoebum_kumar> sadsaddsadsa
<discocaml> <shoebum_kumar> +--||output||--> : wrote "sadsaddsadsa"
<discocaml> <shoebum_kumar> sadasdsdasad
<discocaml> <shoebum_kumar> +--||output||--> : wrote "sadasdsdasad"
<discocaml> <shoebum_kumar> sadsaddsasdasd
<discocaml> <shoebum_kumar> +--||output||--> : wrote "sadsaddsasdasd"
<discocaml> <shoebum_kumar> assaddsasdsadsdsasaassadasdsadsd
<discocaml> <shoebum_kumar> +--||output||--> : wrote "assaddsasdsadsdsasaassadasdsadsd"
<discocaml> <shoebum_kumar> saddsadsda
<discocaml> <shoebum_kumar> +--||output||--> : wrote "saddsadsda"
<discocaml> <shoebum_kumar> ^C
<discocaml> <shoebum_kumar> ```
<discocaml> <shoebum_kumar> this was before I made use of stdout from stdenv
<discocaml> <shoebum_kumar> I was using stdout from `let stdout = Eio_mock.Flow.make "--||output||--> " `
jabuxas has joined #ocaml
<discocaml> <shoebum_kumar> this is the mwe
<discocaml> <shoebum_kumar> ```ocaml
<discocaml> <shoebum_kumar> let repl env =
<discocaml> <shoebum_kumar> let stdin = Eio.Stdenv.stdin env in
<discocaml> <shoebum_kumar> let stdout = Eio.Stdenv.stdout env in
<discocaml> <shoebum_kumar> let rec loop () =
<discocaml> <shoebum_kumar> let reader = Eio.Buf_read.of_flow stdin ~max_size:1_000 in
<discocaml> <shoebum_kumar> let str = Eio.Buf_read.line reader in
<discocaml> <shoebum_kumar> let write writer = Eio.Buf_write.string writer str in
<discocaml> <shoebum_kumar> Eio.Buf_write.with_flow stdout write;
tri has joined #ocaml
<discocaml> <shoebum_kumar> loop ()
<discocaml> <shoebum_kumar> in
<discocaml> <shoebum_kumar> loop ()
<discocaml> <shoebum_kumar> ```
tri has quit [Ping timeout: 240 seconds]
<discocaml> <shoebum_kumar> ok so I am able solve the later part
<discocaml> <shoebum_kumar> ```ocaml
<discocaml> <shoebum_kumar> ❯ dune exec -- ./bin/main.exe
<discocaml> <shoebum_kumar> shubham
<discocaml> <shoebum_kumar> --|output|--> shubham
<discocaml> <shoebum_kumar> .exit
<discocaml> <shoebum_kumar> ```
<discocaml> <shoebum_kumar> I need to format the former part
<discocaml> <._null._> Please don't post long code blocks, the bridge to IRC doesn't like them
ocra8 has quit [Quit: WeeChat 4.2.2]
Serpent7776 has quit [Ping timeout: 264 seconds]
<discocaml> <shoebum_kumar> Noted
<discocaml> <contextfreebeer> is it possible to inline calls to foreign functions?
jabuxas has quit [Ping timeout: 256 seconds]
<discocaml> <shoebum_kumar> Found the solution
<discocaml> <shoebum_kumar> I had to add a printf before reading the stdin
<discocaml> <contextfreebeer> reading through the FFI section of the manual there doesn't look like there is any way to achieve this, I think the linker is in the best position to do this but AFAICT `ld` doesn't offer this option, nor any other major linker for that matter
<dh`> there is some kind of link-time-optimization plugin interface in at least gnu ld that you could misuse for that
<dh`> but it would require support in the foreign library
<dh`> and since FFI calls are usually going to be into shared libraries it isn't going to be very workable anyway
<discocaml> <contextfreebeer> yeah, pass on that one, I was mainly just curious
<discocaml> <contextfreebeer> it would be nice to have some kind of support for inline assembly, I saw an open PR + a talk about an implementation of that, unsure of the status or whether people generally want that in the compiler though
<discocaml> <contextfreebeer> it's closed actually
tri has joined #ocaml
<discocaml> <contextfreebeer> hmm, the containing function is not super complicated though and the compiler chooses not to inline it, could just implement all of it in an external function, it doesn't allocate so I think the overhead should end up being exactly the same? I've been meaning to learn more about the FFI anyway so it's a worthwhile exercise even if I decide not to use it
tri has quit [Ping timeout: 256 seconds]
prgbln has quit [Changing host]
prgbln has joined #ocaml
chiselfuse has quit [Read error: Connection reset by peer]
chiselfuse has joined #ocaml
tri has joined #ocaml
tri has quit [Ping timeout: 260 seconds]
jabuxas has joined #ocaml
ocra8 has joined #ocaml
jabuxas has quit [Ping timeout: 256 seconds]
bartholin has joined #ocaml
<discocaml> <_shakky> hello guys
<discocaml> <_shakky> i'm learning ocaml not very hard level
<discocaml> <_shakky> i need someone to help me with a function to understand how it works
<discocaml> <_shakky> step by step, if someone wants to help me come dms, thx in advance it's about binary tree i don't think it's super hard im stuck cuz i'm not good with recursivity
<discocaml> <._null._> Ask the question here directly (but don't paste code blocks)
<discocaml> <_shakky> what is code blocks ?
<discocaml> <_shakky> i can screen ? wdym
<discocaml> <_shakky> i can screenshot ? wdym
<discocaml> <._null._> Don't copy paste too much code, the bridge doesn't like it
<discocaml> <._null._> Or go to #beginners
<discocaml> <_shakky> about 10 lines
<discocaml> <_shakky> of code
<discocaml> <_shakky> short lines
<discocaml> <_shakky> is that too much ?
<discocaml> <_shakky> oh yeah i can go there if you want
<discocaml> <._null._> Too many lines, yes. Go to the other channel, it will be fine there
tri has joined #ocaml
tri has quit [Ping timeout: 252 seconds]
Serpent7776 has joined #ocaml
tri has joined #ocaml
mbuf has quit [Quit: Leaving]
tri has quit [Ping timeout: 255 seconds]
_whitelogger has joined #ocaml
adrien has joined #ocaml
adrien has quit [Client Quit]
adrien has joined #ocaml
tri has joined #ocaml
tri has quit [Ping timeout: 240 seconds]
rgrinberg has joined #ocaml
waleee has joined #ocaml
tri has joined #ocaml
tri has quit [Ping timeout: 272 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<discocaml> <regularspatula> Is all the magic in the Lazy module to make it fast or to get around some type checking limitations or something like that?
<discocaml> <octachron> Only for optimisation's sake. Otherwise, you can reimplement `Lazy` yourself without troubles.
rgrinberg has joined #ocaml
<discocaml> <regularspatula> Thanks. I like this quote in the file: WARNING: some purple magic is going on here. Do not take this file as an example of how to program in OCaml."
<discocaml> <octachron> Basically, the runtime tries to represent a forced `Lazy.t` as the computed value without any indirection.
<discocaml> <regularspatula> I see, thanks
ocra8 has quit [Quit: WeeChat 4.2.2]
ocra8 has joined #ocaml
bartholin has quit [Quit: Leaving]
Serpent7776 has quit [Ping timeout: 246 seconds]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tri has joined #ocaml
tri has quit [Ping timeout: 252 seconds]
<companion_cube> Controversial opinion: lazy is mostly useless now :p
<companion_cube> It's not thread safe, we need a thread safe alternative
Tuplanolla has quit [Quit: Leaving.]
kaptch has joined #ocaml
kaptch has quit [Client Quit]
mima has quit [Ping timeout: 272 seconds]
chiselfuse has quit [Ping timeout: 260 seconds]
chiselfuse has joined #ocaml