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
mattam has quit ["zZz"]
hitachi is now known as sutabi
hitachi has joined #ocaml
hitachi has quit [Client Quit]
sutabi is now known as hitachi
lus|wazze has quit ["*liephab* <3 <3 <3"]
lament has quit [Remote closed the connection]
Kinners has joined #ocaml
reltuk has quit []
mattam has joined #ocaml
vegai_ has joined #ocaml
smklsmkl has joined #ocaml
Smerdyakov has quit [sterling.freenode.net irc.freenode.net]
vegai has quit [sterling.freenode.net irc.freenode.net]
seth_ has quit [sterling.freenode.net irc.freenode.net]
lam has quit [sterling.freenode.net irc.freenode.net]
smkl has quit [sterling.freenode.net irc.freenode.net]
hitachi has quit [Remote closed the connection]
lam has joined #ocaml
Kinners has left #ocaml []
Smerdyakov has joined #ocaml
seth_ has joined #ocaml
Smerdyakov has quit [sterling.freenode.net irc.freenode.net]
seth_ has quit [sterling.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
seth_ has joined #ocaml
lament has joined #ocaml
Smerdyakov has quit [sterling.freenode.net irc.freenode.net]
seth_ has quit [sterling.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
seth_ has joined #ocaml
smklsmkl is now known as smkl
Smerdyakov has quit [sterling.freenode.net irc.freenode.net]
seth_ has quit [sterling.freenode.net irc.freenode.net]
seth_ has joined #ocaml
lament has quit ["Support Darwin Awards! Join the military!"]
Smerdyakov has joined #ocaml
Vincenz has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
two-face has joined #ocaml
baader has quit ["I'll be back"]
lus|wazze has joined #ocaml
two-face has quit ["Client exiting"]
hitachi has joined #ocaml
Smerdyakov has quit ["reboot"]
Smerdyakov has joined #ocaml
marty has joined #ocaml
docelic|away is now known as docelic
lament has joined #ocaml
systems has joined #ocaml
systems has quit ["Client Exiting"]
asqui has left #ocaml []
TachYon has joined #ocaml
hitachi has quit ["Client exiting"]
hitachi has joined #ocaml
exa has joined #ocaml
<exa> hi
<exa> anybody knows if there's something like Haskell read/show ?
<exa> what's up yo, discriminated hackers? :)
hitachi has quit [Remote closed the connection]
hitachi has joined #ocaml
hitachi has quit [Client Quit]
<lus|wazze> @exa: nope there isn't
<lus|wazze> caml's type system doesn't allow something like this
<lus|wazze> because there is nothing like haskell's classes
<lus|wazze> in caml
<exa> why not?
<exa> I would think I could write a couple of functions to, say, print out 'a list
<exa> Won't that be good enough?
<lus|wazze> how would you do that?
<lus|wazze> when you don't know what 'a is
<exa> ah, i see your point
<exa> of course i'm taking the haskell class system for granted :)
<exa> doesn't work too well obviously
<exa> I wonder if it would be possible to use modules to that end
<exa> Hmmm
<lus|wazze> not really
<lus|wazze> you can only do the same thing with modules that you can do with function, but on a larger scale: parameterize code over an anonymous type
<exa> but it would be impractical?
<lus|wazze> ?
exa is now known as brain
<lus|wazze> it would be impossible?
<lus|wazze> what you want to do is write a function show : 'a -> string
<lus|wazze> i don't see how modules are going to help you there
<lus|wazze> you can of course write a module type
<lus|wazze> like
<lus|wazze> module type Showable = struct type t val show : t -> string end;;
brain is now known as exa
<exa> lus|wazze: but i thought it wouldn't be worth the hassle to write that. Correct/
<exa> ?
<lus|wazze> well depends
<lus|wazze> you wouldnt really gain anything as far as i can see
<lus|wazze> a module type with only one function
<lus|wazze> you could simply instead of, whenever you want to use this, put it into a module parameterized over a module of this above type
<lus|wazze> simply pass the show function directly to those functions which use it
<lus|wazze> ie instead of
<lus|wazze> module UsingShow (Show : Showable) = struct ... end;;
<lus|wazze> do
<lus|wazze> let this_fun_uses_show ?(show = fun _ -> "") ... = ...;;
hitachi has joined #ocaml
Kinners has joined #ocaml
two-face has joined #ocaml
<exa> I didn't quite understand
<exa> was ? optonal
<exa> optional arg?
<lus|wazze> yep
<exa> passing it around as an argument doesn't seem like a very good idea
<exa> i could do this stuff easily in C++
<lus|wazze> well there is no overloading in ocaml
<lus|wazze> but if you want to put it into classes you could easily do that, as well
<lus|wazze> class type showable = object method show : string end;;
<exa> it's a little frustrating
<exa> looks very natural you know
<lus|wazze> i don't really understand what you'd need it for?
<exa> i'm developing some data structs and i wanna debug them, for instance
<exa> i know the interpreter can "show" values, so i wanna do the same!
<lus|wazze> I'm well aware of quite a few shortcomings in ocaml, but lack of a general-purpose to_string function is not really one of them
<lus|wazze> hmm
<lus|wazze> for print debugging, eh?
<exa> yes, for instance
<lus|wazze> why don't you simply call your function from the toplevel to see whether or not it works?
<lus|wazze> well besides print-debugging what other use would there be?
<lus|wazze> i mean
<exa> what do you think would be?
<lus|wazze> as long as every type has an associated foo_to_string functiopn
<exa> I can easily write down the data structures in a text file in haskell
<lus|wazze> there is the marshalling module in ocaml
<exa> and use them as input or transfer between codes
<exa> no that doesn't do the trick
<exa> i can't edit them with hand
<lus|wazze> but really i would do this with my own system
<lus|wazze> then use lisp :)
<lus|wazze> nothing beats lisp in THAT regard
<exa> if you've used haskell you'd know what i mean
<exa> yea maybe
<exa> but the read/show functions are very useful things
<lus|wazze> if you want a readable text representation for every datatype
<lus|wazze> well
<lus|wazze> for what YOU want to do you wouldn't really need to have it for EVERY type
<lus|wazze> for a subset of types which are all defined by YOU it is easy to do
<lus|wazze> use ocaml's oop system
<lus|wazze> like i wrote above
<lus|wazze> make your types classes
<lus|wazze> class type showable = object method show : string end;;
<exa> there's a lot of impedence mismatch there I didn't quite like it :)
<lus|wazze> ?
<exa> the trouble is that there should be one standard way of doing it, so far x_to_string funcions for every module and datatype
<exa> which is not a good solution
<lus|wazze> why not?
<exa> because you want it to work for composite types!
<exa> like 'a list as I said
<exa> that's why show/read is useful
<lus|wazze> of course its useful
<lus|wazze> but you should stop thinking in haskell when you want to write ocaml code
<lus|wazze> different programming languages work differently
<exa> no, what i say is if it weren't for composite types, it would have no meaning
<lus|wazze> personally, I don't even like if the programming language proscribes what an external representation for types has to look like
<lus|wazze> i like to implement my own system
<lus|wazze> like i said above
<lus|wazze> use
<smkl> for lists, you have "list_to_string elem_to_string" ...
<exa> ah, good then
<exa> i didn't notice!
<exa> so there is in fact something
<exa> but i feel it should be more generic
<lus|wazze> which is exactly one of the possible solutions I posted above:
<lus|wazze> let this_fun_uses_show ?(show = fun _ -> "") ... = ...;;
<lus|wazze> ?
<lus|wazze> how could it be more generic?
<lus|wazze> except, of course, with a show function - which is not possible with ml's type system...
<exa> by some way to abstract over types like show does, I don't know. it doesn't have to be type classes
<exa> maybe even the module approach, but i can't construct in my head how to do it well enough
<exa> so it could be usable
<lus|wazze> or you could stop thinking in haskell when writing ocaml programs
<exa> actually i don't think in any particular language when i write programs :)
<Kinners> are there some camlp4 macros or something that generate printers for your declared types?
<exa> it looks a little absurd to me that you've got a pretty printing lib and marshalling in the stdlib but no ascii-printing/parsing lib
<lus|wazze> well you seem to be PRETTY caught up in that haskell "I can simply convert any datatype without knowing what it is into a string as long as it is a member of the showable class" mindset
<lus|wazze> why?
<exa> because marshalling is harder than doing that
<exa> marshalling wants language support, right/
<exa> ?
<smkl> exa: ocaml has very simple marshalling
<exa> yea show/read in haskell isn't super-duper either :)
<smkl> it just about dumps the binary values
Kinners has quit [Read error: 54 (Connection reset by peer)]
Kinners has joined #ocaml
<exa> yea, but it handles a few things, too....
<exa> it's evidently simpler than ascii stuff
<exa> haskell people couldn't yet come up with a working marshalling lib :)
<exa> i can from experience say that general purpose marshalling is harder
<exa> anyway, i think my point is clear :)
<exa> ascii representation is something that all programmers might think of messing with
<smkl> one way that i use is to have function "show" and then structures for different data types, then you can use stuff like "show (list (list string))" ... it's quite easy to add new functions like "read", and it can be generalized to handle records and sums too
<exa> Kinners: Obviously something that could be done using p4, both simple parser (read) and printer (show)
<exa> smkl: definitely, it's a blessing :)
<exa> smkl: and it simplifies writing test programs :)
<vegai_> perhaps what you really want is unit tests?
<exa> no i have 'em thanks :)
<exa> i just write a test code for each module
<exa> smkl: you think the right way to do it is with p4?
<exa> hmmm
<exa> p4 is so good
rox is now known as rox|rauslaufen
<smkl> exa: perhaps ... i'm currently doing it mostly by hand, see http://kokatrix.sourceforge.net/guilib-0.1.tar.gz ... i just have macros for simplifying record/sum stuff
<exa> macros?
<smkl> err, quotations
<exa> hm p4 stuff
<exa> it's profitable to think about problems like this, thank you
<exa> i want to write a lot of ocaml code eventually so i'd better know
<exa> i've started a really neat directed graph code. maybe if I make it look like the libs they can include in the stdlib?
<smkl> dunno. probably not. stdlib is supposed to be very small ie. it just has stuff that is needed in the compiler
<exa> that's surely not the definition of stdlib :)
<exa> I mean all main libs
two-face has quit [Read error: 110 (Connection timed out)]
<exa> where is list_to_string declared?
<smkl> this is always discussed on the mailing list but i haven't checked what is the current situation
<smkl> let list_to_string el lst = "[" ^ String.concat ";" (List.map el lst) ^ "]"
<exa> thx
<exa> with this the print function will look terrible
<exa> to_string vtx edge g
<exa> hm
<marty> i am writting a ocaml server that listens on a port, but if i shut it down and start it up right after i get an error like this:"Fatal error: exception Unix.Unix_error(50, "bind", "")", and if i wait and try again it'll work. is their some way i can get around this? i've tried to make some code in a signal handler that closes the socket down cleanly but it doesn't work because the socket is blocked on an accept.
<Smerdyakov> This is a problem with sockets in any language you use
<Smerdyakov> I think you could say it's a "problem" with TCP/IP, based on how long you have to wait to "really know" a socket is closed.
<marty> yeah, but other applications, like apache don't have this problem
<Smerdyakov> I think some flag called REUSEADDR might help.
<Smerdyakov> I don't remember if it does.
<marty> hmm, i'll try that. i remember seeing something like that in the documentation
<marty> Smerdyakov: you're a genius, that did the trick
<marty> :-)
systems has joined #ocaml
TachYon has quit [Read error: 110 (Connection timed out)]
systems has quit ["Client Exiting"]
marty has quit [Read error: 110 (Connection timed out)]
rox|rauslaufen is now known as rox
lament has quit ["Support Darwin Awards! Join the military!"]
exa has quit [Remote closed the connection]
asqui has joined #ocaml
Kinners has quit [Read error: 104 (Connection reset by peer)]