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
200
自作プログラミング言語Malgoの紹介
『プログラミング言語処理系が好きな人の集まり』での定期ミートアップ(2021/06/13)で発表した資料です
Yuya Kono
June 13, 2021
Tweet
Share
More Decks by Yuya Kono
See All by Yuya Kono
プログラミングの暗黙知
takoeight0821
0
90
git logで振り返る大学4年間
takoeight0821
1
190
自作言語にモジュールを実装した話
takoeight0821
0
420
量子コンピュータで乱数を生成した話
takoeight0821
1
280
自作言語コンパイラを作った話
takoeight0821
0
180
自作言語malgoのコンパイラをリファクタリングした話
takoeight0821
0
370
今日から始める自作コンパイラ ver 0.0.1
takoeight0821
0
1.1k
Language Server Protocolの話
takoeight0821
0
450
GraalVMで遊ぶ
takoeight0821
0
180
Other Decks in Programming
See All in Programming
愛される翻訳の秘訣
kishikawakatsumi
3
370
Cell-Based Architecture
larchanjo
0
160
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
130
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
300
Basic Architectures
denyspoltorak
0
160
これならできる!個人開発のすゝめ
tinykitten
PRO
0
140
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
470
PostgreSQLで手軽にDuckDBを使う!DuckDB&pg_duckdb入門/osc25hi-duckdb
takahashiikki
0
230
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.4k
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
630
Patterns of Patterns
denyspoltorak
0
410
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
160
Featured
See All Featured
New Earth Scene 8
popppiees
0
1.3k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
530
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
280
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
97
The Curse of the Amulet
leimatthew05
0
6.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Embracing the Ebb and Flow
colly
88
4.9k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
120
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
130
A Soul's Torment
seathinner
1
2.1k
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
2k
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