Month: September 2018

  • Lambda Calculus in OCaml:  “fun” and “function”

    Lambda Calculus in OCaml: “fun” and “function”

    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 and function applications: λx.λy.x+y (*A function expression*) λx.λy.x+y 3 4 (*A function application*) In OCaml, you can express the same…

  • Interfacing OCaml with PostgreSQL

    Interfacing OCaml with PostgreSQL

    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 third-party library that provides type-safe abstraction for interfacing with databases).  I loosely follow this tutorial, but instead of using Jbuilder…

  • Using Dune to Build an OCaml Project

    Using Dune to Build an OCaml Project

    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. You can install Dune using OPAM by running (in your system or a particular switch) opam install dune Writing a…

  • Lazy or Eager? Order of Evaluation in Lambda Calculus and OCaml

    Recall in lambda calculus, two items side by side is an application.  One applies the left item (the function) to the right item (the input).  E.g.: f x is read as “apply f to x”, in which f and x can be any lambda expressions.  Therefore, f and/or x may be expressions that can be evaluated…