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/
<dh`> you'll have to be a lot more specific about the grammar than that
<dh`> as long as -> doesn't itself appear in patterns (outside of parens or other containment) it shouldn't matter what's in the patterns
<dh`> or are you trying to make "pat -> expr" with no further decoration be an expression?
<dh`> the latter is going to require being very careful with your pattern syntax so it doesn't overlap the expression syntax.
spip has joined #ocaml
<dh`> and then even if you can make it go it'll likely be an unmaintainable mess
bobo has quit [Ping timeout: 244 seconds]
rgrinberg has joined #ocaml
<hornhack> I have a type x: T of int, so to extract the int, I have to "match v with | T i ->" is it okay to write a oneliner like that and pretend they are like another let.. in
<dh`> what do you mean by okay in this context?
<dh`> also in ocaml you can write "let T i = v in ..."
<hornhack> dh`, ehehe, correct, I forgot that, thankss
<hornhack> arghh, but I need both
<hornhack> dh`, like, does it work? and does it violate the normal match format in coding convention and is frowned upon?
<dh`> it works fine, whitespace isn't significant (this isn't haskell)
<dh`> as for ugly, that's up to you
<hornhack> ahh, very fair
Serpent7776 has quit [Read error: Connection reset by peer]
Serpent7776 has joined #ocaml
<hornhack> is Poly.compare greater_than or less_than
<hornhack> so Poly.compare x y is 1 if x>y ?
<hornhack> -1 if x<y and 0 if equals?
<companion_cube> not necessarily 1 or -1, just >0 and <0
<hornhack> ah, I see, thx
zebrag has quit [Remote host closed the connection]
zebrag has joined #ocaml
chrisz has quit [Ping timeout: 240 seconds]
chrisz has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
waleee has quit [Quit: WeeChat 3.3]
rgrinberg has joined #ocaml
ralu has quit [Ping timeout: 260 seconds]
zebrag has quit [*.net *.split]
kurfen has quit [*.net *.split]
infinity0 has quit [*.net *.split]
Drup has quit [*.net *.split]
klu has quit [*.net *.split]
nyuhu has quit [*.net *.split]
Cypi has quit [*.net *.split]
jyc has quit [*.net *.split]
kurfen has joined #ocaml
zebrag has joined #ocaml
mbuf has joined #ocaml
infinity0 has joined #ocaml
nyuhu has joined #ocaml
Drup has joined #ocaml
klu has joined #ocaml
jyc has joined #ocaml
Cypi has joined #ocaml
xd1le has joined #ocaml
ralu has joined #ocaml
zebrag has quit [Remote host closed the connection]
tomku has quit [Ping timeout: 268 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
recherche has joined #ocaml
recherche has quit [Quit: Client closed]
mro has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Haudegen has joined #ocaml
olle has joined #ocaml
bartholin has joined #ocaml
jlrnick has joined #ocaml
<Franciman> Hi, can I disable the garbage collector in ocaml and manually handle memory?
<olle> yes to first, no to second
<olle> (I think)
<Franciman> first is a great first step :D
<olle> You'd have to configure gc to never collect
<olle> Obviously you'll go OOM quick
<Franciman> thanks olle
<Franciman> yes, I was planning to write my garbage collector, to learn
<Franciman> so it's stupid nonsense
<olle> Eh? In OCaml?
<Franciman> yes
<olle> Why? :)
<Franciman> I wanted to write an interpreter for my language
wonko has joined #ocaml
wonko has quit [Remote host closed the connection]
<olle> Oh, so you're writing a VM in OCaml?
<Franciman> yup!
<olle> Ah
<olle> OK, well, you have to wait until the smart people arrives :D
<Franciman> but for now I rely on the garbage collector of OCaml
<olle> Just me here now, it seems
<Franciman> but I wanted to write one by myself, to get the full awful experience :D
<olle> The OCaml GC is available in C if you want to read it
<Franciman> awesome!
<olle> Part of the OCaml runtime lib
<dmbaturin> The reference implementation of WASM is in OCaml. I haven't looked into its source though.
wonko has joined #ocaml
tomku has joined #ocaml
kakadu has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
mro has quit [Remote host closed the connection]
Haudegen has joined #ocaml
mro has joined #ocaml
rak has quit [Quit: Segmentation fault (core recycled)]
rak has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bobo has joined #ocaml
spip has quit [Ping timeout: 240 seconds]
jlrnick has quit [Ping timeout: 256 seconds]
Haudegen has quit [Quit: Bin weg.]
mro has quit [Remote host closed the connection]
favonia has joined #ocaml
favonia has quit [Ping timeout: 264 seconds]
waleee has joined #ocaml
wwilly has joined #ocaml
mro has joined #ocaml
mro_ has joined #ocaml
mro has quit [Ping timeout: 264 seconds]
Haudegen has joined #ocaml
waleee has quit [Ping timeout: 250 seconds]
waleee has joined #ocaml
Tuplanolla has joined #ocaml
wonko has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
xd1le has quit [Quit: xd1le]
favonia has quit [Quit: Leaving]
waleee has quit [Quit: WeeChat 3.3]
waleee has joined #ocaml
waleee has quit [Ping timeout: 264 seconds]
mro_ has quit [Remote host closed the connection]
jlrnick has joined #ocaml
jlrnick has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 240 seconds]
mro has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
mro has quit [Remote host closed the connection]
mbuf has quit [Quit: Leaving]
mro has joined #ocaml
gwizon has joined #ocaml
bartholin has quit [Quit: Leaving]
Haudegen has quit [Quit: Bin weg.]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
Skyfire has quit [Quit: WeeChat 3.3]
waleee has joined #ocaml
Skyfire has joined #ocaml
mro has quit [Ping timeout: 246 seconds]
<d_bot> <TIDJK94> hello
<d_bot> <TIDJK94> im looking for help
<d_bot> <TIDJK94> i want to use ocaml graphics library for a project. I downloaded it but it doesn't work
<d_bot> <TIDJK94> it shows me, when I type #load "graphics.cma"
<d_bot> <TIDJK94> # #load "graphics.cma";;
<d_bot> <TIDJK94> Cannot find file graphics.cma.
<d_bot> <TIDJK94> please
<companion_cube> you may have to `#use "topfind";;` and then `#require "graphics"`
<d_bot> <NULL> Are you in a top-level? If so #require "graphics" is the easiest way to load them. If not, this is not the way to link libraries
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Haudegen has joined #ocaml
<d_bot> <TIDJK94> i'm using ocaml extension from vscode
<d_bot> <NULL> How do you build / execute your code currently ?
<d_bot> <TIDJK94> doing shift + tab key combination
<d_bot> <NULL> Then on the console toplevel that gets launched, enter `#require "graphics";;` and it should work
<d_bot> <TIDJK94> shift + enter
<d_bot> <TIDJK94> the error
<d_bot> <TIDJK94> @NULL i tried
<d_bot> <NULL> Enter `#use "topfind"` first, then re-enter `#require "graphics"`
<d_bot> <TIDJK94> bruhh
<d_bot> <NULL> To people that know better than me: what is the thing that writes `#use "topfind";;` in .ocamlinit automatically ?
<d_bot> <NULL> How did you install ocaml ?
<d_bot> <TIDJK94> with opam
<d_bot> <TIDJK94> with command line
<d_bot> <TIDJK94> in fact
olle has quit [Ping timeout: 256 seconds]
<d_bot> <NULL> That was probably `user-setup`, but it seems outdated now
<d_bot> <NULL> Is there no file `topfind` in `~/.opam/[switch]/lib/ocaml` ?
wwilly has quit [Ping timeout: 250 seconds]
<d_bot> <NULL> Which one's your active switch ?
<d_bot> <NULL> I'm really not sure this is the best way to install topfind (I checked and it does not come by default), but you can install user-setup
mro has joined #ocaml
motherfsck has quit [Ping timeout: 260 seconds]
waleee has quit [Ping timeout: 246 seconds]
mro has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
<hornhack> why do functions sometimes have ;; at the end?
mro has joined #ocaml
<hornhack> is it like a good coding practice?
<hannes> hornhack: it is needed in the toplevel (REPL).
<hornhack> I'm seeing it in .ml files
<hornhack> so my senior guy just added it to all his functions
<hornhack> I'm not sure why
<hornhack> maybe its good practice or used the ocamlformat for clearer end of function
<hornhack> actually smart, I can see in the code where the function ends
olle has joined #ocaml
np has joined #ocaml
spip has joined #ocaml
<octachron> Using `;;` outside of the toplevel is generally considered bad practice.
ski_ has joined #ocaml
tomku|two has joined #ocaml
vb_ has joined #ocaml
johnel_ has joined #ocaml
dmbaturin_ has joined #ocaml
waleee has joined #ocaml
rgrinberg has quit [*.net *.split]
bobo has quit [*.net *.split]
tomku has quit [*.net *.split]
nerdypepper has quit [*.net *.split]
Putonlalla has quit [*.net *.split]
greenbagels has quit [*.net *.split]
dmbaturin has quit [*.net *.split]
ski has quit [*.net *.split]
johnel has quit [*.net *.split]
vb has quit [*.net *.split]
gwizon has quit [Ping timeout: 240 seconds]
zebrag has joined #ocaml
greenbagels has joined #ocaml
Putonlalla has joined #ocaml
<d_bot> <leviroth> I wouldn't go that far.
<d_bot> <leviroth> One benefit of ;; is that it restricts the scope of syntax errors.
<d_bot> <leviroth> And some people find that the visual separation between functions is helpful, even if it isn't strictly necessary.
<octachron> ? Well, you can use it for debugging syntactic purpose, but syntax errors are not really a concern once the code is written.
<Corbin> I have a third opinion: ;; is a hint to ocamlformat that says "I want these separated but I didn't do a great job with my parens in the prior definition".
<Corbin> You can type ;; just fine, and save it, but ocamlformat will remove it.
<octachron> Let's settle on "some OCaml idioms consider that uses of `;;` are bad practice".
olle has quit [Ping timeout: 246 seconds]
<d_bot> <Valentin> makes me thing of my first OCaml project where I did put `;;` after _every_ declaration
olle has joined #ocaml
olle has quit [Ping timeout: 240 seconds]
<d_bot> <andreypopp> and then you open a janestreet library and see `;;`
<zozozo> sometimes using ;; can help narrow down syntax errors
zebrag has quit [Remote host closed the connection]
zebrag has joined #ocaml
<hornhack> mm thanks, interesting
mro_ has joined #ocaml
mro has quit [Ping timeout: 250 seconds]
mro_ has quit [Quit: Leaving...]
<p4bl0> Hi all. Is it normal that even in the context of line 7 here where we statically know that `f` is a record with a field `n` this code raises an error? https://pastebin.com/HiWy81Xj
<p4bl0> if the record was not inlined in the ADT it would work
<p4bl0> and I would understand that it wouldn't work if the function `string_of_foo` was defined elsewhere out of context because its argument would have no known type, but here it seems feasible to type it properly
<p4bl0> but maybe I don't see the difficulty of typing this?
<zozozo> p4bl0: the function string_of_foo is closed, so it's essentially the same as being defined at toplevel
<zozozo> plus, the type of the inner record is a bit special, and e.g. cannot escape the branch expression (e.g. you cannot return the record alone), plus I'm pretty sure that this type cannot be inferred as the type of a function parameter (mainly because of the escaping concerns)
<zozozo> if `x` was typable/inferrable to be of the type of the inner record, then it could escape the scope of the pattern matching branch, and be returned as a standalone value, which is forbidden
<p4bl0> I see
<p4bl0> thanks zozozo :)
<zozozo> ^^