F# ON THE DESKTOP
Phillip Trelford
Birmingham FP Meetup,
2015
F#UNCTIONAL LONDONERS
Founded Feb 2010
990+ Members
Meets every 2 weeks
Topics include
Machine Learning
Finance
Games
Web
http://meetup.com/fsharplondon
GAMESYS
..our social slots games which by now serve
over 700,000 unique playersand 150,000,000
requests per day at peaks of several thousand
requests per second.
The F# solution offers us an order of magnitude
increase in productivity....
LONDON ASSET MANAGEMENT
COMPANY
We have set up a complete risk
management system that combines
several data sources, presents them in a
… WPF user interface, and does a LOT of
calculation behind the scenes.
When the calculation requires a proper
algorithm (i.e. anything that is more
complex than a simple for loop), our
choice has been F#.
UI LIBRARIES
Native
XAML (WPF, Windows Store)
WinForms
DirectX (MonoGame, SharpDX,
etc.)
Excel (ExcelDNA, FCell)
Browser
ASP.Net MVC
Suave
NancyFX
WebSharper/FunScript (F# to JS)
.. or host your Web app as a Native app via
Node.js…
ANATOMY OF A DESKTOP APP
Data extraction
Database / Web services
Configuration files
Data manipulation
Domain models
Business rules
Visualization
Forms/Grids
Charts
TYPE PROVIDERS: JSON
open FSharp.Data
type Person = JsonProvider<""" { "name":"Name", "age":64 } """>
let thomas = Person.Parse(""" { "name":"Thomas", "age":12 } """)
person.Age
GRIDS, FORMS & BUTTONS
Phillip Trelford
Birmingham FP Meetup,
2015
WINFORMS
open System.IO
open System.Windows.Forms
[<System.STAThread>]
do let form = new Form()
let grid = new DataGridView()
grid.Dock <- DockStyle.Fill
form.Controls.Add(grid)
form.Load.Add(fun _ ->
let files = Directory.GetFiles(".")
grid.DataSource <- [|for file in files -> FileInfo(file)|]
)
Application.Run(form)
CELLZ: UNITS IN CELLS
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of
formula * arithmetic * formula
| LogicalOp of
formula * logical * formula
| Num of UnitValue
| Ref of int * int
| Range of int * int * int * int
| Fun of string * formula list
F# KOANS
//---------------------------------------------------------------
// About Let
//
// The let keyword is one of the most fundamental parts of F#.
// You'll use it in almost every line of F# code you write, so
// let's get to know it well! (no pun intended)
//---------------------------------------------------------------
[<Koan(Sort = 2)>]
module ``about let`` =
[<Koan>]
let LetBindsANameToAValue() =
let x = 50
AssertEquality x __