Linear lazy stream, $ldelay, and freeing a single element.

37 views
Skip to first unread message

Steinway Wu

unread,
May 5, 2018, 10:51:34 PM5/5/18
to ats-lang-users
Hi, 

Even though `stream_vt (a)` is defined on `a: vt@ype`, many library functions for `stream_vt (a)` is only defined on `a: t@ype`. It feels like `a: t@ype` is easier to work with since there's no need to free a single element in some of the library functions, like `stream_vt_make_cons`. Is there other reasons not to support an element of some true view type? What should I put in the 2nd arg in `$ldelay` if I'd like to implement `stream_vt_make_cons` for `a: vt@ype`? 

gmhwxi

unread,
May 5, 2018, 11:01:16 PM5/5/18
to ats-lang-users
Is there a template called gfree? You can put gfree<a>(x) there.
For non-linear x,

implement(a:t@ype) gfree<a>(x) = ().

Steinway Wu

unread,
May 5, 2018, 11:23:33 PM5/5/18
to ats-lang-users
Oh, there's a gfree_val and gfree_ref

Steinway Wu

unread,
May 6, 2018, 12:11:40 AM5/6/18
to ats-lang-users
I have a follow up question. How does `~xs` as in `$ldelay(..., ~xs)` handle a stream of linear elements, or even linear closures? 

Hongwei Xi

unread,
May 6, 2018, 12:19:55 AM5/6/18
to ats-lan...@googlegroups.com

A linear stream is a bit like an object with two methods:
one for eval and the other for free; !xs calls the eval method
and ~xs calls the free method.

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/b113df86-f9da-4ecf-9781-4eb0ef83dad3%40googlegroups.com.

Steinway Wu

unread,
May 6, 2018, 2:15:03 PM5/6/18
to ats-lan...@googlegroups.com
And the `free` method is defined to be the second argument of $ldelay, in addition to freeing the thunk? Is that understanding correct?

Hongwei Xi

unread,
May 6, 2018, 2:16:28 PM5/6/18
to ats-lan...@googlegroups.com
Yes. Should probably use some more informative syntax in ATS3.


On Sun, May 6, 2018 at 2:15 PM, Steinway Wu <stein...@gmail.com> wrote:
And the `free` method is defined to be the second argument of $ldelay? Is that understanding correct?


On Sunday, May 6, 2018 at 12:19:55 AM UTC-4, gmhwxi wrote:

A linear stream is a bit like an object with two methods:
one for eval and the other for free; !xs calls the eval method
and ~xs calls the free method.


--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.

Steinway Wu

unread,
May 6, 2018, 3:05:45 PM5/6/18
to ats-lang-users
I was playing with a utility library based on type classes, implemented as templates. As you mentioned, I experienced "interface explosion". For things like a fold, or a fmap, I have a t@ype version that is probably garbage collected, a vt@ype version that is call-by-value, and a vt@ype version that consumes the resources which seems to be the only possible version for lazy linear types. Is it theoretically possible to introduce some way of doing sort scheme? So one doesn't need to specify any specific base sorts?

gmhwxi

unread,
May 6, 2018, 5:29:59 PM5/6/18
to ats-lang-users
That would greatly complicate the semantics of ATS.
Reply all
Reply to author
Forward
0 new messages