Abstraction with Penalty

hello,
I am reading a comparison between ocaml and Mlton :


They talk about List comprehension by using a List monad

The fact is the Pythagorean triples runs 15x longer than using built-in for
loops with the Ocaml compiler.
The MLton does a lot better.

They say that OCaml can’t inline functions passed as parameters but SML can.

How would ATS compiler work with that problem ?

thanks

Generally speaking, one needs the following two features to get highly
efficient code:

1: flat data representation (that is C-like unboxed data representation) to
reduce the need for memory access.
2: cross-module function inlining.

MLton supports 2 but not 1. It actually does whole program compilation.
ATS supports both 1 and 2. The way of supporting 2 in ATS is through some
extensive use of templates. So in terms of getting efficient code, ATS is
a bit like C extended with the template system of C++; this is a very potent
combination.

By the way, there are linear-closures in ATS to support memory-efficient
lazy-evaluation.
So for a problem like Pythagorean triples, ATS should really shine.