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.2k
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
560
Error Handling in Rust Applications
taiki45
3
550
Efficient Platform for Security and Compliance
taiki45
4
1.3k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
610
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
720
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.3k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
1.8k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.4k
Cloud Native Meetup Tokyo #8 ServiceMesh Day Recap
taiki45
2
370
Other Decks in Programming
See All in Programming
Building Scalable Mobile Projects: Fast Builds, High Reusability and Clear Ownership
cyrilmottier
2
270
海外のアプリで見かけたかっこいいTransitionを真似てみる
shogotakasaki
1
160
Optimizing JRuby 10
headius
0
160
Making TCPSocket.new "Happy"!
coe401_
1
170
AI Coding Agent Enablement - エージェントを自走させよう
yukukotani
14
5.9k
The Weight of Data: Rethinking Cloud-Native Systems for the Age of AI
hollycummins
0
270
Day0 初心者向けワークショップ実践!ソフトウェアテストの第一歩
satohiroyuki
0
840
SwiftUI API Design Lessons
niw
1
270
custom_lintで始めるチームルール管理
akaboshinit
0
210
AIコードエディタの基盤となるLLMのFlutter性能評価
alquist4121
0
200
The Evolution of the CRuby Build System
kateinoigakukun
0
110
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
240
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
49
7.7k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
660
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
2.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
34
2.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
13
1.4k
Automating Front-end Workflow
addyosmani
1369
200k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Faster Mobile Websites
deanohume
306
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