Notes on Computing

Type-safe and composable dependencies

September 20, 2020

Applications that need to communicate with the outside world inadvertently end up accumulating a range of dependencies – things like database connection-strings, logging facilities, or configuration options.

Continue reading

Beyond Lwt promises

July 1, 2020

At work, we are heavy users of the OCaml Lwt library for promised based concurrent programming. Lwt is popular, actively developed, has exceptional performance, and can run on different platforms!

Continue reading

Applicative parsing

May 19, 2019

Parser combinators are sets of functions for building parsers in a composable fashion. Haskell’s Parsec library and OCaml’s Angstrom are two examples. Both of these libraries expose monadic interfaces for describing context-sensitive grammars. This post looks at implementing a more restricted parsing library, structured around applicative functors rather than monads.

Continue reading

OCaml has some new shiny syntax

April 24, 2019

The next major release of the OCaml compiler, version 4.08, will be equipped with a new syntax extension for monadic and applicative composition. Practically it means that it will be a bit more convenient to work with APIs structured around these patterns. The design draws inspiration from ppx_let but offers lighter syntax, and removes the need of running the code through a ppx preprocessor.

Continue reading

Memoization

December 2, 2018

Memoization is a strategy for preventing values to be computed multiple times. The sledgehammer approach in OCaml is a function with the signature:

Continue reading

Lenses via modular implicits

February 5, 2018

Following is a continuation of the topic of modular implicits , introduced in the previous post on implicit functors. This time we’ll look at how the extension can help simplifying lenses. I covered lenses in OCaml lenses via modules, where a rather verbose definition of a (van Laarhoven) lens was given in the form of a module signature LENS:

Continue reading

Implicit functors

January 28, 2018

Modular implicits is an experimental feature of OCaml that has yet to land on the master branch. In this and upcomings posts I’m going to give a few examples of what it brings to the table. For an introduction to the topic it’s best to read the original paper.

Continue reading

OCaml lenses via modules

December 20, 2017

Lenses, often described as first class getters and setters, can help simplify code for manipulating nested data structures. In this post I’m going to look at how to map the most popular Haskell representation, van Laarhoven lenses, to OCaml.

Continue reading

The mice moving challenge

January 15, 2017

A few weeks ago I came across a logic puzzle handed out as a holiday challenge. I didn’t solve it by hand but instead turned to Haskell for some help. As it proved to be a fun exercise I decided to pass it on and invited some friends to contribute with solutions in a language of their choice. I here present the given puzzle along with the set of submissions received.

Continue reading

A lazy implementation of KMP in OCaml

July 27, 2015

The following is a write-up on an implementation of the Knuth-Morris-Pratt (or KMP) text search algorithm in OCaml. The algorithm itself is rather straight forward but implementing it in a functional style serves as a good example of how lazy data structures may be used as an optimization technique.

Continue reading
Next