My initial motivation was this Haskell source code:
https://github.com/dambaev/mobt2/blob/master/haskell/app/Main.hs which is
using lazy list (of course) and recursive binding and I decided to check if
it will be possible to get something similar

ATS version using non-linear stream is here:
https://github.com/dambaev/mobt2/blob/master/ats2/src/TEST/test1.dats , but
it takes to much memory as `stream_take_while` duplicates data, as I have
got, that datatype constructor can't be unfolded with `@stream_cons`
pattern match

There is another version, that generates primes with non-linear stream and
then, converting it to linear stream
https://github.com/dambaev/mobt2/blob/master/ats2/src/TEST/test3.dats .
This is the closest version to haskell's one. but still is using more space
and as twice as slow as Haskell, so I had started to think of how to
eliminate intermediate data structure.

So, not a production issue, hehe, just found an interesting topic to dig in
:)

сб, 9 июл. 2022 г. в 11:11, Hongwei Xi <gmh...@gmail.com>:

> By looking at your first version, my simple answer is that a linear stream
> cannot be used
> in this way. The second version is possible but I am not sure what you
> wanted to do exactly.
> If you show me how to use a non-linear stream to do it, then I could
> probably say more.
>
> On Sat, Jul 9, 2022 at 5:26 AM Dambaev Alexander <ice.redm...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I had tried to implement function of type:
>>
>> ```
>> fun
>>   {a:t0p}
>>   isPrime
>>   ( xs: !stream_vt( int)
>>   , x: int
>>   ):<cloptr1>
>>   bool
>> ```
>>
>> Ie, I want to force evaluation of some portion of a stream, but I need to
>> preserve it for a later use.
>>
>> I had tried to make a similar version:
>> ```
>> fun
>>   {a:t0p}
>>   isPrime
>>   ( xs: stream_vt( int)
>>   , x: int
>>   ):<cloptr1>
>>   ( stream_vt( int), bool)
>> ```
>>
>> but failed as well, so I decided to ask for a direction if someone had
>> tried to do similar stuff
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KwFq7JH%2BiZE7bWCJ_L7oZ38K-kmGBFii7DZsdxWLDsGmg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KwFq7JH%2BiZE7bWCJ_L7oZ38K-kmGBFii7DZsdxWLDsGmg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqp62MaoG8hugJ8h2mUt%2BsSAJ2eu6uRuJ%3D5nMOc4EbcfQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqp62MaoG8hugJ8h2mUt%2BsSAJ2eu6uRuJ%3D5nMOc4EbcfQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KymQhmbsDPQR9u-8DJj0VjyY%3DBsBkmUmxLsaz%2BpzSGONA%40mail.gmail.com.

Reply via email to