adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.07.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.07/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml | Due to ongoing spam, you must register your nickname to talk on the channel
neatonk has quit [Quit: neatonk]
kvda has joined #ocaml
ziyourenxiang has quit [Ping timeout: 252 seconds]
jao has quit [Ping timeout: 245 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jao has joined #ocaml
mfp has quit [Ping timeout: 252 seconds]
kvda has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
cthuluh has quit [Ping timeout: 264 seconds]
caltelt has quit [Ping timeout: 252 seconds]
_whitelogger has joined #ocaml
silver has quit [Quit: rakede]
jao has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
tormen has joined #ocaml
tormen_ has quit [Ping timeout: 272 seconds]
quarters has joined #ocaml
caltelt has joined #ocaml
<quarters> hello. I was wondering what this does: let greet y = "Hello " ^ y in greet "World!" . I believe the output is "Hello World!" but I don't quite understand how it's being built. I only found out that ^ is possibly a string concatenation operator but wasn't able to google the operator itself
<companion_cube> it is concatenation indeed, look up in the manual
pierpa has quit [Quit: Page closed]
<quarters> companion_cube: how does one look up operators like "^" in the manual
<quarters> and also, I was wondering what role "in" plays in the function above
<companion_cube> look in the section about the stdlib, in the "pervasives" part, I think
<companion_cube> `let x = y in z`
pierpal has joined #ocaml
<quarters> greet isn't calling itself, is it?
<quarters> it wouldn't be able to because it's not declared as a recursive function
<quarters> but I can't seem to call greet either
<quarters> nor draw its value out since typing "greet" in utop issues an "Unbound value" error
<companion_cube> it's only locally defined in this case
<companion_cube> in the scope of `in`
<emily> let greet y = ... in ...code... defines greet only for the scope of ...code...
<companion_cube> but you can write `let greet x = "hello" ^ x ^ "world";;
<companion_cube> greet "foo"
<quarters> I think I get it now. so it's pretty much as if I had not setup an assignment. there's no accessible binding to greet
<companion_cube> it's only a local assignment if you use `let … in …`
<quarters> thanks you companion_cube and emily
<quarters> er..thank*
<companion_cube> :)
stux|RC-only has quit [Ping timeout: 245 seconds]
pierpal has quit [Ping timeout: 272 seconds]
stux|RC-only has joined #ocaml
dinosaure has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pierpal has joined #ocaml
dinosaure has quit [Ping timeout: 240 seconds]
kvda has joined #ocaml
<quarters> I'm going through the tryocaml tutorial and I'm on the part where for loops are introduced and the "body" of the for loop is as follows: xl := i :: !xl; There's no description on what it does but I get that a list is populated with this
<quarters> I was wondering if someone can help with clarifying what's happening in this code
<companion_cube> := is the reference assignment function
<companion_cube> 'a ref -> 'a -> unit
<companion_cube> ! is the reference access function, 'a ref -> 'a
<companion_cube> (a reference is just a mutable box which contains one value, nothing magical)
<quarters> sorry, I'm still struggling to see what's happening
<quarters> xl is defined as a ref []
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<companion_cube> `ref []` makes a new box which contains p[
<companion_cube> []
<companion_cube> !xl gets the current content of the box
<companion_cube> (initially, [])
<companion_cube> xl := foo puts foo inside the box
<quarters> and what does :: do?
<companion_cube> ah, it's the list constructor
<companion_cube> 1 :: l is the list that starts with 1 and continues with l
<companion_cube> [1;2;3] is short for 1 :: 2 :: 3 :: []
jbrown has quit [Ping timeout: 272 seconds]
<quarters> companion_cube: can i ask what this means:'a ref -> 'a -> unit
<quarters> I've seen that format in utop
<companion_cube> it's a function type
<companion_cube> a function taking values of type 'a ref and 'a
<companion_cube> and returning unit
<quarters> oooh, I think I see what's meant by xl := i :: !xl now
<quarters> if I understand... a new list is being built using i :: !xl
<quarters> and here !xl is a reference to the current state of the list
<quarters> and i is being added to the front of the list
<companion_cube> yep!
<quarters> so if xl is [1;2;3], 13 :: !xl is [13;1;2;3]?
<companion_cube> it's a lot of new things, I must say
<companion_cube> yes
<quarters> and then this is then reassigned to xl using :=
<companion_cube> note that lists are immutable, so 13::[1;2;3] is just a new value, it doesn't modify the old one
<companion_cube> yes
kvda has joined #ocaml
<quarters> while lists are immutable, xl can be assigned to a new list
<companion_cube> exactly!
<quarters> I noticed that utop outputs val ..., but all of the tutorials has me declare variables using let. Is val ever used by the programmer?
<companion_cube> it's not the variable xl that is modified, btw; it's the box xl points to
<quarters> ok
<companion_cube> val is just for type signatures
<companion_cube> you won't need it much outside of mli files, and a bit of module-related stuff
<quarters> gotcha
<quarters> I was wndering how to reconcile my ability to assign 2 to x (let x = 2) and then later assign "foo" to x (let x = "foo") to OCaml being a strongly typed language
<companion_cube> ah, it's because it's not the same x
<companion_cube> you're defining a new x, equal to "foo", which shadows the old x
<companion_cube> it becomes apparent if you use a closure (that may be a bit subtle, bear with me)
<quarters> does that shadowing lead to a memory leak?
<companion_cube> let x = 2 in let f y = x+x in let x = "foo" in f 10
<companion_cube> no, the old version might be gc'd if nothing points to it
<companion_cube> `let f y = x+y in …`, sorry
<quarters> in the expression you shared, x isn't bound, right?
erkin has quit [Remote host closed the connection]
<companion_cube> it's bound twice, not sure what you mean
<companion_cube> let x = 2 in let f y = x+y in let x = "foo" in f 10
pierpal has quit [Ping timeout: 272 seconds]
<companion_cube> give it a try if you want :)
<quarters> it's only bound in the closure though and can't be accessed in a repl outside of that scope
<companion_cube> ah, yes
<companion_cube> it's a local binding
<quarters> yeah, I should've said it that way
<quarters> in the first place
<companion_cube> you can do cool stuff though, like `let f = let x = 2 in fun y->x+y`
<companion_cube> which is basically `let f y = 2+y`
<quarters> so reassignment of a variable is not a thing in OCaml?
<quarters> I noticed that when typing "let x = 2; x = 10" outputs false since the equality in the second statement is just testing for equality and not assigning
<companion_cube> indeed
<quarters> neat. thanks for your help, companion_cube. this is pretty intense
<companion_cube> :D
<companion_cube> keep on like that, it'll seem natural soon
<quarters> will do :)
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
bramford has quit [Ping timeout: 245 seconds]
sagotch has joined #ocaml
bartholin has joined #ocaml
jack5638 has quit [Ping timeout: 246 seconds]
sagotch has quit [Ping timeout: 272 seconds]
jack5638 has joined #ocaml
pierpal has joined #ocaml
sagotch has joined #ocaml
pierpal has quit [Ping timeout: 245 seconds]
sagotch has quit [Quit: Leaving.]
dinosaure has joined #ocaml
orbifx has joined #ocaml
orbifx has quit [Ping timeout: 240 seconds]
TheLemonMan has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sagotch has joined #ocaml
dinosaure has quit [Ping timeout: 244 seconds]
mfp has joined #ocaml
Guest81551 has joined #ocaml
kakadu has joined #ocaml
Guest81551 has quit [Remote host closed the connection]
dinosaure has joined #ocaml
Haudegen has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
cthuluh has joined #ocaml
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 250 seconds]
thomas_scrace has joined #ocaml
AltGr has joined #ocaml
yurug has joined #ocaml
yurug has quit [Ping timeout: 252 seconds]
govg has joined #ocaml
thomas_scrace has quit [Ping timeout: 272 seconds]
thomas_scrace has joined #ocaml
<xvilka> next week is ditching opam 1.2
<xvilka> yay
axesd9 has joined #ocaml
FreeBirdLjj has joined #ocaml
axesd9 has quit [Client Quit]
yurug has joined #ocaml
webshinra_ has joined #ocaml
sagotch has quit [Quit: Leaving.]
FreeBirdLjj has quit [Ping timeout: 252 seconds]
webshinra has quit [Ping timeout: 264 seconds]
webshinra has joined #ocaml
webshinra_ has quit [Ping timeout: 240 seconds]
yurug has quit [Ping timeout: 246 seconds]
ygrek has quit [Ping timeout: 240 seconds]
ziyourenxiang has joined #ocaml
quipa has joined #ocaml
pierpal has joined #ocaml
<Armael> Nice!
bartholin has quit [Remote host closed the connection]
bartholin has joined #ocaml
silver has joined #ocaml
dinosaure has quit [Ping timeout: 240 seconds]
spew has joined #ocaml
quipa has quit [Read error: Connection reset by peer]
quipa has joined #ocaml
thomas_scrace has quit [Ping timeout: 240 seconds]
thomas_scrace has joined #ocaml
dinosaure has joined #ocaml
dinosaure has quit [Client Quit]
dinosaure has joined #ocaml
sagotch has joined #ocaml
Haudegen has quit [Remote host closed the connection]
sagotch has quit [Client Quit]
jao has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
Haudegen has joined #ocaml
rixed has left #ocaml [#ocaml]
rixed has joined #ocaml
<rixed> Would it be doable that "N f x" were parsed as "N (f x)" instead of resulting in a syntax error? Or would that conflict with something else?
<thizanne> rixed: how would g N f x be parsed ?
<flux[m]> or N @@ f x.. no but that wouldn't work because constructors cannot be curried, boohoo ;-)
<rixed> thizanne: re. "g N f x" I guess the parser would have to know it the constructor expect 0, 1 or more values... which info is likelly unavailable at that time :-/
<thizanne> it's indeed unavailable, and you really don't want the parsing to be sensitive to that kind of information
<rixed> Ok, I'm glad to have a syntax error in case of "g Some f x", but still I'd like "Some f x" to work :)
<companion_cube> I wish `g @@ Some @@ f x` would work
<rixed> companion_cube: wouldn't that work in SML? I vaguely remember that constructors are /mostly/ like functions there...
<thizanne> that doesn't seem really robust rixed
<companion_cube> doesn't SML mostly avoid currying?
ziyourenxiang has quit [Quit: Leaving]
ziyourenxiang has joined #ocaml
neatonk has joined #ocaml
sagotch has joined #ocaml
dmiles has quit [Read error: Connection reset by peer]
thomas_scrace has quit [Ping timeout: 245 seconds]
FreeBirdLjj has joined #ocaml
dmiles has joined #ocaml
<steenuil> yeah, but constructors work like functions
<steenuil> so what you posted above would work
<companion_cube> ah, ok
elfring has joined #ocaml
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 245 seconds]
jbrown has joined #ocaml
ee_ks has joined #ocaml
yurug has joined #ocaml
ee_ks has left #ocaml [#ocaml]
ee_ks has joined #ocaml
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
groovy2shoes has quit [Quit: moritura te salutat]
thomas_scrace has joined #ocaml
thomas_scrace has quit [Ping timeout: 240 seconds]
thomas_scrace has joined #ocaml
jao has quit [Ping timeout: 252 seconds]
dinosaure has quit [Ping timeout: 252 seconds]
dinosaure has joined #ocaml
dinosaure has quit [Quit: WeeChat 1.4]
dinosaure has joined #ocaml
haved has joined #ocaml
Jesin has quit [Quit: Leaving]
haved has quit [Client Quit]
havedB has joined #ocaml
havedB has quit [Client Quit]
sammie has joined #ocaml
sammie has left #ocaml [#ocaml]
sagotch has quit [Quit: Leaving.]
sammie has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
Haudegen has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
elfring has quit [Quit: Konversation terminated!]
thomas_scrace has quit [Ping timeout: 245 seconds]
dinosaure has quit [Ping timeout: 272 seconds]
thomas_scrace has joined #ocaml
Haudegen has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
Jesin has joined #ocaml
thomas_scrace has joined #ocaml
tane has joined #ocaml
thomas_scrace has quit [Ping timeout: 245 seconds]
groovy2shoes has joined #ocaml
thomas_scrace has joined #ocaml
AltGr has quit [Quit: Konversation terminated!]
quipa has quit [Remote host closed the connection]
quipa has joined #ocaml
erkin has joined #ocaml
ziyourenxiang has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
pierpal has quit [Quit: Poof]
Jesin has quit [Quit: Leaving]
pierpal has joined #ocaml
Jesin has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
jnavila has joined #ocaml
thomas_scrace has quit [Ping timeout: 252 seconds]
quipa has quit [Ping timeout: 272 seconds]
jao has joined #ocaml
yurug has quit [Ping timeout: 272 seconds]
yurug has joined #ocaml
orbifx has joined #ocaml
orbifx has quit [Ping timeout: 240 seconds]
pierpal has quit [Ping timeout: 272 seconds]
kakadu has joined #ocaml
coventry has joined #ocaml
<coventry> Is there any way to run an individual test, under dune?
<discord> <struktured> coventry: from the command line, I don't know. from the dune file in your test directory, you can do something like in the flags section: -only-file myfile:100. It also has some notion of tags and their inclusion or exclusion. See: https://github.com/janestreet/ppx_inline_test#command-line-arguments
ee_ks has left #ocaml [#ocaml]
pierpa has joined #ocaml
ee_ks has joined #ocaml
jao has quit [Ping timeout: 244 seconds]
jrslepak has quit [Remote host closed the connection]
<coventry> Thanks!
jrslepak has joined #ocaml
jack5638 has quit [Ping timeout: 244 seconds]
jrslepak has quit [Remote host closed the connection]
jack5638 has joined #ocaml
orbifx has joined #ocaml
tane has quit [Quit: Leaving]
yurug has quit [Ping timeout: 252 seconds]
HDurer[m] is now known as hdurer[m]
ee_ks has quit [Ping timeout: 244 seconds]
coventry has quit [Remote host closed the connection]
spew has quit [Quit: shutting down]
jnavila has quit [Remote host closed the connection]
Jesin has quit [Quit: Leaving]
jrslepak has joined #ocaml
kvda has joined #ocaml
inr has quit [Quit: WeeChat 2.1]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
inr has joined #ocaml
kvda has joined #ocaml
Jessin has joined #ocaml
bartholin has quit [Remote host closed the connection]
kakadu has quit [Remote host closed the connection]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Jessin is now known as Jesin
Jesin has quit [Quit: Leaving]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Jesin has joined #ocaml
orbifx has quit [Ping timeout: 252 seconds]
Haudegen has quit [Remote host closed the connection]
kvda has joined #ocaml
malina has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
ee_ks has joined #ocaml
dmiles has quit [Ping timeout: 240 seconds]