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
170
自作プログラミング言語Malgoの紹介
『プログラミング言語処理系が好きな人の集まり』での定期ミートアップ(2021/06/13)で発表した資料です
Yuya Kono
June 13, 2021
Tweet
Share
More Decks by Yuya Kono
See All by Yuya Kono
プログラミングの暗黙知
takoeight0821
0
75
git logで振り返る大学4年間
takoeight0821
1
170
自作言語にモジュールを実装した話
takoeight0821
0
370
量子コンピュータで乱数を生成した話
takoeight0821
1
240
自作言語コンパイラを作った話
takoeight0821
0
150
自作言語malgoのコンパイラをリファクタリングした話
takoeight0821
0
310
今日から始める自作コンパイラ ver 0.0.1
takoeight0821
0
1k
Language Server Protocolの話
takoeight0821
0
410
GraalVMで遊ぶ
takoeight0821
0
160
Other Decks in Programming
See All in Programming
Laravel × Clean Architecture
bumptakayuki
PRO
0
150
The New Developer Workflow: How AI Transforms Ideas into Code
danielsogl
0
120
Bedrock × Confluenceで簡単(?)社内RAG
iharuoru
1
120
カオスに立ち向かう小規模チームの装備の選択〜フルスタックTSという装備の強み _ 弱み〜/Choosing equipment for a small team facing chaos ~ Strengths and weaknesses of full-stack TS~
bitkey
1
140
Носок на сок
bo0om
0
1.3k
UMAPをざっくりと理解 / Overview of UMAP
kaityo256
PRO
3
1.5k
GitHub Copilot for Azureを使い倒したい
ymd65536
1
330
20250429 - CNTUG Meetup #67 / DevOps Taiwan Meetup #69 - Deep Dive into Tetragon: Building Runtime Security and Observability with eBPF
tico88612
0
180
On-the-fly Suggestions of Rewriting Method Deprecations
ohbarye
3
5.3k
監視 やばい
syossan27
12
10k
データと事例で振り返るDevin導入の"リアル" / The Realities of Devin Reflected in Data and Case Studies
rkaga
1
990
カウシェで Four Keys の改善を試みた理由
ike002jp
1
130
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.7k
A better future with KSS
kneath
239
17k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Documentation Writing (for coders)
carmenintech
71
4.8k
GitHub's CSS Performance
jonrohan
1031
460k
Facilitating Awesome Meetings
lara
54
6.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
KATA
mclloyd
29
14k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
GraphQLとの向き合い方2022年版
quramy
46
14k
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