Strings and Tries; Haskell Versus OCaml
While doing my OCaml MOOC exercise I came across a trie implementation for looking up words. I find that the way OCaml treats strings is very different from the way Haskell does it. It leads…
While doing my OCaml MOOC exercise I came across a trie implementation for looking up words. I find that the way OCaml treats strings is very different from the way Haskell does it. It leads…
Run Time Versus Compile Time Error Run time errors are those that happen when the program runs, as opposed to compile time errors which happen when the program compiles. In a sense, having compile time…
In the last post, I talked about catamorphisms in Haskell. Specifically, the advantages of the foldr1 or foldl1 option in Haskell. Namely, (1) not needing to specify the base case and (2) preserving polymorphisms in…
In the last post I talked about catamorphisms in OCaml. In this post I compare that with Haskell. We’ll see that Haskell gives you more options when implementing catamorphisms. You don’t need to know Haskell…
By bananas, I mean banana brackets as in the famous paper “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire” by Meijer et al. In this post I only focus on bananas, also called catamorphisms….
The comparison operators in OCaml are polymorphic. That is, you can use them for various data types. Because OCaml is a typed language, like any other operator, you have to apply them to the same…
Like many other modern languages, OCaml uses lexical (or static) scoping. That is, in OCaml, when your function includes a name that calls a variable, in the function, that variable has the value when the…
Lambda is fun! Lambda is certainly fun, but what I mean here is that the λ in lambda calculus is similar to the expression fun in OCaml. Recall that in lambda calculus, we have function expressions…
In the last post I talked about building an OCaml project using Dune. In this post I continue with a more complex project. The project interfaces OCaml and PostgreSQL (a database system) with Caqti (a…
Dune is a popular OCaml build tool. If you haven’t already, I encourage you to give it a try! Especially if you are building a project that involves more components. See other compiling options here….