I wrote a full implementation of this version in Haskell as part of my dissertation [0]. I'm linking to a specific commit because in the coming month, I will be modifying it to introduce structural type inference (so that what would typically be considered a data type declaration can also be inferred).
[0]: https://github.com/amnn/typed_geomlab/blob/c79c4bbb3179ef66b...