Right, it is just a convention.

Templates are mostly an experimental feature in ATS.
I find them to be extremely useful, though. There are a lot
of learned lessons on templates that can be readily put into
the next version of ATS, if there is ever going to be one :)


On Sun, Dec 10, 2017 at 3:40 PM, aditya siram <[email protected]>
wrote:

> Oh, cool, thanks!
>
> Another thing I just noticed that was a little confusion was that the
> '$fopr' and '$cont' naming used in the source is just convention, I can
> change it to anything and still seem to get the same results. Not saying
> it's a problem, just didn't know.
>
>
> On Sunday, December 10, 2017 at 2:19:27 PM UTC-6, gmhwxi wrote:
>>
>> It works.
>>
>> You need '{}' and '<>'
>>
>> extern fun{} list_map(...): ...
>>
>> implement list_map<>(...) = ...
>>
>> On Sun, Dec 10, 2017 at 3:12 PM, aditya siram <[email protected]>
>> wrote:
>>
>>> Hi,
>>> I was following along with the templates as functors part of the
>>> tutorial (http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML
>>> /INT2PROGINATS-BOOK-onechunk.html#templates-as-a-special-
>>> form-of-functors) and the provided example works fine, but if I removed
>>> all the template arguments and specialized the function arguments to 'int'
>>> and change 'list_map_fun' to always increment the int:
>>> extern fun list_map{n:nat} (xs: list(int, n)): list_vt(int, n)
>>> extern fun list_map$fopr(x: int): int
>>> implement list_map (xs) =
>>>   let
>>>     fun aux{n:nat}
>>>          (xs: list(int, n)): list_vt(int, n) =
>>>       (
>>>         case+ xs of
>>>         | list_nil() => list_vt_nil()
>>>         | list_cons(x, xs) => list_vt_cons(list_map$fopr(x), aux(xs))
>>>       )
>>> in
>>>   aux(xs)
>>> end
>>> extern fun list_map_fun{n:nat} (xs: list(int, n)): list_vt(int, n)
>>> implement list_map_fun(xs) =
>>> let
>>>   implement list_map$fopr(x) = x + 1
>>> in
>>>   list_map (xs)
>>> end
>>>
>>> Now I get following error on the 'implement list_map$fopr(x) = x + 1'
>>> line:
>>> ...: the implementation should be at the top-level but it is not.Enter
>>> code here...
>>>
>>> Does this approach not work when templates have no polymorphic arguments?
>>> Thanks!
>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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/ms
>>> gid/ats-lang-users/c9cdbd1c-3532-4512-afcf-2acf040cccba%40go
>>> oglegroups.com
>>> <https://groups.google.com/d/msgid/ats-lang-users/c9cdbd1c-3532-4512-afcf-2acf040cccba%40googlegroups.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 [email protected].
> To post to this group, send email to [email protected].
> 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/d730fe08-7469-4349-8809-fec1a9826f91%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/d730fe08-7469-4349-8809-fec1a9826f91%40googlegroups.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 [email protected].
To post to this group, send email to [email protected].
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/CAPPSPLr1Y21T8C6J3sTzq6vuFnqF2RQ6geAEsUM5VxApxZMZ%3Dg%40mail.gmail.com.

Reply via email to