Yurik changed the topic of #ocaml to: http://icfpcontest.cse.ogi.edu/ -- OCaml wins | http://www.ocaml.org/ | http://caml.inria.fr/oreilly-book/ | http://icfp2002.cs.brown.edu/ | SWIG now supports OCaml| Early releases of OCamlBDB and OCamlGettext are available
mrvn has quit [Read error: 110 (Connection timed out)]
mattam has quit ["leaving"]
lament has joined #ocaml
malc has joined #ocaml
emu has quit [leguin.freenode.net irc.freenode.net]
mellum has quit [leguin.freenode.net irc.freenode.net]
rox has quit [leguin.freenode.net irc.freenode.net]
emu has joined #ocaml
mellum has joined #ocaml
rox has joined #ocaml
malc has quit [Read error: 110 (Connection timed out)]
uzdav has joined #ocaml
<uzdav> anyone have experience with recursive use of OCamlMakefile? I have a project in the "root" directory that builds to a library, and then a few subdirectories, each an application that links the lib from the parent directory. 2 questions: 1) how do I get a dependency on the lib (so the applications get rebuilt if the lib is rebuilt)? 2) How do I get recursive builds to work? (passing the options like native-code, etc)? Thanks!
jemfinch has joined #ocaml
det has joined #ocaml
<det> Is it possible to acheive overloaded functions in ocaml (in seperately compiled modules) doing something like this:
<det> module type Showable =
<det> sig
<det> type t
<det> val show: t -> string
<det> end
<det> ;;
<det> module Showable: Showable with type t = int =
<det> struct
<det> type t = int
<det> let show x = string_of_int x
<det> end
<det> ;;
<det> ?
<det> sorry if I pasted too much but it seems like this channel is fairly idle most of the time :)
<mrvn_> seems to work. wheres the problem?
<mrvn_> module type Showable = sig type t val show : t -> string end
<mrvn_> module Showable : sig type t = int val show : t -> string end
<mrvn_> module Showable2 : sig type t = float val show : t -> string end
<mrvn_> Is that what you want?
<det> I mean, is this a common method of acheiving overloaded functions ?
<mrvn_> I only know overloading in classes.
<mellum> Overloading functions would conflict with the type inference, meseems
<det> oh, argh, you cant define multiple Showable modules with type t being different :/
<det> I am looking for the equivalent of overloading like haskell's type classes
<mrvn_> you can only overload with the same type but types can be polymorphic.
<whee> you might want to look into polymorphic variants
<whee> although that'd still be different than type classes
<det> they they provide similar functionality ?
<det> how can you overload using classes ?
<mellum> Hee hee. Only on functional programming language channels, people answer your questions with links to papers.
<Smerdyakov> Also in #teenchat
<mellum> Smerdyakov: really, haven't been there for a while
Psion has joined #ocaml
Smerdyakov has quit [Killed (NickServ (Nickname Enforcement))]
Psion is now known as Smerdyakov
<det> is iin ocaml, is it possible to define a class Showable and then make two classes Integer and Float which inherit from Eq implementing it's show method ?
<det> s/is i//
<det> s/Eq/Showable/
<mrvn_> det: class virtual showable = object method virtual show : unit end;;
<mrvn_> class int_showable i = object inherit showable method show = print_int i end;;
<mrvn_> class float_showable f = object inherit showable method show = print_float f end;;
<mrvn_> let l = [new int_showable 1; new float_showable 2.];;
<mrvn_> # List.iter (fun x -> x#show; print_newline ()) l;;
<mrvn_> 1
<mrvn_> 2.
<mrvn_> - : unit = ()
<det> can int_showable instead be just Integer and inherit from multiple classes (implementing their interfaces) ?
<mrvn_> det: sure
<det> ok, that is what I want
<det> thanks
<det> mrvn_, so then if I want a function to take anything that implements the Showable interface, how would I do thatr ?
<mrvn_> det: you just do.
<mrvn_> det: Sometimes you have to cast the arguments upon useage though.
<mrvn_> foo (a:>showable)
<det> how would I define a function that takes two instances of Showable and concatonates their strings ?
docelic is now known as docelic|sleepo
<mrvn_> det: fun x y -> String.concat "" [x#to_string; y#to_string]
<det> what kind of overhead is there on that dispatch ?
<mrvn_> a virtual table lookup.
<det> any idea what that table would look like? :-p
<det> for a function that only dispatched on to_string
<mrvn_> its a array of function pointers
<det> ok
<mrvn_> so you probably have 2 pointer lookups, first for the table and then for the right function.
<det> that's acceptable
<det> but ..
<Smerdyakov> Same as Haskell type classes, no doubt.
<mrvn_> Its the minimum you can do for virtual functions.
<det> how does the function know where in the vtable to_string is located ?
<mrvn_> except if you store the virtual table in each instance.
<jemfinch> Smerdyakov: Haskell typeclasses are actually implemented difference.
<jemfinch> there's a hidden dictionary mapping types to instance methods that's passed to every function taking a typeclass.
<Smerdyakov> jemfinch, well, I don't think that's part of the definition of Haskell....
<det> does a paticular function always expect a vtable specific to the functions it requires ?
<jemfinch> Smerdyakov: no, but that's how it's implemented.
<mrvn_> What I miss in ocaml is that you can't finalize a function in a class.
<Smerdyakov> jemfinch, you mean in every Haskell compiler today?
<mrvn_> With finalized methods or non virtual methods you wouldn't need to lookup the virtual table.
<jemfinch> Smerdyakov: I mean in GHC. I don't know how it's implemented other than in GHC.
<jemfinch> but GHC is really I think the only industrial strength Haskell compiler available.
<Smerdyakov> jemfinch, I don't see what use a dictionary defined on types is unless you keep around runtime type tags...
<jemfinch> Smerdyakov: I'm just saying, you can ask in #haskell if you don't believe me, but that's how I've heard it was implemented :)
<Smerdyakov> I'd think you just pass a table of instance methods along with every type classed parameter....
<det> what do you mean by dictionary ?
<Smerdyakov> Finite mapping [guess]
<mrvn_> n8
<det> how is it different from a table ?
<Smerdyakov> Possibly implemented in a more efficient way, with respect to some operations
<Smerdyakov> Such as a balanced search tree
<det> if you know the offset of the items to be retreived, then a table is as fast as it gets
<Smerdyakov> Yup, but if the mapping isn't known at compile time, then things get more complicated =)
<det> but in haskell they are known at compile time
<det> right ?
<Smerdyakov> We're talking about an ADT here.
<Smerdyakov> Not a particular use of it
<Smerdyakov> Or at least, _I_ am =D
<det> mrvn_, if you dont even need to specify that you are taking an instance of Showable, what is the purpose of inheriting from it ?
<mrvn_> det: type inference
<mrvn_> It detects by itself that the function needs a showable
<det> can multiple classes define the same method with inheriting from a common class ?
<mrvn_> det: look at the example.
<mrvn_> det: or read the manual, I'm falling asleep here. *wave*
<det> I get type errors with you example
<det> Is there matbe such thing as a polymorphic class ?
<mrvn_> works fine here and yes.
<det>
<det> This expression has type string but is here used with type unit
<det> oh, I changed it, I see
<mrvn_> clclass ['a] foo f = object method bla = (f:'a) end;;
<mrvn_> class ['a] foo : 'a -> object method bla : 'a end
<mrvn_> -cl
<mrvn_> # let i = new foo 1;;
<mrvn_> val i : int foo = <obj>
<mrvn_> so, gone for tonight now.
<det> this isnt as cool as type classes, but still cool :)
walters has joined #ocaml
<walters> is there any way i can push a character back onto an input_channel?
skylan has quit [Read error: 60 (Operation timed out)]
skylan has joined #ocaml
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
<det> Is it possible to pass around modules as first class objects ?
<jemfinch> no, it's not.
det has quit ["Hey! Where'd my controlling terminal go?"]
mattam has joined #ocaml
<walters> anyone have good examples of using Map?
<jemfinch> what do you need?
<jemfinch> you mean the functor, right?
<jemfinch> let me tarball up my O'Caml directory and you can have access to all my O'Caml code. I'll point you to a good place to see Map, iirc :)
<walters> yeah
<walters> cool
<jemfinch> can you accept DCC SEND?
<walters> ah...i am not sure
<walters> try i guess
<walters> jemfinch: wow, slow :)
<jemfinch> walters: I'm on a 31k homenet :)
* jemfinch is too poor for broadband at the moment.
<walters> ah
<walters> jemfinch: ok, cool, looks like there's some useful examples in there
<walters> jemfinch: thanks
<jemfinch> walters: no problem.
<jemfinch> let me find you a Map example...
<jemfinch> go look at ocaml/libsrc/async/async.ml
<jemfinch> I make a Map there of sockets to handlers.
<walters> jemfinch: got it
<walters> holy shit
<walters> i just wrote about 400 lines of code and i only got about 3 type inference clashes
<walters> after fixing those it compiled.
<walters> i love that.
<jemfinch> yeah, it's pretty cool :)
<jemfinch> that was one of my favorite things about writing IRC bots in O'Caml.
<jemfinch> if the code compiled, it'd work, and I wouldn't have many runtime crashes.
<jemfinch> pychecker alleviates a lot of the crashes I'd get in my Python IRC bot otherwise, and gets me almost the same king of uptime.
<walters> 755LISP> FOO
<walters> Unbound variable FOO
<walters> Your lisp code sucks! (evaluation error)
<walters> sweet
<walters> getting closer...
<walters> ok, 3am, time to sleep
<walters> thanks again jemfinch
walters has quit ["z"]
jemfinch has quit ["Client Exiting"]
jemfinch` has joined #ocaml
jemfinch` has quit ["Client Exiting"]
jemfinch`` has joined #ocaml
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
gene9 has joined #ocaml
gene9 has quit [Client Quit]
mellum has quit [Read error: 60 (Operation timed out)]
mellum has joined #ocaml
esabb has joined #ocaml
uzdav has quit ["[x]chat"]
docelic|sleepo is now known as docelic|away
jemfinch`` has quit [Read error: 54 (Connection reset by peer)]
jemfinch`` has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
jemfinch`` has quit [Read error: 110 (Connection timed out)]
Segora has quit [Remote closed the connection]
det has joined #ocaml
Dalroth has joined #ocaml
det has quit ["Hey! Where'd my controlling terminal go?"]
esabb has quit ["Client Exiting"]
systems has joined #ocaml
systems has left #ocaml []
systems has joined #ocaml
systems has quit [Read error: 60 (Operation timed out)]
mattam_ has quit [Read error: 60 (Operation timed out)]
mattam has joined #ocaml
matkor has joined #ocaml
lament has joined #ocaml
Dalroth has quit []
mattam has quit ["'on touche pas au noyau! si!'"]
mattam has joined #ocaml
mrvn has joined #ocaml
mattam has quit ["zZz"]