Get Programming with Haskell
معرفی کتاب «Get Programming with Haskell» نوشتهٔ Will Kurt، منتشرشده توسط نشر Manning Publications Co. LLC در سال 2018. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Get Programming with Haskell» در دستهٔ بدون دستهبندی قرار دارد.
**Summary** __Get Programming with Haskell__ introduces you to the Haskell language without drowning you in academic jargon and heavy functional programming theory. By working through 43 easy-to-follow lessons, you'll learn Haskell the best possible way—by doing Haskell! Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. **About the Technology** Programming languages often differ only around the edges—a few keywords, libraries, or platform choices. Haskell gives you an entirely new point of view. To the software pioneer Alan Kay, a change in perspective can be worth 80 IQ points and Haskellers agree on the dramatic bene ts of thinking the Haskell way—thinking functionally, with type safety, mathematical certainty, and more. In this hands-on book, that's exactly what you'll learn to do. **About the Book** __Get Programming with Haskell__ leads you through short lessons, examples, and exercises designed to make Haskell your own. It has crystal-clear illustrations and guided practice. You will write and test dozens of interesting programs and dive into custom Haskell modules. You will gain a new perspective on programming plus the practical ability to use Haskell in the everyday world. (The 80 IQ points: not guaranteed.) **What's Inside** * Thinking in Haskell * Functional programming basics * Programming in types * Real-world applications for Haskell **About the Reader** Written for readers who know one or more programming languages. **About The Author** **Will Kurt** currently works as a data scientist. He writes a blog at www.countbayesie.com, explaining data science to normal people. **Table of Contents** * Lesson 1 Getting started with Haskell ## Unit 1 - FOUNDATIONS OF FUNCTIONAL PROGRAMMING * Lesson 2 Functions and functional programming * Lesson 3 Lambda functions and lexical scope * Lesson 4 First-class functions * Lesson 5 Closures and partial application * Lesson 6 Lists * Lesson 7 Rules for recursion and pattern matching * Lesson 8 Writing recursive functions * Lesson 9 Higher-order functions * Lesson 10 Capstone: Functional object-oriented programming with robots! ## Unit 2 - INTRODUCING TYPES * Lesson 11 Type basics * Lesson 12 Creating your own types * Lesson 13 Type classes * Lesson 14 Using type classes * Lesson 15 Capstone: Secret messages! ## Unit 3 - PROGRAMMING IN TYPES * Lesson 16 Creating types with "and" and "or" * Lesson 17 Design by composition—Semigroups and Monoids * Lesson 18 Parameterized types * Lesson 19 The Maybe type: dealing with missing values * Lesson 20 Capstone: Time series ## Unit 4 - IO IN HASKELL * Lesson 21 Hello World!—introducing IO types * Lesson 22 Interacting with the command line and lazy I/O * Lesson 23 Working with text and Unicode * Lesson 24 Working with files * Lesson 25 Working with binary data * Lesson 26 Capstone: Processing binary files and book data ## Unit 5 - WORKING WITH TYPE IN A CONTEXT * Lesson 27 The Functor type class * Lesson 28 A peek at the Applicative type class: using functions in a context * Lesson 29 Lists as context: a deeper look at the Applicative type class * Lesson 30 Introducing the Monad type class * Lesson 31 Making Monads easier with donotation * Lesson 32 The list monad and list comprehensions * Lesson 33 Capstone: SQL-like queries in Haskell ## Unit 6 - ORGANIZING CODE AND BUILDING PROJECTS * Lesson 34 Organizing Haskell code with modules * Lesson 35 Building projects with stack * Lesson 36 Property testing with QuickCheck * Lesson 37 Capstone: Building a prime-number library ## Unit 7 - PRACTICAL HASKELL * Lesson 38 Errors in Haskell and the Either type * Lesson 39 Making HTTP requests in Haskell * Lesson 40 Working with JSON data by using Aeson * Lesson 41 Using databases in Haskell * Lesson 42 Efficient, stateful arrays in Haskell * Afterword - What's next? * Appendix - Sample answers to exercises Get Programming with Haskell 1 Contents 6 Preface 8 Acknowledgments 10 About this book 11 Who should read this book 11 How this book is organized 12 About the code 14 Book forum 14 About the author 15 Lesson 1 Getting started with Haskell 16 1.1 Welcome to Haskell 16 1.2 The Glasgow Haskell Compiler 17 1.3 Interacting with Haskell—GHCi 19 1.4 Writing and working with Haskell code 21 Summary 25 Unit 1 Foundations of functional programming 26 Lesson 2 Functions and functional programming 28 2.1 Functions 29 2.2 Functional programming 30 2.3 The value of functional programming in practice 31 Summary 36 Lesson 3 Lambda functions and lexical scope 38 3.1 Lambda functions 39 3.2 Writing your own where clause 40 3.3 From lambda to let: making your own variable variables! 42 3.4 Practical lambda functions and lexical scope 44 Summary 46 Lesson 4 First-class functions 48 4.1 Functions as arguments 49 4.2 Returning functions 54 Summary 57 Lesson 5 Closures and partial application 58 5.1 Closures—creating functions with functions 59 5.2 Example: Generating URLs for an API 60 5.3 Putting it all together 65 Summary 67 Lesson 6 Lists 69 6.1 The anatomy of a list 70 6.2 Lists and lazy evaluation 72 6.3 Common functions on lists 74 Summary 79 Lesson 7 Rules for recursion and pattern matching 80 7.1 Recursion 81 7.2 Rules for recursion 82 7.3 Your first recursive function: greatest common divisor 83 Summary 87 Lesson 8 Writing recursive functions 89 8.1 Review: Rules of recursion 90 8.2 Recursion on lists 90 8.3 Pathological recursion: Ackerman function and the Collatz conjecture 93 Summary 96 Lesson 9 Higher-order functions 98 9.1 Using map 99 9.2 Abstracting away recursion with map 100 9.3 Filtering a list 102 9.4 Folding a list 103 Summary 106 Lesson 10 Capstone: Functional object- oriented programming with robots! 107 10.1 An object with one property: a cup of coffee 108 10.2 A more complex object: let’s build fighting robots! 111 10.3 Why stateless programming matters 115 10.4 Types—objects and so much more! 117 Summary 118 Unit 2 Introducing types 120 Lesson 11 Type basics 122 11.1 Types in Haskell 123 11.2 Function types 126 11.3 Type variables 131 Summary 133 Lesson 12 Creating your own types 135 12.1 Using type synonyms 136 12.2 Creating new types 138 12.3 Using record syntax 142 Summary 146 Lesson 13 Type classes 147 13.1 Further exploring types 148 13.2 Type classes 148 13.3 The benefits of type classes 149 13.4 Defining a type class 150 13.5 Common type classes 151 13.6 The Ord and Eq type classes 152 13.7 Deriving type classes 155 Summary 156 Lesson 14 Using type classes 157 14.1 A type in need of classes 158 14.2 Implementing Show 159 14.3 Type classes and polymorphism 160 14.4 Default implementation and minimum complete definitions 161 14.5 Implementing Ord 163 14.6 To derive or not to derive? 164 14.7 Type classes for more-complex types 167 14.8 Type class roadmap 169 Summary 169 Lesson 15 Capstone: Secret messages! 170 15.1 Ciphers for beginners: ROT13 170 15.2 XOR: The magic of cryptography! 177 15.3 Representing values as bits 179 15.4 The one-time pad 182 15.5 A Cipher class 184 Summary 186 Unit 3 Programming in types 188 Lesson 16 Creating types with “and” and “or” 190 16.1 Product types—combining types with “and” 191 16.2 Sum types—combining types with “or” 195 16.3 Putting together your bookstore 198 Summary 201 Lesson 17 Design by composition— Semigroups and Monoids 202 17.1 Intro to composability—combining functions 203 17.2 Combining like types: Semigroups 204 17.3 Composing with identity: Monoids 208 Summary 215 Lesson 18 Parameterized types 216 18.1 Types that take arguments 217 18.2 Types with more than one parameter 222 Summary 228 Lesson 19 The Maybe type: dealing with missing values 229 19.1 Introducing Maybe: solving missing values with types 230 19.2 The problem with null 231 19.3 Computing with Maybe 234 19.4 Back to the lab! More-complex computation with Maybe 236 Summary 239 Lesson 20 Capstone: Time series 240 20.1 Your data and the TS data type 241 20.2 Stitching together TS data with Semigroup and Monoid 245 20.3 Performing calculations on your time series 250 20.4 Transforming time series 253 Summary 258 Unit 4 IO in Haskell 260 Lesson 21 Hello World!—introducing IO types 264 21.1 IO types—dealing with an impure world 265 21.2 Do-notation 269 21.3 An example: command-line pizza cost calculator 271 21.4 Summary 275 Lesson 22 Interacting with the command line and lazy I/O 276 22.1 Interacting with the command line the nonlazy way 277 22.2 Interacting with lazy I/O 281 Summary 285 Lesson 23 Working with text and Unicode 286 23.1 The Text type 287 23.2 Using Data.Text 287 23.3 Text and Unicode 293 23.4 Text I/O 295 Summary 296 Lesson 24 Working with files 297 24.1 Opening and closing files 298 24.2 Simple I/O tools 301 24.3 The trouble with lazy I/O 303 24.4 Strict I/O 306 Summary 307 Lesson 25 Working with binary data 309 25.1 Working with binary data by using ByteString 310 25.2 Glitching JPEGs 312 25.3 ByteStrings, Char8, and Unicode 321 Summary 322 Lesson 26 Capstone: Processing binary files and book data 323 26.1 Working with book data 325 26.2 Working with MARC records 328 26.3 Putting it all together 339 Summary 340 Unit 5 Working with type in a context 342 Lesson 27 The Functor type class 346 27.1 An example: computing in a Maybe 347 27.2 Using functions in context with the Functor type class 348 27.3 Functors are everywhere! 351 Summary 357 Lesson 28 A peek at the Applicative type class: using functions in a context 358 28.1 A command-line application for calculating the distance between cities 359 28.2 Using for partial application in a context 363 28.3 Using to create data in a context 369 Summary 371 Lesson 29 Lists as context: a deeper look at the Applicative type class 372 29.1 Introducing the Applicative type class 373 29.2 Containers vs. contexts 376 29.3 List as a context 378 Summary 385 Lesson 30 Introducing the Monad type class 387 30.1 The limitations of Applicative and Functor 388 30.2 The bind operator: >>= 393 30.3 The Monad type class 396 Summary 400 Lesson 31 Making Monads easier with do-notation 402 31.1 Do-notation revisited 404 31.2 Using do-notation to reuse the same code in different contexts 406 Summary 415 Lesson 32 The list monad and list comprehensions 417 32.1 Building lists with the list monad 418 32.2 List comprehensions 422 32.3 Monads: much more than just lists 424 Summary 425 Lesson 33 Capstone: SQL-like queries in Haskell 426 33.1 Getting started 427 33.2 Basic queries for your list: select and where 430 33.3 Joining Course and Teacher data types 432 33.4 Building your HINQ interface and example queries 434 33.5 Making a HINQ type for your queries 436 33.6 Running your HINQ queries 437 Summary 442 Unit 6 Organizing code and building projects 444 Lesson 34 Organizing Haskell code with modules 446 34.1 What happens when you write a function with the same name as one in Prelude? 447 34.2 Building a multifile program with modules 450 Summary 456 Lesson 35 Building projects with stack 457 35.1 Starting a new stack project 458 35.2 Understanding the project structure 459 35.3 Writing your code 462 35.4 Building and running your project! 464 Summary 466 Lesson 36 Property testing with QuickCheck 467 36.1 Starting a new project 468 36.2 Different types of testing 469 36.3 Property testing QuickCheck 474 Summary 480 Lesson 37 Capstone: Building a prime-number library 481 37.1 Starting your new project 482 37.2 Modifying the default files 483 37.3 Writing your core library functions 484 37.4 Writing tests for your code 488 37.5 Adding code to factor numbers 492 Summary 494 Unit 7 Practical Haskell 496 Lesson 38 Errors in Haskell and the Either type 498 38.1 Head, partial functions, and errors 499 38.2 Handling partial functions with Maybe 503 38.3 Introducing the Either type 505 Summary 510 Lesson 39 Making HTTP requests in Haskell 512 39.1 Getting your project set up 513 39.2 Using the HTTP.Simple module 516 39.3 Making an HTTP request 518 39.4 Putting it all together 520 Summary 521 Lesson 40 Working with JSON data by using Aeson 522 40.1 Getting set up 524 40.2 Using the Aeson library 525 40.3 Making your data types instances of FromJSON and ToJSON 526 40.4 Putting it all together: reading your NOAA data 534 Summary 537 Lesson 41 Using databases in Haskell 539 41.1 Setting up your project 540 41.2 Using SQLite and setting up your database 541 41.3 Creating data—inserting users and checking out tools 545 41.4 Reading data from the database and FromRow 547 41.5 Updating existing data 551 41.6 Deleting data from your database 554 41.7 Putting it all together 554 Summary 558 Lesson 42 Efficient, stateful arrays in Haskell 559 42.1 Creating efficient arrays in Haskell with the UArray type 561 42.2 Mutating state with STUArray 567 42.3 Taking values out of the ST context 570 42.4 Implementing a bubble sort 572 Summary 575 Afterword: What’s next? 576 A deeper dive into Haskell 576 More powerful type systems than Haskell? 577 Other functional programming languages 578 Appendix: Answers to end-of-lesson exercises 581 Unit 1 581 Unit 2 585 Unit 3 588 Unit 4 591 Unit 5 595 Unit 6 600 Unit 7 600 Index 604 Symbols 604 Numerics 604 A 604 B 605 C 605 D 606 E 606 F 606 G 607 H 607 I 607 J 608 K 608 L 608 M 609 N 610 O 610 P 610 Q 611 R 611 S 612 T 613 U 614 V 614 W 614 X 614 Z 614 Summary Get Programming with Haskell leads you through short lessons, examples, and exercises designed to make Haskell your own. It has crystal-clear illustrations and guided practice. You will write and test dozens of interesting programs and dive into custom Haskell modules. You will gain a new perspective on programming plus the practical ability to use Haskell in the everyday world. (The 80 IQ points: not guaranteed.) Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Technology Programming languages often differ only around the edges—a few keywords, libraries, or platform choices. Haskell gives you an entirely new point of view. To the software pioneer Alan Kay, a change in perspective can be worth 80 IQ points and Haskellers agree on the dramatic benefits of thinking the Haskell way—thinking functionally, with type safety, mathematical certainty, and more. In this hands-on book, that's exactly what you'll learn to do. What's Inside Thinking in Haskell Functional programming basics Programming in types Real-world applications for Haskell About the Reader Written for readers who know one or more programming languages. Table of Contents Lesson 1 Getting started with Haskell Unit 1 - FOUNDATIONS OF FUNCTIONAL PROGRAMMING Lesson 2 Functions and functional programming Lesson 3 Lambda functions and lexical scope Lesson 4 First-class functions Lesson 5 Closures and partial application Lesson 6 Lists Lesson 7 Rules for recursion and pattern matching Lesson 8 Writing recursive functions Lesson 9 Higher-order functions Lesson 10 Capstone: Functional object-oriented programming with robots! Unit 2 - INTRODUCING TYPES Lesson 11 Type basics Lesson 12 Creating your own types Lesson 13 Type classes Lesson 14 Using type classes Lesson 15 Capstone: Secret messages! Unit 3 - PROGRAMMING IN TYPES Lesson 16 Creating types with'and'and'or'Lesson 17 Design by composition—Semigroups and Monoids Lesson 18 Parameterized types Lesson 19 The Maybe type: dealing with missing values Lesson 20 Capstone: Time series Unit 4 - IO IN HASKELL Lesson 21 Hello World!—introducing IO types Lesson 22 Interacting with the command line and lazy I/O Lesson 23 Working with text and Unicode Lesson 24 Working with files Lesson 25 Working with binary data Lesson 26 Capstone: Processing binary files and book data Unit 5 - WORKING WITH TYPE IN A CONTEXT Lesson 27 The Functor type class Lesson 28 A peek at the Applicative type class: using functions in a context Lesson 29 Lists as context: a deeper look at the Applicative type class Lesson 30 Introducing the Monad type class Lesson 31 Making Monads easier with donotation Lesson 32 The list monad and list comprehensions Lesson 33 Capstone: SQL-like queries in Haskell Unit 6 - ORGANIZING CODE AND BUILDING PROJECTS Lesson 34 Organizing Haskell code with modules Lesson 35 Building projects with stack Lesson 36 Property testing with QuickCheck Lesson 37 Capstone: Building a prime-number library Unit 7 - PRACTICAL HASKELL Lesson 38 Errors in Haskell and the Either type Lesson 39 Making HTTP requests in Haskell Lesson 40 Working with JSON data by using Aeson Lesson 41 Using databases in Haskell Lesson 42 Efficient, stateful arrays in Haskell Afterword - What's next? Appendix - Sample answers to exercise Unlike any other programming language, Haskell is purely functional with a strong type system and lazy evaluation. It is arguable the most interesting language but also has the reputation of being one of the most challenging to learn. Learning Haskell doesn't have to be difficult, and this book can help! Learn Haskell teaches readers the Haskell language and functional programming concepts while they hack on interesting problems that are challenging but never frustrating. This example-filled tutorial will take users from the basics to tackling the tough topics. There are lots of crystal-clear illustrations, hands-on exercises, and open-ended tasks that encourage readers to explore Haskell on their own. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. Get Programming with Haskell introduces you to the Haskell language without drowning you in academic jargon and heavy functional programming theory. By working through 43 easy-to-follow lessons, you'll learn Haskell by doing Haskell. This book starts with first concepts, building your knowledge with concrete examples and exercises. You'll learn to think the Haskell way, as you start to understand the language and how to use it effectively. And you'll really appreciate the crystal-clear illustrations, quick-checks, and open-ended tasks that make sure you're solid on each new concept before you move along!
دانلود کتاب Get Programming with Haskell