SlideShare une entreprise Scribd logo
1  sur  13
F# CODE QUOTATIONS:
CODE-AS-DATA
JACK PAPPAS, DMITRY MOROZOV
SEPTEMBER 19, 2013
SOURCES
•http://tinyurl.com/fs-code-
quotations
RECAP
• First appeared in Lisp: '(one two three) vs (one two three). Hence the
name.
• Code as Data (meta-programming, Language Oriented Programming)
• Transformation (to the same or other language)
• Explicit construction and evaluation
• Numerous usage examples:
• F# query expressions , LINQ
• Foq/Moq/Unquote - testing frameworks
• Type providers development
• F# to GPU (Jack's work)
• WebSharper, FunScript, M-Brace, etc.
F# QUOTATIONS VS C# EXPRESSION
TREES
• C# doesn't require caller to have explicit quotation
• F# quotations literals support full language (almost) as opposed to C#
expr. trees
• F# ReflectedDefinitionAttribute - ability to quote programming
language entities: methods, classes, modules
• Composition: F# splicing vs C# OOP
• Decomposition: F# active patterns vs Visitor pattern
QUOTATIONS CONSTRUCTION
• Quotation literals
• Example: <@ 1 + 2 @>
• Explicit construction using Quotations.Expr type factory methods
• Example:
• let op_Add = Type.GetType("Microsoft.FSharp.Core.Operators,
FSharp.Core").GetMethod("op_Addition").MakeGenericMethod(typeof<int>,
typeof<int>, typeof<int>)
• Expr.Cast<int>(Expr.Call(op_Add, [Expr.Value 1; Expr.Value 2]))
• Splicing
• let x = <@ 1 @> in <@ %x + 2 @>
TYPE PROVIDERS IMPLEMENTATION
• Quotations is an essential tool for Type Providers development
TYPE PROVIDER 101
1. Create project using “F# Type Provider Template” by Tao Liu
2. Change “Debug” settings “Start” section to open same solution
within another instance of IDE
3. Replace ProvidedTypes-head.* with the latest from
http://fsharp3sample.codeplex.com/
4. Congratulations! You have skeleton of a working type provider
5. Now pick a data source, develop an new Type Provider and become
F# ninja
SQL COMMAND TYPE PROVIDER
• Dapper on sterioids
• Use SQL Data Tools to develop functional data access layer
• FUNCTIONS, VIEWS, TABLES
• CROSS APPLY operator (monadic Bind, C# SelectMany)
GUI INPUT VALIDATION
• INotifyDataErrorInfo - WPF 4.5, SL, WinRT
• IDataErrorInfo - WPF 4.0 or less, WinForms (partially)
• Statically-typed
• Would be verbose without F# language features:
• Active patterns
• Explicit member constraints
• Partial application
DATA BINDING
• Making implicit dependency explicit (no magic strings)
• Leveraging F#/.NET type system
• Leveraging IDE/compiler
type IView<'Events, 'Model> =
inherit IObservable<'Events>
abstract SetBindings : 'Model -> unit
<@ textBox.Text <- model.Name @>
textBox.SetBinding(TextBox.TextProperty, "Name")
DATA BINDING MICRO DSL
• Scrap your boilerplate
• F# provides great tools to build internal DSLs
DERIVED PROPERTIES
• Scrap your boilerplate
• F# pure magic
• ReflectedDefinitionAttribute
• Quotation
• Active patterns (a lot)
• WPF black magic (MultiBinding)
• C# way of doing things
• http://knockoutcs.com/index.html
• IL rewriting (PostSharp) or weaving (http://github.com/Fody/PropertyChanged)
WPF WITH F#?
• F# MVC for WPF
• GitHub project:
http://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series
• Wiki:
http://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series/wiki
• F# great general purpose language
• Go thru the framework code base – it’s great language tutorial
• Hard things easy impossible things possible

Contenu connexe

Tendances

Tendances (19)

Introduction to F# 3.0
Introduction to F# 3.0Introduction to F# 3.0
Introduction to F# 3.0
 
C# language
C# languageC# language
C# language
 
History of F#, and the ML family of languages.
History of F#, and the ML family of languages. History of F#, and the ML family of languages.
History of F#, and the ML family of languages.
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
 
C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?
 
Swift vs. Language X
Swift vs. Language XSwift vs. Language X
Swift vs. Language X
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages
 
Procedure oriented programming
Procedure oriented programmingProcedure oriented programming
Procedure oriented programming
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)
 
Create Your Own Language
Create Your Own LanguageCreate Your Own Language
Create Your Own Language
 
F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
 
LIL Presentation
LIL PresentationLIL Presentation
LIL Presentation
 
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос....NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
.NET Fest 2019. Алексей Голуб. Монадные парсер-комбинаторы в C# (простой спос...
 
Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)
 
C programming language
C programming languageC programming language
C programming language
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C & C++ Training in Ambala ! BATRA COMPUTER CENTRE
C & C++ Training in Ambala ! BATRA COMPUTER CENTREC & C++ Training in Ambala ! BATRA COMPUTER CENTRE
C & C++ Training in Ambala ! BATRA COMPUTER CENTRE
 
C vs c++
C vs c++C vs c++
C vs c++
 

Similaire à Dmitry mozorov on code quotations code as-data for f#

Developing mobile apps with f sharp
Developing mobile apps with f sharpDeveloping mobile apps with f sharp
Developing mobile apps with f sharp
Gustavo Guerra
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
Eelco Visser
 
Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_final
Jerin John
 

Similaire à Dmitry mozorov on code quotations code as-data for f# (20)

Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
 
Php
PhpPhp
Php
 
Domain Modeling & Full-Stack Web Development F#
Domain Modeling & Full-Stack Web Development F#Domain Modeling & Full-Stack Web Development F#
Domain Modeling & Full-Stack Web Development F#
 
phpwebdev.ppt
phpwebdev.pptphpwebdev.ppt
phpwebdev.ppt
 
F# Sample and Resources
F# Sample and ResourcesF# Sample and Resources
F# Sample and Resources
 
Bay NET Aug 19 2009 presentation ppt
Bay  NET Aug 19 2009 presentation pptBay  NET Aug 19 2009 presentation ppt
Bay NET Aug 19 2009 presentation ppt
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
Developing mobile apps with f sharp
Developing mobile apps with f sharpDeveloping mobile apps with f sharp
Developing mobile apps with f sharp
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#
 
Sudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdfSudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdf
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
F# for Trading
F# for TradingF# for Trading
F# for Trading
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
F# for functional enthusiasts
F# for functional enthusiastsF# for functional enthusiasts
F# for functional enthusiasts
 
Shell scripting with f
Shell scripting with fShell scripting with f
Shell scripting with f
 
Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
 
Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_final
 

Plus de Skills Matter

Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
Skills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
Skills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
Skills Matter
 
Bootstrapping a-devops-matter
Bootstrapping a-devops-matterBootstrapping a-devops-matter
Bootstrapping a-devops-matter
Skills Matter
 
Personal kanban-workshop
Personal kanban-workshopPersonal kanban-workshop
Personal kanban-workshop
Skills Matter
 

Plus de Skills Matter (20)

5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 
Huguk lily
Huguk lilyHuguk lily
Huguk lily
 
Bootstrapping a-devops-matter
Bootstrapping a-devops-matterBootstrapping a-devops-matter
Bootstrapping a-devops-matter
 
Personal kanban-workshop
Personal kanban-workshopPersonal kanban-workshop
Personal kanban-workshop
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Dmitry mozorov on code quotations code as-data for f#

  • 1. F# CODE QUOTATIONS: CODE-AS-DATA JACK PAPPAS, DMITRY MOROZOV SEPTEMBER 19, 2013
  • 3. RECAP • First appeared in Lisp: '(one two three) vs (one two three). Hence the name. • Code as Data (meta-programming, Language Oriented Programming) • Transformation (to the same or other language) • Explicit construction and evaluation • Numerous usage examples: • F# query expressions , LINQ • Foq/Moq/Unquote - testing frameworks • Type providers development • F# to GPU (Jack's work) • WebSharper, FunScript, M-Brace, etc.
  • 4. F# QUOTATIONS VS C# EXPRESSION TREES • C# doesn't require caller to have explicit quotation • F# quotations literals support full language (almost) as opposed to C# expr. trees • F# ReflectedDefinitionAttribute - ability to quote programming language entities: methods, classes, modules • Composition: F# splicing vs C# OOP • Decomposition: F# active patterns vs Visitor pattern
  • 5. QUOTATIONS CONSTRUCTION • Quotation literals • Example: <@ 1 + 2 @> • Explicit construction using Quotations.Expr type factory methods • Example: • let op_Add = Type.GetType("Microsoft.FSharp.Core.Operators, FSharp.Core").GetMethod("op_Addition").MakeGenericMethod(typeof<int>, typeof<int>, typeof<int>) • Expr.Cast<int>(Expr.Call(op_Add, [Expr.Value 1; Expr.Value 2])) • Splicing • let x = <@ 1 @> in <@ %x + 2 @>
  • 6. TYPE PROVIDERS IMPLEMENTATION • Quotations is an essential tool for Type Providers development
  • 7. TYPE PROVIDER 101 1. Create project using “F# Type Provider Template” by Tao Liu 2. Change “Debug” settings “Start” section to open same solution within another instance of IDE 3. Replace ProvidedTypes-head.* with the latest from http://fsharp3sample.codeplex.com/ 4. Congratulations! You have skeleton of a working type provider 5. Now pick a data source, develop an new Type Provider and become F# ninja
  • 8. SQL COMMAND TYPE PROVIDER • Dapper on sterioids • Use SQL Data Tools to develop functional data access layer • FUNCTIONS, VIEWS, TABLES • CROSS APPLY operator (monadic Bind, C# SelectMany)
  • 9. GUI INPUT VALIDATION • INotifyDataErrorInfo - WPF 4.5, SL, WinRT • IDataErrorInfo - WPF 4.0 or less, WinForms (partially) • Statically-typed • Would be verbose without F# language features: • Active patterns • Explicit member constraints • Partial application
  • 10. DATA BINDING • Making implicit dependency explicit (no magic strings) • Leveraging F#/.NET type system • Leveraging IDE/compiler type IView<'Events, 'Model> = inherit IObservable<'Events> abstract SetBindings : 'Model -> unit <@ textBox.Text <- model.Name @> textBox.SetBinding(TextBox.TextProperty, "Name")
  • 11. DATA BINDING MICRO DSL • Scrap your boilerplate • F# provides great tools to build internal DSLs
  • 12. DERIVED PROPERTIES • Scrap your boilerplate • F# pure magic • ReflectedDefinitionAttribute • Quotation • Active patterns (a lot) • WPF black magic (MultiBinding) • C# way of doing things • http://knockoutcs.com/index.html • IL rewriting (PostSharp) or weaving (http://github.com/Fody/PropertyChanged)
  • 13. WPF WITH F#? • F# MVC for WPF • GitHub project: http://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series • Wiki: http://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series/wiki • F# great general purpose language • Go thru the framework code base – it’s great language tutorial • Hard things easy impossible things possible