[MLton] List comprehensions?

Vesa Karvonen vesa.a.j.k at gmail.com
Fri Jun 1 21:50:50 PDT 2007


On 6/2/07, skaller <skaller at users.sourceforge.net> wrote:

[C++ template template arguments]

> Actually I don't think anyone uses them,

Well, this is getting OT, but I've used them. ;-)

One can use them to implement a substitution mechanism for
implementing lambda expressions:

  template<template<class> class F,
           class E0,
           class T, class V>
  struct subst<F<E0>, T, V> {
    typedef F<typename subst<E0, T, V>::expr> expr;
  };

  template<template<class, class> class F,
           class E0, class E1,
           class T, class V>
  struct subst<F<E0, E1>, T, V> {
    typedef F<typename subst<E0, T, V>::expr,
              typename subst<E1, T, V>::expr> expr;
  };

  ...

I probably got the idea from somewhere else.  I made a prototype lazy
template metaprogramming library (in 2004) that uses this technique
(among other techniques).

-Vesa Karvonen



More information about the MLton mailing list