Keith Harrison
Why Hymans Use F#
Risk ModellingActuarial Consultancy
Pragmatic
public class Multiplier {
public int Factor;
public int Calculate(int value) {
return value * Factor;
}
}
var tenMultiplier = new Multiplier { Factor = 10 };
var result = tenMultiplier.Calculate(2);
let createMultiplier (factor) =
fun x -> x * factor
let multiplyByTen = createMultiplier(10)
let result = multiplyByTen(2)
let filter people =
let results = new List<Person>()
for person in people do
if person.Age > 30 then
results.Add(person)
results
let filter people age =
let results = new List<Person>()
for person in people do
if person.Age > age then
results.Add(person)
results
let filter people =
let results = new List<Person>()
for person in people do
if person.Sex = Sex.Male then
results.Add(person)
results
let filter filterFunction people =
let results = new List<Person>()
for person in people do
if filterFunction() then
results.Add(person)
results
let filter filterFunction people =
let results = new List<Person>()
for person in people do
if filterFunction() then
results.Add(person)
results
filter (fun p -> p.Age > 30) personList
filter (fun p -> p.Age > 40) personList
filter (fun p -> p.Sex = Sex.Male) personList
let isOver30 p = p.Age > 30
let isOver40 p = p.Age > 40
let isMale p = p.Sex = Sex.Male
filter isOver30 personList
filter isOver40 personList
filter isMale personList
filter isOver30 personList
personList |> filter isOver30
personList |> filter isOver30
|> filter isMale
Pragmatic
F#
Functional Imperative
Object
Oriented
Books
We’re Hiring
• www.hymans.co.uk/contact-us.aspx
• http://careers.stackoverflow.com/uk/company/hymans-robertson
• keith.Harrison@hymans.co.uk
• @KeithDHar
• http://www.linkedin.com/in/keithdharrison
Questions?

Why Hymans Use F#

Editor's Notes

  • #2 I’m keithharrisonI’m a .Net Developer at Hymans RobertsonHere to talk about why Hymans use F#
  • #3 Start with a bit of back groundWho are Hymans?Actuarial Consultancy FirmModel risk using complex mathematical modelsFor example in a pension scheme calculate how much money you need today to pay each member till the last one dies. Mortality, pay rises, how long each member stay with the company
  • #4 Problem?Port legacy excel application to .NetInteroperation with other systemsUnit Testing
  • #5 What problem does F# solve with F#?Familiar to someone with a maths backgroundLeverage maths skills
  • #6 Compose maths formulas to solve different problemsCalculation such as mortality, discounting cashflows are used to solve lots of different problems.
  • #8 How is F# familiar to people with a strong maths background?
  • #9 C# code.You need to understand, classes, access modifiers, scope, constructors, object initialisers
  • #10 Same solution in F#Explain F# syntax‘let’ names a value or a functionStrongly typed, Types are inferredClosure
  • #11 Explaincomposibility
  • #12 What if we wanted to filter people over 40?
  • #13 Add age variableWhat if we wanted to filter Men?
  • #14 Same as previous functions except if statement
  • #15 Same as previous functions except if statement
  • #21 Multi - paradigm
  • #23 ConclusionPorted legacy system to F#Quickly train up actuaries to expand the teamReuse the math functionsPragmatic convert imperative to F# -&gt; function and use power of .Net framework