Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member GetSlice : startIndex:int option * endIndex:int option -> 'T list
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
val async : AsyncBuilder

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.async
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<_>
static member Async.Sleep : millisecondsDueTime:int -> Async<unit>

FUNCTIONALIST
programming language design





Tomas Petricek, University of Kent + fsharpWorks
@tomaspetricek | tomasp.net | fsharpworks.com

F# & FP contributor

Theory of coeffects

Type providers

Data science tools

Philosophy of science

FUNCTIONAL

A function from \(A\) to \(B\) is an object \(f\)
such that every \(a\in A\) is uniquely associated with an object \(f(a)\in B\).

A function is the purpose for which
something is designed or exists.

form follows function

TRANSFORMATIONS

Transform a value into a new value
using a series of transformations.

DEMO
Working with data

DEMO
Transforming 3D shapes

The elimination of ornament

The elimination of langauge keywords

1: 
2: 
3: 
4: 
Fun.cylinder
|> Fun.color Colors.yellow
|> Fun.scale (1.0, 3.0, 1.0)
|> Fun.move (0.0, -2.0, 0.0)
1: 
  let (|>) x f = f x

TYPE PROVIDERS

Navigating through and extracting information from a data source.

DEMO
JSON type provider in F#

Design conveys the message of simplicity, using basic geometric forms, simple materials.

1: 
2: 
3: 
4: 
5: 
type W = JsonProvider<"http://...">

let weather = W.GetSample()
for w in weather.List do
  printTemp w.Temp.Day w.Temp.Night

How far can we go
with a given material?

DEMO
Pivot provider in TheGamma

If dot is concrete, then type providers are reinforced concrete.

COMPUTATIONS

Give an alternative meaning
to an ordinary computation.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
let tryGetPageLength url = 
  let wc = WebClient()
  try
    let html = wc.Download(url)
    Some(html.Length)
  with e ->
    None
1: 
2: 
3: 
4: 
5: 
6: 
7: 
let tryGetPageLength url = async {
  let wc = WebClient()
  try
    let! html = wc.AsyncDownload(url)
    return Some(html.Length)
  with e ->
    return None }

DEMO
Asynchronous computations

Use flexible material and
design with material in mind.

Using the right abstraction
should be either easy or impossible.

1: 
2: 
3: 
4: 
5: 
6: 
type AsyncSeq<'T> = 
  Async<AsyncSeqResult<'T>>
  
and AsyncSeqResult<'T> = 
  | Empty
  | Value of 'T * AsyncSeq<'T>

DEMO
Asynchronous sequences

SUMMARY

Modernism is associated with

  • Analytical approach to the function
  • Rational use of new materials
  • Openness to structural innovation
  • The elimination of ornament

Function composition
elimination of ornament

Type providers
structural innovation

Computation expressions
leverage new materials

FUNCTIONAL PROGRAMMING


Function as in purpose

Form follows function



Tomas Petricek, University of Kent + fsharpWorks
@tomaspetricek | tomasp.net | fsharpworks.com

1: 
2: 
3: 
4: 
5: 
6: 
let whatDoesThisMean () = reactive {
  let trumpTweets = getTrumpTweets()
  for t in trumpTweets do
    if t.Text.Contains("great") then
      do! Async.Sleep(1000)
    yield t }