You are previewing Foundations of F#.

Foundations of F#

Cover of Foundations of F# by Robert Pickering Published by Apress
  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. Foreword
  6. About the Author
  7. About the Technical Reviewer
  8. Acknowledgements
  9. Preface
  10. CHAPTER 1 Introduction
    1. What Is Functional Programming?
    2. Why Is Functional Programming Important?
    3. What Is F#?
    4. Who Is Using F#?
    5. Who Is This Book For?
    6. What's Next?
  11. CHAPTER 2 How to Obtain, Install, and Use F#
    1. Obtaining F#
    2. Installing F# on Windows
    3. Installing F# on Linux
    4. Using F# in Different Ways
    5. Installing the Software Used in This Book
    6. Summary
  12. CHAPTER 3 Functional Programming
    1. Identifiers
    2. Keywords
    3. Literals
    4. Values and Functions
    5. Scope
    6. Recursion
    7. Anonymous Functions
    8. Operators
    9. Lists
    10. List Comprehensions
    11. Control Flow
    12. Types and Type Inference
    13. Pattern Matching
    14. Defining Types
    15. Exceptions and Exception Handling
    16. Lazy Evaluation
    17. Summary
  13. CHAPTER 4 Imperative Programming
    1. The unit Type
    2. The mutable Keyword
    3. Defining Mutable Record Types
    4. The ref Type
    5. Arrays
    6. Array Comprehensions
    7. Control Flow
    8. Loops over Comprehensions
    9. Calling Static Methods and Properties from .NET Libraries
    10. Using Objects and Instance Members from .NET Libraries
    11. Using Indexers from .NET Libraries
    12. Working with Events from .NET Libraries
    13. Pattern Matching over .NET Types
    14. The |> Operator
    15. Summary
  14. CHAPTER 5 Object-Oriented Programming
    1. Casting
    2. Type Tests
    3. Type Annotations for Subtyping
    4. Records As Objects
    5. F# Types with Members
    6. Object Expressions
    7. Defining Interfaces
    8. Implementing Interfaces
    9. Classes, Fields, and Explicit Constructors
    10. Implicit Class Construction
    11. Classes and Inheritance
    12. Classes and Methods
    13. Accessing the Base Class
    14. Properties and Indexers
    15. Classes and Static Methods
    16. Overriding Methods from Non-F# Libraries
    17. Defining Delegates
    18. Structs
    19. Enums
    20. Summary
  15. CHAPTER 6 Organizing, Annotating, and Quoting Code
    1. Modules
    2. Namespaces
    3. Opening Namespaces and Modules
    4. Giving Namespaces and Modules Aliases
    5. Signature Files
    6. Module Scope
    7. Module Execution
    8. Optional Compilation
    9. Comments
    10. Doc Comments
    11. Custom Attributes
    12. Quoted Code
    13. Summary
  16. CHAPTER 7 The F# Libraries
    1. Libraries Overview
    2. The Native F# Library FSLib.dll
    3. The ML Compatibility Library MLLib.dll
    4. Summary
  17. CHAPTER 8 User Interfaces
    1. Introducing WinForms
    2. Drawing WinForms
    3. Working with Controls in WinForms
    4. Using the Visual Studio Form Designer's Forms in F#
    5. Working with WinForms Events and the IEvent Module
    6. Creating New Forms Classes
    7. Introducing ASP.NET 2.0
    8. Creating an IHttpHandler
    9. Working with ASP.NET Web Forms
    10. Introducing Windows Presentation Foundation
    11. Introducing Windows Presentation Foundation 3D
    12. Summary
  18. CHAPTER 9 Data Access
    1. The System.Configuration Namespace
    2. The System.IO Namespace
    3. The System.Xml Namespace
    4. ADO.NET
    5. The EntLib Data Access Block
    6. Data Binding
    7. Data Binding and the DataGridView
    8. ADO.NET Extensions
    9. Introducing LINQ
    10. Using LINQ to XML
    11. Using LINQ to SQL
    12. Summary
  19. CHAPTER 10 Distributed Applications
    1. Networking Overview
    2. Using TCP/IP Sockets
    3. Using HTTP
    4. Calling Web Services
    5. Creating Web Services
    6. Windows Communication Foundation
    7. Hosting WCF Services
    8. Summary
  20. CHAPTER 11 Language-Oriented Programming
    1. What Is Language-Oriented Programming?
    2. Data Structures As Little Languages
    3. Metaprogramming with Quotations
    4. An Arithmetic-Language Implementation
    5. Summary
  21. CHAPTER 12 The F# Tool Suite and .NET Programming Tools
    1. Using Useful fsc.exe Command-Line Switches
    2. Using fsi.exe Effectively
    3. Using the Source Directory Macro
    4. Writing NUnit Tests
    5. Using Assembly Browsers
    6. Using Debugging Tools
    7. Using Profiling Tools
    8. Summary
  22. CHAPTER 13 Compatibility and Advanced Interoperation
    1. Calling F# Libraries from C#
    2. Using F# with the .NET Framework Versions 1 and 1.1
    3. Calling Using COM Objects
    4. Using P/Invoke
    5. Using Inline IL
    6. Using F# from Native Code via COM
    7. Summary
  23. Index
O'Reilly logo

CHAPTER 13Compatibility and Advanced Interoperation

In this chapter, you will look at everything you need to make F# interoperate well with other languages, not just within the .NET Framework but also using unmanaged code from F# and using F# from unmanaged code.

Caution Throughout this book, I have made every effort to make sure the only language you need to understand is F#. However, in this chapter, it will help if you know a little C#, C++, or .NET Common IL, although I've kept the code in these languages to the minimum necessary.

Calling F# Libraries from C#

You can create two kinds of libraries in F#: libraries that are designed to be used from F# only and libraries that are designed to be used from any .NET language. This is because ...

The best content for your career. Discover unlimited learning on demand for around $1/day.