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
550
Error Handling in Rust Applications
taiki45
3
530
Efficient Platform for Security and Compliance
taiki45
4
1.3k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
600
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
710
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
360
Other Decks in Programming
See All in Programming
ベクトル検索システムの気持ち
monochromegane
29
8.7k
SQL Server ベクトル検索
odashinsuke
0
100
生産性アップのためのAI個人活用
kunoyasu
0
480
アーキテクトと美学 / Architecture and Aesthetics
nrslib
12
2.9k
PsySHから紐解くREPLの仕組み
muno92
PRO
1
510
Denoでフロントエンド開発 2025年春版 / Frontend Development with Deno (Spring 2025)
petamoriken
1
1.3k
RCPと宣言型ポリシーについてのお話し
kokitamura
2
140
CQRS+ES勉強会#1
rechellatek
0
390
フロントエンドテストの育て方
quramy
8
2.4k
CTFのWebにおける⾼難易度問題について
hamayanhamayan
1
950
JavaOne 2025: Advancing Java Profiling
jbachorik
1
310
マルチアカウント環境での、そこまでがんばらない RI/SP 運用設計
wa6sn
0
340
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
39
7.2k
Side Projects
sachag
452
42k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
BBQ
matthewcrist
88
9.5k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
Testing 201, or: Great Expectations
jmmastey
42
7.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Fireside Chat
paigeccino
37
3.3k
The Invisible Side of Design
smashingmag
299
50k
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