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
Scotty + Aeson + Persistentで作るJSON Web API
Search
Fujimura Daisuke
July 07, 2012
Programming
12
9.7k
Scotty + Aeson + Persistentで作るJSON Web API
Fujimura Daisuke
July 07, 2012
Tweet
Share
More Decks by Fujimura Daisuke
See All by Fujimura Daisuke
AIの時代で我々はどのようにコードを書くのか
fujimura
3
760
SaaSを作るという仕事について
fujimura
12
5.6k
一文字エイリアスのすすめ
fujimura
0
310
現役CTOが語る!RubyKaigiの楽しみ方
fujimura
0
1.2k
いかにして文系新卒エンジニアが「大きな問い」を大事にするCTOになったのか
fujimura
2
660
Kaigi on Rails 2022 - 既存Railsアプリ攻略法 CTOが見ること・やること・考えること
fujimura
14
3.9k
SimpleDelegator活用のご提案
fujimura
0
1.5k
入門 名前
fujimura
23
13k
それPostgreSQLでできるよ @ Rails Developer Meetup 2018 Day 1
fujimura
10
3.9k
Other Decks in Programming
See All in Programming
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
6
7.3k
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
310
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
680
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
190
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
Click-free releases & the making of a CLI app
oheyadam
2
110
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
4
2.1k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
460
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
200
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
240
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
カスタムしながら理解するGraphQL Connection
yanagii
1
1.5k
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
334
57k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Transcript
Scotty + Aeson + PersistentͰ࡞ΔJSON Web API גࣜձࣾAiming ౻ଜେհ @
Yesodษڧձୈ2ճ, 2012-07-07
ࣗݾհ • ౻ଜେհ • http://fujimuradaisuke.com @ffu_ • גࣜձࣾAimingॴଐ • Haskell͖ͷRuby
on RailsϓϩάϥϚʔ • ࠷ۙJavaScript/CoffeeScriptΑ͘ॻ͍͍ͯΔ • ΞδΞͷྉཧͱΞϝϦΧͷϏʔϧɺΞϧβεͷϫΠϯ͕͖ • ϥςϯΞϝϦΧจֶ͖
ͱ͜ΖͰɺͳͥࠓJSON Web APIͳͷ͔ • ͳΜ͔ͩ࠷ۙJSON Web APIΛ࡞Δػձ͕ଟ͍ • ҰͭͷΞϓϦέʔγϣϯΛෳΫϥΠΞϯτͰಈ͔͢ࣄྫ͕૿͖͑ͯͨ •
Mobile, PC, iOS/Android Nativeશ෦ʹల։ͱ͔ • ϑϩϯτΤϯυͰUIΛߏங͢Δٕज़ͷൃୡɾਁಁ • ΫϥΠΞϯτɾαʔόʔͷۀਐΈͦ͏
ಥવͰ͕͢Yesod͍·͍ͪͩͱࢥ͏ • ࠷ۙWebσβΠϯ/ϑϩϯτΤϯυ։ൃ͕Ұஈͱ͘͠ͳ͖ͬͯͨؾ͕͢Δ • ͳͷͰΫϥΠΞϯτʗαʔόʔͰۀ͕Ͱ͖ͳ͍ͱݫ͍͠ • Έͳ͞ΜHamletͱCassiusͰϓϩμΫγϣϯϨϕϧͷϨεϙϯγϒͳϚʔΫ ΞοϓͰ͖·͔͢ʁ • Α͏͘sass/less͕ਁಁ͖ͯͨ͠ͷʹ·ͨ৽͍ٕ͠ज़Λ…
• ͔͠΄ͱΜͲҰॹͩ͠… • Web APIͱͯ͠͏ͱͳΔͱϑϧελοΫͷ͕ա͗Δ • ͳͥ͏༧ఆͷͳ͍ೝূϥΠϒϥϦͷΠϯετʔϧΛٻΊΒΕΔͷ͔
ͦ͜ͰWeb APIscottyͰ࡞Ζ͏Ͱͳ͍͔ • Web API࡞ΓDBΞΫηεͱϧʔςΟϯά͑͞Ͱ͖ΕجຊOK • ྫ͑RubyͩͱWeb API࡞Δ࣌RailsͰͳ͘sinatraͬͯͷΑ͋͘Δ • ϥΠϒϥϦͷґଘؔগͳ͍΄͏͕Կ͔ͱͤ
• DBpersistentɺJSONaesonͰͬͯΈΑ͏
scottyʹ͍ͭͯ • RubyͷsinatraΠϯεύΠΞͷWeb Application Framework • https://github.com/xich/scotty/ • γϯϓϧͳAPI •
Yesodͱಉ͘͡waiϕʔε
aesonʹ͍ͭͯ • Real World HaskellͷஶऀɺBryan O'Sullivan͞Μͷ࡞ͬͨJSONϥΠϒϥϦ • https://github.com/bos/aeson • ·ΔͰJSONͷΑ͏ͳߏจͰॻ͚ΔDSL(?)͕େมศར
• ͍Β͍͠
persistentʹ͍ͭͯ • ͝ଘYesodಉࠝͷORM • (͔͠͠ɺ”Object”ʹϚοϐϯά͞ΕͯΔؾશ͘ແ͍ʣ • http://www.yesodweb.com/book/persistent • PostgreSQL, SQLite,
MongoDB, MySQLʹରԠ • QuasiQuoteͰςʔϒϧఆٛɺϚΠάϨʔγϣϯ͋Δ • ܕνΣοΫ͖ͷSQLͬͯײ͡Ͱ͍͍͢
Ͱ͖·ͨ͠ • ͔݁Βݴ͏ͱͱͯͤͳΈ߹ΘͤͰͨ͠
persistentͱaesonͷ૬ੑ͕͢Β͔ͬͨ͠(1) • ςʔϒϧఆٛͨ͠ΒɺͦΕΛToJSON/FromJSONͷΠϯελϯεʹ͢Δ
persistentͱaesonͷ૬ੑ͕͢Β͔ͬͨ͠(2) • ͢ΔͱɺDBͷߦΛJSONͱͯ͠ѻ͑Δ(ToJSONͷΠϯελϯεʹͳΔͷͰʣ • ͳͷͰɺscottyͰͦͷ··JSONϨεϙϯεͱͯ͠ฦͤΔ
persistentͱaesonͷ૬ੑ͕͢Β͔ͬͨ͠(3) • ࠓςʔϒϧͱಉ͡εΩʔϚͷJSONΛPOST͢Δͱɺ • ͦͷ··ߦͱͯ͠DBʹೖΕΒΕΔʢFromJSONͷߦͱͯ͠ड͚औΕΔ͔Βʣ
͜Ε͔ͳΓΤϨΨϯτͳͷͰ • ͜ͷهड़ྔͰDB͔Βͷऔಘ/DBͷՃ͕Ͱ͖·͢ • ͍͢͝ʂ
ΩϥʔϥΠϒϥϦͷ༧ײ • ґଘ͕ؔগͳ͍ͷͰίϯύΠϧָ • ܕΫϥεΛ׆͔ͤΔ • Web APIͳΒHaskellͰΫϥΠΞϯτ։ൃͱͷڠಇͳ͠ • Ή͠ΖϥϯλΠϜΤϥʔ͕ແ͍ͷͰΫϥΠΞϯτ։ൃͤ
༨ஊ • ͪͳΈʹҐஔใܥͷWebαʔϏεΛ࡞Ζ͏ͱͯ͠·ͨ͠ • ΫϥΠΞϯτBackbone.js, CoffeeScriptɺGoogle Maps͋ͨΓΛར༻ • ࣮ࡍͷͱ͜ΖɺΫϥΠΞϯτͷίʔυΛॻ͍ͯΔํ͕͔ͬͨ… •
HTMLςϯϓϨʔτmustacheΛͬͨɻ͜Εྑ͔ͬͨ • ·ͩෳࡶͳ͜ͱΛͬͯͳ͍ͷͰɺམͱ͕݀͋͠Γͦ͏ • ೝূ·ΘΓ·ͩະணखɻམͱ͔݀͜͜͠…ʁ • Template HaskellΛͬͨΒToJSON/FromJSONʹ͢ΔͷࣗಈͰͰ͖ͦ͏ͳ ؾ͕…
͓ΘΓ • ιʔείʔυ https://github.com/fujimura/spot • ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ