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
630
Error Handling in Rust Applications
taiki45
3
680
Efficient Platform for Security and Compliance
taiki45
5
1.5k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
690
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
780
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.4k
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
株式会社 Sun terras カンパニーデック
sunterras
0
200
ИИ-Агенты в каждый дом – Алексей Порядин, PythoNN
sobolevn
0
150
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
0
370
止められない医療アプリ、そっと Swift 6 へ
medley
1
110
Back to the Future: Let me tell you about the ACP protocol
terhechte
0
130
Django Ninja による API 開発効率化とリプレースの実践
kashewnuts
0
900
猫と暮らすネットワークカメラ生活🐈 ~Vision frameworkでペットを愛でよう~ / iOSDC Japan 2025
yutailang0119
0
220
Reduxモダナイズ 〜コードのモダン化を通して、将来のライブラリ移行に備える〜
pvcresin
2
680
Le côté obscur des IA génératives
pascallemerrer
0
120
Catch Up: Go Style Guide Update
andpad
0
120
メモリ不足との戦い〜大量データを扱うアプリでの実践例〜
kwzr
1
780
SpecKitでどこまでできる? コストはどれくらい?
leveragestech
0
490
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Building Adaptive Systems
keathley
43
2.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Six Lessons from altMBA
skipperchong
28
4k
GitHub's CSS Performance
jonrohan
1032
460k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
What's in a price? How to price your products and services
michaelherold
246
12k
Building Applications with DynamoDB
mza
96
6.6k
Writing Fast Ruby
sferik
629
62k
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