todesking
May 28, 2019
890

# 自作言語進捗 2019 May / ojaml-2019-may

May 28, 2019

## Transcript

2. ### ͋Β͢͡ • 1݄͝Ζ͔Βࣗ࡞ݴޠΛ࡞Γ࢝ΊͨͷͰɺͨ·ʹਐḿΛใ ࠂ͠Α͏ͱࢥ͍·͢…… • લճͷ͋Β͢͡: https://speakerdeck.com/todesking/zi- zuo-yan-yu-jin-bu-2019-mar • ಈػ

• Ұ෦ͰCίϯύΠϥࣗ࡞͕ྲྀߦͬͯͨ • ܕγεςϜͷ࣮ݧ͕͍ͨ͠ • JVMͰಈ͘MLܥݴޠΛ࡞͍ͬͯ·͢ • ηϧϑϗεςΟϯά΋໨ඪͱ͢Δ • https://github.com/todesking/ojaml
3. ### ਐḿ Ϟδϡʔϧ Ϟδϡʔϧม਺ ؔ਺ ϩʔΧϧม਺(let/let rec) جຊతͳ੔਺ԋࢉ ݪ࢝తͳܕਪ࿦ Java FFI

ADT ·ͱ΋ͳܕਪ࿦(HM) ύϥϝτϦοΫଟ૬ letଟ૬ REPL Reﬁnement types ηϧϑϗεςΟϯά
4. ### ܕਪ࿦ • ܕ͕ෆ໌ͳ෦෼ʹܕม਺ΛׂΓ౰ͯΔ • ܕม਺͕ै͏΂੍͖໿ΛٻΊΔ • ੍໿ͷղΛٻΊΔ • ৄࡉ͸͙͙Ε module

A { let add = fun x => fun y => x + y ;; (* add: int -> int -> int *) }
5. ### ܕਪ࿦ • ܕ͕ෆ໌ͳ෦෼ʹܕม਺ΛׂΓ౰ͯΔ let add: T1 = (fun x: T2

=> (fun y: T3 => (x + y): T4 ): T5 ): T6 ;;
6. ### ܕਪ࿦ • ܕม਺͕ै͏΂੍͖໿ΛٻΊΔ let +: int -> int -> int;;

let add: T1 = (fun x: T2 => (fun y: T3 => (x + y): T4 ): T5 ): T6 ;; T1 = T6 T6 = T2 -> T5 T5 = T3 -> T4 T4 = int T2 = int T3 = int
7. ### ܕਪ࿦ • ੍໿ͷղΛٻΊΔ T1 = T6 T6 = T2 ->

T5 T5 = T3 -> T4 T4 = int T2 = int T3 = int T1 = T2 -> T5 T6 = T2 -> T5 T5 = T3 -> T4 T4 = int T2 = int T3 = int T1 = T2 -> T3 -> T4 T6 = T2 -> T3 -> T4 T5 = T3 -> T4 T4 = int T2 = int T3 = int
8. ### ܕਪ࿦ • ਪ࿦݁Ռʹܕม਺͕࢒Δ৔߹͸ɺܕύϥϝʔλͱͯ͠ந৅ Խ͢ΔॲཧΛߦ͏ • ந৅Խ͢Δ৚݅ͱ͔͍Ζ͍Ζ͋ΔΜͰ͕͢ʂ • let-polymorphismͰ͙͙Ε let id

= (fun x: T1 => x: T2): T3 T2 = T1 T3 = T1 -> T1 id: [T1] T1 -> T1
9. ### ܕਪ࿦(FFI) • JavaϝιουΛݺͿػೳͷܕਪ࿦ • Φʔόϩʔυ͕͋ΔͨΊɺී௨ͷؔ਺ݺͼग़͠ͱҧ͏ϧʔϧ͕ඞཁ • Ҿ਺ͷܕΛਪ࿦ˠҾ਺ͷܕΛݩʹΦʔόϩʔυղܾˠฦΓ஋ͷܕΛ ܾఆ let x

= Integer##valueOf(1 + 1) ;;
10. ### REPL • JVMϕʔεݴޠͳͷͰͱͯ΋ָͩͬͨ • ͦΕ·Ͱʹఆٛ͞Εͨม਺Λimport͓ͯ͘͠ • ೖྗΛϞδϡʔϧʹม׵ͯ͠ίϯύΠϧ͢Δ REPL:1> 1 +

1 module Repl_1 { let res1 = 1 + 1 ;; } REPL:2> let x = res1 ;; import Repl_1.res1 module Repl_2 { let x = res1 ;; } REPL:3> x + 1 ;; import Repl_1.res1 import Repl_2.x module Repl_3 { let res3 = x + 1 ;; }

16. ### ςετ • src/test/resourcesͷԼʹ͜͏͍͏ͷΛஔ͘ͱࣗಈͰ࣮ߦ͢ Δ࢓૊Έ • assertion͸ίϝϯτͰॻ͘ • ਖ਼ৗܥ: ϑΟʔϧυ໊ɺظ଴͞ΕΔܕͱ஋ •

ҟৗܥ: ίϯύΠϧΤϥʔ͕ظ଴͞ΕΔ৔ॴ