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
1
230
Error Handling in Rust Applications
taiki45
1
310
Efficient Platform for Security and Compliance
taiki45
3
1k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
340
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
620
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
3.1k
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
310
Other Decks in Programming
See All in Programming
Rustではじめる負荷試験
skanehira
5
1.2k
Rubyとクリエイティブコーディングの輪の広がり / The Growing Circle of Ruby and Creative Coding
chobishiba
1
240
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
0
130
BasicBasic認証
sadnessojisan
5
3.2k
ゲームボーイアドバンスでSwiftを動かそう
k_koheyi
0
540
2024 컴포즈 정원사
jisungbin
0
150
GoのIteratorに詳しくなってしまう
inatonix
1
190
Understand the mechanism! Let's do screenshots tests of Compose Previews with various variations / 仕組みから理解する!Composeプレビューを様々なバリエーションでスクリーンショットテストしよう
sumio
2
230
What is Parser
yui_knk
9
3.7k
Go Code Generation at newmo / 2024-08-27 #newmo_layerx_go
genkey6
0
540
いつか使える ObjectSpace / Maybe useful ObjectSpace
euglena1215
2
130
『ドメイン駆動設計をはじめよう』中核の業務領域
masuda220
PRO
5
910
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
64
11k
KATA
mclloyd
27
13k
Embracing the Ebb and Flow
colly
83
4.4k
How to name files
jennybc
75
98k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
28
1.6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
38
9.1k
Build your cross-platform service in a week with App Engine
jlugia
228
18k
Code Review Best Practice
trishagee
62
16k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Building Flexible Design Systems
yeseniaperezcruz
325
37k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
23
590
Unsuck your backbone
ammeep
667
57k
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