SlideShare a Scribd company logo
Elmish / F#
SAFE Stack による Web 開発
T. Midorikawa a.k.a midoliy
• 大阪府 大阪市
• C# / F# 愛の伝道師 (非公式)
• Twitter: @ _midoliy_
• GitHub: @ Midoliy
• HP: https://midoliy.com
• Youtube: https://www.youtube.com/user/dgakusei
• 大阪 F# もくもく会 主催: https://oosakafs-moku2.connpass.com
What is SAFE Stack ?
• Fableを使ってSPAを作成するためのプロジェクトテンプレート
Saturn ・・・ バックエンドサービス用 F# ライブラリ.
Azure ・・・ いわずもがなの Microsoft Azure.
Fable ・・・ Babel を搭載した F# → Javascript コンパイラ.
Elmish ・・・ 本日の主役. F# で UI を記述するためのフレームワー
ク.
SAFE Stack 構成図
(引用元) https://safe-stack.github.io/docs/overview/
What is Elmish ?
• Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー
ク
UpdateView
UI
The Elm Architecture (MVU)
HTML Message
Create
New Model
Model
The Elm Architecture (MVU)
What is Elmish ?
• Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー
ク
UpdateView
UI
HTML Message
Create
New Model
Model
View → UI
let view (model : Model) (dispatch : Msg -> unit) =
div []
[ Navbar.navbar [ Navbar.Color IsPrimary ]
[ Navbar.Item.div [ ]
[ Heading.h2 [ ]
[ str "SAFE Template" ] ] ]
Container.container []
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ]
Columns.columns []
[ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ]
Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ]
Footer.footer [ ]
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ safeComponents ] ] ]
View → UI
let view (model : Model) (dispatch : Msg -> unit) =
div []
[ Navbar.navbar [ Navbar.Color IsPrimary ]
[ Navbar.Item.div [ ]
[ Heading.h2 [ ]
[ str "SAFE Template" ] ] ]
Container.container []
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ]
Columns.columns []
[ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ]
Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ]
Footer.footer [ ]
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ safeComponents ] ] ]
<nav class="navbar is-primary">
<div class="navbar-item">
<h2 class="title is-2">SAFE Template</h2>
</div>
</nav>
View → UI
View → UI
Container.container []
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ]
Columns.columns []
[ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ]
Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ]
<div class="container">
<div class="content has-text-centered">
<h3 class="title is-3">Press buttons to manipulate counter: 42</h3>
</div>
<div class="columns">
<div class="column">
<button class="button is-primary is-fullwidth">-</button>
</div>
<div class="column">
<button class="button is-primary is-fullwidth">+</button>
</div>
</div>
</div>
View → UI
Container.container []
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ]
Columns.columns []
[ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ]
Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ]
UI → Update
The Elm Architecture (MVU)
What is Elmish ?
• Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー
ク
UpdateView
UIHTML Message
Create
New Model
Model
View → UI & UI → Update
The Elm Architecture (MVU)
What is Elmish ?
• Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー
ク
UpdateView
UI
HTML Message
Create
New Model
Model
Update → View
let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> =
match currentModel.Counter, msg with
| Some counter, Increment ->
let nextModel = { currentModel with Counter = Some { Value = counter.Value + 1 } }
nextModel, Cmd.none
| Some counter, Decrement ->
let nextModel = { currentModel with Counter = Some { Value = counter.Value - 1 } }
nextModel, Cmd.none
| _, InitialCountLoaded initialCount ->
let nextModel = { Counter = Some initialCount }
nextModel, Cmd.none
| _ -> currentModel, Cmd.none
Update → View
let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> =
match currentModel.Counter, msg with
| Some counter, Increment ->
let nextModel = { currentModel with Counter = Some { Value = counter.Value + 1 } }
nextModel, Cmd.none
| Some counter, Decrement ->
let nextModel = { currentModel with Counter = Some { Value = counter.Value - 1 } }
nextModel, Cmd.none
| _, InitialCountLoaded initialCount ->
let nextModel = { Counter = Some initialCount }
nextModel, Cmd.none
| _ -> currentModel, Cmd.none
Update → View
let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> =
match currentModel.Counter, msg with
| Some counter, Increment ->
let nextModel = { currentModel with Counter = Some { Value = counter.Value + 1 } }
nextModel, Cmd.none
| Some counter, Decrement ->
let nextModel = { currentModel with Counter = Some { Value = counter.Value - 1 } }
nextModel, Cmd.none
| _, InitialCountLoaded initialCount ->
let nextModel = { Counter = Some initialCount }
nextModel, Cmd.none
| _ -> currentModel, Cmd.none
View → UI
let view (model : Model) (dispatch : Msg -> unit) =
div []
[ Navbar.navbar [ Navbar.Color IsPrimary ]
[ Navbar.Item.div [ ]
[ Heading.h2 [ ]
[ str "SAFE Template" ] ] ]
Container.container []
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ]
Columns.columns []
[ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ]
Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ]
Footer.footer [ ]
[ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ]
[ safeComponents ] ] ]
まとめ
• Elmish = F# で Web開発するためのイケてるライブラリ
• Reactが下で動作しているので、実行効率もそこまで悪くない
• サーバ側と型を共有できるので、型安全にコーディング可能
• 関数型プログラミングでバグり難い開発を!
ご清聴ありがとうございまし
た

More Related Content

Similar to dotnetConf2019 meetup in AICHI / Elmish

Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
Brian Hogan
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
Nattaya Mairittha
 
Web components with Angular
Web components with AngularWeb components with Angular
Web components with Angular
Ana Cidre
 
Declarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeDeclarative UIs with Jetpack Compose
Declarative UIs with Jetpack Compose
Ramon Ribeiro Rabello
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Eyal Vardi
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMohammad Shaker
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
John Wilker
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
Maurizio Vitale
 
Meteor Day Talk
Meteor Day TalkMeteor Day Talk
Meteor Day Talk
Brandon Bechtel
 
Magic of web components
Magic of web componentsMagic of web components
Magic of web components
HYS Enterprise
 
Building Reusable Custom Elements With Angular
Building Reusable Custom Elements With AngularBuilding Reusable Custom Elements With Angular
Building Reusable Custom Elements With Angular
Ilia Idakiev
 
Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
Brian Hogan
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
Kyle Cearley
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
Jeado Ko
 
CodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderCodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilder
Andres Almiray
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatiasapientindia
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
C4Media
 

Similar to dotnetConf2019 meetup in AICHI / Elmish (20)

Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
 
Web components with Angular
Web components with AngularWeb components with Angular
Web components with Angular
 
Declarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeDeclarative UIs with Jetpack Compose
Declarative UIs with Jetpack Compose
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhone
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
Meteor Day Talk
Meteor Day TalkMeteor Day Talk
Meteor Day Talk
 
Magic of web components
Magic of web componentsMagic of web components
Magic of web components
 
Building Reusable Custom Elements With Angular
Building Reusable Custom Elements With AngularBuilding Reusable Custom Elements With Angular
Building Reusable Custom Elements With Angular
 
Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
 
CodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderCodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilder
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 

Recently uploaded

Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 

Recently uploaded (20)

Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 

dotnetConf2019 meetup in AICHI / Elmish

  • 1. Elmish / F# SAFE Stack による Web 開発
  • 2. T. Midorikawa a.k.a midoliy • 大阪府 大阪市 • C# / F# 愛の伝道師 (非公式) • Twitter: @ _midoliy_ • GitHub: @ Midoliy • HP: https://midoliy.com • Youtube: https://www.youtube.com/user/dgakusei • 大阪 F# もくもく会 主催: https://oosakafs-moku2.connpass.com
  • 3. What is SAFE Stack ? • Fableを使ってSPAを作成するためのプロジェクトテンプレート Saturn ・・・ バックエンドサービス用 F# ライブラリ. Azure ・・・ いわずもがなの Microsoft Azure. Fable ・・・ Babel を搭載した F# → Javascript コンパイラ. Elmish ・・・ 本日の主役. F# で UI を記述するためのフレームワー ク.
  • 4. SAFE Stack 構成図 (引用元) https://safe-stack.github.io/docs/overview/
  • 5. What is Elmish ? • Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー ク UpdateView UI The Elm Architecture (MVU) HTML Message Create New Model Model
  • 6. The Elm Architecture (MVU) What is Elmish ? • Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー ク UpdateView UI HTML Message Create New Model Model
  • 7. View → UI let view (model : Model) (dispatch : Msg -> unit) = div [] [ Navbar.navbar [ Navbar.Color IsPrimary ] [ Navbar.Item.div [ ] [ Heading.h2 [ ] [ str "SAFE Template" ] ] ] Container.container [] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ] Columns.columns [] [ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ] Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ] Footer.footer [ ] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ safeComponents ] ] ]
  • 8. View → UI let view (model : Model) (dispatch : Msg -> unit) = div [] [ Navbar.navbar [ Navbar.Color IsPrimary ] [ Navbar.Item.div [ ] [ Heading.h2 [ ] [ str "SAFE Template" ] ] ] Container.container [] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ] Columns.columns [] [ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ] Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ] Footer.footer [ ] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ safeComponents ] ] ] <nav class="navbar is-primary"> <div class="navbar-item"> <h2 class="title is-2">SAFE Template</h2> </div> </nav>
  • 10. View → UI Container.container [] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ] Columns.columns [] [ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ] Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ] <div class="container"> <div class="content has-text-centered"> <h3 class="title is-3">Press buttons to manipulate counter: 42</h3> </div> <div class="columns"> <div class="column"> <button class="button is-primary is-fullwidth">-</button> </div> <div class="column"> <button class="button is-primary is-fullwidth">+</button> </div> </div> </div>
  • 11. View → UI Container.container [] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ] Columns.columns [] [ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ] Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ] UI → Update
  • 12. The Elm Architecture (MVU) What is Elmish ? • Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー ク UpdateView UIHTML Message Create New Model Model
  • 13. View → UI & UI → Update
  • 14. The Elm Architecture (MVU) What is Elmish ? • Elmスタイルの 「Model - View - Update」アーキテクチャをサポートするフレームワー ク UpdateView UI HTML Message Create New Model Model
  • 15. Update → View let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> = match currentModel.Counter, msg with | Some counter, Increment -> let nextModel = { currentModel with Counter = Some { Value = counter.Value + 1 } } nextModel, Cmd.none | Some counter, Decrement -> let nextModel = { currentModel with Counter = Some { Value = counter.Value - 1 } } nextModel, Cmd.none | _, InitialCountLoaded initialCount -> let nextModel = { Counter = Some initialCount } nextModel, Cmd.none | _ -> currentModel, Cmd.none
  • 16. Update → View let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> = match currentModel.Counter, msg with | Some counter, Increment -> let nextModel = { currentModel with Counter = Some { Value = counter.Value + 1 } } nextModel, Cmd.none | Some counter, Decrement -> let nextModel = { currentModel with Counter = Some { Value = counter.Value - 1 } } nextModel, Cmd.none | _, InitialCountLoaded initialCount -> let nextModel = { Counter = Some initialCount } nextModel, Cmd.none | _ -> currentModel, Cmd.none
  • 17. Update → View let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> = match currentModel.Counter, msg with | Some counter, Increment -> let nextModel = { currentModel with Counter = Some { Value = counter.Value + 1 } } nextModel, Cmd.none | Some counter, Decrement -> let nextModel = { currentModel with Counter = Some { Value = counter.Value - 1 } } nextModel, Cmd.none | _, InitialCountLoaded initialCount -> let nextModel = { Counter = Some initialCount } nextModel, Cmd.none | _ -> currentModel, Cmd.none
  • 18. View → UI let view (model : Model) (dispatch : Msg -> unit) = div [] [ Navbar.navbar [ Navbar.Color IsPrimary ] [ Navbar.Item.div [ ] [ Heading.h2 [ ] [ str "SAFE Template" ] ] ] Container.container [] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ Heading.h3 [] [ str ("Press buttons to manipulate counter: " + show model) ] ] Columns.columns [] [ Column.column [] [ button "-" (fun _ -> dispatch Decrement) ] Column.column [] [ button "+" (fun _ -> dispatch Increment) ] ] ] Footer.footer [ ] [ Content.content [ Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] [ safeComponents ] ] ]
  • 19. まとめ • Elmish = F# で Web開発するためのイケてるライブラリ • Reactが下で動作しているので、実行効率もそこまで悪くない • サーバ側と型を共有できるので、型安全にコーディング可能 • 関数型プログラミングでバグり難い開発を!