SlideShare a Scribd company logo
1 of 91
Break Free with
Managed Functional Programming
An Introduction to F#
A language that doesn't affect the way you think
about programming, is not worth knowing.
Alan Perlis, Epigrams on Programming, 1982
About Me
• Dave Fancher
• Blog: http://davefancher.com
• Twitter: @davefancher
• Email: dave@davefancher.com
My Background
Why F#?
LINQ: The Functional Gateway Drug
• Learned about query syntax
• The method syntax
• Introduced me to functional principles
JavaScript, Too!
• Functions are first class citizens
• Its most powerful features are enabled by closures
Turning Functional
• Began applying functional principles in my code
• Immutability with readonly fields & properties
• More delegation
• Coding without side-effects
C# Was Getting Frustrating
• Verbose and repetitive
• Fragile
• Ceremonial
An Accidental Discovery
• Hanselminutes #311
• F#
So, what is this F# thing?
F# is a succinct, expressive, and efficient
functional and object-oriented language
for Microsoft .NET that helps you write
simple code to solve complex problems.
Origin
• CLR Language
• Microsoft Research, Cambridge
Lineage
ML OCaml F#
Multi-Paradigm
• Imperative
• Object-oriented
• Functional
Licensing & Availability
• First Class Citizen of Visual Studio since VS2010
• Apache 2.0 License
• Every major platform
• Managed by F# Software Foundation
Ok, but why should I care?
Gaining Traction
Source: TIOBE Index, May 2014 (http://bit.ly/1cvhJp3)
F# Over Time
August 2011
March 2013
March 2014
Source: TIOBE Index, May 2014 (http://bit.ly/1nnmeWK)
Functional-First
• Favors FP over other styles
• Other styles are available if needed
Design Principles
Terse Syntax
• Few keywords
• Limited punctuation
• Strong type inference
• Implicit return values
Top-Down Evaluation
• File order is significant
• Declaration order is, too
• Avoids inadvertent mutually recursive definitions
• Inferred return values
Organization Constructs
• Namespaces
• Modules
Expression-Based
• Everything returns a value
• Eager evaluation
Immutable by Default
• 3 Types of bindings
• Immutable by default
Let Bindings
Mutability
Reference Cells
Using Function & Use Bindings
Type system
All CLR Types
• Int32
• String
• Double
• Float
• DateTime
• TimeSpan
• Types from other assemblies
• …
Enumerations
Functions
• Every F# function accepts exactly one input and returns exactly one
output
• No concept of void functions
• No concept of parameterless functions
Unit
• Denoted as ()
• Indicates no specific value
• Can safely be ignored
• Usually indicative of a function that has some effect
Tuples
Tuples for out Parameters
Syntactic Tuples
Records
Discriminated Unions
• Immutable
• Structural Equality
• Resemble enumerations but are more powerful
• Versatile
DUs as Object Hierarchies
DUs as Trees
http://bit.ly/1g76AOv
Mitigating Null
Options
Integrated Units of Measure
Measure Types
Live Demo: Enforcing Units of Measure
Collection Types
• Sequences – seq { … }
• Arrays – [| … |]
• Lists – [ … ]
• Maps
• Sets
Collection Modules
• Provide functions for manipulating collections
• Many LINQ-like operations
• map -> Select
• reduce -> Aggregate
• filter -> Where
F# Lists
• Not List<‘T>
• Immutable
• [ … ]
• List module
• Cons operator ::
• Concatenation operator @
Composing F# Lists With :: and @
Object-Oriented
Classes
Filthy little
hobbitses.
They stole it
from us!
Classes
Interfaces
Implementing Interfaces
Inheritance & Virtual Members
Object Expressions
Functional
Functional programming is programming without
assignment statements.
Bob Martin, FP Basics, Episode 1 (http://bit.ly/1nnhDnm)
Functional Purity
• F# is impure
• Mutability and side-effects are
allowed
Functions as Data
• Higher-order functions
• Let-bound functions
• Lambda expressions
Currying
• Named for Haskell Curry
• Arguments are applied individually
• Changes function organization
Curried Addition & Expanded Form
Partial Application
Pipelining
Function Composition
Recursion
• Preferred looping mechanism
• Compiler optimizes for tail calls
Pattern Matching
Basic Pattern Matching
Built-in patterns
• Null
• Variable & Wildcard
• Literal
• Tuple
• Record
• Identifier
• Array
• List
• Cons
• As
• And
• Or
Decomposing Tuples
Decomposing DUs
Active Patterns
• Custom patterns
• Special type of function called an Active Recognizer
• Curried
• Maximum number of cases is 7
• Each input must map to a named case
Partial Active Patterns
• Single custom case
• Not restricted to 7 active patterns
• Return value is option
Live Demo: Partial Active Patterns
Data Access
Language Features
• Query Expressions
• Type Providers
Live Demo: Using the OData Type Provider
Async & Parallel Programming
Asynchronous Workflows
• Conceptually similar to async/await in C#
• Works using lightweight callbacks and continuations
Agent-based programming
• Borrowed from Erlang
• In-memory queuing mechanism
• Uses MailboxProcessor<‘T> for message passing
• Implementation often includes asynchronous workflows for
monitoring
Live Demo: Agent-based Calculator
Computation Expressions
Extending the Language
• Basis for several language features
• Based on a builder class
• Builder class methods map to familiar language elements
Live Demo: Custom Computation Expression
In Summary
• F# is a powerful, multi-paradigm language
• Plays nicely with other CLR languages
• Offers numerous constructs to keep you focused on the problem
rather than the plumbing
• Simple code for complex problems
No matter what language you work in, programming
in a functional style provides benefits. You should do it
whenever it is convenient, and you should think hard
about the decision when it isn’t convenient.
John Carmack, Functional Programming in C++
The More You Know
• The Book of F#
http://bit.ly/1hzHV6v
• F# Software Foundation
http://fsharp.org
• Try F#
http://tryfsharp.org
• F# Language Reference
http://bit.ly/1koEoqK

More Related Content

What's hot

Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slidesluqman bawany
 
Getting started with scala cats
Getting started with scala catsGetting started with scala cats
Getting started with scala catsKnoldus Inc.
 
Programming in python w6
Programming in python w6Programming in python w6
Programming in python w6Priya Nayak
 
Ruby introductions
Ruby introductionsRuby introductions
Ruby introductionsBinh Bui
 
Code reviews
Code reviewsCode reviews
Code reviewsRoger Xia
 
Part 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to ListsPart 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to ListsShivam Mitra
 
Clojure's take on concurrency
Clojure's take on concurrencyClojure's take on concurrency
Clojure's take on concurrencyyoavrubin
 
Advanced debugging
Advanced debuggingAdvanced debugging
Advanced debuggingAli Akhtar
 
Introduction to Functional Programming and Clojure
Introduction to Functional Programming and ClojureIntroduction to Functional Programming and Clojure
Introduction to Functional Programming and ClojureSoumendra Daas
 
0x3E9 Ways To DIE
0x3E9 Ways To DIE0x3E9 Ways To DIE
0x3E9 Ways To DIEynvb
 
Functional OOP, Clojure style
Functional OOP, Clojure styleFunctional OOP, Clojure style
Functional OOP, Clojure styleyoavrubin
 
Python introduction
Python introductionPython introduction
Python introductionRoger Xia
 

What's hot (19)

Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
 
Getting started with scala cats
Getting started with scala catsGetting started with scala cats
Getting started with scala cats
 
Introduction to Python Programming
Introduction to Python Programming Introduction to Python Programming
Introduction to Python Programming
 
Flow control in Python
Flow control in PythonFlow control in Python
Flow control in Python
 
Programming in python w6
Programming in python w6Programming in python w6
Programming in python w6
 
C Sharp Course 101.5
C Sharp Course 101.5C Sharp Course 101.5
C Sharp Course 101.5
 
C#
C#C#
C#
 
C#
C#C#
C#
 
C#
C#C#
C#
 
Ruby introductions
Ruby introductionsRuby introductions
Ruby introductions
 
Chapter one
Chapter oneChapter one
Chapter one
 
Code reviews
Code reviewsCode reviews
Code reviews
 
Part 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to ListsPart 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to Lists
 
Clojure's take on concurrency
Clojure's take on concurrencyClojure's take on concurrency
Clojure's take on concurrency
 
Advanced debugging
Advanced debuggingAdvanced debugging
Advanced debugging
 
Introduction to Functional Programming and Clojure
Introduction to Functional Programming and ClojureIntroduction to Functional Programming and Clojure
Introduction to Functional Programming and Clojure
 
0x3E9 Ways To DIE
0x3E9 Ways To DIE0x3E9 Ways To DIE
0x3E9 Ways To DIE
 
Functional OOP, Clojure style
Functional OOP, Clojure styleFunctional OOP, Clojure style
Functional OOP, Clojure style
 
Python introduction
Python introductionPython introduction
Python introduction
 

Similar to Break Free with F# - An Introduction to Managed Functional Programming

Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Skills Matter
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript FundamentalsSunny Sharma
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understandingmametter
 
Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional ProgrammingDave Fancher
 
F# for startups
F# for startupsF# for startups
F# for startupsjoelgrus
 
.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#NguynSang29
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionAhmed Raza
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideNascenia IT
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentationBhavin Gandhi
 
Developing mobile apps with f sharp
Developing mobile apps with f sharpDeveloping mobile apps with f sharp
Developing mobile apps with f sharpGustavo Guerra
 
10 Sets of Best Practices for Java 8
10 Sets of Best Practices for Java 810 Sets of Best Practices for Java 8
10 Sets of Best Practices for Java 8Garth Gilmour
 
JSR 335 / java 8 - update reference
JSR 335 / java 8 - update referenceJSR 335 / java 8 - update reference
JSR 335 / java 8 - update referencesandeepji_choudhary
 

Similar to Break Free with F# - An Introduction to Managed Functional Programming (20)

2018 12-kube con-ballerinacon
2018 12-kube con-ballerinacon2018 12-kube con-ballerinacon
2018 12-kube con-ballerinacon
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understanding
 
Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional Programming
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
F# for startups
F# for startupsF# for startups
F# for startups
 
.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
Developing mobile apps with f sharp
Developing mobile apps with f sharpDeveloping mobile apps with f sharp
Developing mobile apps with f sharp
 
Python Basics.pptx
Python Basics.pptxPython Basics.pptx
Python Basics.pptx
 
Python1
Python1Python1
Python1
 
10 Sets of Best Practices for Java 8
10 Sets of Best Practices for Java 810 Sets of Best Practices for Java 8
10 Sets of Best Practices for Java 8
 
C# language
C# languageC# language
C# language
 
JSR 335 / java 8 - update reference
JSR 335 / java 8 - update referenceJSR 335 / java 8 - update reference
JSR 335 / java 8 - update reference
 
Unit ii
Unit   iiUnit   ii
Unit ii
 

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Break Free with F# - An Introduction to Managed Functional Programming

Editor's Notes

  1. Developing software for > 10 years Mostly C#/.NET Before that, some Visual Basic, and classic ASP But most important for tonight…
  2. People often ask: Why F#? Why not Haskell, Scala, or Erlang? Question presupposes intent; I didn’t set out to learn a functional language. I outgrew C# and F# matched the way I think..
  3. Query Syntax: Syntactic sugar Compiles to method syntax Added after early adopters reported being confused Method Syntax: Matched the way I think Functional Principles: Purity Referential transparency Higher-order functions
  4. If you’re treating JS as an OO language, you’re doing it wrong JS objects are glorified dictionaries (hashes)
  5. Verbose Generic delegates are verbose & hard to read Repetition: How many times does the compiler need to be told what type something is? Fragile: Reference types can change at any time Side-effects are common Ceremony: Curly braces Parenthesis Explicit returns (training wheels)
  6. Mowing the lawn Hanselminutes #311 Philip Trelford & Richard Minerich F#, a functional language for the CLR
  7. Statement doesn’t tell the whole story
  8. CLR Language: First-class citizen of VS since 2010 Compiles to CIL Strongly-typed Offers cross-language compatibility Realizing the early promise of .NET Often used in mixed language solutions Don Syme – helped develop .NET generics
  9. The live demos are Windows-centric but you can use other platforms Apache 2.0 F# Software Foundation Every major platform
  10. Climbed 25 spots since May 2013
  11. Fizzled out around June 2012 then began its ascent in March 2013
  12. Often lead to better code Often results in less code Generally easier to reason about code Let you stay focused on the problem Enforces many Clean Code guidelines Evolution of SOLID (ref: Mark Seeman’s blog @ ploeh.dk)
  13. Like CShell More interactive than LINQPad
  14. Note: No NuGet Support Example: let add x y = x + y add 5 10;;
  15. Terse Syntax Top-down Constructs Expression-based
  16. Namespaces Same as other languages Logical grouping of code to avoid naming conflicts Modules Static classes Contain only values or functions Let-bound functions cannot be overloaded Can be opened (imported) like namespaces AutoOpenAttribute makes module members visible by opening the module with the namespace is opened
  17. Don’t work with closures C#’s variables work only through compiler magic
  18. Alternative to mutable let bindings Concrete type wraps a mutable value Necessary for mutating within closures (C# does some compiler tricks to hide this) Also allow passing values by reference
  19. Using function returns a value!
  20. Reduces complexity since there’s only one type of function rather than 9 generic overloads of Func and Action
  21. Same underlying types as in C# Tuple<‘T>, and remaining incompatible overloads Easier Native syntax – if you see a comma, it’s a tuple
  22. Light-weight classes Immutable by default CLIMutable for standard .NET serialization Structural equality Visual Studio Demo
  23. Immutable dictionary Good for unchanging data No syntactic shortcuts Map module
  24. Looping while loops Simple For loops Enumerable For loops Branching if expressions if..elif expressions These are expressions if must yield unit if..elif blocks must return both the same type
  25. Overlooked: Sometimes necessary for language interop Sometimes it’s the right tool for the job Power: Can create rich models with classes, structs, and interfaces Polymorphism, inheritance, and encapsulation No concept of protected in F# code but protected members from other languages are still honored Object Expressions: Inline type definitions
  26. Ask about C# 6 features Primary constructors Auto-properties with initializers
  27. Concrete Abstract No static classes static members are allowed use modules or simulate by making members static and sealing Constructors Primary constructors simplify instantiation (C# stole it from us Additional constructors allow chaining No auto-generated default constructor Implicit field definitions Primary constructor parameters become private fields
  28. Virtual members in F# more closely represent how they’re implemented in the CLR. Abstract defines the slot in the virtual method lookup table and default provides the implementation.
  29. Think of as lambda expressions for types Inline implementations of interfaces or base classes Useful as fake objects in unit testing or other places where formal types are overkill
  30. Purity: F# is impure Mutability is allowed Functions can have side-effects Care should be taken to isolate side-effects
  31. Enabled by currying Applying the first n arguments results in a new function Used frequently in pipelined operations
  32. Lets data flow through operations Reverses the argument and function Single-use
  33. Like pipelining but creates a new function Reusable
  34. Each of these are the basis for bindings; bindings use these
  35. Discuss function syntax
  36. Query Expressions LINQ for F# Nullable operators Type Providers Built-in Providers SQL Server Entity Framework OData WSDL Some Third Party Providers App Settings Excel File System Regex XAML