For instance, I see the following kind of recursive templates very often:
fun{a:t@ype}
list0_length(xs: list0(a)): int =
case+ xs of
| list0_nil() => 0
| list0_cons(x1, xs) => 1 + list0_length<a>(xs)
This kind of code may be working, but should be avoided. Instead,
one can replace it with the following code:
fun{a:t@ype}
list0_length(xs: list0(a)): int =
length(xs) where
{
fun length(xs: list0(a)): int =
case+ xs of
| list0_nil() => 0
| list0_cons(_, xs) => 1 + length(xs)
}
BTW, recursive templates, by default, are not supported in ATS3.