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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
taiki45
May 11, 2014
Programming
6
1.3k
Haskell でつくる VM 〜散りゆく Endomorphism〜
関数型LT大会の LT です
http://connpass.com/event/5795/
taiki45
May 11, 2014
Tweet
Share
More Decks by taiki45
See All by taiki45
Mocking in Rust Applications
taiki45
2
700
Error Handling in Rust Applications
taiki45
3
780
Efficient Platform for Security and Compliance
taiki45
6
1.6k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
810
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
820
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.6k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
1.9k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.6k
Cloud Native Meetup Tokyo #8 ServiceMesh Day Recap
taiki45
2
410
Other Decks in Programming
See All in Programming
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
420
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
140
2026/02/04 AIキャラクター人格の実装論 口 調の模倣から、コンテキスト制御による 『思想』と『行動』の創発へ
sr2mg4
0
650
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
320
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
310
ふん…おもしれぇ Parser。RubyKaigi 行ってやるぜ
aki_pin0
0
120
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
3
430
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
800
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
220
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
190
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
110
CSC307 Lecture 12
javiergs
PRO
0
450
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
0
71
How STYLIGHT went responsive
nonsquared
100
6k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
110
Measuring & Analyzing Core Web Vitals
bluesmoon
9
770
エンジニアに許された特別な時間の終わり
watany
106
240k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Abbi's Birthday
coloredviolet
2
5k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
430
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
71
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
96
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
[SF Ruby Conf 2025] Rails X
palkan
2
800
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