pdf

Manning.Get.Programming.with.FSharp.2018.2.pdf

  • 1星
  • 日期: 2018-06-27
  • 大小: 14.3MB
  • 所需积分:0分
  • 下载次数:1
  • favicon收藏
  • rep举报
  • 分享
  • free评论
标签: F#

F#

When  I  first  met  Isaac  Abraham  in  2015,  I  knew  immediately  that  he  shared  my  passion

for  educating  .NET  developers  in  the  art  of  F#.  His  book,  which  you  hold  in  your  hands,

is  the  text  I  had  wanted  when  I  first  kindled  my  F#  romance.  Inside,  Isaac  will  lead  you

on  a  journey  of  F#  that’s  both  pragmatic  and  relevant.  If  you’re  a  C#  or  Visual  Basic  .NET

developer,  you’ll  learn  through  a  series  of  lessons  how  to  apply  F#  to  everyday  .NET

development.  You  won’t  have  to  wade  through  the  deep  theoretical  explanations  that

are  often  the  staple  of  functional  programming  books.  Instead,  Isaac  will  guide  you  with

practical  advice  and  best  practices  derived  from  his  own  experience  as  an  F#  developer.

I  first  fell  in  love  with  F#  when  it  was  still  a  research  language  being  developed  out  of

Microsoft  Research  in  Cambridge,  England.  The  language  was  a  bit  rough  around  the

edges,  but  every  monthly  release  brought  a  fresh  set  of  exciting  new  features  to  explore.

The  community  was  small  but  already  vibrant,  eager  to  evangelize  any  who  would  listen

about  how  F#  was  so  expressive,  powerful,  and  fun.  I  found  myself  caught  up  in  it  all.

Since  F#  was  still  very  new,  there  weren’t  many  books  available  to  help  me  learn  the  language.

Being  a  self-taught  C#  programmer,  I  wanted  something  that  was  light  on  theory

and  heavy  on  practice,  but  such  books  hadn’t  been  written  yet.  I  even  made  my  own

meager  attempt  to  fill  that  void,  by  writing  a  blog  series  (viewable  today  only  via  the

Internet  Archive)  titled,  “Why  I  Love  F#.”

Basic F# syntax, types, and functions // Define module MyCode in namespace Company.Rules (lesson 12) module Company.Rules.MyCode // Open System namespace open System // Define a simple value (lesson 4) let playerName = "Joe" // Create and unwrap a tuple (lesson 9) let playerTuple = playerName, 21 let name, age = playerTuple // Define and create a record (lesson 10) type Player = { Name : string; Score : int; Country : string } let player = { Name = playerName; Score = 0; Country = "GB" } // Function definition with copy-and-update record syntax (lessons 10, 11) let increaseScoreBy score p = { p with Score = p.Score + score } // Piping functions (lesson 11) player |> increaseScoreBy 50 |> printfn "%A" // Function with basic pattern matching and nested expressions (lesson 7, 20) type GreetingStyle = Friendly | Normal let greet style player = let greeting = match style with | Friendly -> "Have a nice day!" | Normal -> "Good luck." sprintf "Hello, player %s! %s" player.Name greeting // Partial function application (lesson 11) let friendlyGreeting = greet Friendly // Composing functions together (lesson 11) let printToConsole text = printfn "%s" text let greetAndPrint = friendlyGreeting >> printToConsole Get Programming with F# A guide for .NET developers Isaac Abraham MANNING Shelter Island For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: orders@manning.com ©2018 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Acquisitions editor: Michael Stephens Development editor: Elesha Hyde Review editor: Aleksandar Dragosavljevic´ Technical development editor: Mark Elston Technical proofreader: Dane Balia Production editor: David Novak Copyeditor: Sharon Wilkey Proofreader: Melody Dolab Typesetter: Dottie Marsico Cover designer: Monica Kamsvaag ISBN 9781617293993 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – EBM – 23 22 21 20 19 18 Contents Foreword v Preface viii Acknowledgments x About this book xi About the author xiv Welcome to Get Programming with F#! 1 Lesson 13 Lesson 14 Achieving code reuse in F# 149 Capstone 2 160 Unit 4 COLLECTIONS IN F# Useful collection functions 186 Lesson 15 Working with collections in F# 173 Lesson 16 Lesson 17 Maps, dictionaries, and sets 197 Folding your way to success 206 Lesson 18 Capstone 3 219 Lesson 19 Unit 5 THE PIT OF SUCCESS WITH THE F# TYPE SYSTEM Program flow in F# 231 Lesson 20 Lesson 21 Modeling relationships in F# 244 Lesson 22 Lesson 23 Lesson 24 Fixing the billion-dollar mistake 257 Business rules as code 270 Capstone 4 284 Unit 6 LIVING ON THE .NET PLATFORM Lesson 25 Lesson 26 Working with NuGet packages 310 Consuming C# from F# 299 Unit 1 F# AND VISUAL STUDIO Lesson 1 Lesson 2 Lesson 3 The Visual Studio experience 17 Creating your first F# program 25 The REPL—changing how we develop 34 Unit 2 HELLO F# Saying a little, doing a lot 47 Trusting the compiler 58 Lesson 4 Lesson 5 Lesson 6 Working with immutable data 70 Expressions and statements 81 Lesson 7 Capstone 1 92 Lesson 8 Unit 3 TYPES AND FUNCTIONS Lesson 9 Lesson 10 Lesson 11 Lesson 12 Shaping data with tuples 101 Shaping data with records 111 Building composable functions 125 Organizing code without classes 138 iii
更多简介内容

推荐帖子

评论

登录/注册

意见反馈

求资源

回顶部

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版 版权声明

北京市海淀区知春路23号集成电路设计园量子银座1305 电话:(010)82350740 邮编:100191

电子工程世界版权所有 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2021 EEWORLD.com.cn, Inc. All rights reserved
$(function(){ var appid = $(".select li a").data("channel"); $(".select li a").click(function(){ var appid = $(this).data("channel"); $('.select dt').html($(this).html()); $('#channel').val(appid); }) })