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
Haskell でつくる VM 〜散りゆく Endomorphism〜
Search
taiki45
May 11, 2014
Programming
1.4k
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Haskell でつくる VM 〜散りゆく Endomorphism〜
関数型LT大会の LT です
http://connpass.com/event/5795/
taiki45
May 11, 2014
More Decks by taiki45
See All by taiki45
Mocking in Rust Applications
taiki45
2
810
Error Handling in Rust Applications
taiki45
3
900
Efficient Platform for Security and Compliance
taiki45
6
1.7k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
910
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
870
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.8k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
2k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.7k
Cloud Native Meetup Tokyo #8 ServiceMesh Day Recap
taiki45
2
450
Other Decks in Programming
See All in Programming
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
180
Cloudflare is Agents
chimame
0
190
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
200
XHTMLが残したもの
yosuke_furukawa
PRO
1
230
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
870
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
130
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
500
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
720
自分的「カンファレンスの楽しみ方」
syumai
0
160
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
130
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
130
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
400
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
230
Unsuck your backbone
ammeep
672
58k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Balancing Empowerment & Direction
lara
6
1.3k
The SEO Collaboration Effect
kristinabergwall1
1
540
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Utilizing Notion as your number one productivity tool
mfonobong
4
560
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
390
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
460
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Transcript
Haskell Ͱͭ͘Δ VM ʙࢄΓΏ͘ Endomorphisʙ taiki45
ϓϩάϥϛϯάྺ2ͷ
ϖϧγΞޠ͠ΌΔ
͓͔͞ͳ
ε( ε^o^)э
hs-vm Simple Virtual Machine written in Haskell. ! https://github.com/taiki45/hs-vm
Why VM
ܭࢉػͷ ιϑτΣΞ࣮
Register Machine vs Stack Machine
hs-vm has no StateT
Endomorphism
Endomorphism A ࢝ҬͱऴҬ͕ಉ͡ܥͰ͋ΔΑ͏ͳ४ಉܕࣸ૾
Endomorphism A ࢝ҬͱऴҬ͕ಉ͡ू߹Ͱ͋ΔΑ͏ͳؔ
VM ͱ໋ྩ V ͋ΔVMΛߟ͑Δ ͦͷVM͕ͱΔঢ়ଶͷू߹Λ V ͱ͢Δ [1,2] [3] [3,4,5]
VM ͱ໋ྩ V [3,4] [1,2,4] Add
VM ͱ໋ྩ VM ͷ໋ྩ Endomorphism ͱߟ͑ΒΕΔ V
໋ྩͷ߹
Monoid (M, ŋ) m ŋ i = m = i
ŋ m m ŋ (m ŋ m) = (m ŋ m) ŋ m
ਖ਼ͷ (N, ×) 3 × 1 = 3 = 3
× 1 3 × (4 × 5) = (3 × 4) × 5
Ϧετ (L, ++) [1, 2] ++ [] = [1, 2]
= [] ++ [1, 2] [1] ++ ([2] ++ [3]) = ([1] ++ [2]) ++ [3]
Endomorphism as Monoid A id f g f . id
= f = id . f (h . g) . f = h . (g . f) h
VM ͱ໋ྩ V f f: VM → VM f: ॳظঢ়ଶ
→ ऴྃঢ়ଶ
VM ͷ࣮ߦͱ
ͻͱͭͷࣸ૾Λ ୳͢͜ͱͩͬͨΜͩʂ
͋Γ͠ͷ VM ͷ࣮ߦ Dual ର Endo ͷରͦͷ߹ॱং͕ٯ 144c3a3dbdb
݅δϟϯϓ
ݱࡏͷ VM ࣮ߦ V Endo Λॱ࣍ద༻͍ͯ͘͠ελΠϧ ࣍ʹద༻͢Δࣸ૾Λ program counter Λͱʹ୳͢
ֶͼ • ػցޠ(ΞηϯϒϦݴޠ)ͱͷରԠ • call convention