adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.06.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.06/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
kvda has joined #ocaml
Haudegen has quit [Remote host closed the connection]
pioneer42 has joined #ocaml
Fare has quit [Ping timeout: 260 seconds]
pierpal has quit [Ping timeout: 276 seconds]
malina has quit [Remote host closed the connection]
Fare has joined #ocaml
ziyourenxiang has joined #ocaml
Fare has quit [Ping timeout: 260 seconds]
jbrown has quit [Remote host closed the connection]
silver has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
cbot has quit [Ping timeout: 240 seconds]
mk9 has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
phvse has joined #ocaml
ygrek has quit [Ping timeout: 264 seconds]
pierpal has joined #ocaml
Fare has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
phvse has quit [Quit: Konversation terminated!]
Fare has quit [Ping timeout: 240 seconds]
Fare has joined #ocaml
mfp has quit [Ping timeout: 256 seconds]
pierpa has quit [Quit: Page closed]
shinnya has joined #ocaml
tormen has joined #ocaml
pierpal has joined #ocaml
tormen_ has quit [Ping timeout: 276 seconds]
cbot has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 244 seconds]
Soni has quit [Ping timeout: 260 seconds]
Soni has joined #ocaml
neatonk1 has joined #ocaml
neatonk has quit [Ping timeout: 260 seconds]
neatonk1 is now known as neatonk
gtrak has quit [Ping timeout: 240 seconds]
ziyourenxiang has quit [Ping timeout: 240 seconds]
jimt has quit [Quit: WeeChat 1.9.1]
jimt has joined #ocaml
kvda has joined #ocaml
talyian has quit [Quit: Page closed]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zv has quit [Ping timeout: 256 seconds]
raduom has joined #ocaml
zv has joined #ocaml
zv has quit [Ping timeout: 244 seconds]
Fare has quit [Ping timeout: 260 seconds]
zv has joined #ocaml
mk9 has quit [Quit: mk9]
ziyourenxiang has joined #ocaml
kakadu has joined #ocaml
steenuil has joined #ocaml
FreeBirdLjj has joined #ocaml
steenuil has quit [Ping timeout: 276 seconds]
kvda has joined #ocaml
kvda has quit [Ping timeout: 240 seconds]
cbot has quit [Quit: Leaving]
argent_smith has joined #ocaml
shinnya has quit [Ping timeout: 248 seconds]
LPeter1997 has joined #ocaml
<LPeter1997> Hi! Beginner OCaml user here. Is the default evaluation strategy eager? I want to write an inner function without parameters but I suspect that it gets evaluated anyway. Is it better to use an empty tuple parameter?
<companion_cube> yes, OCaml is eager, and yes, `let f = <expr>` is evaluated right away
<companion_cube> `let f () = <expr>` is how you write it
<companion_cube> (it's not really an empty tuple, but the unit type)
<LPeter1997> companion_cube: Alright, so I was on the right track. Thank you!
<dmbaturin> LPeter1997: There's also the Lazy module.
<companion_cube> yes, it's a different thing though
<LPeter1997> Isn't the definition of unit is that it's an empty tuple? Or is it just a notation thing?
<companion_cube> it's just a notation thing :)
<dmbaturin> There's no such thing as empty tuple in ML at all actually.
<LPeter1997> Alright, thanks guys, I'm glad that I've finally checked out this language.
<dmbaturin> LPeter1997: Lazy example: "Lazy.force @@ lazy (print_endline "hello world") ;;"
<companion_cube> LPeter1997: cool! don't hesitate to ask other questoins :)
<companion_cube> and good luck
<LPeter1997> I'm sure I'll have to ask more questions eventually, thank you both for the fast and nice responses!
<companion_cube> are you learning via a book? or some online resource?
<LPeter1997> I've picked up "Real world OCaml" and I'm reading the chapters I need in the situations I encounter.
<companion_cube> ok, consensus is that it's a good book ;)
<dmbaturin> Yes, but you should not that it teaches an alternative standard library. There's nothing wrong with that library per se, but you should be aware of it.
<dmbaturin> * should note
<LPeter1997> It is indeed nice, it's not like a "let's teach from scratch" kind of book (which I wanted to avoid, I know imperative stuff and functional basics).
<dmbaturin> There are alternative libraries that are not shadowing any built-in functions, such as Batteries and Containers.
<LPeter1997> dmbaturin: Oh yes it was a gotcha early on, I'm not entirely sure what I'm using right now (I guess the default?).
<companion_cube> it's still based on Core, afaik, which is janestreet's alternative stdlib
<dmbaturin> With Core, you either go all in, or not use it. It also sometimes determines which other libraries are available, for example very popular library for concurrency (Lwt) is incomptaible with Core.
<dmbaturin> (Which is one of the reasons I don't use Core, I like Lwt :)
<LPeter1997> I've heard that OCaml struggles with multi-core concurrency. Does Lwt solve that?
<dmbaturin> Lwt is mostly a cooperative multitasking. I haven't checked the status of the multicore runtime in a while to be fair.
<LPeter1997> A module question: As far as I understand for modules, there are '.ml' and '.mli' files. A '.mli' defines the public interface of the '.ml'. If there is no '.mli', everything is considered public. Correct?
<dmbaturin> It's been improving, but for me it's not a pressing need so I only check once in a while.
<dmbaturin> Uhm, will it compile at all if .mli is missing? :)
<dmbaturin> I don't remember, I always add them.
<LPeter1997> dmbaturin: I don't know TBH. I think it just generates it then, but this is just a shot in the dark. Are there other kinds of files to be aware of?
<octachron> LPeter1997, yes, without a mli file, the compiler infers an interface from the implementation where everything is visible
<dmbaturin> Ah, yes, everything is visible (just tested).
<companion_cube> LPeter1997: source code is ml or mli
<companion_cube> then there's mll (lexer) and mly (parser) which are relatively common (think lex/yacc)
<companion_cube> the rest is a bunch of compiler-generated file formats
<LPeter1997> companion_cube: I'm actually writing a lexer right now by hand. It's a fun exercise (and required for my project).
<dmbaturin> If you want to make the compiler infer an .mli, use ocamlc -i file.ml > file.mli
<octachron> dmbaturin, note that this is not guaranteed to work without manual editing
<companion_cube> LPeter1997: that's nice when you learn. But otherwise it's probably better to use generator tools (ocamllex, ulex, sedlex…)
<dmbaturin> octachron: Well, it will almost certainly work for trivial cases. :)
<LPeter1997> companion_cube: Yeah, I was told so. But I didn't like lex and yacc and I'm used to just handwriting them. And it's a nice opportunity to practice the language a bit before the dirty work begins ;)
<companion_cube> heh, sure
<companion_cube> writing parsers with menhir is much better than yacc, though
<dmbaturin> Menhir is an LR(1) generator for a more civilized age.
<companion_cube> (depending on what kind of thing you parse of course)
<LPeter1997> I'll check out Menhir! Well it's a C-ish language but it's modified to be CF.
<dmbaturin> No lexer hack needed? :)
<LPeter1997> dmbaturin: Nope, this was a must early on. I wanted clear separation between the lexing and parsing stages.
<companion_cube> neat, then menhir might be very helpful for you
<companion_cube> e.g. the reason parser is written with Menhir
<LPeter1997> Is it both a lexer and parser generator?
<dmbaturin> Reason = alternative ML syntax option. companion_cube's sentence is not missing anything. ;)
<LPeter1997> How good is error reporting?
<dmbaturin> No, Menhir is an LR(1) generator only, it needs a lexer. You can easily follow the interface it expects in a handwritten lexer though.
<companion_cube> afaik, menhir's error reporting is pretty good if you work for it
<companion_cube> you can insert error cases in every rule
<companion_cube> also error recovery is possible, I think merlin uses it
* dmbaturin needs to work for it
<dmbaturin> Compcert has a great example.
<LPeter1997> Huh, indeed Menhir looks promising!
<companion_cube> it also has parametrized rules ;-)
<LPeter1997> Is there character categorization in the default library? Something like ctype.h in C?
<companion_cube> there's stuff in Char for ascii
<companion_cube> for unicode you should look at Daniel Bünzli's libraries
<companion_cube> uutf, uucd, etc.
<companion_cube> uucp -- Unicode character properties for OCaml
<companion_cube> (Bünzli is known for writing very high quality libraries, with good doc)
<LPeter1997> Oh I see, thanks!
<LPeter1997> We need heroes like this in the C++ community.
<companion_cube> OCaml's advantage here is the prevalence of a package manager :)
<companion_cube> (and good abstraction boundaries)
<kakadu> Folks, can we do `opam init` without specifing a compiler. I want to do `opam init`, add a remote and specify a compiler from this remote
<companion_cube> I have no idea what opam init does these days
<companion_cube> are you using opam2?
<kakadu> at the moment 1.2
<kakadu> I
<kakadu> I'm playing with opam-android and it can't be upgraded to opam2 automatically
<kakadu> Well, it can but OCaml becomes not cross-compilable
steenuil has joined #ocaml
jao has joined #ocaml
<kakadu> it seems that opam 2.0 has --bare option which seems the one that I need
LPeter1997 has quit [Quit: Page closed]
jnavila has joined #ocaml
jao has quit [Remote host closed the connection]
moolc has joined #ocaml
Haudegen has joined #ocaml
mfp has joined #ocaml
jnavila has quit [Ping timeout: 245 seconds]
mk9 has joined #ocaml
zolk3ri has joined #ocaml
pioneer42 has left #ocaml [#ocaml]
shinnya has joined #ocaml
jnavila has joined #ocaml
mk9 has quit [Quit: mk9]
moolc has quit [Quit: ERC (IRC client for Emacs 27.0.50)]
LPeter1997 has joined #ocaml
<LPeter1997> What should be preferred? Global private functions or nested functions? I'm guessing that it depends. What should be the guideline?
eni has joined #ocaml
mk9 has joined #ocaml
<mrvn> nested functions indent so much. :)
<mrvn> If it's more than a line or two I would make it global. If it binds to local variables I would make it nested.
<mrvn> Sometimes I do both. Make a global private function and then bind it as nested function so I don't have to pass the same arguments every time.
mk9 has quit [Ping timeout: 244 seconds]
<LPeter1997> mrvn: Hmm, that's a great idea! (locally binding common parameters)
mk9 has joined #ocaml
mk9 has quit [Client Quit]
mk9 has joined #ocaml
mk9 has quit [Client Quit]
r3s1stanc3 has quit [Quit: ZNC 1.7.0 - https://znc.in]
r3s1stanc3 has joined #ocaml
r3s1stanc3 has quit [Client Quit]
r3s1stanc3 has joined #ocaml
r3s1stanc3 has quit [Ping timeout: 260 seconds]
r3s1stanc3 has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
mk9 has joined #ocaml
mk9 has quit [Client Quit]
Fare has joined #ocaml
spew has joined #ocaml
shinnya has quit [Ping timeout: 264 seconds]
spew has quit [Quit: Leaving]
LPeter1997 has quit [Quit: Page closed]
groovy2shoes has quit [Ping timeout: 265 seconds]
groovy2shoes has joined #ocaml
malina has joined #ocaml
malina has quit [Client Quit]
BitPuffin has joined #ocaml
ziyourenxiang has quit [Ping timeout: 264 seconds]
spew has joined #ocaml
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
shinnya has joined #ocaml
spew has quit [Read error: Connection reset by peer]
jao has joined #ocaml
Haudegen has quit [Remote host closed the connection]
Soni has quit [Ping timeout: 260 seconds]
Guest27952 has joined #ocaml
Guest27952 has quit [Remote host closed the connection]
bobry has quit [Quit: Connection closed for inactivity]
gtrak has joined #ocaml
cbot has joined #ocaml
Soni has joined #ocaml
Soni has quit [Ping timeout: 276 seconds]
Soni has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
silver has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 276 seconds]
FreeBirdLjj has joined #ocaml
Jesin has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
gtrak has quit [Ping timeout: 276 seconds]
Soni has quit [Ping timeout: 264 seconds]
FreeBirdLjj has joined #ocaml
cbot has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Ping timeout: 276 seconds]
gtrak has joined #ocaml
Soni has joined #ocaml
gtrak has quit [Quit: WeeChat 2.1]
neatonk has quit [Ping timeout: 240 seconds]
neatonk has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
BitPuffin has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 256 seconds]
pierpa has joined #ocaml
argent_smith has quit [Quit: Leaving.]
Fare has quit [Ping timeout: 276 seconds]
kakadu has quit [Remote host closed the connection]
jnavila has quit [Remote host closed the connection]
Fare has joined #ocaml
_whitelogger has joined #ocaml
FreeBirdLjj has joined #ocaml
Fare has quit [Ping timeout: 244 seconds]
ziyourenxiang has joined #ocaml
malina has joined #ocaml
zolk3ri has quit [Remote host closed the connection]