Functional webapplicaations using fsharp and suave

34
Functional Web Applications using F# and Suave @TomasJansson

Transcript of Functional webapplicaations using fsharp and suave

Page 1: Functional webapplicaations using fsharp and suave

FunctionalWeb Applicationsusing

F# and Suave

@TomasJansson

Page 2: Functional webapplicaations using fsharp and suave

BEKKDeveloperPractice lead .NET

OsloFSharp/NNUGMicrosoft MVPF# enthusiast

Page 3: Functional webapplicaations using fsharp and suave

F#?

Page 4: Functional webapplicaations using fsharp and suave

Flickr: Supportive / Scott Robinson/ Creative Commons

Solid foundation

Page 5: Functional webapplicaations using fsharp and suave

Flickr: Lego Bricks/ Benjamin Esham / Creative Commons

Composability

Page 7: Functional webapplicaations using fsharp and suave

Feedback

Page 8: Functional webapplicaations using fsharp and suave

Why F# and Web?

Page 9: Functional webapplicaations using fsharp and suave

All applications are functions,also web applications

Page 10: Functional webapplicaations using fsharp and suave

Server

Request

Response

Page 11: Functional webapplicaations using fsharp and suave

ServerRequest Response

Page 12: Functional webapplicaations using fsharp and suave

FunctionInput Output

Page 13: Functional webapplicaations using fsharp and suave

?

Page 14: Functional webapplicaations using fsharp and suave

Suave is a lightweight, non-blocking web server. The non-blocking I/O model is efficient and suitable for building fast, scalable network applications. In fact, Suave is written in a completely non-blocking fashion throughout. Suave runs on Linux, OS X and Windows flawlessly.

https://suave.io/

Page 15: Functional webapplicaations using fsharp and suave

HttpContextWebPartCombinators

Page 16: Functional webapplicaations using fsharp and suave

HttpContext

Page 17: Functional webapplicaations using fsharp and suave

WebPart

Page 18: Functional webapplicaations using fsharp and suave

WebPart

Page 19: Functional webapplicaations using fsharp and suave

Combinators

Page 20: Functional webapplicaations using fsharp and suave

Combinators… that create a WebPart from more primitive values

… that combine multiple WebParts to a single WebPart

Page 21: Functional webapplicaations using fsharp and suave

Model (simplified)

fun funfun

1. Start with some functions or values

Page 22: Functional webapplicaations using fsharp and suave

WebPartWebPartWebPart

Model (simplified)

fun funfun

1. Start with some functions or values2. Apply one or more combinator to each function or value to create some WebParts

Page 23: Functional webapplicaations using fsharp and suave

WebPart

Model (simplified)1. Start with some functions or values2. Apply one or more combinator to each function or value to create some WebParts3. Apply a combinator to the WebParts to create a single WebPart (repeat if needed)

WebPartWebPartWebPart

fun funfun

Page 24: Functional webapplicaations using fsharp and suave

Demo

Page 25: Functional webapplicaations using fsharp and suave

Demo

http://fsharp.github.io/FAKE/ http://fsprojects.github.io/Paket/

Paket FAKE

Page 26: Functional webapplicaations using fsharp and suave

Summary

Page 27: Functional webapplicaations using fsharp and suave

F# is awesome

Page 28: Functional webapplicaations using fsharp and suave

F# is awesomeThe web is functional

Page 29: Functional webapplicaations using fsharp and suave

F# is awesomeThe web is functionalProgram the web using Suave

Page 30: Functional webapplicaations using fsharp and suave

Resourceshttps://suave.io/

https://github.com/SuaveIO/suave

https://www.gitbook.com/book/theimowski/suave-music-store/

https://github.com/mastoj/my-share

Page 31: Functional webapplicaations using fsharp and suave
Page 32: Functional webapplicaations using fsharp and suave

FP Lab HourRoom 10 at

13:40

Page 33: Functional webapplicaations using fsharp and suave

?

Page 34: Functional webapplicaations using fsharp and suave

@TomasJanssongithub.com/mastojslideshare.net/mastoj