Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.13.0 released: https://ocaml.org/releases/4.13.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
rgrinberg has joined #ocaml
olle has quit [Ping timeout: 256 seconds]
faultline has quit [Remote host closed the connection]
faultline has joined #ocaml
<d_bot> <Et7f3> structural typing => use object, ocaml has now polymorphic variant
average has quit [Quit: Connection closed for inactivity]
Haudegen has quit [Ping timeout: 268 seconds]
oriba has joined #ocaml
oriba has quit [Ping timeout: 264 seconds]
Tuplanolla has quit [Quit: Leaving.]
<d_bot> <ams> what are the requirements for a language to have hm type inference? like why cant languages like java or typescript have it?
<d_bot> <ams> even as like a linting step
<companion_cube> typescript is a lot more advanced than HM, in many ways
<companion_cube> and it's a lot more complicated because it has to accomodate crazy stuff
<d_bot> <ams> oh interesting, like what?
<companion_cube> all the kind-of-dependent stuff?
<companion_cube> keyof, singleton types, unions, flow-sensitive typing
xd1le has joined #ocaml
faultline has quit [Remote host closed the connection]
waleee has quit [Ping timeout: 260 seconds]
bobo has quit [Ping timeout: 264 seconds]
zebrag has quit [Quit: Konversation terminated!]
gravicappa has joined #ocaml
bobo has joined #ocaml
cbarrett has quit [Ping timeout: 260 seconds]
JSharp has quit [Ping timeout: 264 seconds]
kevinsjoberg has quit [Ping timeout: 260 seconds]
jyc has quit [Ping timeout: 260 seconds]
kevinsjoberg has joined #ocaml
JSharp has joined #ocaml
jyc has joined #ocaml
cbarrett has joined #ocaml
recherche has joined #ocaml
<recherche> is there is a way to get ocamldebug working well with code that is preprocessed using -pp (say, cppo)? i can't seem to set breakpoints accurately with line directives, sometimes get locations hundreds of lines away instead. and not using line directives exposes temporary filenames, so breakpoints can't be set at all
recherche has quit [Quit: Ping timeout (120 seconds)]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
gravicappa has quit [Ping timeout: 260 seconds]
recherche has joined #ocaml
<hornhack> hi, is ocaml code easier to read than common imperative code? like tail recursion vs common loop?
hendursaga has joined #ocaml
hendursa1 has quit [Ping timeout: 276 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hendursaga has quit [Ping timeout: 276 seconds]
hendursaga has joined #ocaml
bartholin has joined #ocaml
recherche has quit [Quit: Client closed]
average has joined #ocaml
greenbagels_ is now known as greenbagels
wonko has joined #ocaml
olle has joined #ocaml
mro has joined #ocaml
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> I understand there is some problem with parsing applications rules (x y z is ambiguous), but how can I solve this ?
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ```ocaml
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %token<string> VAR
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %token LAMBDA
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %token DOT
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %token LPAR
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %token RPAR
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %token EOF
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %start<expr> main
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %%
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> expr:
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> | v = VAR { Var v }
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> | LAMBDA ; x = VAR ; DOT ; y = expr { Abstraction (x, y) }
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> | x = expr; y = expr { Apply (x, y) }
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> | LPAR ; e = expr ; RPAR { e }
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> main:
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> e = expr; EOF { e }
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> %%
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ```
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ```
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ** Conflict (shift/reduce) in state 7.
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ** Tokens involved: VAR LPAR LAMBDA
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ** The following explanations concentrate on token VAR.
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> ** This state is reached from main after reading:
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞>
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Guest8 has joined #ocaml
wonko has quit [Ping timeout: 245 seconds]
<d_bot> <Et7f3> And you spammed IRC users
spip has joined #ocaml
bobo has quit [Ping timeout: 260 seconds]
<d_bot> <darrenldl> can irc bridge be configured to drop code blocks?
<d_bot> <darrenldl> vaguely recall another server did something like that
<d_bot> <Et7f3> Your parser generator might have %right/%left to force to shift or reduce and solve this conflict
<d_bot> <Et7f3> (we can't delete message on IRC 😦 )
<d_bot> <۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> oh, sorry 😔
Tuplanolla has joined #ocaml
bartholin has quit [Ping timeout: 256 seconds]
bartholin has joined #ocaml
bronsen has quit [Quit: WeeChat 3.3]
bronsen has joined #ocaml
jlrnick has joined #ocaml
Guest8 has quit [Quit: Client closed]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
jlrnick has quit [Ping timeout: 268 seconds]
rond_ has joined #ocaml
gravicappa has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro_ has joined #ocaml
mro has quit [Ping timeout: 256 seconds]
bartholin has quit [Ping timeout: 256 seconds]
bartholin has joined #ocaml
mro_ has quit [Read error: Connection reset by peer]
mro has joined #ocaml
Haudegen has joined #ocaml
average has quit [Quit: Connection closed for inactivity]
oriba has joined #ocaml
favonia has joined #ocaml
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
oriba has joined #ocaml
<dmbaturin_> hornhack: You can write imperative code in OCaml. :)
<hornhack> yeah, I just think they are not in the spirit of functional programming
<dmbaturin_> Anyway, by now I find pure code easier to follow, generally. But there are many ways to make pure code hard to read, like breaking it into functions too small for their own good that obscure the data flow, or by excessive use of point-free style (the latter is harder in OCaml, for better or worse).
dmbaturin_ is now known as dmbaturin
<hornhack> ehh point-free style?
<d_bot> <idkjs> hey folks. Doing this old ocaml course on udemy. the following is expected to print with comments but does not. Its probably been updated. How do you get print with comments in utop. This doesnt seem to work ```ocaml
<d_bot> <idkjs> utop # print_string "Hello";; (* print string *)
<d_bot> <idkjs> ```
<dmbaturin> hornhack: Well, it's possible to a degree. The value restriction and strict evaluation make it hard to go overboard with it.
<dmbaturin> idjks: Wait, what output do you _expect_ from that line?
<hornhack> ah yeah, I see,
<d_bot> <idkjs> I guess I expectdd a comment. Now that you ask i see the example is
<d_bot> <idkjs> I was thinking the comment would print. What is the point of the comment if it doesnt show?
<dmbaturin> Well, it's just for the reader I guess.
<d_bot> <idkjs> But I havent saved it anywhere. its just in utop so no one will ever see it i guess. Just for me?
<dmbaturin> Like those cheesy martial arts movies where people call all their attacks. ;)
<dmbaturin> I think the author of that example thought it will help students follow the utop session transcript.
<d_bot> <idkjs> So this ```ocaml
<d_bot> <idkjs> utop # let x = 10;;
<d_bot> <idkjs> if x > 5 then print_string "greater than 5"
<d_bot> <idkjs> else print_string "less than 5" (*conditional statement*);;
<d_bot> <idkjs>
<d_bot> <idkjs> ``` outputs ```ocaml
<d_bot> <idkjs> val x : int = 10
<d_bot> <idkjs> ``` when expected ```ocaml
<d_bot> <idkjs> val x : int = 10
<d_bot> <idkjs> # greater than 5- : unit = ()
<d_bot> <idkjs> ``` what am i missing? Some config maybe?
<dmbaturin> hornhack: The curious part is that pure code is a relatively recent fashion. A lot of old ML code looks like Pascal with first-class functions.
<hornhack> dmbaturin, wow, really, I didnt know that
<hornhack> I thought OCaml was born for functional programming
<dmbaturin> idjks: That utop behaviour with two statements on the same input line is interesting... This will work as expected `let x = 10 in if x > 5 then print_string "greater than 5" else print_string "less than 5";;`. Writing `let x = 10;;` and then enxtering `print ...` as a separate command also works.
<dmbaturin> Let me check something...
<d_bot> <idkjs> That worked but not the same code as you seem to have noted ```ocaml
<d_bot> <idkjs> greater than 5- : unit = ()
<d_bot> <idkjs> ```
<dmbaturin> Looks like utop ignores the part after ;; on the same line. Time for a bug report. :)
<d_bot> <idkjs> Doesnt work with a comment either ```ocaml
<d_bot> <idkjs> utop # let x = 10 in if x > 5 then print_string "greater than 5" else print_string "less than 5" (*conditional statement*);;
<d_bot> <idkjs> greater than 5- : unit = ()
<d_bot> <idkjs> ```
<dmbaturin> hornhack: Well, in the 80's, the idea of first-class functions in a practical language was itself still sounded like radically functional programming I guess.
<hornhack> woo, yeahh
<dmbaturin> You may be interested in the "ZINC report". The group that made CAML Light (the direct predecessor of OCaml) came up with an efficient implementation of closures in the early 90's that allowed functional programming idioms to be fast.
<hornhack> wow nice
<hornhack> eh, let me check what is closure
<dmbaturin> I'm not quite sure when the first non-toy programs in aggressively functional style appeared.
<dmbaturin> A closure is a function stored together with its environment. That's how currying works, e.g. `let add1 x = (+) x 1`, here the `(+)` function will be stored with `x = 1` in its environment.
<d_bot> <idkjs> should i do that? Or are you going to do that?
<dmbaturin> I suppose their implementation of closures was the reason OCaml had everything curried by default. In StandardML, most stdlib functions take tuples instead, so it's `(+): int * int -> int` rather than OCaml's `(+) : int -> int -> int`.
<hornhack> ah I see
<hornhack> so functional works because they made closure fast
<dmbaturin> idjks: I'll do that since I have a reproducing step handy now.
rond_ has quit [Quit: Client closed]
<d_bot> <darrenldl> interesting development of fp : O
<dmbaturin> idkjs: Do you have a link to that course? Could you take a screenshot of the example, are they actually using those statements on the same line? I wonder if it did work when the course was made.
mro has quit [Remote host closed the connection]
<dmbaturin> hornhack: https://github.com/SKS-Keyserver/sks-keyserver The SKS key server is one of the oldest OCaml programs in use. That code is mostly functional, but still more imperative than if it was written today. I'll try to remember of the more unashamerly imperative examples.
<dmbaturin> * remember more unashamedly imperative
<dmbaturin> Looks like I'm dyslexic today. ;)
<octachron> The OCaml compiler is fairly imperative itself
<hornhack> hehe interesting
<hornhack> wow thats hypocritical, the compiler is imperative
<octachron> Type inference is done using union-find, and generalization is implented as a form of GC on type variables.
<octachron> Hypocritical??? Not at all. The compiler is never using OCaml feature not available to non-compiler program.
<octachron> Using imperative features internally when it make sense for performance reason is a pretty common way to organize OCaml library/program.
<dmbaturin> I think it's an advantage of the language that you can write it to make it look like either Pascal or Haskell and still end up with a reasonably fast program. ;)
<d_bot> <Drup> The imperative features are there to be used. If not, they wouldn't be there. So the compiler (and many users) indeed do use them 🙂
<Corbin> hornhack: Is it hypocritical to use a CPU wired up to mutable memory to implement immutable programs? Is it hypocritical for the values in the CPU registers to each be immutable?
<dmbaturin> When I have time, I swear I'll make PoC stdlib that uses objects to make it look like Python.
<dmbaturin> Hopefully this summer when (or if...) I graduate.
<d_bot> <Drup> dmbaturin: people have done that previously! I don't remember the name though
<d_bot> <Drup> it wasn't nice
<dmbaturin> Wow, interesting. Let me know if you remember the name.
<d_bot> <Drup> But A+ troll :p
<d_bot> <Drup> mmh, @companion_cube Does that ring a bell ? of course there are pieces of batteries that are a bit weird like that (IO, notably), but not the whole thing
<dmbaturin> Drup: Did it use a set of "magic methods" with standard types as an object communication protocol?
<d_bot> <Drup> I don't remember the details, but it really looked liked python objects
favonia has quit [Remote host closed the connection]
favonia has joined #ocaml
jlrnick has joined #ocaml
<companion_cube> Drup: rings a bell but was a long time ago
<companion_cube> Sadly ocaml doesn't have great control flow primitives for imperative
<dmbaturin> companion_cube: I'm pretty sure some would say s/sadly/thankfully/ :)
<companion_cube> My own ocaml tends to be very imperative at places, so, no, sad :/
bartholin has quit [Ping timeout: 264 seconds]
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #ocaml
bartholin has joined #ocaml
mro has joined #ocaml
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #ocaml
mro has quit [Remote host closed the connection]
gravicappa has quit [Ping timeout: 260 seconds]
waleee has joined #ocaml
mro has joined #ocaml
<d_bot> <rgrinberg> Unfortunately not.
rgrinberg has joined #ocaml
jlrnick has quit [Ping timeout: 268 seconds]
hendursaga has quit [Quit: hendursaga]
hendursaga has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has quit [Ping timeout: 264 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gravicappa has joined #ocaml
rgrinberg has joined #ocaml
mro has quit [Remote host closed the connection]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
gravicappa has quit [Ping timeout: 245 seconds]
<d_bot> <Et7f3> Why I get this: ```
<d_bot> <Et7f3> Makefile:415: .dep/skiplist.npic.d: No such file or directory
<d_bot> <Et7f3> Makefile:415: .dep/codefrag.npic.d: No such file or directory``` when compiling master branch ?
bartholin has joined #ocaml
olle has quit [Ping timeout: 256 seconds]
mro has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
olle has joined #ocaml
mro has quit [Remote host closed the connection]
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bartholin has quit [Ping timeout: 264 seconds]
bartholin has joined #ocaml
favonia has quit [Quit: Leaving]
wonko has joined #ocaml
bobo has joined #ocaml
spip has quit [Ping timeout: 260 seconds]
bartholin has quit [Ping timeout: 260 seconds]
bartholin has joined #ocaml
wonko has quit [Ping timeout: 256 seconds]
rgrinberg has joined #ocaml
Serpent7776 has quit [Quit: leaving]
bartholin has quit [Quit: Leaving]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
olle has quit [Ping timeout: 268 seconds]
Tuplanolla has quit [Quit: Leaving.]