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
530
Error Handling in Rust Applications
taiki45
3
500
Efficient Platform for Security and Compliance
taiki45
4
1.3k
RustでAWS Lambda functionをいい感じに書く
taiki45
2
570
SPIFFE Meetup Tokyo #2 LT: Envoy SDS
taiki45
0
700
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
350
Other Decks in Programming
See All in Programming
Domain-Driven Transformation
hschwentner
2
1.9k
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
370
Introduction to kotlinx.rpc
arawn
0
700
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.4k
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
120
WebDriver BiDiとは何なのか
yotahada3
1
140
『GO』アプリ データ基盤のログ収集システムコスト削減
mot_techtalk
0
120
もう僕は OpenAPI を書きたくない
sgash708
5
1.6k
GAEログのコスト削減
mot_techtalk
0
120
CI改善もDatadogとともに
taumu
0
120
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
8
1.8k
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Thoughts on Productivity
jonyablonski
69
4.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
GraphQLとの向き合い方2022年版
quramy
44
13k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
How GitHub (no longer) Works
holman
314
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
Done Done
chrislema
182
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