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.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
Mocking in Rust Applications
taiki45
2
470
Error Handling in Rust Applications
taiki45
1
360
Efficient Platform for Security and Compliance
taiki45
3
1.1k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
400
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
650
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.1k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
1.8k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.3k
Cloud Native Meetup Tokyo #8 ServiceMesh Day Recap
taiki45
2
320
Other Decks in Programming
See All in Programming
C#および.NETに対する誤解をひも解く
ymd65536
0
330
UnJSで簡単に始めるCLIツール開発 / cli-tool-development-with-unjs
aoseyuu
2
380
LangChain & LangServeでAPIを爆速作成
kijitorabuti
2
350
Vertical Architectures for Scalable Angular Applications
manfredsteyer
PRO
0
180
いかにして不足・不整合なくデータ移行したか
tjmtmmnk
1
570
CSC509 Lecture 04
javiergs
PRO
0
160
Quarto Clean Theme
nicetak
0
220
文化が生産性を作る
jimpei
3
610
20241004 モノタロウ式~ドメインモデリングとリアーキテクチャ
monotaro
PRO
2
650
VS Code extension: ドラッグ&ドロップでファイルを並び替える
ttrace
0
190
Unlocking Python's Core Magic
leew
0
140
ポケモンで考えるコミュニケーション / Communication Lessons from Pokémon
mackey0225
5
220
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
18
1k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
Code Reviewing Like a Champion
maltzj
519
39k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Git: the NoSQL Database
bkeepers
PRO
425
64k
Music & Morning Musume
bryan
46
6.1k
Rails Girls Zürich Keynote
gr2m
93
13k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
What's new in Ruby 2.0
geeforr
342
31k
No one is an island. Learnings from fostering a developers community.
thoeni
19
2.9k
Visualization
eitanlees
143
15k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
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