syme - expert f sharp (apress, 2007)

631 666 0
syme - expert f sharp (apress, 2007)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... time to learn functional programming, and F# offers the best route to learn and apply functional programming on the NET platform The lead designer of the F# language, Don Syme, is one of the authors of this book This book benefits from his authority on F# and NET and from all the authors’ years of experience with F# and other programming languages The Genesis of F# F# began in 2002 when Don Syme and others... examine the inferred types of the sample programs These types play a key role in understanding the behavior of the code ■Note You can download and install F# from http://research.microsoft.com/fsharp Your primary source for information on the aspects of F# explored in this book is http://www .expert- fsharp.com, and you can download all the code samples used in this book from http://www .expert- fsharp.com/... advanced features of F# programming: F# computation expressions (also called workflows), F# reflection, and F# quotations These are used in later chapters, particularly Chapters 13 and 15 Chapter 10, Using the F# and NET Libraries, gives an overview of the libraries most frequently used with F# , including the NET Framework and the extra libraries added by F# 888bba9cf12226c8bc6011165b8042d4 3 Syme_ 85 0-4 C01.fm... language 5 Syme_ 85 0-4 C01.fm Page 6 Tuesday, October 23, 2007 11:57 AM 6 CHAPT ER 1 ■ INTRODUCTION Be sure to read Chapters 2 to 6 carefully, paying particular attention to the ways in which types are used and defined Typed functional languages: If you are familiar with Haskell, OCaml, or Standard ML, you will find the core of F# readily familiar, with some syntactic differences However, F# embraces... collected into a single xml file and processed with additional tools or can be converted immediately to HTML by the F# command-line compiler (fsc.exe) We cover using the F# command-line compiler in more detail in Chapter 7 ■Tip The F# command-line compiler (fsc.exe) options for generating HTML documentation are generate-html and html-output-directory To generate an XMLDoc file, use -doc Understanding Scope... entire expression that follows the definition, though not the definition itself Here are two examples of invalid definitions that try to access variables outside their scope As you can see, let definitions follow a sequential, top-down order, which helps ensure that programs are well-formed and free from many bugs related to uninitialized values: Syme_ 85 0-4 C02.fm Page 11 Tuesday, September 18, 2007... string and returns int * int, which is F# ’s way of saying “a pair of integers.” The keyword val stands for value, and the symbol -> represents a function No explicit type has been given in the program for wordCount or its argument text, because the full type for wordCount has been “inferred” from its definition We discuss type inference further in the “What Is Type Inference?” sidebar and in more detail... types, monads, inference, impredicative higher-ranked types, and so on Even worse, most pure functional languages today are not well integrated with mainstream professional tools and IDEs, libraries, and frameworks xxi Syme_ 85 0-4 FRONT.fm Page xxii Monday, October 29, 2007 10:07 AM xxii F O R E W O R D Imperative programming today is the tool of choice for scientific programmers who simulate fluid dynamics,... Microsoft Research decided to ensure that the “ML” approach to pragmatic but theoretically-based language design found a high-quality 1 Syme_ 85 0-4 C01.fm Page 2 Tuesday, October 23, 2007 11:57 AM 2 CHAPT ER 1 ■ INTRODUCTION expression for the NET platform The project was closely associated with the design and implementation of Generics for the NET Common Language Runtime The first major prerelease of F# ... be needed to make the best use of versions of F# beyond version 1.9.2, which was used for this book An active errata and list of updates will be published at http://www .expert- fsharp.com/Updates Syme_ 85 0-4 C02.fm Page 7 Tuesday, September 18, 2007 7:44 PM CHAPTER 2 ■■■ Getting Started with F# and NET I n this chapter, we cover some simple interactive programming with F# and NET By now you should have . the prior written permission of the copyright owner and the publisher. ISBN-13: 97 8-1 -5 905 9-8 5 0-4 ISBN-10: 1-5 905 9-8 5 0-4 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked. y0 w1 h1" alt="" Expert F# ■■■ Don Syme, Adam Granicz, and Antonio Cisternino Syme_ 85 0-4 FRONT.fm Page i Monday, October 29, 2007 10:07 AM Expert F# Copyright © 2007 by Don Syme, Adam Granicz,. directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www .expert- fsharp.com. Syme_ 85 0-4 FRONT.fm Page ii Monday, October

Ngày đăng: 03/04/2014, 12:24

Mục lục

  • Expert F#

    • Contents at a Glance

    • About the Technical Reviewer

    • Introduction

      • The Genesis of F#

      • Who This Book Is For

      • Getting Started with F# and .NET

        • Creating Your First F# Program

          • Turning On the Lightweight Syntax Option

          • Documenting Code Using XMLDocs

          • Understanding Scope and Using fietf

          • Using Properties and the Dot-Notation

          • Using .NET Libraries from F#

            • Using open to Access Namespaces and Modules

            • Using new and Setting Properties

            • Fetching a Web Page

            • Introducing Functional Programming

              • Getting Started with F# Arithmetic

                • Basic Literals

                • Introducing Simple Strings

                  • Working with String Literals and Primitives

                  • Working with Lists and Options

                    • Using F# Lists

                    • Using F# Option Values

                    • Using Option Values for Control

                    • Working with Conditionals: && and ||

                    • Introducing Function Values

                      • Using Anonymous Function Values

                      • Computing with Aggregate Operators

                      • Composing Functions with >>

Tài liệu cùng người dùng

Tài liệu liên quan