gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
twittard has quit [Remote host closed the connection]
twittard has joined #ocaml
iago has quit [Quit: Leaving]
fantasticsid has joined #ocaml
oriba has quit [Quit: oriba]
avsm has quit [Quit: Leaving.]
twittard has quit [Ping timeout: 244 seconds]
twittard has joined #ocaml
twittard has quit [Quit: twittard]
fantasticsid has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
emmanuelux has quit [Read error: Connection reset by peer]
yroeht has quit [Ping timeout: 255 seconds]
yroeht has joined #ocaml
EmmanuelOga has quit [Ping timeout: 245 seconds]
ulfdoz has quit [Ping timeout: 240 seconds]
ankit9 has quit [Quit: Leaving]
fantasticsid has joined #ocaml
zuymanto has joined #ocaml
zuymanto has quit [Client Quit]
Snark has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
pango has quit [Remote host closed the connection]
<dsheets> anybody know what part of menhir I should prod to get error information after I catch an Error exception from a menhir-generated parser?
<dsheets> I'm using traditional2revised and wrote the appropriate projection functions from 'token to Lexing.position… i just don't know where to retrieve those values, now
ftrvxmtrx has quit [Quit: Leaving]
twittard has joined #ocaml
edwin has joined #ocaml
thomasga has joined #ocaml
ftrvxmtrx has joined #ocaml
avsm has joined #ocaml
cago has joined #ocaml
ankit9 has joined #ocaml
djcoin has joined #ocaml
Cyanure has joined #ocaml
twittard has quit [Ping timeout: 260 seconds]
twittard has joined #ocaml
eikke has joined #ocaml
ankit9 has quit [Quit: Leaving]
Submarine has quit [Ping timeout: 245 seconds]
Submarine has joined #ocaml
Cyanure has quit [Remote host closed the connection]
Cyanure has joined #ocaml
avsm has quit [Quit: Leaving.]
silver has joined #ocaml
_andre has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
<otk> http://realworldocaml.org/ think it was already pasted
ftrvxmtrx has joined #ocaml
<adrien> nope =)
<Ptival> oh cool
<otk> no matter how many times i hit F5 it isn't fall yet
<otk> (how long until Fall?)
<Ptival> just a few more
<otk> also i haven't tried ocaml core yet, looks cool
<otk> flicked through that ocaml book by jason hickey i think
<otk> wonder if it will be similar like
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
cdidd has quit [Ping timeout: 240 seconds]
fantasticsid has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
ankit9 has joined #ocaml
cdidd has joined #ocaml
letrec has joined #ocaml
EmmanuelOga has joined #ocaml
letrec has quit [Remote host closed the connection]
ikaros has joined #ocaml
lamawithonel has quit [Ping timeout: 276 seconds]
lamawithonel has joined #ocaml
lamawithonel_ has joined #ocaml
lamawithonel has quit [Ping timeout: 255 seconds]
<Ptival> why are people not indenting their match cases at the same level!? è__é
<adrien> look for "match or try"
Tobu has quit [Ping timeout: 272 seconds]
<Ptival> I'm currently correcting style in someone's code in other to be able to read it :D
<Ptival> s/other/order/
<adrien> my biggest issue is tabs+space ='(
<adrien> I often start commits by throwing a huge change that only changes indentation ='(
<Ptival> I have more problems with stuff being all on one line
<Ptival> like the first case of a match, or the then clause of an if...
<Ptival> I find it super annoying
<Ptival> visually-dangling elses
<Ptival> maybe I should send the link to this guidelines page to the author
<adrien> heh
Tobu has joined #ocaml
lamawithonel_ has quit [Ping timeout: 276 seconds]
<NaCl> adrien: how anti-emacs of you
<adrien> nah: pro-sense
<adrien> or "meaningful"
lamawithonel has joined #ocaml
<NaCl> sense? what's that?
<adrien> sense: what java doesn't make
<Ptival> NaCl: what were you referring to?
<adrien> emacs is typically the editor that leads to a mix of tabs and spaces in source codes
<Ptival> k
<Ptival> adrien: I do that too :p
<adrien> I use vim; NaCl uses emacs ;-)
* adrien spanks Ptival
<Ptival> I use emacs with evil
<Ptival> for OCaml
<Ptival> and Coq/Agda
<Ptival> vim for the rest
<adrien> in ocaml, it really makes no sense
<Ptival> but tabs are only allowed in Makefiles!
<adrien> it only happens that it "compresses" 8 spaces as one tab
<adrien> Ptival: yes, there; but not a mix anyway
<adrien> anywhere*
<Ptival> spaces everywhere else!
<NaCl> emacs has sane defaults
<NaCl> except for the tab/space thing
<NaCl> wrt indentation
<NaCl> I use emacs for everything that I need to have open for more than a few minutes
<adrien> I'll adapt to anything
<adrien> except mixes of tabs and spaces
<adrien> NaCl: ah, so the startup time doesn't become too dominant? =)
<Ptival> the only use of tabs is to be able to set the size, if you mix in spaces you're doing it very wrong...
<NaCl> I haven't my work emacs sessions in weeks
<NaCl> Ptival: the idea is to make alignment independent of tab length
<Ptival> adrien: hahaha
<NaCl> haven't closed
<adrien> NaCl: yeah ;-)
<adrien> but actually, on an empty cache, vim takes a *LOT
<adrien> * of time to start here
Tobu has quit [Quit: No Ping reply in 180 seconds.]
<djcoin> I'm a Vim fan but thats true that emacs major:minor mode are great. I use emacs for Latex myself
<adrien> when I say "empty", I mean really empty
Tobu has joined #ocaml
<NaCl> I use evil in emacs
<NaCl> because I use the arrow keys
<pippijn> adrien: same here, it takes a few seconds
<f[x]> I use vim with kindness
<adrien> vim 0.20s user 0.29s system 9% cpu 5.084 total
<pippijn> about the same time as emacs
<pippijn> vim 0.14s user 0.04s system 8% cpu 2.107 total
<adrien> time sto start and and be closed at once (I could type ":q" in the terminal before vim had started so it got picked at once)
<adrien> pippijn: if you want an empty cache: echo 3 > /proc/sys/vm/drop_caches
<adrien> it will slow down your computer during some time
<pippijn> adrien: nice
<pippijn> I didn't know about that
<adrien> mostly useful for benchmarks
<NaCl> my emacs takes a few seconds to start up. :P
<pippijn> vim 0.07s user 0.04s system 2% cpu 3.901 total
<adrien> note that with that, your cache will be much colder than after a fresh reboot
<pippijn> wrong
<pippijn> vim 0.12s user 0.11s system 2% cpu 9.722 total
<pippijn> the other one was the 32 bit vim
ankit9 has quit [Quit: Leaving]
<pippijn> and ctags is not installed there
<pippijn> emacs 0.14s user 0.09s system 4% cpu 4.627 total
<adrien> well, my point was mainly that you can make anything very slow if you have an empty cache
<djcoin> not sure measuring accuratly memory usage of emacs vs vim, is a great criteria. I will give most of what I can give to an editor if it can make me more efficient.
<adrien> it reminds me of ff's way to speedup loading
<pippijn> preload?
<djcoin> accurately *
<adrien> basically, the "firefox" binary is now a binary the does "cat $lib > /dev/null" for each library that firefox uses
<pippijn> heh
<adrien> it triggers sequential reads instead of random ones
<pippijn> not bad
<pippijn> by the way, does ocaml support shared libraries?
<pippijn> as in making them
<adrien> .so files?
<pippijn> yes
emmanuelux has joined #ocaml
<adrien> includes "18.7.4 Main program in C"
<adrien> it's an "advanced topic" in the "advanced topic" that mixing C and OCaml is :-)
<pippijn> this is an interesting topic
<pippijn> though I won't be doing any of that, anytime soon
<adrien> it's perfectly doable too even if I sounded scary ;-)
letrec has joined #ocaml
<pippijn> it doesn't look very difficult
<pippijn> I've embedded racket scheme, perl and various other interpreters
<adrien> the only thing is that you lose any kind of security
<pippijn> you mean safety?
<adrien> hmm, yeah; and warnings and errors
<pippijn> what kind of warnings and errors?
<adrien> you work on the memory representation and you can cast arrays to tuples to records for instance
<pippijn> oh, you mean when working with ocaml values from C?
<adrien> yes :-)
<NaCl> adrien did plenty of that
<adrien> and I'm still a beginner :P
<NaCl> wat
<NaCl> adrien: lies
<adrien> for the C interface? I am :P
goncalo_ has joined #ocaml
goncalo has quit [Read error: Connection reset by peer]
mcclurmc has quit [Read error: Connection reset by peer]
goncalo has joined #ocaml
goncalo has quit [Client Quit]
goncalo has joined #ocaml
goncalo_ has quit [Ping timeout: 252 seconds]
gildor has quit [Quit: leaving]
zuymanto has joined #ocaml
zuymanto has quit [Ping timeout: 240 seconds]
Tobu has quit [*.net *.split]
cdidd has quit [*.net *.split]
dsheets has quit [*.net *.split]
joewilliams has quit [*.net *.split]
otk has quit [*.net *.split]
hyperboreean has quit [*.net *.split]
ccasin has quit [*.net *.split]
ccasin has joined #ocaml
otk has joined #ocaml
hyperboreean has joined #ocaml
Tobu has joined #ocaml
dsheets has joined #ocaml
cdidd has joined #ocaml
<Ptival> huh, actually there's something I hate more than -not following obviously good guidelines-
<Ptival> that is: lack of consistency
<Ptival> because if it's always weird in the same way, at least you can adapt =__=
joewilliams has joined #ocaml
<ppilatus> is there a function which is equivalent to (List.rev l1)@l2?
<ppilatus> (I have a zipper, and I want to move contents of one list to another
<adrien> List.rev_append l1 l2 reverses l1 and concatenates it to l2 . This is
<adrien> equivalent to List.rev l1 @ l2 , but rev_append is tail-recursive and
<adrien> more efficient.
<adrien> ?
<ppilatus> thanks
ikaros has quit [Quit: Ex-Chat]
Cyanure has quit [Ping timeout: 260 seconds]
<thelema> pippijn: ocaml supports shared libraries on many platforms, with dynamic loading as provided by https://github.com/mfp/ld.ocaml
<pippijn> thelema: nice
rixed_ has joined #ocaml
rixed has quit [Ping timeout: 276 seconds]
rixed_ has quit [Read error: Operation timed out]
rixed has joined #ocaml
ulfdoz has joined #ocaml
jamii has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
cago has quit [Quit: Leaving.]
pipocaml12 has joined #ocaml
<pipocaml12> can somebody help me understand return values of functions ...
<pipocaml12> how can I return the value buffer
<NaCl> ...
<pipocaml12> oh hey
<NaCl> in copy () ;
<NaCl> buffer ;;
<pipocaml12> I understand it I think
<NaCl> make the first block an imperative statement
<NaCl> then return buffer
<pipocaml12> NaCl, does this function not return buffer already?
<rixed> pipocaml12: yes it does.
<rixed> pipocaml12: don't you mean input instead of read BTW?
<pipocaml12> because it does copy recursively and when there is nothing left to copy()
<pipocaml12> read is a unix socket function. This code is copied from the Ocaml book on Unix programming
<rixed> pipocaml12: also, you may want to use really_input
<pipocaml12> I changed it because I only want to ready
<pipocaml12> read
letrec has quit [Ping timeout: 245 seconds]
<pipocaml12> but the in means that the phrase is functional and not an imperative statement, if I understand NaCl correctly?
<pipocaml12> the "in" at the end
<rixed> pipocaml12: ok. anyway, you have a bug: you should pass current offset to copy
<pipocaml12> no I think reading from sockets means that the buffer is emptied, so no offset
<pipocaml12> every time you read the buffer is getting emptied further
<pipocaml12> or not?
<rixed> the "in" means that the definition of copy holds in the statement "copy ()".
<pipocaml12> offset in sockets makes no sense I suppose
<rixed> pipocaml12: yes, but you overwrite your buffer.
<pipocaml12> so it is like "with" in R and I think Python??
<rixed> pipocaml12: don't know. in opens a scope where the previous definition holds, if you want.
<pipocaml12> okay this code is not indented but am I correct to see it like a cascade with the p1 in p2 in p3, then p3 is the most powerful
<pipocaml12> powerful ... I mean, it is the most containing scope ...
<iZsh> pipocaml12: you should probably read more tutorials before trying to code something. you seem to be missing some basic knowledge about the ocaml language
<rixed> pipocaml12: let a = 1 in expr -> in expr, a is defined to be 1. there is nothing in there to be afraid of, it's like english actualy. juste read the code :-)
<pipocaml12> iZsh I would love to do tutorials if I hade more time, but I turned to OCaml because it solved a problem quite well ...
<rixed> pipocaml12: go ahaid, one get accustomed to the syntax in a couple of hours of practice!
<pipocaml12> I already had an idea what in meant, but I wanted to check my understanding ... and you are right that such elementary things can probably be found with Google in tutorials ... anyway
djcoin has quit [Quit: WeeChat 0.3.2]
<pipocaml12> thx rixed
<rixed> pipocaml12: I maintain you have a bug anyway ;-) -> copy should take offset as argument, and call "read fdin buffer offset (buffer_size-offset)"
<thelema> asking what "in" means in ocaml is like asking what "{" means in C - it's just a delimiter
<pipocaml12> yes but circumfix delimiters like { ... } are clearer and more evident to me at least
<rixed> except that there are no equivalent for '}' so you have to get accustomed to the effect of ";", lets and parenths. But all in all quite easy.
<pipocaml12> in could go both was a in b in c : a > b > c or a < b < c ... so that is why I was not so sure
<pipocaml12> was = ways
<pipocaml12> rixed, the buffer_size is like the chunk size, not the total size.
<pipocaml12> or do I miss your point
eikke has quit [Ping timeout: 260 seconds]
<rixed> the 4th parametert to read is the max size to read. If you already filled 3 bytes in your buffer, you want to read (buffer_size-3) and stores the new bytes at offset 3.
<thelema> pipocaml12: 'in' doesn't work by itself - "a in b in c" isn't valid. "let a = x in let b = y in c" is valid; in just divides the expression to bind from the expression that uses the bound identifier
<pipocaml12> thelema, please bear with me, I am very sloppy in my writing in this chat box ... Always a bit hasty ... I used a b c as shorthands..
<pipocaml12> (not grammatically correct)
<thelema> the a b and c are fine, but you need 'let' for every 'in'
<thelema> and let is probably more important than 'in', so dropping the let and keeping the 'in' seems wrong
<pipocaml12> I got that. So, a, b and c must be expressions or must they strictly be function applications
<pipocaml12> oh no of course not
<thelema> in my example, a and b are identifiers and c is an expression
<rixed> pipocaml12: let some_binding in some_expression (where some_expression can be another let x in y)
<thelema> in your example... a and b are "let foo = bar" strings and c is an expression
<pipocaml12> hmm I don't get that
ulfdoz_ has joined #ocaml
ftrvxmtrx has joined #ocaml
<pipocaml12> why is b not an expression? you define an identifier to equal an expression y
<pipocaml12> 'no assignments in Ocaml'
<pipocaml12> so is this the pointe?
eikke has joined #ocaml
ulfdoz has quit [Ping timeout: 245 seconds]
ulfdoz_ is now known as ulfdoz
EmmanuelOga has quit [Quit: WeeChat 0.3.7-dev]
<thelema> pipocaml12: "a in b in c" requires that a be "let foo = bar" and b be "let foo2 = bar2" and c can be an expression using foo and foo2
<thelema> I think about it as "let a = x in let b = y in z", where a and b are identifiers, x and y and z are expressions
<thelema> y can use "a" in it, and z can use "a" and "b"=
eikke has quit [Ping timeout: 276 seconds]
<thelema> note that "let a = x in y" is an expression itself, so it can be used as a "y" or "z"
<pipocaml12> well my thinking is perhaps still a bit imperative ...
<thelema> yes, it's a bit of a change in thinking.
<pipocaml12> because my intuition about, say: "let foo = bar in let foo2 = bar2 in let c = bar2"
<rixed> pipocaml12: maybe you are confused because contrary to other languages, in ocaml "let a = x" in not a statement by itself. Instead, "let ... in ..." is, so that every binding comes with its "scope" (to speak loosely)
<pipocaml12> would be that b is an expression when it is evaluated in c
<thelema> pipocaml12: what b?
<pipocaml12> correction "let foo = bar in let foo2 = bar2 in let c = bar2"
<pipocaml12> I mean that bar2 is an expression when it is evaluated in the scope of c
<pipocaml12> ?
<pipocaml12> shit
<pipocaml12> again wrong
<thelema> bar2 is an expression that is evaluated right when it's bound to "foo2"
<pipocaml12> "let foo = bar in let foo2 = bar2 in let c = foo2"
<thelema> the result of that evaluation can be used in the expression for c
<pipocaml12> I meant to say foo2... anyway, I will try to focus my attention again not on chatting about it :P
<thelema> ok
<pipocaml12> but one thing
<iZsh> "let c = foo2" alone doesnt mean anything
<iZsh> you have to read it like english really
<thelema> iZsh: it does at the toplevel
<iZsh> thelema: yeah ok, but that's cheating
<thelema> iZsh: and toplevel phrases are accepted in compiled programs, so when I write my programs, they contain "let () = main ()" without an in
<iZsh> thelema: i usually limit the only "let" without "in" to the main, and of course the function definitions
<thelema> iZsh: same here. I'm just saying that it's valid
<rixed> Maybe let ... in would be easier as "with ... in" ?
<pipocaml12> I must say that while the notation is not so explicit as much as I like, I do think I find all of this escalating the scope (that's one, probably not conventional way to describe this chaining of "in") is natural ... I'm trying to say, that I think I will appreciate and understand it better over time .. I am not put off by it, even though it is a world apart from languages like C
<thelema> it's not an expression, it's a phrase, but it's valid
<iZsh> pipocaml12: it is as explicit as saying it in english really
<iZsh> let x be 2 in ...
<rixed> pipocaml12: I came from C as well, and was afraid of the syntax initialy. After a single evening of actually using it, I found it simpler than I though and quite elegant.
<iZsh> let x = 2 in x * 42 ( let x be 2 in x * 42 )
<pipocaml12> yes but when you have programmed in many languages, you start to learn NOT to interpret it like English :P
<pipocaml12> so you look for other interpretations
<iZsh> pipocaml12: I totally and uterly disagree
<rixed> pipocaml12: ML syntax was initialy intended for math students who were not already familiar with other programming languages, IIRC.
<pipocaml12> anyway, it was not my main question and now we have written so much about it :P
<iZsh> rixed: I really dislike the begin/end thing though in ocaml
<thelema> iZsh: use () instead
<iZsh> thelema: still ugly :)
<thelema> you'd prefer {}?
Kakadu has joined #ocaml
<iZsh> well, it often happens with sub matches
<thelema> yes, match within match requires () or begin/end
<iZsh> and it's ugly, begin match … end, is ugly
<thelema> that said, don't be afraid to make one mega match - ocaml is very good at optimizing matching code
<iZsh> I'd prefer, match … end (end being optional)
<rixed> iZsh: I never use begin/end. you can use parenths everywhere, which I find more convenient.
<iZsh> rixed: (match .. ) is still ugly
<iZsh> my issue is having anything before the keyword "match"
<rixed> iZsh: yes I agree for (match...).
<iZsh> thelema: I'm not afraid for the efficiency, I just like nice readable code. so I avoid mega match :)
<thelema> then hide the sub-match in a function?
<rixed> iZsh: but to be fair, once you are used to OCaml you find that C's "if (cond)" is ugly as well (what for the parenth here?)
<iZsh> thelema: not always practical nor necessary for small stuff
<iZsh> I'd really like an optional end keyword
<iZsh> that way, when necessary i could add a "end"
<thelema> meh, deal with the ( before match.
<iZsh> no way ;)
<iZsh> it's ugly!
Cyanure has joined #ocaml
decaf has joined #ocaml
<pippijn> is there function chaining in ocaml?
<Ptival> pippijn: what do you mean?
<Ptival> you can define let ( |> ) x f = f x
<Ptival> and do: let new_stuff = stuff |> stuff_transformer_1 |> stuff_transformer_2
<pippijn> no
<pippijn> (trans1 . trans2) stuff
<pippijn> to be
<pippijn> trans1 (trans2 stuff)
<Kakadu> let ( & ) f x = f x
<Kakadu> print_string & string_of_int & 123
<Ptival> pippijn: this is usually called function composition
eikke has joined #ocaml
<iZsh> pippijn: with "batteries" you can do f -| g
silver has quit [Read error: Connection reset by peer]
decaf has quit [Ping timeout: 276 seconds]
<pippijn> and then I can pass the result of that to another function?
<iZsh> why couldn't you?
Kakadu has quit [Read error: Connection reset by peer]
Kakadu has joined #ocaml
<pippijn> good
<iZsh> what's the easiest way to know where an exception is raised ?
<_habnabit> iZsh, programmatically?
<iZsh> _habnabit: no, just to debug
thomasga has quit [Quit: Leaving.]
<_habnabit> iZsh, export OCAMLRUNPARAM=b
Cyanure has quit [Ping timeout: 244 seconds]
<Drakken> Batteries also has |- if you want to list the functions in order of evaluation
<iZsh> _habnabit: not working (note that I am catching the exception at a higher level)
<_habnabit> iZsh, define 'not working'
<iZsh> it executes the program as usual
<iZsh> I dont see any extra output
<_habnabit> okay; that'll only output the traceback if it's completely unhandled
<_habnabit> otherwise you'll have to use Printexc
decaf has joined #ocaml
<iZsh> mmm the backtrace is empty when calling get_backtrace ()
<iZsh> oops
<iZsh> forgot to start the record
decaf has quit [Ping timeout: 276 seconds]
<_habnabit> normally I just use Printexc.print
<iZsh> ok great, it's working, thx!
Tobu has quit [Remote host closed the connection]
decaf has joined #ocaml
zuymanto has joined #ocaml
djcoin has joined #ocaml
eikke has quit [Ping timeout: 252 seconds]
Cyanure has joined #ocaml
pango has joined #ocaml
Kakadu has quit [Read error: Operation timed out]
zorun has joined #ocaml
eaSy60 has joined #ocaml
eikke has joined #ocaml
<adrien> I'm looking for a _very_ quick expample of phantom types for someone who's not stupid but who doesn't know ocaml
<adrien> hmm, I think I'll steal some bits of http://camltastic.blogspot.com/2008/05/phantom-types.html
eaSy60 has left #ocaml []
twittard has quit [Quit: twittard]
twittard has joined #ocaml
twittard has quit [Client Quit]
blablaa has joined #ocaml
Obfuscate has quit [Quit: WeeChat 0.3.5]
Obfuscate has joined #ocaml
Obfuscate has quit [Client Quit]
Obfuscate has joined #ocaml
decaf has quit [Ping timeout: 276 seconds]
thomasga has joined #ocaml
thomasga has quit [Client Quit]
twittard has joined #ocaml
jamii has quit [Quit: Leaving]
<pipocaml12> does anybody know where to find the Misc module with extensions to the Unix module???
twittard has quit [Remote host closed the connection]
<thelema> pipocaml12: misc?
twittard has joined #ocaml
<pipocaml12> yes misc
<adrien> pipocaml12: do you have an example function that comes from this module?
<adrien> extunix?
<adrien> ah
<pipocaml12> sc
<pipocaml12> sec
<adrien> afaik, it's not exported
<pipocaml12> but the source files, including the module, are not in the download
<adrien> for file functions, you might want to see FileUtils (ocaml-fileutils)
<pipocaml12> only text documents
twittard_ has joined #ocaml
<pipocaml12> I am trying to reuse some code in the sample and change it gradually. Otherwise it will take too much time, I will make my own code later
<pipocaml12> samples
<adrien> I don't know if this module is available; you can copy the code of the file you linked to if you abide by the QPL too
<adrien> (at least for now as you said)
<adrien> but what is your "high-level" goal btw?
<pipocaml12> I want to write a small program that send a mail (in SSL layer) and that is callable from R. the mail signals a big job done in R (statistical package)
<pipocaml12> Jython and other programming platforms that I could couple with R, do not do this. I do not want to mess in C
<pipocaml12> the mailer function works
<pipocaml12> but I cannot call it from R :(
<pipocaml12> only launch shell commands in a crippled way
<pipocaml12> so I am now trying to solve it by having a listening socket
<pipocaml12> this listening TCP socket works also
twittard has quit [Ping timeout: 276 seconds]
twittard_ is now known as twittard
mcclurmc has joined #ocaml
<pipocaml12> but I changed some stuff and I am frustrated with the syntax errors (without explanation from ocamlc)
<pipocaml12> I wont spread this code of course, need to get the job done for myself and it is very insecure anyway
<adrien> if you pastebin it, we can look at the syntax errors
* adrien can't help for the logic though =)
<pipocaml12> okay thx
<pipocaml12> one more note:
<pipocaml12> Note In the rest of this course, we use an auxiliary library Misc which contains several useful functions like try_finalize that are often used in the examples. We will introduce them as they are needed. To compile the examples of the course, the definitions of the Misc module need to be collected and compiled.
<pipocaml12> how sad, the code samples are nowhere, you have to extract them from the tex document sources
<thelema> pipocaml12: so just copy the text of any functions you use from the link above.
<pipocaml12> it also refers to misc functions that are not verbatim in the tutorial
<thelema> pipocaml12: does that link not have the misc functions you're looking for?
<pipocaml12> yes I can use that possibly, I just encountered that one too. But strange that I really have to look there?? There must be a unintended mistake made by the authors of ocamlunix.ocamlforge.org ??
<pipocaml12> I will check that old file now then
<thelema> old? it was last updated on dec 28th of 2011
<thelema> I agree it should be linked to from the ocamlunix page.
<pipocaml12> sorry, old is the wrong word. I found that this file was removed from the current revision, maybe I did not look properly
<pipocaml12> I will paste the (simple, short) code that I have so that you see which functions I need. They are not the file in the VCS
<pipocaml12> moment
<pipocaml12> sigh my internet is slow, I am trying to log in to code paste site
<adrien> wgetpaste =)
<pipocaml12> what is that
<adrien> pastes from the command-line
<pipocaml12> ideone.org as well as pastebin do not respond. I am on WiFi in a busy student complex ...
<adrien> shout that there's free beer and pizza in some other building and everyone will leave =)
Xizor has joined #ocaml
eikke has quit [Ping timeout: 246 seconds]
<pipocaml12> problem is that it is in the middle of nowhere, so everyone is eating pizza in another block that sucks bandwith from the same WiFi pole ;)
<pipocaml12> lines 226/227 need those special functions
<pipocaml12> it seems necessary too because handling connections is asynchronous :( could do without that though
oriba has joined #ocaml
<pipocaml12> first things first ...
<pipocaml12> at line 193 there is syntax error
<pipocaml12> I have changed it since I pasted it first, so refresh if you are looking at it ... but still at that same spot a syntax error
<pipocaml12> I do not see it
<adrien> you can' t do:
<adrien> let foo a =
<adrien> a;
<adrien> ';' means that there is something else coming up afterwards
<pipocaml12> okay
<pipocaml12> it still does not compile if I do:
<pipocaml12> let split_str sep str =
<pipocaml12> Str.split (Str.regexp_string sep) str
<pipocaml12> ;;
<pipocaml12> and also not without ;;
<pipocaml12> at the same lines, when without ;; at 195 (the next let)
<pipocaml12> anyone has an idea?
<adrien> yeah, ';;' forces ocaml to parse what was before as a valid ocaml code
djcoin has quit [Quit: WeeChat 0.3.2]
<thelema> those two lines of code look correct (without the ;;) - look elsewhere for the problem
<adrien> so it prevents syntax errors from being reported later in the code
<pipocaml12> ? that seems weird? why does it force ocaml to parse it as valid code?
<adrien> that's because of line 186
<adrien> you have the same thing =)
<thelema> (unless the error is caused by a failure to link in the str library
<adrien> well, it forces it as _trying_ to parse it as valid code
<pipocaml12> and is there an other for more detailed compilation info? I enabled options:
<pipocaml12> ocamlfind ocamlopt -annot -g -i -linkpkg -w +A -verbose -package unix,netstring,smtp,ssl,str sendmail.ml -o sendmail
<thelema> ok, str should be linked in
<pipocaml12> still it does not give any more information than a location. But is seems line 186 is the real problem?
<adrien> I think camlp4 parsing would help: warnings don't help for syntax errors
smondet has joined #ocaml
<adrien> thelema has a point too: you won't be able to run your code on ideone probably (but syntax errors are much earlier in the compilation process)
<pipocaml12> okay line 186 .... I'm, hitting myself now. :X\
<adrien> =)
<pipocaml12> "let () =", () means empty tuple so it stand for a 'main' like entry point if its in the global level ... or not?
<pipocaml12> I will reorganize it
<pipocaml12> (BTW i'm compiling it locally not on Ideone, that is just a gimmick when you cannot change the paramters to the ocaml compiler)
<thelema> "let () = ..." just means evaluate the following code and throw away the result (but error if the result isn't ())
<pipocaml12> so it is translatable to a void procedure in C? a procedure, not a function?
<pipocaml12> not a main function at least, okay
<pipocaml12> I removed it an placed that stuff in the top level
<pipocaml12> thank god, I have found the missing Misc functions here: http://rosettacode.org/wiki/Hello_world/Web_server
<pipocaml12> trying again ...
<thelema> like void. ocaml doesn't have a main function that returns int - every value in your program is evaluated in the order that they're in modules
<pipocaml12> that is very elegant. No restrictive convention about returning an int to signal error conditions, I am certainly thrilled by Ocaml (might sound silly but OCaml does strike me as compact and powerful ... more than I already though)
<pipocaml12> thought
<pipocaml12> okay I updated the code at: http://ideone.com/QoWTO
<pipocaml12> next little problem
<pipocaml12> File "sendmail.ml", line 173, characters 4-182:
<pipocaml12> Error: This expression is not a function; it cannot be applied
<pipocaml12> Arg.parse arg_list
<pipocaml12> (fun x -> raise (Arg.Bad ("Invalid argument: " ^ x)))
<pipocaml12> usage
<pipocaml12> it is the second line in the above snippet
<thelema> do you need a ;?
<pipocaml12> okay what am I doing here
<pipocaml12> I am providing three arguments to Arg.parse, right?
<pipocaml12> arguments are separated by whitespace ...
<pipocaml12> no problem ... but ... am I really providing a tuple of three arguments?
<pipocaml12> or what else ... ? Because why would I need a ; if I am not delimiting phrases thelema?
<adrien> your error is line 173, not 182
<adrien> it spans over 178 = 182 - 4 chars however
<pipocaml12> hmm
_andre has quit [Quit: leaving]
<adrien> and you can't write
<pipocaml12> okay damn
<adrien> "Arg.parse ..." like that
<adrien> not alone in the file
<adrien> so:
<adrien> let () = Arg.parse...
<pipocaml12> okay, now it compiles here :)
<pipocaml12> but adrien, by coincidence the error was not on 173 but around 182 :) ha
<adrien> yup, noticed ;-)
<pipocaml12> Now if I do this in my R console connectionO <- socketConnection(host = "127.0.0.1", port = 7777); readLines(connectionO)
<pipocaml12> I am greeted with [1] "Hello" :) :)
<pipocaml12> nice
Submarine has quit [Ping timeout: 276 seconds]
<adrien> =)
Sedrikov has joined #ocaml
<pipocaml12> now I have another syntax error
<pipocaml12> it has to do with "in" again I suspect
<pipocaml12> at line 265, characters 23-25:
<pipocaml12> Syntax error
<_habnabit> that doesn't help without the source file
<pipocaml12> there are two "in" there
<pipocaml12> habnabit I have linked the source file two times already, it was some time ago
<pipocaml12> moment
<_habnabit> and presumably you changed it since
<pipocaml12> yes? the file is up to date
<pipocaml12> what the code does there is copy data read in from a socket connection I suppose
<pipocaml12> I do not want that and I do not understand dup2
<pipocaml12> I only want to read from the socket and parse that message
twittard has quit [*.net *.split]
ski has quit [*.net *.split]
maufred_ has quit [*.net *.split]
rixed has quit [*.net *.split]
ccasin has quit [*.net *.split]
srcerer has quit [*.net *.split]
bacam has quit [*.net *.split]
shachaf has quit [*.net *.split]
tlockney has quit [*.net *.split]
The_third_man has quit [*.net *.split]
hnrgrgr has quit [*.net *.split]
datkin has quit [*.net *.split]
bobry has quit [*.net *.split]
yezariaely has quit [*.net *.split]
pippijn has quit [*.net *.split]
micro has quit [*.net *.split]
cyphase has quit [*.net *.split]
bnwr has quit [*.net *.split]
chambart has quit [*.net *.split]
NaCl has quit [*.net *.split]
ousado has quit [*.net *.split]
larsrh has quit [*.net *.split]
Schadenfreude has quit [*.net *.split]
deavid has quit [*.net *.split]
hsuh has quit [*.net *.split]
Nass has quit [*.net *.split]
matthewt has quit [*.net *.split]
hcarty has quit [*.net *.split]
zorun has quit [*.net *.split]
dsheets has quit [*.net *.split]
Derander_ has quit [*.net *.split]
r126f has quit [*.net *.split]
foocraft has quit [*.net *.split]
fraggle_ has quit [*.net *.split]
Ptival has quit [*.net *.split]
pheredhel has quit [*.net *.split]
diml has quit [*.net *.split]
tomprince has quit [*.net *.split]
yezariaely has joined #ocaml
twittard has joined #ocaml
zorun has joined #ocaml
rixed has joined #ocaml
dsheets has joined #ocaml
ccasin has joined #ocaml
datkin has joined #ocaml
bobry has joined #ocaml
ski has joined #ocaml
srcerer has joined #ocaml
pippijn has joined #ocaml
micro has joined #ocaml
cyphase has joined #ocaml
Derander_ has joined #ocaml
r126f has joined #ocaml
foocraft has joined #ocaml
bnwr has joined #ocaml
The_third_man has joined #ocaml
fraggle_ has joined #ocaml
Ptival has joined #ocaml
hnrgrgr has joined #ocaml
pheredhel has joined #ocaml
chambart has joined #ocaml
NaCl has joined #ocaml
bacam has joined #ocaml
diml has joined #ocaml
ousado has joined #ocaml
maufred_ has joined #ocaml
shachaf has joined #ocaml
larsrh has joined #ocaml
matthewt has joined #ocaml
tlockney has joined #ocaml
tomprince has joined #ocaml
Schadenfreude has joined #ocaml
deavid has joined #ocaml
hsuh has joined #ocaml
hcarty has joined #ocaml
Nass has joined #ocaml
blablaa has quit [Quit: Leaving]
<pipocaml12> it compiles now, but only with some tricks
srcerer has quit [Ping timeout: 245 seconds]
Snark has quit [Quit: Quitte]
<pipocaml12> why do you have to repeat the module Unix in this code "let ipaddr = (Unix.gethostbyname hostname).Unix.h_addr_list.(0)"
<pipocaml12> why Unix.h_addr_list
<thelema> pipocaml12: because record fields are namespaced
<thelema> This is needed to have "let get_x r = r.x" be type-inferable
<edwin> you can open Unix and then you don't have to prefix anymore
<pipocaml12> oh no I like explicitness
<smondet> you can also write let ip = Unix.((gethostbyname hostname).h_addr_list.(0))
<thelema> or in 3.12: Unix.((gethostbyname hostname).h_addr_list.(0))
<thelema> :)
<adrien> or, in recent version of ocaml: let ipaddr = Unix.((gethostbyname hostname).h_addr_list.(0))
<pipocaml12> open Unix did not work so I commented it out, I am using ocamlc not ocamlopt BTW
<adrien> ='(
<adrien> or: 'let open Unix in ..."
<thelema> pipocaml12: everything should work the same in ocamlc as ocamlopt
<pipocaml12> smondet I like that notation better :)
<adrien> which is usaully my favortite
<pipocaml12> I am no using findlib to link against Unix, does that make open Unix impossible? Otherwise it must be a different problem
<pipocaml12> no = now
<pipocaml12> pfff ...
<pipocaml12> Error: Error while linking sendmail.cmo:
<pipocaml12> Reference to undefined global `Unix'
<edwin> global? shouldn't it say module?
<pipocaml12> I have now open Unix ;; as well as Unix. prefix ..
<pipocaml12> I guess I put Unix. somewhere wrong
<pipocaml12> no idea where ...
<adrien> unix.cma on the command line
<edwin> if you open then don't use the prefix
<adrien> or .cmxa for native code
<smondet> or -linkpkg with ocamlfind
<adrien> too =)
<pippijn> or -pkg with ocamlbuild
avsm has joined #ocaml
<pipocaml12> i am still struggling with it
<pipocaml12> i use this compilation command:
<pipocaml12> ocamlfind ocamlc -package unix,netstring,smtp,ssl,str sendmail.ml -o sendmail
<adrien> add -linkpkg
<pipocaml12> is -linkpkg only necessary for Unix? how can Iearn about that (I have the API doc for the Unix module open)
<thelema> pipocaml12: it's necessary any time you're using -package
<pipocaml12> is "open" equivalent to -linkpg for native compiled code (I would think not)? and why does "open Unix ;;" fail with Reference to undefined global `Unix'
<thelema> not at all
<thelema> and "open Unix" fails when ocaml can't find a module that provides unix
<pipocaml12> in the man page for ocamlc 3.12.0, i cannot find the option -linkpkg, only -linkall
<pipocaml12> has the name changed or am I missing somehting? I am now just using both
<edwin> linkpkg is from ocamlfind
<pipocaml12> oh
<pipocaml12> I will study that better later and use ocamlbuild instead of a shell script
<pipocaml12> how do you convert a string list to a string
<adrien> String.concat ?
<_habnabit> pipocaml12, http://caml.inria.fr/pub/docs/manual-ocaml/libref/index.html <- have you seen this yet?
<pipocaml12> no thank you
<iZsh> i want to pretty print my AST to a dot (graphviz) file. should i just do the pretty print myself, or is there a lib which could significantly make my life easier?
<iZsh> oops pipocaml12
<pipocaml12> how do i fix this: let string_of_list l = "[" ^ String.concat "; " (List.map fun s -> s l) ^ "]";; (* convert list of string to string *)
EmmanuelOga has joined #ocaml
<pipocaml12> llvm.org/docs/ProgrammersManual.html see "Viewing graphs while debugging code" I thought you can run Ocaml bytecode on LLVM?
<pipocaml12> @iZsh; maybe not useful, perhaps it is
<iZsh> pippijn:
<iZsh> pipocaml12: not useful at all :)
<pipocaml12> I have fixed my function, can someone please give me a hint how to coerce a 'list -> string' into a string?
<pipocaml12> let () = Printf.printf "\t%s\t%s\t%s\nsplitted:" string_of_list splitted_str in
<pipocaml12> i thought it was something with ' .... cant find it anymore
<iZsh> pipocaml12: list -> string is a function which take a list as a parameter and return a string
<iZsh> so to coerce it to string, you just give it a list?
<iZsh> print_endline (String.concat splitted_str)
<pipocaml12> I do that as far as I know, and I got this ...
<pipocaml12> Error: This expression has type string list -> string
<pipocaml12> but an expression was expected of type string
<iZsh> yes
<iZsh> because %s espect a string
<iZsh> and you gave it string_of_list
<pipocaml12> okay so I give a function hehe
<iZsh> which is a string list -> string
<pipocaml12> I get it
<pipocaml12> I am passing the function as value
<iZsh> you want (string_of_list splitted_str)
<iZsh> which is a string
<pipocaml12> thanks
<iZsh> but string_of_list is just String.concat
<pipocaml12> does enclosing an expression that begins with a function name and that provides the proper arguments within parentheses always cause that function to be evaluated
<iZsh> yes
<iZsh> it's not a lazy language
<iZsh> it is evaluated as soon as it can be
<pipocaml12> " let () = Printf.printf "t%s" "test" "
<pipocaml12> is the same as:
<pipocaml12> (Printf.printf "%s" "test")
<pipocaml12> ?
<_habnabit> no.
<pipocaml12> hmm that let may not be called
<pipocaml12> I will think it over
<iZsh> you use the parenthesis for the priority, not to force an evaluation
edwin has quit [Remote host closed the connection]
<iZsh> anyway, afk, reading the dot specs
<adrien> I think there are bindings too
<pipocaml12> let () = Printf.printf "\t%s\t%s\t%s\nsplitted:" (String.concat splitted_str) in results in an error :( I am sorry I must be making simple mistakes all the time
<adrien> that might provide some more safety
<pipocaml12> Error: This expression has type string list
<pipocaml12> but an expression was expected of type string
<adrien> plus dot won't let you write parens and dots in labels
<pipocaml12> oh I see
<pipocaml12> stupid
eikke has joined #ocaml
<pippijn> are all && operators shortcut?
<pippijn> hm, I suppose not
<pippijn> stupid question
<pippijn> is it possible to implement one's own shortcut operator?
<pippijn> (without camlp4)
<adrien> # let (&&) = (||);;
<adrien> val ( && ) : bool -> bool -> bool = <fun>
<adrien> # false && true;;
<adrien> - : bool = true
<adrien> good night =)
<pippijn> meh
<pippijn> adrien: is it shortcut?
<adrien> I don't understand what you mean with "shortcut": these are simply operators
<adrien> there are a few rules (the details is in ocaml's official documentation)
<_habnabit> # let rec aux = function false -> false | x -> aux x in aux false && aux true;;
<_habnabit> - : bool = false
<pippijn> a && b
<_habnabit> that should answer your question
<pippijn> if a is true, b is not evaluated
<adrien> mostly, you declare them by surrounding them with (...) and they have to be non-alphanumeric (or something like that)
Cyanure has quit [Remote host closed the connection]
Xizor has quit [Ping timeout: 260 seconds]
<pippijn> oh fun
<thelema> of course || and && short-circuit
<_habnabit> yes, that's what my code demonstrated
<pippijn> _habnabit: yes
<_habnabit> mine is perhaps a little more dramatic
<jonafan> i'll fix it: let (&&) = (&&)
<pippijn> 00:04 < pippijn> is it possible to implement one's own shortcut operator?
ulfdoz has quit [Ping timeout: 248 seconds]
<thelema> pippijn: no, not possible
<pippijn> ok
<pippijn> thanks
<pippijn> that's all I wanted to know :)
<thelema> all user-defined functions have all their arguments evaluated before the function begins
<Ptival> # false && (let _ = assert false in true);;
<Ptival> - : bool = false
<Ptival> meh
pipocaml12 has quit [Quit: Leaving]
<Ptival> the best you can do is "foo &&& lazy bar" or "foo && (fun _ -> bar)" :\
<Ptival> &&&*
Sedrikov has quit [Quit: Bye all, see you next time!]
letrec has joined #ocaml
zuymanto has left #ocaml []
Nass has quit [Quit: WeeChat 0.3.2]
smondet has quit [Ping timeout: 245 seconds]
eikke has quit [Ping timeout: 260 seconds]
chambart has quit [Ping timeout: 276 seconds]
<otk> let f ~__:___ ~_:____ = ____ - ___;;
<otk> always was a fan of morse code
avsm has quit [Quit: Leaving.]
chambart has joined #ocaml
letrec has quit [Ping timeout: 260 seconds]