Yo!
![]()
I started learning the beautiful ppxlib library and found interesting information in their documentation about OCaml’s syntax features, such as extension literals - the ability to append a one-letter identifier to numeric literals. I was surprised at how easy it was to do this.
Because I was inspired by this, I wrote a demonstration project (located in my GitHub repository) to show how to use it to implement metric system support in code.
utop # 5m;;
- : Metric.Meter.t = 5
utop # Metric.Meter.(1m + 10m);;
- : Metric.Meter.t = 11
References:
- OCaml – Language extensions – Extension literals
- Ppxlib – Context-free transformation – Constant Rewriting