Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ATS language overview'

8,215 views

Published on

ATS language overview'

Published in: Technology

ATS language overview'

  1. 1. ATS language overview'ATS language overview'ATS language overview'ATS language overview'ATS language overview' Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
  2. 2. Remember Heartbleed bug?Remember Heartbleed bug?Remember Heartbleed bug?Remember Heartbleed bug?Remember Heartbleed bug? Should we use safer language than C?Should we use safer language than C?Should we use safer language than C?Should we use safer language than C?Should we use safer language than C? ==�In�English�== "Preventing�heartbleed�bugs�with�safe�programming�languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.html ==�In�Japanease�== "安全なプログラミング⾔語を使って�heartbleed�を防ぐには� https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md ==�In�English�== "Preventing�heartbleed�bugs�with�safe�programming�languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.html ==�In�Japanease�== "安全なプログラミング⾔語を使って�heartbleed�を防ぐには� https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md ==�In�English�== "Preventing�heartbleed�bugs�with�safe�programming�languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.html ==�In�Japanease�== "安全なプログラミング⾔語を使って�heartbleed�を防ぐには� https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md ==�In�English�== "Preventing�heartbleed�bugs�with�safe�programming�languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.html ==�In�Japanease�== "安全なプログラミング⾔語を使って�heartbleed�を防ぐには� https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md ==�In�English�== "Preventing�heartbleed�bugs�with�safe�programming�languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.html ==�In�Japanease�== "安全なプログラミング⾔語を使って heartbleed�を防ぐには� https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug."
  3. 3. Want the safer language... It's ATS!Want the safer language... It's ATS!Want the safer language... It's ATS!Want the safer language... It's ATS!Want the safer language... It's ATS! ☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/ ☆ Syntax like ML☆ Syntax like ML☆ Syntax like ML☆ Syntax like ML☆ Syntax like ML ☆ DML-style dependent types☆ DML-style dependent types☆ DML-style dependent types☆ DML-style dependent types☆ DML-style dependent types ☆ Linear types☆ Linear types☆ Linear types☆ Linear types☆ Linear types ☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC ☆ Optional malloc/free☆ Optional malloc/free☆ Optional malloc/free☆ Optional malloc/free☆ Optional malloc/free ☆ Optional run-time☆ Optional run-time☆ Optional run-time☆ Optional run-time☆ Optional run-time
  4. 4. How to install ATS compilerHow to install ATS compilerHow to install ATS compilerHow to install ATS compilerHow to install ATS compiler ☆ In English: http://bit.ly/instats☆ In English: http://bit.ly/instats☆ In English: http://bit.ly/instats☆ In English: http://bit.ly/instats☆ In English: http://bit.ly/instats ☆ In Japanese: http://bit.ly/instatsj☆ In Japanese: http://bit.ly/instatsj☆ In Japanese: http://bit.ly/instatsj☆ In Japanese: http://bit.ly/instatsj☆ In Japanese: http://bit.ly/instatsj
  5. 5. Install ATS compiler into Debian #1Install ATS compiler into Debian #1Install ATS compiler into Debian #1Install ATS compiler into Debian #1Install ATS compiler into Debian #1 ☆ Get source code of ATS compiler compiler☆ Get source code of ATS compiler compiler☆ Get source code of ATS compiler compiler☆ Get source code of ATS compiler compiler☆ Get source code of ATS compiler compiler $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-contrib-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-contrib-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-contrib-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-contrib-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-0.2.4.tgz $�wget�http://downloads.sourceforge.net/project/ats2-lang/ats2-lang/ats2- postiats-0.2.4/ATS2-Postiats-contrib-0.2.4.tgz ☆ Install packages needed by the ATS compiler ☆ Install packages needed by the ATS compiler ☆ Install packages needed by the ATS compiler ☆ Install packages needed by the ATS compiler ☆ Install packages needed by the ATS compiler $�sudo�apt-get�install�gcc�libgc-dev�libgmp-dev�make$�sudo�apt-get�install�gcc�libgc-dev�libgmp-dev�make$�sudo�apt-get�install�gcc�libgc-dev�libgmp-dev�make$�sudo�apt-get�install�gcc�libgc-dev�libgmp-dev�make$�sudo�apt-get�install�gcc�libgc-dev�libgmp-dev�make
  6. 6. Install ATS compiler into Debian #2Install ATS compiler into Debian #2Install ATS compiler into Debian #2Install ATS compiler into Debian #2Install ATS compiler into Debian #2 ☆ Compile the ATS compiler compiler☆ Compile the ATS compiler compiler☆ Compile the ATS compiler compiler☆ Compile the ATS compiler compiler☆ Compile the ATS compiler compiler $�tar�xf�ATS2-Postiats-0.2.4.tgz $�export�PATSHOME=`pwd`/ATS2-Postiats-0.2.4 $�export�PATH=${PATSHOME}/bin:${PATH} $�tar�xf�ATS2-Postiats-contrib-0.2.4.tgz $�export�PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.2.4 $�cd�${PATSHOME} $�./configure $�make $�tar�xf�ATS2-Postiats-0.2.4.tgz $�export�PATSHOME=`pwd`/ATS2-Postiats-0.2.4 $�export�PATH=${PATSHOME}/bin:${PATH} $�tar�xf�ATS2-Postiats-contrib-0.2.4.tgz $�export�PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.2.4 $�cd�${PATSHOME} $�./configure $�make $�tar�xf�ATS2-Postiats-0.2.4.tgz $�export�PATSHOME=`pwd`/ATS2-Postiats-0.2.4 $�export�PATH=${PATSHOME}/bin:${PATH} $�tar�xf�ATS2-Postiats-contrib-0.2.4.tgz $�export�PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.2.4 $�cd�${PATSHOME} $�./configure $�make $�tar�xf�ATS2-Postiats-0.2.4.tgz $�export�PATSHOME=`pwd`/ATS2-Postiats-0.2.4 $�export�PATH=${PATSHOME}/bin:${PATH} $�tar�xf�ATS2-Postiats-contrib-0.2.4.tgz $�export�PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.2.4 $�cd�${PATSHOME} $�./configure $�make $�tar�xf�ATS2-Postiats-0.2.4.tgz $�export�PATSHOME=`pwd`/ATS2-Postiats-0.2.4 $�export�PATH=${PATSHOME}/bin:${PATH} $�tar�xf�ATS2-Postiats-contrib-0.2.4.tgz $�export�PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.2.4 $�cd�${PATSHOME} $�./configure $�make ☆ Ready to compile ATS code!☆ Ready to compile ATS code!☆ Ready to compile ATS code!☆ Ready to compile ATS code!☆ Ready to compile ATS code! $�patsopt�--version ATS/Postiats�version�0.2.4�with�Copyright�(c)�2011-2015�Hongwei�Xi $�patsopt�--version ATS/Postiats�version�0.2.4�with�Copyright�(c)�2011-2015�Hongwei�Xi $�patsopt�--version ATS/Postiats�version�0.2.4�with�Copyright�(c)�2011-2015�Hongwei�Xi $�patsopt�--version ATS/Postiats�version�0.2.4�with�Copyright�(c)�2011-2015�Hongwei�Xi $�patsopt�--version ATS/Postiats�version�0.2.4�with�Copyright�(c)�2011-2015�Hongwei�Xi
  7. 7. Fizzbuzz on C languageFizzbuzz on C languageFizzbuzz on C languageFizzbuzz on C languageFizzbuzz on C language #include�<stdio.h> void�print_fb(int�i)�{ if�(i�%�3�==�0�&&�i�%�5�==�0)�{ printf�("FizzBuzzn"); }�else�if�(i�%�3�==�0)�{ printf�("Fizzn"); }�else�if�(i�%�5�==�0)�{ printf�("Buzzn"); }�else�{ printf�("%dn",�i); } } void�fizzbuzz(int�n,�int�j)�{ if�(n�!=�j)�{�print_fb(j);�fizzbuzz(n,�j+1);�} } int�main(void)�{ fizzbuzz(100,�1); return�0; } #include�<stdio.h> void�print_fb(int�i)�{ if�(i�%�3�==�0�&&�i�%�5�==�0)�{ printf�("FizzBuzzn"); }�else�if�(i�%�3�==�0)�{ printf�("Fizzn"); }�else�if�(i�%�5�==�0)�{ printf�("Buzzn"); }�else�{ printf�("%dn",�i); } } void�fizzbuzz(int�n,�int�j)�{ if�(n�!=�j)�{�print_fb(j);�fizzbuzz(n,�j+1);�} } int�main(void)�{ fizzbuzz(100,�1); return�0; } #include�<stdio.h> void�print_fb(int�i)�{ if�(i�%�3�==�0�&&�i�%�5�==�0)�{ printf�("FizzBuzzn"); }�else�if�(i�%�3�==�0)�{ printf�("Fizzn"); }�else�if�(i�%�5�==�0)�{ printf�("Buzzn"); }�else�{ printf�("%dn",�i); } } void�fizzbuzz(int�n,�int�j)�{ if�(n�!=�j)�{�print_fb(j);�fizzbuzz(n,�j+1);�} } int�main(void)�{ fizzbuzz(100,�1); return�0; } #include�<stdio.h> void�print_fb(int�i)�{ if�(i�%�3�==�0�&&�i�%�5�==�0)�{ printf�("FizzBuzzn"); }�else�if�(i�%�3�==�0)�{ printf�("Fizzn"); }�else�if�(i�%�5�==�0)�{ printf�("Buzzn"); }�else�{ printf�("%dn",�i); } } void�fizzbuzz(int�n,�int�j)�{ if�(n�!=�j)�{�print_fb(j);�fizzbuzz(n,�j+1);�} } int�main(void)�{ fizzbuzz(100,�1); return�0; } #include�<stdio.h> void�print_fb(int�i)�{ if�(i�%�3�==�0�&&�i�%�5�==�0)�{ printf�("FizzBuzzn"); }�else if�(i�%�3�==�0)�{ printf�("Fizzn"); }�else if�(i�%�5�==�0)�{ printf�("Buzzn"); }�else�{ printf�("%dn",�i); } } void�fizzbuzz(int�n,�int�j)�{ if�(n�!=�j)�{�print_fb(j);�fizzbuzz(n,�j+1);�} } int�main(void)�{ fizzbuzz(100,�1); return 0; }
  8. 8. Fizzbuzz on ATS languageFizzbuzz on ATS languageFizzbuzz on ATS languageFizzbuzz on ATS languageFizzbuzz on ATS language #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" fun�print_fb�(i:int):�void�= ��case+�(i�mod�3�=�0,�i�mod�5�=�0)�of ����│�(true�,�true�)�=>�println!�"FizzBuzz" ����│�(true�,�false)�=>�println!�"Fizz" ����│�(false,�true�)�=>�println!�"Buzz" ����│�(false,�false)�=>�println!�i fun�fizzbuzz�(n:int,�j:int):�void�= ��if�n�!=�j�then�(print_fb�j;�fizzbuzz�(n,�j+1)) implement�main0�()�=�{ ��val�()�=�fizzbuzz�(100,�1) } #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" fun�print_fb�(i:int):�void�= ��case+�(i�mod�3�=�0,�i�mod�5�=�0)�of ����│�(true�,�true�)�=>�println!�"FizzBuzz" ����│�(true�,�false)�=>�println!�"Fizz" ����│�(false,�true�)�=>�println!�"Buzz" ����│�(false,�false)�=>�println!�i fun�fizzbuzz�(n:int,�j:int):�void�= ��if�n�!=�j�then�(print_fb�j;�fizzbuzz�(n,�j+1)) implement�main0�()�=�{ ��val�()�=�fizzbuzz�(100,�1) } #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" fun�print_fb�(i:int):�void�= ��case+�(i�mod�3�=�0,�i�mod�5�=�0)�of ����│�(true�,�true�)�=>�println!�"FizzBuzz" ����│�(true�,�false)�=>�println!�"Fizz" ����│�(false,�true�)�=>�println!�"Buzz" ����│�(false,�false)�=>�println!�i fun�fizzbuzz�(n:int,�j:int):�void�= ��if�n�!=�j�then�(print_fb�j;�fizzbuzz�(n,�j+1)) implement�main0�()�=�{ ��val�()�=�fizzbuzz�(100,�1) } #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" fun�print_fb�(i:int):�void�= ��case+�(i�mod�3�=�0,�i�mod�5�=�0)�of ����│�(true�,�true�)�=>�println!�"FizzBuzz" ����│�(true�,�false)�=>�println!�"Fizz" ����│�(false,�true�)�=>�println!�"Buzz" ����│�(false,�false)�=>�println!�i fun�fizzbuzz�(n:int,�j:int):�void�= ��if�n�!=�j�then�(print_fb�j;�fizzbuzz�(n,�j+1)) implement�main0�()�=�{ ��val�()�=�fizzbuzz�(100,�1) } #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" fun�print_fb�(i:int):�void�= ��case+�(i�mod�3�=�0,�i�mod�5�=�0)�of ����│�(true�,�true�)�=>�println!�"FizzBuzz" ����│�(true�,�false)�=>�println!�"Fizz" ����│�(false,�true�)�=>�println!�"Buzz" ����│�(false,�false)�=>�println!�i fun�fizzbuzz�(n:int,�j:int):�void�= if�n�!=�j�then�(print_fb�j;�fizzbuzz�(n,�j+1)) implement�main0�()�=�{ val�()�=�fizzbuzz�(100,�1) }
  9. 9. How to compile the ATS codeHow to compile the ATS codeHow to compile the ATS codeHow to compile the ATS codeHow to compile the ATS code $�patscc�-o�fizzbuzz�fizzbuzz.dats $�./fizzbuzz�│�head�-20 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz $�patscc�-o�fizzbuzz�fizzbuzz.dats $�./fizzbuzz�│�head�-20 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz $�patscc�-o�fizzbuzz�fizzbuzz.dats $�./fizzbuzz�│�head�-20 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz $�patscc�-o�fizzbuzz�fizzbuzz.dats $�./fizzbuzz�│�head�-20 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz $�patscc�-o�fizzbuzz�fizzbuzz.dats $�./fizzbuzz�│�head�-20 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz
  10. 10. ATS binary is portableATS binary is portableATS binary is portableATS binary is portableATS binary is portable ☆ File size is 13 kB☆ File size is 13 kB☆ File size is 13 kB☆ File size is 13 kB☆ File size is 13 kB $�ls�-lh�fizzbuzz -rwxr-xr-x�1�kiwamu�kiwamu�13K�Nov��6�21:45�fizzbuzz* $�ls�-lh�fizzbuzz -rwxr-xr-x�1�kiwamu�kiwamu�13K�Nov��6�21:45�fizzbuzz* $�ls�-lh�fizzbuzz -rwxr-xr-x�1�kiwamu�kiwamu�13K�Nov��6�21:45�fizzbuzz* $�ls�-lh�fizzbuzz -rwxr-xr-x�1�kiwamu�kiwamu�13K�Nov��6�21:45�fizzbuzz* $�ls�-lh�fizzbuzz -rwxr-xr-x�1�kiwamu�kiwamu�13K�Nov��6�21:45�fizzbuzz* ☆ Number of undefined symbols is 6☆ Number of undefined symbols is 6☆ Number of undefined symbols is 6☆ Number of undefined symbols is 6☆ Number of undefined symbols is 6 $�nm�fizzbuzz�│�grep�'U�' �����������������U�__libc_start_main@@GLIBC_2.2.5 �����������������U�exit@@GLIBC_2.2.5 �����������������U�fflush@@GLIBC_2.2.5 �����������������U�fprintf@@GLIBC_2.2.5 �����������������U�fwrite@@GLIBC_2.2.5 �����������������U�longjmp@@GLIBC_2.2.5 $�nm�fizzbuzz�│�grep�'U�' �����������������U�__libc_start_main@@GLIBC_2.2.5 �����������������U�exit@@GLIBC_2.2.5 �����������������U�fflush@@GLIBC_2.2.5 �����������������U�fprintf@@GLIBC_2.2.5 �����������������U�fwrite@@GLIBC_2.2.5 �����������������U�longjmp@@GLIBC_2.2.5 $�nm�fizzbuzz�│�grep�'U�' �����������������U�__libc_start_main@@GLIBC_2.2.5 �����������������U�exit@@GLIBC_2.2.5 �����������������U�fflush@@GLIBC_2.2.5 �����������������U�fprintf@@GLIBC_2.2.5 �����������������U�fwrite@@GLIBC_2.2.5 �����������������U�longjmp@@GLIBC_2.2.5 $�nm�fizzbuzz�│�grep�'U�' �����������������U�__libc_start_main@@GLIBC_2.2.5 �����������������U�exit@@GLIBC_2.2.5 �����������������U�fflush@@GLIBC_2.2.5 �����������������U�fprintf@@GLIBC_2.2.5 �����������������U�fwrite@@GLIBC_2.2.5 �����������������U�longjmp@@GLIBC_2.2.5 $�nm�fizzbuzz�│�grep�'U�' �����������������U�__libc_start_main@@GLIBC_2.2.5 �����������������U�exit@@GLIBC_2.2.5 �����������������U�fflush@@GLIBC_2.2.5 �����������������U�fprintf@@GLIBC_2.2.5 �����������������U�fwrite@@GLIBC_2.2.5 �����������������U�longjmp@@GLIBC_2.2.5 ☆ Only depends on three libraries☆ Only depends on three libraries☆ Only depends on three libraries☆ Only depends on three libraries☆ Only depends on three libraries $�ldd�fizzbuzz ��������linux-vdso.so.1�(0x00007ffe263d9000) ��������libc.so.6�=>�/lib/x86_64-linux-gnu/libc.so.6�(0x00007fc3c363f000) ��������/lib64/ld-linux-x86-64.so.2�(0x000055d77ccd1000) $�ldd�fizzbuzz ��������linux-vdso.so.1�(0x00007ffe263d9000) ��������libc.so.6�=>�/lib/x86_64-linux-gnu/libc.so.6�(0x00007fc3c363f000) ��������/lib64/ld-linux-x86-64.so.2�(0x000055d77ccd1000) $�ldd�fizzbuzz ��������linux-vdso.so.1�(0x00007ffe263d9000) ��������libc.so.6�=>�/lib/x86_64-linux-gnu/libc.so.6�(0x00007fc3c363f000) ��������/lib64/ld-linux-x86-64.so.2�(0x000055d77ccd1000) $�ldd�fizzbuzz ��������linux-vdso.so.1�(0x00007ffe263d9000) ��������libc.so.6�=>�/lib/x86_64-linux-gnu/libc.so.6�(0x00007fc3c363f000) ��������/lib64/ld-linux-x86-64.so.2�(0x000055d77ccd1000) $�ldd�fizzbuzz ��������linux-vdso.so.1�(0x00007ffe263d9000) ��������libc.so.6�=>�/lib/x86_64-linux-gnu/libc.so.6�(0x00007fc3c363f000) ��������/lib64/ld-linux-x86-64.so.2�(0x000055d77ccd1000)
  11. 11. ATS compile flowATS compile flowATS compile flowATS compile flowATS compile flow
  12. 12. What can ATS do?What can ATS do?What can ATS do?What can ATS do?What can ATS do? ☆ Write code on bare metal hardware☆ Write code on bare metal hardware☆ Write code on bare metal hardware☆ Write code on bare metal hardware☆ Write code on bare metal hardware ☆ Write code in Linux kernel☆ Write code in Linux kernel☆ Write code in Linux kernel☆ Write code in Linux kernel☆ Write code in Linux kernel ☆ Use strong type without any OS☆ Use strong type without any OS☆ Use strong type without any OS☆ Use strong type without any OS☆ Use strong type without any OS ☆ Prove code using dependent types☆ Prove code using dependent types☆ Prove code using dependent types☆ Prove code using dependent types☆ Prove code using dependent types ☆ Safely use malloc using linear types☆ Safely use malloc using linear types☆ Safely use malloc using linear types☆ Safely use malloc using linear types☆ Safely use malloc using linear types ☆ Safely use pointer using linear types☆ Safely use pointer using linear types☆ Safely use pointer using linear types☆ Safely use pointer using linear types☆ Safely use pointer using linear types
  13. 13. Demo running on bare metalDemo running on bare metalDemo running on bare metalDemo running on bare metalDemo running on bare metal http://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nc Arduino Uno hardware:Arduino Uno hardware:Arduino Uno hardware:Arduino Uno hardware:Arduino Uno hardware: ☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture ☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB ☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB
  14. 14. Demo software architectureDemo software architectureDemo software architectureDemo software architectureDemo software architecture https://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-ats
  15. 15. The world of ATS programmingThe world of ATS programmingThe world of ATS programmingThe world of ATS programmingThe world of ATS programming
  16. 16. Dynamics: ML-style programmingDynamics: ML-style programmingDynamics: ML-style programmingDynamics: ML-style programmingDynamics: ML-style programming ☆ Dynamics of ATS is similar to Standard ML.☆ Dynamics of ATS is similar to Standard ML.☆ Dynamics of ATS is similar to Standard ML.☆ Dynamics of ATS is similar to Standard ML.☆ Dynamics of ATS is similar to Standard ML. ☆ You should represent type signature of function, because ATS can't inference everything. ☆ You should represent type signature of function, because ATS can't inference everything. ☆ You should represent type signature of function, because ATS can't inference everything. ☆ You should represent type signature of function, because ATS can't inference everything. ☆ You should represent type signature of function, because ATS can't inference everything. ☆ You should introduce main function, because ATS code is compiled into C language. ☆ You should introduce main function, because ATS code is compiled into C language. ☆ You should introduce main function, because ATS code is compiled into C language. ☆ You should introduce main function, because ATS code is compiled into C language. ☆ You should introduce main function, because ATS code is compiled into C language.
  17. 17. Fizzbuzz on Standard MLFizzbuzz on Standard MLFizzbuzz on Standard MLFizzbuzz on Standard MLFizzbuzz on Standard ML (*�http://rosettacode.org/wiki/FizzBuzz#Standard_ML�*) local ��fun�fbstr�i�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�Int.toString�i ��fun�fizzbuzz'�(n,�j)�= ����if�n�=�j�then�() ������else�(print�(fbstr�j�^�"n");�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�n�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end (*�http://rosettacode.org/wiki/FizzBuzz#Standard_ML�*) local ��fun�fbstr�i�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�Int.toString�i ��fun�fizzbuzz'�(n,�j)�= ����if�n�=�j�then�() ������else�(print�(fbstr�j�^�"n");�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�n�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end (*�http://rosettacode.org/wiki/FizzBuzz#Standard_ML�*) local ��fun�fbstr�i�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�Int.toString�i ��fun�fizzbuzz'�(n,�j)�= ����if�n�=�j�then�() ������else�(print�(fbstr�j�^�"n");�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�n�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end (*�http://rosettacode.org/wiki/FizzBuzz#Standard_ML�*) local ��fun�fbstr�i�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�Int.toString�i ��fun�fizzbuzz'�(n,�j)�= ����if�n�=�j�then�() ������else�(print�(fbstr�j�^�"n");�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�n�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end (*�http://rosettacode.org/wiki/FizzBuzz#Standard_ML�*) local fun�fbstr�i�= ����case�(i�mod 3�=�0,�i�mod 5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�Int.toString�i fun�fizzbuzz'�(n,�j)�= if�n�=�j�then�() else�(print�(fbstr�j�^�"n");�fizzbuzz'�(n,�j+1)) in fun�fizzbuzz�n�=�fizzbuzz'�(n,�1) val�_�=�fizzbuzz�100 end
  18. 18. Fizzbuzz on ATSFizzbuzz on ATSFizzbuzz on ATSFizzbuzz on ATSFizzbuzz on ATS #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" local ��fun�fbstr�(i:int):�string�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�tostring_int�i ��fun�fizzbuzz'�(n:int,�j:int):�void�= ����if�n�=�j�then�() ������else�(println!�(fbstr�j);�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�(n:int):�void�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end implement�main0�()�=�() #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" local ��fun�fbstr�(i:int):�string�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�tostring_int�i ��fun�fizzbuzz'�(n:int,�j:int):�void�= ����if�n�=�j�then�() ������else�(println!�(fbstr�j);�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�(n:int):�void�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end implement�main0�()�=�() #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" local ��fun�fbstr�(i:int):�string�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�tostring_int�i ��fun�fizzbuzz'�(n:int,�j:int):�void�= ����if�n�=�j�then�() ������else�(println!�(fbstr�j);�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�(n:int):�void�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end implement�main0�()�=�() #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" local ��fun�fbstr�(i:int):�string�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�tostring_int�i ��fun�fizzbuzz'�(n:int,�j:int):�void�= ����if�n�=�j�then�() ������else�(println!�(fbstr�j);�fizzbuzz'�(n,�j+1)) in ��fun�fizzbuzz�(n:int):�void�=�fizzbuzz'�(n,�1) ��val�_�=�fizzbuzz�100 end implement�main0�()�=�() #include�"share/atspre_define.hats" #include�"share/atspre_staload.hats" local fun�fbstr�(i:int):�string�= ����case�(i�mod�3�=�0,�i�mod�5�=�0)�of ��������(true�,�true�)�=>�"FizzBuzz" ������│�(true�,�false)�=>�"Fizz" ������│�(false,�true�)�=>�"Buzz" ������│�(false,�false)�=>�tostring_int�i fun�fizzbuzz'�(n:int,�j:int):�void�= if�n�=�j�then�() else�(println!�(fbstr�j);�fizzbuzz'�(n,�j+1)) in fun�fizzbuzz�(n:int):�void�=�fizzbuzz'�(n,�1) val�_�=�fizzbuzz�100 end implement�main0�()�=�()
  19. 19. Proof: Curry–Howard in ATSProof: Curry–Howard in ATSProof: Curry–Howard in ATSProof: Curry–Howard in ATSProof: Curry–Howard in ATS ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement"
  20. 20. Proof: Style of functionsProof: Style of functionsProof: Style of functionsProof: Style of functionsProof: Style of functions
  21. 21. Proof: Function signatureProof: Function signatureProof: Function signatureProof: Function signatureProof: Function signature
  22. 22. Proof: Function bodyProof: Function bodyProof: Function bodyProof: Function bodyProof: Function body
  23. 23. Proof: Before compilingProof: Before compilingProof: Before compilingProof: Before compilingProof: Before compiling
  24. 24. Proof: After compilingProof: After compilingProof: After compilingProof: After compilingProof: After compiling Proof is erased at compile time.Proof is erased at compile time.Proof is erased at compile time.Proof is erased at compile time.Proof is erased at compile time.
  25. 25. Proof: Pros of mixed functionProof: Pros of mixed functionProof: Pros of mixed functionProof: Pros of mixed functionProof: Pros of mixed function You can write following application:You can write following application:You can write following application:You can write following application:You can write following application: ☆ Program without garbage collection☆ Program without garbage collection☆ Program without garbage collection☆ Program without garbage collection☆ Program without garbage collection ☆ Proof to prove the program☆ Proof to prove the program☆ Proof to prove the program☆ Proof to prove the program☆ Proof to prove the program Good news for low-level programming!Good news for low-level programming!Good news for low-level programming!Good news for low-level programming!Good news for low-level programming!
  26. 26. Prop is similar to CoqProp is similar to CoqProp is similar to CoqProp is similar to CoqProp is similar to Coq ☆ Coq is an interactive theorem prover.☆ Coq is an interactive theorem prover.☆ Coq is an interactive theorem prover.☆ Coq is an interactive theorem prover.☆ Coq is an interactive theorem prover. ☆ ATS also has subsystem for theorem- proving. ☆ ATS also has subsystem for theorem- proving. ☆ ATS also has subsystem for theorem- proving. ☆ ATS also has subsystem for theorem- proving. ☆ ATS also has subsystem for theorem- proving. ☆ But ATS doesn't have tactics.☆ But ATS doesn't have tactics.☆ But ATS doesn't have tactics.☆ But ATS doesn't have tactics.☆ But ATS doesn't have tactics. ☆ ATS constructs proofs as total functions.☆ ATS constructs proofs as total functions.☆ ATS constructs proofs as total functions.☆ ATS constructs proofs as total functions.☆ ATS constructs proofs as total functions.
  27. 27. Prop: Coq codeProp: Coq codeProp: Coq codeProp: Coq codeProp: Coq code (*�Coq�*) Inductive�day�:�Type�:= ��│�monday�:�day ��│�tuesday�:�day ��│�wednesday�:�day ��│�thursday�:�day ��│�friday�:�day ��│�saturday�:�day ��│�sunday�:�day. Inductive�good_day�:�day�->�Prop�:= ��│�gd_sat�:�good_day�saturday ��│�gd_sun�:�good_day�sunday. Theorem�gds�:�good_day�sunday. Proof.�apply�gd_sun.�Qed. (*�Coq�*) Inductive�day�:�Type�:= ��│�monday�:�day ��│�tuesday�:�day ��│�wednesday�:�day ��│�thursday�:�day ��│�friday�:�day ��│�saturday�:�day ��│�sunday�:�day. Inductive�good_day�:�day�->�Prop�:= ��│�gd_sat�:�good_day�saturday ��│�gd_sun�:�good_day�sunday. Theorem�gds�:�good_day�sunday. Proof.�apply�gd_sun.�Qed. (*�Coq�*) Inductive�day�:�Type�:= ��│�monday�:�day ��│�tuesday�:�day ��│�wednesday�:�day ��│�thursday�:�day ��│�friday�:�day ��│�saturday�:�day ��│�sunday�:�day. Inductive�good_day�:�day�->�Prop�:= ��│�gd_sat�:�good_day�saturday ��│�gd_sun�:�good_day�sunday. Theorem�gds�:�good_day�sunday. Proof.�apply�gd_sun.�Qed. (*�Coq�*) Inductive�day�:�Type�:= ��│�monday�:�day ��│�tuesday�:�day ��│�wednesday�:�day ��│�thursday�:�day ��│�friday�:�day ��│�saturday�:�day ��│�sunday�:�day. Inductive�good_day�:�day�->�Prop�:= ��│�gd_sat�:�good_day�saturday ��│�gd_sun�:�good_day�sunday. Theorem�gds�:�good_day�sunday. Proof.�apply�gd_sun.�Qed. (*�Coq�*) Inductive�day�:�Type�:= ��│�monday�:�day ��│�tuesday�:�day ��│�wednesday�:�day ��│�thursday�:�day ��│�friday�:�day ��│�saturday�:�day ��│�sunday�:�day. Inductive�good_day�:�day�->�Prop�:= ��│�gd_sat�:�good_day�saturday ��│�gd_sun�:�good_day�sunday. Theorem�gds�:�good_day�sunday. Proof.�apply�gd_sun.�Qed.
  28. 28. Prop: ATS codeProp: ATS codeProp: ATS codeProp: ATS codeProp: ATS code (*�ATS�*) datasort�Day�= ��│�Monday ��│�Tuesday ��│�Wednesday ��│�Thursday ��│�Friday ��│�Saturday ��│�Sunday dataprop�Good_Day�(Day)�= ��│�Gd_Sat�(Saturday)�of�() ��│�Gd_Sun�(Sunday)�of�() extern�prfun�gds:�Good_Day�Sunday primplement�gds�=�Gd_Sun�() (*�ATS�*) datasort�Day�= ��│�Monday ��│�Tuesday ��│�Wednesday ��│�Thursday ��│�Friday ��│�Saturday ��│�Sunday dataprop�Good_Day�(Day)�= ��│�Gd_Sat�(Saturday)�of�() ��│�Gd_Sun�(Sunday)�of�() extern�prfun�gds:�Good_Day�Sunday primplement�gds�=�Gd_Sun�() (*�ATS�*) datasort�Day�= ��│�Monday ��│�Tuesday ��│�Wednesday ��│�Thursday ��│�Friday ��│�Saturday ��│�Sunday dataprop�Good_Day�(Day)�= ��│�Gd_Sat�(Saturday)�of�() ��│�Gd_Sun�(Sunday)�of�() extern�prfun�gds:�Good_Day�Sunday primplement�gds�=�Gd_Sun�() (*�ATS�*) datasort�Day�= ��│�Monday ��│�Tuesday ��│�Wednesday ��│�Thursday ��│�Friday ��│�Saturday ��│�Sunday dataprop�Good_Day�(Day)�= ��│�Gd_Sat�(Saturday)�of�() ��│�Gd_Sun�(Sunday)�of�() extern�prfun�gds:�Good_Day�Sunday primplement�gds�=�Gd_Sun�() (*�ATS�*) datasort�Day�= ��│�Monday ��│�Tuesday ��│�Wednesday ��│�Thursday ��│�Friday ��│�Saturday ��│�Sunday dataprop�Good_Day�(Day)�= ��│�Gd_Sat�(Saturday)�of�() ��│�Gd_Sun�(Sunday)�of�() extern prfun�gds:�Good_Day�Sunday primplement�gds�=�Gd_Sun�() Coq and ATS have same structure.Coq and ATS have same structure.Coq and ATS have same structure.Coq and ATS have same structure.Coq and ATS have same structure.
  29. 29. Prop: Design palindrome libraryProp: Design palindrome libraryProp: Design palindrome libraryProp: Design palindrome libraryProp: Design palindrome library https://github.com/jats-ug/practice-ats/tree/master/atslf_palindromehttps://github.com/jats-ug/practice-ats/tree/master/atslf_palindromehttps://github.com/jats-ug/practice-ats/tree/master/atslf_palindromehttps://github.com/jats-ug/practice-ats/tree/master/atslf_palindromehttps://github.com/jats-ug/practice-ats/tree/master/atslf_palindrome
  30. 30. Prop: Structure of palindromeProp: Structure of palindromeProp: Structure of palindromeProp: Structure of palindromeProp: Structure of palindrome dataprop�PAL�(ilist)�= ��│�PALnil�(ilist_nil)�of�() ��│�{x:int}�PALone�(ilist_sing�(x))�of�() ��│�{x:int}{l,ll:ilist} ����PALcons�(ilist_cons�(x,�ll))�of�(PAL�(l),�SNOC�(l,�x,�ll)) dataprop�PAL�(ilist)�= ��│�PALnil�(ilist_nil)�of�() ��│�{x:int}�PALone�(ilist_sing�(x))�of�() ��│�{x:int}{l,ll:ilist} ����PALcons�(ilist_cons�(x,�ll))�of�(PAL�(l),�SNOC�(l,�x,�ll)) dataprop�PAL�(ilist)�= ��│�PALnil�(ilist_nil)�of�() ��│�{x:int}�PALone�(ilist_sing�(x))�of�() ��│�{x:int}{l,ll:ilist} ����PALcons�(ilist_cons�(x,�ll))�of�(PAL�(l),�SNOC�(l,�x,�ll)) dataprop�PAL�(ilist)�= ��│�PALnil�(ilist_nil)�of�() ��│�{x:int}�PALone�(ilist_sing�(x))�of�() ��│�{x:int}{l,ll:ilist} ����PALcons�(ilist_cons�(x,�ll))�of�(PAL�(l),�SNOC�(l,�x,�ll)) dataprop�PAL�(ilist)�= ��│�PALnil�(ilist_nil)�of�() ��│�{x:int}�PALone�(ilist_sing�(x))�of�() ��│�{x:int}{l,ll:ilist} ����PALcons�(ilist_cons�(x,�ll))�of�(PAL�(l),�SNOC�(l,�x,�ll))
  31. 31. Prop: Proposition on palindromeProp: Proposition on palindromeProp: Proposition on palindromeProp: Proposition on palindromeProp: Proposition on palindrome dataprop�PAPPEND�(ilist,�ilist,�ilist)�= ��│�{pxs:ilist}�PAPPENDnil�(pxs,�ilist_nil,�pxs)�of�PAL�(pxs) ��│�{pxs,pxsx,ys,pzs:ilist}{x:int} ����PAPPENDcons�(pxs,�ilist_cons�(x,�ys),�pzs) ������of�(SNOC�(pxs,�x,�pxsx), ��������PAPPEND�(ilist_cons�(x,�pxsx),�ys,�pzs)) prfun�pal_app�{l,lr,m:ilist} ��(pf1:�REVERSE�(l,�lr),�pf2:�APPEND�(l,�lr,�m)):�PAL�(m) dataprop�PAPPEND�(ilist,�ilist,�ilist)�= ��│�{pxs:ilist}�PAPPENDnil�(pxs,�ilist_nil,�pxs)�of�PAL�(pxs) ��│�{pxs,pxsx,ys,pzs:ilist}{x:int} ����PAPPENDcons�(pxs,�ilist_cons�(x,�ys),�pzs) ������of�(SNOC�(pxs,�x,�pxsx), ��������PAPPEND�(ilist_cons�(x,�pxsx),�ys,�pzs)) prfun�pal_app�{l,lr,m:ilist} ��(pf1:�REVERSE�(l,�lr),�pf2:�APPEND�(l,�lr,�m)):�PAL�(m) dataprop�PAPPEND�(ilist,�ilist,�ilist)�= ��│�{pxs:ilist}�PAPPENDnil�(pxs,�ilist_nil,�pxs)�of�PAL�(pxs) ��│�{pxs,pxsx,ys,pzs:ilist}{x:int} ����PAPPENDcons�(pxs,�ilist_cons�(x,�ys),�pzs) ������of�(SNOC�(pxs,�x,�pxsx), ��������PAPPEND�(ilist_cons�(x,�pxsx),�ys,�pzs)) prfun�pal_app�{l,lr,m:ilist} ��(pf1:�REVERSE�(l,�lr),�pf2:�APPEND�(l,�lr,�m)):�PAL�(m) dataprop�PAPPEND�(ilist,�ilist,�ilist)�= ��│�{pxs:ilist}�PAPPENDnil�(pxs,�ilist_nil,�pxs)�of�PAL�(pxs) ��│�{pxs,pxsx,ys,pzs:ilist}{x:int} ����PAPPENDcons�(pxs,�ilist_cons�(x,�ys),�pzs) ������of�(SNOC�(pxs,�x,�pxsx), ��������PAPPEND�(ilist_cons�(x,�pxsx),�ys,�pzs)) prfun�pal_app�{l,lr,m:ilist} ��(pf1:�REVERSE�(l,�lr),�pf2:�APPEND�(l,�lr,�m)):�PAL�(m) dataprop�PAPPEND�(ilist,�ilist,�ilist)�= ��│�{pxs:ilist}�PAPPENDnil�(pxs,�ilist_nil,�pxs)�of�PAL�(pxs) ��│�{pxs,pxsx,ys,pzs:ilist}{x:int} ����PAPPENDcons�(pxs,�ilist_cons�(x,�ys),�pzs) of�(SNOC�(pxs,�x,�pxsx), ��������PAPPEND�(ilist_cons�(x,�pxsx),�ys,�pzs)) prfun�pal_app�{l,lr,m:ilist} ��(pf1:�REVERSE�(l,�lr),�pf2:�APPEND�(l,�lr,�m)):�PAL�(m)
  32. 32. Prop: Function signature using PALProp: Function signature using PALProp: Function signature using PALProp: Function signature using PALProp: Function signature using PAL fun{a:t@ype}�pal_empty ��():�(PAL�(ilist_nil)�│�gflist�(a,�ilist_nil�())) fun{a:t@ype}�pal_sing ��{x:int}�(x:�stamped_t�(a,�x)): ��(PAL�(ilist_sing(x))�│�gflist�(a,�ilist_sing(x))) fun{a:t@ype}�pal_pappend ��{pxs,xs:ilist} ��(pf:�PAL�(pxs)�│�pxs:�gflist�(INV(a),�pxs),�xs:�gflist�(a,�xs)): ��[pxsx:ilist]�(PAL�(pxsx),�PAPPEND�(pxs,�xs,�pxsx)�│ ����gflist�(a,�pxsx)) fun{a:t@ype}�print_pal ��{xs:ilist}�(pf:�PAL�(xs)�│�xs:�gflist�(INV(a),�xs)):�void fun{a:t@ype}�pal_empty ��():�(PAL�(ilist_nil)�│�gflist�(a,�ilist_nil�())) fun{a:t@ype}�pal_sing ��{x:int}�(x:�stamped_t�(a,�x)): ��(PAL�(ilist_sing(x))�│�gflist�(a,�ilist_sing(x))) fun{a:t@ype}�pal_pappend ��{pxs,xs:ilist} ��(pf:�PAL�(pxs)�│�pxs:�gflist�(INV(a),�pxs),�xs:�gflist�(a,�xs)): ��[pxsx:ilist]�(PAL�(pxsx),�PAPPEND�(pxs,�xs,�pxsx)�│ ����gflist�(a,�pxsx)) fun{a:t@ype}�print_pal ��{xs:ilist}�(pf:�PAL�(xs)�│�xs:�gflist�(INV(a),�xs)):�void fun{a:t@ype}�pal_empty ��():�(PAL�(ilist_nil)�│�gflist�(a,�ilist_nil�())) fun{a:t@ype}�pal_sing ��{x:int}�(x:�stamped_t�(a,�x)): ��(PAL�(ilist_sing(x))�│�gflist�(a,�ilist_sing(x))) fun{a:t@ype}�pal_pappend ��{pxs,xs:ilist} ��(pf:�PAL�(pxs)�│�pxs:�gflist�(INV(a),�pxs),�xs:�gflist�(a,�xs)): ��[pxsx:ilist]�(PAL�(pxsx),�PAPPEND�(pxs,�xs,�pxsx)�│ ����gflist�(a,�pxsx)) fun{a:t@ype}�print_pal ��{xs:ilist}�(pf:�PAL�(xs)�│�xs:�gflist�(INV(a),�xs)):�void fun{a:t@ype}�pal_empty ��():�(PAL�(ilist_nil)�│�gflist�(a,�ilist_nil�())) fun{a:t@ype}�pal_sing ��{x:int}�(x:�stamped_t�(a,�x)): ��(PAL�(ilist_sing(x))�│�gflist�(a,�ilist_sing(x))) fun{a:t@ype}�pal_pappend ��{pxs,xs:ilist} ��(pf:�PAL�(pxs)�│�pxs:�gflist�(INV(a),�pxs),�xs:�gflist�(a,�xs)): ��[pxsx:ilist]�(PAL�(pxsx),�PAPPEND�(pxs,�xs,�pxsx)�│ ����gflist�(a,�pxsx)) fun{a:t@ype}�print_pal ��{xs:ilist}�(pf:�PAL�(xs)�│�xs:�gflist�(INV(a),�xs)):�void fun{a:t@ype}�pal_empty ��():�(PAL�(ilist_nil)�│�gflist�(a,�ilist_nil�())) fun{a:t@ype}�pal_sing ��{x:int}�(x:�stamped_t�(a,�x)): ��(PAL�(ilist_sing(x))�│�gflist�(a,�ilist_sing(x))) fun{a:t@ype}�pal_pappend ��{pxs,xs:ilist} ��(pf:�PAL�(pxs)�│�pxs:�gflist�(INV(a),�pxs),�xs:�gflist�(a,�xs)): ��[pxsx:ilist]�(PAL�(pxsx),�PAPPEND�(pxs,�xs,�pxsx)�│ ����gflist�(a,�pxsx)) fun{a:t@ype}�print_pal ��{xs:ilist}�(pf:�PAL�(xs)�│�xs:�gflist�(INV(a),�xs)):�void
  33. 33. Prop: Application using PALProp: Application using PALProp: Application using PALProp: Application using PALProp: Application using PAL implement�main0�()�=�{ ��//�Pullup ��val�(pfpal�│�lpal)�=�pal_empty�() ��val�(_�│�l)�=�list2gflist�$list{char}('L',�'U',�'P') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" ��//�Devil�never�even�lived. ��val�(pfpal�│�lpal)�=�pal_sing<char>�(stamp_t�'R') ��val�(_�│�l)�=�list2gflist ����$list{char}('E',�'V',�'E',�'N',�'L',�'I',�'V',�'E',�'D') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" } implement�main0�()�=�{ ��//�Pullup ��val�(pfpal�│�lpal)�=�pal_empty�() ��val�(_�│�l)�=�list2gflist�$list{char}('L',�'U',�'P') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" ��//�Devil�never�even�lived. ��val�(pfpal�│�lpal)�=�pal_sing<char>�(stamp_t�'R') ��val�(_�│�l)�=�list2gflist ����$list{char}('E',�'V',�'E',�'N',�'L',�'I',�'V',�'E',�'D') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" } implement�main0�()�=�{ ��//�Pullup ��val�(pfpal�│�lpal)�=�pal_empty�() ��val�(_�│�l)�=�list2gflist�$list{char}('L',�'U',�'P') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" ��//�Devil�never�even�lived. ��val�(pfpal�│�lpal)�=�pal_sing<char>�(stamp_t�'R') ��val�(_�│�l)�=�list2gflist ����$list{char}('E',�'V',�'E',�'N',�'L',�'I',�'V',�'E',�'D') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" } implement�main0�()�=�{ ��//�Pullup ��val�(pfpal�│�lpal)�=�pal_empty�() ��val�(_�│�l)�=�list2gflist�$list{char}('L',�'U',�'P') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" ��//�Devil�never�even�lived. ��val�(pfpal�│�lpal)�=�pal_sing<char>�(stamp_t�'R') ��val�(_�│�l)�=�list2gflist ����$list{char}('E',�'V',�'E',�'N',�'L',�'I',�'V',�'E',�'D') ��val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) ��val�()�=�print_pal<char>�(pfpal�│�lpal) ��val�()�=�print�"n" } implement�main0�()�=�{ ��//�Pullup val�(pfpal�│�lpal)�=�pal_empty�() val�(_�│�l)�=�list2gflist�$list{char}('L',�'U',�'P') val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) val�()�=�print_pal<char>�(pfpal�│�lpal) val�()�=�print�"n" ��//�Devil�never�even�lived. val�(pfpal�│�lpal)�=�pal_sing<char>�(stamp_t�'R') val�(_�│�l)�=�list2gflist $list{char}('E',�'V',�'E',�'N',�'L',�'I',�'V',�'E',�'D') val�(pfpal,�_�│�lpal)�=�pal_pappend�(pfpal�│�lpal,�l) val�()�=�print_pal<char>�(pfpal�│�lpal) val�()�=�print�"n" } $�patscc�main.dats�-DATS_MEMALLOC_LIBC $�./a.out P,�U,�L,�L,�U,�P D,�E,�V,�I,�L,�N,�E,�V,�E,�R,�E,�V,�E,�N,�L,�I,�V,�E,�D $�patscc�main.dats�-DATS_MEMALLOC_LIBC $�./a.out P,�U,�L,�L,�U,�P D,�E,�V,�I,�L,�N,�E,�V,�E,�R,�E,�V,�E,�N,�L,�I,�V,�E,�D $�patscc�main.dats�-DATS_MEMALLOC_LIBC $�./a.out P,�U,�L,�L,�U,�P D,�E,�V,�I,�L,�N,�E,�V,�E,�R,�E,�V,�E,�N,�L,�I,�V,�E,�D $�patscc�main.dats�-DATS_MEMALLOC_LIBC $�./a.out P,�U,�L,�L,�U,�P D,�E,�V,�I,�L,�N,�E,�V,�E,�R,�E,�V,�E,�N,�L,�I,�V,�E,�D $�patscc�main.dats�-DATS_MEMALLOC_LIBC $�./a.out P,�U,�L,�L,�U,�P D,�E,�V,�I,�L,�N,�E,�V,�E,�R,�E,�V,�E,�N,�L,�I,�V,�E,�D
  34. 34. View is linear typeView is linear typeView is linear typeView is linear typeView is linear type ☆ View is linear type in ATS☆ View is linear type in ATS☆ View is linear type in ATS☆ View is linear type in ATS☆ View is linear type in ATS ☆ View manages producing and consuming resource ☆ View manages producing and consuming resource ☆ View manages producing and consuming resource ☆ View manages producing and consuming resource ☆ View manages producing and consuming resource ☆ Example of resource: memory chunk, array, list, queue, lock/unlock, session, ... ☆ Example of resource: memory chunk, array, list, queue, lock/unlock, session, ... ☆ Example of resource: memory chunk, array, list, queue, lock/unlock, session, ... ☆ Example of resource: memory chunk, array, list, queue, lock/unlock, session, ... ☆ Example of resource: memory chunk, array, list, queue, lock/unlock, session, ... ☆ At-view is a ticket to permit dereferencing pointer ☆ At-view is a ticket to permit dereferencing pointer ☆ At-view is a ticket to permit dereferencing pointer ☆ At-view is a ticket to permit dereferencing pointer ☆ At-view is a ticket to permit dereferencing pointer
  35. 35. View: Type of listView: Type of listView: Type of listView: Type of listView: Type of list List defined with linear type.List defined with linear type.List defined with linear type.List defined with linear type.List defined with linear type.
  36. 36. View: Figure of create listView: Figure of create listView: Figure of create listView: Figure of create listView: Figure of create list
  37. 37. View: Code of create listView: Code of create listView: Code of create listView: Code of create listView: Code of create list #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l�=�list_vt_make_pair�(1,�2) ��val�()�=�print_list_vt<int>�l (*val�()�=�list_vt_free<int>�l�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l�=�list_vt_make_pair�(1,�2) ��val�()�=�print_list_vt<int>�l (*val�()�=�list_vt_free<int>�l�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l�=�list_vt_make_pair�(1,�2) ��val�()�=�print_list_vt<int>�l (*val�()�=�list_vt_free<int>�l�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l�=�list_vt_make_pair�(1,�2) ��val�()�=�print_list_vt<int>�l (*val�()�=�list_vt_free<int>�l�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ val�l�=�list_vt_make_pair�(1,�2) val�()�=�print_list_vt<int>�l (*val�()�=�list_vt_free<int>�l�*) (*�Compile-time�error!�*) }
  38. 38. View: Figure of append listView: Figure of append listView: Figure of append listView: Figure of append listView: Figure of append list
  39. 39. View: Code of append listView: Code of append listView: Code of append listView: Code of append listView: Code of append list #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l1�=�list_vt_make_pair�(1,�2) ��val�l2�=�list_vt_make_sing�3 ��val�l3�=�list_vt_append�(l2,�l1) ��val�()�=�print_list_vt<int>�l3�(*�=>�3,�1,�2�*) (*val�()�=�list_vt_free<int>�l3�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l1�=�list_vt_make_pair�(1,�2) ��val�l2�=�list_vt_make_sing�3 ��val�l3�=�list_vt_append�(l2,�l1) ��val�()�=�print_list_vt<int>�l3�(*�=>�3,�1,�2�*) (*val�()�=�list_vt_free<int>�l3�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l1�=�list_vt_make_pair�(1,�2) ��val�l2�=�list_vt_make_sing�3 ��val�l3�=�list_vt_append�(l2,�l1) ��val�()�=�print_list_vt<int>�l3�(*�=>�3,�1,�2�*) (*val�()�=�list_vt_free<int>�l3�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�l1�=�list_vt_make_pair�(1,�2) ��val�l2�=�list_vt_make_sing�3 ��val�l3�=�list_vt_append�(l2,�l1) ��val�()�=�print_list_vt<int>�l3�(*�=>�3,�1,�2�*) (*val�()�=�list_vt_free<int>�l3�*)�(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ val�l1�=�list_vt_make_pair�(1,�2) val�l2�=�list_vt_make_sing�3 val�l3�=�list_vt_append�(l2,�l1) val�()�=�print_list_vt<int>�l3�(*�=>�3,�1,�2�*) (*val�()�=�list_vt_free<int>�l3�*) (*�Compile-time�error!�*) }
  40. 40. At-view: Figure of using pointerAt-view: Figure of using pointerAt-view: Figure of using pointerAt-view: Figure of using pointerAt-view: Figure of using pointer
  41. 41. At-view: Code of using pointerAt-view: Code of using pointerAt-view: Code of using pointerAt-view: Code of using pointerAt-view: Code of using pointer #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�(pfat,�pfgc�│�p)�=�ptr_alloc<int>�()�(*�The�pfat�is�an�at-view�*) ��val�()�=�!p�:=�9�������������������������(*�Store�value�into�pointer�*) ��val�()�=�println!�!p���������������������(*�Show�value�in�the�pointer�*) ��val�()�=�ptr_free�(pfgc,�pfat�│�p) ��val�()�=�println!�!p���������������������(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�(pfat,�pfgc�│�p)�=�ptr_alloc<int>�()�(*�The�pfat�is�an�at-view�*) ��val�()�=�!p�:=�9�������������������������(*�Store�value�into�pointer�*) ��val�()�=�println!�!p���������������������(*�Show�value�in�the�pointer�*) ��val�()�=�ptr_free�(pfgc,�pfat�│�p) ��val�()�=�println!�!p���������������������(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�(pfat,�pfgc�│�p)�=�ptr_alloc<int>�()�(*�The�pfat�is�an�at-view�*) ��val�()�=�!p�:=�9�������������������������(*�Store�value�into�pointer�*) ��val�()�=�println!�!p���������������������(*�Show�value�in�the�pointer�*) ��val�()�=�ptr_free�(pfgc,�pfat�│�p) ��val�()�=�println!�!p���������������������(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ ��val�(pfat,�pfgc�│�p)�=�ptr_alloc<int>�()�(*�The�pfat�is�an�at-view�*) ��val�()�=�!p�:=�9�������������������������(*�Store�value�into�pointer�*) ��val�()�=�println!�!p���������������������(*�Show�value�in�the�pointer�*) ��val�()�=�ptr_free�(pfgc,�pfat�│�p) ��val�()�=�println!�!p���������������������(*�Compile-time�error!�*) } #include�"share/atspre_staload.hats" implement�main0�()�=�{ val�(pfat,�pfgc�│�p)�=�ptr_alloc<int>�()�(*�The�pfat�is�an�at-view�*) val�()�=�!p�:=�9 (*�Store�value�into�pointer�*) val�()�=�println!�!p���������������������(*�Show�value�in�the�pointer�*) val�()�=�ptr_free�(pfgc,�pfat�│�p) val�()�=�println!�!p���������������������(*�Compile-time�error!�*) }
  42. 42. Join "Japan ATS User Group" !Join "Japan ATS User Group" !Join "Japan ATS User Group" !Join "Japan ATS User Group" !Join "Japan ATS User Group" ! http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/ We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. *�ATSプログラミング⼊門 ��http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ *�ATSプログラミングチュートリアル ��http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ *�Effective�ATS ��https://github.com/jats-ug/translate/blob/master/Manual/EffectiveATS.md *�ATSプログラミング⼊門 ��http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ *�ATSプログラミングチュートリアル ��http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ *�Effective�ATS ��https://github.com/jats-ug/translate/blob/master/Manual/EffectiveATS.md *�ATSプログラミング⼊門 ��http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ *�ATSプログラミングチュートリアル ��http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ *�Effective�ATS ��https://github.com/jats-ug/translate/blob/master/Manual/EffectiveATS.md *�ATSプログラミング⼊門 ��http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ *�ATSプログラミングチュートリアル ��http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ *�Effective�ATS ��https://github.com/jats-ug/translate/blob/master/Manual/EffectiveATS.md *�ATSプログラミング⼊門 ��http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ *�ATSプログラミングチュートリアル ��http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ *�Effective�ATS ��https://github.com/jats-ug/translate/blob/master/Manual/EffectiveATS.md Join us and review it!Join us and review it!Join us and review it!Join us and review it!Join us and review it!

×