Top Banner
End-to-end functional web development Tomas Petricek, fsharpWorks | | @tomaspetricek tomasp.net fsharpworks.com
17

End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Jun 24, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

End-to-end functional web development

Tomas Petricek, fsharpWorks | | @tomaspetricek tomasp.net fsharpworks.com

Page 2: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

The web is functional!

Request ‐> Response 

Page 3: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

The web is asynchronous!

Request ‐> Async<Response> 

Page 4: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

DEMOHello world and type providers

Page 5: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Demo summary

Lightweight and asynchronous

Great with type providers

Build and package infrastructure

Page 6: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Package management with PaketSpecify dependencies in paket.dependencies

1: 2: source https://nuget.org/api/v2 nuget Suave

Locked version numbers in paket.lock

1: 2: 3: 4: 5: 6: 7: 8:

NUGET remote: https://nuget.org/api/v2 specs: FSharp.Core (3.1.2.1) FsPickler (1.2.1) Suave (0.28.1) FSharp.Core (>= 3.1.2.1) FsPickler (>= 1.0.7)

Page 7: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Building and live reloading scriptFAKE for building and F# Compiler Service for reloading

1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:

let reloadAppServer () = currentApp.Value <- reloadScript()

Target "run" (fun _ -> let app ctx = currentApp.Value ctx let _, server = startWebServerAsync serverConfig app Async.Start(server)

use watcher = !! (__SOURCE_DIRECTORY__ @@ "*.*") |> WatchChanges (fun _ -> reloadAppServer()) Console.ReadLine() )

Page 8: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

DEMOBuilding chat app with agents

Page 9: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Demo summary

Composable library for REST APIs

Works with agent-based architecture

Scale with Akka.net, Cricket and M-Brace

Page 10: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Routing and handling headersUsing F# power for domain-specific languages

1: 2: 3: 4: 5:

choose [ path "/" >>= setMimeType "text/html" >>= index path "/chat" >>= GET >>= noCache >>= getMessages path "/post" >>= POST >>= noCache >>= postMessage NOT_FOUND "Found no handlers" ]

Page 11: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

DEMODeploying chat app to Azure and Heroku

Page 13: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

DEMOTesting chat app with FsCheck

Page 14: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Demo summary

Nice unit testing with simple syntax

Powerful random testing with FsCheck

Integrated with FAKE and CI servers

Page 15: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Summary

Page 16: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Functional web development

Request to response function

F# but also Elixir, Clojure and more..

Page 17: End-to-end functional web development€¦ · Functional web development Request to response function F# but also Elixir, Clojure and more.. Web dev with Suave and F# ...

Web dev with Suave and F#

www.fsharp.org

www.fsharpconf.com

www.suave.io

See for books & trainings! | |

functional-programming.net@tomaspetricek tomasp.net fsharpworks.com