Banana changed the topic of #ocaml to: OCaml 3.08 "Bastille Day" Release available ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn , 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
menace has quit ["Leaving"]
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
debona|r has joined #ocaml
maihem has joined #ocaml
jdrake has quit [Read error: 110 (Connection timed out)]
yauz_ has joined #ocaml
mrsolo has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
yauz has quit [Read error: 113 (No route to host)]
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
CosmicRay has joined #ocaml
poingie has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
vezenchio has quit ["With little power comes little responsibility"]
monotonom has joined #ocaml
bzzbzz has joined #ocaml
zigong has quit [Remote closed the connection]
gl has left #ocaml []
bzzbzz has quit [Read error: 104 (Connection reset by peer)]
Herrchen_ has joined #ocaml
Herrchen has quit [Read error: 60 (Operation timed out)]
GreyLensman has quit ["Leaving"]
poingie has left #ocaml []
mrsolo has quit [Operation timed out]
monotonom has quit ["Don't talk to those who talk to themselves."]
MacCall has quit [Remote closed the connection]
CosmicRay has quit ["Client exiting"]
debona|r has left #ocaml []
jason has joined #ocaml
_fab has joined #ocaml
dan2 has joined #ocaml
<jason> How do you find out what exceptions a particular call throws?
<dan2> lets say I wanted to write a function that creates a sum of two numbers, but how do I do this without restricting to types
sproctor has quit [Read error: 60 (Operation timed out)]
<jason> I don't think you can do that.
<dan2> heh
<jason> You can do comparisons, list operations, call methods.
<jason> Stuff like that.
<dan2> heh
<jason> I think.
<jason> What?
<dan2> bummer
<dan2> I wanted to be able to mix match integers and floats
<jason> Yeah, that's a problem though, Ocaml tries to make these operations safe.
<dan2> does ocaml have a multi platform toolkit like Wx
<jason> You probably could get bindings to wxWindows.
<jason> It has Gtk.
<jason> And libFox I think.
<dan2> libfox?
<dan2> jason: what about dynamic arrays?
<jason> Well, they're not exactly dynamic arrays, but you do have functional lists and such.
<dan2> bah
<jason> You can add values from them, and remove values from them in a functional manner.
<jason> It's the same effect as a dynamic array really.
<dan2> oh, ok
<Demitar> iirc, there are a number of dynamic array implementations floating around too. (I think even extlib has one.)
<Demitar> And there is generic caml too (as per your operator overloading issue), but one never knows when that might hit mainstream calm.
<mflux> dan2, you could do something like let int_ops = [| ( + ) ; ( - ) ; ( * ) |]; and then fun operate ops x y = ops.(0) x y;
<mflux> that might not be enough for you though
ionOS has joined #ocaml
<mflux> hmh, fun -> let that is
<mflux> this way you can write operate int_ops 4 2; or operate float_ops 4.0 2.0;
<jason> mflux: How do I find out what exceptions are thrown?
<jason> And is there a typedef somewhere for a NULL string?
<mflux> you don't
<jason> Like, how do I say "This string doesn't have any valid contents"?
<jason> Well, can I catch a generic exception?
<mflux> actually, there's a project that determines from an ocaml progrrgam which exceptions are uncaught
<jason> Like "with exception"?
<mflux> I can't remember its name
<mflux> I doubt you can
<jason> I'm technically catching NO exceptions at the moment
<jason> Not a very well defined program.
<mflux> also I don't think ocaml exceptions can form a hierarchy similar to c++ or java, but then again I don't know that much about ocaml yet
<mflux> instead of null-pointers you may use option
<jason> You can make a with statement at the end of a let or a try.
<jason> What's option?
<mflux> such as let foo n = match n with 0 -> None | _ -> Some "foo";;
<mflux> type 'a option = None | Some of 'a;;
<mflux> (that's predefined)
<jason> Alright.
<jason> mflux: I'm using a String to buffer contents I'm reading from a server.
<mflux> using option will get a little bit more simple if you implement a little module that does get and on failure throws an exception - sourceforge.net has a module that does exactly that
<mflux> ocamlextlib or something
<jason> Does Ocaml pad it with some unusual characters or something?
<mflux> no
<mflux> ocaml just replaces the characters with the ones it received
<jason> Hm.
<mflux> if there were more characters originally they will stay there
<jason> Well, the problem is, I'm using them as a proxy between a client and a server.
<mflux> I did a similar program and it stores separately how much it read from the server
<jason> The input must be different than what it usually is.
<jason> Because the client doesn't understand the incomming string even though the printout of it looks correct.
<mflux> I have some code that succesfully accesses a nntp-server with ocaml
<jason> Yeah.
<jason> I made some generic socket stuff.
<jason> It works with most everything I've used it with so far.
<jason> Http, FTP.
<jason> But the input must be slightly different because the client is particularly anal about what input it receives
<mflux> well, have you inspected the data?
<mflux> followed the network traffic?
<mflux> or dumped the data to a file from your program for inspection with a hex viewer..
<jason> No, I was hoping it was just some padded chars.
<Demitar> It's like in C where the return value of recv() is important (it's boils down to speed in the end really, you can implement allocating versions on top of those if you want).
<dan2> hmm, whats the algorithm for finding the rref of a matrix
mrsolo has joined #ocaml
<Demitar> "rref of a matrix"?
<dan2> reduced row echelon form
<dan2> when it shows 1s coming diagnolly from the top left
<dan2> :)
<mflux> there are the algorithms you use when you do it by hand, and then there are the efficient algorithms for computers ;)
<dan2> :)
<mflux> I suspect a google search will guide in both of them..
<dan2> mflux: like the newton algorithm of sqrts :)
<dan2> super effective on computers because they can number crunch
<dan2> x_k+1 = 1/2(x_k + n/x_k)
<dan2> heh, I can't program ocaml, I can't even do this
<dan2> I don't know how to write that in ocaml
<dan2> how would you write that in ocaml
weitzman has quit [Read error: 60 (Operation timed out)]
kinners has joined #ocaml
bk_ has joined #ocaml
mr_bubbs has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
kinners has quit [Nick collision from services.]
kinners has joined #ocaml
bk_ has joined #ocaml
kinners has quit [Nick collision from services.]
kinners has joined #ocaml
Herrchen_ is now known as Herrchen
jdrake has joined #ocaml
jason has quit ["Client Exiting"]
mattam_ is now known as mattam
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
smimou has joined #ocaml
kinners has quit [Read error: 60 (Operation timed out)]
smimou has quit [Client Quit]
smimou has joined #ocaml
gzl has quit [Read error: 104 (Connection reset by peer)]
gzl has joined #ocaml
vezenchio has joined #ocaml
mr_bubbs has quit [niven.freenode.net irc.freenode.net]
mr_bubbs has joined #ocaml
yella has quit [Read error: 110 (Connection timed out)]
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
GreyLensman has joined #ocaml
whee has joined #ocaml
weitzman has joined #ocaml
poingie has joined #ocaml
Dvalin has quit [Remote closed the connection]
tautologico has joined #ocaml
Dvalin has joined #ocaml
poingie is now known as point
point is now known as poing
weitzman has quit ["weitzman has no reason"]
cjohnson has quit [Read error: 110 (Connection timed out)]
br1 has joined #ocaml
cjohnson has joined #ocaml
br1 has left #ocaml []
mr_bubbs has left #ocaml []
pac_away has joined #ocaml
pac_away is now known as pac_awake
pac_awake is now known as pac_aw
menace has joined #ocaml
debona|r has joined #ocaml
tautologico has quit ["Leaving"]
ne1 has joined #ocaml
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
poing has left #ocaml []
mrsolo has quit ["Leaving"]
mrsolo has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
Nutssh has joined #ocaml
pattern has quit [Read error: 113 (No route to host)]
mattam_ has joined #ocaml
ionOS has quit [Read error: 104 (Connection reset by peer)]
R3s3arch has joined #ocaml
<Smerdyakov> R3s3arch, congratulations! You have a ridiculous nick!
pac_aw has left #ocaml []
Nutssh has left #ocaml []
mattam has quit [Read error: 110 (Connection timed out)]
weitzman has joined #ocaml
weitzman has quit [SendQ exceeded]
weitzman has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
jcristau has joined #ocaml
<mflux> hm, I can say ( - ) 42 to create a function that substracts
<mflux> how do I write the same using unary - ?
<mflux> ie. negate the argument
<mflux> and, another one ;) : how do I retrieve some node from a hash without knowing its key; doesn't matter which one
<mflux> it doesn't strike as very efficient to me to use Hashtbl.fold/iter for that
<mflux> otoh, it might be the hash table doesn't have an easy way to do that either
<mflux> hmh, no, of course it does as it implements the foresaid functions 8-)
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
<mflux> uhh, and Map doesn't have functions for accessing the smallest/largest key or previous/next?-o
pattern has joined #ocaml
cedricshock has joined #ocaml
smimou has quit ["?"]
cedricshock has quit ["Leaving"]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<dan2> are there any real books yet for ocaml in english?
<menace> the o'reilly book?
<dan2> menace: a real book?
<dan2> I want something I can hold in my hand
<menace> Print it? :)
whee has quit []
<dan2> menace: 400pages?
<menace> copyshop :)
<menace> it's not as expensive as it seems to be imo
<dan2> menace: mm, I wonder how much that'd be from Kinkos
<dan2> say its 5 cents a copy
<dan2> 20 bucks
<dan2> heh
<menace> :)
* dan2 searches for a copy shop with 3 cents per copy\
<dan2> menace: how can I find the type of the input of a function?
<dan2> sure, id x = x;;
<dan2> but, I need to know how to identify which is which
<menace> hä?
<dan2> menace: how long did it take you to learn ocaml?
<menace> i'm still learning and have just a few basic skills
<dan2> menace: how do yo I use types?
<menace> atm i don't use it very expressive/much..
<menace> atm i don't code anything at all because of lack of time
<dan2> heh
<dan2> menace: how do I enforce types upon something in a class
<mflux> do you mean let foo (x : int) = x;; ?
<mflux> you will rarely need that though
<dan2> yes something like that
<dan2> mflux: let foo (x : int,float)?
<mflux> sorry, no
<dan2> heh
<dan2> mflux: I am trying to apply it to a class
<Riastradh> Every variable has exactly one type.
<mflux> perhaps some day in future
<dan2> I want the class to except only one type
<dan2> or two types even
<Riastradh> Make up your mind.
<dan2> mflux: well, how do I create a type
<dan2> like, type number = Float of float | Int of int but use it for the class
<mflux> in that case you will need to accept number as a parameter
<Riastradh> class type ['a] arithmetic = object method add : 'a -> 'a method subtract : 'a -> 'a ... end (* or something like that; I have no idea if that will actually work *)
<Riastradh> Why are you using the object system?
<dan2> Riastradh: testing
<dan2> mflux: class number ( type n = Float of float | Int of int;) ?
<Riastradh> Testing what?
<mflux> yes, except I don't think you can define a type inside a class
<dan2> mflux: well, how do I define the type before hand
<mflux> so type num = ...; class foo = object var bar = Number 42 end;;
<Riastradh> s/Number/Int/1
<mflux> what he said
<mflux> ;)
<dan2> mflux: can I do something like (type n a) as an argument?
<mflux> you can make a polymorphic class if that's what you mean
<dan2> mflux: heh, this is confusing
<Riastradh> dan2, why are you using the object system? 'Testing' isn't a very satisfactory answer.
<dan2> I just want a class to identify numbers and use a sane substraction function regardless of type
<Riastradh> To 'identify' numbers?
<mflux> well why didn't you say so in the first place!-)
<mflux> I can think only one way of doing that
<dan2> mflux: so I guess it needs to be polymorphic
<mflux> infact which I've shown earlier on this channel, hm
<mflux> so you have for example arrays or records for different kinds of operations
<dan2> ok
<mflux> let int_op = ( + ) and let float_op = ( +. )
<mflux> and you give the data plus that function as an argument to a class
<Riastradh> type 'a arithmetic = { add : 'a -> 'a; subtract : 'a -> 'a; etc }
<dan2> Riastradh: then how do I define the methods for subtracting
<Riastradh> ...er, 'a -> 'a -> 'a, not 'a -> 'a.
<dan2> I don't understand how that works at all
<Smerdyakov> dan2, first, I would ask you to consider why you want to do this in the first place.
<Riastradh> let float_arith = { add = (+.); subtract = (-.) }
<Smerdyakov> dan2, is it just to avoid having to type -. instead of - sometimes?
<dan2> Smerdyakov: not quite
<Smerdyakov> dan2, OK, then why?
<mflux> the class could be written like class ['op, 'data] foo (op : 'op) (init : 'data) = object method value_plus_n n = op init n end;;
<mflux> smerdyakov, perhaps he likes a class that works with int, Int32 and Int64
<mflux> nevermind what he needs it for, it is a thing that needs to be possible to write in ocaml ;)
<Smerdyakov> mflux, I don't identify much meaning with the idea "a class that works with types." "Working with types" makes me think more of functors.
<Riastradh> (which is basically what I'm suggesting, but statically)
<Smerdyakov> mflux, what is this thing, and why is it needed?
<mflux> perhaps he likes to know how is it done or can it be done in advance of designing a program that might or might not use the feature
<Smerdyakov> I don't buy "reasons" like that. They're usually given by people new to a language who don't understand the common idioms in it.
<Smerdyakov> Just because you _think_ it would be useful to do something doesn't mean that it actually makes sense to do it.
<mflux> it is useful to _know_ something
<Smerdyakov> It is more useful to know more useful things.
<mflux> so your statement is that under no circumtances it is possible to write a useful program that uses the forementioned feature, and even if it, it could be written better without?
<mflux> s/if it/if it is/
<Smerdyakov> I'm saying that it doesn't seem likely to me that it makes sense to write any programs using that "feature."
<mflux> and I'm saying I don't know if there's a program for which it makes sense to use it
<Smerdyakov> The only way I would change my mind is if I were given a concrete example.
<mflux> I'm unlikely to pull such an example out of my hat right now, but perhaps some day I'll figure out one ;)
<Smerdyakov> Since I have never encountered such a thing before, never wanted it, and never seen anyone else request it, I assume by default that someone asking for that feature needs to state his problem at a higher level so that he can be told what the idiomatic way to do it is.
pattern has quit [No route to host]
* dan2 doesn't like super safe typing
<Riastradh> dan2, just answer the question: what is this for?
* dan2 heads back toward malloc()
<Riastradh> dan2, _what_is_this_for_?
<dan2> Riastradh: a system to let me create functions that don't care about types
<dan2> Riastradh: its the number type
<dan2> :)
<Riastradh> dan2, can you specify what you intend to use this for?
<Riastradh> And are you familiar with functors?
<Smerdyakov> dan2, your question is like someone asking "How do I disable interrupts in Java?".
<mflux> anyway, the technique is useful without classes too, and very ml'ish, although maybe not exactly for arithmetics
<Smerdyakov> dan2, you are trying to lift something from another style of programming, despite the fact that it may not have an equivalent in the new language.
* dan2 wrote a new algorithm to handle spam
<mflux> isn't he just writing a function (class, no difference in this aspect) that accepts any kind of data without builtin-support for "any kind of data"
<Smerdyakov> dan2, but the fact that it doesn't have an equivalent doesn't mean that the _high_level_ task you are trying to perform can't be handled elegantly.
<dan2> the algorithm I wrote can identify spammers
<Smerdyakov> mflux, if he is, he has probably misdesigned the program.
<dan2> Smerdyakov: haven't implemented eyt
<mflux> well, I believe I have a similar approach and it doesn't seem faulty to me
<mflux> I have a module that has a function that threads messages
<Smerdyakov> mflux, what is your approach? You just said you couldn't think of an example.
<Riastradh> dan2, please, can you just give more specifics regarding what you intend to use this for?
<mflux> I didn't relate my problem immediately to this
<Smerdyakov> mflux, well, if you want to make a case for the utility of this mysterious feature, please do go ahead!
<dan2> Riastradh: it has to do with sentence count, char count, and count of each type of charachter, along with word count to create percentages
<mflux> because I don't want to be bothered designing yet what kind of messages I will be handling, the function signature is val thread_messages : 'a message list -> ('a -> 'a -> int) -> ('a -> 'b) -> 'a msg_tree list
<Riastradh> OK, go on, dan2...
<Smerdyakov> mflux, OK, that is a standard polymorphic function. It doesn't seem related to the previous conversation.
<dan2> Riastradh: the whole design is written on about 50 postits on my desk
<Smerdyakov> dan2, why does this make you think it is appropriate to do what you asked at the start?
<dan2> Riastradh: I wrote a perl script to test it between 6 documents RMS wrote, and then out of the blue the BSD license
<mflux> smerdyakov, how is that what dan2 is writing not a 'standard polymorphic function', the fact he's doing arithmetics with it?
<Riastradh> dan2, I don't really care about the whole design of your new spam filter; all I'm asking about is what you intend to use the function with this funky type for.
<dan2> Riastradh: clearly its a polymorphic function
<Smerdyakov> mflux, I haven't yet understood what he is asking, but it seems he wants to perform actual _operations_ on data of unknown type, not just move them around in memory.
<Riastradh> What is?
<dan2> the parser and its other functions
<mflux> and the ml way would be to provide functions to do just that as arguments to the function?
<Riastradh> Can you be more specific, dan2?
<Smerdyakov> mflux, the ML way, whenever you want "operations on data of unknown type," almost always uses functors.
<dan2> because the word count would always be integral, and charachter count, but the produced presentage between differentiation and division would return different types
<mflux> smerdyakov, hm, can you instantiate a functor within a function?
<Smerdyakov> mflux, no. That is not something a competent ML programmer wants, though.
<mflux> doing that might needlessly complicate the interface
<Smerdyakov> mflux, i.e., if you think that would be helpful, you probably don't understand how to use functors.
<Riastradh> dan2, why don't you just convert the word & character counts to floats and perform the rest of the operations on floats?
<dan2> Riastradh: heh
<Riastradh> ?
<dan2> too tired to explain why now
<mflux> smerdyakov, well, considering my program, I first wanted to make a hash or map that would use a hashing/comparison function given as a parameter to thread_messages
<Riastradh> Do you expect to get help as to the solution for your problem if you can't explain your problem?
<dan2> Riastradh: the fact is, I need to do it this way
<mflux> I'm not sure if or how that can be done though
<Smerdyakov> dan2, I hope you'll excuse us if we don't believe you. :P
<Smerdyakov> mflux, have you spent any amount of time reading about functors?
<mflux> smerdyakov, I've basically read enough to instantiate a set or map with custom data and comparison functions ;)
<mflux> but not much more
<Smerdyakov> mflux, OK, then what is stopping you from instantiating something with a custom hashing/comparison function?
<dan2> Riastradh: guess the learning curve is too steep for me to move from C based languages to an ML based
<Smerdyakov> dan2, rather, it seems that your communication skills are too bad to get help on this.
<Riastradh> dan2, no, you're _making_ it _seem_ to steep by not explaining your problems.
<mflux> smerdyakov, it wouldn't anymore be a simple function call for the module user?
<mflux> smerdyakov, the module user would be distracted with a implementation detail of thread_messages
<mflux> as the hash itself never appears to the user
<Smerdyakov> mflux, you make a mdoule that continas thread_messages.
<Riastradh> Just explain why you can't operate on floats, dan2.
<Smerdyakov> mflux, this module is a functor, parametric on the necessary data.
<Smerdyakov> mflux, the functor is instantiated once for every kind of data.
<mflux> hm well yes that would do it
<Smerdyakov> mflux, the key difference is thinking of things as static applications of functors instead of run-time dynamic dispatch.
<Riastradh> s/to steep/too steep/1
<mflux> but it does seem quite an artificial step; adding one level of indirection makes drastic changes on how the module is used
<Smerdyakov> mflux, you do all "dynamic dispatch" via static resolution for module-level functor applications.
<dan2> Riastradh: because I need something where I can get larger numbers than accepted by floats
<Smerdyakov> mflux, what kind of changes?
<Riastradh> Larger numbers than accepted by floats?
<dan2> Riastradh: > 64 bit numbers?
<mflux> smerdyakov, I was under the impression after that the user would need to write module Bar = Threading.Make ( .. ) instead of just Threading.thread_messages data (fun.. ) ?
<Smerdyakov> dan2, I think floats support _larger_ integers than ints with perfect precision, not the other way around.
<mflux> in any case it does sound like the functor way is the way to go
<Smerdyakov> mflux, right.
<dan2> Smerdyakov: no, but both int and float would be too small
<Smerdyakov> dan2, at any rate, you still haven't explained why you want a weird class that works with ints and floats.
<Riastradh> dan2, so use a float module that provides even more precision.
menace has quit ["Leaving"]
<dan2> Smerdyakov: why is an irrelvent question, its that it needs to work this way because I say so
<dan2> Smerdyakov: the fact that you think I am too stupid to know why I need each type is irritating
<Riastradh> dan2, do you think the fact that you won't tell us is less irritating?
<dan2> Riastradh: I came for a 'How' answer, not a 'Why' question
<Riastradh> dan2, I don't want to start irritation matches. I just want to help you solve your problem, and both Smerdyakov & I think that you're probably doing something unidiomatic of OCaml.
<Riastradh> If you tell us what you're doing that requires such a mechanism, then perhaps we might be able to lead you to the usual OCaml idiom for your purpose.
<Smerdyakov> dan2, I don't think you are too "stupid." I think you are too _unfamiliar_ with OCaml.
<dan2> Smerdyakov: I wanted to use ocaml, because I need garbage collection, and I need a good lexer
<Riastradh> dan2, can you just tell us why you must use floats and ints interchangably?
<ne1> double precision float is exact with 53-bit integer or so.
dan2 has left #ocaml []
<ne1> He doesn't like "super safe typing" in the first place anyway.
<ne1> Imagine someone going into a Christian church saying "I want Christianity because I want resurrection. But I don't like your idea of original sin."
<ne1> What can you say. He is welcome to create his own religion, you know.
cjohnson has quit [Connection timed out]