Partial generic template implementation

1 view
Skip to first unread message

Dambaev Alexander

unread,
Feb 21, 2026, 7:33:21 AM (7 days ago) Feb 21
to ats-lan...@googlegroups.com
Hi,

ATS2 supports either generic template implementation or fully specified:

So if I have template function like this:

```
extern fn
  {a: t@ype}
  {acc:viewt@ype+}
  {cont: (t@ype, int) -> t@ype}
  foldl
  {n:nat}
  ( xs: cont(a,n)
  , acc: acc
  ):
  acc
```

I can't defined partially specialized generic implementation like this:

```
extern fn
  <a:t@ype>
  <acc:viewt@ype+>
  foldl_list
  {n:nat}
  ( xs: list(a,n)
  , acc: acc
  ):
  acc

implement {a}{acc}foldl<list>(xs, acc) = foldl_list<a><acc>(xs, acc)
```

as compiler asks to provide full set of template arguments
and this:

```
implement {a}{acc}{cont}foldl<a><acc><list>(xs, acc) = foldl_list<a><acc>(xs, acc)
```

is not working as well (compiler complains on "redundant arguments")

Will ATS3 support such partially specialized generic implementations?

Or maybe will it support this kind of partial specialization?

```
extern fn
  {a: t@ype}
  {acc:viewt@ype+}
  {cont: t@ype}
  foldl1
  ( xs: cont
  , acc: acc
  ):
  acc

implement foldl1<[a:t@ype]a><[acc:viewt@ype+]acc><List0(a)>(xs, acc) = foldl_list(xs, acc)
```

Hongwei Xi

unread,
Feb 21, 2026, 9:00:58 AM (7 days ago) Feb 21
to ats-lan...@googlegroups.com
The current *design* is that both styles are to be supported.
For now, only the latter style is implemented in ATS3.

Here is the current concrete syntax for your example:

#impltmp
{a:type}
{acc:vwtp}
foldl1<a><acc><list(a)>(xs, acc) = foldl_list(xs, acc)


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ats-lang-users/CAHjn2Kx_0DxB3Kdq2Mc6y8AFWgvQJhvq7PzRYbCTaEnRPe3%3DjA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages