SlideShare a Scribd company logo
探索 .NET 新世界
F# & SAFE Stack
函數式開發典範
Kevin Yang
F# 基本介紹
什麼是 F#
• An open-source language that makes it easy to write succinct,
robust, and performant code.
• Many features
• Lightweight syntax
• Immutable by default
• Type inference and automatic generalization
• First-class functions
• Powerful data types
• Pattern matching
• Async programming
執行環境
• 安裝 .NET SDK 6 (支援 F# 6,有很多新功能)
• 編輯器選擇
• Visual Studio
• Visual Studio Code with【 Ionide-fsharp 】extension
Something about Function
• Simple Rule
• One input and return one output
• Pure function
• Given the same input, it will always return the same output.
Produces no side effects.
• Benefits
• easy to test
• cacheable
• parallelizable.
F# 語法介紹
Functions and modules
• Functions 是 F# 最基本元素
• 可用 Modules 來做分類管理
• 使用 open 來打開 module
• 使用 let 宣告 function
• 使用 let 綁定值到變數上 (Immutable)
• 使用 mutable 設定變數為 mutable
• 使用 <- 來改變值
Pipelines
• he pipe operator |> is used extensively when processing
data in F#.
Curried Functions
• Currying is a process that transforms a function that has
more than one parameter into a series of embedded
functions, each of which has a single parameter.
型別
• 基礎型別
• string
• double quote
• string literal with @ or triple quote
• concatenation with +
• %s print a string value (type-safe)
• substrings use the indexer notation
• integer
• %d print an integer value (type-safe)
• float
• %f print a float value (type-safe)
• Boolean
• %b print a Boolean value (type-safe)
Tuples
• grouping of unnamed but ordered values
let tuple1 = (1, 2, 3)
let swapElems (a, b) = (b, a)
Lists, Arrays, Sequences
• Lists: ordered, immutable collections of elements of the same
type
• [ ] // empty list
• [1; 2; 3]
• [ 1 .. 10 ]
• Array: fixed-size, mutable collections of elements of the same
type
• [| |] // empty array
• 其餘的寫法跟 List 一樣
• Sequences: a logical series of elements, all of the same type
• Seq.empty // empty sequence
• seq { 1.. 10 }
Record
• an aggregate of named values, with optional members (such
as methods)
type ContactCard = { Name : string Phone : string Verified :
bool }
let contact1 = { Name = "Alf" Phone = "(206) 555-0157"
Verified = false }
let contact2 = { contact1 with Phone = "(206) 555-0112"
Verified = true }
Discriminated Unions
• values that could be a number of named forms or cases.
type Suit = | Hearts | Clubs | Diamonds | Spades
type Rank =
/// Represents the rank of cards 2 .. 10
| Value of int
| Ace
| King
| Queen
| Jack
Pattern Matching
• the F# feature that enables correctness for operating on F#
types.
Demo
Functional BDD
SAFE Stack
什麼是 SAFE
• An end-to-end, functional-first stack for cloud-ready web
development that emphasizes type-safe programming
• .NET Core ready
什麼是 SAFE
• Saturn + Giraffe for back-end services in F#
• Azure (Host) <= 為了拼出 SAFE 硬加上去的
• Fable for running F# in the web browser
• Elmish for client-side user interfaces
使用 SAFE
• 安裝 SAFE project template (One time effort)
•
• 使用 safe project template
dotnet new –I SAFE.Template
dotnet new SAFE
Demo
TODO App with SAFE Stack
Take away
• F# is fun, you should try it sometime.
• FP 不難,只是他用另外一個角度思考問題罷了
References
• SAFE Documentation
• https://safe-stack.github.io/docs/template-overview/
• SAFE Demo Code
• https://github.com/chgc/FSharp-and-safe-demoCode-
dotnetConf2021
• F#
• https://fsharp.org/
• Functional BDD Demo Code
• https://github.com/chgc/example-functional-bdd-dotnetConf2021
Kevin Yang
• Blog
https://blog.kevinyang.net/
• FB Page
https://www.facebook.com/CKNotepad
Thanks for joining!
Azure Taiwan
User Group

More Related Content

What's hot

Functions in javascript
Functions in javascriptFunctions in javascript
C# 8 in Libraries and Applications
C# 8 in Libraries and ApplicationsC# 8 in Libraries and Applications
C# 8 in Libraries and Applications
Christian Nagel
 
Intro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionIntro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: Function
Jeongbae Oh
 
5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca
ssuserfadb24
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
GlobalLogic Ukraine
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
Marcus Denker
 
Introduction to f#
Introduction to f#Introduction to f#
Introduction to f#
mjyeaney
 
Swift, a quick overview
Swift, a quick overviewSwift, a quick overview
Swift, a quick overview
Julian Król
 
A (very brief) into to Functional Programming
A (very brief) into to Functional ProgrammingA (very brief) into to Functional Programming
A (very brief) into to Functional Programming
Brooklyn Zelenka
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in Pharo
Marcus Denker
 
Functions, anonymous functions and the function type
Functions, anonymous functions and the function typeFunctions, anonymous functions and the function type
Functions, anonymous functions and the function type
Chang John
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
Marcus Denker
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 
What's new in Swift 5.0
What's new in Swift 5.0What's new in Swift 5.0
What's new in Swift 5.0
you-hsuan yu
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
Mohamed Wael
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
Andrei Rinea
 
Dynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection PromisesDynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection Promises
Marcus Denker
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
Marcus Denker
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
Neeraj Bhusare
 

What's hot (19)

Functions in javascript
Functions in javascriptFunctions in javascript
Functions in javascript
 
C# 8 in Libraries and Applications
C# 8 in Libraries and ApplicationsC# 8 in Libraries and Applications
C# 8 in Libraries and Applications
 
Intro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionIntro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: Function
 
5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca5 hs mpostcustomizationrenefonseca
5 hs mpostcustomizationrenefonseca
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Introduction to f#
Introduction to f#Introduction to f#
Introduction to f#
 
Swift, a quick overview
Swift, a quick overviewSwift, a quick overview
Swift, a quick overview
 
A (very brief) into to Functional Programming
A (very brief) into to Functional ProgrammingA (very brief) into to Functional Programming
A (very brief) into to Functional Programming
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in Pharo
 
Functions, anonymous functions and the function type
Functions, anonymous functions and the function typeFunctions, anonymous functions and the function type
Functions, anonymous functions and the function type
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
What's new in Swift 5.0
What's new in Swift 5.0What's new in Swift 5.0
What's new in Swift 5.0
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
 
Dynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection PromisesDynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection Promises
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
 

Similar to Dotnet Conf 2021 - F# and Safe Stack

Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
Azilen Technologies Pvt. Ltd.
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
Pray Desai
 
Java Fx
Java FxJava Fx
Elixir Study Group Kickoff Meetup
Elixir Study Group Kickoff MeetupElixir Study Group Kickoff Meetup
Elixir Study Group Kickoff Meetup
Yuri Leikind
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayLuka Zakrajšek
 
SIL - All you need to know about Swift Intermediate Language
SIL - All you need to know about Swift Intermediate LanguageSIL - All you need to know about Swift Intermediate Language
SIL - All you need to know about Swift Intermediate Language
Bartosz Polaczyk
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0
Moaid Hathot
 
Java ce241
Java ce241Java ce241
Java ce241
Minal Maniar
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
APNIC
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
IndyMobileNetDev
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
Dave Fancher
 
Core JavaScript
Core JavaScriptCore JavaScript
Core JavaScript
Lilia Sfaxi
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos
3Pillar Global
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
pmanvi
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
MAYANKKUMAR492040
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
Troy Miles
 
Elixir Programming Language 101
Elixir Programming Language 101Elixir Programming Language 101
Elixir Programming Language 101
Around25
 
Object Oriented Programming with COBOL
Object Oriented Programming with COBOLObject Oriented Programming with COBOL
Object Oriented Programming with COBOL
Micro Focus
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmerselliando dias
 

Similar to Dotnet Conf 2021 - F# and Safe Stack (20)

Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Java Fx
Java FxJava Fx
Java Fx
 
Elixir Study Group Kickoff Meetup
Elixir Study Group Kickoff MeetupElixir Study Group Kickoff Meetup
Elixir Study Group Kickoff Meetup
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
SIL - All you need to know about Swift Intermediate Language
SIL - All you need to know about Swift Intermediate LanguageSIL - All you need to know about Swift Intermediate Language
SIL - All you need to know about Swift Intermediate Language
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0
 
Java ce241
Java ce241Java ce241
Java ce241
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
 
Core JavaScript
Core JavaScriptCore JavaScript
Core JavaScript
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
 
Elixir Programming Language 101
Elixir Programming Language 101Elixir Programming Language 101
Elixir Programming Language 101
 
Object Oriented Programming with COBOL
Object Oriented Programming with COBOLObject Oriented Programming with COBOL
Object Oriented Programming with COBOL
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmers
 

More from Chieh Kai Yang

無密碼時代終於要來了嗎
無密碼時代終於要來了嗎無密碼時代終於要來了嗎
無密碼時代終於要來了嗎
Chieh Kai Yang
 
Structured data
Structured dataStructured data
Structured data
Chieh Kai Yang
 
Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]
Chieh Kai Yang
 
Study4TW - .NET Conf 2019 - Rx
Study4TW - .NET Conf 2019 - RxStudy4TW - .NET Conf 2019 - Rx
Study4TW - .NET Conf 2019 - Rx
Chieh Kai Yang
 
Reactive Programmin
Reactive ProgramminReactive Programmin
Reactive Programmin
Chieh Kai Yang
 
從零走到 Angular 世界
從零走到 Angular 世界從零走到 Angular 世界
從零走到 Angular 世界
Chieh Kai Yang
 
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
Chieh Kai Yang
 
Study4.TW .NET Conf 2018 - Fp in c#
Study4.TW .NET Conf 2018  - Fp in c#Study4.TW .NET Conf 2018  - Fp in c#
Study4.TW .NET Conf 2018 - Fp in c#
Chieh Kai Yang
 
How to 系列 - Hosting a website
How to 系列 - Hosting a websiteHow to 系列 - Hosting a website
How to 系列 - Hosting a website
Chieh Kai Yang
 
2018-01-06 Study4Love Conference - Rendertron
2018-01-06 Study4Love Conference - Rendertron2018-01-06 Study4Love Conference - Rendertron
2018-01-06 Study4Love Conference - Rendertron
Chieh Kai Yang
 
ModernWeb 2017 angular component
ModernWeb 2017 angular componentModernWeb 2017 angular component
ModernWeb 2017 angular component
Chieh Kai Yang
 

More from Chieh Kai Yang (11)

無密碼時代終於要來了嗎
無密碼時代終於要來了嗎無密碼時代終於要來了嗎
無密碼時代終於要來了嗎
 
Structured data
Structured dataStructured data
Structured data
 
Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]
 
Study4TW - .NET Conf 2019 - Rx
Study4TW - .NET Conf 2019 - RxStudy4TW - .NET Conf 2019 - Rx
Study4TW - .NET Conf 2019 - Rx
 
Reactive Programmin
Reactive ProgramminReactive Programmin
Reactive Programmin
 
從零走到 Angular 世界
從零走到 Angular 世界從零走到 Angular 世界
從零走到 Angular 世界
 
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
 
Study4.TW .NET Conf 2018 - Fp in c#
Study4.TW .NET Conf 2018  - Fp in c#Study4.TW .NET Conf 2018  - Fp in c#
Study4.TW .NET Conf 2018 - Fp in c#
 
How to 系列 - Hosting a website
How to 系列 - Hosting a websiteHow to 系列 - Hosting a website
How to 系列 - Hosting a website
 
2018-01-06 Study4Love Conference - Rendertron
2018-01-06 Study4Love Conference - Rendertron2018-01-06 Study4Love Conference - Rendertron
2018-01-06 Study4Love Conference - Rendertron
 
ModernWeb 2017 angular component
ModernWeb 2017 angular componentModernWeb 2017 angular component
ModernWeb 2017 angular component
 

Recently uploaded

Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 

Recently uploaded (20)

Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 

Dotnet Conf 2021 - F# and Safe Stack

  • 2. F# & SAFE Stack 函數式開發典範 Kevin Yang
  • 4. 什麼是 F# • An open-source language that makes it easy to write succinct, robust, and performant code. • Many features • Lightweight syntax • Immutable by default • Type inference and automatic generalization • First-class functions • Powerful data types • Pattern matching • Async programming
  • 5. 執行環境 • 安裝 .NET SDK 6 (支援 F# 6,有很多新功能) • 編輯器選擇 • Visual Studio • Visual Studio Code with【 Ionide-fsharp 】extension
  • 6. Something about Function • Simple Rule • One input and return one output • Pure function • Given the same input, it will always return the same output. Produces no side effects. • Benefits • easy to test • cacheable • parallelizable.
  • 8. Functions and modules • Functions 是 F# 最基本元素 • 可用 Modules 來做分類管理 • 使用 open 來打開 module • 使用 let 宣告 function • 使用 let 綁定值到變數上 (Immutable) • 使用 mutable 設定變數為 mutable • 使用 <- 來改變值
  • 9. Pipelines • he pipe operator |> is used extensively when processing data in F#.
  • 10. Curried Functions • Currying is a process that transforms a function that has more than one parameter into a series of embedded functions, each of which has a single parameter.
  • 11. 型別 • 基礎型別 • string • double quote • string literal with @ or triple quote • concatenation with + • %s print a string value (type-safe) • substrings use the indexer notation • integer • %d print an integer value (type-safe) • float • %f print a float value (type-safe) • Boolean • %b print a Boolean value (type-safe)
  • 12. Tuples • grouping of unnamed but ordered values let tuple1 = (1, 2, 3) let swapElems (a, b) = (b, a)
  • 13. Lists, Arrays, Sequences • Lists: ordered, immutable collections of elements of the same type • [ ] // empty list • [1; 2; 3] • [ 1 .. 10 ] • Array: fixed-size, mutable collections of elements of the same type • [| |] // empty array • 其餘的寫法跟 List 一樣 • Sequences: a logical series of elements, all of the same type • Seq.empty // empty sequence • seq { 1.. 10 }
  • 14. Record • an aggregate of named values, with optional members (such as methods) type ContactCard = { Name : string Phone : string Verified : bool } let contact1 = { Name = "Alf" Phone = "(206) 555-0157" Verified = false } let contact2 = { contact1 with Phone = "(206) 555-0112" Verified = true }
  • 15. Discriminated Unions • values that could be a number of named forms or cases. type Suit = | Hearts | Clubs | Diamonds | Spades type Rank = /// Represents the rank of cards 2 .. 10 | Value of int | Ace | King | Queen | Jack
  • 16. Pattern Matching • the F# feature that enables correctness for operating on F# types.
  • 19. 什麼是 SAFE • An end-to-end, functional-first stack for cloud-ready web development that emphasizes type-safe programming • .NET Core ready
  • 20. 什麼是 SAFE • Saturn + Giraffe for back-end services in F# • Azure (Host) <= 為了拼出 SAFE 硬加上去的 • Fable for running F# in the web browser • Elmish for client-side user interfaces
  • 21. 使用 SAFE • 安裝 SAFE project template (One time effort) • • 使用 safe project template dotnet new –I SAFE.Template dotnet new SAFE
  • 22. Demo TODO App with SAFE Stack
  • 23. Take away • F# is fun, you should try it sometime. • FP 不難,只是他用另外一個角度思考問題罷了
  • 24. References • SAFE Documentation • https://safe-stack.github.io/docs/template-overview/ • SAFE Demo Code • https://github.com/chgc/FSharp-and-safe-demoCode- dotnetConf2021 • F# • https://fsharp.org/ • Functional BDD Demo Code • https://github.com/chgc/example-functional-bdd-dotnetConf2021
  • 25. Kevin Yang • Blog https://blog.kevinyang.net/ • FB Page https://www.facebook.com/CKNotepad

Editor's Notes

  1. F # 是一種開放原始碼、跨平臺、互通的程式設計語言,可用於撰寫簡潔、穩固且高效能的程式碼。 您的焦點會保持在您的問題領域,而不是程式設計的詳細資料。 輕量語法 預設為不可變 型別推斷和自動一般化 一級函式 強大的資料類型 模式比對 非同步程式設計