cjeris changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
moglum has quit []
skal has quit [Remote closed the connection]
mikeX has joined #ocaml
moconnor has left #ocaml []
cjeris has quit [Read error: 104 (Connection reset by peer)]
malune_ has quit [Read error: 110 (Connection timed out)]
benny_ has joined #ocaml
mikeX has quit ["leaving"]
benny has quit [Read error: 110 (Connection timed out)]
the_dormant has joined #ocaml
the_dormant has quit [Client Quit]
kelaouchi has quit [zelazny.freenode.net irc.freenode.net]
ulfdoz has quit [zelazny.freenode.net irc.freenode.net]
benny_ has quit [zelazny.freenode.net irc.freenode.net]
mbishop has quit [zelazny.freenode.net irc.freenode.net]
z__z has quit [zelazny.freenode.net irc.freenode.net]
mrvn has quit [zelazny.freenode.net irc.freenode.net]
Hadaka has quit [zelazny.freenode.net irc.freenode.net]
benny_ has joined #ocaml
kelaouchi has joined #ocaml
mbishop has joined #ocaml
ulfdoz has joined #ocaml
z__z has joined #ocaml
mrvn has joined #ocaml
Hadaka has joined #ocaml
kelaouchi has quit [Read error: 104 (Connection reset by peer)]
kelaouchi has joined #ocaml
zmdkrbou has quit [zelazny.freenode.net irc.freenode.net]
mattam has quit [zelazny.freenode.net irc.freenode.net]
slipstream has quit [zelazny.freenode.net irc.freenode.net]
G has quit [zelazny.freenode.net irc.freenode.net]
ita|afk has quit [zelazny.freenode.net irc.freenode.net]
ulfdoz has quit [zelazny.freenode.net irc.freenode.net]
mbishop has quit [zelazny.freenode.net irc.freenode.net]
benny_ has quit [zelazny.freenode.net irc.freenode.net]
mrvn has quit [zelazny.freenode.net irc.freenode.net]
z__z has quit [zelazny.freenode.net irc.freenode.net]
Hadaka has quit [zelazny.freenode.net irc.freenode.net]
jlouis_ has quit [zelazny.freenode.net irc.freenode.net]
Mr_Awesome has quit [zelazny.freenode.net irc.freenode.net]
sourcerror has quit [zelazny.freenode.net irc.freenode.net]
Smerdyakov has quit [zelazny.freenode.net irc.freenode.net]
cmeme has quit [zelazny.freenode.net irc.freenode.net]
tree_ has quit [zelazny.freenode.net irc.freenode.net]
ramkrsna has quit [zelazny.freenode.net irc.freenode.net]
Amorphous has quit [zelazny.freenode.net irc.freenode.net]
twobitsprite has quit [zelazny.freenode.net irc.freenode.net]
kelaouchi has quit [zelazny.freenode.net irc.freenode.net]
Submarine has quit [zelazny.freenode.net irc.freenode.net]
mnemonic has quit [zelazny.freenode.net irc.freenode.net]
Demitar has quit [zelazny.freenode.net irc.freenode.net]
gunark has quit [zelazny.freenode.net irc.freenode.net]
joshcryer has quit [zelazny.freenode.net irc.freenode.net]
romanoffi has quit [zelazny.freenode.net irc.freenode.net]
vorago has quit [zelazny.freenode.net irc.freenode.net]
_blackdog has quit [zelazny.freenode.net irc.freenode.net]
flux has quit [zelazny.freenode.net irc.freenode.net]
TaXules has quit [zelazny.freenode.net irc.freenode.net]
Nutssh has quit [zelazny.freenode.net irc.freenode.net]
tsuyoshi has quit [zelazny.freenode.net irc.freenode.net]
levi_home has quit [zelazny.freenode.net irc.freenode.net]
svenl has quit [zelazny.freenode.net irc.freenode.net]
haelix has quit [zelazny.freenode.net irc.freenode.net]
Oatmeat|umn has quit [zelazny.freenode.net irc.freenode.net]
oracle1 has quit [zelazny.freenode.net irc.freenode.net]
smimou has quit [zelazny.freenode.net irc.freenode.net]
gim has quit [zelazny.freenode.net irc.freenode.net]
eroyf has quit [zelazny.freenode.net irc.freenode.net]
kelaouchi has joined #ocaml
Hadaka has joined #ocaml
mrvn has joined #ocaml
z__z has joined #ocaml
ulfdoz has joined #ocaml
mbishop has joined #ocaml
benny_ has joined #ocaml
jlouis_ has joined #ocaml
Mr_Awesome has joined #ocaml
sourcerror has joined #ocaml
Smerdyakov has joined #ocaml
Submarine has joined #ocaml
mnemonic has joined #ocaml
cmeme has joined #ocaml
Demitar has joined #ocaml
romanoffi has joined #ocaml
tree_ has joined #ocaml
gunark has joined #ocaml
ramkrsna has joined #ocaml
Amorphous has joined #ocaml
twobitsprite has joined #ocaml
joshcryer has joined #ocaml
vorago has joined #ocaml
zmdkrbou has joined #ocaml
mattam has joined #ocaml
slipstream has joined #ocaml
G has joined #ocaml
ita|afk has joined #ocaml
smimou has joined #ocaml
gim has joined #ocaml
eroyf has joined #ocaml
haelix has joined #ocaml
Oatmeat|umn has joined #ocaml
oracle1 has joined #ocaml
_blackdog has joined #ocaml
flux has joined #ocaml
TaXules has joined #ocaml
Nutssh has joined #ocaml
tsuyoshi has joined #ocaml
levi_home has joined #ocaml
svenl has joined #ocaml
m3ga has joined #ocaml
Ai_Itai has joined #ocaml
cratylus has joined #ocaml
cratylus has left #ocaml []
Smerdyakov has quit ["Leaving"]
ygrek has joined #ocaml
the_dormant has joined #ocaml
the_dormant has quit [Remote closed the connection]
Demitar has quit [Read error: 113 (No route to host)]
moglum has joined #ocaml
bluestorm_ has joined #ocaml
ed-t8 has joined #ocaml
bluestorm__ has joined #ocaml
moglum has quit [Read error: 110 (Connection timed out)]
ygrek has quit [Remote closed the connection]
Mr_Awesome has quit ["...and the Awesome level drops"]
bluestorm_ has quit [Read error: 113 (No route to host)]
love-pingoo has joined #ocaml
moglum has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
sourcerror has quit [Read error: 110 (Connection timed out)]
sourcerror has joined #ocaml
m3ga has joined #ocaml
moglum has quit []
mnemonic has quit [Read error: 104 (Connection reset by peer)]
asylumgov has joined #ocaml
<asylumgov>
Hi all, does anybody have an idea how to handle "include"-type statements with ocamllex/ocamlyacc?
<asylumgov>
i.e., in the language I'm parsing, there can be statements of the form "include(filename)", where "filename" describes an external file which contains statements in the same language again
<bluestorm__>
asylumgov: this isn't a ocamlyacc-handling, but you could code a ocaml fonction that, given a file name, try to open and parse it (raising an exception on error)
<bluestorm__>
and then
<bluestorm__>
Include { try_include $1 }
<bluestorm__>
(where try_include in the ocaml function, coded in the header of you .mly file )
<bluestorm__>
(Include is supposed to be your inclusion token, giving the included filename)
<asylumgov>
so try_include reads the file and calls the parser's entry function?
<asylumgov>
won't this cause some kind of circularity?
<bluestorm__>
hmm
<bluestorm__>
you're right, the parser entry function isn't defined at this stage
<bluestorm__>
hm
<asylumgov>
the naive way would be to preprocess the file and just expand the "include"-statements by inserting the file contents
<asylumgov>
but I was hoping to somehow do it in one pass
<bluestorm__>
you could also create a "Include this file" expression in you language
<bluestorm__>
(i mean, in the AST)
<bluestorm__>
and the recall the parser function at eval-time
<asylumgov>
yes
<asylumgov>
but this would be complicated
<bluestorm__>
hm
<asylumgov>
in my specific case
<bluestorm__>
but more flexible than handling at lex/yacc-time
<bluestorm__>
because you can have a rich error handler
<bluestorm__>
(whereas the .mly header is not a adequate place to put lots of code for smart include error handling)
<asylumgov>
the problem is, that there is already a lot of processing on the data structures at parse time, so I would have to duplicate that or move it out of the parser module
<asylumgov>
yes
<asylumgov>
well thanks anyway, I'll give it some more thought
<ita|afk>
it is 2007 and we still cannot write parsers properly
ita|afk is now known as ita
moglum has joined #ocaml
_JusSx_ has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
mnemonic has joined #ocaml
<mnemonic>
hi
<ita>
mnemonic: hey
jlouis_ has quit [Remote closed the connection]
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
slipstream-- has quit [Read error: 104 (Connection reset by peer)]
asylumgov has left #ocaml []
moglum has quit []
Demitar has joined #ocaml
slipstream has joined #ocaml
malune_ has joined #ocaml
ed-t8 has quit [Read error: 110 (Connection timed out)]
moglum has joined #ocaml
pedro_soc has joined #ocaml
ygrek has joined #ocaml
ita is now known as ita|afk
pango has quit [Remote closed the connection]
pango has joined #ocaml
bluestorm__ has quit [Remote closed the connection]
fax8 has joined #ocaml
Ai_Itai has quit ["Leaving"]
fax8 has quit ["using sirc version 2.211+KSIRC/1.3.12"]
ygrek has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
<twobitsprite>
I have a .ml file, that has EXTEND expressions... I can't seem to get it to compile... I've tried "ocamlopt -pp camlp4o foo.ml" and "ocamlopt -I +camlp4 gramlib.cmxa foo.ml" but every time I get a syntax error in my EXTEND expression, and I'm almost positive that it should work..
ygrek has joined #ocaml
pango has joined #ocaml
<twobitsprite>
the documentation shows how to use extentions in the top level, and how to link with extention libs, but not how to compile things with extention libs.....
<twobitsprite>
nevermind... I think I'm getting somewhere
<twobitsprite>
hmm... it seems camlp4o doesn't like having streams within quotations... i.e. I have " ... -> <:expr< [< $e1$; $e2$ >] >> ]]" and it gives me "illegal start of expression" whereas, if I turn that into a list instead of a stream, it compiles fine.
noteventime has joined #ocaml
malune__ has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
<flux>
twobitsprite, is it interesting to play around with camlp4o? I
<flux>
I've never got myself to get started :)
<twobitsprite>
flux: it's wierd
malune_ has quit [Read error: 110 (Connection timed out)]
<twobitsprite>
I wish the camlp4 syntax was a bit more integrated with/similar to the actual ocaml syntax
<twobitsprite>
but it's more like a completely different language
<twobitsprite>
I.e., I wish ocaml had something more like Scheme's macros... where it still feels like the same language
<pango>
it's OCaml too, but revised syntax
<pango>
you can use that syntax for plain OCaml programs, too
<twobitsprite>
pango: well... ocamlp4o is still uses regular ocaml syntax... but I mean the syntax for grammar extentions
<noteventime>
Are the any performance differences between calling opengl comands from C or through an FFI?
<pango>
twobitsprite: what I'm saying
<noteventime>
Well, libraries in general
<twobitsprite>
i.e. "EXTEND expr: LEVEL "simple" ..." etc, is kind of wierd
<flux>
noteventime, well, there is some overhead
<flux>
noteventime, to evaluate if it matters, you need to benchmark
<flux>
noteventime, when called from ocaml there is bound to be more code than when calling directly from C
<twobitsprite>
does the ocaml mailing list not send you your own messages?
pango has quit [Remote closed the connection]
<ita>
is any of you working on the caml compiler by the way ? (patching it, ..) ?
<twobitsprite>
I thought the compiler was completely maintained by inria?
pango has joined #ocaml
Smerdyakov has joined #ocaml
<ita>
well, i wonder if it would be possible to patch the compiler so it is able to find the sources automatically (like the c# compilers)
<Submarine>
just do it ! :-)
<ita>
compilation scripts are annoying
<ita>
but will the ocaml guys accept it ?
<bluestorm_>
i think they're pretty conservative
<bluestorm_>
but, wasn't ocamldep done for that purpose ?
<twobitsprite>
they get paid to perform research on compilers, etc, and I think they like to be able to take credit for thier work instead of accepting community contributions
_blackdog has quit [Remote closed the connection]
<bluestorm_>
i'm not sure it's the good explanation
<ita>
bluestorm_: well, the c# compilers are pretty smart usually, and no scripts required
<bluestorm_>
giving them the copyright would be the solution to this problem
<ita>
ah, good idea
<ita>
i suppose no one is involved too much with the compiler in here then
<twobitsprite>
I suppose you could fork the compiler, but that's usually frowned up on unless you plan to do some serious overhauling and end up with a fairly distinct product
<ita>
heh
<ita>
i have f0rkd scons, that's enough :-)
<pango>
twobitsprite: the compiler is under QPL
<ita>
gpl or qpl ?
<twobitsprite>
pango: doesn't that allow for forking, so long as you give credit to the authors, and don't claim to be the original product?
<pango>
twobitsprite: you'll have to distribute your fork as patches, from what I'm reading
<twobitsprite>
pango: that's right... forgot about that part... lame
<ita>
oh nice, i use the same qpl license for my works
<twobitsprite>
so, does that preclude distributing your fork as a package containing the original unmolested source code with the patches and as a part of the build process simply apply the patches?
<ita>
yes
<Smerdyakov>
I don't see the problem.
<Smerdyakov>
The SML toolset is superior in pretty much every way, including much nicer licensing, so take this as an eye-opener that drives you to switch. ;)
love-pingoo is now known as estelle
estelle is now known as love-pingoo
<ita>
Smerdyakov: does sml have something like twt ?
<flux>
an ocaml-quality preprocessor for sml would personally make it more interesting for me
<flux>
(hm, redundancy detected within statement :))
<bluestorm_>
"ocaml" "quality" ? :-°
<ita>
inria(tm)
<ita>
he probably meant : give me an inria-grade preprocessor for customizing sml
<ita>
inria as in "Institut National de Recherche en Informatique Amusante"
<flux>
that is: a c preprocessor isn't going to cut it
the_dormant has joined #ocaml
<tsuyoshi>
omg that's awful
<flux>
:)
<tsuyoshi>
so there are people that actually prefer significant whitespace? I never really believed it...
<bluestorm_>
hm
the_dormant has quit [Client Quit]
<bluestorm_>
what's the problem with significant whitespace actually ?
<bluestorm_>
(apart from the clumsy layouting rules that only your editor can understand)
<tsuyoshi>
I find it very annoying
<flux>
significant whitespace does look neat
<flux>
but I like to define the scopes with actual visible tokens
<flux>
and let the editor reindent based on those
<tsuyoshi>
but getting rid of the ; seems really wrong in ocaml
<bluestorm_>
why ?
<tsuyoshi>
it's an operator, not a statement-separator
<flux>
it's not actually an operator, is it?
<tsuyoshi>
yes it is
<flux>
if you look at the language specification?
* tsuyoshi
doublechecks spec
<mrvn>
imagine you have some code and you want to insert "if foo then" before it. That means you have to reindent the whole block consistently so it all falls under the "if". With actual tokens you just add them around the block.
<flux>
; is not in the list of infix-symbols, prefix-symbols or operator characters
<ita>
tsuyoshi: i do
<tsuyoshi>
ok, spec says it's a control structure
<bluestorm_>
it's a "control structure"
ygrek has quit [Remote closed the connection]
<bluestorm_>
hm
<flux>
infact it also states ; is a keyword
<tsuyoshi>
ah, I gotta go now
<tsuyoshi>
going to brunch with my mom
<ita>
the whitespace is a keyword in python
ygrek has joined #ocaml
<flux>
albeit, I'm interested if anything would break if ; were an operator
<flux>
for one, you could redefine it
<mrvn>
; has multiple uses. type foo = { x:int; y:int }, [1;2;3], foo (); bar ()
<bluestorm_>
flux:
<flux>
yeah, I suppose that's why it cannot be an operator
<ita>
; is an operator
<flux>
it would lead to parsing ambiguities
<flux>
ita, where does it say so?
<bluestorm_>
does operator have a fixed evaluation rule ?
<ita>
flux: the gramar ?
<bluestorm_>
i think this could create some problem
<ita>
whoops no
<bluestorm_>
even && and || are described as control structures in the manual
<bluestorm_>
(but "boolean operators" too)
<bluestorm_>
hm
<flux>
bluestorm_, yeah, they are handled specially, with the shortcut-rule - or lazy evaluation, if you will
<bluestorm_>
( ; ) could be described the same actually
<flux>
could be, but isn't
<mrvn>
bluestorm_: but { ...; ...} can't
<bluestorm_>
yes
<mrvn>
or [...;...;...]
<flux>
it might be that the change from ; being a keyword to being an operator wouldn't be a trivial one
<mrvn>
actualy it could for lists but with different meaning
<flux>
even if most of the time for human the semantics would be clear
<ita>
the { ...; ...} and [...;...;...] are not annoying, the excessive ( ) and ; are
<bluestorm_>
hm
<mrvn>
ita: does twt get rid of those two?
<ita>
mrvn: the two last yes
<ita>
mrvn: not the two first
<mrvn>
I ment the former
<mikeX>
mrvn: you can squeeze the if in between if there's space, and it's temporary, otherwise you can just reindent with an s/.../ expression and a decent editor
<mrvn>
mikeX: error prone
<mrvn>
plus you have the problem of tabs and space being different
<flux>
(in normal ocaml, not the whitespace-thingy)
<mikeX>
well I only use spaces :P
<ita>
mrvn: there is an option to allow only tabs or only spaces
<mikeX>
mis-indented statements are more error-prone I think
<mrvn>
if you have a large project with multiple people someone will want the other kind or mix the two.
<mikeX>
yeah that's probably true, but you should decide on a coding standard in such a case
<mrvn>
How do you break a statement into multiple lines in twt?
<ita>
mrvn: as usual
<flux>
I remember once having a bug with nested matches
<flux>
(that the compiler didn't catch)
<mrvn>
ita: meaning?
love-pingoo has quit ["Connection reset by pear"]
<ita>
mrvn: code on the next line without more indentation
<mrvn>
foo bar
<mrvn>
baz blub
<mrvn>
? I though that ment foo bar; baz blub
<ita>
mrvn: buahaha
<mikeX>
you mean like the \ continuation character in python?
<ita>
no
<ita>
mikeX: sorry i must go now
ita is now known as ita|afk
<mikeX>
bye
<ita|afk>
later
<ita|afk>
:-/
_blackdog has joined #ocaml
_blackdog has quit [Client Quit]
_blackdog has joined #ocaml
_blackdog has quit [Client Quit]
_blackdog has joined #ocaml
ev` has joined #ocaml
<ev`>
Hello, I'm starting with caml and I have some questions about a piece of code :)
<Smerdyakov>
First rule of IRC: never ask to ask.
<ev`>
I know... it was to say hello :)
<ev`>
let sum i =
<ev`>
let sum2 j =
<ev`>
i + j
<ev`>
in
<ev`>
sum2;;
<ev`>
this is the code
pango has quit [Remote closed the connection]
<Smerdyakov>
You shouldn't paste so many lines of code in any IRC channel without getting permission first.
<Smerdyakov>
Put it up on the web somewhere instead, and give a URL.
pango has joined #ocaml
<flux>
I prefer such short code fragments to be put into a single line; although it might be difficult for newbies to read, it shouldn't pose much difficult to regulars here.. but maybe it's just my preference.
<ev`>
Sorry for the paste..
<pango>
ev`: anyway go ahead, what are the questions ?
<ev`>
anyways.. I dont understand how it works..
<mikeX>
ev`: do you understand what it does?
<ev`>
it creates a function called sum
<Smerdyakov>
ev`, what text are you reading to learn OCaml?
<ev`>
Introduction to the Objective Caml Programming Language
<ev`>
Jason Hickey
<Smerdyakov>
OK, I don't know it, but I know Jason, so I bet it's good. :)
<mikeX>
ev`: yes, do you know what sum does?
<ev`>
gets 2 numbers as parameters and return the sum
<pango>
ev`: sum is a function that takes an integer (i), that return a function that adds i to integers
<pango>
ev`: so if you supply two integers you indeed get their sum
<mbishop>
yeah that Hickey book is pretty good
<Smerdyakov>
ev`, is there a section of that book that explains currying?
<ev`>
maybe I've just started reading it
<mbishop>
Smerdyakov: page 27
<Smerdyakov>
ev`, are you past page 27?
<ev`>
the code is at page 28
<mbishop>
heh in fact
<mbishop>
they have an almost exact copy of the code he pasted above just above where they explain currying
<mbishop>
let sum = fun i j -> i +j;;
<Smerdyakov>
ev`, did you read the text that explains currying?
<ev`>
yes
<Smerdyakov>
And you didn't understand it?
<ev`>
the thing I dont understand is how let and in works in this case
<ev`>
'let' and 'in'
<Smerdyakov>
Local definitions.
<ev`>
'in' is referred to the first 'let' or the second one ?
<Smerdyakov>
First, 'let f x = e' is shorthand for 'let f = fun x -> e'.
<mbishop>
'let' is different from 'let in'
<Smerdyakov>
Now that we've simplified that, think of 'let x = e1 in e2' as the same as substituting 'e1' for 'x' everywhere it appears in 'e2'.
<mbishop>
ev`: second, as you should be able to tell from the indentation
* mbishop
always tries toputs his "in" on a seperate line, just to make that clean
<ev`>
so he is defining sum2 inside sum2 ?
<ev`>
let sum2 j = something in sum2;;
<Smerdyakov>
ev`, just perform the variable substitution manually and it should be clear what it means.
<ev`>
Smerdyakov, I understand it with just variables...
<ev`>
but with functions
<Smerdyakov>
ev`, variable substitution is purely syntactic. It doesn't matter what the type of the variable is, including if the variable has a function type.
<mrvn>
There are no variables. Only bindings. :)
<Smerdyakov>
mrvn, I think that is incorrect w.r.t. standard OCaml terminology.
<Smerdyakov>
But perhaps ev` doesn't understand that both 'sum2' and 'j' are variables in his example.
<mrvn>
Smerdyakov: then the terminology is flawed. They aren't variable so variable is a misnomer.
<Smerdyakov>
This terminology is hundreds of years old..
desertbot has joined #ocaml
<Smerdyakov>
So, if you don't like it, too bad, but it's absolutely standard.
<mrvn>
Smerdyakov: I think you have the wrong timespan there and in functional languages the normal term is binding, not variable.
<Smerdyakov>
Nope.
<Smerdyakov>
I'm talking about the mathematical concept of "variable."
<Smerdyakov>
Which is the concept that functional programming inherits.
<Smerdyakov>
There isn't any idea of imperativity in math, so clearly "variable" has nothing to do with mutable update.
<flux>
mrvn, in certain terminology a in this function is variable: let foo a = a + 42
<flux>
mrvn, because it varies from call to call
<flux>
or in ocaml one could say 'immutable varible'
<mrvn>
ocaml manual: "The let binding is not an assignment, it introduces a new identifier with a new scope."
<flux>
well it doesn't say whether it's a binding or variable, then?
<Smerdyakov>
mrvn, who said that variables have anything to do with assignment?
<mrvn>
I think the manual uses all three, binding, variable and identifier.
<Smerdyakov>
I never denied that "binding" is also a valid term.
<mrvn>
flux: the question was more what foo is, not a.
<ev`>
I've modified the code
<ev`>
let sum = fun i -> (let sum2 = fun j -> i + j in sum2);;
<mrvn>
ev`: the inner let is unneccesary
<Smerdyakov>
mrvn, it was in the original, too!
<mrvn>
not in the form given here
<flux>
please drop the nonessentials and proceed with helping the newbie :) (when a clarifying question arrives)
<mrvn>
.oO( typing less is quite essential :)
<ev`>
mrvn, the let inside the parenthesis ?
<mrvn>
ev`: the let just gives the "fun j -> i + j" a name and replaces it wherever that names appear after the in, which means the one occurance of "sum2".
<mrvn>
You can just as well do the replacing in your head and write let sum = fun i -> (fun j -> i + j)
<ev`>
:O
<ev`>
I see now...
<mrvn>
Does the book describe how nice it is that the above is also equivalent to "let sum i j = i + j"?
ygrek has quit [Remote closed the connection]
<ev`>
yes that was the first function he mentioned :)
<ev`>
then he says.. this is another way to write the same thing.. talking about nested functions
<mrvn>
Writing it out with seperate "fun" keywords just makes it more visible that you have a curried function.
ygrek has joined #ocaml
desertbot has quit ["Reg'd"]
<ev`>
this stuff is amazing really :)
<ev`>
I've been using C for too much and this things are incredible for me :D
<mrvn>
There is a small difference though. You can't write the following with a single let: "fun i -> Printf.printf "Got i = %d\n" i; fun j -> Printf.printf "Got j = %d, i +j = %d\n" i (i + j); i + j"
<ev`>
mrvn, uh ?
<mrvn>
ev`: ever used function pointers in C?
<ev`>
yeah
<mrvn>
much much simpler and more common in ocaml.
<mrvn>
ev`: Try this: let sum = fun i -> Printf.printf "Got i = %d\n" i; fun j -> Printf.printf "Got j = %d, i +j = %d\n" j (i + j); i + j;;
<mrvn>
let inc = sum 1;;
<mrvn>
inc 5;;
<mrvn>
Notice when it prints the texts.
<ev`>
hmm
<mrvn>
And then try with let sum i j = Printf.printf "Got i = %d, j = %d, i +j = %d\n" i j (i + j); i + j;;
moglum has quit []
<ev`>
nice :)
love-pingoo has joined #ocaml
<bluestorm_>
let apply_and_say op str_op i j = let result = op i j in Printf.printf "Got i = %d, j = %d, i %s j = %d\n" i j str_op result; result
<bluestorm_>
let sum = apply_and_say ( + ) "+"
<ev`>
so + is a function taking 2 arguments ?
<mrvn>
# ( + );;
<mrvn>
- : int -> int -> int = <fun>
<bluestorm_>
(actually you could have something even more general with two more arguments str_i and str_j, because here i and j are of type int because of the %d)
<bluestorm_>
and sum would then be :
<bluestorm_>
let sum i j = apply_and_say ( + ) "+" i (string_of_int i) j (string_of_int j)
<bluestorm_>
:p
<ev`>
scary :P
<mrvn>
ev`: scary is when you get 3rd, 4th or 5th order functions
<mrvn>
Ever had a C function that returned a function pointer?
<ev`>
alot
<mrvn>
wow. That isn't so common.
<ev`>
callbacks
<mrvn>
Ok.
LeCamarade has joined #ocaml
moglum has joined #ocaml
desertbot has joined #ocaml
<LeCamarade>
@bot
<desertbot>
All your function are belong to us!
<LeCamarade>
@bot
<desertbot>
O, Caml.
<LeCamarade>
@bot
<desertbot>
not (if not true then not true else not (not true));;
<LeCamarade>
Ladies and gentlemen, our answer to lambdabot.
<LeCamarade>
The only module I have written is that one (the one that answers to @bot).
<desertbot>
Someone called me ... ?
<LeCamarade>
Anybody want the source? She is lagging out because my connection is pretty rotten.
<LeCamarade>
I'll move her to another server, tomorrow, and we can all start to have fun.
<bluestorm_>
:p
<bluestorm_>
i'm interested in the source
<LeCamarade>
bluestorm_: I thought I'd left you in #haskell! :oD
<bluestorm_>
_my_ irc client support tabs :)
<LeCamarade>
@bot
<LeCamarade>
That is all he can do for now. Lemme pack the source to some location so you can get it.
<LeCamarade>
We are lagging out badly. That's my connection for you.
<LeCamarade>
@bot! I'm altering that module as we go, so I may break it. :oD It's really easy to write modules for desertbot.
<LeCamarade>
@bot
<LeCamarade>
Hmm ...
<LeCamarade>
@bot
<desertbot>
OCaml v3.09.2
moglum has quit []
<twobitsprite>
why "desertbot"?
<LeCamarade>
Lemme write one more module (uptime) before I go.
<LeCamarade>
You guys can get a saner name. I figured Camls stay in the desert, so ...
<twobitsprite>
ahhh
* twobitsprite
wasn't putting 42 and 5 together
<ev`>
eheh
<twobitsprite>
ev`: so, you're just learning ocaml? how long have you been playing with it?
<LeCamarade>
:oD
<twobitsprite>
LeCamarade: either that smiley has a big nose, or two mouths...
<LeCamarade>
twobitsprite: I have a rather big nose, myself. :oD And I grin rather wide, so ...
<twobitsprite>
I see :)
* LeCamarade
kinda hates his nose.
<LeCamarade>
twobitsprite: You have no nose! :oO
<twobitsprite>
LeCamarade: actually, I have a sky slope... it's the english in me :P
<twobitsprite>
skii*
<twobitsprite>
bleh, whatever
<twobitsprite>
LeCamarade: you ever mess around with camlp4?
ygrek has quit [Remote closed the connection]
<LeCamarade>
twobitsprite: Never had the heart for it. Not as yet.
<LeCamarade>
Next thing on my to-do. Should be fun
<twobitsprite>
LeCamarade: it's a pre-processor for ocaml
<twobitsprite>
I was hoping you could answer a question for me :P
<LeCamarade>
twobitsprite: Nope. Sorry.
<ev`>
twobitsprite, sry I was afk eating dinner :)
<ev`>
started about 3 hours ago
ita|afk is now known as ita
jlouis has joined #ocaml
the_dormant has joined #ocaml
<mbishop>
LeCamarade: do you use a library for your ocaml irc bot? (for the IRC stuff, or did you write it yourself?)
<mrvn>
iirc he wrote an irssi plugin
<LeCamarade>
mbishop: I wrote everything from scratch.
<LeCamarade>
I used sockets stuff.
<LeCamarade>
It's not compilcated. You can do an IRC bot with telnet(1).
<LeCamarade>
:oD
<LeCamarade>
s/compilcated/complicated/gi
* LeCamarade
has done it with telnet before.
Smerdyakov has quit ["Leaving"]
<bluestorm_>
hm
<mbishop>
Yeah, but you need to do quite a bit of abstraction before IRC becomes usable heh
<bluestorm_>
what about TeaBot ?
<bluestorm_>
tuareg drink tea
<bluestorm_>
:-°
<bluestorm_>
hm
<bluestorm_>
or maybe SandBot
<bluestorm_>
it suggests security
<bluestorm_>
(whereas desertbot looks like "hey, nobody left on this chan")
<LeCamarade>
mbishop: Actually, since it is just a bunch of lines, you can parse it easily.
<LeCamarade>
Of course an abstraction would have helped, but ...
<LeCamarade>
I can't just apt-get install ocaml-network or something.
<LeCamarade>
The name can change by one line in the conf. :oD I didn't hope desertbot would last even this long ...
<mrvn>
apt-get install make-it-work
<LeCamarade>
mrvn: Is there some package management thingy for humps, so I can just do and apt-get-like thing?
* LeCamarade
is worried someone will say `Where's the patch?'
<LeCamarade>
@uptime
<bluestorm_>
hm
<LeCamarade>
Hmm ...
<LeCamarade>
@bot
<mrvn>
LeCamarade: don't know.
<desertbot>
:o)
<LeCamarade>
@uptime
<pango>
LeCamarade: the hump is just a collection of links to external sites (half of them dead)
<mbishop>
godi works a little like apt
<mbishop>
although there was an apt-caml or something
<pango>
yep, was about to mention godi
<pango>
debian has several ocaml libs already packaged, too
<pango>
I think it's one of the most ocaml friendly distro atm
<LeCamarade>
pango: Yeah, `apt-cache search ocaml' blows the mind.
<mbishop>
yeah, I usually just get my packages from apt (on ubuntu)
<LeCamarade>
@uptime
<pango>
not much success
<LeCamarade>
?
noteventime has quit ["Leaving"]
<LeCamarade>
@bot
<desertbot>
Someone called me ... ?
<LeCamarade>
desertbot: Yes, but you are on a slow connection! And my @uptime module doesn't work! X-(
* LeCamarade
is suffering with his snail, dog-slow conn. :o(
<LeCamarade>
@uptime
<LeCamarade>
I think I healed it/
<LeCamarade>
s/\//./gi
<LeCamarade>
@uptime
<LeCamarade>
@bot
<desertbot>
Who called me a camel? X-(
<LeCamarade>
Okay. uptime has played me. Gotta go. :o(
<LeCamarade>
It's starting to rain.
<LeCamarade>
Aha! I was just using the API the wrong way!
<LeCamarade>
@uptime
<LeCamarade>
yes, the bot has an API. :oD
* LeCamarade
twiddles his thumbs ... work, work, work ... work, desertbot, work!
<LeCamarade>
@bot
<desertbot>
O, Caml.
<LeCamarade>
Okay, I give up.
<LeCamarade>
Sorry, friends. You know how hard it is to give up. And the bot can't go to more than one channel. And the problem doesn't show up on the local. And I swear I have solved it now (brute force).
<LeCamarade>
@uptime
desertbot has quit [Remote closed the connection]
desertbot has joined #ocaml
<LeCamarade>
Hehehe. He had to load the conf afresh. Silly me. :oD
<LeCamarade>
@uptime
<desertbot>
Uptime: 35 seconds
<LeCamarade>
:oD
<LeCamarade>
Note to self. Dynamic reload of conf. Write a ctl prog.
<LeCamarade>
@uptime
<bluestorm_>
hm LeCamarade
<bluestorm_>
did you finally find a ftp or somewhere ? :p
<LeCamarade>
bluestorm_: The source, you mean?
<bluestorm_>
yes
<LeCamarade>
Lemme push it to some spot and give you the link. Plus the @bot and @uptime modules.
<desertbot>
Someone called me ... ?
<LeCamarade>
@uptime You should have responded too! Don't wear me out!