图书介绍
真实世界的HaskellPDF|Epub|txt|kindle电子书版本网盘下载
![真实世界的Haskell](https://www.shukui.net/cover/69/33212643.jpg)
- BryanOSullivan,JohnGoerzen,DonStewart著 著
- 出版社: 南京:东南大学出版社
- ISBN:9787564119256
- 出版时间:2010
- 标注页数:673页
- 文件大小:27MB
- 文件页数:709页
- 主题词:Haskell语言-程序设计-英文
PDF下载
下载说明
真实世界的HaskellPDF格式电子书版下载
下载的文件为RAR压缩包。需要使用解压软件进行解压得到PDF格式图书。建议使用BT下载工具Free Download Manager进行下载,简称FDM(免费,没有广告,支持多平台)。本站资源全部打包为BT种子。所以需要使用专业的BT下载软件进行下载。如BitComet qBittorrent uTorrent等BT下载工具。迅雷目前由于本站不是热门资源。不推荐使用!后期资源热门了。安装了迅雷也可以迅雷进行下载!
(文件页数 要大于 标注页数,上中下等多册电子书除外)
注意:本站所有压缩包均有解压码: 点击下载压缩包解压工具
图书目录
1.Getting Started1
Your Haskell Environment1
Getting Started with ghci,the Interpreter2
Basic Interaction:Using ghci as a Calculator3
Simple Arithmetic3
An Arithmetic Quirk:Writing Negative Numbers4
Boolean Logic,Operators,and Value Comparisons5
Operator Precedence and Associativity7
Undefined Values,and Introducing Variables8
Dealing with Precedence and Associativity Rules8
Command-Line Editing in ghci9
Lists9
Operators on Lists11
Strings and Characters11
First Steps with Types12
A Simple Program15
2.Typesand Functions17
Why Care About Types?17
Haskell's Type System18
Strong Types18
Static Types19
Type Inference20
What to Expect from the Type System20
Some Common Basic Types21
Function Application22
Useful Composite Data Types:Lists and Tuples23
Functions over Lists and Tuples25
Passing an Expression to a Function26
Function Types and Purity27
Haskell Source Files,and Writing Simple Functions27
Just What Is a Variable,Anyway?28
Conditional Evaluation29
Understanding Evaluation by Example32
Lazy Evaluation32
A More Involved Example33
Recursion34
Ending the Recursion35
Returning from the Recursion35
What Have We Learned?36
Polymorphism in Haskell36
Reasoning About Polymorphic Functions38
Further Reading38
The Type of a Function of More Than One Argument38
Why the Fuss over Purity?39
Conclusion40
3.Defining Types,Streamlining Functions41
Defining a New Data Type41
Naming Types and Values43
Type Synonyms43
Algebraic Data Types44
Tuples,Algebraic Data Types,and When to Use Each45
Analogues to Algebraic Data Types in Other Languages47
Pattern Matching50
Construction and Deconstruction51
Further Adventures52
Variable Naming in Patterns53
The Wild Card Pattern53
Exhaustive Patterns and Wild Cards54
Record Syntax55
Parameterized Types57
Recursive Types58
Reporting Errors60
A More Controlled Approach61
Introducing Local Variables61
Shadowing62
The where Clause63
Local Functions、Global Variables63
The Offside Rule and Whitespace in an Expression64
A Note About Tabs Versus Spaces66
The Offside Rule Is Not Mandatory66
The case Expression66
Common Beginner Mistakes with Patterns67
Incorrectly Matching Against a Variable67
Incorrectly Trying to Compare for Equality68
Conditional Evaluation with Guards68
4.Functional Programming71
Thinking in Haskell71
A Simple Command-Line Framework71
Warming Up:Portably Splitting Lines of Text72
A Line-Ending Conversion Program75
Infix Functions76
Working with Lists77
Basic List Manipulation78
Safely and Sanely Working with Crashy Functions79
Partial and Total Functions79
More Simple List Manipulations80
Working with Sublists81
Searching Lists82
Working with Several Lists at Once83
Special String-Handling Functions84
How to Think About Loops84
Explicit Recursion85
Transforming Every Piece of Input87
Mapping over a List88
Selecting Pieces of Input90
Computing One Answer over a Collection90
The Left Fold92
Why Use Folds,Maps,and Filters?93
Folding from the Right94
Left Folds,Laziness,and Space Leaks96
Further Reading99
Anonymous(lambda)Functions99
Partial Function Application and Currying100
Sections102
As-patterns103
Code Reuse Through Composition104
Use Your Head Wisely107
Tips for Writing Readable Code107
Space Leaks and Strict Evaluation108
Avoiding Space Leaks with seq108
Learning to Use seq109
5.Writing a Library:Working with JSONData111
A Whirlwind Tour of JSON111
Representing JSON Data in Haskell111
The Anatomy of a Haskell Module113
Compiling Haskell Source114
Generating a Haskell Program and Importing Modules114
Printing JSON Data115
Type Inference Is a Double-Edged Sword117
A More General Look at Rendering118
Developing Haskell Code Without Going Nuts119
Pretty Printing a String120
Arrays and Objects,and the Module Header122
Writing a Module Header123
Fleshing Out the Pretty-Printing Library124
Compact Rendering127
True Pretty Printing128
Following the Pretty Printer129
Creating a Package131
Writing a Package Description131
GHC's Package Manager133
Setting Up,Building,and Installing133
Practical Pointers and Further Reading134
6.Using Typeclasses135
The Need for Typeclasses135
What Are Typeclasses?136
Declaring Typeclass Instances139
Important Built-in Typeclasses139
Show139
Read141
Serialization with read and show143
Numeric Types144
Equality,Ordering,and Comparisons148
Automatic Derivation148
Typeclasses at Work:Making JSON Easier to Use149
More Helpful Errors151
Making an Instance with a Type Synonym151
Living in an Open World152
When Do Overlapping Instances Cause Problems?153
Relaxing Some Restrictions on Typeclasses154
How Does Show Work for Strings?155
How to Give a Type a New Identity155
Differences Between Data and Newtype Declarations157
Summary:The Three Ways of Naming Types158
JSON Typeclasses Without Overlapping Instances159
The Dreaded Monomorphism Restriction162
Conclusion163
7.I/O165
Classic I/O in Haskell165
Pure Versus I/O168
Why Purity Matters169
Working with Files and Handles169
More on openFile171
Closing Handles172
Seek and Tell172
Standard Input,Output,and Error173
Deleting and Renaming Files174
Temporary Files174
Extended Example:Functional I/O and Temporary Files175
Lazy I/O178
hGetContents178
readFile and writeFile180
A Word on Lazy Output181
interact181
The IO Monad183
Actions183
Sequencing186
The True Nature of Return187
Is Haskell Really Imperative?188
Side Effects with Lazy I/O188
Buffering189
Buffering Modes189
Flushing The Buffer190
Reading Command-Line Arguments190
Environment Variables191
8.Efficient File Processing,Regular Expressions,and Filenarne Matching193
Efficient File Processing193
Binary I/O and Qualified Imports194
Text I/O195
Filename Matching197
Regular Expressions in Haskell198
The Many Types of Result198
More About Regular Expressions200
Mixing and Matching String Types200
Other Things You Should Know201
Translating a glob Pattern into a Regular Expression202
An important Aside:Writing Lazy Functions205
Making Use of Our Pattern Matcher206
Handling Errors Through API Design210
Putting Our Code to Work211
9.I/O Case Study:A Library for Searching the Filesystem213
The find Command213
Starting Simple:Recursively Listing a Directory213
Revisiting Anonymous and Named Functions214
Why Provide Both mapM and forM?215
A Naive Finding Function215
Predicates:From Poverty to Riches,While Remaining Pure217
Sizing a File Safely219
The Acquire-Use-Release Cycle221
A Domain-Specific Language for Predicates221
Avoiding Boilerplate with Lifting223
Gluing Predicates Together224
Defining and Using New Operators225
Controlling Traversal226
Density,Readability,and the Learning Process228
Another Way of Looking at Traversal229
Useful Coding Guidelines232
Common Layout Styles233
10.Code Case Study:Parsing a Binary Data Format235
Grayscale Files235
Parsing a Raw PGM File236
Getting Rid of Boilerplate Code238
Implicit State239
The Identity Parser240
Record Syntax,Updates,and Pattern Matching241
A More Interesting Parser242
Obtaining and Modifying the Parse State242
Reporting Parse Errors243
Chaining Parsers Together243
Introducing Functors244
Constraints on Type Definitions Are Bad247
Infix Use of fmap248
Flexible Instances248
Thinking More About Functors249
Writing a Functor Instance for Parse250
Using Functors for Parsing251
Rewriting Our PGM Parser252
Future Directions254
11.Testing and Quality Assurance255
QuickCheck:Type-Based Testing256
Testing for Properties257
Testing Against a Model259
Testing Case Study:Specifying a Pretty Printer259
Generating Test Data259
Testing Document Construction262
Using Lists as a Model263
Putting It All Together264
Measuring Test Coverage with HPC265
12.Barcode Recognition269
A Little Bit About Barcodes269
EAN-13 Encoding270
Introducing Arrays270
Arrays and Laziness273
Folding over Arrays273
Modifying Array Elements274
Encoding an EAN-13 Barcode275
Constraints on Our Decoder275
Divide and Conquer276
Turning a Color Image into Something Tractable278
Parsing a Color Image278
Grayscale Conversion279
Grayscale to Binary and Type Safety279
What Have We Done to Our Image?280
Finding Matching Digits282
Run Length Encoding282
Scaling Run Lengths,and Finding Approximate Matches283
List Comprehensions284
Remembering a Match's Parity285
Chunking a List287
Generating a List of Candidate Digits287
Life Without Arrays or Hash Tables288
A Forest of Solutions288
A Brief Introduction to Maps289
Further Reading292
Turning Digit Soup into an Answer292
Solvvng for Check Digits in Parallel292
Completing the Solution Map with the First Digit294
Finding the Correct Sequence295
Working with Row Data295
Pulling It All Together296
A Few Comments on Development Style297
13.Data Structures299
Association Lists299
Maps301
Functions Are Data,Too303
Extended Example:/etc/passwd304
Extended Example:Numeric Types307
First Steps309
Completed Code311
Taking Advantage of Functions as Data317
Turning Difference Lists into a Proper Library318
Lists,Difference Lists,and Monoids320
General-Purpose Sequences322
14.Monads325
Revisiting Earlier Code Examples325
Maybe Chaining325
Implicit State326
Looking for Shared Patterns327
The Monad Typeclass329
And Now,a Jargon Moment330
Using a New Monad:Show Your Work!331
Information Hiding331
Controlled Escape332
Leaving a Trace332
Using the Logger Monad333
Mixing Pure and Monadic Code334
Putting a Few Misconceptions to Rest336
Building the Logger Monad336
Sequential Logging,Not Sequential Evaluation337
The Writer Monad337
The Maybe Monad338
Executing the Maybe Monad338
Maybe at Work,and Good API Design338
The List Monad340
Understanding the List Monad342
Putting the List Monad to Work343
Desugaring of do Blocks344
Monads as a Programmable Semicolon345
Why Go Sugar-Free?346
The State Monad346
Almost a State Monad347
Reading and Modifying the State348
Will the Real State Monad Please Stand Up?348
Using the State Monad:Generating Random Values349
A First Attempt at Purity350
Random Values in the State Monad351
Running the State Monad352
What About a Bit More State?352
Monads and Functors354
Another Way of Looking at Monads354
The Monad Laws and Good Coding Style355
15.Programming with Monads359
Golfing Practice:Association Lists359
Generalized Lifting360
Looking for Alternatives362
The Name mplus Does Not Imply Addition364
Rules for Working with MonadPlus364
Failing Safely with MonadPlus364
Adventures in Hiding the Plumbing365
Supplying Random Numbers368
Another Round of Golf369
Separating Interface from Implementation369
Multiparameter Typeclasses370
FunctionaI Dependencies370
Rounding Out Our Module371
Programming to a Monad's Interface372
The Reader Monad373
A Return to Automated Deriving374
Hiding the IO Monad375
Using a newtype376
Designing for Unexpected Uses377
Using Typeclasses378
Isolation and Testing379
The Writer Monad and Lists380
Arbitrary I/O Revisited381
16.Using Parsec383
First Steps with Parsec:Simple CSV Parsing383
The sepBy and endBy Combinators386
Choices and Errors387
Lookahead389
Error Handling390
Extended Example:Full CSV Parser391
Parsec and MonadPlus393
Parsing a URL-Encoded Query String393
Supplanting Regular Expressions for Casual Parsing395
Parsing Without Variables395
Applicative Functors for Parsing395
Applicative Parsing by Example396
Parsing JSON Data398
Parsing a HTTP Request401
Backtracking and Its Discontents402
Parsing Headers402
17.Interfacing with C:The FFI405
Foreign Language Bindings:The Basics406
Be Careful of Side Efiects407
A High-Level Wrapper408
Regular Expressions for Haskell:A Binding for PCRE409
Simple Tasks:Using the C Preprocessor410
Binding Haskell to C with hsc2hs411
Adding Type Safety to PCRE411
Binding to Constants412
Automating the Binding413
Passing String Data Between Haskell and C414
Typed Pointers416
Memory Management:Let the Garbage Collector Do the Work417
A High-Level Interface:Marshaling Data418
Marshaling ByteStrings419
Allocaring Local C Data:The Storable Class419
Putting It All Together420
Matching on Strings422
Extracting Information About the Pattern423
Pattern Matching with Substrings424
The Real Deal:Compiling and Matching Regular Expressions426
18.Monad Transformers429
Motivation:Boilerplate Avoidance429
A Simple Monad Transformer Example430
Common Patterns in Monads and Monad Transformers431
Stacking Multiple Monad Transformers433
Hiding Onr Work435
Moving Down the Stack436
When Explicit Lifting Is Necessary437
Understanding Monad Transformers by Building One438
Creating a Monad Transformer439
More Typeclass Instances440
Replacing the Parse Type with a Monad Stack440
Transformer Stacking Order Is Important441
Putting Monads and Monad Transformers into Perspective443
Interference with Pure Code443
Overdetermined Ordering444
Runtime Overhead444
Unwieldy Interfaces444
Pulling It All Together445
19.Error Handling447
Error Handling with Data Types447
Use of Maybe448
Use of Either452
Exceptions454
First Steps with Exceptions454
Laziness and Exception Handling455
Using handle456
Selective Handling of Exceptions456
I/O Exceptions457
Throwing Exceptions459
Dynamic Exceptions459
Error Handling in Monads462
A Tiny Parsing Framework463
20.Systems Programming in Haskell467
Running External Programs467
Directory and File Information468
Program Termination469
Dates and Times470
ClockTime and CalendarTime470
File Modification Times475
Extended Example:Piping476
Using Pipes for Redirection477
Better Piping483
Final Words on Pipes491
21.Using Databases493
Overview of HDBC493
Installing HDBC and Drivers494
Connecting to Databases495
Transactions495
Simple Queries496
SqlValue497
Query Parameters497
Prepared Statements498
Reading Results499
Reading with Statements501
Lazy Reading501
Database Metadata502
Error Handling503
22.Extended Example:Web Client Programming505
Basic Types506
The Database506
The Parser510
Downloading513
Main Program515
23.GUI Programming with gtk2hs517
Installing gtk2hs517
Overview of the GTK+Stack517
User Interface Design with Glade518
Glade Concepts518
Event-Driven Programming519
Initializing the GUI520
The Add Podcast Window524
Long-Running Tasks525
Using Cabal528
24.Concurrent and Multicore Programming531
Defining Concurrency and Parallelism531
Concurrent Programming with Threads532
Threads Are Nondeterministic532
Hiding Latency532
Simple Communication Between Threads533
The Main Thread and Waiting for Other Threads534
SafelyModifying an MVar536
Safe Resource Management:A Good Idea,and Easy Besides536
Finding the Status of a Thread537
Writing Tighter Code538
Communicating over Channels539
Useful Things to Know About539
MVar and Chan Are Nonstrict539
Chan Is Unbounded540
Shared-State Concurrency Is Still Hard540
Deadlock541
Starvation541
Is There Any Hope?542
Using Multiple Cores with GHC542
Runtime Options543
Finding the Number of Available Cores from Haskell543
Choosing the Right Runtime544
Parallel Programming in Haskell544
Normal Form and Head Normal Form545
Sequential Sorting545
Transforming Our Code into Parallel Code545
Knowing What to Evaluate in Parallel546
What Promises Does par Make?547
Running Our Code and Measuring Performance547
Tuning for Performance550
Parallel Strategies and MapReduce551
Separating Algorithm from Evaluation552
Separating Algorithm from Strategy554
Writing a Simple MapReduce Definition554
MapReduce and Strategies555
Sizing Work Appropriately555
Efficiently Finding Line-Aligned Chunks557
Counting Lines558
Finding the Most Popular URLs559
Conclusions560
25.Profiling and Optimization561
Profiling Haskell Programs561
Collecting Runtime Statistics562
Time Profiling563
Space Profiling566
Controlling Evaluation570
Strictness and Tail Recursion571
Adding Strictness572
Understanding Core575
Advanced Techniques:Fusion578
Tuning the Generated Assembly579
Conclusions580
26.Advanced Library Design:Building a Bloom Filter581
Introducing the Bloom Filter581
Use Cases and Package Layout582
Basic Design583
Unboxing,Lifting,and Bottom583
The ST Monad584
Designing an API for Qualified Import585
Creating a Mutable Bloom Filter586
The Immutable API587
Creating a Friendly Interface588
Re-Exporting Names for Convenience589
Hashing Values589
Turning Two Hashes into Many593
Implementing the Easy Creation Function593
Creating a Cabal Package595
Dealing with Different Build Setups596
Compilation Options and Interfacing to C598
Testing with QuickCheck599
Polymorphic Testing600
Writing Arbitrary Instances for ByteStrings601
Are Suggested Sizes Correct?602
Performance Analysis and Tuning604
Profile-Driven Performance Tuning605
27.Sockets and Syslog611
Basic Networking611
Communicating with UDP611
UDP Client Example:syslog612
UDP Syslog Server615
Communicating with TCP616
Handling Multiple TCP Streams616
TCP Syslog Server617
TCP Syslog Client619
28.Software Transactional Memory623
The Basics623
Some Simple Examples624
STM and Safety626
Retrying a Transaction626
What Happens When We Retry?628
Choosing Between Alternatives628
Using Higher Order Code with Transactions628
I/O and STM629
Communication Between Threads630
A Concurrent Web Link Checker631
Checking a Link633
Worker Threads634
Finding Links635
Command-Line Parsing636
Pattern Guards637
Practical Aspects of STM638
Getting Comfortable with Giving Up Control638
Using Invariants639
A.Installing GHCand Haskell Libraries641
B.Characters,Strings,and Escaping Rules649
Index655