SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Ryan Riley
Tachyus
 Tachyus’ success with F#
 Data Access
 Web APIs
 Handling Exceptions
 Managing Builds
 Questions
F# on the Web
 ASP.NET Web API hosted in Azure
 AngularJS-based SPA providing information to office
workers
 iOS application for workers in oil fields
 Less code
 Get things done faster
 Type safety
 Expressive syntax
 Full .NET compatibility
 Active, strong community (small but growing!)
F# on the Web
 DbmlFile and SqlDataConnection (LINQ to SQL)
 EdmxFile and SqlEntityConnection (Entity Framework)
 SQL Provider
 FSharp.Data.SqlClient <- we use this one
“SQL is the best DSL for working with data”
- Rob Conery, http://www.infoq.com/articles/ORM-Saffron-
Conery
F# on the Web
F# on the Web
HttpRequestMessage -> HttpResponseMessage
Request/Response
 Methods, URIs, Status Codes
Headers (info on client, server, request type, etc)
 General, Request, Response, Content
Resources –
 “anything that has identity”–RFC2396
GET /item/1
+ POST /item/1
+ PUT /item/1
+ DELETE /item/1
+ OPTIONS /item/1
GET (or POST) /
+ /items
+ /item/{itemId}
+ /setresult?foo=bar
HTTP
Resource
HTTP
“Service”
 Serve functional Web APIs
 Consume HTTP with pattern matching
 F# DSL using System.Net.Http
 Headers composition
 Follows the natural composition of HTTP
 Frank Resources == HTTP Resources
 Define your own conventions!
HttpRequestMessage -> HttpResponseMessage
HttpRequestMessage -> Async<HttpResponseMessage>
// handler
let echo request = async {
let! body = request.Content.AsyncReadAsString()
return request.CreateResponse(HttpStatusCode.OK, body)
}
// method handler
get echo
let helloworld request = async { … }
let echo request = async { … }
let resource = route “/” (get helloworld <|> post echo)
let todoListResource = route “/” (get todoList <|> …)
let todoItemResource = route “/item/{1}” (put …)
config |> register [todoListResource;todoItemResource]
 Works out of the box using a F# library and C# web project
 F# MVC 5 project template
 Frank
F# on the Web
 http://www.slideshare.net/ScottWlaschin/railway-oriented-
programming
 http://fsharpforfunandprofit.com/posts/recipe-part2/
“FAKE is a Domain Specific Language that you can use without knowing F#, but if
and when you outgrow it you can keep heading down the F# road. In all cases you've
got all of .NET at your command.”
- Scott Hanselman,
http://www.hanselman.com/blog/ExploringFAKEAnFBuildSystemForAllOfNET.asp
x
 WebSharper and FunScript – F# -> JavaScript compilers
 VegaHub – interactive charting from the F# interactive
window
 F# Web Stack – OWIN-based tools for building web APIs
 Work in progress to merge Frank + HyperF + Dyfrig + Taliesin
 F# Software Foundation
 Community for F#
 Sergey Tihon’s F# Weekly
 F# for Fun and Profit
 Real World Functional Programming on MSDN
F# on the Web

Más contenido relacionado

Was ist angesagt?

Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Ngoc Dao
 
Regex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadRegex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadAll Things Open
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to LaravelEli Wheaton
 
Developing OpenResty Framework
Developing OpenResty FrameworkDeveloping OpenResty Framework
Developing OpenResty FrameworkOpenRestyCon
 
Laravel Webcon 2015
Laravel Webcon 2015Laravel Webcon 2015
Laravel Webcon 2015Tim Bracken
 
Developing high-performance network servers in Lisp
Developing high-performance network servers in LispDeveloping high-performance network servers in Lisp
Developing high-performance network servers in LispVladimir Sedach
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introductionSimon Funk
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...All Things Open
 
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...Etiene Dalcol
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel frameworkPhu Luong Trong
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIPaul Withers
 
Apache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareRobert Munteanu
 
Play framework productivity formula
Play framework   productivity formula Play framework   productivity formula
Play framework productivity formula Sorin Chiprian
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0Ido Flatow
 
Engage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API SlidesEngage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API SlidesPaul Withers
 

Was ist angesagt? (20)

Owin
OwinOwin
Owin
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 
Regex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadRegex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language Instead
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to Laravel
 
Developing OpenResty Framework
Developing OpenResty FrameworkDeveloping OpenResty Framework
Developing OpenResty Framework
 
REST API Laravel
REST API LaravelREST API Laravel
REST API Laravel
 
Laravel Webcon 2015
Laravel Webcon 2015Laravel Webcon 2015
Laravel Webcon 2015
 
Developing high-performance network servers in Lisp
Developing high-performance network servers in LispDeveloping high-performance network servers in Lisp
Developing high-performance network servers in Lisp
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...
 
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel framework
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
Apache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middleware
 
Play framework productivity formula
Play framework   productivity formula Play framework   productivity formula
Play framework productivity formula
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
ASP.NET vNext ANUG 20140817
ASP.NET vNext ANUG 20140817ASP.NET vNext ANUG 20140817
ASP.NET vNext ANUG 20140817
 
Engage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API SlidesEngage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API Slides
 

Ähnlich wie F# on the Web

The Functional Web
The Functional WebThe Functional Web
The Functional WebRyan Riley
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015Nir Noy
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
PHP: The Beginning and the Zend
PHP: The Beginning and the ZendPHP: The Beginning and the Zend
PHP: The Beginning and the Zenddoublecompile
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
Treasure Data and OSS
Treasure Data and OSSTreasure Data and OSS
Treasure Data and OSSN Masahiro
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderSadayuki Furuhashi
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureMarcel Offermans
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application FrameworkSimon Willison
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeRick Copeland
 
The Atmosphere Framework
The Atmosphere FrameworkThe Atmosphere Framework
The Atmosphere Frameworkjfarcand
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleAdobe
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleCarsten Ziegeler
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegelermfrancis
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA PresentationRob Tweed
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuseejlp12
 

Ähnlich wie F# on the Web (20)

The Functional Web
The Functional WebThe Functional Web
The Functional Web
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
03 form-data
03 form-data03 form-data
03 form-data
 
PHP: The Beginning and the Zend
PHP: The Beginning and the ZendPHP: The Beginning and the Zend
PHP: The Beginning and the Zend
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Rack
RackRack
Rack
 
Treasure Data and OSS
Treasure Data and OSSTreasure Data and OSS
Treasure Data and OSS
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loader
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the future
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application Framework
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForge
 
The Atmosphere Framework
The Atmosphere FrameworkThe Atmosphere Framework
The Atmosphere Framework
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 

Mehr von Ryan Riley

Introduction to F#x
Introduction to F#xIntroduction to F#x
Introduction to F#xRyan Riley
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional ProgrammingRyan Riley
 
HTTP: the Other ESB
HTTP: the Other ESBHTTP: the Other ESB
HTTP: the Other ESBRyan Riley
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 

Mehr von Ryan Riley (7)

Test first
Test firstTest first
Test first
 
Introduction to F#x
Introduction to F#xIntroduction to F#x
Introduction to F#x
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Practical F#
Practical F#Practical F#
Practical F#
 
HTTP: the Other ESB
HTTP: the Other ESBHTTP: the Other ESB
HTTP: the Other ESB
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 

F# on the Web

  • 2.  Tachyus’ success with F#  Data Access  Web APIs  Handling Exceptions  Managing Builds  Questions
  • 4.  ASP.NET Web API hosted in Azure  AngularJS-based SPA providing information to office workers  iOS application for workers in oil fields
  • 5.  Less code  Get things done faster  Type safety  Expressive syntax  Full .NET compatibility  Active, strong community (small but growing!)
  • 7.  DbmlFile and SqlDataConnection (LINQ to SQL)  EdmxFile and SqlEntityConnection (Entity Framework)  SQL Provider  FSharp.Data.SqlClient <- we use this one
  • 8. “SQL is the best DSL for working with data” - Rob Conery, http://www.infoq.com/articles/ORM-Saffron- Conery
  • 12. Request/Response  Methods, URIs, Status Codes Headers (info on client, server, request type, etc)  General, Request, Response, Content Resources –  “anything that has identity”–RFC2396
  • 13. GET /item/1 + POST /item/1 + PUT /item/1 + DELETE /item/1 + OPTIONS /item/1 GET (or POST) / + /items + /item/{itemId} + /setresult?foo=bar HTTP Resource HTTP “Service”
  • 14.  Serve functional Web APIs  Consume HTTP with pattern matching
  • 15.  F# DSL using System.Net.Http  Headers composition  Follows the natural composition of HTTP  Frank Resources == HTTP Resources  Define your own conventions!
  • 17. // handler let echo request = async { let! body = request.Content.AsyncReadAsString() return request.CreateResponse(HttpStatusCode.OK, body) } // method handler get echo
  • 18. let helloworld request = async { … } let echo request = async { … } let resource = route “/” (get helloworld <|> post echo)
  • 19. let todoListResource = route “/” (get todoList <|> …) let todoItemResource = route “/item/{1}” (put …) config |> register [todoListResource;todoItemResource]
  • 20.  Works out of the box using a F# library and C# web project  F# MVC 5 project template  Frank
  • 23. “FAKE is a Domain Specific Language that you can use without knowing F#, but if and when you outgrow it you can keep heading down the F# road. In all cases you've got all of .NET at your command.” - Scott Hanselman, http://www.hanselman.com/blog/ExploringFAKEAnFBuildSystemForAllOfNET.asp x
  • 24.  WebSharper and FunScript – F# -> JavaScript compilers  VegaHub – interactive charting from the F# interactive window  F# Web Stack – OWIN-based tools for building web APIs  Work in progress to merge Frank + HyperF + Dyfrig + Taliesin
  • 25.  F# Software Foundation  Community for F#  Sergey Tihon’s F# Weekly  F# for Fun and Profit  Real World Functional Programming on MSDN

Hinweis der Redaktion

  1. Our back end is all F# using Web API and running in Azure. Our two client applications started in languages native to their target platforms. The iOS team has almost completed a successful conversion to F# using Xamarin. We are currently evaluating options to do the same with F# to generate JavaScript and HTML, which should also provide some additional opportunities for code sharing.
  2. I know this is called F# on the web, but really, you want to expose some data, right? Also, F# is very strong at modeling data flows, so it only makes sense to start at the data layer.
  3. Spaghetti code? Not this! It’s fully type-checked! And it generates the types for you, with the same runtime performance as Dapper and other micro ORMs.
  4. Demo!
  5. Exceptions can be a real pain in the neck. Exceptions tend to bubble back up, requiring you to break all the nice forward-only flows we’ve been writing to this point. Railway-oriented (or data flow) programming can help resolve the issue and retain the nice flows we are using. The Async module includes a Catch function that will allow us to partition the changes coming out and handle successes and failures as we progress.