<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…]
<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