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
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
200
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
130
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
260
Hono + Inertia + React で LP を構築した話
oukayuka
2
190
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.3k
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
280
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
240
T3DD26: From RAGs to Riches
martinhelmich
0
130
Dockerfile CMD for Node.js
grazie1999
0
160
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
4
2.3k
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.4k
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
850
Featured
See All Featured
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Docker and Python
trallard
47
4.2k
Test your architecture with Archunit
thirion
2
2.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Into the Great Unknown - MozCon
thekraken
41
2.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Optimizing for Happiness
mojombo
378
71k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
BBQ
matthewcrist
89
10k
How to Ace a Technical Interview
jacobian
281
24k
First, design no harm
axbom
PRO
2
1.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