+ All Categories
Home > Technology > Metasepi team meeting #19: ATS application on Arduino

Metasepi team meeting #19: ATS application on Arduino

Date post: 29-Nov-2014
Category:
Upload: kiwamu-okabe
View: 798 times
Download: 3 times
Share this document with a friend
Description:
* [0] ATS application demo * [1] What is Metasepi? * [2] How to create Metasepi? * [3] What is ATS language? * [4] Let's read the demo code * [5] Japan ATS User Group
33
Metasepi team meeting #19: ATS application on Arduino Metasepi team meeting #19: ATS application on Arduino Metasepi team meeting #19: ATS application on Arduino Metasepi team meeting #19: ATS application on Arduino Metasepi team meeting #19: ATS application on Arduino Kiwamu Okabe @ Metasepi Project Kiwamu Okabe @ Metasepi Project Kiwamu Okabe @ Metasepi Project Kiwamu Okabe @ Metasepi Project Kiwamu Okabe @ Metasepi Project
Transcript
Page 1: Metasepi team meeting #19: ATS application on Arduino

Metasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19:ATS application on Arduino

Kiwamu Okabe @ Metasepi ProjectKiwamu Okabe @ Metasepi ProjectKiwamu Okabe @ Metasepi ProjectKiwamu Okabe @ Metasepi ProjectKiwamu Okabe @ Metasepi Project

Page 2: Metasepi team meeting #19: ATS application on Arduino

Demo: ATS on Arduino UnoDemo: ATS on Arduino UnoDemo: ATS on Arduino UnoDemo: ATS on Arduino UnoDemo: ATS on Arduino Uno

☆ http://nico.ms/sm24680530☆ http://nico.ms/sm24680530☆ http://nico.ms/sm24680530☆ http://nico.ms/sm24680530☆ http://nico.ms/sm24680530

☆ https://github.com/fpiot/arduino-ats☆ https://github.com/fpiot/arduino-ats☆ https://github.com/fpiot/arduino-ats☆ https://github.com/fpiot/arduino-ats☆ https://github.com/fpiot/arduino-ats

☆ Without any GC, and any malloc☆ Without any GC, and any malloc☆ Without any GC, and any malloc☆ Without any GC, and any malloc☆ Without any GC, and any malloc

Page 3: Metasepi team meeting #19: ATS application on Arduino

Demo: Arduino UnoDemo: Arduino UnoDemo: Arduino UnoDemo: Arduino UnoDemo: Arduino Uno

☆ MCU: ATmega328☆ MCU: ATmega328☆ MCU: ATmega328☆ MCU: ATmega328☆ MCU: ATmega328

☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB

☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KBhttp://arduino.cc/en/Main/ArduinoBoardUnohttp://arduino.cc/en/Main/ArduinoBoardUnohttp://arduino.cc/en/Main/ArduinoBoardUnohttp://arduino.cc/en/Main/ArduinoBoardUnohttp://arduino.cc/en/Main/ArduinoBoardUno

Page 4: Metasepi team meeting #19: ATS application on Arduino

Demo: LCD ShieldDemo: LCD ShieldDemo: LCD ShieldDemo: LCD ShieldDemo: LCD Shield

☆ LinkSprite 16X2 LCD Keypad Shield☆ LinkSprite 16X2 LCD Keypad Shield☆ LinkSprite 16X2 LCD Keypad Shield☆ LinkSprite 16X2 LCD Keypad Shield☆ LinkSprite 16X2 LCD Keypad Shield

☆ 16x2 LCD☆ 16x2 LCD☆ 16x2 LCD☆ 16x2 LCD☆ 16x2 LCD

☆ HD44780 compatible☆ HD44780 compatible☆ HD44780 compatible☆ HD44780 compatible☆ HD44780 compatiblehttp://store.linksprite.com/linksprite-16x2-lcd-keypad-shield-for-arduino-version-b/http://store.linksprite.com/linksprite-16x2-lcd-keypad-shield-for-arduino-version-b/http://store.linksprite.com/linksprite-16x2-lcd-keypad-shield-for-arduino-version-b/http://store.linksprite.com/linksprite-16x2-lcd-keypad-shield-for-arduino-version-b/http://store.linksprite.com/linksprite-16x2-lcd-keypad-shield-for-arduino-version-b/

Page 5: Metasepi team meeting #19: ATS application on Arduino

Demo: Software ArchitectureDemo: Software ArchitectureDemo: Software ArchitectureDemo: Software ArchitectureDemo: Software Architecture

Page 6: Metasepi team meeting #19: ATS application on Arduino

Demo code: main.datsDemo code: main.datsDemo code: main.datsDemo code: main.datsDemo code: main.dats

Page 7: Metasepi team meeting #19: ATS application on Arduino

Demo code: lcs.satsDemo code: lcs.satsDemo code: lcs.satsDemo code: lcs.satsDemo code: lcs.sats

Page 8: Metasepi team meeting #19: ATS application on Arduino

Demo code: lcs.datsDemo code: lcs.datsDemo code: lcs.datsDemo code: lcs.datsDemo code: lcs.dats

☆ We don't read it, today.☆ We don't read it, today.☆ We don't read it, today.☆ We don't read it, today.☆ We don't read it, today.

Page 9: Metasepi team meeting #19: ATS application on Arduino

AgendaAgendaAgendaAgendaAgenda

☆ [0] ATS application demo☆ [0] ATS application demo☆ [0] ATS application demo☆ [0] ATS application demo☆ [0] ATS application demo

☆ [1] What is Metasepi?☆ [1] What is Metasepi?☆ [1] What is Metasepi?☆ [1] What is Metasepi?☆ [1] What is Metasepi?

☆ [2] How to create Metasepi?☆ [2] How to create Metasepi?☆ [2] How to create Metasepi?☆ [2] How to create Metasepi?☆ [2] How to create Metasepi?

☆ [3] What is ATS language?☆ [3] What is ATS language?☆ [3] What is ATS language?☆ [3] What is ATS language?☆ [3] What is ATS language?

☆ [4] Let's read the demo code☆ [4] Let's read the demo code☆ [4] Let's read the demo code☆ [4] Let's read the demo code☆ [4] Let's read the demo code

☆ [5] Japan ATS User Group☆ [5] Japan ATS User Group☆ [5] Japan ATS User Group☆ [5] Japan ATS User Group☆ [5] Japan ATS User Group

Page 10: Metasepi team meeting #19: ATS application on Arduino

[1] What is Metasepi?[1] What is Metasepi?[1] What is Metasepi?[1] What is Metasepi?[1] What is Metasepi?

http://metasepi.org/http://metasepi.org/http://metasepi.org/http://metasepi.org/http://metasepi.org/

☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.

☆ We want to use Metasepi OS for daily desktop usage (e.g. web browser, programming, office suite, ... etc.)

☆ We want to use Metasepi OS for daily desktop usage (e.g. web browser, programming, office suite, ... etc.)

☆ We want to use Metasepi OS for daily desktop usage (e.g. web browser, programming, office suite, ... etc.)

☆ We want to use Metasepi OS for daily desktop usage (e.g. web browser, programming, office suite, ... etc.)

☆ We want to use Metasepi OS for daily desktop usage (e.g. web browser, programming, office suite, ... etc.)

☆ We have surveyed may functional languages (e.g. Haskell, OCaml, MLton, ... etc.)

☆ We have surveyed may functional languages (e.g. Haskell, OCaml, MLton, ... etc.)

☆ We have surveyed may functional languages (e.g. Haskell, OCaml, MLton, ... etc.)

☆ We have surveyed may functional languages (e.g. Haskell, OCaml, MLton, ... etc.)

☆ We have surveyed may functional languages (e.g. Haskell, OCaml, MLton, ... etc.)

Page 11: Metasepi team meeting #19: ATS application on Arduino

Kernel developer wants typeKernel developer wants typeKernel developer wants typeKernel developer wants typeKernel developer wants type

☆ Kernels are developed with C.☆ Kernels are developed with C.☆ Kernels are developed with C.☆ Kernels are developed with C.☆ Kernels are developed with C.

☆ We should design kernel with the greatest care.☆ We should design kernel with the greatest care.☆ We should design kernel with the greatest care.☆ We should design kernel with the greatest care.☆ We should design kernel with the greatest care.

☆ C language is unsafe!☆ C language is unsafe!☆ C language is unsafe!☆ C language is unsafe!☆ C language is unsafe!

Page 12: Metasepi team meeting #19: ATS application on Arduino

Kernel Bug #1: Buffer overrunKernel Bug #1: Buffer overrunKernel Bug #1: Buffer overrunKernel Bug #1: Buffer overrunKernel Bug #1: Buffer overrun

☆ Pointer to array doesn't know the length.☆ Pointer to array doesn't know the length.☆ Pointer to array doesn't know the length.☆ Pointer to array doesn't know the length.☆ Pointer to array doesn't know the length.

Page 13: Metasepi team meeting #19: ATS application on Arduino

Kernel Bug #2: Page faultKernel Bug #2: Page faultKernel Bug #2: Page faultKernel Bug #2: Page faultKernel Bug #2: Page fault

☆ Page fault in user space => SEGV☆ Page fault in user space => SEGV☆ Page fault in user space => SEGV☆ Page fault in user space => SEGV☆ Page fault in user space => SEGV

☆ Page fault in kernel space => Halt!☆ Page fault in kernel space => Halt!☆ Page fault in kernel space => Halt!☆ Page fault in kernel space => Halt!☆ Page fault in kernel space => Halt!

Page 14: Metasepi team meeting #19: ATS application on Arduino

Kernel Bug #3: Weak typeKernel Bug #3: Weak typeKernel Bug #3: Weak typeKernel Bug #3: Weak typeKernel Bug #3: Weak type

☆ Lots of (void *) and unsafe coercion.☆ Lots of (void *) and unsafe coercion.☆ Lots of (void *) and unsafe coercion.☆ Lots of (void *) and unsafe coercion.☆ Lots of (void *) and unsafe coercion.

☆ NetBSD kernel uses it 45130 times!☆ NetBSD kernel uses it 45130 times!☆ NetBSD kernel uses it 45130 times!☆ NetBSD kernel uses it 45130 times!☆ NetBSD kernel uses it 45130 times!$ pwd/home/kiwamu/src/netbsd/sys$ grep "void \*" `find . -name "*.c"` | wc -l45130

$ pwd/home/kiwamu/src/netbsd/sys$ grep "void \*" `find . -name "*.c"` | wc -l45130

$ pwd/home/kiwamu/src/netbsd/sys$ grep "void \*" `find . -name "*.c"` | wc -l45130

$ pwd/home/kiwamu/src/netbsd/sys$ grep "void \*" `find . -name "*.c"` | wc -l45130

$ pwd/home/kiwamu/src/netbsd/sys$ grep "void \*" `find . -name "*.c"` | wc -l45130

☆ Kernel developers frequently use (void *) for flexibility. It's realy BAD, but there is no other option.

☆ Kernel developers frequently use (void *) for flexibility. It's realy BAD, but there is no other option.

☆ Kernel developers frequently use (void *) for flexibility. It's realy BAD, but there is no other option.

☆ Kernel developers frequently use (void *) for flexibility. It's realy BAD, but there is no other option.

☆ Kernel developers frequently use (void *) for flexibility. It's realy BAD, but there is no other option.

Page 15: Metasepi team meeting #19: ATS application on Arduino

[2] How to create Metasepi?[2] How to create Metasepi?[2] How to create Metasepi?[2] How to create Metasepi?[2] How to create Metasepi?

☆ Scratch or Rewrite☆ Scratch or Rewrite☆ Scratch or Rewrite☆ Scratch or Rewrite☆ Scratch or Rewrite

Page 16: Metasepi team meeting #19: ATS application on Arduino

Snatch-driven developmentSnatch-driven developmentSnatch-driven developmentSnatch-driven developmentSnatch-driven development

http://en.wikipedia.org/wiki/Snatcherhttp://en.wikipedia.org/wiki/Snatcherhttp://en.wikipedia.org/wiki/Snatcherhttp://en.wikipedia.org/wiki/Snatcherhttp://en.wikipedia.org/wiki/Snatcher

Page 17: Metasepi team meeting #19: ATS application on Arduino

Which language should we use?Which language should we use?Which language should we use?Which language should we use?Which language should we use?

☆ ATS http://www.ats-lang.org/☆ ATS http://www.ats-lang.org/☆ ATS http://www.ats-lang.org/☆ ATS http://www.ats-lang.org/☆ ATS http://www.ats-lang.org/

Page 18: Metasepi team meeting #19: ATS application on Arduino

[3] What is ATS language?[3] What is ATS language?[3] What is ATS language?[3] What is ATS language?[3] What is ATS language?

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

☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime

☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC

☆ Developed at Boston University☆ Developed at Boston University☆ Developed at Boston University☆ Developed at Boston University☆ Developed at Boston University

Page 19: Metasepi team meeting #19: ATS application on Arduino

ATS compile flowATS compile flowATS compile flowATS compile flowATS compile flow

Page 20: Metasepi team meeting #19: ATS application on Arduino

[4] Let's read the demo code[4] Let's read the demo code[4] Let's read the demo code[4] Let's read the demo code[4] Let's read the demo code

Start from main.dats.Start from main.dats.Start from main.dats.Start from main.dats.Start from main.dats.arduino-ats|-- DATS| `-- lcd.dats|-- SATS| |-- arduino.sats| `-- lcd.sats|-- avr_prelude| |-- DATS| | `-- string0.dats| |-- SATS| | `-- string0.sats| |-- kernel_prelude.cats| `-- kernel_staload.hats`-- demo `-- lcd_ats |-- DATS | `-- main.dats # <= Start from here. `-- config.hats

arduino-ats|-- DATS| `-- lcd.dats|-- SATS| |-- arduino.sats| `-- lcd.sats|-- avr_prelude| |-- DATS| | `-- string0.dats| |-- SATS| | `-- string0.sats| |-- kernel_prelude.cats| `-- kernel_staload.hats`-- demo `-- lcd_ats |-- DATS | `-- main.dats # <= Start from here. `-- config.hats

arduino-ats|-- DATS| `-- lcd.dats|-- SATS| |-- arduino.sats| `-- lcd.sats|-- avr_prelude| |-- DATS| | `-- string0.dats| |-- SATS| | `-- string0.sats| |-- kernel_prelude.cats| `-- kernel_staload.hats`-- demo `-- lcd_ats |-- DATS | `-- main.dats # <= Start from here. `-- config.hats

arduino-ats|-- DATS| `-- lcd.dats|-- SATS| |-- arduino.sats| `-- lcd.sats|-- avr_prelude| |-- DATS| | `-- string0.dats| |-- SATS| | `-- string0.sats| |-- kernel_prelude.cats| `-- kernel_staload.hats`-- demo `-- lcd_ats |-- DATS | `-- main.dats # <= Start from here. `-- config.hats

arduino-ats|-- DATS| `-- lcd.dats|-- SATS| |-- arduino.sats| `-- lcd.sats|-- avr_prelude| |-- DATS| | `-- string0.dats| |-- SATS| | `-- string0.sats| |-- kernel_prelude.cats| `-- kernel_staload.hats`-- demo `-- lcd_ats |-- DATS | `-- main.dats # <= Start from here. `-- config.hats

Page 21: Metasepi team meeting #19: ATS application on Arduino

main.dats sequencemain.dats sequencemain.dats sequencemain.dats sequencemain.dats sequence

Page 22: Metasepi team meeting #19: ATS application on Arduino

lcd.satslcd.satslcd.satslcd.satslcd.sats

Page 23: Metasepi team meeting #19: ATS application on Arduino

Power of Dependent Type #1Power of Dependent Type #1Power of Dependent Type #1Power of Dependent Type #1Power of Dependent Type #1$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..f00eccd 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -13,7 +13,7 @@ val g_str_message = " ATS is a statically typed programming lang implement main0 () = { fun loop {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = {- val () = if pos + lcd_width <= length str then {+ val () = if pos + lcd_width <= 1 + length str then { val () = lcd_setCursor (lcd, 1, 0) val () = lcd_print (lcd, g_str_atsrun, i2sz 0, length g_str_atsrun) val () = lcd_setCursor (lcd, 0, 1)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..f00eccd 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -13,7 +13,7 @@ val g_str_message = " ATS is a statically typed programming lang implement main0 () = { fun loop {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = {- val () = if pos + lcd_width <= length str then {+ val () = if pos + lcd_width <= 1 + length str then { val () = lcd_setCursor (lcd, 1, 0) val () = lcd_print (lcd, g_str_atsrun, i2sz 0, length g_str_atsrun) val () = lcd_setCursor (lcd, 0, 1)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..f00eccd 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -13,7 +13,7 @@ val g_str_message = " ATS is a statically typed programming lang implement main0 () = { fun loop {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = {- val () = if pos + lcd_width <= length str then {+ val () = if pos + lcd_width <= 1 + length str then { val () = lcd_setCursor (lcd, 1, 0) val () = lcd_print (lcd, g_str_atsrun, i2sz 0, length g_str_atsrun) val () = lcd_setCursor (lcd, 0, 1)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..f00eccd 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -13,7 +13,7 @@ val g_str_message = " ATS is a statically typed programming lang implement main0 () = { fun loop {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = {- val () = if pos + lcd_width <= length str then {+ val () = if pos + lcd_width <= 1 + length str then { val () = lcd_setCursor (lcd, 1, 0) val () = lcd_print (lcd, g_str_atsrun, i2sz 0, length g_str_atsrun) val () = lcd_setCursor (lcd, 0, 1)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..f00eccd 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -13,7 +13,7 @@ val g_str_message = " ATS is a statically typed programming lang implement main0 () = { fun loop {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = {- val () = if pos + lcd_width <= length str then {+ val () = if pos + lcd_width <= 1 + length str then { val () = lcd_setCursor (lcd, 1, 0) val () = lcd_print (lcd, g_str_atsrun, i2sz 0, length g_str_atsrun) val () = lcd_setCursor (lcd, 0, 1)

Page 24: Metasepi team meeting #19: ATS application on Arduino

Power of Dependent Type #2Power of Dependent Type #2Power of Dependent Type #2Power of Dependent Type #2Power of Dependent Type #2$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 958(line=20, offs=25) -- 958(line=20, offs=25): error(3): unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(<=); S2Eapp(S2Ecst(+); S2EVar(1830->S2Evar(i(5501))), S2EVar(1831->S2Eintinf(16))), S2EVar(1829->S2Evar(n(5500)))))typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 958(line=20, offs=25) -- 958(line=20, offs=25): error(3): unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(<=); S2Eapp(S2Ecst(+); S2EVar(1830->S2Evar(i(5501))), S2EVar(1831->S2Eintinf(16))), S2EVar(1829->S2Evar(n(5500)))))typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 958(line=20, offs=25) -- 958(line=20, offs=25): error(3): unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(<=); S2Eapp(S2Ecst(+); S2EVar(1830->S2Evar(i(5501))), S2EVar(1831->S2Eintinf(16))), S2EVar(1829->S2Evar(n(5500)))))typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 958(line=20, offs=25) -- 958(line=20, offs=25): error(3): unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(<=); S2Eapp(S2Ecst(+); S2EVar(1830->S2Evar(i(5501))), S2EVar(1831->S2Eintinf(16))), S2EVar(1829->S2Evar(n(5500)))))typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 958(line=20, offs=25) -- 958(line=20, offs=25): error(3): unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(<=); S2Eapp(S2Ecst(+); S2EVar(1830->S2Evar(i(5501))), S2EVar(1831->S2Eintinf(16))), S2EVar(1829->S2Evar(n(5500)))))typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.

☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!

☆ Constraint "i + j <= n" is at lcd.sats☆ Constraint "i + j <= n" is at lcd.sats☆ Constraint "i + j <= n" is at lcd.sats☆ Constraint "i + j <= n" is at lcd.sats☆ Constraint "i + j <= n" is at lcd.sats

☆ main.dats violates the constraint☆ main.dats violates the constraint☆ main.dats violates the constraint☆ main.dats violates the constraint☆ main.dats violates the constraint

Page 25: Metasepi team meeting #19: ATS application on Arduino

Power of Linear Type #1Power of Linear Type #1Power of Linear Type #1Power of Linear Type #1Power of Linear Type #1$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..4c73340 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -25,6 +25,7 @@ implement main0 () = { fun forever {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = { val () = loop (lcd, str, pos)+ val () = lcd_close lcd val () = forever (lcd, str, pos) } val lcd = lcd_open (8, 13, 9, 4, 5, 6, 7)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..4c73340 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -25,6 +25,7 @@ implement main0 () = { fun forever {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = { val () = loop (lcd, str, pos)+ val () = lcd_close lcd val () = forever (lcd, str, pos) } val lcd = lcd_open (8, 13, 9, 4, 5, 6, 7)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..4c73340 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -25,6 +25,7 @@ implement main0 () = { fun forever {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = { val () = loop (lcd, str, pos)+ val () = lcd_close lcd val () = forever (lcd, str, pos) } val lcd = lcd_open (8, 13, 9, 4, 5, 6, 7)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..4c73340 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -25,6 +25,7 @@ implement main0 () = { fun forever {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = { val () = loop (lcd, str, pos)+ val () = lcd_close lcd val () = forever (lcd, str, pos) } val lcd = lcd_open (8, 13, 9, 4, 5, 6, 7)

$ pwd/home/kiwamu/src/arduino-ats/demo/lcd_ats$ vi DATS/main.dats$ git diffdiff --git a/demo/lcd_ats/DATS/main.dats b/demo/lcd_ats/DATS/main.datsindex ab94597..4c73340 100644--- a/demo/lcd_ats/DATS/main.dats+++ b/demo/lcd_ats/DATS/main.dats@@ -25,6 +25,7 @@ implement main0 () = { fun forever {n:int}{i:nat | i < n} (lcd: !lcd_t, str: string (n), pos: size_t (i)): void = { val () = loop (lcd, str, pos)+ val () = lcd_close lcd val () = forever (lcd, str, pos) } val lcd = lcd_open (8, 13, 9, 4, 5, 6, 7)

Page 26: Metasepi team meeting #19: ATS application on Arduino

Power of Linear Type #2Power of Linear Type #2Power of Linear Type #2Power of Linear Type #2Power of Linear Type #2$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the linear dynamic variable [lcd$1182(-1)] is no longer available./home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the dynamic expression cannot be assigned the type [S2Ecst(lcd_t)].

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the linear dynamic variable [lcd$1182(-1)] is no longer available./home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the dynamic expression cannot be assigned the type [S2Ecst(lcd_t)].

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the linear dynamic variable [lcd$1182(-1)] is no longer available./home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the dynamic expression cannot be assigned the type [S2Ecst(lcd_t)].

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the linear dynamic variable [lcd$1182(-1)] is no longer available./home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the dynamic expression cannot be assigned the type [S2Ecst(lcd_t)].

$ make--snip--patsopt -o DATS/main_dats.c -d DATS/main.dats/home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the linear dynamic variable [lcd$1182(-1)] is no longer available./home/kiwamu/src/arduino-ats/demo/lcd_ats/DATS/main.dats: 1263(line=29, offs=23) -- 1266(line=29, offs=26): error(3): the dynamic expression cannot be assigned the type [S2Ecst(lcd_t)].

☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!☆ ATS2 finds issue at compile time!

☆ Linear value "lcd" is consumed☆ Linear value "lcd" is consumed☆ Linear value "lcd" is consumed☆ Linear value "lcd" is consumed☆ Linear value "lcd" is consumed

☆ However "lcd" is used by "forever"☆ However "lcd" is used by "forever"☆ However "lcd" is used by "forever"☆ However "lcd" is used by "forever"☆ However "lcd" is used by "forever"

Page 27: Metasepi team meeting #19: ATS application on Arduino

[5] Japan ATS User Group[5] Japan ATS User Group[5] Japan ATS User Group[5] Japan ATS User Group[5] 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/

Page 28: Metasepi team meeting #19: ATS application on Arduino

Doc: ATSプログラミング入門Doc: ATSプログラミング入門Doc: ATSプログラミング入門Doc: ATSプログラミング入門Doc: ATSプログラミング入門http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/

Page 29: Metasepi team meeting #19: ATS application on Arduino

Doc: チュートリアルDoc: チュートリアルDoc: チュートリアルDoc: チュートリアルDoc: チュートリアルhttp://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/

Page 30: Metasepi team meeting #19: ATS application on Arduino

Doc: MLプログラマ向けガイドDoc: MLプログラマ向けガイドDoc: MLプログラマ向けガイドDoc: MLプログラマ向けガイドDoc: MLプログラマ向けガイドhttps://github.com/jats-ug/translate/blob/master/Web/cs.likai.org/ats/ml-programmers-guide-to-ats.mdhttps://github.com/jats-ug/translate/blob/master/Web/cs.likai.org/ats/ml-programmers-guide-to-ats.mdhttps://github.com/jats-ug/translate/blob/master/Web/cs.likai.org/ats/ml-programmers-guide-to-ats.mdhttps://github.com/jats-ug/translate/blob/master/Web/cs.likai.org/ats/ml-programmers-guide-to-ats.mdhttps://github.com/jats-ug/translate/blob/master/Web/cs.likai.org/ats/ml-programmers-guide-to-ats.md

Page 31: Metasepi team meeting #19: ATS application on Arduino

Doc: ATS2 wikiDoc: ATS2 wikiDoc: ATS2 wikiDoc: ATS2 wikiDoc: ATS2 wikihttps://github.com/githwxi/ATS-Postiats/wikihttps://github.com/githwxi/ATS-Postiats/wikihttps://github.com/githwxi/ATS-Postiats/wikihttps://github.com/githwxi/ATS-Postiats/wikihttps://github.com/githwxi/ATS-Postiats/wiki

Page 32: Metasepi team meeting #19: ATS application on Arduino

Functional IoTFunctional IoTFunctional IoTFunctional IoTFunctional IoThttp://fpiot.metasepi.org/http://fpiot.metasepi.org/http://fpiot.metasepi.org/http://fpiot.metasepi.org/http://fpiot.metasepi.org/

Page 33: Metasepi team meeting #19: ATS application on Arduino

Follow me!Follow me!Follow me!Follow me!Follow me!

https://twitter.com/jats_ughttps://twitter.com/jats_ughttps://twitter.com/jats_ughttps://twitter.com/jats_ughttps://twitter.com/jats_ug


Recommended