OCaml Weekly News
Hello
Here is the latest OCaml Weekly News, for the week of December 11 to 18, 2018.
Table of Contents
- Build-/Installation-Tools - not enough of them?
- PyTorch bindings
- LablGtk 3.0.beta2 and LablGtk 2.18.7
travesty
, monadic traversals, state monads, and suchlike on top of Core's monads- Some feedback on teaching with jbuilder as a build tool
- Blog post: A new general computation model for Dune
- Ppxlib 0.4.0
- opam 2.0.2!
- Ocaml Github Pull Requests
- Other OCaml News
- Old CWN
Build-/Installation-Tools - not enough of them?
Deep in this thread, SP said
Reading this discussion inspired me to write this:
https://notes.orbitalfox.eu/distributing-software.html
I hope it helps. It doesn't cover all the points raised here. Any constructive remarks are welcome.
PyTorch bindings
Laurent Mazare announced
We are very pleased to announce the first release of our PyTorch bindings for ocaml. These bindings provide a NumPy like tensor library with GPU acceleration and support for automatic differentiation.
The torch
package can be installed via opam. More details can be found in the github repo, including a tutorial training some neural networks on the MNIST dataset, various deep-learning examples: Generative Adverserial Networks, Neural Style Transfer, state of the art computer vision models on CIFAR-10, etc. Pre-trained weights for some recent computer vision models are also provided.
Any feedback is very welcome. Hopefully we will write a couple new tutorials to describe the current examples and add more examples in the next few weeks.
(note that the tensorflow
package providing TensorFlow bindings also has been updated this week and is now up to speed with the github repo)
LablGtk 3.0.beta2 and LablGtk 2.18.7
Jacques Garrigue announced
Here is a new release of Lablgtk 2 and 3. There are only a few bug fixes and improvements, but this should provide a better basis for packagers.
They are available for download at the usual location:
http://lablgtk.forge.ocamlcore.org
https://forge.ocamlcore.org/frs/download.php/1774/lablgtk-3.0.beta2.tar.gz
https://forge.ocamlcore.org/frs/download.php/1773/lablgtk-2.18.7.tar.gz
The code and bug reports are on GitHub
https://github.com/garrigue/lablgtk
https://github.com/garrigue/lablgtk/tree/lablgtk3 (for the lablgtk3 branch)
travesty
, monadic traversals, state monads, and suchlike on top of Core's monads
Matt Windsor announced
My first OPAM package, travesty
, is now in the repository :tada:
What is it?
Travesty is (yet another :upside_down_face:) implementation of monadic traversals (similar to Haskell's Traversable
typeclass), state monads and transformers, and several other container and monad extensions. Though it's nowhere near as comprehensive as, say, BAP's monads library, it sits on top of Core_kernel
's existing Monad
and Container
infrastructure and tries to use similar conventions where possible.
Travesty specifically includes:
- a
Mappable
signature set that captures ~map~ping over arity-0 and arity-1 types (what Haskell would call a functor); - a
Traversable
signature set that describesmap_m
, a generalisation ofmap
to Core-style monads similar to Haskell's traverse; - an implementation of state transformers over Core monads, and standalone state monads;
- some functors for deriving Core-style
Container~s from types with monadic traversals (since ~map_m
over a state monad can derivefold
); - various helper functions for building
map_m
over Fieldslib and Variantslib derived operations; - a
Singleton
container, which lifts a single value into a traversable container; - miscellaneous extensions for Core containers, and specific extensions for
list
andoption
.
Travesty is MIT licenced.
Caveat emptor: Travesty is still in pre-release (v0.1.2
at time of writing). This is because I very much expect to make breaking changes to the API. Now that it's on OPAM
, I'll try to keep any pre-v1
breaking changes to minor version increments, but nonetheless here be dragons.
Why does this exist?
Travesty is a spin-off from some other work I've been doing, where the same monadic concepts kept recurring over and over again, and eventually accumulated in a utils
module. I figured that it might be useful for other Core
-style projects, so I spun it out.
(To be honest, I didn't notice BAP's monads library until after I'd done so :scream: , though I feel like Travesty has a niche for being a more 'Core
-ish' library.)
Is there documentation?
Autogenerated API documentation is here — for now, I've tried to make it comprehensive in terms of describing signatures, but it's missing examples and usage information. I'm also new to odoc
, so I'm learning how to document as I go along :slightly_smiling_face:
What about contributions?
I'm very much open to contributions, be they extensions, documentation improvements, cleanups, and so on—either through issues or direct pull requests. I'm fairly new to all of this (having come from a more Haskell-y world, travesty
is mostly the end result of trying to program OCaml like Haskell!), so I greatly appreciate any engagement available.
Ivan Gotovchits later said
FYI, The Monads library is also pretty Core stylish, as not only it implements the Core monad interface (that keeps changing from version to version of the Core library), but it also provides [the container interface][1]. Basically, the traversal.
[1]: http://binaryanalysisplatform.github.io/bap/api/v1.3.0/Monads.Std.Monad.Collection.html
Some feedback on teaching with jbuilder as a build tool
David Chemouil announced
I've been TA-ing a course on functional programming in OCaml at ENSEEIHT, Toulouse, since September and it's just over now. Students, 4th year students after the "baccalauréat" (how do you call them? graduates? postgraduates?), had to follow several lectures as well as roughly 10 seminars and 10 lab sessions. The whole course was completely revamped this year, so we also decided to use Jbuilder (not Dune, as we had to set up an infrastructure long before Dune 1.0) for our lab sessions.
Overall, the experience has been very nice, so kudos to Dune developers!
However, we also had a few issues that I would like to report for the record (Cc: @diml @rgrinberg ), and perhaps to foster a few evolutions of Dune (or to be shown how to solve them easily : we may have missed some information in the documentation).
jbuilder runtest
sometimes just hangs while running, I'll try to devise an MWE later but I'm still reporting this in case this is already a known issue.- Sometimes we wanted to have a program open a file whose path would be relative to the source code itself and harcoded in the ML file. For instance, the OCaml file contained something like
open_in "./foo"
. Unfortunately, it seems Jbuilder doesn't runruntest
andutop
from the same working directory, hence depending on the path written in the ML file, one of these commands failed. Is there an easy way to solve this? (We know we could use an absolute path to some location, but we have dozens of PCs running on a university network, so the configuration is not as flexible as one could expect. We'd also like to avoid passing the path on the commandline.) - I already spoke about this in another post (https://discuss.ocaml.org/t/dune-link-against-cmo-cmi-without-source/2488/8) but I'm writing this here too: we sometimes like to provide students with a .cmi/.cmo file pair but no source code. AFAIK there's no simple, straightforward way to do this with Dune alone…
Well that's about it. We met a couple of other problems but they could be solved in a reasonably easy way. The only trouble now is that, sometimes, students would like to create their own jbuild
file or update one we have provided, and it's a bit hard for them to know how to proceed (and the Dune documentation is good but perhaps more aimed at regular developers than students). I expect future versions of Dune or some Dune plugins, or even other tools, to ease setting up basic projects without writing the dune file yourself (e.g. something like dune new-lib mylib
or dune add-dep mylib core_kernel
).
Marshall Abrams then said
I agree that the Dune docs by themselves are not the best starting point. Maybe some of the links here would be helpful: https://ocamlverse.github.io/content/quickstart.html
Blog post: A new general computation model for Dune
Jérémie Dimino announced
https://dune.build/blog/new-computation-model/ A blog post about the new computation model that Dune is built on.
Ppxlib 0.4.0
Jérémie Dimino announced
The ppxlib team is pleased to announce the release of ppxlib 0.4.0. This release adds better support for defining compile-time interpretation of dotted operators such as +.+
and also improves integration with other tools such as reason or metaocaml by no longer complaining about attributes generated by these tools. In particular, ppxlib now treats all attributes whose name start with an _
as machine generated attributes and doesn't complain if it can't decide whether they have been correctly interpreted or not. FTR, ppxlib tries to detect attributes and extension points that are dead-code, in order to catch typing mistakes or misplacement.
Here is the full changelog for this release:
- Do not report errors about dropped or uninterpreted attributes
starting with
_
(ocaml-ppx/ppxlib#46, fix ocaml-ppx/ppxlib#40, @diml) - Fix he
special_function
rule for dotted operators and allowLongident.parse
to parse dotted operators (ocaml-ppx/ppxlib#44, @Octachron) - Port to
dune
and remove use of bash (ocaml-ppx/ppxlib#45, @rgrinberg) - Ignore all attribites starting with
_
(ocaml-ppx/ppxlib#46, @diml) - Reserve the
reason
andrefmt
namespaces (ocaml-ppx/ppxlib#46, @diml) - Reserve the
metaocaml
namespace (ocaml-ppx/ppxlib#50, @rgrinberg) - Fix attribute extraction for Otag/Rtag (ocaml-ppx/ppxlib#51, @xclerc)
- Do not relocate files unless
-loc-filename
is passed (ocaml-ppx/ppxlib#55, @hhugo) - Perserve the filename in the output (ocaml-ppx/ppxlib#56, @hhugo)
opam 2.0.2!
R. Boujbel announced
We are pleased to announce the release of opam 2.0.2.
This new version contains mainly backported fixes, you can find more information in this blog post.
Note that as sandbox scripts have been updated, don't forget to run opam init --reinit -ni
to update yours.
opam is a source-based package manager for OCaml. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
Anil Madhavapeddy added
Thanks @rjbou! :) For anyone on Ubuntu that wants a quick upgrade, the opam2 PPA has been updated with this release as well.
Ocaml Github Pull Requests
Gabriel Scherer and the editor compiled this list
Here is a sneak peek at some potential future features of the Ocaml compiler, discussed by their implementers in these Github Pull Requests.
Other OCaml News
From the ocamlcore planet blog
Here are links from many OCaml blogs aggregated at OCaml Planet.
Old CWN
If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.
If you also wish to receive it every week by mail, you may subscribe online.