dark_light changed the topic of #ocaml to: OCaml 3.09.2 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/
<pango> 2am... n8!
<Payo543> what?
Mr_Awesome has joined #ocaml
postalchris has quit ["Leaving."]
buluca has quit ["Leaving."]
chessguy has joined #ocaml
<Kzzch> Payo, I felt the same way when I tried to use the ocamlode library
<Kzzch> I couldn't even get it to compile
<Kzzch> I'm thinking that rather than rewrite the bindings I'll just write a native dynamics library
<Kzzch> Give it the same API as ODE maybe
buluca has joined #ocaml
KzzchX has joined #ocaml
<Payo543> Kzzch, you still there?
<KzzchX> I'm back
<KzzchX> Yes Payo I'm here, I lost my connection
chessguy has quit [Connection timed out]
<KzzchX> Are *you* still here?
Kzzch has quit [Read error: 110 (Connection timed out)]
<KzzchX> /nick Kzzch
KzzchX is now known as Kzzch
<Kzzch> ...
<Payo543> lol
<Payo543> yea sorry about that
<Payo543> Kzzch, are you any experinced with writing c libs in ocaml ?
<Payo543> im wating to like update / make a few libs myself
<Kzzch> Nope
<Payo543> casue a GD library would be Great :)
<Payo543> and that GD4O is like 2003 not evne finished crap
<Kzzch> I've taken a look at a few bindings
<Payo543> hmmmmmmmm
<Payo543> Kzzch, ocaml really needs a community grrrrrr ......
<Payo543> it would be up there with c and c++ if it did
<Kzzch> I dunno about that, people stick with what they're familiar with for the most part
<Kzzch> I'm still pretty new to the language myself
<Payo543> Kzzch, heh but communtiy also brings popularity
<Payo543> me too but i have a some what tight grasp on it
duncanm has quit [Read error: 110 (Connection timed out)]
duncanm has joined #ocaml
<Kzzch> have you read that? it may help you.
descender has quit [Remote closed the connection]
chessguy has joined #ocaml
<Payo543> is the only way to include a file #use ?
buluca has quit [Read error: 104 (Connection reset by peer)]
<Kzzch> I think that's if your in the interactive toplevel
<Kzzch> otherwise you use open
<Kzzch> If I remember correctly anyhow
<Payo543> Kzzch, what do you mean ?
<Kzzch> If you're writing an .ml file you use open I think.
<Kzzch> like open Graphics;;
<Kzzch> -like
<Kzzch> Yeah, that's right
<Kzzch> if you started ocaml from the command line you'd use #use
pango_ has joined #ocaml
<Payo543> Kzzch, do you know what the graphics library offers off hand ?
<Kzzch> I think simple primitive drawing functions
<Kzzch> like circles and such
pango has quit [Remote closed the connection]
<Payo543> Kzzch, could i make a cool graph with it you think ?
<levi_home> Is it possible to register callbacks from C/C++ that take C pointers or C++ references as arguments?
duncanm has quit [Read error: 110 (Connection timed out)]
<Payo543> also what is a .mli file ?>
<levi_home> .mli is an interface file, which defines the interface to the module defined in the corresponding .ml file.
<Kzzch> It looks like you might be able to make a graph with it Payo, and the .mli is the interface to the .ml file
<abez> levi_home: yah it is in the manual
<Kzzch> type #load "graphics.cma";; into your interactive window, then type: module MyGraphics = Graphics;; and it will show you all the commands in the Graphics module
<Payo543> Kzzch, what do you mean .mli is inerface to .ml ?
<Payo543> i also dont see much of a point to that graphics library
* Kzzch shrugs
<Kzzch> I didn't write it :P
<Payo543> hmmmmmmm
<Payo543> it does have some good functions thouggggh
<dark_light> Payo543, .mli lists all functions that are visible to external modules, and it's signatures
<levi_home> So, in my C function I need to create zero-tagged blocks of length 1, use Val_int to store ints in them, and pass them to my registered caml callback?
<Payo543> dark_light, i still dont get it :P
<Payo543> why does a library contain one
<dark_light> Payo543, well :P you know that if i have a file nice.ml, and wow.ml, i can call Nice.slugh in wow.ml and then it will call the slugh function in nice.ml, right?
<dark_light> but nice.ml needs a .mli that says the slugh function exists in nice.ml
<levi_home> Payo543: A module defines a bunch of functions and types and such, only some of which might need to be exported to the world. The interface lists the types, functions, etc that you want to export.
<levi_home> If you don't supply a .mli, the compiler assumes you're exporting everything.
<Payo543> dark_light, cant you do that without a .mli ?
<dark_light> Payo543, i don't know
<Payo543> o boy its late but i still dont see a point to a .mli :)
<levi_home> No, there has to be an interface. The compiler will create one that exports everything if you don't explicitly write one in a .mli.
<levi_home> Payo543: Have you heard of encapsulation? Data hiding?
<dark_light> Payo543, it's easy: simply load the module using #use on the toplevel and copy the signatures that appears to a mli file, so you mli has exactly all things that the .ml have (if you want to)
<levi_home> Does anyone know if I'm on the right track with my ffi code?
<dark_light> ffi?
<levi_home> foreign function interface
<Payo543> so a .mli is just telling the compileing what is being used in other files ?
<dark_light> levi_home, i didn't see the code
<levi_home> Payo543: A .mli lets the compiler know what functions and types are exported by a module.
<dark_light> Payo543, yes. it's like the .h in C, but it's not included in files that use the .mli
<levi_home> Payo543: Kind of like, in something like C++, your .h file tells the compiler what class members are public.
<Payo543> so if i want to use functions in other stuffi need a mli file right ?
ggyy has joined #ocaml
<levi_home> dark_light: My goal is to register a callback that can modify its arguments, so I can return multiple values to C. I figured I could use refs, which are really single-element records. A record seems to be a 0-tagged block of length 1. So, can I pass 0-tagged blocks of length 1 to my callback, initially filled with Val_int() values?
<levi_home> Er, return multiple values from C.
<levi_home> Payo543: No, you don't have to create one explicitly unless you want to hide some of the functions you've created. It's good programming practice, but not necessary.
<Payo543> why would you want to hide ?
<Payo543> any performance difference or same ?
<levi_home> Payo543: If you don't create a .mli, when you use the module created by your .ml, the compiler assumes the interface includes everything.
<levi_home> It's not a matter of performance, but a matter of defining an interface to an abstract data type.
<levi_home> Payo543: Are you familiar with abstract data types or C++ or Java-style object oriented programming?
<Payo543> would it make the program bigger?
<Payo543> levi_home, no just C - D - lUA - perl php and osme other variout scritping langs
<levi_home> Have you taken any classes on programming?
<Payo543> nope nope
<levi_home> Ahh, okay.
<Payo543> done quite a bit but just various stufff
<Payo543> i dont know ocaml all to well but i do have a big chunk of a jabber client built + a jabber library i made
<dark_light> levi_home, :o :o i have no idea at all
<levi_home> Well, exposing an interface that hides implementation details is done for the purpose of cleanly separating parts of a program.
<Payo543> but is there any reasons i n doing it except for clean ?
<Payo543> size / speed / performance ?
<levi_home> By publishing an interface, you force clients to only rely on that interface. That allows you to change the implementation details without worrying about whether clients of your module will break.
<Payo543> hmmm
<levi_home> There is a lot more to programming than size, speed, and performance.
<Payo543> i know :D
<levi_home> First of all, there is correctness.
<Payo543> well i will worry about /.mli file last
<levi_home> Having well-defined interfaces helps to keep your programs correct.
<Payo543> i seee
<levi_home> It also helps to keep your modules reusable.
<levi_home> And keeps your code well-organized, so you can understand how it works better.
david_koontz has joined #ocaml
<levi_home> I'm going to poke around with my C interface stuff now, so I will be idle.
<Payo543> man
<Payo543> it looks so complicated to make a ocaml binding for a C library
ggyy has quit [Connection timed out]
<abez> ? Ever worked with XS and perl?
<abez> Ocaml is pretty clean cut
<abez> take params in
<abez> convert their values
<abez> do your c calls
<abez> convert return type to ocaml types and return
<ayrnieu> well, it helps to have a GC.
<Payo543> GC?
<Payo543> garbage collector ?
<ayrnieu> yes.
<Payo543> well for GD i need about 10 functions or so to build my graph .......would it be possible to just make those 10 functions should i say bind with ocaml or would i have to do the whole library or many more parts?
<ayrnieu> your question doesn't make any sense, sorry.
<Payo543> ayrnieu, yes i know
<Payo543> grrrrrrrrr
<ayrnieu> ... oh, you want to know if you can create bindings for a subset of functions in a C library? Of course you can!
<Payo543> well i just what to write for what i need
<Payo543> GD has a huge boat load of stuff
<ayrnieu> the only pressure: if you decide to release the bindings separately, you'll want to focus on making the entire library useful, and not just on supporting what you've needed to do.
<ayrnieu> also, I believe that swig can generate ocaml bindings. You might look into this.
<Payo543> ayrnieu, well in 3 or 4 days when i have this all sorted out i am going to buy a domain setup a ocaml library directory with a SVN for each and transfer as ,many known projects as i can find over
<Payo543> if theres a svn it might make it easier for people to work on it
<ayrnieu> aye.
<Payo543> thats something i see that ocaml needs
<Payo543> half the links on those library pages on ocaml hump dont even work
<ayrnieu> well, a nice repository has failed impressively help other languages, and other languages have been impressively helped by repositories simpnot backed by a VCS. I think the real requirement is persistence.
<Payo543> ayrnieu, well the problem is people making repositories of 1995
<Payo543> and when i see something that looks like it was done in 30 mins
<Payo543> i get iffy about using it
<levi_home> OCaml's C interface is pretty nice. My callback worked just as I expected it to.
Smerdyakov has quit ["Leaving"]
<abez> I must say, ubuntu made ocaml awesome for me.
<abez> libraries were very easy to install and very available
<Payo543> levi_home, ocaml C interface?
<dark_light> abez, me too
duncanm has joined #ocaml
Mr_Awesome has quit ["...and the Awesome level drops"]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- IRC for those that like to be different"]
<levi_home> I'm using OCaml on OS X and Windows, primarily. Works really well in both places.
<abez> does unix work on windows?
<abez> Unix
<levi_home> Do you mean the unix module, or what?
<levi_home> I haven't tried the Unix module.
<abez> I mean the Unix module
<Payo543> abez, yes alot does .............theres a page somewhere that shows what works where ..... select works i know that
duncanm has quit [Read error: 110 (Connection timed out)]
<Payo543> also when should i sleep an app ? and should i even worry about that ?
<Payo543> is sleeping needed ? for a jabber client ?
Wild_Cat has joined #ocaml
Snark has joined #ocaml
<abez> Payo543: just block on i/o or let your select do it
<Payo543> abez, Glib is doing the polling
david_koontz has quit ["This computer has gone to sleep"]
Wild_Cat has quit []
bluestorm has joined #ocaml
ggyy has joined #ocaml
_velco has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
Carillon has joined #ocaml
slipstream has joined #ocaml
bluestorm has quit ["Konversation terminated!"]
shans_home has joined #ocaml
<shans_home> can anyone help me with pcaml?
<shans_home> sorry, camlp4?
slipstream-- has quit [Read error: 110 (Connection timed out)]
pango_ has quit [Read error: 104 (Connection reset by peer)]
two-face has joined #ocaml
<two-face> Hi
pango has joined #ocaml
love-pingoo has joined #ocaml
triple_ has joined #ocaml
_fab has joined #ocaml
<two-face> What's the benefit of using records over variants?
shawn has joined #ocaml
<pango> how can you compare the two ? They're totally different things
<two-face> not so different
<pango> how would you do the job of a record using a variant then ?
<two-face> variants add a level which is equivalent to unions in C
<flux__> payo543, I've written a few simple bindings
<flux__> payo543, and it wasn't very difficult
Skal has joined #ocaml
<pango> two-face: well, sortof,... But does that answer the question ?
<two-face> pango: no it doesn't
<two-face> but anyway
ggyy has quit [Read error: 104 (Connection reset by peer)]
<two-face> pango: it looks great, thank you
velco has joined #ocaml
dark_light has quit ["Ex-Chat"]
shawn has quit ["Leaving"]
buluca has joined #ocaml
<flux__> hmm.. I wrote this: http://modeemi.fi/~flux/typetest.ml
<flux__> everything but 'destruction' works
<flux__> I wonder if there exists a fix for it..
<flux__> the idea is that you could write something like map_func (int_of_string <<- id <<- int_of_float) (42 << " and " << 42.42) and produce a string
<flux__> (actually it would really construct sql-queries and not probably quite like that)
<flux__> des is the map_func in the code fragment
<flux__> oh, I forgot the lists need to be terminated somehow, maybe like <<- eofl and << eol
<flux__> the value construction works great, but deconstruction doesn't :-)
Carillon_ has joined #ocaml
<flux__> (updated file)
<flux__> (still doesn't work)
<flux__> error produced: File "typetest.ml", line 9, characters 55-61: This expression has type 'a but is here used with type ('b -> string, 'a) t
<flux__> I'm not sure if that would be useful, but atleast fun :)
<flux__> crap, I broke it
<flux__> updated ;)
Carillon has quit [Read error: 60 (Operation timed out)]
<pango> I suspect you'll run into recursive polymorphism problems
<flux__> well.. I'm running into some troubles, for sure ;)_
<pango> for one, I think there's a problem of associativity with <<
_fab has quit []
<flux__> yes
<flux__> I fixed that
<flux__> (it was that when I said 'crap, I broke it' :-))
ikaros has quit [Read error: 60 (Operation timed out)]
ikaros has joined #ocaml
<flux__> annoying how easy it is to construct that, but so difficult (impossible?) to deconstruct
buluca has quit [Remote closed the connection]
<pango> the problem comes from the fact that, in recursive functions, the type system infers that the type of the whole function and its occurences in its definition are the same
<flux__> hm, yes
<shans_home> do you need to use special quotations for generating classes in camlp4? Or should <:str_item< ... >> work?
<flux__> I wonder if there's a way around that
<pango> (otherwise it would sometimes need infinite type definitions, that are not supported)
<flux__> sometimes, but not for that program :)
<flux__> hmm.. I wonder if the object system offers a loophole..
<flux__> I also had the map_v defined wrong
<flux__> atleast there are some more lax restrictions in object types
<pango> really ? that was not my impression (no polymorphic methods, etc...)
<flux__> surely there are polymorphic methods
<flux__> (object method a b = b end)#a 42;;
<pango> I can't argue anything about OCaml's OO however, I've stayed away from it for now
<ikaros> hi
<ikaros> do you know if theres a chm file for official ocaml docs? or something similar
<pango> for full text searches I bet ?
<ikaros> ye
<pango> there's a PDF version of the user manual... if that's what you mean by "official docs"
<ikaros> yes i know that.. i have that one. hmm i was searching for a chm file cause it has way better searching options than a plain pdf file.. and it has links like html
<pango> pdfs can have links too
<ikaros> ok but i think this didnt
<pango> correct, just checked
<ikaros> i found something in google: "docchm" .. it was at the hump too but it seems the project is gone..
<ikaros> sadly there is no such link as mentioned ;)
falconair has quit [Read error: 104 (Connection reset by peer)]
falconair has joined #ocaml
falconair has quit [Read error: 54 (Connection reset by peer)]
falconair has joined #ocaml
falconair_ has joined #ocaml
falconair_ has quit [Read error: 104 (Connection reset by peer)]
duncanm has joined #ocaml
<pango> yes... 3 years later, it's nowhere to be found
falconair has quit [Read error: 104 (Connection reset by peer)]
falconair_ has joined #ocaml
falconair has joined #ocaml
falconair_ has quit [Read error: 104 (Connection reset by peer)]
<pango> even the web archive missed http://tech.motion-twin.com/?&node=40
falconair has quit [Read error: 104 (Connection reset by peer)]
falconair_ has joined #ocaml
falconair_ has quit [Connection reset by peer]
falconair has joined #ocaml
<setog3> I want the laste element of a list, and I want to use fold_right to do this
<setog3> I do this with : let dernier_liste liste = fold_right (fun l a-> match a with []->[] |x::[]->[x] |x::t->t) liste liste ;;
<setog3> but it's not the good way..
<setog3> do you have a best method ?
<datrus> how come a statement like: let b=1 in let a=2;; doesn't work?
<flux__> what should it do?
<datrus> set a gobal variable 'a' to 2
<datrus> like let a=2;;
<flux__> let .. in starts a new scope
<flux__> you can't define anything global under it
<flux__> so if that were legal, it would mean let b = 1 in let a=2 in (* this expression, which is empty, and after which a is not anymore defined *);;
<flux__> you can write let b = 1 let a = 2
<datrus> ok, in that case both are global
<flux__> yes
<flux__> if you want to define a based on b, but not make b global, you write let a = let b = 42 in b + 5;;
<datrus> ah ok, that's what i want
<abez> datrus: let a = let b = 1 in 2 ;;
<abez> datrus: read it out loud and think about math when you do it. (it helped me)
<ikaros> is there a way to force the ocaml interpreter to print the whole array no matter how big it is? it always cuts off after some lines with: ..|] ..|]
Smerdyakov has joined #ocaml
Aradorn has joined #ocaml
two-face has quit ["KVIrc 3.2.4 Anomalies http://www.kvirc.net/"]
<ikaros> nobody knows? =/
<flux__> I don't think there is
<flux__> you could look at the source
<ikaros> problem is
<flux__> or you could try the dumping library at caml humps
<flux__> or patch ocaml
<ikaros> i wrote a lil program to create the table and i need to copy it ;)
<flux__> well, you can output it yourself
<flux__> when obviously such limits don't apply
<ikaros> is there something like display in scheme?
<flux__> I don't know what is display in scheme
<ikaros> hm
<ikaros> well i tried to print it.. but it seems i have to convert it to string first
<ikaros> so can i convert a whole array to string?
<Smerdyakov> The ML approach to compilation fundamentally doesn't support dynamic type analysis, and there is no static replacement like type classes.
Leonidas has joined #ocaml
<Smerdyakov> (I mention dynamic type analysis because that must be how Scheme 'display' works.)
<flux__> buy you could write like: let display_row r = Array.iter (printf "%d ") r; printf "\n" let display_array a = Array.iter (display_row) a;; display_array [|[|1; 2|]; [|2;3|]|];;
<ikaros> ye Smerdyakov that is the problem
<ikaros> hm flux__
<Smerdyakov> ikaros, maybe you should switch to Haskell. :)
<ikaros> hehe i just switched to ocaml ;)
<ikaros> im just trying alot these days
<ikaros> in fact i like ocaml so far.. i just need to get used to it a bit more..
love-pingoo has quit ["Leaving"]
mike has joined #ocaml
buluca has joined #ocaml
Aradorn has left #ocaml []
Aradorn has joined #ocaml
shawn has joined #ocaml
chessguy has joined #ocaml
velco has quit ["Ex-Chat"]
<Payo543> flux__, well flux__ if you could maybe show me those simple bindings that would be great ..........all these other bidnings the authors wanbt to make it all super complicated and add layers of OOP
<flux__> I would imagine there are simple bindings around also
<flux__> but mine aren't that simple either, except the ones that are trivial, and they are infact proprietary..
<Payo543> you mean closed source :P
<flux__> payo543, have you checked out curses bindings for ocaml?
<flux__> (I would expect them to be simple)
<flux__> (even if they are big)
<Payo543> flux__, the ncures ?
<flux__> I'll retract that
<pango> #print_depth n;;
<pango> Limit the printing of values to a maximal depth of n. The parts of values whose depth exceeds n are printed as ... (ellipsis).
<flux__> infact they are somewhat sophisticated from the C size
<flux__> or ugly, depending on your pov
<Payo543> the ncurses bindgins are huge
<pango> and #print_length n
<Payo543> flux__, its just there not as info about writing bindings for C stuff
<Payo543> all i want to do is have 1 function from a c library
<ikaros> thx pango .. wrote my own print already but ill have a look soon
<Payo543> i will take a look at it
<flux__> this page has a list of some bindings available: http://caml.inria.fr/cgi-bin/hump.en.cgi?sort=0&browse=65
<flux__> without looking, I would expect gz and metaphone bindings to be simple
<Payo543> i seeee
david_koontz has joined #ocaml
_fab has joined #ocaml
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
_velco has quit ["I'm outta here ..."]
bluestorm has joined #ocaml
Skal has quit [Remote closed the connection]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <-"]
smimou has joined #ocaml
pango has quit ["Leaving"]
pango has joined #ocaml
buluca has left #ocaml []
Aradorn has quit ["Leaving"]
bluestorm is now known as bluestorm_aw
chessguy has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
<Payo543> flux__, hmmmmmm
<setog3> pango: do you have any idea about my problem with fold_left
<pango> setog3: which one ?
Payo543 has quit [Remote closed the connection]
mike has quit ["This computer has gone to sleep"]
<pango> in the last message I saw you were using List.fold_right...
<setog3> yeah fold_right
<setog3> I think I must search more before asking or help
<setog3> but If you have a better idea ..
_velco has joined #ocaml
<pango> there's no good way to get the last element of a list; No matter what, the complexity is O(n), so if you find yourself in need of the last element of lists very often, or of potentially large lists, you probably don't want to use lists in the first place
<ulfdoz> ACK, arrays are the better solution for those problems or you invert the order of the list, if you can.
shawn has joined #ocaml
<pango> arrays, or another datastructure
newbcoder has joined #ocaml
<newbcoder> is ocaml for scientists worth it?
<ulfdoz> ehm
<ulfdoz> newbcoder: It always depends on the problem.
<pango> ulfdoz: I think he's talking about the book
* ulfdoz votes for TOPICLEN <= 80 chars
<ulfdoz> pango: The cookbook?
<ulfdoz> ah
Snark has quit ["Leaving"]
<newbcoder> yeah
<newbcoder> it is very expensive
<ulfdoz> Perhaps you find a library having the book.
<pango> newbcoder: I personally never had access to it, but from what I've read the price is the only complain people have about it
Payo543 has joined #ocaml
<Payo543> flux__, what was that binding you recomended me to look at ?
<abez> I've been meaning to purchase that book
<abez> they started ocaml-tutorial and everything
<abez> ocaml can get your employment at investment firms and banks ;)
<abez> s/your/you/
<Payo543> ocaml is gaining alot of popularity
<pango> ocaml-beginners list traffic was higher in 2005
<Payo543> ocaml 10 years ago was :\
<Payo543> pango, i have a buddy list + add remove etc in a gtk tree window and ......IM ' ing done
<newbcoder> oh wait
<newbcoder> the guys behind thebook are well konwn in the ocaml communikty?
<pango> Payo543: what do you mean by "10 years ago..." ? url ?
<Payo543> pango, 10 years ago i remember looking at ocaml .....well ML should i say its no where as popular back then then now
<pango> Payo543: the maximum for "seniors mailing list" was reached in 2004 according to http://caml.inria.fr/pub/ml-archives/caml-list/index.en.html
<Payo543> yea
<Payo543> if it had stable library support it would have much more
<newbcoder> ocaml doedsn't have stable library support?
<Payo543> newbcoder, no
<newbcoder> what?
<newbcoder> I thought ocaml's libraries
<newbcoder> were some ofthe best
<newbcoder> comparable to java
<Payo543> newbcoder, no no i mean communtiy made libs
<Payo543> not included libs
<Payo543> newbcoder, people dont update crap and its not setup easily for people to update and re distribute
<abez> to be honest, configuration and setting that stuff up is non-trivial
<pango> Payo543: yes, I barely used OCaml at uni in '95; It does change the fact that mailing lists traffic is slightly decreasing
<abez> so if you don't have an extra box generally you wont do it
<abez> the traffic could be decreasing because much has been asked on it and the archives are available
<abez> It is hard to gauge the userbase
<abez> the applications of ocaml are pretty broad too
<pango> abez: sure, it's no proof of anything
<Payo543> i just need to make a few small bindings for some stuff and i will have all the tools i need
<Payo543> pango, that GIO channel poll stuff in GTK is awesome
<pango> abez: but questions like "how to read a file into a string list" have been asked in beginners list for 4 years now, so I'm not sure archives is the reason why traffic decreases ;)
<Payo543> you just set the GIO channel add it to the main loop and its done
<bluestorm_aw> pango: do you think others languages (Haskell ?) may attract people more ?
_velco has quit ["I'm outta here ..."]
<Payo543> erlang is good
<abez> I know many scandinavian universities teach haskell and erlang
<bluestorm_aw> hm
<abez> they don't necessarily cover ocaml
<bluestorm_aw> i thougt erlang whas concurrent-oriented
<abez> yep
<Payo543> ejabberd is awesomw
<bluestorm_aw> hm
<bluestorm_aw> but this is not a "general" language, is it ?
<pango> bluestorm_aw: I have strictly no idea how to interpret this, for lack of other facts
<Payo543> bluestorm_aw, whats not general ?
<bluestorm_aw> dunno
<bluestorm_aw> hum
<abez> bluestorm_aw: it supposedly doesn't come with enough useless libs to be considered general like Java general. but neither does ocaml.
<Payo543> ocaml is label'd a general purpose programming language
<abez> I mean useful
<bluestorm_aw> ^^
<pango> maybe because "new languages benchmarks" are slightly less favorable to OCaml that Doug's one was ;)
<abez> new language benchmarks?
<abez> like rating the stdlib?
<Payo543> ocaml does well on debian shootout
<pango> Payo543: but not as good as in the older bench
<Payo543> but i dont know if its going off top level / byte code or native
<bluestorm_aw> maybe the bench codes may be improved ?
<Payo543> pango, also theres hundreds of ways to do things
<abez> I'd rather benchmark based on how you expect people to write it
<bluestorm_aw> (i looked at both Ocaml and Haskell code on a particular benchmark, and Ocaml version was slighty more complex)
<abez> rather than worry about optimizing examples
<abez> haskell has polymorphic operators
<bluestorm_aw> hum
<pango> that bench is just as flawed as others, among things because of arbitrary constraints
<Payo543> haskell has no where close to the speed of ocaml though
<abez> Payo543: it was until they told haskell to actually do the computation ;)
<Payo543> abez, huh ?
<abez> Payo543: Lazy eval
<Payo543> haskell is purely interpreted i thought
<abez> Payo543: if you don't make it produce a value, it won't
<abez> Payo543: if your computation is not part of the output it won't do it.
<Payo543> abez, all i was saying was ocaml is drmatically faster then haskell :P
<abez> Payo543: I'm just trying to be funny suggesting that haskell was faster before because it recognized the benchmark for worthless busy-work.
<Payo543> :D
<Payo543> ocaml even is kinda neck to neck with GCC
<abez> I suspect most of that is because of stack handling with non-recursive functions
<Payo543> yea well i just like how ocaml compiles against libc so i dont have any big huge wierd runtiems to attach
<pango> or from personal experience
<Payo543> pango, not debian shooout
<Payo543> i was going off some other ones
<Payo543> but that also shows a pretty close
<Payo543> it*
<pango> well, it's not often twice as slow
<Payo543> pango, well i dont care when stuff is that close :P
<Payo543> erlang - lua is fast
<Payo543> its when you start going php and ruby'd where things get slow
<pango> I mentionned online benchmarks because I think they have an "advertisement value", not because of rl usefulness
<Payo543> that lua JIT is super fast
TSC has quit [Remote closed the connection]
<abez> Ocaml gets really slow once you have to deal with the outside world >:(
<Payo543> lua is my favorite scripting lang and o caml is fav compiled well can be used for scritping too but yea
<Payo543> abez, you havent saw slow unless you have used ruby
<abez> I use perl and we know about ruby
<abez> ruby is so incredibly dog slow compared to perl it isn't funny
<Payo543> abez, and they think this yarv is going to save them and make it fast .........its even slow
<abez> Payo543: parrot actually is reasonably fast for perl speeds
<abez> Payo543: when 5.10 comes out (Ponie) it'll be nice
<bluestorm_aw> actually
<abez> I don't expect Perl6 to be really great since it scares the crap out of me.
<bluestorm_aw> i don't think ruby's people take care of speed that much
<Payo543> bluestorm_aw, i think they are scared to even mess with it
<Payo543> wouldnt you
<bluestorm_aw> hum
<bluestorm_aw> but speed of a scripting language is not that important, imo
<bluestorm_aw> (you may see ruby/python as "prototypes languages")
<abez> Prototypes my butt
<Payo543> LUA is where it gets serious :)
<abez> people don't throw away prototypes as often as you wish
<Payo543> i wish perl would get faster
<Payo543> i prefer that over php
<Payo543> well they are all about the same
<abez> In php it is faster to use a regex than to iterate all the characters in a string ;)
<Payo543> one scripting language for the most part carries same principles over
<abez> even if you have to compile the regex
<abez> I'm surprised people use python for numerical computation
<Payo543> python is good
<Payo543> i dont use it though and never plan too
<abez> They have modules for fast math but it doesn't get around the slowness in handling for loops etc
<Payo543> i dont like snakes :)
<bluestorm_aw> but abez
<abez> I think python is fundamentally worthless. It is like a dynmically typed java that is just as wordy
<Payo543> alot of people like it
<abez> I had a friend who went full circle from java to python and back again
<Payo543> i prefer LUA :)
<bluestorm_aw> i don't see the problem in doing for example little graphical applications in Python
<abez> I use ion3 and it uses lua
<bluestorm_aw> PyQt sounds great
<Payo543> lua is a true scripting lang
<abez> the fact that python has reasonable QT bindings is neat
<bluestorm_aw> and graphical applications aren't that much speed-obsessed
<abez> maybe if all your widgets do everything you want
<Payo543> gui frameworks GTK + GLIB and wx all do alot more stuff then just gui these days
<bluestorm_aw> as Qt does
<Payo543> i wonder if they will ever add qt bindings to ocaml
<bluestorm_aw> just code it yourself :)
<Payo543> i dont care about qt that much :)
<Payo543> i prefer GTK
<bluestorm_aw> (it seems an terrible amount of work, but would be great)
<bluestorm_aw> hm
<Payo543> pango, yea cool stuff ......kinda outdated though
<Payo543> lua is just so small
<Payo543> great forembedding
<Payo543> and for extending your application
<Payo543> i am going to cut down the size of my app for ocaml a well cut out everything i am not using in lablgtk ....all that paint crap .....other useless things i wont use
Mr_Awesome has joined #ocaml
bluestorm_aw is now known as bluestorm
TSC has joined #ocaml
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- The future of IRC"]
chessguy has joined #ocaml
kral has joined #ocaml
Kzzch has left #ocaml []
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- The future of IRC"]
<knobo> is it posible to make a function that can return either a function or an int?
kral has quit ["adios"]
<bluestorm> knobo:
<bluestorm> basically, this should not happen
<bluestorm> (type would not be convenient)
<bluestorm> however
<bluestorm> you may have
<bluestorm> either a polymorphic function (somethig that may return both, because processing is the same for both)
<bluestorm> either a sum type
<bluestorm> type MyThink = Int of int | Fuction of int -> int
<bluestorm> (i assumed the function you were spoking about was int -> int)
<bluestorm> (did you know about sum type ?)
<knobo> well, my experiment here is to make a function X that that returns a function Y that takes one argument ( a number ) and returns Y unless the argument is 0
<knobo> or mayby unless the argument is () or []
<knobo> then it returns a number
<bluestorm> hum
<bluestorm> this is not possible, i guess
<bluestorm> why could you not return an option type ?
<knobo> what is an option type?
<bluestorm> hum
<bluestorm> type 'a option = Some of 'a | None
<bluestorm> (it's an ocaml standard type)
<bluestorm> as an example :
<knobo> bluestorm: that could be the solution
<bluestorm> let divide a b = if b = 0 then None else Some (b / a) in
<bluestorm> (hum, a / b, not b / a)
<pango> exceptions are also a possibility, depending on context
batdog is now known as batdog|gone
<pango> knobo: what's x supposed to do when its argument is not 0 ?
<knobo> well, maybe actualy we only Y function, not x
<Payo543> i am debating HMMMMMM
<Payo543> what do you guys program in faster LUA or Ocaml ?
<knobo> let's take an example. a function that computes average, it accumulates it's arguments util the argument is 0
<knobo> then it returns the the average
<knobo> then you have to compose a new function in every call
<pango> if I understand what you're doing, it's not functional approach (because your "function" stores some state)
<knobo> pango: you'r right. maybe the experiment stops here...
<pango> you can also have several closures that share some state... Still not functional, but better interface
<knobo> but it would still be interesting to si if it is doable.
<knobo> but here "accumulate 10" does not return a function
<knobo> here the value is stored in the function accumulate
<pango> yes
<knobo> I would like to compose new function that takes one argument
<knobo> which return a new function that takes one argument, that returns a function ( and so on :)
<knobo> until the argument is 0
<Payo543> anyone know how much slower ocaml top level is then ocaml bytecode and native ?
<pango> must be doable
<pango> Payo543: must be the same as bytecode, or very close
<pango> since it's just a REPL on top of a bytecode compiler
<knobo> pango: that's what I thought would be an interesting experiment.
<knobo> I often do things like that in lisp...
<Payo543> pango, hmmmmmmm
<pango> knobo: as already said, in a strongly typed language, you'll need a variant type, or exceptions (yuck), for the return value then
<pango> and if you separate the two behaviors (accumulating and returning average), you end up using a closure to store a tuple, it's not very exciting:
<Payo543> pango, do you think ocaml is good for web stuff ?
<bluestorm> hmm
<Payo543> for my web panel i have the daemon for it in ocaml .......but i think i might want to make the actual pages in lua
<pango> Payo543: anything that could get rid of php is fine
Carillon has joined #ocaml
<Payo543> pango, i dont like php anymore either
<pango> I'm not the same, I never liked it :)
<Payo543> well back when i wanted a shopping cart it was my only option
<Payo543> and i learned it
<pango> it has "HACK ME" writted all over it
<Payo543> i see
<pango> s/writted/written/
<Payo543> well i am making a web panel for my hosting .......and i didnt know if i should do the whole thing in ocaml or do the daemon in ocaml and maybe a few other parts and do the rest in lua and hook up lua JIT to it
<pango> knobo: back to the first idea, you can create several accumulators : http://nopaste.tshw.de/11607798845c4ce/
<knobo> pango: yes, we are getting pretty close :)
<setog3> how is the best way to test if an element is the last (in a list) .. something like if liste=x::[] then x is the last ?
<pango> setog3: yes, but you'll need pattern matching to write such thing
<setog3> ok ..
<pango> match l with [x] -> x (* and the other cases... *)
<bluestorm> if match liste with a::[] -> a = x | _ -> false then ...
<setog3> ok ok.. so to do it with fold_right ..
<bluestorm> (where a is a free variable and x the element that may be the last)
<bluestorm> setog3: actually, if you do not need maximal performance
<pango> setog3: what makes you think fold_right is the right tool for the job ?
<bluestorm> List.hd (List.rev liste) would be ok
<setog3> pango: because in my university exercise the teachers say you must use fold_rigth to do all the jobs
<pango> mmh
<setog3> it's only to understand fold_left and right
<bluestorm> let rec is_last x = function [] -> failwith "empty list" | a::[] -> a = x | _::tail -> is_last x tail in
<bluestorm> ah
<setog3> so I try with my way.. and I found, but I think it's not how the teachers want we do (my way is (I repeat) fold_right (fun l a-> match a with []->[] |x::[]->[x] |x::t->t) liste liste ;;
<setog3> I think the good way is : fold_right (fun l a -> "I DONT KNOW") liste []
Carillon_ has quit [Connection timed out]
<setog3> dp
<setog3> so if you have any idea about the "I DONT KNOW" function.. just say
<pango> have you seen option types yet ?
<setog3> not yet
<setog3> what is it ?
<pango> a predefined variant type... type 'a option = None | Some of 'a
<setog3> hmm ok
bluestorm has quit ["Konversation terminated!"]
<pango> does it need to work with lists of anything, too ?
<setog3> no only list of int (for now..)
<pango> with fold_right, the first element examined will the last of the list (the one we're interested in), so you'll need a way to determine when this happens (from examining the accumulator, of course)
<setog3> O H !!
<setog3> I have an idea .. wait
<pango> an option type would have made it easy, but it can be done without them, specially if we drop the requirement that the function must be polymorphic...
<pango> if the type of the list is known, one could even use exceptions, but I'm not sure such solution would be appreciated ;)
<setog3> I think about (fun l a -> if a = 0 then l else do_nothing) liste 0 ;;
<setog3> or else exit..
<pango> well, that's the basic idea
<setog3> (fun l a -> if a = 0 then l else a)
<pango> but then you can't handle correctly lists that contain zero(es)
<setog3> arg ..
<setog3> a list can't contain [] ..
<pango> what datatypes have you learned so far ?
smimou has quit ["bli"]
<pango> mmh ? a list of list can
<setog3> yes .. but if I have only a list of int..
<pango> but [] type is not int, so you can't use [] as a "magic value", static typing won't accept it
<setog3> we only now liste int, list of list .. unit type , and some other
<setog3> know not now
<pango> tuples ? records ? variants ?
<setog3> not me.. but the other "player" know that (it's my first year in programming, before I do maths study)
<pango> thinking of it, you can use [] as a magic value... but you have to store the last element as a list of a single element in the accumulator
<setog3> like that (fun l a -> match a with []->[l] |a->a) liste [] ?
<pango> yes, and then as a last step you have to extract the element from its list
<setog3> but how, I don't know, I need to do a match on (fun l a -> match a with []->[l] |a->a) ?
<pango> yes, another pattern matching on the returned value
<pango> does it make sense ?
<setog3> yes but I don't how to do this ..
<pango> if you know about List.hd you can also avoid using pattern matching
<setog3> I think about something like match (fun l a -> match a with []->[l] |a->a) with x::[] -> x | _ -> 555
<setog3> but we can do
<setog3> oh no
<setog3> I have a better idea
<pango> you need the whole fold_right expression, not just its anonymous function
<setog3> a match on fold_right (fun l a -> (fun l a -> match a with []->[l] |a->a) with x::[]->x | _ -> 2) liste []
<pango> the liste [] are not at the right place
<pango> just put the first expression within a match with
<pango> match (... previous expression here ...) with x :: [] -> x | [] -> ...
<pango> if you've learned about let bindings, you can also give a name to the first expression, and avoid those overly long expressions
<pango> let maybe_last = (... previous expression here ...) in
<pango> match maybe_last with x :: [] -> x | [] -> ...
<pango> from the logical point of view, it doesn't change anything; but it improves readability...
<setog3> hmm yes
<setog3> but I don't know what to choos for case improbable like _->
<pango> well, I'm sure you'll learn about exceptions :)
<pango> which are really what such situation calls for
<setog3> yes .. we learn this .. something like raise improbable, and a exception improbable first
<pango> for now you could use 1 / 0
<setog3> hmm.. I reread the exercice.. and we only need to put [last] if the liste isn't = [] else [] :D .. not the integer
<setog3> I will use exeption
<pango> if you've seen exceptions already, use them here
<Payo543> any of you guys know of any web servers written in ocaml ?
<pango> actually, if the result must be either [] or [last], you've already finished the exercice :)
<pango> that's what you fold_right expression returns
<pango> s/you/your/
<setog3> yes
<setog3> and this only to test the exception ( let maybe_last = (fold_right (fun l a -> match a with []->[l] |a->a) liste []) in match maybe_last with x::[] -> [x] |[]->[] |_->raise Improbable);; .. and it's work :D now I can go sleep a little
<setog3> thx pango
<setog3> and good night all
<pango> np, good night! (will go, too :) )
setog3 has quit [Client Quit]