Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
型付きWebフレームワークで遊んでみた
Search
kokuyouwind
July 14, 2014
Programming
1.9k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
型付きWebフレームワークで遊んでみた
発表時間5分の社内LT大会で使用した資料です(実名・所属など一部改変)。
OCamlのWebフレームワークOcsigenを使ってみたので、その簡単な紹介となっています。
kokuyouwind
July 14, 2014
More Decks by kokuyouwind
See All by kokuyouwind
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
590
謎解きサイトを Rails SPA で作って RubyKaigi で配布した話
kokuyouwind
0
95
ドメイン指定Cookieとサービス間共有Redisで作る認証基盤サービス
kokuyouwind
0
46
Do LLMs dream of Type Inference?
kokuyouwind
0
49
Let's use LLMs from Ruby 〜 Refine RBS types using LLM 〜
kokuyouwind
0
8.6k
APMをちゃんと使おうとしたら、いつのまにか独自gemを作っていた話
kokuyouwind
0
980
RBS meets LLMs - Type inference using LLM
kokuyouwind
0
1.1k
オンラインボードゲームを作りたい人生だった
kokuyouwind
0
710
1年間本番運用してわかった、スタートアップこそAWS Copilot CLIを使うべきNつの理由
kokuyouwind
2
12k
Other Decks in Programming
See All in Programming
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
[DroidKaigi 2026] Bring your own phones to Gradle Managed Devices
f2lk
0
110
Foundry Localでエージェント開発
seosoft
0
160
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
420
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
130
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
220
Family mrubyの進捗
kishima
1
100
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
760
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
190
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
140
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
Six Lessons from altMBA
skipperchong
29
4.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
510
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
690
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
380
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
570
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Transcript
型付きWebフレームワークで 遊んでみた @kokuyouwind
$ whoami • Web開発 3年目(PHP Only) • Twitter : @kokuyouwind
• ブログ : blog.kokuyouwind.com • ニコニコミュニティ : co1347624 • ポーカー好き このアイコンの人→
先週のハッカソン
テーマ:出会い
出会い → 協調作業
協調作業 → 一緒にお絵かき
お絵かきアプリだ!
デモ http://draw.kokuyouwind.com/
screenshot
普通じゃね?
面白い所: HTMLもJavaScriptも 書いてない!
Haml? TypeScript?
いえいえ
全てOCamlです!
Code on Github https://github.com/kokuyouwind/ocsigen-tutorial ロジック部分は全てOcamlコード graffiti.eliomは150行弱
謝罪
さっきのデモは チュートリアルの丸写しです 正直すまんかった
Ocsigen http://ocsigen.org/
基本記法 {shared{ type message = string }} {client{ let _
= Eliom_lib.alert "Hello!" }} let main_service = (* ... *) 共通コード クライアントコード サーバーコード
サービス定義 let main_service = Eliom_registration.Html5.register_service ~path:[“hello"] ~get_params:Eliom_parameter.unit (fun () ()
-> Lwt.return (html (head (title (pcdata “hello")) []) (body [h1 [pcdata “hello, world!"]]))) Html型の値を生成
サービス定義 let main_service = Eliom_registration.Html5.register_service ~path:["graff"] ~get_params:Eliom_parameter.unit (fun () ()
-> Lwt.return (html (head (title (pcdata "Page title")) []) (body [ul [pcdata "Graffiti"]]))) ↑コンパイル時に型エラー (ulの子要素がliじゃない)
サーバー変数埋め込み let message = “hello” {client{ let _ = Eliom_lib.alert
“%s” %message }} ↑ %hogeでサーバー側の 変数を参照
サーバー変数埋め込み let message = 0 {client{ let _ = Eliom_lib.alert
“%s” %message }} ↑ Stringじゃないので エラーになる
サーバー変数埋め込み let message = 0 {client{ let _ = Eliom_lib.alert
“%s” (string_of_int %message) }} ↑ これならオーケー
他にも… • Bus, React – イベントをやりとりする – 前者がEvent Driven, 後者がReactive
– 型が合わないとコンパイル時にエラー • Ajaxでのjsonとかの呼び出し – service定義を参照してurlを生成 – 型が合わないとコンパイル時にエラー
まとめ • Ocsigenだと全部Ocamlで書ける • コンパイル時点で型起因のバグは弾く • コードが割と短くなる • 学習コストは結構高い •
名古屋こわい • ことりちゃんかわいい http://tkotori.github.io/
終わり from @mzp
以下予備スライド
Ocsigenプロジェクト • OcsigenServer : Webサーバ • Eliom : Webフレームワーク •
Js_of_ocaml : JSコンパイラ • Lwt : 並列計算ライブラリ • 他色々 – http://ocsigen.org/overview/framework
ページサイズ • HTML : 3.39KB – 通信用の識別子とかが埋め込まれている • JavaScript :
282.39KB – OCamlバイトコード => JavaScriptコード – 直接読むのは多分辛い – 実行はかなり高速らしい • VM実行OCamlよりも速い場合があるとのこと
ことりちゃん? • 高階ことり • モナドの薄い本のイメージキャラクター – @dico_lequeさんの本(予定) – @bleisさんと@mzpさんの差し金 •
ことりちゃん可愛い • http://tkotori.github.io/
参考 • Ocsigenプロジェクトページ – http://ocsigen.org/ • OCamlで構築するモダンWeb – http://proofcafe.org/~keigoi/pplss2012- ocaml.pdf
• OCamlで作ったWebアプリをHerokuで 動かす方法(2) – http://mzp.hatenablog.com/entry/2013/06 /08/003029