<?xml 
version="1.0" encoding="utf-8"?>
<rss version="2.0" 
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
>

<channel xml:lang="en">
	<title>blog.rastageeks.org</title>
	<link>http://blog.rastageeks.org/</link>
	
	<language>en</language>
	<generator>SPIP - www.spip.net</generator>

	<image>
		<title>blog.rastageeks.org</title>
		<url>http://blog.rastageeks.org/local/cache-vignettes/L100xH99/siteon0-cb303.png</url>
		<link>http://blog.rastageeks.org/</link>
		<height>99</height>
		<width>100</width>
	</image>



<item xml:lang="en">
		<title>Unix.open_process* and file descriptors</title>
		<link>http://blog.rastageeks.org/ocaml/article/unix-open_process-and-file</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/unix-open_process-and-file</guid>
		<dc:date>2012-03-15T00:23:26Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;Hi fellow OCamlers, long time no see! :-)&lt;/p&gt; &lt;p&gt;I would like to mention here an issue with &lt;code class='spip_code' dir='ltr'&gt;Unix.open_process*&lt;/code&gt; that may concern some of you here.&lt;/p&gt; &lt;p&gt;Processes opened using &lt;code class='spip_code' dir='ltr'&gt;Unix.open_process&lt;/code&gt; in POSIX systems are spawned using &lt;code class='spip_code' dir='ltr'&gt;fork()&lt;/code&gt;. Therefore, they inherit all file descriptors opened by the calling process.&lt;/p&gt; &lt;p&gt;This leads to many unfortunate minor issues. For instance, if the calling
process has opened a port and crashes after calling the external process, then that port remains open until the external process terminates..&lt;/p&gt; &lt;p&gt;More importantly, this is a source of potentially important security issues: by default, processes spawned with &lt;code class='spip_code' dir='ltr'&gt;Unix.open_process*&lt;/code&gt; will have access to any opened file or socket, allowing them to those read files' content or sniff network traffic..&lt;/p&gt; &lt;p&gt;The problem is not easy to fix using the standard POSIX API. If you have control over all opened file descriptor in your code, you can use &lt;code class='spip_code' dir='ltr'&gt;close-on-exec&lt;/code&gt; on each of them, which makes sure that they are closed when forking. However, for large programs this quickly turns out to be impractical, in particular if your program is using libraries that open file descriptors.&lt;/p&gt; &lt;p&gt;Another common solution is to emulate BSD's &lt;code class='spip_code' dir='ltr'&gt;closefrom()&lt;/code&gt; function, which closes all file descriptors higher than a given number. You can find a portable but possibly very slow implementation of this function in openssh's code:
&lt;a href=&quot;http://anoncvs.mindrot.org/index.cgi/openssh/openbsd-compat/bsd-closefrom.c?view=markup&quot; class='spip_out' rel='external'&gt;http://anoncvs.mindrot.org/index.cgi/openssh/openbsd-compat/bsd-closefrom.c?view=markup&lt;/a&gt;&lt;/p&gt; &lt;p&gt;OCaml developers are aware of the situation but haven't found a suitable fix for them. Here is a comment from Xavier Leroy:&lt;/p&gt; &lt;blockquote class=&quot;spip&quot;&gt;
&lt;p&gt;
Feel free to publicize this PR so that Unix experts out there can chime in.&lt;/p&gt; &lt;p&gt;This is an old issue that popped up during the development of Cash (the Caml shell), in particular. The &quot;ideal&quot; solution is to have all file descriptors in
&lt;code class='spip_code' dir='ltr'&gt;close-on-exec&lt;/code&gt; mode, but it requires discipline from the programmers. (File descriptors created by &lt;code class='spip_code' dir='ltr'&gt;Pervasives.open_in&lt;/code&gt; and &lt;code class='spip_code' dir='ltr'&gt;Pervasives.open_out&lt;/code&gt; are &lt;code class='spip_code' dir='ltr'&gt;close-on-exec&lt;/code&gt;, but not those created by &lt;code class='spip_code' dir='ltr'&gt;Unix.openfile&lt;/code&gt; or &lt;code class='spip_code' dir='ltr'&gt;Unix.socket&lt;/code&gt;, for compatibility with the Unix specs.)&lt;/p&gt; &lt;p&gt;Also, a long time ago we experimented with a &lt;code class='spip_code' dir='ltr'&gt;closeall()/closefrom()&lt;/code&gt; function that did not use &lt;code class='spip_code' dir='ltr'&gt;/proc/&lt;pid&gt;/fd&lt;/code&gt;, and it was really slow to call &lt;code class='spip_code' dir='ltr'&gt;close()&lt;/code&gt; on thousands of potential file descriptors. The &lt;code class='spip_code' dir='ltr'&gt;/proc/&lt;pid&gt;/fd&lt;/code&gt; trick is nice but not terribly portable.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This issue can be a problem for some of you so I wanted with this post to properly document it. It is particularly crucial if you implement any kind of delegation to a less powerful system user using forked processes, for instance when implementing a CGI interface..&lt;/p&gt; &lt;p&gt;Take care y'all!&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Type fascism..</title>
		<link>http://blog.rastageeks.org/ocaml/article/type-fascism</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/type-fascism</guid>
		<dc:date>2011-08-26T01:06:44Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;I used to think of me as a libertarian.. Maybe it is because I am getting old and grumpy but I've found myself lately being more of a totalitarian rigid conservative.. concerning typing and APIs.. :-)&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://savonet.sourceforge.net/&quot; class='spip_out' rel='external'&gt;Liquidsoap&lt;/a&gt; being a stream-oriented software, we had felt the need for a long time to be able to manipulate mp3 id3 tags without them being attached to an actual file.. This is certainly possible in theory: id3 tags are not part of the mpeg I/II audio layer 3 format but an addition in the form of a binary blob, either at the beginning or at the end of the file. However, in practice there are very few libraries that actually support that &#8212; in fact there are very few implementations of the id3 tag specifications..&lt;/p&gt; &lt;p&gt;Anyway, I realize lately that, twisting &lt;a href=&quot;http://developer.kde.org/~wheeler/taglib.html&quot; class='spip_out' rel='external'&gt;TagLib&lt;/a&gt;'s arm, it was actually possible to implement this using this clean, maintained and well-designed library.. So I went on and upgraded our binding, adding what I called &lt;i&gt;inline&lt;/i&gt; tags support. This allows to parse existing id3 binary tags or generate a binary representation of an inline tag that can be written to a file, or a stream in our case.&lt;/p&gt; &lt;p&gt;However, there are some constraints to consider in order to assure a proper use of the library, namely:&lt;/p&gt; &lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; The user should be able to allocate empty inline tags.&lt;/li&gt;&lt;li&gt; An empty inline tag can be filled by parsing a binary blob representing an actual id3 tag&lt;/li&gt;&lt;li&gt; An can also be filled directly with id3 frames.&lt;/li&gt;&lt;li&gt; An initial empty inline tag is valid iff it has been filled with at least one frame or parsed from a valid id3 binary tag&lt;/li&gt;&lt;li&gt; Only valid inline tags should be rendered as binary blobs.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;To make things more tricky, parsing a binary representation is done in two steps:&lt;/p&gt; &lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; Parsing of the header, some initial 10 bytes. Only after this step is the total size of the binary data known.&lt;/li&gt;&lt;li&gt; Parsing of the full tag, using the size returned during header parsing.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;And, of course, one should not do anything after parsing the header expect parsing the full tag, as the current state of the tag after parsing only the header is not consistent yet..&lt;/p&gt; &lt;p&gt;So, with all these considerations in mind, I wondered how it could be possible to restrict the freedom of the users while adding as few of a burden as possible, both for me and them.. As it turned out, phantom polymorphic types provide a very neat way of doing so!&lt;/p&gt; &lt;p&gt;Reading from above, an inline tag has 3 possible states:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;type state = [`Invalid | `Parsed | `Valid]&lt;/code&gt;&lt;/div&gt;
&lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; &lt;code class='spip_code' dir='ltr'&gt;`Invalid&lt;/code&gt; is the initial state of an empty tag&lt;/li&gt;&lt;li&gt; &lt;code class='spip_code' dir='ltr'&gt;`Parsed&lt;/code&gt; is the state of a tag after parsing its header&lt;/li&gt;&lt;li&gt; &lt;code class='spip_code' dir='ltr'&gt;`Valid&lt;/code&gt; is the state of a tag which is valid for rendering&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Then, the full signature is as follows:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt; type state = [ `Invalid | `Parsed | `Valid ]&lt;br /&gt; &lt;br /&gt; type 'a t &lt;br /&gt; &lt;br /&gt; val init : unit -&gt; [`Invalid] t&lt;br /&gt; &lt;br /&gt; val header_size : int&lt;br /&gt; &lt;br /&gt; val parse_header : [`Invalid] t -&gt; string -&gt; [`Parsed] t&lt;br /&gt; &lt;br /&gt; val tag_size : [&lt; `Parsed | `Valid] t -&gt; int&lt;br /&gt; &lt;br /&gt; val parse_tag : [`Parsed] t -&gt; string -&gt; [`Valid] t&lt;br /&gt; &lt;br /&gt; val attach_frame : [&lt; `Invalid | `Valid ] t -&gt; frame_type -&gt; frame_text -&gt; [`Valid] t&lt;br /&gt; &lt;br /&gt; val render : [`Valid] t -&gt; string&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;As you can see, the tag's state is used as a phantom type in &lt;code class='spip_code' dir='ltr'&gt;'a t&lt;/code&gt; and is updated as the tag passes through the various API calls. This makes it impossible to actually hit &lt;code class='spip_code' dir='ltr'&gt;render&lt;/code&gt; without either adding a single frame or successfully parsing a binary tag.&lt;/p&gt; &lt;p&gt;And it comes at zero cost, both for me and the user! As for myself, I just write the implementation bearing in mind that I need to return the given tag after each call. Likewise, the user only has to redefine its tag after each call, much like in the plain pure functional good ole fashion.. For instance:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;let tag = init () in&lt;br /&gt; let tag = attach_frame tag &quot;TIT2&quot; &quot;The times They Are A-Changin'&quot; in&lt;br /&gt; render tag&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;I am too lazy to draw it but this can be generalized: if you think of your API as a diagram, where nodes represent states and arrows represent the various calls, then each state can be mapped to a polymorphic type and each call can be annotated with similar polymorphic phantom types in order to make sure that one can only call them from a correct state..&lt;/p&gt; &lt;p&gt;I think I really appreciate static typing when it comes at such a low cost. It makes you feel comfortable with both the code you write and the code people will write using your API and removes the need to constantly check boring things at runtime..&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Moving out of the 70s...</title>
		<link>http://blog.rastageeks.org/ocaml/article/moving-out-of-the-70s</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/moving-out-of-the-70s</guid>
		<dc:date>2011-07-25T22:12:35Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;Dear OCamlers,&lt;/p&gt; &lt;p&gt;The seventies were a cool time.. Progressive rock, pacifist movements and, of course, free love.
However, the seventies were also the dark ages for modern computing.. and the time of POSIX..&lt;/p&gt; &lt;p&gt;On this note, I am sick and tired of fixing over and over the same bugs caused by corner cases and shitty aspects of the POSIX norm. The top two is the following:&lt;/p&gt; &lt;h3 class='h3 spip'&gt;SIGPIPE&lt;/h3&gt;
&lt;p&gt;A sigpipe, depending on some obscur run-time considerations, may silently terminate your program or raise an exception. If you want to be sure that you only have an exception, you need to explicitely ask for this signal to be caught.&lt;/p&gt; &lt;p&gt;Of course, this signal does not exist under win32 and if you try to catch it under windows, you will get an exception thrown to your face which most likely will also crash your program..&lt;/p&gt; &lt;p&gt;Sipgipe may be received when communicating through a network socket. Thus, any time you write a server, you need to make sure the signal is properly registered for catching. And if you do not do it, your code may work perfectly for you but crash randomly on another system. In this case, I wish you good luck to trackback the crash to this issue..&lt;/p&gt; &lt;p&gt;To sumarize:&lt;/p&gt; &lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; In any server-oriented program or, more generally, any program which expects an exception for sigpipe, you need to make sure the signal is registered for catching&lt;/li&gt;&lt;li&gt; If you plan on porting your code to windows, you also need to &lt;i&gt;not&lt;/i&gt; execute the registration code under windows.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Now, why is that hapenning? This is well explained in &lt;a href=&quot;http://caml.inria.fr/mantis/print_bug_page.php?bug_id=4640&quot; class='spip_out' rel='external'&gt;this bug report&lt;/a&gt;: sigpipe is also received when a program is piped to something that failed, for instance if you pipe a cat to less and the user terminates the less part.&lt;/p&gt; &lt;p&gt;How many OCaml programs/programmers expect their program to silently crash when receiving a sigpipe? I bet not so many.... Back to the seventies, piping programs was an essential feature of Unix. But what about the 21st century...&lt;/p&gt; &lt;h3 class='h3 spip'&gt;End of stream&lt;/h3&gt;
&lt;p&gt;Another classic of the POSIX semantics is the way that end of streams are detected. There may not be any error or exception raised when a connection has ended. Instead, the system will simply report 0 characters read when invoking Unix.read.&lt;/p&gt; &lt;p&gt;This means that in every place where you call this function, you need to think about what should happen if the returned number is zero and raise an appropriate exception if needed.&lt;/p&gt; &lt;p&gt;This also means that any failure to do so may result in a severe bug in your application.&lt;/p&gt; &lt;h3 class='h3 spip'&gt;What now?&lt;/h3&gt;
&lt;p&gt;The reason I am writing this is that although I totally understand that a &quot;serious&quot; programming language should adequately reflect the POSIX api &#8212; after all, skilled programmers and dinosaurs expect the POSIX behaviour &#8212; it does not seem to make sense to me that this should be the only alternative.&lt;/p&gt; &lt;p&gt;What about having a global flag in the Unix module that would allow to switch to a 21 century semantics? It could not fix all the shitty POSIX aspects (like having to call select to know if a socket is ready for reading or writing) but it could at least turn on some workaround, for instance making sure an exception is raised for each sigpipe or end of stream..&lt;/p&gt; &lt;p&gt;So, fellow OCamlers, am I the only one to struggle with those issues? Do you have other similar stories to report? Do you think that OCaml should at least have a non-default behaviour that reflects 21st century concerns and not plain old seventies hippie programming?&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Dynlink as dlopen..</title>
		<link>http://blog.rastageeks.org/ocaml/article/dynlink-as-dlopen</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/dynlink-as-dlopen</guid>
		<dc:date>2011-05-13T23:18:16Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;Dear Lazyweb,&lt;/p&gt; &lt;p&gt;One big issue we constantly face with liquidsoap is that most of our users have to recompile the whole software just to have support for mp3 encoding using liblame and ocaml-lame.&lt;/p&gt; &lt;p&gt;We have been devising two different approaches with Samuel to address this issue. I would like to expose mine here, both for documentation purposes &#8212; finding documentation and examples of how to use the dynlink module is not easy &#8212; and to maybe get some feedback..&lt;/p&gt; &lt;p&gt;The whole issue with dynlink is that it is capable of loading a module at run-time but cannot expose its API to the running program. Therefore, a shared module has to be defined so that it registers some functionalities when loaded.&lt;/p&gt; &lt;p&gt;In our case, we would like to be able to activate mp3 encoding by loading the Lame module at run-time if detected. Our requirements are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We should be able to compile liquidsoap on a system which does not have ocaml-lame installed
&lt;li&gt;We would like to expose the whole ocaml-lame API once loaded dynamically
&lt;/ul&gt;
&lt;p&gt;The first requirement is important because we would like to distribute a canonical build of liquidsoap through debian for instance, so that if a user wants to dynamically load Lame, she only has to compile ocaml-lame. On the one hand, this reduces our workload by only having to work on one package and on the other hand, this the only case which makes sense.&lt;/p&gt; &lt;p&gt;Indeed, the other solution would be to compile a liquidsoap plugin against a compiled Lame module. Practically, this means that we would have to compile a liquidsoap package on a system which has lame installed. But in this case, we should simply build the sotware with lame included and forget about the shared module..&lt;/p&gt; &lt;p&gt;The second requirement is a natural consequence of the first one: if the shared module is built independently of liquidsoap, then it has to be provided by ocaml-lame. Then in this case, it should be more general than just exposing the functionalities needed by liquidsoap..&lt;/p&gt; &lt;p&gt;So, after much poking around, here is the solution I came to. I will explain it with a simple example.&lt;/p&gt; &lt;p&gt;Imagine that you have a module &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt; which has the following interface.&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;(** An abstract type for the encoder. *)&lt;br /&gt; type encoder&lt;br /&gt; &lt;br /&gt; (** A function to instanciate an encoder. *)&lt;br /&gt; val create : unit -&gt; encoder&lt;br /&gt; &lt;br /&gt; (** A function to encode. *)&lt;br /&gt; val encode : encoder -&gt; float array array -&gt; string&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;The idea here is that we want to expose the whole API and make it possible for any software to be compiled without having the module &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt; installed and still be able to dynalically load it at run-time. Therefore, we define the &lt;code class='spip_code' dir='ltr'&gt;Foo_dynlink&lt;/code&gt; interface:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;type encoder&lt;br /&gt; type encoder_handler = &lt;br /&gt; { create : unit -&gt; encoder;&lt;br /&gt; encode : encoder -&gt; float array array -&gt; string }&lt;br /&gt; type handler = { mutable encoder_handler : encoder_handler option }&lt;br /&gt; val handler : handler&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;But we do not implement the corresponding &lt;code class='spip_code' dir='ltr'&gt;.ml&lt;/code&gt; module. This &lt;code class='spip_code' dir='ltr'&gt;mli&lt;/code&gt; specifies what the program that will load dynamically &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt; will have to implement.&lt;/p&gt; &lt;p&gt;Now, we implement a loader for &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt;, called &lt;code class='spip_code' dir='ltr'&gt;Foo_loader&lt;/code&gt;:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;open Foo_dynlink&lt;br /&gt; let () = &lt;br /&gt; let create () = &lt;br /&gt; Obj.magic (Foo.create ())&lt;br /&gt; in&lt;br /&gt; let encode enc data = &lt;br /&gt; Foo.encode (Obj.magic enc) data&lt;br /&gt; in&lt;br /&gt; handler.encoder_handler &lt;- &lt;br /&gt; Some { create = create;&lt;br /&gt; encode = encode }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Here, we need to use &lt;code class='spip_code' dir='ltr'&gt;Obj.magic&lt;/code&gt; as the two abstract types &lt;code class='spip_code' dir='ltr'&gt;Foo.encoder&lt;/code&gt; and &lt;code class='spip_code' dir='ltr'&gt;Foo_dynlink.encoder&lt;/code&gt; cannot be unified: &lt;code class='spip_code' dir='ltr'&gt;Foo_dynlink&lt;/code&gt; will be implemented by the calling program, which will not have &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt; available..&lt;/p&gt; &lt;p&gt;Finally, we can now write a program that dynamically loads &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt;. It consists of at least two modules, &lt;code class='spip_code' dir='ltr'&gt;Foo_dynlink&lt;/code&gt;, which implements the corresponding interface and another module that uses it. Let's see &lt;code class='spip_code' dir='ltr'&gt;foo_dynlink.ml&lt;/code&gt; first:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;type encoder&lt;br /&gt; type encoder_handler = &lt;br /&gt; { create : unit -&gt; encoder;&lt;br /&gt; encode : encoder -&gt; float array array -&gt; string }&lt;br /&gt; type handler = { mutable encoder_handler : encoder_handler option }&lt;br /&gt; let handler = { encoder_handler = None }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Now &lt;code class='spip_code' dir='ltr'&gt;main.ml&lt;/code&gt;&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;let foo_dyn = &quot;/path/to/foo.cmxs&quot;&lt;br /&gt; let foo_loader = &quot;/path/to/foo_loader.cmxs&quot;&lt;br /&gt; &lt;br /&gt; open Foo_dynlink&lt;br /&gt; &lt;br /&gt; let () =&lt;br /&gt; (** First load Foo. *)&lt;br /&gt; Dynlink.loadfile foo_dyn;&lt;br /&gt; (** Now execute the loader. *)&lt;br /&gt; Dynlink.loadfile foo_loader;&lt;br /&gt; (** At this point, Foo_dynlink.handler should be populated. *)&lt;br /&gt; match handler.encoder_handler with&lt;br /&gt; | None -&gt; Printf.printf &quot;Dynamic loading failed..\n&quot;&lt;br /&gt; | Some _ -&gt; Printf.printf &quot;Dynamic loading succeeded!!\n&quot;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Let's try it now!&lt;/p&gt; &lt;p&gt;First. make a seperate directory for &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt;:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;mkdir /tmp/foo&lt;br /&gt; cd /tmp/foo&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Then compile the module and its loader:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;ocamlopt -c foo.mli&lt;br /&gt; ocamlopt -shared foo.ml -o foo.cmxs&lt;br /&gt; ocamlopt -c foo_dynlink.mli&lt;br /&gt; ocamlopt -shared foo_loader.ml -o foo_loader.cmxs&lt;br /&gt; # We do not need the compile interface for foo_dynlink at this point..&lt;br /&gt; rm foo_dynlink.cmi&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Now, let's prepare another directory for the main program:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;mkdir /tmp/bar&lt;br /&gt; cd /tmp/bar&lt;br /&gt; cp /tmp/foo/foo_dynlink.mli .&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;And compile it:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;ocamlopt -c foo_dynlink.mli&lt;br /&gt; ocamlopt -c foo_dynlink.ml&lt;br /&gt; ocamlopt -c main.ml&lt;br /&gt; ocamlfind ocamlopt -linkpkg -package dynlink foo_dynlink.cmx main.cmx -o bar&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Of course, the paths to &lt;code class='spip_code' dir='ltr'&gt;foo.cmxs&lt;/code&gt; and &lt;code class='spip_code' dir='ltr'&gt;foo_loader.cmxs&lt;/code&gt; in &lt;code class='spip_code' dir='ltr'&gt;main.ml&lt;/code&gt; have been changed to their actual location..&lt;/p&gt; &lt;p&gt;At this point, &lt;code class='spip_code' dir='ltr'&gt;bar&lt;/code&gt; has been compiled without any reference to &lt;code class='spip_code' dir='ltr'&gt;Foo&lt;/code&gt;. The only requirement is that it implements a module that has the interface required by &lt;code class='spip_code' dir='ltr'&gt;foo_loader.cmxs&lt;/code&gt;. Now is the time to try it!&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;./bar &lt;br /&gt; Dynamic loading succeeded!!&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;:-)&lt;/p&gt; &lt;p&gt;What do you think? Ugly or interesting?&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>A Monad for OCaml Duppy</title>
		<link>http://blog.rastageeks.org/ocaml/article/a-monad-for-ocaml-duppy</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/a-monad-for-ocaml-duppy</guid>
		<dc:date>2011-05-07T19:42:37Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;h2&gt;The context&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://www.rastageeks.org/duppy.html&quot; class='spip_out' rel='external'&gt;Duppy&lt;/a&gt; is the OCaml module that we have developped with the Savonet Team as a solution for all scheduling tasks in &lt;a href=&quot;http://savonet.sourceforge.net/&quot; class='spip_out' rel='external'&gt;Liquidsoap&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Duppy was initially intended as a nice way to create a simple scheduler that supports the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Delayed tasks, that is tasks to be exectued after a given delay&lt;/li&gt;
&lt;li&gt; Reading and writing on &lt;code class='spip_code' dir='ltr'&gt;Unix.fd&lt;/code&gt; file descriptors without blocking the calling thread
&lt;li&gt; Custom priority system whith a pool of threads running concurrent queues processing tasks according to their priorities&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For instance, for a HTTP server, a client acessing a local file such as an image, should be processed with maximum priority but a client requesting a php page should be processed with low priority, because executing a php script can potentially take a long time whereas reading from a local file is fast. Also, one php page may be using many images so serving the images faster is important to ensure a smooth data flow to the client.&lt;/p&gt; &lt;p&gt;Duppy was initially considered as a slight abstraction &#8212; namely a functional abstraction over &lt;code class='spip_code' dir='ltr'&gt;Unix.select&lt;/code&gt;, but not necessarily of a very general scope. However, I realized lately that a much more interesting use of Duppy could be done.&lt;/p&gt; &lt;h2&gt;Servers in Liquidsoap&lt;/h2&gt;
&lt;p&gt;The main use of Duppy in Liquidsoap is for implementing the various servers (telnet and harbor, our native implementation of the icecast source protocol) as well as implementing delayed tasks within the main language.&lt;/p&gt; &lt;p&gt;Concerning the server part, the code was written using exception catching as follows:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;let serve_task socket task = &lt;br /&gt; (..code for serving task..)&lt;br /&gt; if (..some condition, for instance that the task is recognized..) then&lt;br /&gt; (..code processing task..)&lt;br /&gt; raise (Answer &quot;P = NP!&quot;)&lt;br /&gt; else&lt;br /&gt; raise (Answer &quot;Invalid request&quot;)&lt;br /&gt; &lt;br /&gt; let login socket data = &lt;br /&gt; (...code checking authentication..)&lt;br /&gt; if not (..login correct..) then&lt;br /&gt; raise (Answer &quot;Wrong Authentification data&quot;) &lt;br /&gt; &lt;br /&gt; let process_client socket request = &lt;br /&gt; try&lt;br /&gt; (..parse login data..)&lt;br /&gt; (* Check login *)&lt;br /&gt; login socket data;&lt;br /&gt; (.. parse task request..)&lt;br /&gt; (* Process data *)&lt;br /&gt; serve_task socket task&lt;br /&gt; with&lt;br /&gt; | Answer s -&gt; reply s; close socket&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;When implementing a complex protocol, such as the Icecast source protocol, this allows to have very readable code, using an exception to stop the execution flow. The ultimate goal being the possibility to seperate more clearly the protocol logic from the control flow of the execution, in order to be able to proof-read the code more conveniently.&lt;/p&gt; &lt;p&gt;However, this approach has a major drawback: it messes with the semantics of exceptions, which are usually used to raise errors in OCaml.&lt;/p&gt; &lt;p&gt;Although not necessarily an issue for simple flows, in the case of protocols such as Icecast source protocol, where two totally different version of the protocol have to be supported, with different authentication schemes, etc.. this quickly became a nightmare.&lt;/p&gt; &lt;p&gt;In order to cope with the complex execution flow when using exception-based programming, it becomes necessary to add multiple type of exceptions and to catch and process them accordingly. This impacts the readability of the code very quickly, to the point where using exceptions is no longer really interesting.&lt;/p&gt; &lt;p&gt;Furthermore, OCaml does not offer the possibility to know which exceptions may be raised by a given function. which does not make it easy to verify that all possible catching cases are covered..&lt;/p&gt; &lt;h2&gt;What about a Monad!&lt;/h2&gt;
&lt;p&gt;Seperating execution flow from the computaiton logic and encapsulating side-effects are the two main advantages of using monads in functional programming. Therefore, why about implementing those using a monad!&lt;/p&gt; &lt;p&gt;Basically, processing a request from a client consists of composing computations which either return immediatly with a response or return a result to use with the next one.&lt;/p&gt; &lt;p&gt;Furthermore, we would like those computations to be implemented using the Duppy scheduler, which has great advantages for writing and reading on network sockets and also to prioritize the different steps of the computation.&lt;/p&gt; &lt;p&gt;We consider thus computations of type &lt;code class='spip_code' dir='ltr'&gt;('a,'b)t&lt;/code&gt;. A computation &lt;code class='spip_code' dir='ltr'&gt;('a,'b)t&lt;/code&gt; either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;returns a value of type &lt;code class='spip_code' dir='ltr'&gt;'a&lt;/code&gt;, which is passed to the next computation&lt;/li&gt;
&lt;li&gt;returns a value of type &lt;code class='spip_code' dir='ltr'&gt;'b&lt;/code&gt; which is sent back to the previous computation&lt;/li&gt;
&lt;/ul&gt;
This monad does the same as an exception monad, except that is is implemented using Duppy tasks.
&lt;p&gt;The main fonctions of the monad are:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;module Monad :&lt;br /&gt; sig&lt;br /&gt; (** Type representing a computation&lt;br /&gt; * which returns a value of type ['a]&lt;br /&gt; * or raises a value of type ['b] *)&lt;br /&gt; type ('a,'b) t&lt;br /&gt; &lt;br /&gt; (** [return x] create a computation that&lt;br /&gt; * returns value [x]. *)&lt;br /&gt; val return : 'a -&gt; ('a,'b) t&lt;br /&gt; &lt;br /&gt; (** [raise x] create a computation that raises&lt;br /&gt; * value [x]. *)&lt;br /&gt; val raise : 'b -&gt; ('a,'b) t&lt;br /&gt; &lt;br /&gt; (** Compose two computations.&lt;br /&gt; * [bind f g] is equivalent to:&lt;br /&gt; * [let x = f in g x] where [x]&lt;br /&gt; * has f's return type. *)&lt;br /&gt; val bind : ('a,'b) t -&gt; ('a -&gt; ('c,'b) t) -&gt; ('c,'b) t&lt;br /&gt; &lt;br /&gt; (** [&gt;&gt;=] is an alternative notation&lt;br /&gt; * for [bind] *)&lt;br /&gt; val (&gt;&gt;=) : ('a,'b) t -&gt; ('a -&gt; ('c,'b) t) -&gt; ('c,'b) t&lt;br /&gt; &lt;br /&gt; (** [catch f g] redirects values [x] raised during&lt;br /&gt; * [f]'s execution to [g]. The name suggests the&lt;br /&gt; * usual [try .. with ..] exception catching. *)&lt;br /&gt; val catch : ('a,'b) t -&gt; ('b -&gt; ('a,'c) t) -&gt; ('a,'c) t&lt;br /&gt; &lt;br /&gt; (** [=&lt;&lt;] is an alternative notation for catch. *)&lt;br /&gt; val (=&lt;&lt;) : ('b -&gt; ('a,'c) t) -&gt; ('a,'b) t -&gt; ('a,'c) t&lt;br /&gt; &lt;br /&gt; (** [run f ~return ~raise ()] executes [f] and process&lt;br /&gt; * returned values with [return] or raised values&lt;br /&gt; * with [raise]. *)&lt;br /&gt; val run : return:('a -&gt; unit) -&gt; raise:('b -&gt; unit) -&gt; ('a,'b) t -&gt; unit&lt;br /&gt; end&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Mutexes and Conditions are also implemented within the monad, but we do not describe them here.&lt;/p&gt; &lt;p&gt;Finally, there is a camlp4 syntax extension, which allows to write code using this monad in a natural syntax:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;duppy check_http x = &lt;br /&gt; if x = &quot;HTTP&quot; then&lt;br /&gt; duppy_return Http&lt;br /&gt; else&lt;br /&gt; duppy_raise Not_http&lt;br /&gt; in&lt;br /&gt; duppy_try&lt;br /&gt; check_htttp x&lt;br /&gt; with&lt;br /&gt; | Not_http -&gt; (...)&lt;/code&gt;&lt;/div&gt;
&lt;h2&gt;Priorities and I/O operations&lt;/h2&gt;
&lt;p&gt;The main advantage of the Duppy monad is the handling of priorities and I/O operations.&lt;/p&gt; &lt;p&gt;Concerning priorities, a duppy computation can be rescheduled at any time with a new priority and optionally a delay. For instance the following computation:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;duppy f x =&lt;br /&gt; duppy_do&lt;br /&gt; (..computation code..)&lt;br /&gt; with&lt;br /&gt; { priority = Slow;&lt;br /&gt; handler = h }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;When &lt;code class='spip_code' dir='ltr'&gt;f&lt;/code&gt; is called, its execution is sent to a queue processing tasks of &lt;code class='spip_code' dir='ltr'&gt;Slow&lt;/code&gt; priority.&lt;/p&gt; &lt;p&gt;Likewise, reading or writing a value from and to a &lt;code class='spip_code' dir='ltr'&gt;Unix.file_descriptor&lt;/code&gt; is very simple:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;duppy read_crlf () = &lt;br /&gt; duppy_read&lt;br /&gt; Duppy.Split &quot;\r\n&quot;&lt;br /&gt; with&lt;br /&gt; { handler = h;&lt;br /&gt; priority = Fast }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;In this code, &lt;code class='spip_code' dir='ltr'&gt;f_crlf&lt;/code&gt; is a computation that reads from a file descriptor specified in &lt;code class='spip_code' dir='ltr'&gt;handler&lt;/code&gt; until the first &lt;code class='spip_code' dir='ltr'&gt;\r\n&lt;/code&gt; marker has been seen.
It is scheduled with a &lt;code class='spip_code' dir='ltr'&gt;Fast&lt;/code&gt; priority because all read/write operations in Duppy are executed only when they will not block.&lt;/p&gt; &lt;h2&gt;Code examples&lt;/h2&gt;
&lt;p&gt;Several examples using the Duppy monad are available. The module has two examples, a telnet and a HTTP server, which can be browsed online:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://savonet.hg.sourceforge.net/hgweb/savonet/savonet/file/tip/ocaml-duppy/examples/telnet.ml&quot; class='spip_out' rel='external'&gt;Telnet server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://savonet.hg.sourceforge.net/hgweb/savonet/savonet/file/tip/ocaml-duppy/examples/http.ml&quot; class='spip_out' rel='external'&gt;HTTP server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
The monad is also used in liquidsoap, for the internal telnet server, which is very similar to the Telnet server above, but also for the harbor server, which implements the source part of the icecast protocol, and for the new &lt;code class='spip_code' dir='ltr'&gt;output.harbor&lt;/code&gt;, which implements the listener part of the icecast protocol. These two examples can also be browsed online:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://savonet.hg.sourceforge.net/hgweb/savonet/savonet/file/tip/liquidsoap/src/tools/harbor.camlp4&quot; class='spip_out' rel='external'&gt;Habor server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://savonet.hg.sourceforge.net/hgweb/savonet/savonet/file/tip/liquidsoap/src/outputs/harbor_output.camlp4&quot; class='spip_out' rel='external'&gt;Harbor output&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Difference with Lwt&lt;/h2&gt;
&lt;p&gt;The reader familiar with &lt;a href=&quot;http://ocsigen.org/lwt/manual/&quot; class='spip_out' rel='external'&gt;Lwt&lt;/a&gt; may wonder what is the difference with this module. The essential difference is that Duppy does not implement light-weight threads but rather a pool of queues picking up different tasks one by one.&lt;/p&gt; &lt;p&gt;Therefore, it allows to specify priorities for the queues and does not require that you rewrite all your code using compatible versions of the blocking functions.&lt;/p&gt; &lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Monads can be very useful in order to encapsulate specific computation flows. In this case, we have used a monad to have a notion of exception raising that is compatible with the Duppy scheduler. Eventually, this allows to write code that is easy to proof-read and that takes advantage of all advanced functionalities of the scheduler without being obscured by many irrelevant technical details..&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Liquidsoap at ON2: Test signals, October, 22-23 2010 in Berlin</title>
		<link>http://blog.rastageeks.org/liquidsoap/article/liquidsoap-at-on2-test-signals</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/liquidsoap/article/liquidsoap-at-on2-test-signals</guid>
		<dc:date>2010-09-28T02:14:05Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>debian</dc:subject>
		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;It is my pleasure to announce that the &lt;a href=&quot;http://savonet.sourceforge.net/savonet.html&quot; class='spip_out' rel='external'&gt;Savonet Team&lt;/a&gt; [&lt;a href='#nb1' class='spip_note' rel='footnote' title='http://savonet.sourceforge.net/savo...' id='nh1'&gt;1&lt;/a&gt;] will be presenting &lt;a href=&quot;http://savonet.sourceforge.net/&quot; class='spip_out' rel='external'&gt;Liquidsoap&lt;/a&gt; [&lt;a href='#nb2' class='spip_note' rel='footnote' title='http://savonet.sourceforge.net/' id='nh2'&gt;2&lt;/a&gt;] at the &lt;a href=&quot;http://wiki.sourcefabric.org/display/ON2/Home&quot; class='spip_out' rel='external'&gt;ON2: Test signals festival&lt;/a&gt; [&lt;a href='#nb3' class='spip_note' rel='footnote' title='http://wiki.sourcefabric.org/displa...' id='nh3'&gt;3&lt;/a&gt;], taking place on Friday, Oct. 22 and Saturday, Oct. 23 in Berlin, Germany.&lt;/p&gt; &lt;p&gt;We will be holding a workshop session on Friday, during which we will explain how to use Liquidsoap in many details, and a more general talk about Liquidsoap the next Saturday.&lt;/p&gt; &lt;p&gt;We are also expecting to prepare and release a second beta for the occasion, which we are planning to use during the event.&lt;/p&gt; &lt;p&gt;Any interested user or contributor to Liquidoap that is available is warmly invited to join and meet with us! The festival is free but requires to signup (see above link).&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;p&gt;[&lt;a href='#nh1' id='nb1' class='spip_note' title='Footnotes 1' rev='footnote'&gt;1&lt;/a&gt;] &lt;a href=&quot;http://savonet.sourceforge.net/savonet.html&quot; class='spip_url spip_out' rel='nofollow external'&gt;http://savonet.sourceforge.net/savo...&lt;/a&gt;&lt;/p&gt; &lt;p&gt;[&lt;a href='#nh2' id='nb2' class='spip_note' title='Footnotes 2' rev='footnote'&gt;2&lt;/a&gt;] &lt;a href=&quot;http://savonet.sourceforge.net/&quot; class='spip_url spip_out' rel='nofollow external'&gt;http://savonet.sourceforge.net/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;[&lt;a href='#nh3' id='nb3' class='spip_note' title='Footnotes 3' rev='footnote'&gt;3&lt;/a&gt;] &lt;a href=&quot;http://wiki.sourcefabric.org/display/ON2/Home&quot; class='spip_url spip_out' rel='nofollow external'&gt;http://wiki.sourcefabric.org/displa...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Liquidsoap 1.0 beta1 and 0.9.3 released!</title>
		<link>http://blog.rastageeks.org/liquidsoap/article/liquidsoap-1-0-beta1-and-0-9-3</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/liquidsoap/article/liquidsoap-1-0-beta1-and-0-9-3</guid>
		<dc:date>2010-09-11T01:38:54Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>debian</dc:subject>
		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;We have finally released two new versions of &lt;a href=&quot;http://savonet.sf.net/&quot; class='spip_out' rel='external'&gt;Liquidsoap&lt;/a&gt; [&lt;a href='#nb1' class='spip_note' rel='footnote' title='http://savonet.sf.net/' id='nh1'&gt;1&lt;/a&gt;]!&lt;/p&gt; &lt;p&gt;This is a very good news for the project because the 1.0 branch contains huge and exciting improvements in particular video support, dynamic source creation/destruction and support for different clocks/time flow.
1.0 beta is also the first release that runs natively on windows, when compiled using the &lt;a href=&quot;https://fedoraproject.org/wiki/Features/Windows_cross_compiler&quot; class='spip_out' rel='external'&gt;ocaml cross-compiler&lt;/a&gt; [&lt;a href='#nb2' class='spip_note' rel='footnote' title='https://fedoraproject.org/wiki/Feat...' id='nh2'&gt;2&lt;/a&gt;].&lt;/p&gt; &lt;p&gt;1.0 is still some time away but the beta is now considered solid enough to be considered for production. That's also where bugfixing will happen now.&lt;/p&gt; &lt;p&gt;0.9.3 is a bugfix release for 0.9.2 and will be the last 0.9.x release.&lt;/p&gt; &lt;p&gt;The release also includes a bunch of new binding releases, namely:&lt;/p&gt; &lt;ul class=&quot;spip&quot;&gt;&lt;li&gt; ocaml-alsa: added resume and recover function, reworked exception handling&lt;/li&gt;&lt;li&gt; ocaml-cry: removed an extra crlf sent when using icecast source protocol&lt;/li&gt;&lt;li&gt; ocaml-dtools: added support for syslog&lt;/li&gt;&lt;li&gt; ocaml-duppy: minor win32 fixes..&lt;/li&gt;&lt;li&gt; ocaml-gavl: fixed Gc issue.&lt;/li&gt;&lt;li&gt; ocaml-mad: win32-related fixes.&lt;/li&gt;&lt;li&gt; ocaml-ogg: stricter parsing of ogg streams&lt;/li&gt;&lt;li&gt; ocaml-theora: support for theora 1.1 API&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The custom debian packages have been updated for 0.9.3. For the beta, you can try the SVN daily package [&lt;a href='#nb3' class='spip_note' rel='footnote' title='the automatic build needs to be fixed, the cron script does not work now (...)' id='nh3'&gt;3&lt;/a&gt;]&lt;/p&gt; &lt;p&gt;Official Debian packages should come, but through experimental while squeeze is frozen..&lt;/p&gt; &lt;p&gt;The release notes and changelog can be read in the &lt;a href=&quot;https://sourceforge.net/mailarchive/message.php?msg_name=AANLkTikUzWq0Y2-9%3DwcONYwkYmj8wx_PtyfuSzKge6h3%40mail.gmail.com&quot; class='spip_out' rel='external'&gt;announcement mail&lt;/a&gt; [&lt;a href='#nb4' class='spip_note' rel='footnote' title='https://sourceforge.net/mailarchive...' id='nh4'&gt;4&lt;/a&gt;].&lt;/p&gt; &lt;p&gt;Yeah!&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;p&gt;[&lt;a href='#nh1' id='nb1' class='spip_note' title='Footnotes 1' rev='footnote'&gt;1&lt;/a&gt;] &lt;a href=&quot;http://savonet.sf.net/&quot; class='spip_url spip_out' rel='nofollow external'&gt;http://savonet.sf.net/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;[&lt;a href='#nh2' id='nb2' class='spip_note' title='Footnotes 2' rev='footnote'&gt;2&lt;/a&gt;] &lt;a href=&quot;https://fedoraproject.org/wiki/Features/Windows_cross_compiler&quot; class='spip_url spip_out' rel='nofollow external'&gt;https://fedoraproject.org/wiki/Feat...&lt;/a&gt;&lt;/p&gt; &lt;p&gt;[&lt;a href='#nh3' id='nb3' class='spip_note' title='Footnotes 3' rev='footnote'&gt;3&lt;/a&gt;] the automatic build needs to be fixed, the cron script does not work now for some reasons although it is perfectly fine manually..&lt;/p&gt; &lt;p&gt;[&lt;a href='#nh4' id='nb4' class='spip_note' title='Footnotes 4' rev='footnote'&gt;4&lt;/a&gt;] &lt;a href=&quot;https://sourceforge.net/mailarchive/message.php?msg_name=AANLkTikUzWq0Y2-9%3DwcONYwkYmj8wx_PtyfuSzKge6h3%40mail.gmail.com&quot; class='spip_url spip_out' rel='nofollow external'&gt;https://sourceforge.net/mailarchive...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Mingw32-ocaml 3.12.0</title>
		<link>http://blog.rastageeks.org/ocaml/article/mingw32-ocaml-3-12-0</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/mingw32-ocaml-3-12-0</guid>
		<dc:date>2010-08-11T23:02:54Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>debian</dc:subject>
		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;An updated version of the &lt;a href=&quot;http://packages.qa.debian.org/m/mingw32-ocaml.html&quot; class='spip_out' rel='external'&gt;ocaml cross-compiler package&lt;/a&gt;, based on ocaml 3.12.0, has just been uploaded to Debian experimental !&lt;/p&gt; &lt;p&gt;Any report and test on the package would be very welcome ! I have personally tested it with &lt;a href=&quot;http://savonet.sf.net/&quot; class='spip_out' rel='external'&gt;Liquidsoap&lt;/a&gt; and built a &lt;a href=&quot;http://www.rastageeks.org/~toots/liq-win32/&quot; class='spip_out' rel='external'&gt;win32 version&lt;/a&gt; of the software.&lt;/p&gt; &lt;p&gt;Since this build implies many external modules as well as C objects, I am pretty confident in the cross-compiler uploaded to experimental..&lt;/p&gt; &lt;p&gt;&lt;strong&gt;About the cross-compiler:&lt;/strong&gt; the ocaml cross-compiler is the result of the hard work done by &lt;a href=&quot;http://rwmj.wordpress.com/&quot; class='spip_out' rel='external'&gt;Richard Jones&lt;/a&gt; for &lt;a href=&quot;https://fedoraproject.org/wiki/Features/Windows_cross_compiler&quot; class='spip_out' rel='external'&gt;Fedora&lt;/a&gt;. The Debian package is merely a backport (and adaptation to ocaml 3.12.0) of his patches.&lt;/p&gt; &lt;p&gt;If you care about the future of the cross-compiler, the best you can do is work with upstream to find how to push the needed changes there in order to have a plain support for it.&lt;/p&gt; &lt;p&gt;I have personally no time for starting this process but I could try to describe the patches to an intereste contributor. Warning: some are REALLY hacky :-)&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>I have a dream...</title>
		<link>http://blog.rastageeks.org/other/article/i-have-a-dream</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/other/article/i-have-a-dream</guid>
		<dc:date>2010-06-21T21:22:49Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>debian</dc:subject>
		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;I have a dream that one day, serious programming language theoriticians, which would gather and realize that LaTeX has done a great job but is basically just a pile of rewriting rules built on top of postscript.&lt;/p&gt; &lt;p&gt;I have a dream that one day, one would get the fundings and rewrite from scratch a new &lt;strong&gt;language&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;A language with a clear syntax for describing the beautification constraints.&lt;/p&gt; &lt;p&gt;A language which would also be flexible enough to be able to override those constraints.&lt;/p&gt; &lt;p&gt;A language that would allow to write mathematic formula, macros and other tools without arcane tricks and hacks to obtain the required rending....&lt;/p&gt; &lt;p&gt;And much more...&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="en">
		<title>Private records in OCaml</title>
		<link>http://blog.rastageeks.org/ocaml/article/private-records-in-ocaml</link>
		<guid isPermaLink="true">http://blog.rastageeks.org/ocaml/article/private-records-in-ocaml</guid>
		<dc:date>2010-06-15T00:23:43Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>en</dc:language>
		<dc:creator>Toots</dc:creator>


		<dc:subject>ocaml</dc:subject>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;In &lt;a href=&quot;http://ocaml.janestreet.com/?q=node/59&quot; class='spip_out' rel='external'&gt;Private type abbreviations, what are they good for?&lt;/a&gt; [&lt;a href='#nb1' class='spip_note' rel='footnote' title='http://ocaml.janestreet.com/?q=node/59' id='nh1'&gt;1&lt;/a&gt;] and then in &lt;a href=&quot;http://ocaml.janestreet.com/?q=node/77&quot; class='spip_out' rel='external'&gt;Another use for private type abbreviations&lt;/a&gt; [&lt;a href='#nb2' class='spip_note' rel='footnote' title='http://ocaml.janestreet.com/?q=node/77' id='nh2'&gt;2&lt;/a&gt;], yminsky wrote about the use of private type in OCaml.&lt;/p&gt; &lt;p&gt;Among the various proposed examples, the idea of read-only value was mentioned in the second post. I may have not followed the whole discussion after this, but I came on to an example in ocaml-ao today.&lt;/p&gt; &lt;p&gt;In ao, a driver is handled with an int, its id. It also has several read-only values, name, short_name etc..&lt;/p&gt; &lt;p&gt;Using a private record, it is possible to create a driver type this way:&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;(** Driver type (private). *)&lt;br /&gt; type driver_t = private&lt;br /&gt; { id : int ;&lt;br /&gt; kind : driver_kind_t ;&lt;br /&gt; short_name : string ;&lt;br /&gt; name : string ;&lt;br /&gt; comment : string ;&lt;br /&gt; author : string ;&lt;br /&gt; priority : int ;&lt;br /&gt; preferred_byte_format : byte_format_t ;&lt;br /&gt; options : string list&lt;br /&gt; }&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;That way, one can access directly the fields of the record without being able to write a fresh one. In our case for instance, we then make sure that the id field, used when opening a device, is always a valid entry.&lt;/p&gt; &lt;p&gt;Another suggested use was, for bindings, when you have an extra internal field, like a state represented by a C void pointer. In this case, you may declare an object with n+1 element in the C function an only export the n first one as a private record type.. Its a bit hacky but it may be useful as well...&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;p&gt;[&lt;a href='#nh1' id='nb1' class='spip_note' title='Footnotes 1' rev='footnote'&gt;1&lt;/a&gt;] &lt;a href=&quot;http://ocaml.janestreet.com/?q=node/59&quot; class='spip_url spip_out' rel='nofollow external'&gt;http://ocaml.janestreet.com/?q=node/59&lt;/a&gt;&lt;/p&gt; &lt;p&gt;[&lt;a href='#nh2' id='nb2' class='spip_note' title='Footnotes 2' rev='footnote'&gt;2&lt;/a&gt;] &lt;a href=&quot;http://ocaml.janestreet.com/?q=node/77&quot; class='spip_url spip_out' rel='nofollow external'&gt;http://ocaml.janestreet.com/?q=node/77&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>



</channel>

</rss>
