vect changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn, ICFP'03 http://www.icfpcontest.org/, A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/, A free book: http://cristal.inria.fr/~remy/cours/appsem, Mailing List (best ml ever for any computer language): http://caml.inria.fr/bin/wilma/caml-list
<Defcon7> how i can use to make a list from a string ?
<ayrnieu> Do you mean to ask how you can construct a list of characters from a string?
<Defcon7> a 'list', this type exists in ocaml
<Defcon7> i wish to manipulate a string with the commands avaiable to manipulate lists
<Defcon7> in list module
<Riastradh> Defcon7, he's not asking what a list is. He's asking more precisely what you mean; he's asking if what you mean to ask is how to convert the string "foo" into the list ['f';'o';'o'].
<Defcon7> so i think that i have to convert that
<ayrnieu> Then you want to construct a list from the characters of a string.
<Defcon7> that is
<Defcon7> :P
<ayrnieu> hint: "foo".[0] == 'f'
<Defcon7> ok i found that in the web, thanks
<simon-> does ocaml have a function reference?
<Maddas> Defcon7: O'Caml's basic examples come with an example of how to do that
<Maddas> (it's pretty easy)
mimosa has quit ["I like core dumps"]
malc has joined #ocaml
simon- is now known as _-simon-_
_-simon-_ is now known as simon
simon is now known as simon-
noss has left #ocaml []
simon- is now known as _-simon-_
_-simon-_ is now known as simon-
malc has quit ["no reason"]
gim has quit ["Zz."]
<Defcon7> the "if" syntax if ((a=b) and (b=c)) or ((x>y) and (e<k)) is right ?
<Defcon7> or we have to use && and ||
<Defcon7> ?
<Defcon7> or the embracing is wrong ?
<Smerdyakov> && and ||
<Defcon7> tnx :)
<Smerdyakov> You could have just tried it. :D
<Defcon7> you are right :)
<Defcon7> try (List.nth 4 lastlist) with Failure -> ""
<Defcon7> this gives an error: This expression has type int but is here used with type 'a list
<Defcon7> but how i can handle List.nth exception without try ?
<Smerdyakov> Look at the type of List.nth.
<Defcon7> 'try'
<Riastradh> Defcon7, what is the type of List.nth?
* Riastradh bahs at Smerdyakov!
<Defcon7> val nth : 'a list -> int -> 'a
<Defcon7> Return the n-th element of the given list. The first element (head of the list) is at position 0. Raise Failure "nth" if the list is too short.
<Riastradh> What arguments have you passed to it, and what are their types, in oroder?
<Riastradh> Order, even.
<Defcon7> int ,list of strings
<Defcon7> (4,lastlist)
<simon-> after reading some tutorials, I find O'Caml less confusing, but I still think there is a lot of stuff I find very crammed into the syntax
<Defcon7> ops
<Defcon7> i have inverted them
<Smerdyakov> simon-, like?
<Defcon7> sorry :P
<simon-> Smerdyakov, like named arguments (just to mention what I studied last)
<Riastradh> Yes. OCaml's syntax sucks.
<Smerdyakov> simon-, I hate those. :)
<Riastradh> And though I think named arguments can be nice, OCaml's graft of them onto its syntax and onto currying is horrible.
<simon-> I actually like it. I just think there is a lot of stuff I could live without.
<Riastradh> It would be so much easier if OCaml just used S-expressions.
<ayrnieu> Riastradh - why do you see them as horrible?
<Riastradh> Or I could just use Scheme and be happy.
<simon-> Riastradh, what are S-expressions?
<Riastradh> ayrnieu, just think about how currying interacts with named and unpositional arguments.
<ayrnieu> Riastradh - well, I think an s-expression syntax with camlp4 exists.
<Riastradh> simon-, Lisp's syntax, in short.
<Defcon7> this is my second day that i play with ocaml and i found it really cool, you'll love it :)
Kinners has joined #ocaml
<ayrnieu> Riastradh - I suppose that I miss something, then, because I don't see anything horrible.
<simon-> well, I am really amazed how making recursive functions both looks and works pretty smoothly.
<Riastradh> ayrnieu, you don't think that it's rather kludgily hacked on top of currying?
<ayrnieu> simon - as opposed to making them in what other languages?
<simon-> ayrnieu, any imperative language. C?
<ayrnieu> Riastradh - I don't see it as any kludgier than Haskell's system.
<Defcon7> defcon7@spawn:~/ml$ ocamlopt unix.cmxa str.cmxa prova.ml -o prova
<Defcon7> defcon7@spawn:~/ml$
<Riastradh> Haskell doesn't have named arguments.
<Defcon7> yeeees
<ayrnieu> simon - some people like to think of O'Caml as an imperative language =)
<Riastradh> So I don't see what the comparison is.
<ayrnieu> Riastradh - then I guess that I don't understand your complaint with O'Caml's named arguments, because O'Caml has and fails to have them in the same way.
<Riastradh> ??
<Riastradh> You, um, _are_ familiar with OCaml's named arguments, or labels, right?
<ayrnieu> Riastradh - can you provide some code, so we've something more solid to talk about?
<simon-> actually I think "class name = object (self) ... end;;" does not look very good either
<Riastradh> I'm talking about those labels.
<ayrnieu> Riastradh - ah. Sorry, I read "named arguments" as "non-pointless"
<ayrnieu> You should've said 'keyword arguments' =)
<Riastradh> OK, yes, I ought to have, but simon- referred to them as 'named arguments' and my brain got stuck on that term momentarily.
* Riastradh glares at simon-.
<simon-> sorry, one moment
<Defcon7> http://www.nectarine.info/misc/prova.ml <- this is something like a simple log parser, can you like at it and tell me where i could be more coincise ?
<Defcon7> more coincise or less stupid :P
<Riastradh> You duplicate a _lot_ of code there.
<Defcon7> cooool
<Defcon7> hehe
<ayrnieu> also, parentheses annoy me.
<ayrnieu> by which I mean: *your* *use* of parentheses annoys me.
<Defcon7> you are referring to the begin...end thing ?
<ayrnieu> No; the way you put open- and close- parentheses on their own lines.
<Defcon7> oh
<Defcon7> probably you are right
<Defcon7> lemme try
<ayrnieu> but anyway, you should probably factor out a function with two arguments for the big if || && && && then expression.
<Defcon7> http://www.nectarine.info/misc/prova.ml <- you mean something like this ?
<ayrnieu> yegods
<ayrnieu> Yes, like that, only in the other direction.
<ayrnieu> Also, factoring out that function would help.
<Defcon7> in the other direction ?
<ayrnieu> Towards greater conciseness, with open- and close- parentheses not written on a line by themselves.
<Defcon7> trying again
<Defcon7> looks better
<whee> still looks a bit redundant to me :P
<ayrnieu> Yes, that function-factoring thing than needs to happen. Also, YOU MOCK ME
<Kinners> Defcon7: you could make a function which takes two arguments (the string to build the regexp and the List.nth number)
<ayrnieu> o/~ somebody o/~ reads the scrollback. mmm?
<Defcon7> mock ?
<whee> personally, I'd try to turn that if statement into a nice fold_left
<whee> and of course do some refactoring with additional function declarations
<Defcon7> hmm trying :)
<Defcon7> why it says that "tail" isnt a function ?
<Defcon7> it isnt :?
<Kinners> Defcon7: is your factored function defined outside of the tail function?
<Defcon7> yes it is
<Defcon7> i tried to define into it but probably im trying in the wrong way
<Defcon7> at the end of tail definition at the last ) i made ); let rec factored_function_name.....
<Defcon7> but it (probably obviously) says syntax error
<Defcon7> so i tried to define out of tail
<Kinners> let lastlist = ... in let f re idx = ... in if ((f "^.*courier*" 4) || ...
<Defcon7> hrm
<Defcon7> how i can define it at the end of tail ?
<Defcon7> which is the syntax ?
<Defcon7> starting from the last )
<Kinners> like, let rec foo x y z = (... ) and bar x y z = ... ?
<Defcon7> hrm nop
<Defcon7> ); in
<Defcon7> let rec getel lastlist n = try (List.nth lastlist n) with nth -> (tail chid) 0;;
<Defcon7> where ) is the actual end of tail definition
<Defcon7> but its wrong, so im asking what is the syntax to declare a function in that point
<Kinners> just what I showed you, using 'and' instead of '; in let rec'
<Defcon7> oh :)
<Defcon7> sorry i didnt get you before
<Defcon7> again it says that tail is not a function
<Defcon7> (grrr)
<Defcon7> why not, it is
<Defcon7> plus it applies tail many times before
<Defcon7> why not here
<Defcon7> why here is not a function
<Defcon7> O_o
<Defcon7> im perplessed
<Smerdyakov> Riastradh, at least you agree Defcon7 can't spell? ;)
<Kinners> Defcon7: put it up on your site
<Defcon7> Smerdyakov, try you to talk italian :P
<Defcon7> Kinners done
<Riastradh> Yes, I agree with that.
<Defcon7> :P
<Riastradh> Defcon7, for context, Smerdyakov wrongfully accused me of misspelling 'minuscule' in another channel, and now he's trying to make his mistake less drastic.
<ayrnieu> (I consider those my friends that, however ineptly they speak English, speak it without vile hyperreductionism or k3wlt0k)
<Defcon7> Riastradh loool
<Defcon7> mumble mumble
Etaoin has joined #ocaml
<Etaoin> hi
<simon-> hello
<Defcon7> hi :)
<Etaoin> neat
<Etaoin> I expected no reply for a while
<Defcon7> you will get it later dont worry
<Defcon7> lool :P
clog has joined #ocaml
<Defcon7> what about "tail is not a function" thing ?
<Defcon7> anyone has discovered something ?
<Etaoin> ?
<Etaoin> do camels have tails?
<Defcon7> hehe
<Kinners> Defcon7: you are doing (tail chid) 0 , which is using the result of 'tail chid' as a function and passing 0 to it
<Defcon7> ouch hehe
<Defcon7> what i wish to mean is to call tail chid, not to use it, what is the syntax :?
<Defcon7> (not to use its result)
<Kinners> just 'tail chid'
<Kinners> (tail chid) 0 is like, let f = tail chid in f 0;;
<Smerdyakov> Who wants to be my little tail chid?
<Smerdyakov> My itty bitty cutey wutey tail chid?
<Defcon7> hahaha
* Defcon7 get me, im your tail chid
<Smerdyakov> OK. You're my tail chid.
<Defcon7> hehe
<Defcon7> kinners it works finally :)
<Defcon7> thanks :D
<ayrnieu> etaoin - yes.
<Etaoin> ayrnieu: oh
<ayrnieu> Etaoin - but why do you ask?
clog has joined #ocaml
<Defcon7> there is any reason because a line like a := 2; cant be followed by a let ?
<Smerdyakov> No reason.
<Defcon7> im getting a syntax error in this situation
<Defcon7> and this sounds strage effectively
<Defcon7> only and only with a let
<Defcon7> with any other command it works
<Defcon7> ip := Str.global_replace (Str.regexp "\]$") "" (Str.global_replace (Str.regexp "^ip=\[::ffff:") "" (getel lastlist 7));
<Defcon7> let bau = 1+2;
<Defcon7> );
<Smerdyakov> What the hell is that?
<Smerdyakov> Every 'let' expression must have an 'in'....
<Defcon7> oh.
<Defcon7> that isnt true.
<Smerdyakov> It is. The top-level stuff isn't expressions.
<Smerdyakov> It's a special convenience form.
<Defcon7> good to know :P
lus|wazze has joined #ocaml
Kinners has quit [Read error: 60 (Operation timed out)]
<Defcon7> defcon7@spawn:~/ml$ ocamlopt unix.cmxa str.cmxa mysql.cmxa -o prova -I /usr/lib/ocaml/mysql/ prova.ml
<Defcon7> File "prova.ml", line 22, characters 131-133:
<Defcon7> Syntax error: ')' expected
<Defcon7> File "prova.ml", line 21, characters 12-13:
<Defcon7> This '(' might be unmatched
<Defcon7> parentheses are probably right and the error is another
<Defcon7> but is half hour that im searching it
<Defcon7> if someone more skilled than me can take a look pls
<async_> still having problems with that?
async_ is now known as async
<Defcon7> hehe it has grow :)
<Defcon7> i found the error
<async> Defcon7: what was it
<Defcon7> nope not found
async has quit ["Lost terminal"]
<Defcon7> someone can help me ^?
<Defcon7> hmm too late here
<Defcon7> good night all
karryall has quit ["leaving"]
__buggs is now known as buggs
srv has joined #ocaml
mimosa has joined #ocaml
gim has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
maihem has quit ["Client exiting"]
Herrchen has joined #ocaml
<Herrchen> hello
<Herrchen> someone able to tell me, why "let f : 'a -> 'b = fun x -> x;;" doesn't produce a type error and makes 'a = 'b? Just thought this would cause some error, so I would see if I make mistakes, using a module type and defining the type of the value as above there produces an error message
<mattam_> 'a and 'b are unifiable, there's no reason the typechecking to error
mattam_ is now known as mattam
<Herrchen> hmm no way to tell him not to unify?
<Herrchen> because I explicitly using different names to express, they could be different
<mattam> i don't think so
<Herrchen> though defining it in a module type will produce an error, so the type checking is done there differently
<mattam> hmmm, then you shouldn't rely on that, if it's not the same behavior in modules and regular code then it is probably implementation-specific
<mattam> although i would find that pretty weird
<Herrchen> well I thought maybe some error, but at least 3.06 and 3.07p2 behave like this
<mattam> i get no error defining:
<mattam> module SomeModule = struct
<mattam> let g : 'a -> 'b = fun x -> x
<mattam> end
<mattam> module SomeModule = struct
<mattam> let g : 'a -> 'b = fun x -> x
<mattam> end
<mattam> oops
<Herrchen> hmm on toplevel I get no error with "let f : 'a -> 'b = fun x -> x;;"
<Herrchen> ah
<Herrchen> damn can't read
<Herrchen> so we agree at this
<mattam> that there is no error in any case ?
<Herrchen> module F : sig val f : 'a -> 'b end = struct let f x = x end;;
<Herrchen> produces an error
<Herrchen> telling me 'a -> 'a and 'a -> 'b are incompatible as expected
<Herrchen> I of course want to use the type declarations as some error catching, so the above no error stuff is very annoying
<mattam> go to sig everything so ?
<Herrchen> yes, but not that charming, don't want to write signatures when I export anyshit
<Herrchen> but seems so as I have to
<Herrchen> hmm well at least using camlp4 I could make this automatically
<mattam> write code and use ocamlc -i to produce signatures when finished ?
<Herrchen> oh I like it to have some "unmatched type at line xx error message"
<Herrchen> so I thought of this
<Herrchen> well I just try if there is much overhead if I put everything in modules
<Herrchen> if not -> camlp4 and fun
<Herrchen> well anyway I could use this way of compiling just for testing purposes
<Herrchen> just a minor overhead in code-output and no performance loss as expected, well I try it this way no - thanks for info/help/suggestions/etc.
smkl has quit [zelazny.freenode.net irc.freenode.net]
smkl has joined #ocaml
owll has joined #ocaml
owll has quit [Client Quit]
<Herrchen> bye
__DL__ has joined #ocaml
mimosa has quit ["I like core dumps"]
buggs|afk has joined #ocaml
rox is now known as rox|off
buggs has quit [Read error: 60 (Operation timed out)]
Demitar has joined #ocaml
<Defcon7> http://www.nectarine.info/misc/prova.ml <- can someone take a look at this small ocaml program and tell me whats the error? (im getting syntax error in line 22, i tried for hours but no way to resolve it :| )
<mellum> you mean the illegal backslash?
<mellum> try \\
<Defcon7> oh ok
<Defcon7> tnx
<smkl> the syntax for let is "let p = e1 in e2"
<Defcon7> defcon7@spawn:~/ml$ ocamlopt unix.cmxa str.cmxa mysql.cmxa -o prova -I /usr/lib/ocaml/mysql/ prova.ml
<Defcon7> File "prova.ml", line 22, characters 133-135:
<Defcon7> Syntax error: ')' expected
<Defcon7> File "prova.ml", line 21, characters 12-13:
<Defcon7> This '(' might be unmatched
<Defcon7> same thing with double backslash
<Defcon7> i used that backslash because of the [ ]
<smkl> first use "let lastlist = Str.split (Str.regexp "[ \t]+") last_line in"
<Defcon7> yes i removed it as a try
<smkl> then comment useless "in let bau = 1+2;"
<Defcon7> i have to place in that point an useful but complex let something =
<Defcon7> but the problem has come and i replaced it with a simple and useless let
<Defcon7> to see how goes
<Defcon7> but the problem is still here
<smkl> then just comment useless "in" and use the correct syntax for the let-expression
<smkl> err, remove the "in"
<Defcon7> someone has told me that every let must have an in before
<smkl> they ment that the "in" must be after let
<Defcon7> removing the in i get a syntax error in the next line
<Defcon7> line 24: );
<smkl> you get that because you didn't fix the let-expression to the correct form, for example: let bau = 1+2 in ()
<Defcon7> oh.
<Defcon7> wooosh
<Defcon7> :*
<Defcon7> works finally
<Defcon7> and i've leant something :P
buggs|afk is now known as buggs
owll has joined #ocaml
owll has left #ocaml []
KAeL[N7] has joined #ocaml
<KAeL[N7]> salut les gens
KAeL[N7] has quit ["[x]chat"]
<Defcon7> can someone suggest me a linux console editor which has highlight for ocaml ?
<mellum> xemacs
<Defcon7> console ?
<Defcon7> ok.
<simon-> vim?
<Smerdyakov> emacs is better!
<Demitar> Woo, editor war! ;-)
<simon-> Smerdyakov, emacs is as good an editor as the emacs doctor is a good doctor.
<simon-> (actually I just don't like the bindings... and the vim syntax files are quite decent to play with)
buggs has quit [Read error: 104 (Connection reset by peer)]
buggs has joined #ocaml
<Defcon7> theres any other sleep function than Unix.sleep ?
<mellum> The good old unix trick of abusing select works.
<Demitar> Or you could block using a dead thread and wait for a signal. ;-)
<Defcon7> hmm but for example
<Defcon7> for the main loop
<Defcon7> without a sleep it will eat all the cpu and with a second sleep will be extremely slow
<Defcon7> there isnt something like nanosleep syscall ?
<mellum> What's the problem with select?
<Defcon7> the only problem i dont know that trick :)
<mellum> Well, read its description
<Defcon7> im programming ocaml from 2 days :P
<Defcon7> okay ill do
<Demitar> Defcon7, well select() is alot more unixy than it's ocaml specific.
rox|off is now known as rox
mimosa has joined #ocaml
noss has joined #ocaml
maihem has joined #ocaml
eternite has joined #ocaml
<eternite> hello!
srv has quit ["leaving"]
systems has joined #ocaml
maihem has quit [Read error: 104 (Connection reset by peer)]
maihem has joined #ocaml
noss has quit ["[x]chat"]
JackAvon has joined #ocaml
eternite has quit [Read error: 104 (Connection reset by peer)]
systems has quit [Read error: 110 (Connection timed out)]
Maddas_ has joined #ocaml
lus|wazze has quit [zelazny.freenode.net irc.freenode.net]
Etaoin has quit [zelazny.freenode.net irc.freenode.net]
Maddas has quit [zelazny.freenode.net irc.freenode.net]
phubuh has quit [zelazny.freenode.net irc.freenode.net]
drlion has quit [zelazny.freenode.net irc.freenode.net]
det has quit [zelazny.freenode.net irc.freenode.net]
det has joined #ocaml
drlion has joined #ocaml
lus|wazze has joined #ocaml
Etaoin has joined #ocaml
Maddas has joined #ocaml
phubuh has joined #ocaml
Demitar has quit [Remote closed the connection]
Maddas has quit [Read error: 60 (Operation timed out)]
Demitar has joined #ocaml
mimosa has quit [Read error: 110 (Connection timed out)]
gim has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
lus|wazze has quit ["Copyright is a temporary loan from the public domain, not property"]
JackAvon has quit []
mattam has quit [zelazny.freenode.net irc.freenode.net]
The-Fixer has quit [zelazny.freenode.net irc.freenode.net]
mellum has quit [zelazny.freenode.net irc.freenode.net]
avn has quit [zelazny.freenode.net irc.freenode.net]
mattam has joined #ocaml
The-Fixer has joined #ocaml
avn has joined #ocaml
mellum has joined #ocaml
phubuh has quit [Remote closed the connection]
systems has joined #ocaml
buggs is now known as buggs|afk
systems has quit ["Client Exiting"]
brwill has quit ["xfree upgrade restart"]