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/
> msgid/ats-lang-users/c9cdbd1c-3532-4512-afcf-2acf040cccba%
> 40googlegroups.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/CAPPSPLpPerKqbnj4diXGS-_mu5Zsof9sAhLXYOa5tAUjbKW0yg%40mail.gmail.com.

Reply via email to