sepp2k1 has quit [Remote host closed the connection]
walter|r has quit [Read error: Connection reset by peer]
walter has quit [Read error: Connection reset by peer]
walter has joined #ocaml
walter|r has joined #ocaml
madroach has quit [Ping timeout: 244 seconds]
madroach has joined #ocaml
lolcathost has joined #ocaml
deu5 has quit [Quit: Leaving]
emmanuelux has quit [Quit: emmanuelux]
everyonemines has joined #ocaml
Yoric has joined #ocaml
tautologico has quit [Quit: tautologico]
astertronistic has joined #ocaml
leoncamel has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
tac has joined #ocaml
lolcathost has quit [Ping timeout: 240 seconds]
lolcathost has joined #ocaml
justdit has joined #ocaml
tac has quit [Quit: Page closed]
<Skolem>
Why is this a syntax error? let k = 7 in let _ = print_endline "1";;
<_habnabit>
Skolem, every 'let' needs an 'in'
<_habnabit>
Skolem, you can just do let k = 7 in print_endline "1";;
paolooo has joined #ocaml
<Skolem>
habit: Thank you for the answer, but I don't understand yet how every "let" requires an "in". If that were the case, I would expect this to be a syntax error, yet it works fine: let _ = print_endline "1";; What am I missing?
paolooo has quit [Client Quit]
<_habnabit>
Skolem, '_habnabit'. you can tab-complete my nickname if it helps.
<Skolem>
_habnabit: thanks, the tab completion works great.
paolooo has joined #ocaml
paolooo has quit [Client Quit]
<_habnabit>
Skolem, anyway you can only do that with statements that are at the top level of a module. that's how you define the values that a module exports.
<Skolem>
Gotcha. Since I'm not trying to do any module exports, I'll just try to remember what you said about every "let" requiring an "in".
walter|r has quit [Read error: Connection reset by peer]
<_habnabit>
Skolem, sorry, it's actually been a while since i did much ocaml dev. it's not just for that; you can't just have arbitrary expressions in a module. i don't remember _all_ of the statements that are allowed at the module scope, but you can't (for example) just call a function
<_habnabit>
Skolem, so you have to do e.g. let () = prent_endline "1"
<_habnabit>
print, even
walter|r has joined #ocaml
<Skolem>
Thanks. I don't even know what module scope is. I just want to define some functions and call them, and I'm clinging to your rule of thumb about let/in like a life preserver. So far it's working. ;)
<_habnabit>
Skolem, 'module scope' is just what you write in a .ml file
<Skolem>
Ah. I googled for ["module scope" ocaml] and didn't see anything that looked canonical.
<_habnabit>
i don't know if there's a more official term for it
<Skolem>
Basically I don't plan to use modules yet. I just want to define a bunch of functions and then call the main one at the end.
<pippijn>
you can call a function at top level
<pippijn>
print_endline "Hello";;
<pippijn>
works fine
<Skolem>
pippijn: Thank you, _habnabit also explained that to me earlier… (_habnabit: Skolem, you can just do let k = 7 in print_endline "1";;)
<pippijn>
no
<pippijn>
let k = 7;; print_endline "1";;
<pippijn>
this is allowed
<pippijn>
07:08 < _habnabit> Skolem, so you have to do e.g. let () = prent_endline "1"
<pippijn>
this is incorrect
<_habnabit>
can you do that without ;; though
<pippijn>
_habnabit: please don't misinform people
<pippijn>
_habnabit: yes, if it's the last expression in the module
<Skolem>
Ah, you don't need the let at all. I see.
<_habnabit>
really??
<_habnabit>
let's see
<pippijn>
try it and see
<pippijn>
Skolem: it is not common practice to have toplevel expressions
<_habnabit>
welp okay you can
<_habnabit>
weird
<pippijn>
but for example in ocamlbuild, it's common
<pippijn>
07:15 < pippijn> _habnabit: yes, if it's the last expression in the module
<_habnabit>
forgot a semicolon whoops
<_habnabit>
pippijn, yes, that's what i mean--i didn't know that
<pippijn>
that's ok
<pippijn>
you don't need to know everything
<pippijn>
but then you shouldn't spread misinformation as facts
<_habnabit>
sigh
<pippijn>
anyway
<pippijn>
you learnt something today :)
<pippijn>
so next time you can teach someone better
madroach has quit [Quit: leaving]
<pippijn>
Skolem: actually I prefer to say: let main () = ... let () = main ()
<pippijn>
Skolem: because just main () doesn't check whether main returns unit
<Skolem>
pippijn: Thanks. I'm getting a syntax error I don't understand with that. Here's my code (all one one line): let show f = print_endline f in let main () = show "foo" let () = main ()
madroach has joined #ocaml
<pippijn>
ah
<pippijn>
toplevel let is actually a very different construct than local let
<pippijn>
local let is an expression of the form "let binding in expr"
<pippijn>
binding is "a = b"
<pippijn>
and expr is mandatory
<pippijn>
toplevel bindings are of the form "let binding" without "in"
<pippijn>
as soon as you add "in", it becomes an expression
<pippijn>
so it behaves like print_endline "hello"
<pippijn>
let show f = print_endline f (with optional ;;)
<pippijn>
let main () = show "foo"
<pippijn>
let () = main ()
<pippijn>
_habnabit: because it's the same as: let bar = "bar" print_endline bar
<pippijn>
you need a ;; here
<Skolem>
pippijn: Thanks, that definitely works. I think I'm confused about when to use 'let' and when to use ';;'. is there some simple rule of thumb I can follow that will get me through the kind of simple code I'm trying to write?
<_habnabit>
gross
<pippijn>
;; terminates a sentence
<_habnabit>
so it seems it's more like "you can call a function if it's the only expression in a module" and not "the last expression"
<pippijn>
_habnabit: if you insist on not adding ;; after that expression, yes
<_habnabit>
adding ;;s seems silly
<pippijn>
_habnabit: but you can write print_endline "hello";; print_endline "world";; Printf.printf "this is a number: %d\n" 300;;
<pippijn>
adding ;; is sometimes useful
<pippijn>
especially in imperative code
<pippijn>
because you get funny syntax errors if you do this:
<pippijn>
let func () = expr; expr; expr;
<pippijn>
let main () = func ()
<pippijn>
you will get a syntax error after the definition of main
<pippijn>
because the trailing ";" causes "let main () = func ()" to be the start of a let-in expression
<pippijn>
you can also do
<pippijn>
let func () = begin expr; expr; expr; end
<pippijn>
or
<pippijn>
let func () = (expr; expr; expr;)
<pippijn>
or like I said
<pippijn>
let func () = expr; expr; expr; ;;
<pippijn>
up to you, really, it's a style question
mye has joined #ocaml
<everyonemines>
I thought if you're doing "let () =" then you should end every function with "in"
<everyonemines>
let fn _ = exp; exp; exp; in let main _ = fn ()
<everyonemines>
personally I use ;; though because I don't like "let func ()"
<Skolem>
everyonemines: that can't be right, because this ends every function with "in", but gives a syntax error: let show f = print_endline f in let main () = show "foo" in let () = main ()
<everyonemines>
hmm
<everyonemines>
yeah, I guess that doesn't work
<everyonemines>
I guess I should stick to ;; :-)
<Skolem>
That was my take-away.
<everyonemines>
you would actually need to write that as "let main _ = let show f = print_endline f in show "foo" "
<everyonemines>
so you can do it, but it might get confusing
justdit has quit [Ping timeout: 252 seconds]
<everyonemines>
the annoying thing is when you need to move imperative code using ;; to inside a function
<everyonemines>
Skolem: let () = let show f = print_endline f in show "foo" in ()
<everyonemines>
there you go
<everyonemines>
actually, let () = let show f = print_endline f in let () = show "foo" in ()
<everyonemines>
obviously superior
<everyonemines>
because it's more functional
<Skolem>
wow.
<Skolem>
It assigns () to (), that's for sure.
<Skolem>
well,doesn't "assign" but ....
<everyonemines>
hey i remember you skolem
<everyonemines>
we chatted before
<Skolem>
Yes :)
<everyonemines>
what are you up to now?
<Skolem>
Nice to see you again.
<Skolem>
Just now, I was testing the performance of js_of_ocaml against "native" javascript for a tight loop of arithmetic operations.
<companion_cube>
exactly, it's a bit surprising to have try/except but not finally
sgnb` has quit [Remote host closed the connection]
sgnb has joined #ocaml
justdit has joined #ocaml
munga has joined #ocaml
justdit has quit [Read error: Connection reset by peer]
larhat has quit [Quit: Leaving.]
larhat has joined #ocaml
justdit has joined #ocaml
mjonsson has quit [Ping timeout: 255 seconds]
justdit has quit [Read error: Connection reset by peer]
justdit has joined #ocaml
justdit has quit [Read error: Connection reset by peer]
justdit has joined #ocaml
justdit has quit [Client Quit]
fraggle_laptop has joined #ocaml
oez has joined #ocaml
<oez>
if i create a Set on the type (string * int) list * (string * sign * int) list (with type sign = PLUS | MINUS), would it behave like we expect it to?
<oez>
(with Pervasives.compare)
xavierm02 has joined #ocaml
<ppseafield>
oez: if you define sign like that, PLUS will be less than MINUS
<oez>
ye i never use the order between two signs (as long as they're different)
Kakadu has quit [Quit: Konversation terminated!]
<ppseafield>
oez: just learning ocaml myself, but it looks like yes
<oez>
ok thanks
<oez>
if i understand correctly Pervasives.compare should be able to compare any combination of lists, cartesian product, and abstract and base types, but only those
<companion_cube>
be careful of cyclic structures
<oez>
probably cannot compare two Sets with Pervasives.compare
<oez>
companion_cube: why?
<companion_cube>
no, it will have false negatives
<oez>
right
<companion_cube>
because compare (and (=)) traverse recursively data structures
fraggle_laptop has quit [Remote host closed the connection]
<oez>
yes ok
<oez>
as long as my values are well formed it should be fine then?
<companion_cube>
as long as they do not contain mutable references to parents
<companion_cube>
but yeah, if you use simple algebraic datatypes it will be fine
<companion_cube>
do not hesitate to write comparison functions specific to your types
chambart has quit [Ping timeout: 255 seconds]
csag8264 has joined #ocaml
<oez>
ok thanks
travisbrady has joined #ocaml
<thelema>
can compare two sets, just will give structural comparison on the trees, not the set-theoretic equality
<oez>
right
chambart has joined #ocaml
alexnixon has joined #ocaml
eikke has joined #ocaml
chambart has quit [Ping timeout: 245 seconds]
gustav__ has quit [Remote host closed the connection]
jpdeplaix has quit [Ping timeout: 245 seconds]
jpdeplaix has joined #ocaml
jamii has joined #ocaml
jamii has quit [Client Quit]
jamii has joined #ocaml
Cyanure has quit [Remote host closed the connection]
oez has quit [Ping timeout: 245 seconds]
munga has quit [Quit: Ex-Chat]
gustav__ has joined #ocaml
jamii has quit [Ping timeout: 248 seconds]
larhat has quit [Quit: Leaving.]
tac has joined #ocaml
hkBst has quit [Quit: Konversation terminated!]
fusillia has quit [Ping timeout: 276 seconds]
beckerb has quit [Quit: Konversation terminated!]
paolooo has quit [Ping timeout: 245 seconds]
Yoric has quit [Ping timeout: 252 seconds]
Neros has joined #ocaml
tac_ has joined #ocaml
tac has quit [Ping timeout: 245 seconds]
ocp has quit [Ping timeout: 260 seconds]
Submarine has joined #ocaml
answer_42 has quit [Ping timeout: 276 seconds]
ftrvxmtrx_ has joined #ocaml
csag8264 has quit [Ping timeout: 276 seconds]
tane has joined #ocaml
astertronistic has quit [Ping timeout: 252 seconds]
answer_42 has joined #ocaml
Neros has quit [Ping timeout: 264 seconds]
Submarine has quit [Read error: Operation timed out]
Neros has joined #ocaml
eikke has quit [Ping timeout: 268 seconds]
jamii has joined #ocaml
sepp2k has quit [Ping timeout: 240 seconds]
sepp2k has joined #ocaml
jamii has quit [Ping timeout: 246 seconds]
jamii has joined #ocaml
mye has joined #ocaml
Enjolras has quit [Read error: Connection reset by peer]
Xizor has joined #ocaml
pangoafk is now known as pango
ontologiae has quit [Ping timeout: 276 seconds]
Yoric has joined #ocaml
smondet has joined #ocaml
ftrvxmtrx has quit [Remote host closed the connection]
eikke has joined #ocaml
mye has quit [Quit: mye]
answer_42 has quit [Write error: Broken pipe]
mye has joined #ocaml
answer_42 has joined #ocaml
larhat has joined #ocaml
tac_ has left #ocaml []
oriba has joined #ocaml
scp has joined #ocaml
<scp>
hello ocaml'ers
<scp>
I wanna learn your language, anyone got a good starter guide for me?
Snark has joined #ocaml
<scp>
I'm decent at haskell already, so it doesn't need to be a "procedural programmer's first" type guide
emmanuelux has joined #ocaml
_andre has quit [Quit: leaving]
<pippijn>
scp: I think the ocaml manual is good for you
<bitbckt>
scp: I usually recommend Jason Hickey's book, "Intro. to Objective Caml".
<pippijn>
read the grammar section
<pippijn>
knowing haskell, that should get you started
<pippijn>
you know the concepts, now you just need to learn the syntax to apply them
<scp>
cool, thanks guys
<pippijn>
after that, I suggest you look at the manual index and pick whatever title looks interesting to you
<pippijn>
and read it
cdidd has joined #ocaml
tac has joined #ocaml
oriba has quit [Quit: oriba]
tac has quit [Quit: Page closed]
Snark has quit [Quit: Quitte]
thelema has quit [Remote host closed the connection]
Cyanure has joined #ocaml
ftrvxmtrx_ has quit [Ping timeout: 260 seconds]
mjonsson has joined #ocaml
thomasga has quit [Ping timeout: 256 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
thomasga has joined #ocaml
thomasga has quit [Remote host closed the connection]
djcoin has quit [Quit: WeeChat 0.3.9.1]
Cyanure has quit [Remote host closed the connection]
deu5 has joined #ocaml
gustav__ has quit [Read error: Connection reset by peer]
Xizor has quit [Quit: So yes it's mIRC under wine under debian double peche capital. ;) I'll soon see in kfreeBSD.]
ppseafield has quit [Quit: Leaving.]
tane has quit [Quit: Verlassend]
Yoric has quit [Ping timeout: 252 seconds]
lolcathost has joined #ocaml
scp has quit [Ping timeout: 240 seconds]
ftrvxmtrx_ has joined #ocaml
eikke has quit [Ping timeout: 252 seconds]
TDJACR has joined #ocaml
answer_42 has quit [Quit: WeeChat 0.3.9]
xavierm02 has quit [Quit: Leaving]
mye has quit [Quit: mye]
smondet has quit [Ping timeout: 260 seconds]
chambart has joined #ocaml
thelema has joined #ocaml
ontologiae has joined #ocaml
ivan\ has quit [Ping timeout: 252 seconds]
jamii has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
ivan\ has joined #ocaml
travisbrady has quit [Quit: travisbrady]
ontologiae has quit [Ping timeout: 276 seconds]
BiDOrD_ has joined #ocaml
BiDOrD has quit [Ping timeout: 260 seconds]
chambart has quit [Ping timeout: 246 seconds]
fraggle_ has quit [Ping timeout: 245 seconds]
Submarine has quit [Remote host closed the connection]
chambart has joined #ocaml
lolcathost has quit [Ping timeout: 240 seconds]
lolcathost has joined #ocaml
Anarchos has quit [Quit: sleep time]
fraggle_ has joined #ocaml
sepp2k has quit [Remote host closed the connection]