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
1k
Haskell でつくる VM 〜散りゆく Endomorphism〜
関数型LT大会の LT です
http://connpass.com/event/5795/
taiki45
May 11, 2014
Tweet
Share
More Decks by taiki45
See All by taiki45
RustでAWS Lambda functionをいい感じに書く
taiki45
1
250
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
570
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
1.7k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.2k
Cloud Native Meetup Tokyo #8 ServiceMesh Day Recap
taiki45
2
300
EnvoyCon 2018: Building and operating service mesh at mid-size company
taiki45
4
4.3k
Cookpad Tech Kitchen #20 クックパッドでのサービスメッシュについて
taiki45
1
2.2k
Building and operating service mesh at mid-size company
taiki45
2
2.2k
Other Decks in Programming
See All in Programming
The Hotwire Landscape After Turbo 8 @ Brighton Ruby 2024
marcoroth
2
230
[Flutter] Unitテストの基礎を理解する
haruki_uiru
0
200
アーキテクチャレベルで考える開発生産性 / architecture-and-productivity
minodriven
18
7.2k
奥が深いメールのシステム / The depth of Email system
linyows
3
240
アプリケーションをリプレイスしたら チームとサービス運用に向き合えた
kazatohiei
1
340
スクラムチームに入れないという選択: フルサイクルチームにおける開発者のステップアップ / Why We Don’t Add Newbies to Our Scrum Team
yuk4w4
3
1.6k
KotlinのLinter まなびなおし2024
nyafunta9858
0
2.5k
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.1k
Get started with Compose Multiplatform!
ogi2ogi
0
1.2k
Adding Tests to Untestable Legacy Code
afilina
PRO
0
190
高品質と高スピードを両立させるテストアプローチ/Test Approach that Improves Quality and Agility Together
goyoki
12
8.4k
Secure Development with PHP
dbrumann
2
200
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
The Cult of Friendly URLs
andyhume
74
5.8k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
24
1.7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
19
7.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
651
58k
Agile that works and the tools we love
rasmusluckow
325
20k
Creatively Recalculating Your Daily Design Routine
revolveconf
213
11k
The Language of Interfaces
destraynor
151
23k
Optimizing for Happiness
mojombo
372
69k
4 Signs Your Business is Dying
shpigford
177
21k
WebSockets: Embracing the real-time Web
robhawkes
59
7.1k
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