Type signatures in ATS

26 views
Skip to first unread message

Michael Lan

unread,
May 29, 2021, 1:41:25 AM5/29/21
to ats-lang-users
Hello,

New ATS learner here. The following code does not compile:

```
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"

fn do_something (
  f : string -> void
) : void =
(
  f "hi"
)

val _ = do_something(print)

implement main0 () = ()
```

It says the symbol [print] cannot be resolved. I suspect it is because the type of `f should somehow encode the effect. I did try `string -<1> void` as well but that didn't work either. Some pointers appreciated, I am mainly reading along with the ATS2 book.

Michael

artyom.s...@gmail.com

unread,
May 29, 2021, 1:56:37 AM5/29/21
to ats-lan...@googlegroups.com
Hi Michael,

Welcome!

I think you need to pass one of the functions for which [print] stands for. It’s an overloaded symbol.

Sent from my iPhone

On 29 May 2021, at 08:41, Michael Lan <michae...@gmail.com> wrote:

Hello,
--
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-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/454cdb2a-7af8-40b2-8f51-48f5d67e6235n%40googlegroups.com.

Dambaev Alexander

unread,
May 29, 2021, 2:08:55 AM5/29/21
to ats-lan...@googlegroups.com
Hi,
In this case, you can try `print_string`, you can see prelude/SATS/string.sats for reference.

Michael Lan

unread,
May 29, 2021, 2:11:13 AM5/29/21
to ats-lang-users
Thank you all! That does make sense. Where can I learn more about symbols, and how they differ from functions etc?

Artyom Shalkhakov

unread,
May 29, 2021, 3:58:41 AM5/29/21
to ats-lang-users
сб, 29 мая 2021 г. в 09:11, Michael Lan <michae...@gmail.com>:
Thank you all! That does make sense. Where can I learn more about symbols, and how they differ from functions etc?


It's here:


We also have a wiki on GitHub, please take a look there as well. I think there was some info about overloading there.
 
On Friday, May 28, 2021 at 11:08:55 PM UTC-7 ice.r...@gmail.com wrote:
Hi,
In this case, you can try `print_string`, you can see prelude/SATS/string.sats for reference.

--
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-user...@googlegroups.com.


--
Cheers,
Artyom Shalkhakov

Michael Lan

unread,
May 29, 2021, 12:47:18 PM5/29/21
to ats-lan...@googlegroups.com
I get this error when I change print to print_string:
In file included from min_dats.c:15:
min_dats.c: In function '_057_Users_057_michaellan_057_code_057_postiats_057_min_056_dats__dynload':
min_dats.c:267:41: error: 'atspre_print_string' undeclared (first use in this function); did you mean 'atspre_fprint_string'?
  267 | ATSINSmove_void(statmp1, do_something_0(atspre_print_string)) ;
      |                                         ^~~~~~~~~~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: note: in definition of macro 'ATSINSmove_void'
  284 | #define ATSINSmove_void(tmp, command) command
      |                                       ^~~~~~~
min_dats.c:267:41: note: each undeclared identifier is reported only once for each function it appears in
  267 | ATSINSmove_void(statmp1, do_something_0(atspre_print_string)) ;
      |                                         ^~~~~~~~~~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:284:39: note: in definition of macro 'ATSINSmove_void'
  284 | #define ATSINSmove_void(tmp, command) command
      |                                       ^~~~~~~

Any idea why this is occuring?

Reply all
Reply to author
Forward
0 new messages