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
120
自作プログラミング言語Malgoの紹介
『プログラミング言語処理系が好きな人の集まり』での定期ミートアップ(2021/06/13)で発表した資料です
Yuya Kono
June 13, 2021
Tweet
Share
More Decks by Yuya Kono
See All by Yuya Kono
プログラミングの暗黙知
takoeight0821
0
62
git logで振り返る大学4年間
takoeight0821
1
150
自作言語にモジュールを実装した話
takoeight0821
0
330
量子コンピュータで乱数を生成した話
takoeight0821
1
200
自作言語コンパイラを作った話
takoeight0821
0
110
自作言語malgoのコンパイラをリファクタリングした話
takoeight0821
0
250
今日から始める自作コンパイラ ver 0.0.1
takoeight0821
0
980
Language Server Protocolの話
takoeight0821
0
370
GraalVMで遊ぶ
takoeight0821
0
130
Other Decks in Programming
See All in Programming
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
Jakarta EE meets AI
ivargrimstad
0
690
Remix on Hono on Cloudflare Workers
yusukebe
1
300
Jakarta EE meets AI
ivargrimstad
0
150
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
subpath importsで始めるモック生活
10tera
0
320
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
1
110
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
52
13k
KATA
mclloyd
29
14k
How to Ace a Technical Interview
jacobian
276
23k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Visualization
eitanlees
145
15k
Being A Developer After 40
akosma
87
590k
Building Adaptive Systems
keathley
38
2.3k
Designing the Hi-DPI Web
ddemaree
280
34k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Designing for Performance
lara
604
68k
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