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

More Related Content

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 microcontroller
Kiwamu 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 language
Kiwamu 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 language
Kiwamu 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 language
Kiwamu 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 Arduino
Kiwamu Okabe
 
ATS2 updates 2017
ATS2 updates 2017ATS2 updates 2017
ATS2 updates 2017
Kiwamu Okabe
 
ATS/LF for Coq users
ATS/LF for Coq usersATS/LF for Coq users
ATS/LF for Coq users
Kiwamu Okabe
 
Past and today of Metasepi project
Past and today of Metasepi projectPast and today of Metasepi project
Past and today of Metasepi project
Kiwamu 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 ATS
Kiwamu 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, again
Kiwamu 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 Tal
Julia 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 GC
Kiwamu Okabe
 
Spring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good partsSpring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good parts
Jarek Ratajski
 
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLON
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLONGareth Rushgrove (Puppet) - Ubiquity at #DOXLON
Gareth Rushgrove (Puppet) - Ubiquity at #DOXLON
Outlyer
 
My talk at Linux Piter 2016
My talk at Linux Piter 2016My talk at Linux Piter 2016
My talk at Linux Piter 2016
Alex Chistyakov
 
Debugging with pry
Debugging with pryDebugging with pry
Debugging with pry
Creditas
 
JavaScript Speech Recognition
JavaScript Speech RecognitionJavaScript Speech Recognition
JavaScript Speech Recognition
FITC
 
DNSSec
DNSSecDNSSec

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 @ Osaka
Kiwamu 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 @ Nagoya
Kiwamu Okabe
 
Origins of Serverless
Origins of ServerlessOrigins of Serverless
Origins of Serverless
Andrii Soldatenko
 
Metasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewMetasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project Overview
Kiwamu Okabe
 
Safer IoT using functional language
Safer IoT using functional languageSafer IoT using functional language
Safer IoT using functional language
Kiwamu Okabe
 
Functional MCU programming
Functional MCU programmingFunctional MCU programming
Functional MCU programming
Kiwamu 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 type
Kiwamu Okabe
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
Atlassian
 
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
Ted 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 Domain
Ken Collins
 
Try! Swift Tokyo2017
Try! Swift Tokyo2017Try! Swift Tokyo2017
Try! Swift Tokyo2017
Amy 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 plan
Kiwamu Okabe
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
John Anderson
 
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 Performance
allmarkedup
 
Introduction to VeriFast @ Kyoto
Introduction to VeriFast @ KyotoIntroduction to VeriFast @ Kyoto
Introduction to VeriFast @ Kyoto
Kiwamu Okabe
 
EcmaScript
EcmaScriptEcmaScript
EcmaScript
Fernanda Bernardo
 
JS Experience 2017 - ECMAScript 7
JS Experience 2017 - ECMAScript 7JS Experience 2017 - ECMAScript 7
JS Experience 2017 - ECMAScript 7
iMasters
 
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 OS
Kiwamu 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

Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 

Recently uploaded (20)

Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 

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!