type WebServer = obj -> obj Full name: index.WebServer
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 -> Async<unit> 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<_>
type 'T option = Option<'T> Full name: Microsoft.FSharp.Core.option<_>
Multiple items type Startup = new : env:obj -> Startup member Configure : app:'a * env:'b * loggerFactory:'c -> unit Full name: index.Startup -------------------- new : env:obj -> Startup
val env : obj
val this : Startup
member Startup.Configure : app:'a * env:'b * loggerFactory:'c -> unit Full name: index.Startup.Configure
val app : 'a
val env : 'b
val loggerFactory : 'c
val ignore : value:'T -> unit Full name: Microsoft.FSharp.Core.Operators.ignore
Sponsors slide (required by organizators)
Web Development With F#
Grigoriy Belenkiy
Software engineer, S&P Global
@grishace
//denver/dev/day
October 28, 2016
Agenda
F#
ASP.NET WebAPI/MVC
Suave
WebSharper
Freya - similar ideas to Suave - function composition, but could not build the HelloWorld example
Fable - promising, but hard to implement even such simple example as FB
Why F#?
Functional
Object-oriented
Functional
1:
type WebServer = HttpRequest -> Async < HttpResponse option >
SOLID and all design patterns replaced with function composition
example - the essence of a web-server
Object-oriented
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
type Startup (env : IHostingEnvironment )=
// This method gets called by the runtime. Use this method to configure
// the HTTP request pipeline.
member this . Configure (app : IApplicationBuilder , env : IHostingEnvironment ,
loggerFactory : ILoggerFactory ) =
loggerFactory
. AddConsole (configuration . GetSection ("Logging" ))
. AddDebug ()
|> ignore
app . UseMvc () |> ignore
.NET language - need to coexist and interop with other languages
Can use all (almost?) libraries/packages created for C#
example - from generated ASP.NET Core MVC application
F#zzBuzz
https://en.wikipedia.org/wiki/Fizz_buzz#Programming_interviews
ASP.NET Core WebAPI/MVC
ASP.NET Core is a new open-source and cross-platform framework
for building modern cloud based internet connected applications,
such as web apps, IoT apps and mobile backends.
https://www.asp.net/core
https://dribbble.com/shots/3005811-Core-Sticker
by Pablo Iglesias
Suave
Suave is a simple web development F# library providing a
lightweight web server and a set of combinators to manipulate
route flow and task composition.
https://suave.io
WebSharper
WebSharper is a framework and toolset for developing
web/mobile applications and web services entirely in
C# or F# (of a mix of the two languages) with strongly-typed
client-server communication and site navigation.
http://websharper.com
Books
Building Web, Cloud, and Mobile Solutions with F#
by Daniel Mohl
Expert F# 4.0
by Don Syme, Adam Granicz, Antonio Cisternino
F# Applied
by Tamizhvendan S