dylan changed the topic of #ocaml to: OCaml 3.09.1 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
rillig has quit ["exit(EXIT_SUCCESS)"]
sym0r_ has joined #ocaml
Quinthius has quit [Read error: 104 (Connection reset by peer)]
Quinthius has joined #ocaml
neax has joined #ocaml
sym0r__ has quit [Read error: 110 (Connection timed out)]
sym0r_ has quit [Read error: 110 (Connection timed out)]
CLxyz has joined #ocaml
bzzbzz has joined #ocaml
mikeX has quit ["zzz"]
perspectivet has quit [Read error: 110 (Connection timed out)]
descender has quit [Read error: 110 (Connection timed out)]
descender has joined #ocaml
holo has joined #ocaml
<holo> hi
dark_light has quit [Connection timed out]
<ketty> hello..
<ketty> what timezone are you in?
<holo> ketty, i had a nice feeling like i was going to be saved when you said "hello"
<holo> ketty, GMT
<ketty> heh :)
<ketty> hmm gmt..
<holo> its 4 am here
<holo> almost 5 am
<ketty> ok.. it is almost 6 here
<holo> ah its
<holo> hmm
<holo> france?
<ketty> no sweden :)
<holo> oh
<Oejet> ketty: Which part?
<holo> same timezone ?
<ketty> yes same timezone
<ketty> (i think)
<ketty> Oejet: south part..
<Oejet> Malmö?
<ketty> lund..
<ketty> so almost malmö
<Oejet> I was in Lund once for a track meeting.
<holo> so :o can we talk about my problem?
<ketty> what is a track meeting? :)
<holo> ok ok continue
<ketty> holo: yes, what is your problem?
<ketty> your code looks weird, i don't understand it :)
<holo> http://pastebin.com/659004 <- this runs, but it is assuming a strange input type
<ketty> you have to explain :)
<holo> hehe
<holo> it's a damm good hack
<holo> let rec eats_first_field_of_dot str x=
<holo> match nth_char str x with
<holo> at this point it knows str is string
<Oejet> ketty: Athletics, you know, Christian Olson, Johan Wissman, etc.
<holo> it eats things till it finds a "."
* ketty don't know anything about athletics ^^
<holo> and then sends the string to the ident_of_dot_field
<holo> match stream_of_string str with
<ketty> and if it never finds a dot?
<holo> at this point it knows its a string too
<holo> ketty, it *has* dot
<holo> becouse of previous conditions
<holo> these are only aux functions
<ketty> it could be good to be paranoid in this case i think...
<holo> ketty, this code wont be reused
<ketty> but then i dont know about the previous conditions :)
<ketty> mm...
<holo> the previous conditions assure the dot, only if this functions were to be used by other functions not with the same conditions, that would be a problem
<ketty> the string passed to ident_of_dot_field...
<holo> yes
<ketty> hmm
<holo> its a string
<ketty> how should it look?
<holo> nth_char str x
<holo> this assures it sends a string
<ketty> should it be the same string as passed to second_field?
<holo> yes
<holo> ha
<holo> no
<holo> no
<holo> ooops
<holo> oh god
<holo> i just need something to actualy eat the string
<holo> index_char
<holo> ahaha
Oejet has quit ["#haskell Just five minutes...zzzZZZZ"]
dark_light has joined #ocaml
descender has quit [Remote closed the connection]
neax has quit [Remote closed the connection]
coumbes has joined #ocaml
<holo> This function is applied to too many arguments.
<holo> er
<ketty> mmm?
<holo> i think i abused type conversion
<ketty> which line generates the error?
<holo> Toplevel input:
<holo> > |`.` -> ident_of_dot_field str (x+1)
<holo> ident_of_dot_field
<ketty> hmm.. shouldnt nth char be nth_char?
<ketty> line 3
<holo> argh
Skal has joined #ocaml
<holo> This expression has type string,
<holo> but is used with type int -> string.
<ketty> mmm... you use a string as if it was a function...
<holo> where??
<ketty> i don't know..
<ketty> what part generates the error?
<holo> oh
<holo> test
<holo> wat
<ketty> you should get a line number or something..
<holo> second_field "0.pesso"
<ketty> m?
<holo> the functions work
<ketty> so, everithing fixed?
<holo> but when i run, the behavior is unexpected
<holo> it was just that "_" error
<ketty> _ error?
<ketty> ahh..
<ketty> remember :)
<ketty> hmm how is the behaviour unexpected?
<ketty> what should it do and what does it?
<holo> it should increment x till dot
<holo> and then eat caracters in the other function till empty stream and then return those eaten caracters
<ketty> and then call indent_of_dot_field with new x?
<holo> as a string
<holo> yeah
<holo> the position at right of dot
<ketty> and how does it fail doing so?
<ketty> and why are you using a stream?
<holo> This expression has type string,
<holo> but is used with type int -> string.
<ketty> which line gives you that error message?
<holo> "0.peso"
<holo> it's only one line so
<ketty> hmm.. you are using the top level loop?
<holo> ketty, don't say weird stuff at 6 am
<holo> pelase
<ketty> ok :)
<ketty> how does the line look?
<ketty> that gives you error...
<holo> ha
<holo> its that, a function and an argument
<ketty> mmm?
<holo> second_field "0.peso";;
<ketty> ok
<ketty> if you type: second_field;;
<ketty> what does it answer?
<ketty> heh.. i see your error :)
<ketty> now tell me what it says when you type: second_field;;
<holo> ok
<holo> #second_field;;
<holo> - : (int -> string) -> int -> string = <fun>
<ketty> that is very weird... :/
<ketty> ohh..
<ketty> i see
<ketty> you know what "(int -> string) -> int -> string = <fun>" means?
<holo> i think i do
<holo> hmm
<holo> int argument to int argument make some int that turns into some string
<ketty> mmm.. almost :)
<holo> if i wosn't so tired, i would answer more accuratly
<ketty> it means that second_field is a function
<holo> LOL
<ketty> that takes a function and an it as arguments
<ketty> and return a string
<ketty> the first argument (which is a function)
<ketty> takes int and returns string
<ketty> i am pretty sure this is not what you intended
<ketty> could you tell me the type a correct version of second_field should have?
<holo> omg
<holo> :s
<holo> ok
<holo> (int -> string) -> string
<holo> hmm no
<holo> int -> string = fun
<ketty> hmm...
<holo> omg, i can't think anymore
<ketty> it should take an int as argument?
<ketty> are you sure? :)
<holo> hmm
<holo> ?hit!!
<holo> damm ()
<ketty> you found your errer? :)
<ketty> ehh error..
<holo> well
<holo> now i have this
<holo> #Uncaught exception: Invalid_argument "nth_char"
<holo> hu
<ketty> heh..
<ketty> you know that it means?
<holo> no
<holo> :|
<ketty> well
<ketty> you apply an invalid argument to "nth_char"
<ketty> it usualy means that the int is to big
<ketty> so you try to get a char that is not in the string
<holo> hei
<holo> geeza
<holo> wait
<ketty> so if a string has length 5 and you do (nth_char str 5) you get that error
<ketty> since the last char in the string has position 4
<holo> but but
<holo> char started at 0
<ketty> yes?
<holo> and length starts at 1
<ketty> ehh?
<holo> abc
<holo> lenght =3
<ketty> yes
<ketty> and the indexes ar 0,1,2
<holo> nth_char str 0 = `a`
<ketty> yes
<holo> yes
<ketty> but i dont think that is your problem
<ketty> your problem seems to be in ident_of_dot_field
<ketty> i think you are trying to do something weird :)
<ketty> could you tell me why you are using streams?
<holo> hehe
<holo> of course i have a reason
<holo> ``
<holo> this isn't possible
<ketty> ahh...
<holo> [<>] is
<ketty> but you dont get around your problem
<holo> yeah
<ketty> you will never get a [<>]
<holo> i wanted to have a stream_of_char
<holo> hm
<ketty> when you reach the end of the string you get that error of yours instead
<ketty> you see why?
<holo> ok no
<holo> i tried to twist some prevert logic.. but no
<ketty> in: tream_of_string(string_of_char (nth_char str x))
<holo> yeah it looks awfull
<ketty> the first thing that is evaluated is:
<ketty> (nth_char str x)
<ketty> and it should look like this btw: stream_of_string (string_of_char (nth_char str x)
<ketty> with a space :)
Smerdyakov has quit ["Leaving"]
<ketty> since nth_char str x is evaluated first
<ketty> when you reach the end of the string
<ketty> it will try to get a char that doesnt exists
<ketty> you see?
<ketty> well it doesnt really depend on it being evaluated first
<ketty> but that way we can just ignore the rest
<holo> oh
<ketty> so you know the problem now?
<holo> nth_char str x in some point returns a char that doesn't exist
<ketty> well it doesnt even return
<holo> becouse it surpassed the string
<holo> yea
<ketty> it just throws an exception
<holo> yea
<ketty> so you have a solution in mind? :)
<holo> ok if statement
<ketty> yes, that sounds like a good idea :)
<holo> what is type unit?
<ketty> it looks like this: ()
<holo> hu
<ketty> it is sort of a "dummy-value"
<ketty> since a function has to take some argument (so caml know it is not a value)
<ketty> we somtimes need a dummy-value
<ketty> when the function should only return stuff
<ketty> so thats where "unit" comes in
<ketty> let f () = 5;;
<ketty> this is a function that allways returns 5
<holo> oh
<holo> ok i'll see that tomorrow
<holo> thanks ketty
<holo> i think i will not even wash the teeth
<ketty> heh :)
holo has quit ["This computer has gone to sleep"]
Quinthius has quit ["Leaving"]
Tachyon76 has joined #ocaml
pango is now known as pangoafk
pangoafk is now known as pango
joshcryer has quit [Read error: 104 (Connection reset by peer)]
joshcryer has joined #ocaml
mrsolo__ has quit [Read error: 113 (No route to host)]
derpy has joined #ocaml
<derpy> can someone please explain to me what "type matcher = fragment -> acceptor -> fragment option" means? specifically the "->" (i what it means when used with "let match | ->") and the "option" token
<ketty> hmm
<pango> they're totally different uses
<ketty> yes
<pango> in first case they're used to define a function type
<derpy> heh thats where my trouble is
<derpy> couldnt find naything on ocaml-tutorial.org about it
<pango> say, string -> int means a function that takes a string and returns an int
<derpy> but why 3 leves?
<derpy> levels*
<derpy> currying?
<pango> yes
<derpy> and the "option" token?
<pango> it's a predefined sum type
<derpy> ?
<pango> type 'a option = None | Some of 'a
<derpy> what does it do when it is added to "type matcher = fragment -> acceptor -> fragment"?
<ketty> it is only added to fragment
<derpy> oh
<pango> a 'fragment option' type value can be either 'None', or 'Some t', with t of type fragment
<derpy> so it would either return a type none or some correct?
<derpy> oh ok
<derpy> thanks
<derpy> all makes sense now thanks again
<pango> np
love-pingoo has joined #ocaml
<theArthur> in what ways dose Int32's div function differ from (/)
<pango> it works on Int32s
<pango> ( / ) works on ints only
<theArthur> but other than the number of bits they should be the same right?
<pango> they aren't that many definitions for division, so I'd say yes
<pango> from performance point of view Int32s are boxed, so it could be somewhat slower, but that's not specific to division
<flux__> thearthur, normal ints are actually 31-bit or 63-bit
<pango> rounding seems to be the same
<pango> # (-3) / 5 ;;
<pango> - : int = 0
<pango> # Int32.div (-3l) 5l ;;
<pango> - : int32 = 0l
<theArthur> as far as i can tell
<theArthur> how dose div and mod compare
<theArthur> do they differ when dealing with negative numbers?
<theArthur> that could be causeing myproblems
<pango> # (-3) mod 5 ;;
<pango> - : int = -3
<pango> # Int32.rem (-3l) 5l ;;
<pango> - : int32 = -3l
* theArthur thinks he wrote his program correctly and the computer must be getting it wrong!
<pango> they seem to match on their "common domain"
<flux__> thearthur, your only option is to prove the program ;)
<pango> use a functor and instanciate the same code for ints and Int32s
<flux__> and with defunctoriser there wouldn't even be performance hit. but it's at present for 3.06, I wonder if it works with a more recent ocaml..
<derpy> why doesn't this work as a "car" equivilant "let car l = match l with | [] -> None | x::_ -> x;;" ?
<pango> None is of type 'a option
<derpy> how would you fix this?
<pango> so your function is only well typed if x is one too
<pango> you could write x :: _ -> Some x
<pango> or use List.hd ;)
<pango> that one throws an exception for empty lists, however
<derpy> is there a way to do it where it returns nothing?
<theArthur> a wrapper around List.hd that catches the exception and replaces it with []
<derpy> since []->[] doesnt work?
<pango> [] is of type 'a list
<pango> so it's well typed if the other branch(es) are or type 'a list too
<pango> s/or/of/
<derpy> what would be the proper was to write "car" then?
<pango> they're more than one proper way
<derpy> without using exceptions
<pango> but I'd suggest sticking with using match, and explicitly handle the case when the list is empty
<pango> that's what ocaml syntax is about, not let you forget pathological cases ;)
<derpy> im not acutlaly using car, just making small programs to get a hang of ocaml
<pango> then you're not getting the hang of it
<derpy> clearly
<pango> (at least, imho)
<derpy> keep trying to force lisp onto ocaml
<pango> probably
<pango> so I can tell you right away : there's no equivalent for 'eval' either ;)
<pango> compiled programs to not embed any interpreter
<derpy> do not*?
<pango> oups, correct
<theArthur> my problem with Int32 was because of the difference between != and <> when i switched from int to int32 :0
<pango> theArthur: sounds logical
clog has joined #ocaml
derpy has joined #ocaml
<derpy> i want a type fragment that is a list of 'a, "type fragment = ????? list" how do i write that? please help
<derpy> hello?
<derpy> nm
<flux__> you can't have a 'a list, where 'a isn't something specific
<flux__> maybe you want type 'a fragment = 'a list
Quinthius has joined #ocaml
<derpy> in some sample code there is a portion which has "... match accept frag with ..." i know its curryed but i fail to see what is going on, does it match accept or frag?
<pango> functions, including partially applied, cannot be compared, so 'accept frag' *must* evaluate to something
<pango> I suppose accept is then a function of a single parameter
<derpy> so it matches what is (accept frag) evaluates too?
<derpy> -is
<pango> yes
<derpy> let rec match_junk k frag accept = match accept frag with ..... so in this case accept must be a function
<pango> yes
<pango> if you wanted to match a tuple, you would have to write match accept, frag with
<pango> or match (accept, frag) with
<derpy> oh
<derpy> thanks again
<pango> you can compile with -i and get inferred types to stdout
<pango> or compile with -dtypes to get .annot files, that emacs modes like tuareg can use to give you the type of what's under the point
<derpy> im using ocamlbrowser though
<pango> yes, that's another way
<derpy> thanks for the -i tip, was looking for that earlier
derpy has quit ["Download Gaim: http://gaim.sourceforge.net/"]
Skal has joined #ocaml
Skal has quit [Remote closed the connection]
Snark has joined #ocaml
Tachyon76 has quit ["Leaving"]
love-pingoo has quit ["Leaving"]
holo has joined #ocaml
<holo> hi
<holo> () is dummy value?
<holo> i want to pass it to a else statement
<holo> argh
<Quinthius> i'm new, but i think () means the function returns nothing... like "void" in C/C++
<Quinthius> or that it takes no arguments
<ketty> holo: you want: if bla then ble else () ?
<ketty> in that case you can omit the else part...
mfurr has joined #ocaml
<pango> holo: () is the single value of the unit type
<pango> holo: so it carries no information, but can be useful at times
<ketty> ie a dummy value :)
<pango> syntax is also consistent with a tuple of no members
<pango> ;)
khaladan has joined #ocaml
<pango> ketty: else () can sometimes be used as an alternative to enclosing the if ... then ... construct in a block
<pango> when nesting them
<ketty> ahh.. nice ^^
<pango> personally I prefer if then (if ... then ...) else ... over if ... then if ... then ... else () else ...
<ketty> yes.. ( .. ) takes less space...
<pango> and the extra else () can sometimes be confusing, depending on how you indent the whole code
<pango> ymmv
<ketty> hmm... is it only me who want local type definitions?
<pango> if values of those types "leak" out of their scope, they would be seen as abstract ?
<ketty> yes, probably...
<pango> anyway you can, just use a module
<ketty> yes i know.. :)
<ketty> but i want to type less characters :)
Smerdyakov has joined #ocaml
kmag has joined #ocaml
pango is now known as pangoafk
holo has quit ["This computer has gone to sleep"]
pangoafk is now known as pango
Submarine has joined #ocaml
Quinthius has quit ["Leaving"]
Submarine has quit ["Leaving"]
Submarine has joined #ocaml
love-pingoo has joined #ocaml
love-pingoo has quit [Client Quit]
love-pingoo has joined #ocaml
mfurr has quit ["Client exiting"]
Snark has quit ["Leaving"]
theArthur has quit [Remote closed the connection]
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
dark_light has quit [Read error: 104 (Connection reset by peer)]
dark_light has joined #ocaml
ketty has quit ["Leaving."]
Schmurtz has quit ["Plouf !"]
ketty has joined #ocaml
iorek has joined #ocaml
<iorek> hi there
<ketty> hello
<iorek> does anyone know how can I open more than an unique window with the open_graph function from Graphics?
<iorek> seems like no... :(
<ketty> iorek: there seems to be a module called GraphicsX11
<ketty> maybe that will work if you are on linux
<iorek> i work under windows right now, but the it have to work under linux
<iorek> s/have/has
<ketty> i have never used it, but it has a method called open_subwindow...
Quinthius has joined #ocaml
<iorek> GraphicsX11 seems to contain all the functions i need but... th reason i can't use it is in its name
<ketty> i see...
<iorek> i just find it weird that only one window can be opened at a time using Graphics
<ketty> heh.. maybe you can use multiple processes? ^^
<ketty> yes, i also found that weird...
love-pingoo has quit ["Connection reset by by pear"]
<iorek> well, i also don't want to build a gas factory
<iorek> ;)
<ketty> i don't know if it is possible with sdl...
<ketty> you could check...
<pango> one could imagine a frame buffer implementation of Graphics...
<pango> allowing to open several graphic screens means you assume a windowing system
<iorek> i'm not a depth user of ocaml (even if i hope i'll be) so.. i'll just create a special layout in a single window
<ketty> iorek: i think that is even better than using several windows ^^
<iorek> yes, and i just wanted to add a window containing a set of colors thaht can be picked up, i can easily add this to the main window
<ketty> hmmm... are you designing a gui in Graphics?
<ketty> maybe you should use a toolkit...
<iorek> that's just a simple tool i need to develop quickly to move on in another project : pick up colors and generate a bitmap pixel by pixel
<iorek> and i want to limit library imports as much as possible
<iorek> so it's gonna make it
<ketty> ok..
* ketty once did a fairly complex gui in Graphics/Sdl
<ketty> and i dont recomend it :)
<iorek> i think that's a pretty but hard interresting work, isn't it?
<ketty> yes
<ketty> i sort of ended up implementing my own toolkit...
<ketty> but it was a complete mess :)
<iorek> do you distribute it?
<iorek> héhé
<ketty> it doesnt even compile right now :)
<iorek> :)
<ketty> but one day i might try to shape it up... :)
<ketty> i think my reason for doing it was because i was to lazy to learn gtk...
<ketty> silly :)
<iorek> ok, i have to go, thank you
<ketty> byebye
iorek has quit ["Leaving"]
<ketty> cool.. ^^
<pango> http://www.tutok.sk/fastgl/ ... and then some ;)
jcreigh has joined #ocaml
theArthur has joined #ocaml
mattam has quit [Read error: 104 (Connection reset by peer)]
mattam has joined #ocaml
theArthur has quit [Remote closed the connection]
jcreigh has quit ["leaving"]