Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
自作プログラミング言語Malgoの紹介
Search
Yuya Kono
June 13, 2021
Programming
0
180
自作プログラミング言語Malgoの紹介
『プログラミング言語処理系が好きな人の集まり』での定期ミートアップ(2021/06/13)で発表した資料です
Yuya Kono
June 13, 2021
Tweet
Share
More Decks by Yuya Kono
See All by Yuya Kono
プログラミングの暗黙知
takoeight0821
0
83
git logで振り返る大学4年間
takoeight0821
1
180
自作言語にモジュールを実装した話
takoeight0821
0
400
量子コンピュータで乱数を生成した話
takoeight0821
1
260
自作言語コンパイラを作った話
takoeight0821
0
170
自作言語malgoのコンパイラをリファクタリングした話
takoeight0821
0
340
今日から始める自作コンパイラ ver 0.0.1
takoeight0821
0
1.1k
Language Server Protocolの話
takoeight0821
0
430
GraalVMで遊ぶ
takoeight0821
0
170
Other Decks in Programming
See All in Programming
CSC305 Summer Lecture 05
javiergs
PRO
0
110
コーディングは技術者(エンジニア)の嗜みでして / Learning the System Development Mindset from Rock Lady
mackey0225
2
580
Understanding Ruby Grammar Through Conflicts
yui_knk
1
130
A Gopher's Guide to Vibe Coding
danicat
0
170
AIエージェント開発、DevOps and LLMOps
ymd65536
1
350
LLMOpsのパフォーマンスを支える技術と現場で実践した改善
po3rin
8
980
MLH State of the League: 2026 Season
theycallmeswift
0
160
Laravel Boost 超入門
fire_arlo
1
130
為你自己學 Python - 冷知識篇
eddie
1
140
コーディングエージェント時代のNeovim
key60228
1
100
エンジニアのための”最低限いい感じ”デザイン入門
shunshobon
0
130
SOCI Index Manifest v2が出たので調べてみた / Introduction to SOCI Index Manifest v2
tkikuc
1
110
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Producing Creativity
orderedlist
PRO
347
40k
Automating Front-end Workflow
addyosmani
1370
200k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Become a Pro
speakerdeck
PRO
29
5.5k
Navigating Team Friction
lara
189
15k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
183
54k
The Cult of Friendly URLs
andyhume
79
6.5k
Transcript
ʹΌʔΜʢ!UBLPFJHIUʣ ࣗ࡞ϓϩάϥϛϯάݴޠ .BMHPͷհ
ʹΌΜͰ͢ !UBLPFJHIU
ࣗ࡞ݴޠ.BMHP IUUQTHJUIVCDPNNBMHPMBOHNBMHP w ੩తܕ͖ؔϓϩάϥϛϯάݴޠ w ܕਪɺతσʔλܕɺύλʔϯϚον w )BTLFMMͬΆ͍ߏจ w ܕએݴUZQF
EBUB w ΠϯσϯτϕʔεͰͳ͍ w ؔϦςϥϧͷߏจͳͲɺҧ͏ͱ͜Ζଟ͍
ࣗ࡞ݴޠ.BMHP IUUQTHJUIVCDPNNBMHPMBOHNBMHP w ੩తܕ͖ؔϓϩάϥϛϯάݴޠ w ܕਪɺతσʔλܕɺύλʔϯϚον w )BTLFMMͬΆ͍ߏจ w ܕએݴUZQF
EBUB w ΠϯσϯτϕʔεͰͳ͍ w ؔϦςϥϧͷߏจͳͲɺҧ͏ͱ͜Ζଟ͍ ࠓύλʔϯϚονͷίϯύΠϧʹ͍ͭͯ͠·͢
.BMHPͰॻ͍ͨϓϩάϥϜ data Bool = False | True; if :: Bool
-> {a} -> {a} -> a; if c t f = c |> { True -> !t | False -> !f }; ifΛؔͱͯ͠ϢʔβʔఆٛͰ͖Δʂ
.BMHPͰॻ͍ͨϓϩάϥϜ ύλʔϯϚονͱ༥߹ͨؔ͠Ϧςϥϧ Int#ͷϥούʔΦϒδΣΫτͷΑ͏ͳͷ data List a = Nil | Cons
a (List a); sum = { Nil -> Int# 0L# | (Cons (Int# x) xs) -> sum xs |> {(Int# s) -> Int# (x +# s)} }
ύλʔϯϚονͷίϯύΠϧ
ύλʔϯϚονͷίϯύΠϧ w .BMHPڧྗͳʢؔܕݴޠʹΑ͋͘ΔʣύλʔϯϚονΛͭ w ҙͷϢʔβʔఆٛܕʹରͯ͠ɺೖΕࢠΛͭύλʔϯΛهड़Ͱ͖Δ w ύλʔϯϚονΛTXJUDIDBTFʹམͱ͠ࠐΉඞཁ͕͋Δ w ҙຯతʹ্͔ΒԼʹ࣮ߦ͢ΔJGͰ͍͍͕ɺظ͞ΕΔڍಈTXJUDIDBTF w
ύλʔϯϚονͷίϯύΠϧख๏ʹ͍ͭͯ͋·Γࢿྉ͕ͳ͍ w 5IF*NQMFNFOUBUJPOPG'VODUJPOBM1SPHSBNNJOH-BOHVBHFTʹ ؆୯ͳ࣮ํ๏ͷهड़͕͋ͬͨ
͜ͷϓϩάϥϜʹ͍ͭͯߟ͑Δ { Nil -> Int# 0L# | (Cons (Int# x)
xs) -> sum xs |> {(Int# s) -> Int# (x +# s)} } match [u1] [ ( [Nil], Int# 0L# ), ( [Cons (Int# x) xs], sum xs ...) ] ERROR ԼͷΑ͏ͳதؒදݱΛߟ͑ɺίϯύΠϧ͢Δ
ύλʔϯϚονͷίϯύΠϧNBUDI match [u1] [ ( [Nil], Int# 0L# ), (
[Cons (Int# x) xs], sum xs ...) ] ERROR ύλʔϯϚονΛల։͢ΔؔmatchΛߟ͑Δ ୈҰҾύλʔϯϚονͷରʹͳΔมʢTDSVUJOFFʣͷྻ ୈೋҾύλʔϯͱͦͷύλʔϯʹ߹க͢Δ࣌ͷࣜͷͷྻ ୈࡾҾͲͷύλʔϯʹ߹க͠ͳ͔ͬͨͱ͖ͷࣜ
ύλʔϯϚονͷίϯύΠϧNBUDI match [u1] [ ( [Nil], Int# 0L# ), (
[Cons (Int# x) xs], sum xs ...) ] ERROR ύλʔϯϚονΛల։͢ΔؔmatchΛߟ͑Δ ୈҰҾύλʔϯϚονͷରʹͳΔมʢTDSVUJOFFʣͷྻ ୈೋҾύλʔϯͱͦͷύλʔϯʹ߹க͢Δ࣌ͷࣜͷͷྻ ୈࡾҾͲͷύλʔϯʹ߹க͠ͳ͔ͬͨͱ͖ͷࣜ
ύλʔϯϚονͷίϯύΠϧNBUDI match [u1] [ ( [Nil], Int# 0L# ), (
[Cons (Int# x) xs], sum xs ...) ] ERROR ύλʔϯϚονΛల։͢ΔؔmatchΛߟ͑Δ ୈҰҾύλʔϯϚονͷରʹͳΔมʢTDSVUJOFFʣͷྻ ୈೋҾύλʔϯͱͦͷύλʔϯʹ߹க͢Δ࣌ͷࣜͷͷྻ ୈࡾҾͲͷύλʔϯʹ߹க͠ͳ͔ͬͨͱ͖ͷࣜ
ύλʔϯϚονͷίϯύΠϧNBUDI match [u1] [ ( [Nil], Int# 0L# ), (
[Cons (Int# x) xs], sum xs ...) ] ERROR ୈೋҾͷύλʔϯͷઌ಄ʹ͢ΔʢࠓճͦͦҰݸ͔͠ͳ͍ʣ Nil͜ΕҎ্ฏୱʹͳΒͳ͍ͷͰ͜ͷ·· Cons (Int# x) xs(Int# x)Λల։͠ͳ͍ͱ͍͚ͳ͍
ύλʔϯϚονͷίϯύΠϧNBUDI match u1 with | Nil -> Int# 0L# |
Cons u2 u3 -> match [u2, u3] [ ( [Int# x, xs], sum xs ...) ] ERROR Ұ࣌มu2 u3Λ༻͍ͯɺu1ʹରԠ͢ΔύλʔϯΛల։ NilͷઅίϯύΠϧऴྃ ConsͷҾInt# x, xs͕࣍ͷmatchʹ͞ΕΔ ࣍Int# xΛల։͢Δ
ύλʔϯϚονͷίϯύΠϧNBUDI match u1 with | Nil -> Int# 0L# |
Cons u2 u3 -> match u2 with | Int# u4 -> match [u4, u3] [ ( [x, xs], sum xs ...) ] ERROR xΛ͍ͬͯΔͯ͢ͷύλʔϯͷઌ಄ʹՃ ʢ͜͜ͰҰ͔ͭ͠ͳ͍͕ʜʣ
ύλʔϯϚονͷίϯύΠϧNBUDI match u1 with | Nil -> Int# 0L# |
Cons u2 u3 -> match u2 with | Int# u4 -> sum u3 |> {(Int# s) -> Int# (u4 +# s)} มύλʔϯͷల։ࣗ໌ʢஔ͖͑Δ͚ͩʣ ͯ͢ͷύλʔϯ͔ΒೖΕࢠ͕ͳ͘ͳͬͨ ͜͏͍͏NBUDIXJUITXJUDIDBTF؆୯ʹίϯύΠϧͰ͖Δ
ࠓޙͷωλ
ࠓޙͷωλ w ܕਪͷΞϧΰϦζϜͱ࣮ w తσʔλܕͷ࣮ߦ࣌දݱ w ΫϩʔδϟͷίϯύΠϧ w ଟ૬ؔͷ࣮ํࣜͱϘοΫεԽ w
ׂίϯύΠϧͷ࣮ݱํ๏ w தؒදݱ,PSJFMͷઃܭ .BMHP·ͩ·ͩ։ൃ్த Լͷͱ͜ΖܕݕࠪثͷόάΛमਖ਼ IUUQTHJUIVCDPNNBMHPMBOHNBMHP