<?xml version="1.0" encoding="UTF-8"?>


  <feed xmlns="http://www.w3.org/2005/Atom">
     
     <id>http://www.ocamlpro.com/atom/</id><title>OCamlPro's atom feed</title><rights>All rights reserved by the author</rights><updated>2011-05-06T00:00:00Z</updated>
     <contributor><name>Fabrice Le Fessant</name><uri>http://fabrice.lefessant.net/</uri><email>fabricel@ocamlpro.com</email></contributor><contributor><name>Thomas Gazagnaire</name><uri>http://gazagnaire.org</uri><email>thomas@ocamlpro.com</email></contributor>
     
  <entry>
    <id>http://www.ocamlpro.com/blog/2011/05/06/longval.html</id><title>OCaml 32bits longval</title><author><name>Thomas Gazagnaire</name><uri>http://gazagnaire.org</uri><email>thomas@ocamlpro.com</email></author><rights>All rights reserved by the author</rights><updated>2011-05-06T00:00:00Z</updated>
    
    
  <content type="xhtml">
   <div xmlns="http://www.w3.org/1999/xhtml">
      <p>Archive: <a href="http://www.ocamlpro.com//files/ocaml-3.11.2-longval-byte-i686.tar.bz2">ocaml-3.11.2-longval-byte-i686.tar.bz2</a></p><p>You will need OCaml 3.11.2 installed on a i686 linux computer. The archive contains:</p><ul> <li> <p>libcamlrun-linux-i686.a</p> </li><li> <p>ocamlrun-linux-i686</p> </li><li> <p>Makefile</p> </li><li> <p>README</p> </li> </ul><p>The Makefile has two targets:</p><ul> <li> <p><b>sudo make install</b> will save <i>/usr/bin/ocamlrun</i> and <i>/usr/lib/ocaml/libcamlrun.a</i> in the current directory and replace them with the longval binaries.</p> </li><li> <p><b>sudo make restore</b> will restore the saved files.</p> </li> </ul><p>If your install directories are not the default ones, you should modify the Makefile.  After installing, you can test it with the standard OCaml top-level:</p><pre><code># ocaml
        Objective Caml version 3.11.2

# let s = ref &quot;&quot;;;
val s : string ref = {contents = &quot;&quot;}

# s := String.create 20_000_000;;
- : unit = ()
</code></pre><p>Now you can enjoy big values in all your strings and arrays in bytecode. You will need to relink all your custom binaries. If you are interested in the native version of the longval compiler, you can <a href="http://www.ocamlpro.com//contact.html">contact</a> us.</p> 
   </div>
  </content>

  </entry>

  <entry>
    <id>http://www.ocamlpro.com/blog/2011/06/03/cheatsheets.html</id><title>OCaml Cheat Sheets</title><author><name>Fabrice Le Fessant</name><uri>http://fabrice.lefessant.net/</uri><email>fabricel@ocamlpro.com</email></author><rights>All rights reserved by the author</rights><updated>2011-06-03T00:00:00Z</updated>
    
    
  <content type="xhtml">
   <div xmlns="http://www.w3.org/1999/xhtml">
      <p>When you are beginning in a new programming language, it is sometimes helpful to have an overview of the documentation, that you can pin on your wall and easily have a look at it while you are programming. Since we couldn't find such <b>Cheat Sheets</b>, we decided to start writting our own cheat sheets for OCaml.</p><p>Beware, these documents are drafts, that we plan to improve in the next months. In the meantime, feel free to tell us how we could improve them, what is missing, and where the focus should be !</p><ul> <li> <p><a href="http://www.ocamlpro.com//files/ocaml-lang.pdf">The OCaml Language</a> (June 8, 2011)</p> </li><li> <p><a href="http://www.ocamlpro.com//files/ocaml-tools.pdf">OCaml Standard Tools</a> (June 7, 2011)</p> </li><li> <p><a href="http://www.ocamlpro.com//files/ocaml-stdlib.pdf">OCaml Standard Library</a>  (June 7, 2011)</p> </li><li> <p><a href="http://www.ocamlpro.com//files/tuareg-mode.pdf">OCaml Emacs Mode (Tuareg)</a> (June 27, 2011)</p> </li> </ul> 
   </div>
  </content>

  </entry>

  <entry>
    <id>http://www.ocamlpro.com/blog/2011/06/23/ocaml-mscv-win64.html</id><title>OCaml and Windows</title><author><name>Thomas Gazagnaire</name><uri>http://gazagnaire.org</uri><email>thomas@ocamlpro.com</email></author><rights>All rights reserved by the author</rights><updated>2011-06-23T00:00:00Z</updated>
    
    
  <content type="xhtml">
   <div xmlns="http://www.w3.org/1999/xhtml">
      <p>Recently, I have been experimenting wiht OCaml / MSVC running on Windows 7 64bit. I have mainly followed what the <a href="http://caml.inria.fr/pub/distrib/ocaml-3.12/notes/README.win32">OCaml's README.win32</a> was saying and I learned some NSIS tricks. The result of this experiment is the following two (rather big) windows binaries :</p><ul> <li> <p><a href="http://www.ocamlpro.com//files/ocaml-trunk-64-installer.exe">ocaml-trunk-64-installer.exe</a> (92 MB)</p> </li><li> <p><a href="http://www.ocamlpro.com//files/ocaml-3.12-64-installer.exe">ocaml-3.12-64-installer.exe</a> (92 MB)</p> </li> </ul><p>These binaries are auto-installer for :</p><ul> <li> <p>the OCaml distribution (either the 3.12.1+rc1 version or trunk);</p> </li><li> <p>Emacs (version 23.3) + tuareg mode (version 2.0.4);</p> </li><li> <p>OCamlGraph (version 1.7) : this is just a little experiment with packaging external libraries.</p> </li> </ul><p>Hopefully, all of this might be useful to some people, at least to people looking for an alternative to WinOcaml which seems to be broken. You should need no other dependencies if you just want to use the OCaml top-level (ocaml.exe). If you want to compile your project you will need MSVC installed and correctly set-up. If your project is using Makefiles then you should probably install cygwin as well. I can give more details if some people are interested.</p><p>Unfortunately, the current process for creating these binaries involves an awlful lot of manual steps (including switching for Windows Termninal to cygwin shell) and further, many OCaml packages won't install directly on windows (as most of them are using shell tricks to be configured correctly). I hope we will be able to release something cleaner in a later stage.</p> 
   </div>
  </content>

  </entry>

  <entry>
    <id>http://www.ocamlpro.com/blog/2011/08/10/ocaml-pack-functors.html</id><title>Packing and Functors</title><author><name>Fabrice Le Fessant</name><uri>http://fabrice.lefessant.net/</uri><email>fabricel@ocamlpro.com</email></author><rights>All rights reserved by the author</rights><updated>2011-08-10T00:00:00Z</updated>
    
    
  <content type="xhtml">
   <div xmlns="http://www.w3.org/1999/xhtml">
      <p>We have recently worked on modifying the OCaml system to be able to pack a set of modules within a functor, parameterized on some signatures. This page presents this work, funded by Jane Street.</p><p>All the patches on this page are provided for OCaml version 3.12.1.</p><h1>Packing Functors</h1><h2>Installation of the modified OCaml system</h2><p>The patch for OCaml 3.12.1 is available here:</p><p><a href="http://www.ocamlpro.com//files/ocaml+libfunctor-3.12.1.patch.gz">ocaml+libfunctor-3.12.1.patch.gz</a> (26 kB)</p><p>To use it, you can use the following recipe, that will compile and install the patched version in ~/ocaml+libfunctor-3.12.1/bin/.</p><pre><code>~%  wget http://caml.inria.fr/pub/distrib/ocaml-3.12/ocaml-3.12.1.tar.gz
~%  tar zxf ~/ocaml-3.12.1.tar.gz
~%  cd ocaml-3.12.1
~/ocaml-3.12.1%  wget www.ocamlpro.com/code/ocaml+libfunctor-3.12.1.patch.gz
~/ocaml-3.12.1%  gzip -d ocaml+libfunctor-3.12.1.patch.gz
~/ocaml-3.12.1%  patch -p1 &lt; ocaml+libfunctor-3.12.1.patch
~/ocaml-3.12.1%  ./configure --prefix ~/ocaml+libfunctor-3.12.1
~/ocaml-3.12.1%  make coldstart
~/ocaml-3.12.1%  make ocamlc ocamllex ocamltools
~/ocaml-3.12.1%  make library-cross
~/ocaml-3.12.1%  make bootstrap
~/ocaml-3.12.1%  make all opt opt.opt
~/ocaml-3.12.1%  make install
~/ocaml-3.12.1%  cd ~
~% export PATH=$HOME/ocaml+libfunctor-3.12.1/bin:$PATH
</code></pre><p>Note that it needs to bootstrap the compiler, as the format of object files is not compatible with the one of ocaml-3.12.1.</p><h2>Usage of the lib-functor patch.</h2><p>Now that you are equiped with the new system, you can start using it. The lib-functor patch adds two new options to the compilers <b>ocamlc</b> and <b>ocamlopt</b>:</p><ul> <li> <p><b>-functor &lt;interface_file&gt;</b> : this option is used to specify that the current module is compiled with the interface files specifying the argument of the functor. This option should be used together with <b>-for-pack &lt;module&gt;</b>, where <b>&lt;module&gt;</b> is the name of the module in which the current module will be embedded.</p> </li><li> <p><b>-pack-functor &lt;module&gt;</b> : this option is used to pack the modules. It should be used with the option <b>-o &lt;object_file&gt;</b> to specify in which module it should be embedded. The <b>&lt;module&gt;</b> specified with <b>-pack-functor</b> specifies the name of functor that will be created in the target object file.</p> </li> </ul><p>If the interface <code>x.mli</code> contains :</p><pre><code>type t
val compare : t -&gt; t -&gt; int
</code></pre><p>and the files <code>xset.ml</code> and <code>xmap.ml</code> contain respectively :</p><pre><code>(* xset.ml *)
module T = Set.Make(X)

(* xmap.ml *)
module T = Map.Make(X)
</code></pre><p>Then :</p><pre><code>~/test%  ocamlopt -c -for-pack Xx -functor x.cmi xset.ml
~/test%  ocamlopt -c -for-pack Xx -functor x.cmi xmap.ml
~/test%  ocamlopt -pack-functor MakeSetAndMap  -o xx.cmx xset.cmx xmap.cmx
</code></pre><p>will construct a compiled unit whose signature is (that you can get with <code>ocamlopt -i xx.cmi</code>, see below) :</p><pre><code>module MakeSetAndMap :
  functor (X : sig type t val compare : t -&gt; t -&gt; int end) -&gt;
    sig
      module Xset :
        sig
          module T :
            sig
              type elt = X.t
              type t = Set.Make(X).t
              val empty : t
              val is_empty : t -&gt; bool
              ...
            end
        end
      module Xmap :
        sig
          module T :
            sig
              type key = X.t
              type 'a t = 'a Map.Make(X).t
              val empty : 'a t
              val is_empty : 'a t -&gt; bool
              ...
            end
        end
    end
</code></pre><h2>Other extension: printing interfaces</h2><p>OCaml only allows you to print the interface of a module or interface by compiling its source with the <b>-i</b> option. However, you don't always have the source of an object interface (in particular, if it was generated by packing), and you might still want to do it.</p><p>In such a case, the lib-functor patch allows you to do that, by using the <b>-i</b> option on an interface object file:</p><pre><code>~/test%  cat &gt; a.mli
val x : int
~/test%  ocamlc -c -i a.mli
val x : int
~/test%  ocamlc -c -i a.cmi
val x : int
</code></pre><h2>Other extension: packing interfaces</h2><p>OCaml only allows you to pack object files inside another object file (.cmo or .cmx). When doing so, you can either provide an source interface (.mli) that you need to compile to provide the corresponding object interface (.cmi), or the object interface will be automatically generated by exporting all the sub-modules within the packed module.</p><p>However, sometimes, you would want to be able to specify the interfaces of each module separately, so that:</p><ul> <li> <p>you can reuse most  of the interfaces you already specified</p> </li><li> <p>you can use a different interface for a module, that the one used to compile the other modules. This happens when you want to export more values to the other internal sub-modules than you want to export to the user.</p> </li> </ul><p>In such a case, the lib-functor patch allows you to do that, by using the <b>-pack</b> option on interface object files:</p><pre><code>test%  cat &gt; a.mli
val x : int
test%  cat &gt; b.mli
val y : string
test%  ocamlc -c a.mli b.mli
test%  ocamlc -pack -o c.cmi a.cmi b.cmi
test%  ocamlc -i c.cmi
module A : sig val x : int end
module B : sig val y : string end
</code></pre><h1>Using <b>ocp-pack</b> to pack source files</h1><h2>Installation of ocp-pack</h2><p>Download the source file from:</p><ul> <li> <p><a href="http://www.ocamlpro.com//files/ocp-pack-1.0.1.tar.gz">ocp-pack-1.0.1.tar.gz</a> (20 kB, GPL Licence, Copyright OCamlPro SAS)</p> </li> </ul><p>Then, you just need to compile it with:</p><pre><code>~%  tar zxf ocp-pack-1.0.1.tar.gz
~%  cd ocp-pack-1.0.1
~/ocp-pack-1.0.1%  make
~/ocp-pack-1.0.1%  make install
</code></pre><h2>Usage of ocp-pack</h2><p><b>ocp-pack</b> can be used to pack source files of modules within just one source file. It allows you to avoid the use of the <b>-pack</b> option, that is not always supported by all ocaml tools (for example, ocamldoc). Moreover, <b>ocp-pack</b> tries to provide the correct locations to the compiler, so errors are not reported within the generated source file, but within the original source files.</p><p>It supports the following options:</p><pre><code>%  ocp-pack -help
Usage:

  ocp-pack -o target.ml [options] files.ml*

Options:
  -o &lt;filename.ml&gt;         generate filename filename.ml
  -rec                     use recursive modules
                           all .ml files must have a corresponding .mli file
  -pack-functor &lt;modname&gt;  create functor with name &lt;modname&gt;
  -functor  &lt;filename.mli&gt; use filename as an argument for functor
  -mli                     output the .mli file too
                           .ml files without .mli file will not export any value
  -no-ml                   do not output the .ml file
  -with-ns                 use directory structure to create a hierarchy of modules
  -v                       increment verbosity
  --version                display version information
</code></pre><p><b>ocp-pack</b> automatically detects interface sources and implementation sources. When only the interface source is available, it is assumed that it is a type-only module, i.e. no <b>val</b> items are present inside.</p><p>Here is an example of using <b>ocp-pack</b> to build the ocamlgraph package:</p><pre><code>test%  ocp-pack -o graph.ml \
  lib/bitv.ml  lib/heap.ml  lib/unionfind.ml \
  src/sig.mli src/dot_ast.mli src/sig_pack.mli \
  src/version.ml src/util.ml src/blocks.ml \
  src/persistent.ml src/imperative.ml  src/delaunay.ml \
  src/builder.ml src/classic.ml src/rand.ml src/oper.ml \
  src/path.ml src/traverse.ml src/coloring.ml src/topological.ml \
  src/components.ml src/kruskal.ml src/flow.ml  src/graphviz.ml \
  src/gml.ml src/dot_parser.ml src/dot_lexer.ml src/dot.ml \
  src/pack.ml  src/gmap.ml src/minsep.ml src/cliquetree.ml \
  src/mcs_m.ml src/md.ml src/strat.ml
test%  ocamlc -c graph.ml
test%  ocamlopt -c graph.ml
</code></pre><p>The <b>-with-ns</b> option can be used to automatically build a hierarchy of modules. With that option, sub-directories are seen as sub-modules. For example, packing <b>a/x.ml</b>, <b>a/y.ml</b> and <b>b/z.ml</b> will give a result like:</p><pre><code>module A = struct
  module X = struct ... end
  module Y = struct ... end
end
module B = struct
  module Z = struct ... end
end
</code></pre><h2>Packing modules as functors</h2><p>The <b>-pack-functor</b> and <b>-functor</b> options provide the same behavior as the same options with the lib-functor patch. The only difference is that <b>-functor</b> takes the interface source as argument, not the interface object.</p><h2>Packing recursive modules</h2><p>When trying to pack modules with <b>ocp-pack</b>, you might discover that your toplevel modules have recursive dependencies. This is usually achieved by types declared abstract in the interfaces, but depending on each other in the implementations. Such modules cannot simply packed by <b>ocp-pack</b>.</p><p>To handle them, <b>ocp-pack</b> provides a <b>-rec</b> option. With that option, modules are put within a <b>module rec</b> construct, and are all required to be accompagnied by an interface source file.</p><p>Moreover, in many cases, OCaml is not able to compile such recursive modules:</p><ul> <li> <p>For typing reasons: recursive modules are typed in an environment containing only an approximation of other recursive modules signatures</p> </li><li> <p>For code generation reasons: recursive modules can be reordered depending on their shape, and this reordering can generate an order that is actually not safe, leading to an exception at runtime</p> </li> </ul><p>To solve these two issues in most cases, you can use the following patch (you can apply it using the same recipe as for lib-functor, and even apply both patches on the same sources):</p><ul> <li> <p><a href="http://www.ocamlpro.com//files/ocaml+rec-3.12.1.patch.gz">ocaml+rec-3.12.1.patch.gz</a></p> </li> </ul><p>With this patch, recursive modules are typed in an environment that is enriched progressively with the final types of the modules as soon as they become available. Also, during code generation, a topological order is computed on the recursive modules, and the subset of modules that can be initialized using in that topological order are immediatly generated, leaving only the other modules to be reordered.</p> 
   </div>
  </content>

  </entry>

  </feed>


