2011-04-29

<larhat> hcarty: about ocaml and zmq — i tried to build Caravan library but it didn't work, so i picked up ocaml-zmq (master branch) and now I'm working with that library. situation with zmq bindings is not very good, due to absence of "official" package.

2011-04-28

<hcarty> Are there any OCaml zeromq binding users here? I'm curious to know how well the current versions/versions work.
<hcarty> ygrek: Success!
<ygrek> hcarty, one doesn't exclude the other, in camlunity every vector is normalized and looks straight forward!
<hcarty> ygrek: That's ridiculous. It's the length of a normalized caml vector.
<hcarty> robinn: In short, you're not supposed to know about its internal structure.
<hcarty> robinn: It's an abstract type

2011-04-27

<hcarty> It sounds like the program is trying to load a format which is not supported by SDL
<hcarty> robinnn: What raises the exception?

2011-04-26

<hcarty> You only have direct access to 8-byte floating point values and (machine - 1) bit integers as numeric types.
<hcarty> You're welcome
<hcarty> joelr: None, but you can store them with bigarrays
<hcarty> I don't have much to say beyond the comment in the documentation for now, but if I come up with something I will add it.
<hcarty> That's clearly a much more intuitive name :-)
<hcarty> thelema_: Cool, thanks. I hadn't seen it before, but I've found it very useful.
<hcarty> thelema_: Out of curiosity - where did the name of the "tap" function come from?
<hcarty> thelema: The macro component of pa-do provides something of a defunctorizer, but I'm not sure if it would do much to help here.
<thelema> hcarty: oops, did I miss that what was posted wasn't polymorphic?
<hcarty> I've found that the polymorphic Map and Set modules in Batteries have caused me more trouble than they have saved typing.
<hcarty> thelema: It would be nice to have a functor-based BatMapSet/BatMultiMap in Batteries

2011-04-25

<hcarty> everyonemines: Have fun with OCaml, however you end up going about it.
<hcarty> From the outside, SML and OCaml look interchangable. From the inside, they look slightly less so.
<hcarty> The SML world has a lot of different implementations, but at this point OCaml only has one implementation.
<hcarty> F# is Microsoft's "embrace and 'extend'" take on OCaml
<hcarty> SML is from a different heritage, as I understand it. OCaml and SML share a common theoretical parent somewhere in their history, but they are and (always?) have been independent languages.
<hcarty> The language authors don't have a lot of time to spend on OCaml so their focus tends to be on improving and extending the compiler itself.
<hcarty> And libraries like Batteries which extend the standard library and come with a large set of examples.
<hcarty> There are several tutorials available
<hcarty> It doesn't take long to make, but people have other work to do
<hcarty> Other operating systems would be up to volunteers using those OSs
<hcarty> Prepackaged for Debian and Fedora at least :-)
<hcarty> The combination of Batteries and ocamlfind and oasis-db will hopefully help lower the initial levels of frustration people feel with the language.
<hcarty> The OCaml community is smaller than the communities around many other languages (Perl, Python, Haskell)
<hcarty> Beyond that, there is the oasis-db project (currently under heavy development) which will give the OCaml world a CPAN-like infrastructure
<hcarty> You could use GODI, which builds OCaml + libraries
<hcarty> Batteries does a lot to help with discoverability of functions
<hcarty> And ocamlfind/findlib provides a nice way to load or link libraries
<hcarty> You can load different implementations of a library with the same module names, for example.
<hcarty> Not necessarily
<hcarty> That is probably a C holdover
<hcarty> Most, if not all, of the stdlib functions which have potentially mismatched arguments have short examples of how to call them
<hcarty> I'm used to it at this point, but I actually filed a bug report about this when I first started out with OCaml :-)
<hcarty> everyonemines: Is there a function in particular you have in mind?
<hcarty> My guess is that part of the reason there are few/no examples in the documentation is that users may be expected to understand the concepts behind the functions already
<hcarty> All that said, the official OCaml distribution is sadly lacking in example code.
<hcarty> But once you know what they mean the type signature of a function is a useful and concise reference.
<hcarty> than example code
<hcarty> They take a bit more to get used to
<hcarty> More than a set of examples would
<hcarty> I agree that examples are useful, but the types provide a huge amount of information.
<hcarty> The distinction is probably not well advertised
<hcarty> OCaml's documentation is definitely lacking in some areas, but it's excellent in others
<hcarty> everyonemines: Which parts?
<hcarty> everyonemines: The toplevel can bite you that way :-)
<hcarty> Or Str.(split_delim (regexp " ") " abc ") if you want to play with 3.12 syntax
<hcarty> everyonemines: Str.split_delim (Str.regexp " ") " abc "
<hcarty> everyonemines: (begin joking flame)No it doesn't!(end joking flame)
<hcarty> And good
<hcarty> Yes
<hcarty> everyonemines: There is often a lack of OSX folks around here
<hcarty> everyonemines: You best bet may be to email the author, Markus Mottl - http://www.ocaml.info/

2011-04-23

<hcarty> png, svg, pdf, ps, X, Cairo surface, and a few others
<hcarty> zorun: Yes
<hcarty> The OCaml PLplot bindings have some very simple single-line functions for point, line and contour plots. Nothing for bar charts though.
<hcarty> You're quite welcome
<hcarty> DOUK: http://plplot.sourceforge.net/examples.php?demo=12 -- this may work for what you need, but if this is a one-shot thing then writing the data to a text file and plotting it in gnuplot is likely to be simpler
<hcarty> With the disclosure that I'm the author/maintainer of the PLplot OCaml bindings :-)
<hcarty> If it's something you plan to do over and over then PLplot is likely simpler in the long run.
<hcarty> But if you only need it for this one thing then it may be easier to write the information out to a text file and plot it with gnuplot.
<hcarty> Functions on the x-axis, time on the y-axis could work
<hcarty> Graph as in a series of (x, y) points, or something else?
<hcarty> All of the prerequisites are packaged for Ubuntu
<hcarty> DOUK: Debian + Ubuntu packages may be available eventually, but for now Fedora is the only platform with pre-built PLplot + OCaml packages.

2011-04-21

<hcarty> thelema: Thank you!
<hcarty> To match String.print_quoted naming
<hcarty> Or unquoted
<hcarty> thelema: Looks good to me
<hcarty> It's too bad that the existing String.t_printer gives a quoted string, as it's a mismatch with String.print and String.print_quoted
<hcarty> In the long %{...} form
<hcarty> Yes
<hcarty> A different name, as long as it ends in _printer, will work correctly
<hcarty> thelema: p"%{String.t}" calls String.t_printer -- p"%{foo}" calls foo_printer
<hcarty> thelema: I really wish that I had more time to spend on Batteries, beyond the occasional bug report
<hcarty> thelema: Yes, I believe so
<thelema> hcarty: regarding your issue #94 in batteries (https://github.com/ocaml-batteries-team/batteries-included/issues/94), would adding that code to batstring (+ the signature in .mli) satisfy your request?
<hcarty> sheets1: I believe so
<hcarty> thelema: I don't know of many people using it, but cameleon seems like more than a beginner's tool
<hcarty> josh_back: vim here
<joshwa> hcarty: wow! i was thinking of doing somehting like that with erlang, but OCaml seems cool :)
<hcarty> One of the coolest projects I've seen in a long time :-)
<hcarty> joshwa: http://forge.ocamlcore.org/ -- here as well
<hcarty> books in print that is
<hcarty> I don't think that there are any good English language books on OCaml
<hcarty> joshwa: The official manual's first chapter provides a nice introduction. Jason Hickey also wrote a nice book which is available in PDF form : www.cs.caltech.edu/courses/cs134/cs134b/book.pdf
<hcarty> joshwa: Along with many other applications
<hcarty> joshwa: It's used as a general programming language - everything from compiler writing to web applications to math + science research projects

2011-04-20

<hcarty> sheets1: You can use object method x = 1 end to (or method x = ref 1) to avoid manually creating getters and setters
<hcarty> sheets1: That's the one
<sheets1> hcarty: aha yes, you are correct 3.13 Functional objects in the manual
<hcarty> sheets1: {< ... >} or something similar
<hcarty> sheets1: Possibly - it's been a while since I've used OCaml's object system heavily
<sheets1> hcarty: don't I have to wrap everything in methods, though? I no longer get "setter constructors" for free?
<hcarty> sheets1: Objects can do have a similar syntax

2011-04-14

<thelema> hcarty: yes, it raises [No_more_input] if 0 characters can be read.
<hcarty> If I try to read stdin only, BatPervasives.input fails with No_more_input once anything is written to stdout.
<hcarty> I'm trying to read stdin and stderr from a process, but I'm not having any luck. Does anyone have any examples?
<hcarty> thelema: Should BatPervasives.input ever raise No_more_input?
<hcarty> adrien: Thank yoU!
<adrien> hcarty: not really but they don't return the same error(s)
<hcarty> Is there a difference between Sys.rename and Unix.rename?

2011-04-11

<hcarty> kusco: You're welcome, and have fun :-)
<kusco> Thanks hcarty
<hcarty> kusco: I need to run, but here's a reference for more - http://caml.inria.fr/pub/docs/manual-ocaml/manual023.html
<hcarty> kusco: If it's compiled, you can use #load "foo.cmo";;
<hcarty> kusco: Or you can put "open Foo" at the top of Bar to have direct access to all values and types from Foo without needing the Foo. prefix.
<hcarty> kusco: ex. Foo.t to refer to type t from module Foo
<hcarty> kusco: You don't have to put anything in the Bar module to access types or values from Foo. You can prepend them with Foo.
<hcarty> It's probably safer to use a shipped version anyway, unless you are going to get in to development
<hcarty> andreas: They may not have the svn version ready to go without oasis to avoid constantly updating the oasis-generated files.

2011-04-08

<hcarty> I was reading lots of Discworld at the time
<hcarty> mrvn: You're welcome :-)
<hcarty> mrvn: I found and uploaded the mp4 of the Mirage talk if you're interested
<rien> hcarty: I disagree somewhat, I think things like (> 2) are very necessary. replacing them for fun x -> x > 2 hurts reaadability
<hcarty> Whereas I think xstrp4 and pa_string from Batteries are examples of syntax extensions which do add readability quite often.
<hcarty> They are all nifty, but don't seem to provide a big gain in language usability.
<hcarty> At the end of the day, though, I think most if not all of those syntax additions hurt readability more than they help.
<hcarty> rien: "where" was in the original Batteries bag of syntax extensions as well, so I'm sure it's floating around somewhere.
<hcarty> But it was a fairly complete implementation along the lines of (\ \3 + 4) IIRC
<hcarty> thelema: The syntax is a little different
<thelema> hcarty: did he implement that in the end?
<hcarty> Your anonymous function shorthand has an implementation by bluestorm
<hcarty> Function composition is spelled differently
<hcarty> rien: I think almost all of those are available in some form

2011-04-07

<pdhborges> hcarty: if I take 2 more modules my brain will just explode by having to litter the code with srtruct end and sig ends
<hcarty> pdhborges: Take two module systems and call #ocaml in the morning?
<hangs> (back from lunch) hcarty: ocaml 3.12. same error w/ BATTERIES_NATIVE_SHLIB = no
<hcarty> hangs: I don't use OSX, but I think there was something on either the GODI or main OCaml mailing list about this. Which version of OCaml are you using?
<hangs> hcarty: i can't install camomile
<hcarty> Likely directly from extlib
<hcarty> Batteries seems to as well
<hcarty> hangs: The Cal Tech book by Jason Hickey has a nice chapter which focuses on a comparison between OO-based and module-based approaches to problems, for example.
<hcarty> hangs: Have you seen the (old but still useful) O'Reilly book, or the Cal Tech book? Both are reasonable, although probably not oriented toward Java folks specifically.
<hcarty> thomasga: I have no idea :-)
<hcarty> after I get home from work that is
<hcarty> thomasga: I can host it somewhere for your to retrieve after I work
<hcarty> thomasga: As long as it's ok with whoever owns the video
<thomasga> ouups, sorry, I meant hcarty
<hcarty> mrvn: sorry, http not https
<hcarty> mrvn: https://ocaml.janestreet.com/?q=node/89 if you haven't seen it yet
<hcarty> mrvn: I think that's one of the projects the OCamlPro folk(s) are talking about implementing
<hcarty> Oh, it looks like avsm has left. I'm happy to provide it, but I want to make sure it's ok to do so.
<hcarty> Which was from a legitimate source. I just don't remember which.
<hcarty> I have an mp4 somewhere...
<hcarty> The talk is informative, and the project is cool
<hcarty> mrvn: Have you watched the tech talk on Mirage?

2011-04-05

<hcarty> rrenaud: rlwrap is a nice alternative to ledit, and the Lwt library comes with a custom toplevel which performs context-appropriate tab completion.

2011-04-04

<hcarty> Which you can then pull from there and maintain directly if you like
<hcarty> adrien: It puts files in your GODI install dir
<hcarty> $HOME/godi or similar
<hcarty> adrien: Your godi install prefix
<hcarty> gildor: I haven't had a chance to test yet, but I plan to soon
<hcarty> gildor: Thank you for the new and updated GODI packages :-)
<adrien> hcarty: thanks, thought as much
<hcarty> adrien: Starting with godiva is nice because it gives you a template to work from
<hcarty> adrien: It's a good start, even if it ends up not being enough for the final package

2011-04-01

<hcarty> Oh. Nevermind then :-)
<joelr> hcarty: the array needs to be passed to a c function
<hcarty> But it may not make things any easier in the end.
<hcarty> It avoids the C-side malloc
<hcarty> joelr: If you can allocate one element at a time, you could allocate the OCaml array then fill in each element separately
<joelr> hcarty: i'm trying to implement a poll function for ocaml-zmq and normally the # of sockets is known in advance, so in c you allocate an array of poll descriptors on the stack. it appears that i'll have to malloc it in the ocaml stubs :-(
<joelr> hcarty: thanks!
<hcarty> I reference it and the OCaml manual pretty frequently when working on bindings
<hcarty> And if you have seen it... then it's an excellent resource you already know about :-)
<hcarty> If you haven't seen this, it's an excellent resource: http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php
<hcarty> Reading involves reading the OCaml value from the array, then reading the tuple elements from that value
<joelr> hcarty: thanks
<hcarty> joelr: I don't have an example handy - but the short version is that to create it you create the tuples as OCaml values and insert them in to the array

2011-03-31

<hcarty> thelema: Asparagus here too. A spooky #ocaml conspiracy.
<hcarty> I believe it's primarily runtime - there is some overhead cost associated with using first-class modules
<scooty-puff> hcarty, looked like they have first-class modules, but i imagine most of this is at runtime (though it would be cool if its smart enough to shift to compile-time what it can)
<hcarty> scooty-puff: Possibly not... 3.12.x and 3.13.x may bring it closer?
<hcarty> Definitely - better to know than not :-)
<hcarty> philed: Cool, thank you for letting me know
<philed> hcarty: "lwt s = Lwt_io.read_line Lwt_io.stdin;;" won't work.
<philed> hcarty: No bug.
<hcarty> notk0: You can wrap the inner match in "begin .. end" or ( )

2011-03-30

<hcarty> It is probably worth sending them an email to ask what is missing
<hcarty> philed: It could be a bug. I'm not an Lwt expert, but upstream is generally very responsive to feedback
<philed> hcarty: It doesn't work for me when compiling either.
<hcarty> philed: I'm not sure - that doesn't work for me here either
<philed> hcarty: Ah, I'm being very careless. Yes, the code you gave works. But what if I want to write lwt s = Lwt_io.read_line Lwt_io.stdin in s;;?
<hcarty> philed: After that it worked for me
<hcarty> philed: From a fresh ocaml session, #use "topfind";; #camlp4o;; #require "lwt.simple-top";; #require "lwt.syntax";;
<hcarty> philed: "lwt s = Lwt_io.read_line Lwt_io.stdin;;"
<hcarty> philed: I tried it here and it works
<hcarty> Or, rather, second - before the #require
<hcarty> thelema: I'm fairly certain the #camlp4o;; does need to come first
<hcarty> thelema: Time to shut the project down :-)
<hcarty> mrvn, thelema: Very true
<thelema> hcarty: but a float array can be generated optimized, and passes to a function that takes 'a array
<mrvn> hcarty: when you construct the array. But how are other functions supposed to know that?
<thelema> hcarty: true
<hcarty> I thought the optimization only happened if the record/array was known at compile time to be float only
<mrvn> hcarty: Array.get arr x needs runtime checks.
<thelema> hcarty: there is for float arrays
<hcarty> There is no extra runtime cost to check for float records + arrays
<hcarty> mrvn: I don't think it is
<mrvn> hcarty: float*float is also a float block with 2 entries.
<hcarty> mrvn: Unless a and b are float, of course
<joelr> hcarty: i'm stuffing http headers someplace
<hcarty> joelr: StringMap vs Hashtbl - it depends on what you are doing. Hashtbl can be faster, while StringMap.t values are not mutable.

2011-03-29

<hcarty> gildor: I need to go - I can hopefully provide some feedback tomorrow if needed
<hcarty> gildor: Ah. In that case, it's probably a good idea to include that. I believe the original odb info files have that information.
<gildor> hcarty: I try to mimic what thelema has done by hand
<gildor> hcarty: this is an odb compatible repository, extracted from oasis-db
<hcarty> gildor: But I'm not sure if I thinking of this in the correct context.
<hcarty> gildor: On the page, or elsewhere? I see a file listing.
<hcarty> gildor: List where?
<gildor> thelema, hcarty: I am now listing findlib name rather than package name
<gildor> thelema, hcarty: concerning odb
<hcarty> alexyk: Most MPI distributions have their own tools for starting a set of processes. zeromq may have something similar.
<gildor> alexyk: read also my two other reply to hcarty ^^^
<gildor> hcarty: if you need extra rules (e.g. to use alphaCaml or ocamlify) you'll have to hack myocamlbuild.ml, but this is REALLY advanced stuff
<hcarty> gildor: That's what I had gathered from discussions in here
<gildor> hcarty: indeed, if you need some "advanced" stuff like syntax extension, you'll need to add a couple of line in _tags
<hcarty> alexyk: My understanding is that you can use oasis for a lot without dealing with ocamlbuild directly, but for some uses you still need to do some work with ocamlbuild.
<hcarty> thelema: Cool, thanks
<thelema> hcarty: I made you an admin on http://oasis.ocamlcore.org/dev/admin/odb if you want to play with odb
<hcarty> thelema: pong
<thelema> hcarty: ping

2011-03-28

<thelema> hcarty: you too
<thelema> hcarty: // is Enum.filter
<hcarty> thelema: What is // currently?
<thelema> hcarty: if // wasn't taken, I'd like to mirror perl
<hcarty> I think there are a few Infix modules floating around
<hcarty> thelema: Should the be done consistently through Batteries then?
<hcarty> ( |? ) or ( |?> ) seem like the obvious choices. I've used ( |? ) as an infix form of Option.default.
<hcarty> thelema: Ok. I'm trying to come up with a suitable operator name...
<thelema> hcarty: not yet - you're welcome to create Option.Infix and put your proposed operator there
<hcarty> Does Batteries have an infix form of Option.map? An option equivalent to ( |> )
<mrvn> hcarty: It's too late to grock that now. Will have to look at that in the morning.
<hcarty> mrvn: I believe so. There was a mailing list post along these lines recently
<hcarty> mrvn: ex. let module M = (val m : M_sig) in ...
<mrvn> hcarty: so with include and coercion you have inheritance like objects.
<hcarty> mrvn: I'm not sure if it counts as coercion, but I think you apply more restrictive but still matching signatures
<hcarty> mrvn: From what I remember reading, I think that's roughly equivalent to what first class modules do internally
<hcarty> mrvn: I'm not sure. kaustuv did some first class module tests around 3.12.0's release, and I think they do carry some overhead in a case like this.
<hcarty> You could then unwrap the module and call the accessor functions on the common fields. Any differing fields wouldn't matter at that point.
<hcarty> joelr: Yes
<hcarty> joelr: Wrap each record type in a module with accessor functions
<joelr> hcarty: first-class modules?
<hcarty> joelr: If you are using OCaml 3.12, you could pass modules around as a half-way point between objects and records
<hcarty> rproust: I think the printer can do some beautification. There is a big difference between the revised syntax output and the standard syntax output.
<hcarty> The revised printer does seem to do a much better job of giving the code a readable layout.
<hcarty> There is also Camlp4OCamlRevisedPrinter.cmo for printing in the revised syntax
<hcarty> joelr: You can play around with "camlp4of Camlp4Printer.cmo ..." and "camlp4o Camlp4OCamlPrinter.cmo"
<hcarty> The printers can be tweaked, but I don't understand enough of the camlp4 code to say how.
<hcarty> joelr: They aren't the neatest :-)
<hcarty> joelr: There are a few pre-defined pretty printers

2011-03-25

<hcarty> adrien: Using the myocamlbuild.ml from Batteries
<hcarty> adrien: That's odd - I've used the same (generic) myocamlbuild.ml between 3.11.x and 3.12.0
<thelema> hcarty: agreed - I helped develop those functions, but thought them too risky to use in production code. If Jane street has vetted them well, maybe it's okay to put them in batteries
<hcarty> thelema: It may be worth grabbing or at least studying a few of the updated Core functions, particularly the sped up tail recursive list functions.
<hcarty> thelema: Agreed
<thelema> hcarty: there's definitely uses for them, but they're not the right solution for everything.
<hcarty> thelema: Functors work beautifully in the Map.Make case, particularly if you want to be different maps can't be mistakenly interchanged.
<hcarty> thelema: Thanks, I thought Batteries had something
<hcarty> rien: You're welcome, and good luck :-)
<rien> hcarty: I appreciate the help!
<hcarty> rien: There is some more information here, though I don't know how useful it is - http://stackoverflow.com/questions/307499/a-good-ocaml-parser
<hcarty> rien: There may be something in Batteries, but this is an area of OCaml I haven't worked with
<rien> hcarty: understood. I'll look for those. do you know if there's a parser combinator library for OCaml? (in Haskell there's a good one called Parsec)
<hcarty> rien: So that may help
<hcarty> rien: I don't know Haskell well enough to say, but on a somewhat related note I think there is a scheme or two written in OCaml already out there.
<hcarty> Or nest both modules in a parent functor
<hcarty> So it's ~% "%d:%d" 2 4
<hcarty> thelema: Except that the ~ means it's a prefix operator
<hcarty> I have "say" defined as a wrapper around printf, and "warn" as eprintf
<thelema> hcarty: "%d:%d" ~% 2 4
<hcarty> thelema: Oh, really? I suppose that makes some sense then
<hcarty> That's an interesting piece of shorthand
<thelema> hcarty: rubyish.
<hcarty> Wow... Jane St. defines ( ~% ) = sprintf
<hcarty> thelema: I saw that camlzip has a META file in Subversion - is that the version available to odb, or does odb have the official 1.0.4 release?
<thelema> hcarty: actually, the svn of camlzip has a META file and a make target for findlib installation, it's just not make install

2011-03-24

<hcarty> thelema: camlzip's installation doesn't work properly, but that seems to be down to having no META file so the installation can't be verified.
<hcarty> thelema: You're welcome, and thank you!
<hcarty> thelema: odb.ml install --debug batteries -> success
<hcarty> thelema: I've wanted to do the same. Along with a Sys.command which returns (code, stdout, stderr).
<hcarty> Yep
<hcarty> thelema: The %v needs a space before the "
<hcarty> 94, assuming I didn't add any newlines...
<hcarty> thelema: I'll send a patch once I've tested it
<hcarty> thelema: Found at least one problem - a typo in has_dep