The Bank Kata in Ocaml - Part 3: injecting a clock with Functors

So at the end of part 2 we said we don’t like that we have to add the date as part of the public API. Which makes sense for a public bank terminal, we do a deposit or withdrawal now. So we’ll want to remove on from deposit and withdrawal. But where do the dates come from now? Let’s introduce a Clock module: Let’s see if we can rewrite our test to adapt to this new API »

The Bank Kata in Ocaml - Part 2: implementing the kata

In part 1 we’ve set everything up, let’s implement the kata now. If we check the readme we can see a simple acceptance test, let’s start with that. We create a file test/account_test.ml: open! Base open! Stdio let%expect_test "Printing the statements should contain all transactions" = Lib.Account.create () |> Lib.Account.deposit ~amount:1000.0 ~on:"10/01/2012" |> Lib.Account.deposit ~amount:2000.0 ~on:"13/01/2012" |> Lib.Account.withdrawal ~amount:500.0 ~on:"14/01/2012" |> Lib.Account.print; [%expect{| date || amount || balance 14/01/2012 || -500. »

The Bank Kata in Ocaml: Part 1 setting everything up

The goal of this small series of blogs is to implement the Bank kata in OCaml, doing it test and type driven and try to have a clean design. We’ll try to implement the kata with outside-in tests. My personal goal is to learn some OCaml along the way. I won’t be going into every detail of OCaml, but if you have some experience with an ML language, you should be able to follow along. »

Why I choose Bucklescript

On the meetups I attend, some people know me as the Elm guy. Yet, when reading the title of this post, you can see that I’m going for Bucklescript lately. In this post I’m going to try to explain my choice for Bucklescript. If you are in doubt, maybe some points in this post can help, but my advice would be to just try and research both languages and see for yourself. »