Re: ML/OCaml style functors via includes

2017-10-18 Thread gmhwxi

Say we want to do something like what you mentioned:

>> potential use case would be, for example, being able write code that is 
"functorized" over atomics and threads, with implementations like
>>a) pthreads and c11 atomics modules for production use
>>b) userspace threads and atomics modules, which can be subjected to 
randomized or exhaustive interleaving to check for concurrency bugs

Let's forget modules for the moment. How should a reasonable programmer 
approach this?
I would say that he or she should be "self-centered" in the following sense:

List the set of functions needed for thread-related stuff. Implement the 
code based
these functions. And then implement the listed functions based on pthreads. 
Also implement
them based on userspace threads. This is basically how ATS approaches 
modularity. When
doing this, one may introduce some abstract types along the way.

Personally, I always prefer to write code first and have the confidence in 
fixing modularity issues
later.


On Wednesday, October 18, 2017 at 7:37:31 PM UTC-4, Andrew Knapp wrote:

> As a concrete example, an ATS port of the short ML example from this 
> message would be very helpful, even if none of the functions are actually 
> implemented.
>
> https://mail.haskell.org/pipermail/haskell/2004-August/014463.html
>
> I'd also like to know which of the features of the ML module system 
> described in that message can be replicated in ATS, and more generally, 
> what kind of support there is for the kind of modularity described by 
> Robert Harper here.
>
> https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/
>
> A potential use case would be, for example, being able write code that is 
> "functorized" over atomics and threads, with implementations like
>
> a) pthreads and c11 atomics modules for production use
> b) userspace threads and atomics modules, which can be subjected to 
> randomized or exhaustive interleaving to check for concurrency bugs
>
> On Wednesday, October 18, 2017 at 1:39:50 PM UTC-7, gmhwxi wrote:
>>
>>
>> The following article may shed some light on this issue:
>>
>>
>> http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/DivideConquer/main.html
>>
>> If you can tell me something a bit more concrete, I will probably be able 
>> to say more.
>>
>> On Wednesday, October 18, 2017 at 3:53:34 PM UTC-4, Andrew Knapp wrote:
>>>
>>>
>>> Hello,
>>>
>>> Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that 
>>> file inclusion can be used to emulate SML or OCaml style functors in a 
>>> limited manner.
>>>
>>> Is there an example of this technique somewhere? I would use the 
>>> record-based functor method, as described in the make_ratmod_intmod 
>>> example, but that has a performance cost.
>>> It prevents inlining and leads to calls through function pointers, both 
>>> of which I would like to avoid.
>>>
>>> Thanks,
>>> Andrew
>>>
>>

-- 
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 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/a43c8b07-22b6-4306-a38f-cb7c12f1841b%40googlegroups.com.


Re: ML/OCaml style functors via includes

2017-10-18 Thread gmhwxi

The most natural way I can think of to implement
sets in ATS is the following one:

abstype
myset(a:t@ype) = ptr

extern
fun
{a:t@ype}
element(): myset(a)
extern
fun
{a:t@ype}
add(x0: a, xs: myset(a)): myset(a)
extern
fun
{a:t@ype}
member(x0: a, xs: myset(a)): bool

And here is a list-based implementation:

local

assume
myset(a:t@ype) = list0(a)

in (* in-of-local *)

implement
{a}
element() = list0_nil()

implement
{a}
add(x0, xs) = list0_cons(x0, xs)

implement
{a}
member(x0, xs) =
list0_exists(xs, lam(x) => geq_val_val(x0, x))

end // end of [local]



On Wednesday, October 18, 2017 at 7:37:31 PM UTC-4, Andrew Knapp wrote:
>
> As a concrete example, an ATS port of the short ML example from this 
> message would be very helpful, even if none of the functions are actually 
> implemented.
>
> https://mail.haskell.org/pipermail/haskell/2004-August/014463.html
>
> I'd also like to know which of the features of the ML module system 
> described in that message can be replicated in ATS, and more generally, 
> what kind of support there is for the kind of modularity described by 
> Robert Harper here.
>
> https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/
>
> A potential use case would be, for example, being able write code that is 
> "functorized" over atomics and threads, with implementations like
>
> a) pthreads and c11 atomics modules for production use
> b) userspace threads and atomics modules, which can be subjected to 
> randomized or exhaustive interleaving to check for concurrency bugs
>
> On Wednesday, October 18, 2017 at 1:39:50 PM UTC-7, gmhwxi wrote:
>>
>>
>> The following article may shed some light on this issue:
>>
>>
>> http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/DivideConquer/main.html
>>
>> If you can tell me something a bit more concrete, I will probably be able 
>> to say more.
>>
>> On Wednesday, October 18, 2017 at 3:53:34 PM UTC-4, Andrew Knapp wrote:
>>>
>>>
>>> Hello,
>>>
>>> Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that 
>>> file inclusion can be used to emulate SML or OCaml style functors in a 
>>> limited manner.
>>>
>>> Is there an example of this technique somewhere? I would use the 
>>> record-based functor method, as described in the make_ratmod_intmod 
>>> example, but that has a performance cost.
>>> It prevents inlining and leads to calls through function pointers, both 
>>> of which I would like to avoid.
>>>
>>> Thanks,
>>> Andrew
>>>
>>

-- 
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 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/1f34f185-6b50-40d9-aecd-f1d266d2523e%40googlegroups.com.


Re: ML/OCaml style functors via includes

2017-10-18 Thread Andrew Knapp
As a concrete example, an ATS port of the short ML example from this 
message would be very helpful, even if none of the functions are actually 
implemented.

https://mail.haskell.org/pipermail/haskell/2004-August/014463.html

I'd also like to know which of the features of the ML module system 
described in that message can be replicated in ATS, and more generally, 
what kind of support there is for the kind of modularity described by 
Robert Harper here.

https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/

A potential use case would be, for example, being able write code that is 
"functorized" over atomics and threads, with implementations like

a) pthreads and c11 atomics modules for production use
b) userspace threads and atomics modules, which can be subjected to 
randomized or exhaustive interleaving to check for concurrency bugs

On Wednesday, October 18, 2017 at 1:39:50 PM UTC-7, gmhwxi wrote:
>
>
> The following article may shed some light on this issue:
>
> http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/DivideConquer/main.html
>
> If you can tell me something a bit more concrete, I will probably be able 
> to say more.
>
> On Wednesday, October 18, 2017 at 3:53:34 PM UTC-4, Andrew Knapp wrote:
>>
>>
>> Hello,
>>
>> Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that 
>> file inclusion can be used to emulate SML or OCaml style functors in a 
>> limited manner.
>>
>> Is there an example of this technique somewhere? I would use the 
>> record-based functor method, as described in the make_ratmod_intmod 
>> example, but that has a performance cost.
>> It prevents inlining and leads to calls through function pointers, both 
>> of which I would like to avoid.
>>
>> Thanks,
>> Andrew
>>
>

-- 
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 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/6b298205-95fa-44db-bf74-21fa5d407df7%40googlegroups.com.


Re: ML/OCaml style functors via includes

2017-10-18 Thread gmhwxi

The following article may shed some light on this issue:

http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/DivideConquer/main.html

If you can tell me something a bit more concrete, I will probably be able 
to say more.

On Wednesday, October 18, 2017 at 3:53:34 PM UTC-4, Andrew Knapp wrote:
>
>
> Hello,
>
> Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that 
> file inclusion can be used to emulate SML or OCaml style functors in a 
> limited manner.
>
> Is there an example of this technique somewhere? I would use the 
> record-based functor method, as described in the make_ratmod_intmod 
> example, but that has a performance cost.
> It prevents inlining and leads to calls through function pointers, both of 
> which I would like to avoid.
>
> Thanks,
> Andrew
>

-- 
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 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/d1ea1b6a-8c5b-40df-8dde-31a692887582%40googlegroups.com.


ML/OCaml style functors via includes

2017-10-18 Thread Andrew Knapp

Hello,

Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that file 
inclusion can be used to emulate SML or OCaml style functors in a limited 
manner.

Is there an example of this technique somewhere? I would use the 
record-based functor method, as described in the make_ratmod_intmod 
example, but that has a performance cost.
It prevents inlining and leads to calls through function pointers, both of 
which I would like to avoid.

Thanks,
Andrew

-- 
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 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/9026b239-479f-4b4d-b84c-0ca3cedf04ae%40googlegroups.com.