SlideShare a Scribd company logo
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

More Related Content

PPTX
A Brief History of OWIN
PDF
Your First Scala Web Application using Play 2.1
PPTX
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
PDF
Installing and Getting Started with Alfresco
PPTX
Building Apis in Scala with Playframework2
PPT
Learn REST API with Python
PPTX
Introduction to Laravel
PDF
Laravel 5 Annotations: RESTful API routing
A Brief History of OWIN
Your First Scala Web Application using Play 2.1
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
Installing and Getting Started with Alfresco
Building Apis in Scala with Playframework2
Learn REST API with Python
Introduction to Laravel
Laravel 5 Annotations: RESTful API routing

What's hot (20)

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

Similar to F# on the Web (20)

PPTX
The Functional Web
PPTX
Domain Modeling & Full-Stack Web Development F#
PPTX
F# on the Server-Side
PPTX
Declarative authorization in REST services in SharePoint with F# and ServiceS...
PDF
Concurrecny inf sharp
PDF
F# and SignalR for a FastWeb
PPTX
Building Better Web Apps with F#
PDF
.NET Fest 2018. Антон Молдован. One year of using F# in production at SBTech
PPTX
Building Better Web Apps with F#
PDF
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
PPTX
AFNetworking
KEY
Async. and Realtime Geo Applications with Node.js
PDF
Introduction to Node.js
PPTX
F# Server-side programming
PPTX
F# for functional enthusiasts
PPTX
Multi-Process JavaScript Architectures
PPTX
Mobile F#un
PDF
Adopting F# at SBTech
PPTX
iOS App Development with F# and Xamarin
PPTX
TechDaysNL 2015 - F# for C# Developers
The Functional Web
Domain Modeling & Full-Stack Web Development F#
F# on the Server-Side
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Concurrecny inf sharp
F# and SignalR for a FastWeb
Building Better Web Apps with F#
.NET Fest 2018. Антон Молдован. One year of using F# in production at SBTech
Building Better Web Apps with F#
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
AFNetworking
Async. and Realtime Geo Applications with Node.js
Introduction to Node.js
F# Server-side programming
F# for functional enthusiasts
Multi-Process JavaScript Architectures
Mobile F#un
Adopting F# at SBTech
iOS App Development with F# and Xamarin
TechDaysNL 2015 - F# for C# Developers
Ad

More from Ryan Riley (7)

PPTX
Test first
PPTX
Introduction to F#x
PPTX
Rx workshop
PPTX
Functional Programming
PPTX
Practical F#
PPTX
HTTP: the Other ESB
PPTX
Domain Driven Design
Test first
Introduction to F#x
Rx workshop
Functional Programming
Practical F#
HTTP: the Other ESB
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

Editor's Notes

  • #5: 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.
  • #7: 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.
  • #9: 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.
  • #21: Demo!
  • #23: 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.