Tooling is Awesome
A quick note about my current OCaml setup, in my last
First, I use Oasis to manage and
build the project. It relies on OCamlbuild, but brings in several niceties:
- automatic generation of configure and Makefile files.
- it deals with sub-libraries, and the configure script can enable or
disable the build of each sub-library.
- it builds and runs my tests. Yay!
Oh dear. Merlin has improved
my workflow with OCaml so much that I can't imagine working without it now.
I can use it with Vim, but it also works for emacs users, so everyone is happy.
The basics features I use are the ability
to ask for the type of any expression (cursor
on it, then \t), and the omni-completion of functions and modules
in the same project or from (ocamlfind) libraries.
Incidentally, my vim setup includes a file ~/.vim/after/ftplugin/ocaml.vim
au filetype ocaml :setlocal comments=sr:(*,m1:\ ,e:*)
au filetype ocaml :nmap <leader>d :MerlinDestruct<CR>
au filetype ocaml :nmap <leader>r :MerlinRename
au filetype ocaml :syn sync maxlines=1500
The two middle lines are key bindings:
- map \d to :MerlinDestruct, which decomposes
variables into constructors in pattern matches.
- map \r to :MerlinRename, to easily change the name of functions
or variables (yes, it's better than a regex, because it knows about scoping).
The Makefile contains a target make watch that will loop forever, watching
for changes in .ml files to recompile. It looks like this (careful,
use tabs, as always with Makefiles):
while find src/ -print0 | \
xargs -0 inotifywait -e delete_self -e modify ;\
echo "============ at `date` ==========" ; \
make ; \
Well, that's it. I also use some other things, including
of course Opam
I will post something about the internals of Nunchaku
some day, it has a cool 5-arguments GADT ;-)
OCaml Compiler Hacking: how to add a primitive
I have been hacking on the OCaml compiler recently; in particular, I added
some support for coloring warning/error messages.
At some point during the discussion over this pull request, it became clear
that colored output should only be enabled if stderr was an interactive
terminal (in opposition to a ...
Simple Refinements Types for OCaml
For more than one year, vulnerabilies in software (especially pervasive C software)
have been disclosed at an alarmingly high rate. I love OCaml, which is definitely
safer, but still has gaps left open. I believe formal verification, albeit
a very powerful tool, is not mature enough for most programmers (too ...
Introduction to Automated Theorem Proving with Logtk
My PhD work is centered around
automated theorem proving
in first-order logic.
This is obviously a very cool topic (otherwise I wouldn't have focused on it),
so this post is a crash course (but the program won't crash because
I use OCaml) on one of the most classic ...
Batch Operations on Collections
Some very common (and useful) operations, including the classic
map, filter, and flat_map, traverse their whole argument
and return another collection. When several such operations are composed,
intermediate collections will be created and become useless immediately
after. Languages like Haskell sometimes perform optimizations
that merge together the operations so as ...
Representing Lazy Values
A quick survey of Lazy in OCaml
I remember having heard that Jane Street
had its own implementation of Lazy values, and that it was faster
than the standard one. So I played a bit with several ways of
managing lazy values in OCaml.
Definition of Lazy implementations
First we ...
Universal Serialization and Deserialization
TL;DR: combinators and GADTs allow to describe types in abstract enough
a way that they can be converted into/from various serialization
Edit: the code is now available in its own repository
on github, and
on my opam repository
under the name CConv. Optional interfaces to Yojson, Sexplib ...
QuickCheck for OCaml
I've written, and am using, an
OCaml module (see the documentation) that is
heavily inspired from Haskell's QuickCheck. Note: I will make
an extensive use of the convenient notation
that evaluates the expression in the scope of the module. It's
one of those features ...
I've recently read an interesting article
which shows an example of concurrency implemented in 3 differenet languages,
namely Go, Erlang and C++. While the Erlang and Go examples seemed clear and
concise, the C++ one looks long and hard to understand. The reason behind this
complexity is that C ...
... is how you were born