Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The F# Path to Relaxation

105 views

Published on

The F# Path to Relaxation by Don Syme

Born in a lab, matured in the enterprise, and now fully baked as an open-source, cross-platform, professionally-supported language: the F# journey has always been about reconciling the apparently irreconcilable. Javascript and .NET, Linux and Windows, Functional and Objects, Company and Openness, Android and iOS, Programming and Data, Server and Client - F# finds a way. Come along and take a journey with me through the modern programming landscape and the F# approach to language design, interoperability, tooling and community.



Published in: Technology
  • Be the first to comment

  • Be the first to like this

The F# Path to Relaxation

  1. 1. | Basel The F# Path to Relaxation Language Design, Platforms, Community, Openness Don Syme, F# Community Contributor, MSR Principal Researcher in Mobile Tools
  2. 2. X Y
  3. 3. Functional Interop
  4. 4. ✔ ✔ ✔ ✖ Functional Interop
  5. 5. X Y
  6. 6. Enterprise Openness
  7. 7. F# is open, cross- platform, neutral, independent All F# language and tooling is accepting contributions The F# community is very “self-empowered” fsharp.org Xamarin provide F# tools Android and iOS The Visual F# Tools are Microsoft’s professional tools for Windows and Azure Debian, RPM and .NET Core for Linux/OSX The F# Compiler Service powers many other tools Fable for F#-to- Javascript SAFE for F# fullstack F# 4.1 now complete!
  8. 8. fsharp.github.io
  9. 9. github.com/fsharp/fslang-design github.com/fsharp/fslang-suggestions
  10. 10. ✔ ✔ ✔ ✔ ✔ ✔ https://github.com/fsharp/fslang-design/tree/master/FSharp-4.0
  11. 11. ✔ ✔ ✔ ✔ ✔ ✔ https://github.com/fsharp/fslang-design/tree/master/FSharp-4.1
  12. 12. docs.microsoft.com/en-us/dotnet/core/
  13. 13. fable.io
  14. 14. fsharp.github.io/FSharp.Compiler.Service
  15. 15. printfn "hello world" ✓ ✓ ✓ ✓ ✓ ✓
  16. 16. let symbolUses = symbolUses |> Array.filter (fun symbolUse -> …) |> Array.Parallel.map (fun symbolUse -> …) |> Array.filter (fun … -> …) |> Array.groupBy (fun … -> …) |> Array.map (fun … ->….)
  17. 17. https://lukemerrett.com/fsharp-domain-modelling/ type Status = | Online | Unresponsive of string | Missing of string | NotChecked of string | Ignored
  18. 18. https://medium.com/@odytrice Ody Mbegbu type Value = | Integer of int64 | String of string | Date of DateTime | Data of string | Bool of bool | Dict of (string * Value) list | Array of Value list
  19. 19. /// The view function giving updated content for the page let view model dispatch = match model.Text with | [| |] -> div [] [ div [] [str "Loading..."] ] | _ -> div [ ClassName "container" ] [ button [ OnClick (fun _ -> dispatch Faster) ] [ str "Faster" ] div [ ClassName "theText" ] [ str model.Text.[model.Index] ] button [ OnClick (fun _ -> dispatch Slower) ] [ str "Slower" ] div [] [ str (sprintf "Ticks Per Update: %d" model.TicksPerUpdate) ] ] A functional-reactive dynamic web view
  20. 20. /// The view function giving updated content for the page let view (model: Model) dispatch = if model.Pressed then Xaml.Label(text="I was pressed!") else Xaml.Button(text="Press Me!", command=(fun () -> dispatch Pressed)) A functional-reactive mobile app view
  21. 21. type Msg = | Pressed type Model = { Pressed: bool } let init() = { Pressed=false } let update msg model = match msg with | Pressed -> { model with Pressed = true } let view (model: Model) dispatch = if model.Pressed then Xaml.abel(text="I was pressed!") else Xaml.Button(text="Press Me!", command=(fun () -> dispatch Pressed)) type App () = inherit Application () do Program.run init update view A full Xamarin mobile app The messages The initial model The update function The dynamic view Host+run github.com/fsprojects/Elmish.XamarinForms/ The model
  22. 22. ✔ Enterprise Openness
  23. 23. X Y
  24. 24. Functional Objects
  25. 25. type Vector2D (dx:double, dy:double) = let d2 = dx*dx+dy*dy member v.DX = dx member v.DY = dy member v.Length = sqrt d2 member v.Scale(k) = Vector2D (dx*k, dy*k) Inputs to object construction Exported properties Exported method Object internals
  26. 26. Object Interface Types type IObject = interface ISimpleObject abstract Prop1 : type abstract Meth2 : type -> type Object Expressions { new IObject with member x.Prop1 = expr member x.Meth1 args = expr } { new Object() with member x.Prop1 = expr interface IObject with member x.Meth1 args = expr interface IWidget with member x.Meth1 args = expr } Constructed Class Types type ObjectType(args) = let internalValue = expr let internalFunction args = expr let mutable internalState = expr member x.Prop1 = expr member x.Meth2 args = expr
  27. 27. objects as a single paradigm overuse of hierarchical classification large abstractions many holes failure points declarations expressions complex inheriting complex
  28. 28. ✔ Functional Objects
  29. 29. fsharp.org/testimonials
  30. 30. 350,000 lines of C# OO by offshore team 30,000 lines of robust F#, with parallel +more features An application to evaluate the revenue due from Balancing Services contracts in the UK energy industry http://simontcousins.azurewebsites.net/does-the-language-you-use-make-a- difference-revisited/
  31. 31. Zero bugs in deployed system “F# is the safe choice for this project, any other choice is too risky” An application to evaluate the revenue due from Balancing Services contracts in the UK energy industry http://simontcousins.azurewebsites.net/does-the-language-you-use-make-a- difference-revisited/
  32. 32. X Y
  33. 33. Pattern Matching Abstraction
  34. 34. module BasicPatterns = let (|Value|_|) (e:FSharpExpr) = ... let (|Const|_|) (e:FSharpExpr) = ... let (|TypeLambda|_|) (e:FSharpExpr) = ... let (|Lambda|_|) (e:FSharpExpr) = ... let (|Application|_|) (e:FSharpExpr) = ... let (|IfThenElse|_|) (e:FSharpExpr) = ... let (|Let|_|) (e:FSharpExpr) = ... let (|LetRec|_|) (e:FSharpExpr) = ... let (|NewRecord|_|) (e:FSharpExpr) = ... let (|NewUnionCase|_|) (e:FSharpExpr) = ... let (|NewTuple|_|) (e:FSharpExpr) = ... let (|TupleGet|_|) (e:FSharpExpr) = ...
  35. 35. let (|IdentifierNameSyntax|_|) (n: CSharpSyntaxNode) = match n with | :? IdentifierNameSyntax as t -> Some(t.CSharpKind(), t.Identifier) | _ -> None let (|IdentifierName|_|) (n: CSharpSyntaxNode) = match n.CSharpKind() with | SyntaxKind.IdentifierName -> ... | _ -> None let (|QualifiedNameSyntax|_|) (n: CSharpSyntaxNode) = match n with | :? QualifiedNameSyntax as t -> ... | _ -> None let (|QualifiedName|_|) (n: CSharpSyntaxNode) = match n.CSharpKind() with | SyntaxKind.QualifiedName -> ... | _ -> None
  36. 36. ✔ Pattern Matching Abstraction
  37. 37. Code Data
  38. 38. 1 2 3 4 5 6 7 2012 2013 6,432 10,537
  39. 39. Statically Typed Dynamically Typed Options • make statically typed langs more dynamic • make dynamically typed langs more static • apply moderated static typing much more broadly
  40. 40. http://fsharp.github.io/FSharp.Data/images/csv.gif http://fsharp.github.io/FSharp.Data/images/wb.gif
  41. 41. types Segoe UI Light
  42. 42. 01/06/2018 70
  43. 43. 01/06/2018 71
  44. 44. 01/06/2018 72
  45. 45. 01/06/2018 73
  46. 46. 01/06/2018 74
  47. 47. 01/06/2018 75
  48. 48. 01/06/2018 76
  49. 49. 01/06/2018 77
  50. 50. 01/06/2018 78
  51. 51. 01/06/2018 79
  52. 52. integrating internet-scale information services directly into the program's variable and type space is probably the most innovative programming language idea I’ve heard of in a decade
  53. 53. ✔ ✔ Code Data
  54. 54. X Y
  55. 55. Sync Async
  56. 56. Numbers Numbers- with Units
  57. 57. Synthesis from contradiction is at the heart of applied PL design Opposites come in all shapes and flavours Achieve relaxation today ☺ Code Data Functi onal Objec ts Open Enter prise Sync Async … …
  58. 58. Thank you!! Questions?

×