Practical F#

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Practical F# - Presentation Transcript

    1. Practical F#
      Ryan Riley
      Catapult Systems, Inc.
      Houston TechFest 2009
    2. Agenda
      Core Concepts
      Basic Syntax
      Why Consider F#
      When to use F#
      When not to use F#
      Summary
    3. Core Concepts
    4. F# Paradigms
      Functional
      Object-oriented
      Language-oriented
    5. Functional Programming Concepts
      First-Class Functions (and Events)
      Strong Type Inference
      Immutability
      Make side-effects explicit (the M-word)
      Functional Reactive Programming
      Easy Concurrency
      Actor-model Messaging (similar to Erlang)
      Lazy Evaluation
    6. Basic Syntax
    7. let
      Similar to var in C#.
    8. Tuples
      Type-safe collection of values
      C# out parameters are returned as tuples
    9. Class Declaration
    10. Abstract Classes
    11. Interfaces
    12. Inheritance
    13. Records
      But then, why bother?
    14. Discriminated Unions
      Functional inheritance
    15. Pattern Matching
    16. Extension Methods
    17. Object Expressions
    18. Control Flow with Pipes
    19. Function Composition
    20. Computation Workflows
    21. Quotations
      This is supposed to be a practical discussion!
      Quotations are similar to LINQ Expressions.
    22. REPL
    23. Visual Studio Integration
    24. Why Consider F#?
      You can do everything you did in C# within F#
      Some things are simpler, some harder
      Simpler: many OO design patterns
      Simpler: Asynchronous tasks
      Harder: GUI programming
      Terrific for specialized tasks (polyglot)
      Many great F# libraries
      Terse language = fewer lines of code = $ saved
    25. When to use F#
      Asynchronous operations
      Concurrent operations
      Messaging (MailboxProcessor)
      Transformation operations (like SSIS)
      Computation-intensive operations (like SSAS)
      Creating Domain Specific Languages (DSLs)
      Aspect-Oriented Programming (AOP)
      Testing
    26. FP vs. OOP
    27. #1 Reason to use F#
      Your entire application is already just a series of LINQ statements!
    28. Testing
      FsTest
      FsUnit
    29. Generate Test Data
    30. Mathematical Calculations
      Project Euler Problem 4:
      Project Euler Problem 3:
      Project Euler Problem 6
    31. Excel Financial Functions
    32. Parsers
      FSharp.PowerPack has a lexer and parser
      Fparsec
      Cashel
    33. Automated Builds with Fake
    34. Async Workflows
    35. Async Workflows from C#
    36. Functional AOP?
    37. When not to use F#
      Just want to use the newest thing
      GUI programming
      You can do it
      Can’t use the designers
      Can still be a great tool
      When you are already proficient in C# and are focused almost entirely on OOP.
      Stick to what you know. You’ll be faster.
    38. Summary
      “Write tomorrow’s legacy code today with C#”
      Chris Smith’s F# Facts
      Try F#
      Fall in love with F#
      Use F#
      The End
    39. Resources
      F# is still CTP
      Try it in VS2010 Beta 1
      Or use the VS2008 CTP installer
      Read books
      Foundations of F#(Pickering)
      Expert F# (Syme)
      Functional Programming for the Real World (Petricek and Skeet)
      F# for Scientists (Harrop)
    40. Resources
      http://channel9.msdn.com/pdc2008/TL11/
      http://tomasp.net/blog/fsharp-webcast-functional.aspx
      http://lorgonblog.spaces.live.com/blog/
      http://codebetter.com/blogs/matthew.podwysocki/default.aspx
    41. The end …
    42. Monads
      Monads are about function composition.
      Take a monoid:f(x) -> xg(x) -> xf(g(x)) -> x
      f.g x -> x
      Add a transformation:f(x) -> Mxg(x) -> Mxf(g(x)) -> Mx
      f.g x -> Mx
    43. Creating Monadic Builders
      The parts of a monad:(in F#, this would be a workflow builder)
      x.Let (value, transform): sets a value, like LINQ’s Select().
      x.Bind (value, transform): splits the value from the transform and passes it into the next function, like LINQ’s SelectMany().
      x.Return (value): returns the result.
      x.Delay (transform): kicks off the workflow.
    44. Computation workflow structure
      Typical structure of a workflow builder:type WorkflowBuilder () = member x.Bind (value, transform) = transform value member x.Return (value) = fun () -> value member x.Delay (transform) = fun () -> transform ()let workflow = new WorkflowBuilder()
      Execute like so:let myWorkflow = workflow { let x = 1 // x.Let let! y = 2 // x.Bind return x + y // x.Return }let result = myWorkflow () // x.Delay
    SlideShare Zeitgeist 2009

    + Ryan RileyRyan Riley Nominate

    custom

    204 views, 0 favs, 1 embeds more stats

    Presented at Houston Tech Fest 2009.

    F# is the new more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 204
      • 182 on SlideShare
      • 22 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 2
    Most viewed embeds
    • 22 views on http://wizardsofsmart.net

    more

    All embeds
    • 22 views on http://wizardsofsmart.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories