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
Error Handling in Rust Applications
taiki45
0
89
Efficient Platform for Security and Compliance
taiki45
3
750
RustでAWS Lambda functionをいい感じに書く
taiki45
2
280
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
590
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.3k
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
Other Decks in Programming
See All in Programming
さきがけから振り返るアーキテクチャ刷新 / Reflecting on the Architectural Renewal from the Vanguard
nrslib
2
770
CSC307 Lecture 06
javiergs
PRO
0
360
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
370
Play Billing Library 7.0.0 変更点まとめ@potatotips#88
kako351
0
160
Introduction of Happy Eyeballs Version 2 (RFC8305) to the Socket library
coe401_
1
220
Xcode 16のPreviewModifierと@Previewableを活用した効率的なプレビュー方法の考察
ojun9
2
160
APIのない大学ログインWebサービスをWKWebViewとJavaScriptでアプリ化した話
akidon0000
1
330
MIERUNE BBQにおけるユーザー中心設計()
mierune
PRO
1
110
最古の関数型言語「Lisp」ことはじめ / lisp_in_kamiyama
uhooi
1
190
Clean Architecture by TypeScript & NestJS
ryounasso
0
150
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
AHC035解説
terryu16
0
710
Featured
See All Featured
In The Pink: A Labor of Love
frogandcode
139
22k
It's Worth the Effort
3n
181
27k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
17
1.5k
The Cult of Friendly URLs
andyhume
75
5.9k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Rails Girls Zürich Keynote
gr2m
93
13k
Documentation Writing (for coders)
carmenintech
63
4.2k
Into the Great Unknown - MozCon
thekraken
20
1.3k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
WebSockets: Embracing the real-time Web
robhawkes
59
7.2k
The Invisible Customer
myddelton
117
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
224
21k
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