SlideShare a Scribd company logo
ATS Programming TutorialATS Programming TutorialATS Programming TutorialATS Programming TutorialATS Programming Tutorial
Kiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICS
Are you ready?Are you ready?Are you ready?Are you ready?Are you ready?
Have you installed ATS2 compiler? If
not, please install the ATS2 into your
PC on following manual:
Have you installed ATS2 compiler? If
not, please install the ATS2 into your
PC on following manual:
Have you installed ATS2 compiler? If
not, please install the ATS2 into your
PC on following manual:
Have you installed ATS2 compiler? If
not, please install the ATS2 into your
PC on following manual:
Have you installed ATS2 compiler? If
not, please install the ATS2 into your
PC on following manual:
☆ 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
Also, you can get a code of this slide at
following:
Also, you can get a code of this slide at
following:
Also, you can get a code of this slide at
following:
Also, you can get a code of this slide at
following:
Also, you can get a code of this slide at
following:
☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306
Install ATS2 into Debian #1Install ATS2 into Debian #1Install ATS2 into Debian #1Install ATS2 into Debian #1Install ATS2 into Debian #1
☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler
$ wget http://downloads.sourceforge.net/project/ats2-lang/ats2-
lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/
ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang/ats2-
lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/
ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang/ats2-
lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/
ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang/ats2-
lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/
ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang/ats2-
lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz
$ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/
ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz
☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2
$ 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
Install ATS2 into Debian #2Install ATS2 into Debian #2Install ATS2 into Debian #2Install ATS2 into Debian #2Install ATS2 into Debian #2
☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler
$ tar xf ATS2-Postiats-0.1.9.tgz
$ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9
$ export PATH=${PATSHOME}/bin:${PATH}
$ tar xf ATS2-Postiats-contrib-0.1.6.tgz
$ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6
$ cd ${PATSHOME}
$ ./configure
$ make
$ tar xf ATS2-Postiats-0.1.9.tgz
$ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9
$ export PATH=${PATSHOME}/bin:${PATH}
$ tar xf ATS2-Postiats-contrib-0.1.6.tgz
$ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6
$ cd ${PATSHOME}
$ ./configure
$ make
$ tar xf ATS2-Postiats-0.1.9.tgz
$ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9
$ export PATH=${PATSHOME}/bin:${PATH}
$ tar xf ATS2-Postiats-contrib-0.1.6.tgz
$ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6
$ cd ${PATSHOME}
$ ./configure
$ make
$ tar xf ATS2-Postiats-0.1.9.tgz
$ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9
$ export PATH=${PATSHOME}/bin:${PATH}
$ tar xf ATS2-Postiats-contrib-0.1.6.tgz
$ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6
$ cd ${PATSHOME}
$ ./configure
$ make
$ tar xf ATS2-Postiats-0.1.9.tgz
$ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9
$ export PATH=${PATSHOME}/bin:${PATH}
$ tar xf ATS2-Postiats-contrib-0.1.6.tgz
$ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6
$ 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.1.9 with Copyright (c) 2011-2015 Hongwei Xi
$ patsopt --version
ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi
$ patsopt --version
ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi
$ patsopt --version
ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi
$ patsopt --version
ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi
What is ATS?What is ATS?What is ATS?What is ATS?What is 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
☆ Dependent types☆ Dependent types☆ Dependent types☆ Dependent types☆ Dependent types
☆ Linear types☆ Linear types☆ Linear types☆ Linear types☆ Linear types
☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC
☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime
☆ Successor of Dependent ML☆ Successor of Dependent ML☆ Successor of Dependent ML☆ Successor of Dependent ML☆ Successor of Dependent ML
What can ATS do?What can ATS do?What can ATS do?What can ATS do?What can ATS do?
☆ Proof code using dependent types☆ Proof code using dependent types☆ Proof code using dependent types☆ Proof code using dependent types☆ Proof 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
☆ 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
☆ 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
The goal of todayThe goal of todayThe goal of todayThe goal of todayThe goal of today
Already, ATS has some good documents.Already, ATS has some good documents.Already, ATS has some good documents.Already, ATS has some good documents.Already, ATS has some good documents.
* Introduction to Programming in ATS
http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/
* A Tutorial on Programming Features in ATS
http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/
* Effective ATS
http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/
* Wiki for ATS2
https://github.com/githwxi/ATS-Postiats/wiki
* Introduction to Programming in ATS
http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/
* A Tutorial on Programming Features in ATS
http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/
* Effective ATS
http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/
* Wiki for ATS2
https://github.com/githwxi/ATS-Postiats/wiki
* Introduction to Programming in ATS
http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/
* A Tutorial on Programming Features in ATS
http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/
* Effective ATS
http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/
* Wiki for ATS2
https://github.com/githwxi/ATS-Postiats/wiki
* Introduction to Programming in ATS
http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/
* A Tutorial on Programming Features in ATS
http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/
* Effective ATS
http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/
* Wiki for ATS2
https://github.com/githwxi/ATS-Postiats/wiki
* Introduction to Programming in ATS
http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/
* A Tutorial on Programming Features in ATS
http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/
* Effective ATS
http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/
* Wiki for ATS2
https://github.com/githwxi/ATS-Postiats/wiki
However, they are sometimes hard for
beginner. The goal of today is to learn
to read "Introduction to Programming
in ATS" by yourself.
However, they are sometimes hard for
beginner. The goal of today is to learn
to read "Introduction to Programming
in ATS" by yourself.
However, they are sometimes hard for
beginner. The goal of today is to learn
to read "Introduction to Programming
in ATS" by yourself.
However, they are sometimes hard for
beginner. The goal of today is to learn
to read "Introduction to Programming
in ATS" by yourself.
However, they are sometimes hard for
beginner. The goal of today is to learn
to read "Introduction to Programming
in ATS" by yourself.
Hello WorldHello WorldHello WorldHello WorldHello World
$ vi helloworld.dats
val () = println! "Hello, world!"
implement main0 () = ()
$ patscc helloworld.dats
$ ./a.out
Hello, world!
$ vi helloworld.dats
val () = println! "Hello, world!"
implement main0 () = ()
$ patscc helloworld.dats
$ ./a.out
Hello, world!
$ vi helloworld.dats
val () = println! "Hello, world!"
implement main0 () = ()
$ patscc helloworld.dats
$ ./a.out
Hello, world!
$ vi helloworld.dats
val () = println! "Hello, world!"
implement main0 () = ()
$ patscc helloworld.dats
$ ./a.out
Hello, world!
$ vi helloworld.dats
val () = println! "Hello, world!"
implement main0 () = ()
$ patscc helloworld.dats
$ ./a.out
Hello, world!
You can call println! directly.You can call println! directly.You can call println! directly.You can call println! directly.You can call println! directly.
$ vi helloworld2.dats
implement main0 () = () where {
val () = println! "Hello, world!"
}
$ vi helloworld2.dats
implement main0 () = () where {
val () = println! "Hello, world!"
}
$ vi helloworld2.dats
implement main0 () = () where {
val () = println! "Hello, world!"
}
$ vi helloworld2.dats
implement main0 () = () where {
val () = println! "Hello, world!"
}
$ vi helloworld2.dats
implement main0 () = () where {
val () = println! "Hello, world!"
}
Or more simply...Or more simply...Or more simply...Or more simply...Or more simply...
$ vi helloworld3.dats
implement main0 () = println! "Hello, world!"
$ vi helloworld3.dats
implement main0 () = println! "Hello, world!"
$ vi helloworld3.dats
implement main0 () = println! "Hello, world!"
$ vi helloworld3.dats
implement main0 () = println! "Hello, world!"
$ vi helloworld3.dats
implement main0 () = println! "Hello, world!"
IntegerIntegerIntegerIntegerInteger
The "share/atspre_staload.hats" is
needed by overloaded operators.
The "share/atspre_staload.hats" is
needed by overloaded operators.
The "share/atspre_staload.hats" is
needed by overloaded operators.
The "share/atspre_staload.hats" is
needed by overloaded operators.
The "share/atspre_staload.hats" is
needed by overloaded operators.
$ vi int_op.dats
#include "share/atspre_staload.hats"
val () = println! (3 + 4 * 2)
val () = println! ((3 + 4) * 2)
val () = println! (2 - 3)
val () = println! (7 / 2)
val () = println! (7 % 2)
implement main0 () = ()
$ patscc int_op.dats
$ ./a.out
11
14
-1
3
1
$ vi int_op.dats
#include "share/atspre_staload.hats"
val () = println! (3 + 4 * 2)
val () = println! ((3 + 4) * 2)
val () = println! (2 - 3)
val () = println! (7 / 2)
val () = println! (7 % 2)
implement main0 () = ()
$ patscc int_op.dats
$ ./a.out
11
14
-1
3
1
$ vi int_op.dats
#include "share/atspre_staload.hats"
val () = println! (3 + 4 * 2)
val () = println! ((3 + 4) * 2)
val () = println! (2 - 3)
val () = println! (7 / 2)
val () = println! (7 % 2)
implement main0 () = ()
$ patscc int_op.dats
$ ./a.out
11
14
-1
3
1
$ vi int_op.dats
#include "share/atspre_staload.hats"
val () = println! (3 + 4 * 2)
val () = println! ((3 + 4) * 2)
val () = println! (2 - 3)
val () = println! (7 / 2)
val () = println! (7 % 2)
implement main0 () = ()
$ patscc int_op.dats
$ ./a.out
11
14
-1
3
1
$ vi int_op.dats
#include "share/atspre_staload.hats"
val () = println! (3 + 4 * 2)
val () = println! ((3 + 4) * 2)
val () = println! (2 - 3)
val () = println! (7 / 2)
val () = println! (7 % 2)
implement main0 () = ()
$ patscc int_op.dats
$ ./a.out
11
14
-1
3
1
Zero DivisionZero DivisionZero DivisionZero DivisionZero Division
But, zero-division causes compile error!But, zero-division causes compile error!But, zero-division causes compile error!But, zero-division causes compile error!But, zero-division causes compile error!
$ vi divmod.dats
#include "share/atspre_staload.hats"
val () = println! (7 / (2 - 2))
implement main0 () = ()
$ patscc divmod.dats
/home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61
r
)))
typechecking has failed: there are some unsolved constraints:
please inspect the above reported error message(s) for information.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi divmod.dats
#include "share/atspre_staload.hats"
val () = println! (7 / (2 - 2))
implement main0 () = ()
$ patscc divmod.dats
/home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61
r
)))
typechecking has failed: there are some unsolved constraints:
please inspect the above reported error message(s) for information.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi divmod.dats
#include "share/atspre_staload.hats"
val () = println! (7 / (2 - 2))
implement main0 () = ()
$ patscc divmod.dats
/home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61
r
)))
typechecking has failed: there are some unsolved constraints:
please inspect the above reported error message(s) for information.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi divmod.dats
#include "share/atspre_staload.hats"
val () = println! (7 / (2 - 2))
implement main0 () = ()
$ patscc divmod.dats
/home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61
r
)))
typechecking has failed: there are some unsolved constraints:
please inspect the above reported error message(s) for information.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi divmod.dats
#include "share/atspre_staload.hats"
val () = println! (7 / (2 - 2))
implement main0 () = ()
$ patscc divmod.dats
/home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61
r
)))
typechecking has failed: there are some unsolved constraints:
please inspect the above reported error message(s) for information.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
The error message is hard to be read ...The error message is hard to be read ...The error message is hard to be read ...The error message is hard to be read ...The error message is hard to be read ...
Understanding internal typesUnderstanding internal typesUnderstanding internal typesUnderstanding internal typesUnderstanding internal types
Let's decode the error message that is
represented on following internal types:
Let's decode the error message that is
represented on following internal types:
Let's decode the error message that is
represented on following internal types:
Let's decode the error message that is
represented on following internal types:
Let's decode the error message that is
represented on following internal types:
https://github.com/githwxi/ATS-Postiats/wiki/Internal-types
* S2Eapp - an application term.
* S2Ecst - a type constant (for instance, int, bool, list, etc.)
* S2Eeff - function effects.
* S2Eexi - an existentially quantified type.
* S2Eint - machine precision integer.
* S2Eintinf - infinite precision integer; commonly used for
integer sorts in most compiled versions of atsopt (patsopt).
* S2Evar - a (typically universally quantified) variable.
* S2Etop (0; T) means T?
* S2Etop (1; T) means T?!
* S2EVar - an (existentially quantified) unification variable
introduced by the typechecker.
https://github.com/githwxi/ATS-Postiats/wiki/Internal-types
* S2Eapp - an application term.
* S2Ecst - a type constant (for instance, int, bool, list, etc.)
* S2Eeff - function effects.
* S2Eexi - an existentially quantified type.
* S2Eint - machine precision integer.
* S2Eintinf - infinite precision integer; commonly used for
integer sorts in most compiled versions of atsopt (patsopt).
* S2Evar - a (typically universally quantified) variable.
* S2Etop (0; T) means T?
* S2Etop (1; T) means T?!
* S2EVar - an (existentially quantified) unification variable
introduced by the typechecker.
https://github.com/githwxi/ATS-Postiats/wiki/Internal-types
* S2Eapp - an application term.
* S2Ecst - a type constant (for instance, int, bool, list, etc.)
* S2Eeff - function effects.
* S2Eexi - an existentially quantified type.
* S2Eint - machine precision integer.
* S2Eintinf - infinite precision integer; commonly used for
integer sorts in most compiled versions of atsopt (patsopt).
* S2Evar - a (typically universally quantified) variable.
* S2Etop (0; T) means T?
* S2Etop (1; T) means T?!
* S2EVar - an (existentially quantified) unification variable
introduced by the typechecker.
https://github.com/githwxi/ATS-Postiats/wiki/Internal-types
* S2Eapp - an application term.
* S2Ecst - a type constant (for instance, int, bool, list, etc.)
* S2Eeff - function effects.
* S2Eexi - an existentially quantified type.
* S2Eint - machine precision integer.
* S2Eintinf - infinite precision integer; commonly used for
integer sorts in most compiled versions of atsopt (patsopt).
* S2Evar - a (typically universally quantified) variable.
* S2Etop (0; T) means T?
* S2Etop (1; T) means T?!
* S2EVar - an (existentially quantified) unification variable
introduced by the typechecker.
https://github.com/githwxi/ATS-Postiats/wiki/Internal-types
* S2Eapp - an application term.
* S2Ecst - a type constant (for instance, int, bool, list, etc.)
* S2Eeff - function effects.
* S2Eexi - an existentially quantified type.
* S2Eint - machine precision integer.
* S2Eintinf - infinite precision integer; commonly used for
integer sorts in most compiled versions of atsopt (patsopt).
* S2Evar - a (typically universally quantified) variable.
* S2Etop (0; T) means T?
* S2Etop (1; T) means T?!
* S2EVar - an (existentially quantified) unification variable
introduced by the typechecker.
The zero division error means...The zero division error means...The zero division error means...The zero division error means...The zero division error means...
unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar
(4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)),
S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0)))
↓ meaning
The proposition "2 - 2 != 0" is not solved.
unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar
(4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)),
S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0)))
↓ meaning
The proposition "2 - 2 != 0" is not solved.
unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar
(4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)),
S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0)))
↓ meaning
The proposition "2 - 2 != 0" is not solved.
unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar
(4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)),
S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0)))
↓ meaning
The proposition "2 - 2 != 0" is not solved.
unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar
(4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)),
S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0)))
↓ meaning
The proposition "2 - 2 != 0" is not solved.
It's powered by dependent types that
are used at ATS language's prelude.
It's powered by dependent types that
are used at ATS language's prelude.
It's powered by dependent types that
are used at ATS language's prelude.
It's powered by dependent types that
are used at ATS language's prelude.
It's powered by dependent types that
are used at ATS language's prelude.
$ vi ATS-Postiats/prelude/SATS/integer.sats
typedef
g1int_div_type
(tk:tk) =
{i,j:int | j != 0}
(g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk)
--snip--
fun g1int_div_int : g1int_div_type (intknd) = "mac#%"
fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%"
fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%"
fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
$ vi ATS-Postiats/prelude/SATS/integer.sats
typedef
g1int_div_type
(tk:tk) =
{i,j:int | j != 0}
(g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk)
--snip--
fun g1int_div_int : g1int_div_type (intknd) = "mac#%"
fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%"
fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%"
fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
$ vi ATS-Postiats/prelude/SATS/integer.sats
typedef
g1int_div_type
(tk:tk) =
{i,j:int | j != 0}
(g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk)
--snip--
fun g1int_div_int : g1int_div_type (intknd) = "mac#%"
fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%"
fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%"
fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
$ vi ATS-Postiats/prelude/SATS/integer.sats
typedef
g1int_div_type
(tk:tk) =
{i,j:int | j != 0}
(g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk)
--snip--
fun g1int_div_int : g1int_div_type (intknd) = "mac#%"
fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%"
fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%"
fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
$ vi ATS-Postiats/prelude/SATS/integer.sats
typedef
g1int_div_type
(tk:tk) =
{i,j:int | j != 0}
(g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk)
--snip--
fun g1int_div_int : g1int_div_type (intknd) = "mac#%"
fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%"
fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%"
fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
Real NumberReal NumberReal NumberReal NumberReal Number
$ vi double_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3.0 + 5.0) * 8.0 / 3.0)
implement main0 () = ()
$ patscc double_op.dats
$ ./a.out
21.333333
$ vi double_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3.0 + 5.0) * 8.0 / 3.0)
implement main0 () = ()
$ patscc double_op.dats
$ ./a.out
21.333333
$ vi double_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3.0 + 5.0) * 8.0 / 3.0)
implement main0 () = ()
$ patscc double_op.dats
$ ./a.out
21.333333
$ vi double_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3.0 + 5.0) * 8.0 / 3.0)
implement main0 () = ()
$ patscc double_op.dats
$ ./a.out
21.333333
$ vi double_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3.0 + 5.0) * 8.0 / 3.0)
implement main0 () = ()
$ patscc double_op.dats
$ ./a.out
21.333333
The operators are overloaded.The operators are overloaded.The operators are overloaded.The operators are overloaded.The operators are overloaded.
$ vi double_int_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3 + 5.0) * 8 / 3.0)
implement main0 () = ()
$ patscc double_int_op.dats
$ ./a.out
21.333333
$ vi double_int_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3 + 5.0) * 8 / 3.0)
implement main0 () = ()
$ patscc double_int_op.dats
$ ./a.out
21.333333
$ vi double_int_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3 + 5.0) * 8 / 3.0)
implement main0 () = ()
$ patscc double_int_op.dats
$ ./a.out
21.333333
$ vi double_int_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3 + 5.0) * 8 / 3.0)
implement main0 () = ()
$ patscc double_int_op.dats
$ ./a.out
21.333333
$ vi double_int_op.dats
#include "share/atspre_staload.hats"
val () = println! ((3 + 5.0) * 8 / 3.0)
implement main0 () = ()
$ patscc double_int_op.dats
$ ./a.out
21.333333
Boolean valueBoolean valueBoolean valueBoolean valueBoolean value
$ vi bool_op.dats
#include "share/atspre_staload.hats"
val () = println! (true && false)
val () = println! (not (false || not false && not false))
val () = println! (2 < 3)
val () = println! (2 < 3 && 2.0 >= 3.0)
val () = println! (2 < 3 || 2.0 = 3.0)
val () = println! (not (3 < 2))
implement main0 () = ()
$ patscc bool_op.dats
$ ./a.out
false
false
true
false
true
true
$ vi bool_op.dats
#include "share/atspre_staload.hats"
val () = println! (true && false)
val () = println! (not (false || not false && not false))
val () = println! (2 < 3)
val () = println! (2 < 3 && 2.0 >= 3.0)
val () = println! (2 < 3 || 2.0 = 3.0)
val () = println! (not (3 < 2))
implement main0 () = ()
$ patscc bool_op.dats
$ ./a.out
false
false
true
false
true
true
$ vi bool_op.dats
#include "share/atspre_staload.hats"
val () = println! (true && false)
val () = println! (not (false || not false && not false))
val () = println! (2 < 3)
val () = println! (2 < 3 && 2.0 >= 3.0)
val () = println! (2 < 3 || 2.0 = 3.0)
val () = println! (not (3 < 2))
implement main0 () = ()
$ patscc bool_op.dats
$ ./a.out
false
false
true
false
true
true
$ vi bool_op.dats
#include "share/atspre_staload.hats"
val () = println! (true && false)
val () = println! (not (false || not false && not false))
val () = println! (2 < 3)
val () = println! (2 < 3 && 2.0 >= 3.0)
val () = println! (2 < 3 || 2.0 = 3.0)
val () = println! (not (3 < 2))
implement main0 () = ()
$ patscc bool_op.dats
$ ./a.out
false
false
true
false
true
true
$ vi bool_op.dats
#include "share/atspre_staload.hats"
val () = println! (true && false)
val () = println! (not (false || not false && not false))
val () = println! (2 < 3)
val () = println! (2 < 3 && 2.0 >= 3.0)
val () = println! (2 < 3 || 2.0 = 3.0)
val () = println! (not (3 < 2))
implement main0 () = ()
$ patscc bool_op.dats
$ ./a.out
false
false
true
false
true
true
Constant definitionConstant definitionConstant definitionConstant definitionConstant definition
$ vi val_overwrite.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = 1
val b = a
val () = println! a
val () = println! b
val a = 2
val () = println! a
val () = println! b
}
$ patscc val_overwrite.dats
$ ./a.out
1
1
2
1
$ vi val_overwrite.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = 1
val b = a
val () = println! a
val () = println! b
val a = 2
val () = println! a
val () = println! b
}
$ patscc val_overwrite.dats
$ ./a.out
1
1
2
1
$ vi val_overwrite.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = 1
val b = a
val () = println! a
val () = println! b
val a = 2
val () = println! a
val () = println! b
}
$ patscc val_overwrite.dats
$ ./a.out
1
1
2
1
$ vi val_overwrite.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = 1
val b = a
val () = println! a
val () = println! b
val a = 2
val () = println! a
val () = println! b
}
$ patscc val_overwrite.dats
$ ./a.out
1
1
2
1
$ vi val_overwrite.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = 1
val b = a
val () = println! a
val () = println! b
val a = 2
val () = println! a
val () = println! b
}
$ patscc val_overwrite.dats
$ ./a.out
1
1
2
1
Function definitionFunction definitionFunction definitionFunction definitionFunction definition
$ vi two_arguments.dats
#include "share/atspre_staload.hats"
fun g (x:int, y:int): int = x * x + y * y - 4
implement main0 () = println! (g (3, 2))
$ patscc two_arguments.dats
$ ./a.out
9
$ vi two_arguments.dats
#include "share/atspre_staload.hats"
fun g (x:int, y:int): int = x * x + y * y - 4
implement main0 () = println! (g (3, 2))
$ patscc two_arguments.dats
$ ./a.out
9
$ vi two_arguments.dats
#include "share/atspre_staload.hats"
fun g (x:int, y:int): int = x * x + y * y - 4
implement main0 () = println! (g (3, 2))
$ patscc two_arguments.dats
$ ./a.out
9
$ vi two_arguments.dats
#include "share/atspre_staload.hats"
fun g (x:int, y:int): int = x * x + y * y - 4
implement main0 () = println! (g (3, 2))
$ patscc two_arguments.dats
$ ./a.out
9
$ vi two_arguments.dats
#include "share/atspre_staload.hats"
fun g (x:int, y:int): int = x * x + y * y - 4
implement main0 () = println! (g (3, 2))
$ patscc two_arguments.dats
$ ./a.out
9
TypecheckingTypecheckingTypecheckingTypecheckingTypechecking
$ vi f_takes_double.dats
#include "share/atspre_staload.hats"
fun f (x:int): int = 3 * x
implement main0 () = {
val r = f 4.0
val () = println! r
}
$ patscc f_takes_double.dats
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): the dynamic expression cannot be
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst
(double_kind))
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind))
$ vi f_takes_double.dats
#include "share/atspre_staload.hats"
fun f (x:int): int = 3 * x
implement main0 () = {
val r = f 4.0
val () = println! r
}
$ patscc f_takes_double.dats
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): the dynamic expression cannot be
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst
(double_kind))
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind))
$ vi f_takes_double.dats
#include "share/atspre_staload.hats"
fun f (x:int): int = 3 * x
implement main0 () = {
val r = f 4.0
val () = println! r
}
$ patscc f_takes_double.dats
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): the dynamic expression cannot be
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst
(double_kind))
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind))
$ vi f_takes_double.dats
#include "share/atspre_staload.hats"
fun f (x:int): int = 3 * x
implement main0 () = {
val r = f 4.0
val () = println! r
}
$ patscc f_takes_double.dats
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): the dynamic expression cannot be
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst
(double_kind))
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind))
$ vi f_takes_double.dats
#include "share/atspre_staload.hats"
fun f (x:int): int = 3 * x
implement main0 () = {
val r = f 4.0
val () = println! r
}
$ patscc f_takes_double.dats
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): the dynamic expression cannot be
/home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) --
106(line=6, offs=17): error(3): mismatch of static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst
(double_kind))
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind))
Function "f" should take value of int.Function "f" should take value of int.Function "f" should take value of int.Function "f" should take value of int.Function "f" should take value of int.
Conditional branchConditional branchConditional branchConditional branchConditional branch
$ vi if_then_else.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = if 1 < 2 then 3 else 4
val () = println! (a:int)
}
$ patscc if_then_else.dats
$ ./a.out
3
$ vi if_then_else.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = if 1 < 2 then 3 else 4
val () = println! (a:int)
}
$ patscc if_then_else.dats
$ ./a.out
3
$ vi if_then_else.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = if 1 < 2 then 3 else 4
val () = println! (a:int)
}
$ patscc if_then_else.dats
$ ./a.out
3
$ vi if_then_else.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = if 1 < 2 then 3 else 4
val () = println! (a:int)
}
$ patscc if_then_else.dats
$ ./a.out
3
$ vi if_then_else.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val a = if 1 < 2 then 3 else 4
val () = println! (a:int)
}
$ patscc if_then_else.dats
$ ./a.out
3
Able to drop else clauseAble to drop else clauseAble to drop else clauseAble to drop else clauseAble to drop else clause
$ vi println_expr.dats
#include "share/atspre_staload.hats"
implement main0 () = if 7 > 5 then println! "It's true."
$ patscc println_expr.dats
$ ./a.out
It's true.
$ vi println_expr.dats
#include "share/atspre_staload.hats"
implement main0 () = if 7 > 5 then println! "It's true."
$ patscc println_expr.dats
$ ./a.out
It's true.
$ vi println_expr.dats
#include "share/atspre_staload.hats"
implement main0 () = if 7 > 5 then println! "It's true."
$ patscc println_expr.dats
$ ./a.out
It's true.
$ vi println_expr.dats
#include "share/atspre_staload.hats"
implement main0 () = if 7 > 5 then println! "It's true."
$ patscc println_expr.dats
$ ./a.out
It's true.
$ vi println_expr.dats
#include "share/atspre_staload.hats"
implement main0 () = if 7 > 5 then println! "It's true."
$ patscc println_expr.dats
$ ./a.out
It's true.
Showing typesShowing typesShowing typesShowing typesShowing types
$ vi showtype_int.dats
val () = println! 3
val _ = $showtype 3
implement main0 () = ()
$ patscc showtype_int.dats
**SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39
(line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst
(g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas
(S2RTBASimp(1; t@ype))
$ ./a.out
3
$ vi showtype_int.dats
val () = println! 3
val _ = $showtype 3
implement main0 () = ()
$ patscc showtype_int.dats
**SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39
(line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst
(g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas
(S2RTBASimp(1; t@ype))
$ ./a.out
3
$ vi showtype_int.dats
val () = println! 3
val _ = $showtype 3
implement main0 () = ()
$ patscc showtype_int.dats
**SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39
(line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst
(g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas
(S2RTBASimp(1; t@ype))
$ ./a.out
3
$ vi showtype_int.dats
val () = println! 3
val _ = $showtype 3
implement main0 () = ()
$ patscc showtype_int.dats
**SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39
(line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst
(g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas
(S2RTBASimp(1; t@ype))
$ ./a.out
3
$ vi showtype_int.dats
val () = println! 3
val _ = $showtype 3
implement main0 () = ()
$ patscc showtype_int.dats
**SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39
(line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst
(g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas
(S2RTBASimp(1; t@ype))
$ ./a.out
3
"Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype".
"$showtype" prints out the type of a value or variable in ATS's
internal type representation. Very helpful for understanding type
errors, but the exact meaning of the output can still be cryptic
for more complicated cases.
"$showtype" prints out the type of a value or variable in ATS's
internal type representation. Very helpful for understanding type
errors, but the exact meaning of the output can still be cryptic
for more complicated cases.
"$showtype" prints out the type of a value or variable in ATS's
internal type representation. Very helpful for understanding type
errors, but the exact meaning of the output can still be cryptic
for more complicated cases.
"$showtype" prints out the type of a value or variable in ATS's
internal type representation. Very helpful for understanding type
errors, but the exact meaning of the output can still be cryptic
for more complicated cases.
"$showtype" prints out the type of a value or variable in ATS's
internal type representation. Very helpful for understanding type
errors, but the exact meaning of the output can still be cryptic
for more complicated cases.
Immutable stringImmutable stringImmutable stringImmutable stringImmutable string
$ vi print_foo.dats
#include "share/atspre_staload.hats"
val () = println! "foo"
implement main0 () = ()
$ patscc print_foo.dats
$ ./a.out
foo
$ vi print_foo.dats
#include "share/atspre_staload.hats"
val () = println! "foo"
implement main0 () = ()
$ patscc print_foo.dats
$ ./a.out
foo
$ vi print_foo.dats
#include "share/atspre_staload.hats"
val () = println! "foo"
implement main0 () = ()
$ patscc print_foo.dats
$ ./a.out
foo
$ vi print_foo.dats
#include "share/atspre_staload.hats"
val () = println! "foo"
implement main0 () = ()
$ patscc print_foo.dats
$ ./a.out
foo
$ vi print_foo.dats
#include "share/atspre_staload.hats"
val () = println! "foo"
implement main0 () = ()
$ patscc print_foo.dats
$ ./a.out
foo
However, immutable string can't do
such like following:
However, immutable string can't do
such like following:
However, immutable string can't do
such like following:
However, immutable string can't do
such like following:
However, immutable string can't do
such like following:
☆ append☆ append☆ append☆ append☆ append
☆ reverse☆ reverse☆ reverse☆ reverse☆ reverse
Try to use mutable stringTry to use mutable stringTry to use mutable stringTry to use mutable stringTry to use mutable string
$ vi try_string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
}
$ patscc try_string_append.dats
/home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135
(line=6, offs=2): error(3): the linear dynamic variable [s3$3509
(-1)] needs to be consumed but it is preserved with the type
[S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead.
patsopt(TRANS3): there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi try_string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
}
$ patscc try_string_append.dats
/home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135
(line=6, offs=2): error(3): the linear dynamic variable [s3$3509
(-1)] needs to be consumed but it is preserved with the type
[S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead.
patsopt(TRANS3): there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi try_string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
}
$ patscc try_string_append.dats
/home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135
(line=6, offs=2): error(3): the linear dynamic variable [s3$3509
(-1)] needs to be consumed but it is preserved with the type
[S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead.
patsopt(TRANS3): there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi try_string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
}
$ patscc try_string_append.dats
/home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135
(line=6, offs=2): error(3): the linear dynamic variable [s3$3509
(-1)] needs to be consumed but it is preserved with the type
[S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead.
patsopt(TRANS3): there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
$ vi try_string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
}
$ patscc try_string_append.dats
/home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135
(line=6, offs=2): error(3): the linear dynamic variable [s3$3509
(-1)] needs to be consumed but it is preserved with the type
[S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead.
patsopt(TRANS3): there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE
rrorExn(1025)
Why does error occur?Why does error occur?Why does error occur?Why does error occur?Why does error occur?
Need to free mutable stringNeed to free mutable stringNeed to free mutable stringNeed to free mutable stringNeed to free mutable string
$ vi string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
val () = free s3
}
$ patscc string_append.dats -DATS_MEMALLOC_LIBC
$ ./a.out
YokohamaStation
$ vi string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
val () = free s3
}
$ patscc string_append.dats -DATS_MEMALLOC_LIBC
$ ./a.out
YokohamaStation
$ vi string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
val () = free s3
}
$ patscc string_append.dats -DATS_MEMALLOC_LIBC
$ ./a.out
YokohamaStation
$ vi string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
val () = free s3
}
$ patscc string_append.dats -DATS_MEMALLOC_LIBC
$ ./a.out
YokohamaStation
$ vi string_append.dats
#include "share/atspre_staload.hats"
implement main0 () = {
val s3 = string_append ("Yokohama", "Station")
val () = println! s3
val () = free s3
}
$ patscc string_append.dats -DATS_MEMALLOC_LIBC
$ ./a.out
YokohamaStation
The "ATS_MEMALLOC_LIBC" flag is
needed to use malloc on libc.
The "ATS_MEMALLOC_LIBC" flag is
needed to use malloc on libc.
The "ATS_MEMALLOC_LIBC" flag is
needed to use malloc on libc.
The "ATS_MEMALLOC_LIBC" flag is
needed to use malloc on libc.
The "ATS_MEMALLOC_LIBC" flag is
needed to use malloc on libc.
How can ATS2 know failure of free?How can ATS2 know failure of free?How can ATS2 know failure of free?How can ATS2 know failure of free?How can ATS2 know failure of free?
Linear type watches resourceLinear type watches resourceLinear type watches resourceLinear type watches resourceLinear type watches resource
Type of ListType of ListType of ListType of ListType of List
Create listCreate listCreate listCreate listCreate list
$ vi make_pair.dats
#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
}
$ patscc make_pair.dats -DATS_MEMALLOC_LIBC
$ ./a.out
1, 2
$ vi make_pair.dats
#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
}
$ patscc make_pair.dats -DATS_MEMALLOC_LIBC
$ ./a.out
1, 2
$ vi make_pair.dats
#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
}
$ patscc make_pair.dats -DATS_MEMALLOC_LIBC
$ ./a.out
1, 2
$ vi make_pair.dats
#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
}
$ patscc make_pair.dats -DATS_MEMALLOC_LIBC
$ ./a.out
1, 2
$ vi make_pair.dats
#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
}
$ patscc make_pair.dats -DATS_MEMALLOC_LIBC
$ ./a.out
1, 2
The "<int>" is needed to use template
function.
The "<int>" is needed to use template
function.
The "<int>" is needed to use template
function.
The "<int>" is needed to use template
function.
The "<int>" is needed to use template
function.
Create list as figureCreate list as figureCreate list as figureCreate list as figureCreate list as figure
Append listAppend listAppend listAppend listAppend list
$ vi append_list.dats
#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
val () = list_vt_free<int> l3
}
$ patscc append_list.dats -DATS_MEMALLOC_LIBC
$ ./a.out
3, 1, 2
$ vi append_list.dats
#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
val () = list_vt_free<int> l3
}
$ patscc append_list.dats -DATS_MEMALLOC_LIBC
$ ./a.out
3, 1, 2
$ vi append_list.dats
#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
val () = list_vt_free<int> l3
}
$ patscc append_list.dats -DATS_MEMALLOC_LIBC
$ ./a.out
3, 1, 2
$ vi append_list.dats
#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
val () = list_vt_free<int> l3
}
$ patscc append_list.dats -DATS_MEMALLOC_LIBC
$ ./a.out
3, 1, 2
$ vi append_list.dats
#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
val () = list_vt_free<int> l3
}
$ patscc append_list.dats -DATS_MEMALLOC_LIBC
$ ./a.out
3, 1, 2
Append list as figureAppend list as figureAppend list as figureAppend list as figureAppend list as figure
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!

More Related Content

PDF
Functional IoT: Programming Language and OS
PDF
Start! ATS programming
PDF
Metasepi team meeting #14: ATS programming on MCU
PDF
Metasepi team meeting #16: Safety on ATS language + MCU
PDF
Functional IoT: Introduction
PDF
Functional IoT: Hardware and Platform
PDF
Metasepi team meeting #20: Start! ATS programming on MCU
PDF
ATS programming on ESP8266
Functional IoT: Programming Language and OS
Start! ATS programming
Metasepi team meeting #14: ATS programming on MCU
Metasepi team meeting #16: Safety on ATS language + MCU
Functional IoT: Introduction
Functional IoT: Hardware and Platform
Metasepi team meeting #20: Start! ATS programming on MCU
ATS programming on ESP8266

What's hot (20)

PDF
Hands-on VeriFast with STM32 microcontroller
PDF
Real-time OS system state captured by ATS language
PDF
Static typing and proof in ATS language
PDF
ATS language overview'
PDF
Embedded application designed by ATS language
PDF
Metasepi team meeting #19: ATS application on Arduino
PDF
ATS2 updates 2017
PDF
ATS/LF for Coq users
PDF
Past and today of Metasepi project
PDF
Arduino programming of ML-style in ATS
PDF
Emacs verilog-mode is coming to Debian, again
PDF
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
PDF
Monkey-patching in Python: a magic trick or a powerful tool?
PDF
Ajhc Haskell Compiler with Reentrant GC
PDF
Spring, CDI, Jakarta EE good parts
PDF
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLON
PDF
My talk at Linux Piter 2016
PDF
Debugging with pry
PDF
JavaScript Speech Recognition
PDF
Using Go in DevOps
Hands-on VeriFast with STM32 microcontroller
Real-time OS system state captured by ATS language
Static typing and proof in ATS language
ATS language overview'
Embedded application designed by ATS language
Metasepi team meeting #19: ATS application on Arduino
ATS2 updates 2017
ATS/LF for Coq users
Past and today of Metasepi project
Arduino programming of ML-style in ATS
Emacs verilog-mode is coming to Debian, again
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
Monkey-patching in Python: a magic trick or a powerful tool?
Ajhc Haskell Compiler with Reentrant GC
Spring, CDI, Jakarta EE good parts
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLON
My talk at Linux Piter 2016
Debugging with pry
JavaScript Speech Recognition
Using Go in DevOps
Ad

Similar to ATS Programming Tutorial (20)

PDF
Hands-on VeriFast with STM32 microcontroller @ Osaka
PDF
Hands-on VeriFast with STM32 microcontroller @ Nagoya
PDF
Origins of Serverless
PDF
Metasepi team meeting: Ajhc Project Overview
PDF
Safer IoT using functional language
PDF
Functional MCU programming
PDF
Poster: Generate ATS interface from C code, and introduce linear type
PDF
Becoming a Git Master - Nicola Paolucci
PDF
A Taxonomy of Clustering, or, No Container is an Island
PDF
Free The Enterprise With Ruby & Master Your Own Domain
PDF
Try! Swift Tokyo2017
PDF
RTOS application verified by VeriFast, and future plan
PDF
Automate Yo' Self
PDF
Let's contribute, HTML5Rocks/ko!
KEY
A rough guide to JavaScript Performance
PDF
Introduction to VeriFast @ Kyoto
PDF
EcmaScript
PDF
JS Experience 2017 - ECMAScript 7
PDF
Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Sour...
PDF
Metasepi team meeting #7: Snatch application on tiny OS
Hands-on VeriFast with STM32 microcontroller @ Osaka
Hands-on VeriFast with STM32 microcontroller @ Nagoya
Origins of Serverless
Metasepi team meeting: Ajhc Project Overview
Safer IoT using functional language
Functional MCU programming
Poster: Generate ATS interface from C code, and introduce linear type
Becoming a Git Master - Nicola Paolucci
A Taxonomy of Clustering, or, No Container is an Island
Free The Enterprise With Ruby & Master Your Own Domain
Try! Swift Tokyo2017
RTOS application verified by VeriFast, and future plan
Automate Yo' Self
Let's contribute, HTML5Rocks/ko!
A rough guide to JavaScript Performance
Introduction to VeriFast @ Kyoto
EcmaScript
JS Experience 2017 - ECMAScript 7
Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Sour...
Metasepi team meeting #7: Snatch application on tiny OS
Ad

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Understanding_Digital_Forensics_Presentation.pptx
Electronic commerce courselecture one. Pdf
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

ATS Programming Tutorial

  • 1. ATS Programming TutorialATS Programming TutorialATS Programming TutorialATS Programming TutorialATS Programming Tutorial Kiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICSKiwamu Okabe @ RIKEN AICS
  • 2. Are you ready?Are you ready?Are you ready?Are you ready?Are you ready? Have you installed ATS2 compiler? If not, please install the ATS2 into your PC on following manual: Have you installed ATS2 compiler? If not, please install the ATS2 into your PC on following manual: Have you installed ATS2 compiler? If not, please install the ATS2 into your PC on following manual: Have you installed ATS2 compiler? If not, please install the ATS2 into your PC on following manual: Have you installed ATS2 compiler? If not, please install the ATS2 into your PC on following manual: ☆ 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 Also, you can get a code of this slide at following: Also, you can get a code of this slide at following: Also, you can get a code of this slide at following: Also, you can get a code of this slide at following: Also, you can get a code of this slide at following: ☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306☆ http://bit.ly/ats20150306
  • 3. Install ATS2 into Debian #1Install ATS2 into Debian #1Install ATS2 into Debian #1Install ATS2 into Debian #1Install ATS2 into Debian #1 ☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler☆ Get source code of ATS2 compiler $ wget http://downloads.sourceforge.net/project/ats2-lang/ats2- lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/ ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang/ats2- lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/ ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang/ats2- lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/ ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang/ats2- lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/ ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang/ats2- lang/ats2-postiats-0.1.9/ATS2-Postiats-0.1.9.tgz $ wget http://downloads.sourceforge.net/project/ats2-lang-contrib/ ats2-lang-contrib/ATS2-Postiats-contrib-0.1.6.tgz ☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2☆ Install packages needed by the ATS2 $ 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
  • 4. Install ATS2 into Debian #2Install ATS2 into Debian #2Install ATS2 into Debian #2Install ATS2 into Debian #2Install ATS2 into Debian #2 ☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler☆ Compile the ATS2 compiler $ tar xf ATS2-Postiats-0.1.9.tgz $ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9 $ export PATH=${PATSHOME}/bin:${PATH} $ tar xf ATS2-Postiats-contrib-0.1.6.tgz $ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6 $ cd ${PATSHOME} $ ./configure $ make $ tar xf ATS2-Postiats-0.1.9.tgz $ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9 $ export PATH=${PATSHOME}/bin:${PATH} $ tar xf ATS2-Postiats-contrib-0.1.6.tgz $ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6 $ cd ${PATSHOME} $ ./configure $ make $ tar xf ATS2-Postiats-0.1.9.tgz $ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9 $ export PATH=${PATSHOME}/bin:${PATH} $ tar xf ATS2-Postiats-contrib-0.1.6.tgz $ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6 $ cd ${PATSHOME} $ ./configure $ make $ tar xf ATS2-Postiats-0.1.9.tgz $ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9 $ export PATH=${PATSHOME}/bin:${PATH} $ tar xf ATS2-Postiats-contrib-0.1.6.tgz $ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6 $ cd ${PATSHOME} $ ./configure $ make $ tar xf ATS2-Postiats-0.1.9.tgz $ export PATSHOME=`pwd`/ATS2-Postiats-0.1.9 $ export PATH=${PATSHOME}/bin:${PATH} $ tar xf ATS2-Postiats-contrib-0.1.6.tgz $ export PATSHOMERELOC=`pwd`/ATS2-Postiats-contrib-0.1.6 $ 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.1.9 with Copyright (c) 2011-2015 Hongwei Xi $ patsopt --version ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi $ patsopt --version ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi $ patsopt --version ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi $ patsopt --version ATS/Postiats version 0.1.9 with Copyright (c) 2011-2015 Hongwei Xi
  • 5. What is ATS?What is ATS?What is ATS?What is ATS?What is 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 ☆ Dependent types☆ Dependent types☆ Dependent types☆ Dependent types☆ Dependent types ☆ Linear types☆ Linear types☆ Linear types☆ Linear types☆ Linear types ☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC ☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime ☆ Successor of Dependent ML☆ Successor of Dependent ML☆ Successor of Dependent ML☆ Successor of Dependent ML☆ Successor of Dependent ML
  • 6. What can ATS do?What can ATS do?What can ATS do?What can ATS do?What can ATS do? ☆ Proof code using dependent types☆ Proof code using dependent types☆ Proof code using dependent types☆ Proof code using dependent types☆ Proof 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 ☆ 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 ☆ 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
  • 7. The goal of todayThe goal of todayThe goal of todayThe goal of todayThe goal of today Already, ATS has some good documents.Already, ATS has some good documents.Already, ATS has some good documents.Already, ATS has some good documents.Already, ATS has some good documents. * Introduction to Programming in ATS http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/ * A Tutorial on Programming Features in ATS http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/ * Effective ATS http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/ * Wiki for ATS2 https://github.com/githwxi/ATS-Postiats/wiki * Introduction to Programming in ATS http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/ * A Tutorial on Programming Features in ATS http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/ * Effective ATS http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/ * Wiki for ATS2 https://github.com/githwxi/ATS-Postiats/wiki * Introduction to Programming in ATS http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/ * A Tutorial on Programming Features in ATS http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/ * Effective ATS http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/ * Wiki for ATS2 https://github.com/githwxi/ATS-Postiats/wiki * Introduction to Programming in ATS http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/ * A Tutorial on Programming Features in ATS http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/ * Effective ATS http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/ * Wiki for ATS2 https://github.com/githwxi/ATS-Postiats/wiki * Introduction to Programming in ATS http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/ * A Tutorial on Programming Features in ATS http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/ * Effective ATS http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/ * Wiki for ATS2 https://github.com/githwxi/ATS-Postiats/wiki However, they are sometimes hard for beginner. The goal of today is to learn to read "Introduction to Programming in ATS" by yourself. However, they are sometimes hard for beginner. The goal of today is to learn to read "Introduction to Programming in ATS" by yourself. However, they are sometimes hard for beginner. The goal of today is to learn to read "Introduction to Programming in ATS" by yourself. However, they are sometimes hard for beginner. The goal of today is to learn to read "Introduction to Programming in ATS" by yourself. However, they are sometimes hard for beginner. The goal of today is to learn to read "Introduction to Programming in ATS" by yourself.
  • 8. Hello WorldHello WorldHello WorldHello WorldHello World $ vi helloworld.dats val () = println! "Hello, world!" implement main0 () = () $ patscc helloworld.dats $ ./a.out Hello, world! $ vi helloworld.dats val () = println! "Hello, world!" implement main0 () = () $ patscc helloworld.dats $ ./a.out Hello, world! $ vi helloworld.dats val () = println! "Hello, world!" implement main0 () = () $ patscc helloworld.dats $ ./a.out Hello, world! $ vi helloworld.dats val () = println! "Hello, world!" implement main0 () = () $ patscc helloworld.dats $ ./a.out Hello, world! $ vi helloworld.dats val () = println! "Hello, world!" implement main0 () = () $ patscc helloworld.dats $ ./a.out Hello, world! You can call println! directly.You can call println! directly.You can call println! directly.You can call println! directly.You can call println! directly. $ vi helloworld2.dats implement main0 () = () where { val () = println! "Hello, world!" } $ vi helloworld2.dats implement main0 () = () where { val () = println! "Hello, world!" } $ vi helloworld2.dats implement main0 () = () where { val () = println! "Hello, world!" } $ vi helloworld2.dats implement main0 () = () where { val () = println! "Hello, world!" } $ vi helloworld2.dats implement main0 () = () where { val () = println! "Hello, world!" } Or more simply...Or more simply...Or more simply...Or more simply...Or more simply... $ vi helloworld3.dats implement main0 () = println! "Hello, world!" $ vi helloworld3.dats implement main0 () = println! "Hello, world!" $ vi helloworld3.dats implement main0 () = println! "Hello, world!" $ vi helloworld3.dats implement main0 () = println! "Hello, world!" $ vi helloworld3.dats implement main0 () = println! "Hello, world!"
  • 9. IntegerIntegerIntegerIntegerInteger The "share/atspre_staload.hats" is needed by overloaded operators. The "share/atspre_staload.hats" is needed by overloaded operators. The "share/atspre_staload.hats" is needed by overloaded operators. The "share/atspre_staload.hats" is needed by overloaded operators. The "share/atspre_staload.hats" is needed by overloaded operators. $ vi int_op.dats #include "share/atspre_staload.hats" val () = println! (3 + 4 * 2) val () = println! ((3 + 4) * 2) val () = println! (2 - 3) val () = println! (7 / 2) val () = println! (7 % 2) implement main0 () = () $ patscc int_op.dats $ ./a.out 11 14 -1 3 1 $ vi int_op.dats #include "share/atspre_staload.hats" val () = println! (3 + 4 * 2) val () = println! ((3 + 4) * 2) val () = println! (2 - 3) val () = println! (7 / 2) val () = println! (7 % 2) implement main0 () = () $ patscc int_op.dats $ ./a.out 11 14 -1 3 1 $ vi int_op.dats #include "share/atspre_staload.hats" val () = println! (3 + 4 * 2) val () = println! ((3 + 4) * 2) val () = println! (2 - 3) val () = println! (7 / 2) val () = println! (7 % 2) implement main0 () = () $ patscc int_op.dats $ ./a.out 11 14 -1 3 1 $ vi int_op.dats #include "share/atspre_staload.hats" val () = println! (3 + 4 * 2) val () = println! ((3 + 4) * 2) val () = println! (2 - 3) val () = println! (7 / 2) val () = println! (7 % 2) implement main0 () = () $ patscc int_op.dats $ ./a.out 11 14 -1 3 1 $ vi int_op.dats #include "share/atspre_staload.hats" val () = println! (3 + 4 * 2) val () = println! ((3 + 4) * 2) val () = println! (2 - 3) val () = println! (7 / 2) val () = println! (7 % 2) implement main0 () = () $ patscc int_op.dats $ ./a.out 11 14 -1 3 1
  • 10. Zero DivisionZero DivisionZero DivisionZero DivisionZero Division But, zero-division causes compile error!But, zero-division causes compile error!But, zero-division causes compile error!But, zero-division causes compile error!But, zero-division causes compile error! $ vi divmod.dats #include "share/atspre_staload.hats" val () = println! (7 / (2 - 2)) implement main0 () = () $ patscc divmod.dats /home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61 r ))) typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi divmod.dats #include "share/atspre_staload.hats" val () = println! (7 / (2 - 2)) implement main0 () = () $ patscc divmod.dats /home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61 r ))) typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi divmod.dats #include "share/atspre_staload.hats" val () = println! (7 / (2 - 2)) implement main0 () = () $ patscc divmod.dats /home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61 r ))) typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi divmod.dats #include "share/atspre_staload.hats" val () = println! (7 / (2 - 2)) implement main0 () = () $ patscc divmod.dats /home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61 r ))) typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi divmod.dats #include "share/atspre_staload.hats" val () = println! (7 / (2 - 2)) implement main0 () = () $ patscc divmod.dats /home/kiwamu/tmp/tmp/divmod.dats: 60(line=3, offs=22) -- 61 r ))) typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) The error message is hard to be read ...The error message is hard to be read ...The error message is hard to be read ...The error message is hard to be read ...The error message is hard to be read ...
  • 11. Understanding internal typesUnderstanding internal typesUnderstanding internal typesUnderstanding internal typesUnderstanding internal types Let's decode the error message that is represented on following internal types: Let's decode the error message that is represented on following internal types: Let's decode the error message that is represented on following internal types: Let's decode the error message that is represented on following internal types: Let's decode the error message that is represented on following internal types: https://github.com/githwxi/ATS-Postiats/wiki/Internal-types * S2Eapp - an application term. * S2Ecst - a type constant (for instance, int, bool, list, etc.) * S2Eeff - function effects. * S2Eexi - an existentially quantified type. * S2Eint - machine precision integer. * S2Eintinf - infinite precision integer; commonly used for integer sorts in most compiled versions of atsopt (patsopt). * S2Evar - a (typically universally quantified) variable. * S2Etop (0; T) means T? * S2Etop (1; T) means T?! * S2EVar - an (existentially quantified) unification variable introduced by the typechecker. https://github.com/githwxi/ATS-Postiats/wiki/Internal-types * S2Eapp - an application term. * S2Ecst - a type constant (for instance, int, bool, list, etc.) * S2Eeff - function effects. * S2Eexi - an existentially quantified type. * S2Eint - machine precision integer. * S2Eintinf - infinite precision integer; commonly used for integer sorts in most compiled versions of atsopt (patsopt). * S2Evar - a (typically universally quantified) variable. * S2Etop (0; T) means T? * S2Etop (1; T) means T?! * S2EVar - an (existentially quantified) unification variable introduced by the typechecker. https://github.com/githwxi/ATS-Postiats/wiki/Internal-types * S2Eapp - an application term. * S2Ecst - a type constant (for instance, int, bool, list, etc.) * S2Eeff - function effects. * S2Eexi - an existentially quantified type. * S2Eint - machine precision integer. * S2Eintinf - infinite precision integer; commonly used for integer sorts in most compiled versions of atsopt (patsopt). * S2Evar - a (typically universally quantified) variable. * S2Etop (0; T) means T? * S2Etop (1; T) means T?! * S2EVar - an (existentially quantified) unification variable introduced by the typechecker. https://github.com/githwxi/ATS-Postiats/wiki/Internal-types * S2Eapp - an application term. * S2Ecst - a type constant (for instance, int, bool, list, etc.) * S2Eeff - function effects. * S2Eexi - an existentially quantified type. * S2Eint - machine precision integer. * S2Eintinf - infinite precision integer; commonly used for integer sorts in most compiled versions of atsopt (patsopt). * S2Evar - a (typically universally quantified) variable. * S2Etop (0; T) means T? * S2Etop (1; T) means T?! * S2EVar - an (existentially quantified) unification variable introduced by the typechecker. https://github.com/githwxi/ATS-Postiats/wiki/Internal-types * S2Eapp - an application term. * S2Ecst - a type constant (for instance, int, bool, list, etc.) * S2Eeff - function effects. * S2Eexi - an existentially quantified type. * S2Eint - machine precision integer. * S2Eintinf - infinite precision integer; commonly used for integer sorts in most compiled versions of atsopt (patsopt). * S2Evar - a (typically universally quantified) variable. * S2Etop (0; T) means T? * S2Etop (1; T) means T?! * S2EVar - an (existentially quantified) unification variable introduced by the typechecker.
  • 12. The zero division error means...The zero division error means...The zero division error means...The zero division error means...The zero division error means... unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar (4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)), S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0))) ↓ meaning The proposition "2 - 2 != 0" is not solved. unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar (4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)), S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0))) ↓ meaning The proposition "2 - 2 != 0" is not solved. unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar (4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)), S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0))) ↓ meaning The proposition "2 - 2 != 0" is not solved. unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar (4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)), S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0))) ↓ meaning The proposition "2 - 2 != 0" is not solved. unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(!=); S2EVar (4177->S2Eapp(S2Ecst(sub_int_int); S2EVar(4173->S2Eintinf(2)), S2EVar(4174->S2Eintinf(2)))), S2Eintinf(0))) ↓ meaning The proposition "2 - 2 != 0" is not solved. It's powered by dependent types that are used at ATS language's prelude. It's powered by dependent types that are used at ATS language's prelude. It's powered by dependent types that are used at ATS language's prelude. It's powered by dependent types that are used at ATS language's prelude. It's powered by dependent types that are used at ATS language's prelude. $ vi ATS-Postiats/prelude/SATS/integer.sats typedef g1int_div_type (tk:tk) = {i,j:int | j != 0} (g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk) --snip-- fun g1int_div_int : g1int_div_type (intknd) = "mac#%" fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%" fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%" fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%" $ vi ATS-Postiats/prelude/SATS/integer.sats typedef g1int_div_type (tk:tk) = {i,j:int | j != 0} (g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk) --snip-- fun g1int_div_int : g1int_div_type (intknd) = "mac#%" fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%" fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%" fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%" $ vi ATS-Postiats/prelude/SATS/integer.sats typedef g1int_div_type (tk:tk) = {i,j:int | j != 0} (g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk) --snip-- fun g1int_div_int : g1int_div_type (intknd) = "mac#%" fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%" fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%" fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%" $ vi ATS-Postiats/prelude/SATS/integer.sats typedef g1int_div_type (tk:tk) = {i,j:int | j != 0} (g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk) --snip-- fun g1int_div_int : g1int_div_type (intknd) = "mac#%" fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%" fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%" fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%" $ vi ATS-Postiats/prelude/SATS/integer.sats typedef g1int_div_type (tk:tk) = {i,j:int | j != 0} (g1int (tk, i), g1int (tk, j)) -<fun0> g1int (tk) --snip-- fun g1int_div_int : g1int_div_type (intknd) = "mac#%" fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%" fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%" fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
  • 13. Real NumberReal NumberReal NumberReal NumberReal Number $ vi double_op.dats #include "share/atspre_staload.hats" val () = println! ((3.0 + 5.0) * 8.0 / 3.0) implement main0 () = () $ patscc double_op.dats $ ./a.out 21.333333 $ vi double_op.dats #include "share/atspre_staload.hats" val () = println! ((3.0 + 5.0) * 8.0 / 3.0) implement main0 () = () $ patscc double_op.dats $ ./a.out 21.333333 $ vi double_op.dats #include "share/atspre_staload.hats" val () = println! ((3.0 + 5.0) * 8.0 / 3.0) implement main0 () = () $ patscc double_op.dats $ ./a.out 21.333333 $ vi double_op.dats #include "share/atspre_staload.hats" val () = println! ((3.0 + 5.0) * 8.0 / 3.0) implement main0 () = () $ patscc double_op.dats $ ./a.out 21.333333 $ vi double_op.dats #include "share/atspre_staload.hats" val () = println! ((3.0 + 5.0) * 8.0 / 3.0) implement main0 () = () $ patscc double_op.dats $ ./a.out 21.333333 The operators are overloaded.The operators are overloaded.The operators are overloaded.The operators are overloaded.The operators are overloaded. $ vi double_int_op.dats #include "share/atspre_staload.hats" val () = println! ((3 + 5.0) * 8 / 3.0) implement main0 () = () $ patscc double_int_op.dats $ ./a.out 21.333333 $ vi double_int_op.dats #include "share/atspre_staload.hats" val () = println! ((3 + 5.0) * 8 / 3.0) implement main0 () = () $ patscc double_int_op.dats $ ./a.out 21.333333 $ vi double_int_op.dats #include "share/atspre_staload.hats" val () = println! ((3 + 5.0) * 8 / 3.0) implement main0 () = () $ patscc double_int_op.dats $ ./a.out 21.333333 $ vi double_int_op.dats #include "share/atspre_staload.hats" val () = println! ((3 + 5.0) * 8 / 3.0) implement main0 () = () $ patscc double_int_op.dats $ ./a.out 21.333333 $ vi double_int_op.dats #include "share/atspre_staload.hats" val () = println! ((3 + 5.0) * 8 / 3.0) implement main0 () = () $ patscc double_int_op.dats $ ./a.out 21.333333
  • 14. Boolean valueBoolean valueBoolean valueBoolean valueBoolean value $ vi bool_op.dats #include "share/atspre_staload.hats" val () = println! (true && false) val () = println! (not (false || not false && not false)) val () = println! (2 < 3) val () = println! (2 < 3 && 2.0 >= 3.0) val () = println! (2 < 3 || 2.0 = 3.0) val () = println! (not (3 < 2)) implement main0 () = () $ patscc bool_op.dats $ ./a.out false false true false true true $ vi bool_op.dats #include "share/atspre_staload.hats" val () = println! (true && false) val () = println! (not (false || not false && not false)) val () = println! (2 < 3) val () = println! (2 < 3 && 2.0 >= 3.0) val () = println! (2 < 3 || 2.0 = 3.0) val () = println! (not (3 < 2)) implement main0 () = () $ patscc bool_op.dats $ ./a.out false false true false true true $ vi bool_op.dats #include "share/atspre_staload.hats" val () = println! (true && false) val () = println! (not (false || not false && not false)) val () = println! (2 < 3) val () = println! (2 < 3 && 2.0 >= 3.0) val () = println! (2 < 3 || 2.0 = 3.0) val () = println! (not (3 < 2)) implement main0 () = () $ patscc bool_op.dats $ ./a.out false false true false true true $ vi bool_op.dats #include "share/atspre_staload.hats" val () = println! (true && false) val () = println! (not (false || not false && not false)) val () = println! (2 < 3) val () = println! (2 < 3 && 2.0 >= 3.0) val () = println! (2 < 3 || 2.0 = 3.0) val () = println! (not (3 < 2)) implement main0 () = () $ patscc bool_op.dats $ ./a.out false false true false true true $ vi bool_op.dats #include "share/atspre_staload.hats" val () = println! (true && false) val () = println! (not (false || not false && not false)) val () = println! (2 < 3) val () = println! (2 < 3 && 2.0 >= 3.0) val () = println! (2 < 3 || 2.0 = 3.0) val () = println! (not (3 < 2)) implement main0 () = () $ patscc bool_op.dats $ ./a.out false false true false true true
  • 15. Constant definitionConstant definitionConstant definitionConstant definitionConstant definition $ vi val_overwrite.dats #include "share/atspre_staload.hats" implement main0 () = { val a = 1 val b = a val () = println! a val () = println! b val a = 2 val () = println! a val () = println! b } $ patscc val_overwrite.dats $ ./a.out 1 1 2 1 $ vi val_overwrite.dats #include "share/atspre_staload.hats" implement main0 () = { val a = 1 val b = a val () = println! a val () = println! b val a = 2 val () = println! a val () = println! b } $ patscc val_overwrite.dats $ ./a.out 1 1 2 1 $ vi val_overwrite.dats #include "share/atspre_staload.hats" implement main0 () = { val a = 1 val b = a val () = println! a val () = println! b val a = 2 val () = println! a val () = println! b } $ patscc val_overwrite.dats $ ./a.out 1 1 2 1 $ vi val_overwrite.dats #include "share/atspre_staload.hats" implement main0 () = { val a = 1 val b = a val () = println! a val () = println! b val a = 2 val () = println! a val () = println! b } $ patscc val_overwrite.dats $ ./a.out 1 1 2 1 $ vi val_overwrite.dats #include "share/atspre_staload.hats" implement main0 () = { val a = 1 val b = a val () = println! a val () = println! b val a = 2 val () = println! a val () = println! b } $ patscc val_overwrite.dats $ ./a.out 1 1 2 1
  • 16. Function definitionFunction definitionFunction definitionFunction definitionFunction definition $ vi two_arguments.dats #include "share/atspre_staload.hats" fun g (x:int, y:int): int = x * x + y * y - 4 implement main0 () = println! (g (3, 2)) $ patscc two_arguments.dats $ ./a.out 9 $ vi two_arguments.dats #include "share/atspre_staload.hats" fun g (x:int, y:int): int = x * x + y * y - 4 implement main0 () = println! (g (3, 2)) $ patscc two_arguments.dats $ ./a.out 9 $ vi two_arguments.dats #include "share/atspre_staload.hats" fun g (x:int, y:int): int = x * x + y * y - 4 implement main0 () = println! (g (3, 2)) $ patscc two_arguments.dats $ ./a.out 9 $ vi two_arguments.dats #include "share/atspre_staload.hats" fun g (x:int, y:int): int = x * x + y * y - 4 implement main0 () = println! (g (3, 2)) $ patscc two_arguments.dats $ ./a.out 9 $ vi two_arguments.dats #include "share/atspre_staload.hats" fun g (x:int, y:int): int = x * x + y * y - 4 implement main0 () = println! (g (3, 2)) $ patscc two_arguments.dats $ ./a.out 9
  • 17. TypecheckingTypecheckingTypecheckingTypecheckingTypechecking $ vi f_takes_double.dats #include "share/atspre_staload.hats" fun f (x:int): int = 3 * x implement main0 () = { val r = f 4.0 val () = println! r } $ patscc f_takes_double.dats /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): the dynamic expression cannot be /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): mismatch of static terms (tyleq): The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst (double_kind)) The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind)) $ vi f_takes_double.dats #include "share/atspre_staload.hats" fun f (x:int): int = 3 * x implement main0 () = { val r = f 4.0 val () = println! r } $ patscc f_takes_double.dats /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): the dynamic expression cannot be /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): mismatch of static terms (tyleq): The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst (double_kind)) The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind)) $ vi f_takes_double.dats #include "share/atspre_staload.hats" fun f (x:int): int = 3 * x implement main0 () = { val r = f 4.0 val () = println! r } $ patscc f_takes_double.dats /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): the dynamic expression cannot be /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): mismatch of static terms (tyleq): The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst (double_kind)) The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind)) $ vi f_takes_double.dats #include "share/atspre_staload.hats" fun f (x:int): int = 3 * x implement main0 () = { val r = f 4.0 val () = println! r } $ patscc f_takes_double.dats /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): the dynamic expression cannot be /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): mismatch of static terms (tyleq): The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst (double_kind)) The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind)) $ vi f_takes_double.dats #include "share/atspre_staload.hats" fun f (x:int): int = 3 * x implement main0 () = { val r = f 4.0 val () = println! r } $ patscc f_takes_double.dats /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): the dynamic expression cannot be /home/kiwamu/tmp/tmp/f_takes_double.dats: 103(line=6, offs=14) -- 106(line=6, offs=17): error(3): mismatch of static terms (tyleq): The actual term is: S2Eapp(S2Ecst(g0float_t0ype); S2Ecst (double_kind)) The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Ecst(int_kind)) Function "f" should take value of int.Function "f" should take value of int.Function "f" should take value of int.Function "f" should take value of int.Function "f" should take value of int.
  • 18. Conditional branchConditional branchConditional branchConditional branchConditional branch $ vi if_then_else.dats #include "share/atspre_staload.hats" implement main0 () = { val a = if 1 < 2 then 3 else 4 val () = println! (a:int) } $ patscc if_then_else.dats $ ./a.out 3 $ vi if_then_else.dats #include "share/atspre_staload.hats" implement main0 () = { val a = if 1 < 2 then 3 else 4 val () = println! (a:int) } $ patscc if_then_else.dats $ ./a.out 3 $ vi if_then_else.dats #include "share/atspre_staload.hats" implement main0 () = { val a = if 1 < 2 then 3 else 4 val () = println! (a:int) } $ patscc if_then_else.dats $ ./a.out 3 $ vi if_then_else.dats #include "share/atspre_staload.hats" implement main0 () = { val a = if 1 < 2 then 3 else 4 val () = println! (a:int) } $ patscc if_then_else.dats $ ./a.out 3 $ vi if_then_else.dats #include "share/atspre_staload.hats" implement main0 () = { val a = if 1 < 2 then 3 else 4 val () = println! (a:int) } $ patscc if_then_else.dats $ ./a.out 3
  • 19. Able to drop else clauseAble to drop else clauseAble to drop else clauseAble to drop else clauseAble to drop else clause $ vi println_expr.dats #include "share/atspre_staload.hats" implement main0 () = if 7 > 5 then println! "It's true." $ patscc println_expr.dats $ ./a.out It's true. $ vi println_expr.dats #include "share/atspre_staload.hats" implement main0 () = if 7 > 5 then println! "It's true." $ patscc println_expr.dats $ ./a.out It's true. $ vi println_expr.dats #include "share/atspre_staload.hats" implement main0 () = if 7 > 5 then println! "It's true." $ patscc println_expr.dats $ ./a.out It's true. $ vi println_expr.dats #include "share/atspre_staload.hats" implement main0 () = if 7 > 5 then println! "It's true." $ patscc println_expr.dats $ ./a.out It's true. $ vi println_expr.dats #include "share/atspre_staload.hats" implement main0 () = if 7 > 5 then println! "It's true." $ patscc println_expr.dats $ ./a.out It's true.
  • 20. Showing typesShowing typesShowing typesShowing typesShowing types $ vi showtype_int.dats val () = println! 3 val _ = $showtype 3 implement main0 () = () $ patscc showtype_int.dats **SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39 (line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst (g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas (S2RTBASimp(1; t@ype)) $ ./a.out 3 $ vi showtype_int.dats val () = println! 3 val _ = $showtype 3 implement main0 () = () $ patscc showtype_int.dats **SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39 (line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst (g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas (S2RTBASimp(1; t@ype)) $ ./a.out 3 $ vi showtype_int.dats val () = println! 3 val _ = $showtype 3 implement main0 () = () $ patscc showtype_int.dats **SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39 (line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst (g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas (S2RTBASimp(1; t@ype)) $ ./a.out 3 $ vi showtype_int.dats val () = println! 3 val _ = $showtype 3 implement main0 () = () $ patscc showtype_int.dats **SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39 (line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst (g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas (S2RTBASimp(1; t@ype)) $ ./a.out 3 $ vi showtype_int.dats val () = println! 3 val _ = $showtype 3 implement main0 () = () $ patscc showtype_int.dats **SHOWTYPE[UP]**(/home/kiwamu/tmp/tmp/showtype_int.dats: 39 (line=2, offs=19) -- 40(line=2, offs=20)): S2Eapp(S2Ecst (g1int_int_t0ype); S2Ecst(int_kind), S2Eintinf(3)): S2RTbas (S2RTBASimp(1; t@ype)) $ ./a.out 3 "Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype"."Wiki for ATS2" explains "$showtype". "$showtype" prints out the type of a value or variable in ATS's internal type representation. Very helpful for understanding type errors, but the exact meaning of the output can still be cryptic for more complicated cases. "$showtype" prints out the type of a value or variable in ATS's internal type representation. Very helpful for understanding type errors, but the exact meaning of the output can still be cryptic for more complicated cases. "$showtype" prints out the type of a value or variable in ATS's internal type representation. Very helpful for understanding type errors, but the exact meaning of the output can still be cryptic for more complicated cases. "$showtype" prints out the type of a value or variable in ATS's internal type representation. Very helpful for understanding type errors, but the exact meaning of the output can still be cryptic for more complicated cases. "$showtype" prints out the type of a value or variable in ATS's internal type representation. Very helpful for understanding type errors, but the exact meaning of the output can still be cryptic for more complicated cases.
  • 21. Immutable stringImmutable stringImmutable stringImmutable stringImmutable string $ vi print_foo.dats #include "share/atspre_staload.hats" val () = println! "foo" implement main0 () = () $ patscc print_foo.dats $ ./a.out foo $ vi print_foo.dats #include "share/atspre_staload.hats" val () = println! "foo" implement main0 () = () $ patscc print_foo.dats $ ./a.out foo $ vi print_foo.dats #include "share/atspre_staload.hats" val () = println! "foo" implement main0 () = () $ patscc print_foo.dats $ ./a.out foo $ vi print_foo.dats #include "share/atspre_staload.hats" val () = println! "foo" implement main0 () = () $ patscc print_foo.dats $ ./a.out foo $ vi print_foo.dats #include "share/atspre_staload.hats" val () = println! "foo" implement main0 () = () $ patscc print_foo.dats $ ./a.out foo However, immutable string can't do such like following: However, immutable string can't do such like following: However, immutable string can't do such like following: However, immutable string can't do such like following: However, immutable string can't do such like following: ☆ append☆ append☆ append☆ append☆ append ☆ reverse☆ reverse☆ reverse☆ reverse☆ reverse
  • 22. Try to use mutable stringTry to use mutable stringTry to use mutable stringTry to use mutable stringTry to use mutable string $ vi try_string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 } $ patscc try_string_append.dats /home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135 (line=6, offs=2): error(3): the linear dynamic variable [s3$3509 (-1)] needs to be consumed but it is preserved with the type [S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead. patsopt(TRANS3): there are [1] errors in total. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi try_string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 } $ patscc try_string_append.dats /home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135 (line=6, offs=2): error(3): the linear dynamic variable [s3$3509 (-1)] needs to be consumed but it is preserved with the type [S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead. patsopt(TRANS3): there are [1] errors in total. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi try_string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 } $ patscc try_string_append.dats /home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135 (line=6, offs=2): error(3): the linear dynamic variable [s3$3509 (-1)] needs to be consumed but it is preserved with the type [S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead. patsopt(TRANS3): there are [1] errors in total. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi try_string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 } $ patscc try_string_append.dats /home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135 (line=6, offs=2): error(3): the linear dynamic variable [s3$3509 (-1)] needs to be consumed but it is preserved with the type [S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead. patsopt(TRANS3): there are [1] errors in total. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) $ vi try_string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 } $ patscc try_string_append.dats /home/kiwamu/tmp/try_string_append.dats: 60(line=3, offs=22) -- 135 (line=6, offs=2): error(3): the linear dynamic variable [s3$3509 (-1)] needs to be consumed but it is preserved with the type [S2Eapp(S2Ecst(strptr_addr_vtype); S2EVar(4175))] instead. patsopt(TRANS3): there are [1] errors in total. exit(ATS): uncaught exception: _2home_2kiwamu_2src_2ATS_2dPostiats_2src_2pats_error_2esats__FatalE rrorExn(1025) Why does error occur?Why does error occur?Why does error occur?Why does error occur?Why does error occur?
  • 23. Need to free mutable stringNeed to free mutable stringNeed to free mutable stringNeed to free mutable stringNeed to free mutable string $ vi string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 val () = free s3 } $ patscc string_append.dats -DATS_MEMALLOC_LIBC $ ./a.out YokohamaStation $ vi string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 val () = free s3 } $ patscc string_append.dats -DATS_MEMALLOC_LIBC $ ./a.out YokohamaStation $ vi string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 val () = free s3 } $ patscc string_append.dats -DATS_MEMALLOC_LIBC $ ./a.out YokohamaStation $ vi string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 val () = free s3 } $ patscc string_append.dats -DATS_MEMALLOC_LIBC $ ./a.out YokohamaStation $ vi string_append.dats #include "share/atspre_staload.hats" implement main0 () = { val s3 = string_append ("Yokohama", "Station") val () = println! s3 val () = free s3 } $ patscc string_append.dats -DATS_MEMALLOC_LIBC $ ./a.out YokohamaStation The "ATS_MEMALLOC_LIBC" flag is needed to use malloc on libc. The "ATS_MEMALLOC_LIBC" flag is needed to use malloc on libc. The "ATS_MEMALLOC_LIBC" flag is needed to use malloc on libc. The "ATS_MEMALLOC_LIBC" flag is needed to use malloc on libc. The "ATS_MEMALLOC_LIBC" flag is needed to use malloc on libc. How can ATS2 know failure of free?How can ATS2 know failure of free?How can ATS2 know failure of free?How can ATS2 know failure of free?How can ATS2 know failure of free?
  • 24. Linear type watches resourceLinear type watches resourceLinear type watches resourceLinear type watches resourceLinear type watches resource
  • 25. Type of ListType of ListType of ListType of ListType of List
  • 26. Create listCreate listCreate listCreate listCreate list $ vi make_pair.dats #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 } $ patscc make_pair.dats -DATS_MEMALLOC_LIBC $ ./a.out 1, 2 $ vi make_pair.dats #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 } $ patscc make_pair.dats -DATS_MEMALLOC_LIBC $ ./a.out 1, 2 $ vi make_pair.dats #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 } $ patscc make_pair.dats -DATS_MEMALLOC_LIBC $ ./a.out 1, 2 $ vi make_pair.dats #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 } $ patscc make_pair.dats -DATS_MEMALLOC_LIBC $ ./a.out 1, 2 $ vi make_pair.dats #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 } $ patscc make_pair.dats -DATS_MEMALLOC_LIBC $ ./a.out 1, 2 The "<int>" is needed to use template function. The "<int>" is needed to use template function. The "<int>" is needed to use template function. The "<int>" is needed to use template function. The "<int>" is needed to use template function.
  • 27. Create list as figureCreate list as figureCreate list as figureCreate list as figureCreate list as figure
  • 28. Append listAppend listAppend listAppend listAppend list $ vi append_list.dats #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 val () = list_vt_free<int> l3 } $ patscc append_list.dats -DATS_MEMALLOC_LIBC $ ./a.out 3, 1, 2 $ vi append_list.dats #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 val () = list_vt_free<int> l3 } $ patscc append_list.dats -DATS_MEMALLOC_LIBC $ ./a.out 3, 1, 2 $ vi append_list.dats #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 val () = list_vt_free<int> l3 } $ patscc append_list.dats -DATS_MEMALLOC_LIBC $ ./a.out 3, 1, 2 $ vi append_list.dats #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 val () = list_vt_free<int> l3 } $ patscc append_list.dats -DATS_MEMALLOC_LIBC $ ./a.out 3, 1, 2 $ vi append_list.dats #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 val () = list_vt_free<int> l3 } $ patscc append_list.dats -DATS_MEMALLOC_LIBC $ ./a.out 3, 1, 2
  • 29. Append list as figureAppend list as figureAppend list as figureAppend list as figureAppend list as figure
  • 30. 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!