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
ziyourenxiang has quit [Quit: Leaving]
ziyourenxiang has joined #ocaml
jao has quit [Ping timeout: 256 seconds]
dinosaure has quit [Ping timeout: 256 seconds]
silver has quit [Read error: Connection reset by peer]
CcxWrk has quit [Quit: ZNC 1.6.5 - http://znc.in]
CcxWrk has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 260 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
pierpa has quit [Quit: Page closed]
tormen_ has joined #ocaml
tormen has quit [Ping timeout: 248 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
FreeBird_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 268 seconds]
cobreadmonster has joined #ocaml
Fare has joined #ocaml
Fare has quit [Ping timeout: 276 seconds]
Fare has joined #ocaml
Fare has quit [Ping timeout: 248 seconds]
cbot has joined #ocaml
sophiag has joined #ocaml
kakadu has joined #ocaml
cobreadmonster has quit [Quit: Connection closed for inactivity]
<sophiag> does anyone here use nixos? i have some ocaml packages installed through there, but dune/jbuilder can't find them. normally i just ignore this if i'm busy, but one has a c dependeny and nixos isn't supported by opam-depext :/
<sophiag> fwiw, i just needed to launch a nix-shell with the specific package :p
TarVanimelde has joined #ocaml
cbot has quit [Quit: Leaving]
LPeter1997 has joined #ocaml
<discord> <rgrinberg> dune looks up packages from 2 sources: * It's workspace * The "current" findlib install path (discovered from env vars or the ocamlfind tool)
<discord> <rgrinberg> so there are 2 options for you to make the library available to dune
<LPeter1997> I'm handwriting a lexer and I'd like some advice. What would be better (in terms of identical OCaml)? A state that I mutate and I return a token or an immutable state and I return a new state with a token?
<companion_cube> a mutable state is perfectly fine for a lexer
<LPeter1997> Right. And what if I encounter something that just needs to be skipped (like a comment)? Is recursion a good choice here? I know these are weird questions but I've never touched anything functional before :D
<companion_cube> yes, recursion is fine
<companion_cube> in general, what you'd write as a non trivial loop in C/java/… will be a tailrec function in OCaml
<companion_cube> (since there is no early return/break/continue)
<LPeter1997> I'm guessing TCO will yield the same anyway
<companion_cube> let rec next_token (st:token_state) : token option = …
<companion_cube> yep!
<LPeter1997> It's so fun to hack in this language it's incredible.
<companion_cube> it's pretty expressive :)
<LPeter1997> It does not give you too much stuff like C++
pierpal has quit [Ping timeout: 260 seconds]
zolk3ri has joined #ocaml
TarVanimelde has quit [Quit: TarVanimelde]
shinnya has quit [Ping timeout: 244 seconds]
jao has joined #ocaml
pierpal has joined #ocaml
pierpal has quit [Remote host closed the connection]
letoh has quit [Read error: Connection reset by peer]
letoh has joined #ocaml
<LPeter1997> Is there an if let <parrent> = <expr> then ... construct?
<LPeter1997> *pattern (can't type)
malina has quit [Ping timeout: 276 seconds]
<dmbaturin> LPeter1997: You mean a way to introduce a variable in the middle of a conditional?
<dmbaturin> I think not.
<LPeter1997> dmbaturin: Alright, fair enough. I thought that rust borrowed that construct from OCaml or something.
<dmbaturin> I'm not even sure if I would like to have that construct in ML or not. :)
<LPeter1997> Another stupid question. My lexer requires 1 or 2 characters of lookahead. Is it worth to explode the string into a list so that I can pattern match easier?ű
Guest68104 has joined #ocaml
mfp has joined #ocaml
<dmbaturin> LPeter1997: Why? You can get a character from string by index, s.[i]
<dmbaturin> Though in an educational implementation exploding into list may have advantages.
<LPeter1997> dmbaturin: Yep, but I'll have to watch out for over-indexing. And it kinda makes the whole thing a lot more ugly.
<dmbaturin> Why? Pass the index in the tail call, match on the retrieved character(s).
<LPeter1997> Well, for example '/' is a token. But '/*' is the beginning of a nested comment. So I would have to branch in the case of a '/'. And pattern matching on lists can just do this without branching.
<LPeter1997> In case of a '/', first I'll have to check if there is even a character after it. Then I'll have to check if it's a '*' or a '/' (single- or multi-line comment)
<LPeter1997> But I'm in no means expert (in fact I'm a complete noob in OCaml)
<dmbaturin> I probably would pass / to a continuation that branches either to token or to a function that reads comment.
<Drup> I would just use sedlex :D
<LPeter1997> Huh I always forget CPS is a thing...
<LPeter1997> Drup: Yeah, I'll eventually use a lexer generator but I need to practice the language in less dangerous places first. I don't want to mess up semantic checking for example :D
<LPeter1997> (Of course I will but I don't want to blame it on my lack of language knowledge)
<Drup> I'm not sure I undertand what that means. You have more chances to mess up by writing your lexer by hand instead of using appropriate tools
<LPeter1997> Drup: I'm writing a compiler, and it's far easier to debug a lexer than a semantic analyzer. So I'm practicing OCaml a bit by writing a lexer first (I've never touched it before)
jnavila has joined #ocaml
<dmbaturin> I think it's a bit like that saying about OS development, "if you start with bootloader that's also where you'll stop" :)
<LPeter1997> dmbaturin: Lol that is so true!
<dmbaturin> (Implying if a kernel is what you want to write, better just use something like GRUB, else you'll spend a lot of time solving problems unrelated to the kernel)
<Drup> Yeah, I don't think your approach is particular useful LPeter1997, Just get lexing/parsing out of the way as quickly as possible and jump into the interesting part
<dmbaturin> Obligatory link to something by Oleg. ;)
jnavila has quit [Ping timeout: 240 seconds]
<Drup> It's like XKCD, there is always a relevant work by Oleg
<dmbaturin> It's basically an illustation for https://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/ even though the latter was written later. :)
<dmbaturin> Drup: Sounds like a recipe for promoting FP: convert Oleg's works to a comic strip format. ;)
shinnya has joined #ocaml
<Drup> dmbaturin: https://ro-che.info/ccc/15
<dmbaturin> Lol. First time I see this comic, not sure how I missed it.
argent_smith has joined #ocaml
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 256 seconds]
Guest68104 has quit [Remote host closed the connection]
jnavila has joined #ocaml
<LPeter1997> Is there a builtin for List to get the nth tail?
shinnya has quit [Quit: ZNC - http://znc.in]
<Drup> LPeter1997: CCList.drop
<LPeter1997> Thanks!
shinnya has joined #ocaml
pierpal has joined #ocaml
dhil has joined #ocaml
octarin has joined #ocaml
jnavila has quit [Ping timeout: 240 seconds]
mk9 has joined #ocaml
dhil has quit [Quit: Quit]
dhil has joined #ocaml
dhil has quit [Remote host closed the connection]
dhil has joined #ocaml
<LPeter1997> I have tried to separate an interface form my implementation file. Because I need to access it from outside the module, the definition is in the foo.mli. But I get an error in the foo.ml that it's an unbound type ctor.
mk9 has quit [Quit: mk9]
dhil has quit [Quit: Leaving]
<mrvn> LPeter1997: it has to be in both mli and ml
<LPeter1997> mrvn: So it isn't enough to just declare it in the .ml? So I would be better off just to define it in a separate module to make it public?
<dmbaturin> It's the advantage of proper module systems.
<dmbaturin> It will also not compile if types in .ml and .mli don't match.
<mrvn> The type in mli can be abstract or private compared to the one in ml
<dmbaturin> Yes, they don't need to be the same, they just cannot be incompatible.
<dmbaturin> Which means if you forget to update module signatures, you are quickly caught.
<mrvn> but yes, putting types in a ml without mli and importing that can mean less duplication.
<LPeter1997> The module system looks really awesome. It's hard to understand it after no modules (C/C++)
shinnya has quit [Ping timeout: 276 seconds]
<LPeter1997> Thanks for the suggestions! :)
<dmbaturin> Ironically, the basic idea of that module system style is almost contemporary with C, it comes from Modula-2.
mk9 has joined #ocaml
<LPeter1997> Is that the other language of the creator of Pascal?
<dmbaturin> Yes. One of the long list of languages he created. ;)
<dmbaturin> His latest one is called Oberon.
BitPuffin has joined #ocaml
<LPeter1997> Oh I see he loved the word 'PROCEDURE' :D
<LPeter1997> Is there a recommended build-system/build-generator? Can I use CMake?
<Drup> LPeter1997: dune
<mrvn> you can but I recommend ocaml
<mrvn> with oasis
<dmbaturin> Well, clear separation between subroutines called just for their side effects and those that produce values isn't a bad idea.
<mrvn> aeh, oasis with ocaml.
<dmbaturin> In a language that has no concept of unit type anyway.
pierpal has quit [Quit: Poof]
<mrvn> dmbaturin: and then we got methods
pierpal has joined #ocaml
<LPeter1997> dmbaturin: True!
<dmbaturin> LPeter1997: If you want to see a modern language coming from that tradition, you should try Ada.
<dmbaturin> Really nice type system, even if absolutely not MLish. It has type-safe parametric polymorphism (in form of generics, of which C++ templates is a type-unsafe imitation).
<LPeter1997> I've actually used Ada a bit, it was very nice. It felt similar to Eiffel (or maybe my memory is just fuzzy now).
<Drup> dmbaturin: nowadays, you might as well use rust really ...
<LPeter1997> Ahh... As far as I can see, no build system is supported for ocaml on Windows.
<mrvn> windows runs linux software so you have plenty of choice there
<LPeter1997> Developing on a Linux subsystem? Maybe...
<LPeter1997> At least I remember Debian stuff a bit.
<dmbaturin> Drup: Can Rust do separate compilation now?
TheLemonMan has joined #ocaml
<Drup> It couldn't before ?
<dmbaturin> At least a while ago its separate compilation abilities seemed quite poor. I hope it's improved, that's why I ask.
mk9 has quit [Quit: mk9]
slash^ has joined #ocaml
<LPeter1997> Can you do out-of-source build with oasis?
<Drup> It's the case by default
<Drup> but use dune, it does everything that oasis does, but better
<LPeter1997> Drup: Okay, I'll give that a shot
<Drup> (and it's far more future-proof)
steenuil has quit [Read error: Connection reset by peer]
steenuil has joined #ocaml
<dmbaturin> Drup: I should try dune finally. Future-proof in what ways?
<Drup> It's actively developed
<LPeter1997> What editor do you use? I'm using VSCode but the syntax highlight is off at a lot of places.
<dmbaturin> Emacs!
<presiden> Vim!
<octarin> Ed!
<reynir> Magnetized needle and a steady hand!
<presiden> ah, the old M-X Butterfly
<LPeter1997> reynir: Lol
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<dmbaturin> reynir: It doesn't work with non-magnetic media such as punched cards!
<steenuil> ed, man!
<dmbaturin> Well, ok, it kinda does, but the needle doesn't need to be magnetized.
<Armael> isn't dune supposed to work on windows?
<Armael> from the readme: "
<Armael> Especially, one can install OCaml on Windows with a binary installer and then use only the Windows Console to build dune and packages using dune."
<Armael> sounds like it should work
<Drup> dune is definitely supposed to work on windows
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 245 seconds]
slash^ has quit [Read error: Connection reset by peer]
ziyourenxiang has quit [Ping timeout: 260 seconds]
<dmbaturin> How's opam on windows doing?
cbot has joined #ocaml
dtornabene has joined #ocaml
malina has joined #ocaml
nullifidian_ has joined #ocaml
nullifidian has quit [Ping timeout: 260 seconds]
jnavila has joined #ocaml
tane has joined #ocaml
cbot has quit [Quit: Leaving]
FreeBird_ has quit [Remote host closed the connection]
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
pioneer42 has joined #ocaml
Fare has joined #ocaml
nullifidian_ is now known as nullifidian
malina has quit [Ping timeout: 264 seconds]
jao has quit [Ping timeout: 256 seconds]
<discord> <rgrinberg> dune indeed works on windows
<discord> <rgrinberg> Adding the confirmation here because "supposed to" isn't quite strong enough 😃
mk9 has joined #ocaml
Fare has quit [Ping timeout: 256 seconds]
malina has joined #ocaml
mk9 has quit [Quit: mk9]
Fare has joined #ocaml
LPeter1997 has quit [Quit: Page closed]
tane has quit [Quit: Leaving]
Jesin has quit [Quit: Leaving]
Haudegen has joined #ocaml
Jesin has joined #ocaml
dtornabene has quit [Read error: Connection reset by peer]
dtornabene has joined #ocaml
tezos_noob has joined #ocaml
dtornabene_ has joined #ocaml
dtornabene has quit [Ping timeout: 240 seconds]
<tezos_noob> Hello. when i see this line of code : type error += Explosion_failure of string * int;;. How do i read this. Is this filling the hole in the functor module with the Explosion_of_failure in this example. Is there a term for this so i can look this up. The special symbols are killing goog.
dtornabene__ has joined #ocaml
dtornabene_ has quit [Read error: Connection reset by peer]
<tezos_noob> octachron, thank you. let me read that.
pioneer42 has left #ocaml [#ocaml]
shinnya has joined #ocaml
dtornabene__ has quit [Quit: Leaving]
jao has joined #ocaml
Soni has quit [Ping timeout: 268 seconds]
jack5638 has quit [Ping timeout: 248 seconds]
jack5638 has joined #ocaml
Soni has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
pierpa has joined #ocaml
malina has quit [Ping timeout: 276 seconds]
zolk3ri has quit [Remote host closed the connection]
argent_smith has quit [Quit: Leaving.]
Fare has quit [Ping timeout: 276 seconds]
malina has joined #ocaml
mali__ has joined #ocaml
malina has quit [Remote host closed the connection]
jnavila has quit [Remote host closed the connection]
tezos_noob has quit [Ping timeout: 265 seconds]
octarin has quit [Quit: leaving]
<dxtr> List.fold_left (fun acc t -> acc) 0 [] <- That gives me "This epxression has type int but an epxression was expected of type 'a -> 'b -> 'c". How come?
BitPuffin has quit [Remote host closed the connection]
<lyxia> dxtr: you need to look around that to understand why ('a -> 'b -> 'c) is expected.
<dxtr> Look around?
<dxtr> Oh.. okay
pierpal has quit [Ping timeout: 240 seconds]
tezos_noob has joined #ocaml
kakadu has quit [Remote host closed the connection]
mk9 has joined #ocaml
Haudegen has quit [Remote host closed the connection]
mk9 has quit [Quit: mk9]