SlideShare a Scribd company logo
1 of 30
Download to read offline
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

What's hot

Hands-on VeriFast with STM32 microcontroller
Hands-on VeriFast with STM32 microcontrollerHands-on VeriFast with STM32 microcontroller
Hands-on VeriFast with STM32 microcontrollerKiwamu Okabe
 
Real-time OS system state captured by ATS language
Real-time OS system state captured by ATS languageReal-time OS system state captured by ATS language
Real-time OS system state captured by ATS languageKiwamu Okabe
 
Static typing and proof in ATS language
Static typing and proof in ATS languageStatic typing and proof in ATS language
Static typing and proof in ATS languageKiwamu Okabe
 
ATS language overview'
ATS language overview'ATS language overview'
ATS language overview'Kiwamu Okabe
 
Embedded application designed by ATS language
Embedded application designed by ATS languageEmbedded application designed by ATS language
Embedded application designed by ATS languageKiwamu Okabe
 
Metasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoKiwamu Okabe
 
ATS/LF for Coq users
ATS/LF for Coq usersATS/LF for Coq users
ATS/LF for Coq usersKiwamu Okabe
 
Past and today of Metasepi project
Past and today of Metasepi projectPast and today of Metasepi project
Past and today of Metasepi projectKiwamu Okabe
 
Arduino programming of ML-style in ATS
Arduino programming of ML-style in ATSArduino programming of ML-style in ATS
Arduino programming of ML-style in ATSKiwamu Okabe
 
Emacs verilog-mode is coming to Debian, again
Emacs verilog-mode is coming to Debian, againEmacs verilog-mode is coming to Debian, again
Emacs verilog-mode is coming to Debian, againKiwamu Okabe
 
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
"Black Clouds and Silver Linings in Node.js Security" Liran Tal"Black Clouds and Silver Linings in Node.js Security" Liran Tal
"Black Clouds and Silver Linings in Node.js Security" Liran TalJulia Cherniak
 
Monkey-patching in Python: a magic trick or a powerful tool?
Monkey-patching in Python: a magic trick or a powerful tool?Monkey-patching in Python: a magic trick or a powerful tool?
Monkey-patching in Python: a magic trick or a powerful tool?Elizaveta Shashkova
 
Ajhc Haskell Compiler with Reentrant GC
Ajhc Haskell Compiler with Reentrant GCAjhc Haskell Compiler with Reentrant GC
Ajhc Haskell Compiler with Reentrant GCKiwamu Okabe
 
Spring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good partsSpring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good partsJarek Ratajski
 
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLON
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLONGareth Rushgrove (Puppet) - Ubiquity at #DOXLON
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLONOutlyer
 
My talk at Linux Piter 2016
My talk at Linux Piter 2016My talk at Linux Piter 2016
My talk at Linux Piter 2016Alex Chistyakov
 
Debugging with pry
Debugging with pryDebugging with pry
Debugging with pryCreditas
 
JavaScript Speech Recognition
JavaScript Speech RecognitionJavaScript Speech Recognition
JavaScript Speech RecognitionFITC
 

What's hot (20)

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

Similar to ATS Programming Tutorial

Hands-on VeriFast with STM32 microcontroller @ Osaka
Hands-on VeriFast with STM32 microcontroller @ OsakaHands-on VeriFast with STM32 microcontroller @ Osaka
Hands-on VeriFast with STM32 microcontroller @ OsakaKiwamu Okabe
 
Hands-on VeriFast with STM32 microcontroller @ Nagoya
Hands-on VeriFast with STM32 microcontroller @ NagoyaHands-on VeriFast with STM32 microcontroller @ Nagoya
Hands-on VeriFast with STM32 microcontroller @ NagoyaKiwamu Okabe
 
Metasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewMetasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewKiwamu Okabe
 
Safer IoT using functional language
Safer IoT using functional languageSafer IoT using functional language
Safer IoT using functional languageKiwamu Okabe
 
Functional MCU programming
Functional MCU programmingFunctional MCU programming
Functional MCU programmingKiwamu Okabe
 
Poster: Generate ATS interface from C code, and introduce linear type
Poster: Generate ATS interface from C code, and introduce linear typePoster: Generate ATS interface from C code, and introduce linear type
Poster: Generate ATS interface from C code, and introduce linear typeKiwamu Okabe
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciAtlassian
 
A Taxonomy of Clustering, or, No Container is an Island
A Taxonomy of Clustering, or, No Container is an IslandA Taxonomy of Clustering, or, No Container is an Island
A Taxonomy of Clustering, or, No Container is an IslandTed M. Young
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainKen Collins
 
Try! Swift Tokyo2017
Try! Swift Tokyo2017Try! Swift Tokyo2017
Try! Swift Tokyo2017Amy Cheong
 
RTOS application verified by VeriFast, and future plan
RTOS application verified by VeriFast, and future planRTOS application verified by VeriFast, and future plan
RTOS application verified by VeriFast, and future planKiwamu Okabe
 
Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Chang W. Doh
 
A rough guide to JavaScript Performance
A rough guide to JavaScript PerformanceA rough guide to JavaScript Performance
A rough guide to JavaScript Performanceallmarkedup
 
Introduction to VeriFast @ Kyoto
Introduction to VeriFast @ KyotoIntroduction to VeriFast @ Kyoto
Introduction to VeriFast @ KyotoKiwamu Okabe
 
JS Experience 2017 - ECMAScript 7
JS Experience 2017 - ECMAScript 7JS Experience 2017 - ECMAScript 7
JS Experience 2017 - ECMAScript 7iMasters
 
Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Sour...
Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Sour...Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Sour...
Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Sour...Moritz Beller
 
Metasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSMetasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSKiwamu Okabe
 

Similar to ATS Programming Tutorial (20)

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

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

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!