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/
Tuplanolla has joined #ocaml
darchitect has joined #ocaml
manicennui has left #ocaml [#ocaml]
jabuxas has quit [Ping timeout: 255 seconds]
Tuplanolla has quit [Quit: Leaving.]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
raskol has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
jabuxas has joined #ocaml
azimut has quit [Ping timeout: 260 seconds]
azimut has joined #ocaml
<discocaml> <contextfreebeer> that's cool! I will definitely keep my eye on this. re2c is not my favorite lexer generator to be honest, but I would definitely consider using it over what we have now
waleee has quit [Ping timeout: 240 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jabuxas has quit [Ping timeout: 256 seconds]
__jmcantrell__ has joined #ocaml
__jmcantrell__ is now known as jmcantrell
azimut has quit [Ping timeout: 260 seconds]
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
kurfen has quit [Ping timeout: 240 seconds]
kurfen has joined #ocaml
Serpent7776 has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
Serpent7776 has quit [Ping timeout: 255 seconds]
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<discocaml> <fabric.input_output> wish `Core.Bytes` had `[read/write]_[value_type]_[be/le/ne]` functions like `Stdlib.Bytes`
jmcantrell has quit [Quit: WeeChat 4.2.1]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
rgrinberg has joined #ocaml
Tuplanolla has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
bartholin has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
raskol has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Ping timeout: 255 seconds]
darchitect has quit [Ping timeout: 260 seconds]
waleee has joined #ocaml
Serpent7776 has joined #ocaml
romildo has joined #ocaml
darchitect has joined #ocaml
anpad has quit [Quit: ZNC 1.8.2 - https://znc.in]
anpad has joined #ocaml
oriba has joined #ocaml
a51 has quit [Ping timeout: 256 seconds]
jabuxas has joined #ocaml
jabuxas has quit [Remote host closed the connection]
jabuxas has joined #ocaml
azimut has joined #ocaml
deadmarshal_ has quit [Ping timeout: 272 seconds]
jabuxas_ has joined #ocaml
jabuxas has quit [Read error: Connection reset by peer]
Guest17 has joined #ocaml
jabuxas_ has quit [Read error: Connection reset by peer]
jabuxas has joined #ocaml
Guest17 has quit [Client Quit]
jabuxas has quit [Read error: Connection reset by peer]
jabuxas_ has joined #ocaml
hsw_ has joined #ocaml
hsw has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 260 seconds]
deadmarshal_ has joined #ocaml
raskol has joined #ocaml
waleee has quit [Ping timeout: 272 seconds]
szkl has joined #ocaml
azimut has quit [Ping timeout: 260 seconds]
<discocaml> <pmetzger> I used to have a low opinion of it because of how messy it seemed to be. I completely changed my mind after using it on a few projects. The way it lets you deal with the state machine is nearly unique and (I have now decided) really important for production work. Also, re2c has had serious algorithmic improvements in how things like submatch handling are done that are also impressive.
azimut has joined #ocaml
rgrinberg has joined #ocaml
jabuxas_ has quit [Ping timeout: 260 seconds]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
rgrinberg has quit [Ping timeout: 264 seconds]
deadmarshal_ has quit [Ping timeout: 264 seconds]
rgrinberg has joined #ocaml
<discocaml> <fabric.input_output> is `In_channel` like `io.Reader` in golang?
deadmarshal_ has joined #ocaml
<discocaml> <fabric.input_output> ok nvm it isn't, `In_channel.t` is more like `FILE*` in C
<discocaml> <fabric.input_output> what's an `io.Reader` equivalent though
<companion_cube> There's not really an established one
<companion_cube> And that makes me very sad
<discocaml> <fabric.input_output> 😭
<discocaml> <fabric.input_output> is there any workaround?
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
average has joined #ocaml
<dh`> what is an io.Reader?
<discocaml> <fabric.input_output> https://pkg.go.dev/io#Reader
<discocaml> <fabric.input_output> you see this as `std::istream` in c++
<discocaml> <fabric.input_output> or `std::io::Read` in rust
<discocaml> <fabric.input_output> and probably `Read` in haskell or something
<dh`> std::istream is the same as a FILE* so I don't understand
<discocaml> <fabric.input_output> no, `std::fstream` is more like `FILE *`
<discocaml> <fabric.input_output> `std::istream` is some sort of abstract class that defines an interface for reading values and data from some source
<dh`> (there's a slightly different version in linux too)
<dh`> but I take your point
<dh`> there is no such thing in the ocaml stdlib
<discocaml> <fabric.input_output> I guess I'll have to make my own "struct o' functions" thingy
<discocaml> <fabric.input_output> or use a lib
<discocaml> <bluddy5> companion_cube is working on iostream https://github.com/c-cube/ocaml-iostream
<discocaml> <bluddy5> but I don't know if it's stable enough from his perspective yet
romildo has quit [Quit: Leaving]
<companion_cube> dh`: FILE is not extensible
<companion_cube> Well I just released iostream 0.2
<discocaml> <bluddy5> have you benchmarked the performance?
<companion_cube> Not particularly, but the most important thing is buffering anyway
<companion_cube> It's objects now
<companion_cube> And that does improve the API a lot
<discocaml> <bluddy5> buffering bypasses the method calls?
<companion_cube> Sure, once you have refilled the buffer you can use it
<discocaml> <fabric.input_output> would be good to have a `read_byte` or `read_char` function in `In`, I'll have to make a temp 1 byte long buffer and read into that
<discocaml> <fabric.input_output> would be good to have a `read_byte` or `read_char` function in `In`, I'll have to make a temp 1 byte long bytes object and read into that
<companion_cube> If you're looking at iostream, what you want is In_buf.t
<companion_cube> Cause that's what buffering is for
<discocaml> <fabric.input_output> do I have to `to_seq -> get 1 char from seq -> from_seq`?
<discocaml> <fabric.input_output> cuz there's still no `read_char` or `read_byte` function
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
<companion_cube> Oh yeah, right. I have it in another project. But you can use fill_buf and read the first char from there
<companion_cube> And then consume it
<discocaml> <fabric.input_output> is the slice a view or a copy?
<discocaml> <fabric.input_output> or is it just the entire buffer
<companion_cube> The slice is the internal buffer
<companion_cube> There's no implicit copy
<companion_cube> (it's inspired by rust's BufReader)
<discocaml> <fabric.input_output> I'm still a beginner in ocaml, so I have a question: I can create my own specialized types and functions that work like `In_buf` because the things are defined with `class` and `class` works kinda like in haskell, or like a trait in rust or an interface in a few other languages?
<discocaml> <fabric.input_output> because for example I might need to have a `In_buf.t` thingy that reads from a network or something else
<discocaml> <Kali> classes are functions that produce objects (subtypeable structs, essentially); you're probably looking for modules (which have the implementation/interface duality you're talking about)
jabuxas has joined #ocaml
<discocaml> <Kali> classes can't hide information about types, but modules can
<discocaml> <Kali> they also have better performance
<discocaml> <Kali> classes are sometimes necessary of course, or they wouldn't exist, but for code organization you want moduels
<discocaml> <Kali> * modules
<discocaml> <fabric.input_output> I mean, I'll have to do something like this
<discocaml> <fabric.input_output> ```haskell
<discocaml> <fabric.input_output> decode :: (Read reader) => reader -> thing
<discocaml> <fabric.input_output> ```
<discocaml> <fabric.input_output> or
<discocaml> <fabric.input_output> ```rust
<discocaml> <fabric.input_output> fn decode<Reader: std::io::Read>(reader: &mut Reader) -> Thing { ... }
<discocaml> <fabric.input_output> ```
<discocaml> <._null._> Don't post messages with newlines in this channel, the bridge to IRC doesn't like them
<discocaml> <fabric.input_output> lol
<discocaml> <fabric.input_output> ok
<discocaml> <Kali> perhaps move to #beginners?
<companion_cube> You can easily make instances of In_buf.t
<companion_cube> Either with an object literal (`object... end`) or a class
<discocaml> <fabric.input_output> I mean, since it's `class type` I can make specialized instances of it right?
<companion_cube> Yep
<discocaml> <fabric.input_output> ok thanks
<companion_cube> For example I make new ones in iostream-camlzip
<companion_cube> As a useful example of stream transformations
<companion_cube> With the stdlib's channels you literally cannot make a (de)compressed in_channel :(
<discocaml> <fabric.input_output> tbh all I wanted for now was an `in_channel` that reads from a `string` or `bytes`
<companion_cube> Yep
<companion_cube> 🤷
<discocaml> <bluddy5> This is one of those things that isn't so simple to do in ocaml. You basically need to use objects to make it a good experience, but ocaml programmers don't like using its objects very much.
<discocaml> <Kali> a little funny, given it's in the name
<discocaml> <bluddy5> yep
<discocaml> <bluddy5> there are a bunch of other possible ways, but none of them is as clean as just using objects, which is why none of them has been adopted by the stdlib
<companion_cube> Idk why none has been adopted by the stdlib. My impression is that the core maintainers don't care that much about IO really
<companion_cube> (which is weird because Xavier has at least one library with a similar OO abstraction)
torretto has quit [Remote host closed the connection]
torretto has joined #ocaml
<discocaml> <idontwantausernamefeckoff> still a pet peeve of mine that the only thing Eio took feedback on was abstracting away objects because jane street are allergic to hashtags
<discocaml> <idontwantausernamefeckoff> *the hash key
Serpent7776 has quit [Ping timeout: 268 seconds]
<discocaml> <ulugbek3209> A dune build produces a file at `_build/default/src/vscode_ocaml_platform.bc.js` but I need it at `dist/vscode_ocaml_platform.bc.js` . How can I make dune to either output directly the output js file to `dist/` or copy the produced file afterwards?
bartholin has quit [Quit: Leaving]
<companion_cube> ahah right?
<discocaml> <idontwantausernamefeckoff> found it very funny when i opened the source code for stdenv and it’s just a bunch of one line wrappers for method calls
<companion_cube> It's not necessarily a bad idea, it gives better error messages
<companion_cube> But using # in types is really more ergonomic than anything else ocaml offers (records of functions, modules)