chris1 has quit [Read error: 110 (Connection timed out)]
pac_ has quit ["leaving"]
chris2 has quit []
monotonom has quit ["Don't talk to those who talk to themselves."]
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
vezenchio has joined #ocaml
<vincenz>
no
<Riastradh>
Yes.
<Lemmih>
Maybe.
wedman has joined #ocaml
<Riastradh>
Mu.
yauz_ has joined #ocaml
yauz has quit [Read error: 110 (Connection timed out)]
<vincenz>
((lx.x x) (lx.x x))
* vincenz
wonders what the type of lx.x x is
<vincenz>
that's a recursive type, no?
<vincenz>
type x = 'a -> 'b = 'a
<vincenz>
type x = ('a -> 'b) as 'a
<vincenz>
?
* vincenz
wonders how hindley milner does that without entering an infinte loop
<vincenz>
ah, it's not allowed in ocaml :P
<vincenz>
# let f x = x x;;
<vincenz>
This expression has type 'a -> 'b but is here used with type 'a
<vincenz>
(on the last x)
<vincenz>
makes sense
cjohnson has joined #ocaml
kinners has joined #ocaml
wedman has left #ocaml []
vezenchio has quit ["According to [a processor for game design], you statistically have a better chance of becoming a rock star than you do of succ"]
vezenchio has joined #ocaml
mrsolo has joined #ocaml
bk_ has quit [Remote closed the connection]
bk_ has joined #ocaml
kinners has quit [Read error: 60 (Operation timed out)]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
buggs has quit [Remote closed the connection]
buggs has joined #ocaml
buggs has quit [Remote closed the connection]
buggs has joined #ocaml
<Vulpyne>
http://nopaste.php.cd/20029 if anyone wants a not-so-trivial example of using ocaml's libevent library. It's my first ocaml program, so if anyone wants to critique, feel free. :)
<Vulpyne>
It's an interface to libevent, for making event-driven applications with select/poll/kqueue or whatever your system has.
<vincenz>
bad choice of name though
<Vulpyne>
Ah, I didn't make that.
<vincenz>
yeah, but there's an Event module already
<Vulpyne>
I see...
<vincenz>
so no threads?
<Vulpyne>
No threads. It uses io multiplexing only.
<vincenz>
where is the main loop then>?
<vincenz>
dispatch I presume
<Vulpyne>
Event.dispatch
* vincenz
nods
<vincenz>
seems cool :)
<vincenz>
is it stable?
<vincenz>
(0.0.2 ...)
<Vulpyne>
Event or my code?
<Vulpyne>
I don't know, probably not.
Herrchen_ has joined #ocaml
<Vulpyne>
Wasn't tested much. Heh, there was a print_newline in the middle of the actual Event module that just would print lots of blank lines whenever there was an event.
<vincenz>
ouch
<Vulpyne>
Pretty easy to fix once I figured out it wasn't coming from my code.
<Vulpyne>
Any comments on my code? Stuff I should have done better, etc?
<Vulpyne>
I've never written any ocaml programs before.
CosmicRay has joined #ocaml
rox has quit ["Client exiting"]
<vincenz>
is libevent efficient?
Herrchen has quit [Read error: 110 (Connection timed out)]
<Vulpyne>
Yeah.
<Vulpyne>
It's quite fast.
<Vulpyne>
I haven't used it, but I wrote my own libevent in C.
<Vulpyne>
Only supports kqueue, though.
kinners has joined #ocaml
<vincenz>
kqueue?
<Vulpyne>
Kind of like select/poll, but better.
<Vulpyne>
Are you familiar with those?
<vincenz>
euhm
<vincenz>
I know what they do yes
<vincenz>
But for the rest myk nowledge of tcp/ip programming is quite limited
<Vulpyne>
Basically, you submit a list of fds with possible timeouts and it returns with the ones that have changed whenever there are events.
<Vulpyne>
And then you just call your handlers and do processing for any fd with events.
<Vulpyne>
libevent can do signals also.
<vincenz>
how does it do that?
<vincenz>
just loop?
<Vulpyne>
Do which?
<Vulpyne>
And are you talking about kqueue or libevent?
<vincenz>
libevent
<Vulpyne>
It's dispatch function is a loop where it calls kqueue/select/poll to check for events and dispatches to handlers.
<Vulpyne>
Was that your question?
CosmicRay has quit [Read error: 113 (No route to host)]
<vincenz>
yeah, thnx
<Vulpyne>
Sure.
Iter has quit [Read error: 110 (Connection timed out)]
kinners has quit [Read error: 110 (Connection timed out)]
bk_ has joined #ocaml
_JusSx_ has joined #ocaml
_fab has joined #ocaml
<Vulpyne>
http://nopaste.php.cd/20031 - Take a look at where handle_ClientDisconnect is called, and also defined down near the bottom.
<Vulpyne>
I pass it just an int for the hash, because I can't figur out how to actually pass the object around.
<Vulpyne>
I guess I need a polymorphic method, but I can't get that working... Anyone able to help perhaps?
<Vulpyne>
Line 47 is where it's called, 235 where it's defined.
<Vulpyne>
Any ideas?
MercyW_ has joined #ocaml
mrsolo has quit [Read error: 104 (Connection reset by peer)]
MercyW_ is now known as mrsolo_
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
smimou has joined #ocaml
bk_ has joined #ocaml
<Vulpyne>
Did anyone see my question?
vincenz has quit ["leaving"]
smimou has quit ["?"]
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
smimou has joined #ocaml
smimou has quit [Client Quit]
yauz_ is now known as yauz
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
_JusSx_ has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
smimou has quit [Read error: 113 (No route to host)]
smimou has joined #ocaml
maihem has joined #ocaml
Iter has joined #ocaml
_JusSx_ has joined #ocaml
cjohnson has quit [Success]
cjohnson has joined #ocaml
smimou has quit ["?"]
smimou has joined #ocaml
vezenchio has quit ["According to [a processor for game design], you statistically have a better chance of becoming a rock star than you do of suc]
vezenchio has joined #ocaml
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
Iter has quit [Read error: 110 (Connection timed out)]
Axioplase has joined #ocaml
<Axioplase>
Chat Lu!
CosmicRay has joined #ocaml
yella has joined #ocaml
<yella>
hi
<mrsolo_>
hi
<yella>
if i have a recursive function which, at some point, raises an exception and I want to ignore or 'jump over' this exception, how do I do it?
<yella>
like i have Str.search_forward in this function which raises Not_found everytime the regexp does not match, but i still want the the function goes own
<cDlm>
try ... with Not_found -> ...
<Riastradh>
let x = try ... with Not_found -> ...
<Riastradh>
in recur ...
<yella>
yes but ..hrm no
settra has quit [Read error: 110 (Connection timed out)]
<yella>
and what comes after catching it? do I call the recursive function again?
<Riastradh>
What do you do with Str.search_forward's result?
<yella>
well nothing, I'm just interested if i get an exception or not. if not then i concatenate the string which i gave to Str.search_forward with the result from the recursive function
<yella>
Str.search_forward regexpp msg 0; msg ^ (get_msg_from s t)
rox has joined #ocaml
rox has quit ["Client exiting"]
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
_fab has quit [Read error: 60 (Operation timed out)]
rox has joined #ocaml
vezenchio has quit ["<lus|wats> wer soll "rehakles" denn sein bitteschön?? :|"]
_JusSx_ has quit [Read error: 110 (Connection timed out)]
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
<Vulpyne>
http://nopaste.php.cd/20031 - Take a look at where handle_ClientDisconnect is called, and also defined down near the bottom.
<Vulpyne>
I pass it just an int for the hash, because I can't figur out how to actually pass the object around.
<Vulpyne>
I guess I need a polymorphic method, but I can't get that working... Line 47 is where it's called, 235 where it's defined.
<Vulpyne>
Anyone around that may be able to help me?
<Vulpyne>
Or if you need help understanding what my code is actually doing, I can clarify.
Axioplase is now known as Axio|Away
gim has joined #ocaml
<mattam_>
polymorphic methods are explained in the manual
mattam_ is now known as mattam
<Vulpyne>
I read it, but the explanation really isn't very basic.
<Vulpyne>
method fold : 'a. ('a -> int -> 'a) -> 'a -> 'a = fun f accu -> List.fold_left f accu l
<Vulpyne>
That's their example from the manual, but it may as well be written in swahili for me.
cjohnson has quit [Connection timed out]
<Vulpyne>
I don't see any explanation about 'a. and what exactly that does, etc.
<Vulpyne>
Can you possibly give me a simpler example/explanation?
<mattam>
basically you need to explicitly type it, giving the type in which your method is polymorphic like the 'a. in their example
<Vulpyne>
I kind of understand the basic idea, but not the details.
<mattam>
what's the function ? (line 235 is just an instruction)
<mattam>
oh nm
<Vulpyne>
235 is method handle_ClientDisconnect
<Vulpyne>
The client (netconnection class) needs to pass itself back to the server (netserver class) to be unregistered from the clients list.
<Vulpyne>
But it can't just be set to take a netserver, because I'll inherit from that for different types of servers.
<Vulpyne>
Does what I'm trying to do make any sense?
<mattam>
yes
<Vulpyne>
I found a message where they basically say change: method id x = x
<mattam>
you can use Oo.id instead of the Hashtbl.hash
<Vulpyne>
to: method id: 'a.'a -> 'a = fun x -> x to make it polymorphic.
<Vulpyne>
But I don't understand why there are three "'a"s for example. Or what the dot joining two of them means.
<Vulpyne>
Ah, good idea. I still should learn how to do it the polymorphic way, though.
<mattam>
if you want to pass the object then you have to use recursive class definitions i think
<Vulpyne>
Like method handle_ClientDisconnect: 'a.'a -> unit = fun whatever -> blah; blah; () doesn't work.
<mrsolo_>
hmm does anybody know where i can get some examples on practical use of fuctors?
<mattam>
'a. means "forall a"
<mattam>
'a -> 'a means the method has type 'a -> 'a like regular functions
<Vulpyne>
Ah.
<Vulpyne>
So I'd basically slap the two classes next to each other and replace the end;; on the first one with "and".
<Vulpyne>
And type parent to : netconnection?
<Vulpyne>
What about when I subclass, though?
<mattam>
shouldn't parent be netserver instead ?
<Vulpyne>
Err, sorry. I shouldn't have even been saying parent.
<Vulpyne>
I mean type the argument to handle_ClientDisconnect in the netserver class to take a netconnection.
<mattam>
class ['a] connection =... and ['client] server = val clients = 'client connection list ... method disconnect : 'client connection -> unit...
<mattam>
but now you don't have polymorphism
<Vulpyne>
I don't understand how to do it then.
<Vulpyne>
I need to say that the method can take any netconnection or any class that inherited from it.
<mattam>
you should define a client _class type_ and type disconnect to '#client_class_type -> unit'
<Vulpyne>
In each subclass?
<mattam>
so #netconnection here
<mattam>
each subclass of what ?
<Vulpyne>
disconnect is in the #netserver, which will always be subclassed into specific types of server.
<Vulpyne>
And it'll always take subclasses of #netconnection.
<mattam>
yes, you'll have to give the same type in each subclass
<Vulpyne>
I meant, I would just define it in netconnection, and again every time I subclass netconnection?
<Vulpyne>
To make sure it was the current type.
<Vulpyne>
Is that what you're saying?
<mattam>
disconnect == handle_ClientDisconnect in my mind
<Vulpyne>
Yup, that's what I meant when I adopted your abbreviation too.
<mattam>
so not in subclasses of connection but of server
<Vulpyne>
Er, yeah.
<Vulpyne>
Sorry.
<Vulpyne>
But was what I said about re-typing in every subclass of netserver correct?
<mattam>
np
<mattam>
yes, you'll be forced to do it by the type system
<Vulpyne>
Okay, thanks.
<Vulpyne>
I'll leave it with Oo.id for the moment, though. :)
<Vulpyne>
I'll have to deal with this eventually if I start using ocaml seriously, and your help will come in very useful then. :)
amandus has joined #ocaml
cjohnson has joined #ocaml
_fab has joined #ocaml
greenrd has quit [Read error: 60 (Operation timed out)]
rox has quit [Remote closed the connection]
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
rox has joined #ocaml
rox has quit [Remote closed the connection]
rox has joined #ocaml
GreyLensman has joined #ocaml
rox has quit [Read error: 104 (Connection reset by peer)]
rox has joined #ocaml
buggs has quit [Remote closed the connection]
amandus has left #ocaml []
maml has joined #ocaml
maml has quit ["Leaving"]
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
ne1 has joined #ocaml
mrsolo_ has quit ["Leaving"]
buggs has joined #ocaml
pac_ has joined #ocaml
<pac_>
Hi all
pattern has quit [Read error: 113 (No route to host)]
<pac_>
any ocam guru
<pac_>
?
<pac_>
ocaml guru ?
<mellum>
pac_: you'd save a lot of time if you'd ask your question immediately :)
<pac_>
mellum: I am working on another stuff so I am not hurry
<pac_>
mellum: :D
<pac_>
here is my question, is OCAML well supported for Databases ?
<pac_>
mellum: now you see you do not answer ;)
<mellum>
So I guess I'm not a guru then.
Iter has joined #ocaml
<pac_>
mellum: in which contect do you work with OCAML ?
<mellum>
pac_: I use it for research in theoretical computer science
<pac_>
mellum: are you doing a PhD ?
<mellum>
pac_: yes
<Banana>
pac_: did you have a look at the Ocaml Hump ?
<pac_>
Banana: in which university will you do your PhD?
<Banana>
well that's THE question for now ^_^.
<pac_>
Banana: do you ALain Frish ?
<pac_>
do you know
<Banana>
?
<pac_>
him
<Banana>
yes.
<Banana>
he his co-supervising my internship.
<pac_>
its one of my indirect cousin :D
gim has quit ["a bientot"]
<Banana>
hey what do you know, it's a small world.
<Banana>
he drops by here from times to times.
<pac_>
oki
bk_ has joined #ocaml
<pac_>
Banana: is still phd student or now he is professor ?
<Banana>
still phd student.
<Banana>
but not for long...
<pac_>
oki
<pac_>
when does he finish it ?
<Banana>
September.
<pac_>
ehehe
<pac_>
so you do not know where to do your Phd Thesis...
<Banana>
i do no know exactly.
<Banana>
if i get a grant then in University Paris XI.
<pac_>
ki
<Banana>
if not there then co-financed (?) by ens paris and university of Marseille.
<Banana>
so i 'll have to spend half of my phd thesis there.
<pac_>
co-funded ??
<Banana>
yes.
<Banana>
i'm near Paris right now
<pac_>
well Provence is not a bad place to work :D
<Banana>
^_^
<pac_>
OCAML is very good language and not enough used in the industry why ?
<pac_>
WHy is there only a native compiler for x86 that's also a big question for me !!
<Banana>
?
<Banana>
there is also native compiler for ppc, alpha...
<Banana>
ia64, opteron
<pac_>
Banana: really ?
<Banana>
of course.
<greenrd>
pac_: IMHO OCAML is not as convenient as Java in some respects.
<ne1>
Popularity is based on a lot of factors, the least important of which is quality.
<pac_>
is it possible to use CDuce from a OCAML application ?
<Banana>
3rd paragrah of the README file.
<pac_>
ne1: not false
<Banana>
pac_: that's at work.
<greenrd>
The need to use let rec - in general the inability to do recursive or forward-referencing definitions flexibly
<greenrd>
No packages
<Banana>
an intern is coding an interface to use CDuce in caml...
<Banana>
greenrd: you have modules.
<greenrd>
Not quite the same.
<Banana>
which are much more flexible.
<ne1>
I am inclined to believe that chance is the most important factor.
<pac_>
Banana: " The native-code compiler is only available on certain platforms. " OCAML manual which platforms are missing?
<Banana>
and forward declaration isn't that usefull.
<Banana>
pac_: read the README and you will see which are not missing :
<greenrd>
Can you do package private access? In fact can you access fields from another class AT ALL, because I haven't worked out how to...
<Banana>
you mean attributes ?
<Banana>
(i wasn't talking of object but...)
<Banana>
attributes are private.
<greenrd>
Er yeah, sorry
<Banana>
i dont' use object at all.
<greenrd>
Yeah, so, less flexible modularity
<Banana>
no I use polymorphic modules.
<greenrd>
Well, OO is popular in industry, some would say for good reason
<pac_>
Banana: yep do not explictly say which are not suported but that's good news anyway for what I am planning to do.
<pac_>
greenrd: OCAML provides Object
<greenrd>
I know.
<Banana>
pac_: I wouldn't go on this sides.
<ne1>
How OO became popular is interesting. Remember there was a time when industry actually rejected OO as inefficient and obscuring.
<greenrd>
That was when comps were ORDERS OF MAGNITUDE slower.
<Banana>
objects in caml are realy good but they are not what "people of the OO real word blah blah" are used to.
<pac_>
Banana: ??
<greenrd>
Times have changed. As for obscuring - pah - that's just the standard "New therefore huh?" reaction.
<pac_>
Banana: ????
<ne1>
I think the main contribution was from a bunch of giant consultants such as Yourdon and Codd and the Rational people. They actively visited companies, literally selling OO as snake oil.
<greenrd>
Heh
<Banana>
pac_: Object in Ocaml are polymorphic AND statically typed.
<Banana>
so there are some « restriction »
<pac_>
Banana: everything is statically typed in OCAML right ?
<Banana>
yes.
<pac_>
Banana: what can't you do with OCAML object that you will be able to do in C++ or Java ?
<Banana>
pac_: that's not what i said.
<ne1>
Anything backed by a team of hardworking salespersons will become popular.
<Banana>
you can do what you want. (it's turing complete after all ;)))
<greenrd>
Oh, and you can't do casts to subtypes in OCAML. Even casts to supertypes have to be made explicit ("thanks" to type inference).
<Banana>
hold on.
<Banana>
first don't call it subtype.
<greenrd>
I find objects in OCAML less flexible, though perhaps that's just because I'm new to the language.
<Banana>
it's subclass
<Banana>
subtyping is a slightly different thing.
<greenrd>
Please explain.
<Banana>
then as there is no dynamic typing you cannot coerce to a subclass.
<greenrd>
I thought I understood...
<Banana>
inheritance and subtyping are 2 different things.
<greenrd>
Yeah, I know.
<pac_>
yep sure
<Banana>
(i'm just pickering i know... but..., call it brain wash by my teachers ^_^).
<greenrd>
It's nonsensical to cast to a super/sub class if it's a copmletely unrelated type right? That's why I say subtype.
<greenrd>
It's old school abbreviation, seems like the young whippersnappers don't know these things any more ;)
<Banana>
Sous-typage des types fonctionnels
<Banana>
greenrd: good'Ol'time when we were irccing with telnet on port 6667.
<ne1>
Let class c1 be declared as having two methods f:int->unit, g:int, and nothing else. Let me also declare class c2 with methods f:int->unit, g:int, h:blah. Note that c2 does not have a clause "inherits c1". I like the fact that in ocaml I can still use an object of c2 in a place where c1 is expected.
<pac_>
Banana: ?
<Banana>
yes ?
<greenrd>
ne1: That's nice in a way. But it's inherently name-based, no, not semantics-based?
<Banana>
ok imagine a function of type t1 -> t2 ok ?
<pac_>
yep
<Banana>
and another one of type s1 -> s2
<ne1>
I used to read newsgroups by telnetting on the nntp port. I sometimes also surfed the web by telnetting to port 80 and typing "GET index.html" :D
<greenrd>
Couple that with no packages and you have a recipe for ... NAMESPACE CONFLICTS! :)
<pac_>
Banana: yep
<ne1>
Java and C++ are name-based. OCaml is signature-based.
<Banana>
if you want them to be subtype : t1 -> t2 < s1 -> s2
<Banana>
then you need t2 < s2 (covariance)
<greenrd>
No, well, Java is based on the explicit extends clauses. Which is safer IMO.
<Banana>
and s1 < t1 (contravariance).
<greenrd>
But maybe the danger is purely theoretical :)
<pac_>
Banana: I dont see the issue in Java...
<greenrd>
My preferred way to handle unanticipated inheritance is aspect-oriented.
<Banana>
pac_: but you did see than the order of the "<" is reversed yes ?
<greenrd>
i.e. you can explicitly say "A extends B" in class C (sometimes called an aspect).
<ne1>
I have personally run into numerous situations where I want to use MyObserver where Observer is needed, and I do not want to subclass Observer because Observer is not really designed to be extended.
<greenrd>
(I studied AOP for a PhD and I think it is heavily overhyped though.)
<greenrd>
(AOP=Aspecct-Oriented Programming)
<greenrd>
ne1: Hmm can't you use a wrapper? :)
<greenrd>
Of course wrappers incur extra storage space compared to efficient inheritance, so they are not always suitable ... but the overhead is typically insignificant to zero.
<ne1>
You mean, every time a language is designed improperly, can't I appeal to its Turing-completeness and write extra code manually to work around it?
<greenrd>
heheh, point taken
Iter has quit [Read error: 110 (Connection timed out)]
<greenrd>
But I would argue that a class that is not designed for inheritance but needs to be inherited from , is the real culprit :)
<ne1>
Such classes cannot be avoided, since no programmer has full access to the future.
<greenrd>
This is true.
<ne1>
Yes actually requiring an explicit "extends" clause is safer.
<greenrd>
Thank you :)
* greenrd
decides to push his luck too far
<greenrd>
And so is eschewing ALL type inference and declaring specific types for every variable, parameter and attribute - as in Java/C++ etc.
<ne1>
The bottomline is to ensure that c2 behaves "like" c1, whatever that means, and not just superficially providing a compatible signature.
<greenrd>
Yup. Exactly.
<greenrd>
In the language I'm developing, not only pre and post conditions but also proofs will be first-class constructs in the language.
<ne1>
Requiring an "extends" clause does not really ensure it, but it does make breaking it harder. It is an interim workaround.
<greenrd>
I want to try and encourage very precise programming.
<ne1>
YES! The solution is exactly THAT!
<greenrd>
I know some of the Haskell people are working in that direction, but I want to do something more like ocaml, something which does not dispense with the assignment operator.
buggs^z has joined #ocaml
<ne1>
c1 and c2 ought to be defined not in terms of method signatures, not in terms of "extends" relations, ... they should be defined in terms of behaviorial specifications, and therefore their compatibility is checkable.
<greenrd>
Yup.
<greenrd>
You have seen the future - and it is my language, or something like it ;-)
smimou has quit ["?"]
buggs has quit [Connection timed out]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<pac_>
eheheee
sundeep has joined #ocaml
buggs^z is now known as buggs
pattern has joined #ocaml
<pac_>
any operator overload in OCAML ?
_fab has quit [Remote closed the connection]
<mattam>
nope, but you can redefine (+) to (+.) if you like
<pac_>
did not get it
<pac_>
anyway time to eat for me
<pac_>
see ya
pac_ is now known as pac_aw
<mattam>
no operator overload, but operator redefinition