val reloadAppServer : unit -> 'a
Full name: index.reloadAppServer
Multiple items
type Async
static member AsBeginEnd : computation:('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit)
static member AwaitEvent : event:IEvent<'Del,'T> * ?cancelAction:(unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate)
static member AwaitIAsyncResult : iar:IAsyncResult * ?millisecondsTimeout:int -> Async<bool>
static member AwaitTask : task:Task<'T> -> Async<'T>
static member AwaitWaitHandle : waitHandle:WaitHandle * ?millisecondsTimeout:int -> Async<bool>
static member CancelDefaultToken : unit -> unit
static member Catch : computation:Async<'T> -> Async<Choice<'T,exn>>
static member FromBeginEnd : beginAction:(AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg:'Arg1 * beginAction:('Arg1 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * beginAction:('Arg1 * 'Arg2 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * arg3:'Arg3 * beginAction:('Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromContinuations : callback:(('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T>
static member Ignore : computation:Async<'T> -> Async<unit>
static member OnCancel : interruption:(unit -> unit) -> Async<IDisposable>
static member Parallel : computations:seq<Async<'T>> -> Async<'T []>
static member RunSynchronously : computation:Async<'T> * ?timeout:int * ?cancellationToken:CancellationToken -> 'T
static member Sleep : millisecondsDueTime:int -> Async<unit>
static member Start : computation:Async<unit> * ?cancellationToken:CancellationToken -> unit
static member StartAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions * ?cancellationToken:CancellationToken -> Task<'T>
static member StartChild : computation:Async<'T> * ?millisecondsTimeout:int -> Async<Async<'T>>
static member StartChildAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions -> Async<Task<'T>>
static member StartImmediate : computation:Async<unit> * ?cancellationToken:CancellationToken -> unit
static member StartWithContinuations : computation:Async<'T> * continuation:('T -> unit) * exceptionContinuation:(exn -> unit) * cancellationContinuation:(OperationCanceledException -> unit) * ?cancellationToken:CancellationToken -> unit
static member SwitchToContext : syncContext:SynchronizationContext -> Async<unit>
static member SwitchToNewThread : unit -> Async<unit>
static member SwitchToThreadPool : unit -> Async<unit>
static member TryCancelled : computation:Async<'T> * compensation:(OperationCanceledException -> unit) -> Async<'T>
static member CancellationToken : Async<CancellationToken>
static member DefaultCancellationToken : CancellationToken
Full name: Microsoft.FSharp.Control.Async
--------------------
type Async<'T>
Full name: Microsoft.FSharp.Control.Async<_>
static member Async.Start : computation:Async<unit> * ?cancellationToken:System.Threading.CancellationToken -> unit
The web is functional!
Request -> Response
The web is asynchronous!
Request -> Async<Response>
DEMO
Hello world and type providers
|
|
Demo summary
- Lightweight and asynchronous
- Great with type providers
- Build and package infrastructure
Package management with Paket
Specify 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)
|
Building and live reloading script
FAKE 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()
)
|
DEMO
Building chat app with agents
|
|
Demo summary
- Composable library for REST APIs
- Works with agent-based architecture
- Scale with Akka.net, Cricket and M-Brace
Routing and handling headers
Using 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" ]
|
DEMO
Testing chat app with FsCheck
|
|
Demo summary
- Nice unit testing with simple syntax
- Powerful random testing with FsCheck
- Integrated with FAKE and CI servers
DEMO
Deploying chat app to Azure and Heroku
|
|
Summary
Many more interesting F# web stacks!
- Suave for lightweight web development
- Freya hosting on IIS & elsewhere using OWIN
- WebSharper integrates client and server-side
- But also: ASP.NET MVC, Nancy & ServiceStack