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
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
650
Error Handling in Rust Applications
taiki45
3
700
Efficient Platform for Security and Compliance
taiki45
5
1.6k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
710
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
790
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.5k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
1.9k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.5k
Cloud Native Meetup Tokyo #8 ServiceMesh Day Recap
taiki45
2
390
Other Decks in Programming
See All in Programming
Health Kit × Foundation Models でAIコーチを作ってみた
ryunakayama
0
100
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
400
ボトムアップの生成AI活用を推進する社内AIエージェント開発
aku11i
0
1.5k
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
250
外接に惑わされない自システムの処理時間SLIをOpenTelemetryで実現した話
kotaro7750
0
220
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
6k
PHPライセンス変更の議論を通じて学ぶOSSライセンスの基礎
matsuo_atsushi
0
120
Researchlyの開発で参考にしたデザイン
adsholoko
0
110
KoogではじめるAIエージェント開発
hiroaki404
1
370
NIKKEI Tech Talk#38
cipepser
0
420
「10分以内に機能を消せる状態」 の実現のためにやっていること
togishima
1
160
CSC509 Lecture 08
javiergs
PRO
0
280
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.7k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
We Have a Design System, Now What?
morganepeng
54
7.9k
It's Worth the Effort
3n
187
28k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Stop Working from a Prison Cell
hatefulcrawdad
272
21k
Optimizing for Happiness
mojombo
379
70k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Faster Mobile Websites
deanohume
310
31k
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