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
950
Haskell でつくる VM 〜散りゆく Endomorphism〜
関数型LT大会の LT です
http://connpass.com/event/5795/
taiki45
May 11, 2014
Tweet
Share
More Decks by taiki45
See All by taiki45
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
520
builderscon Tokyo 2019: Intro Service Mesh
taiki45
6
2.9k
NoOps Meetup Tokyo #7: 入門サービスメッシュ
taiki45
4
1.7k
CloudNative Days Tokyo 2019: Understanding Envoy
taiki45
3
3.1k
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.2k
Cookpad Tech Kitchen #20 クックパッドでのサービスメッシュについて
taiki45
1
2.1k
Building and operating service mesh at mid-size company
taiki45
2
2.1k
Observability, Service Mesh and Microservices
taiki45
25
6.1k
Other Decks in Programming
See All in Programming
スタートアップのフロントエンド事情 GENBA #2 〜Front-End Opsの現場〜
ebijun1007
1
780
OpCode目線で眺める PHPコードのカバレッジ
o0h
PRO
2
470
Cloud RunとCloud PubSubでサーバレスなデータ基盤2024 with Terraform / Cloud Run and PubSub with Terraform
shinyorke
7
1.7k
PHP で読む楽しいコアダンプ
sji
0
220
PHPアプリケーションのスケーラビリティと 信頼性を革新する nginx+ngx_mrubyとGoの融合
pyama86
2
220
Kotlinを用いたDSL的な設計手法と使用上の注意
kohii00
2
490
Learning PHP and Static Analysis with PHP Parser
inouehi
1
220
mandaRa: R言語ユーザのための新しい知識共有の場 / mandara_tokyor111
s_uryu
2
410
まっちすいっち戦争 / match vs switch
takuyakatsusa
1
630
iOS / Android ネイティブ 実装アプリの Flutter 化事例
mthiroshi
0
650
PHP 8.3で追加されたjson_validate()を徹底的に深掘りしてみよう
mashirou1234
0
610
Material 3で Material 2ぽい見た目にする
numeroanddev
2
220
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
27
6.3k
GraphQLとの向き合い方2022年版
quramy
28
12k
Automating Front-end Workflow
addyosmani
1353
200k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.2k
[RailsConf 2023] Rails as a piece of cake
palkan
21
3.8k
Being A Developer After 40
akosma
56
580k
Design by the Numbers
sachag
274
18k
Writing Fast Ruby
sferik
619
59k
Documentation Writing (for coders)
carmenintech
59
3.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
KATA
mclloyd
14
11k
Principles of Awesome APIs and How to Build Them.
keavy
119
16k
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