0% found this document useful (0 votes)
39 views

Stylish F# 6: Crafting Elegant Functional Code for .NET 6 Kit Eason instant download

Stylish F# 6: Crafting Elegant Functional Code for .NET 6 by Kit Eason is a comprehensive guide focused on writing functional code in F#. The book covers various topics, including function design, handling missing data, collection functions, immutability, and pattern matching. It is aimed at developers looking to enhance their coding style and efficiency in .NET 6.

Uploaded by

vilanioret
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Stylish F# 6: Crafting Elegant Functional Code for .NET 6 Kit Eason instant download

Stylish F# 6: Crafting Elegant Functional Code for .NET 6 by Kit Eason is a comprehensive guide focused on writing functional code in F#. The book covers various topics, including function design, handling missing data, collection functions, immutability, and pattern matching. It is aimed at developers looking to enhance their coding style and efficiency in .NET 6.

Uploaded by

vilanioret
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Stylish F# 6: Crafting Elegant Functional Code

for .NET 6 Kit Eason pdf download

https://ebookmeta.com/product/stylish-f-6-crafting-elegant-
functional-code-for-net-6-kit-eason/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

ASP NET Core 6 Succinctly Dirk Strauss

https://ebookmeta.com/product/asp-net-core-6-succinctly-dirk-
strauss/

Effective Go: Elegant, Efficient, and Testable Code


(MEAP Version 3) 1 / chapter 1 to 6 of 8 Edition Inanc
Gumus

https://ebookmeta.com/product/effective-go-elegant-efficient-and-
testable-code-meap-version-3-1-chapter-1-to-6-of-8-edition-inanc-
gumus/

The easiest way to learn design patterns With C code


samples using NET 6 templates Fiodar Sazanavets

https://ebookmeta.com/product/the-easiest-way-to-learn-design-
patterns-with-c-code-samples-using-net-6-templates-fiodar-
sazanavets/

An Introduction to Programming Languages: Simultaneous


Learning in Multiple Coding Environments 1st Edition
Paul A. Gagniuc

https://ebookmeta.com/product/an-introduction-to-programming-
languages-simultaneous-learning-in-multiple-coding-
environments-1st-edition-paul-a-gagniuc/
Five Dates Between Friends 1st Edition Erin Thomson

https://ebookmeta.com/product/five-dates-between-friends-1st-
edition-erin-thomson/

Bring the War Home The White Power Movement and


Paramilitary America First Edition Kathleen Belew

https://ebookmeta.com/product/bring-the-war-home-the-white-power-
movement-and-paramilitary-america-first-edition-kathleen-belew/

The Green Hedge Witch 2nd Edition Rae Beth

https://ebookmeta.com/product/the-green-hedge-witch-2nd-edition-
rae-beth/

Sorrentino's Canadian Textbook for the Support Worker


Mary J. Wilk

https://ebookmeta.com/product/sorrentinos-canadian-textbook-for-
the-support-worker-mary-j-wilk/

Writing Research Proposals for Social Sciences and


Humanities in a Higher Education Context 1st Edition
George Damaskinidis

https://ebookmeta.com/product/writing-research-proposals-for-
social-sciences-and-humanities-in-a-higher-education-context-1st-
edition-george-damaskinidis/
Essential Astrophysics: Interstellar Medium to Stellar
Remnants 1st Edition Shantanu Basu

https://ebookmeta.com/product/essential-astrophysics-
interstellar-medium-to-stellar-remnants-1st-edition-shantanu-
basu/
Stylish
F# 6
Crafting Elegant Functional Code
for .NET 6

Second Edition

Kit Eason
Stylish F# 6
Crafting Elegant Functional
Code for .NET 6
Second Edition

Kit Eason
Stylish F# 6: Crafting Elegant Functional Code for .NET 6
Kit Eason
Farnham, Surrey, UK

ISBN-13 (pbk): 978-1-4842-7204-6 ISBN-13 (electronic): 978-1-4842-7205-3


https://doi.org/10.1007/978-1-4842-7205-3

Copyright © 2022 by Kit Eason


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Joan Murray
Development Editor: Laura Berendson
Coordinating Editor: Jill Balzano
Cover image designed by Kit Eason, based on data courtesy of NYC Open Data
Distributed to the book trade worldwide by Springer Science+Business Media LLC, 1 New York Plaza, Suite
4600, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.
com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner)
is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484272046. For more
detailed information, please visit http://www.apress.com/source-­code.
Printed on acid-free paper
To Val, Matt, Meg, Kate, Andy, Noah, and Darwin:
my own persistent collection.
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv

About the Technical Reviewer�������������������������������������������������������������������������������xvii


Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Chapter 1: The Sense of Style����������������������������������������������������������������������������������� 1


Why a Style Guide?����������������������������������������������������������������������������������������������������������������������� 1
Understanding Beats Obedience��������������������������������������������������������������������������������������������������� 2
Good Guidance from Bad Code����������������������������������������������������������������������������������������������������� 2
What About Testability?����������������������������������������������������������������������������������������������������������������� 8
Complexity Explosions������������������������������������������������������������������������������������������������������������������ 8
Summary�������������������������������������������������������������������������������������������������������������������������������������� 9

Chapter 2: Designing Functions Using Types���������������������������������������������������������� 11


Miles and Yards (No, Really!)������������������������������������������������������������������������������������������������������� 11
Converting Miles and Yards to Decimal Miles����������������������������������������������������������������������� 12
How to Design a Function����������������������������������������������������������������������������������������������������������� 13
Sketch the Signature of the Function������������������������������������������������������������������������������������ 14
Naively Code the Body of the Function���������������������������������������������������������������������������������� 14
Review the Signature for Type Safety������������������������������������������������������������������������������������ 15
Review and Refine����������������������������������������������������������������������������������������������������������������� 19
A Final Polish������������������������������������������������������������������������������������������������������������������������������ 21
Recommendations���������������������������������������������������������������������������������������������������������������������� 23
Summary������������������������������������������������������������������������������������������������������������������������������������ 24
Exercises������������������������������������������������������������������������������������������������������������������������������������� 24
Exercise Solutions����������������������������������������������������������������������������������������������������������������������� 25

v
Table of Contents

Chapter 3: Missing Data����������������������������������������������������������������������������������������� 29


A Brief History of Null������������������������������������������������������������������������������������������������������������������ 29
Option Types vs. Null������������������������������������������������������������������������������������������������������������������� 32
Consuming Option Types������������������������������������������������������������������������������������������������������������� 34
Pattern Matching on Option Types����������������������������������������������������������������������������������������� 35
The Option Module���������������������������������������������������������������������������������������������������������������� 36
Option Type No-Nos��������������������������������������������������������������������������������������������������������������������� 43
Designing Out Missing Data�������������������������������������������������������������������������������������������������������� 44
Interoperating with the Nullable World��������������������������������������������������������������������������������������� 48
Leaking In of Null Values������������������������������������������������������������������������������������������������������� 48
Defining a SafeString Type���������������������������������������������������������������������������������������������������� 49
Using Option.ofObj����������������������������������������������������������������������������������������������������������������� 50
Using Option.ofNullable��������������������������������������������������������������������������������������������������������� 51
Leaking Option Types and DUs Out���������������������������������������������������������������������������������������� 52
Using Option.toObj����������������������������������������������������������������������������������������������������������������� 52
Using Option.toNullable��������������������������������������������������������������������������������������������������������� 53
The Future of Null������������������������������������������������������������������������������������������������������������������ 54
The ValueOption Type������������������������������������������������������������������������������������������������������������������ 55
Recommendations���������������������������������������������������������������������������������������������������������������������� 56
Summary������������������������������������������������������������������������������������������������������������������������������������ 56
Exercises������������������������������������������������������������������������������������������������������������������������������������� 57
Exercise Solutions����������������������������������������������������������������������������������������������������������������������� 58

Chapter 4: Working Effectively with Collection Functions�������������������������������������� 61


Anatomy of a Collection Function����������������������������������������������������������������������������������������������� 61
Picking the Right Collection Function����������������������������������������������������������������������������������������� 64
Detailed Collection Function Tables�������������������������������������������������������������������������������������������� 66
Practicing with Collection Functions������������������������������������������������������������������������������������������� 72
Exercise Setup����������������������������������������������������������������������������������������������������������������������� 72
Single Collection Function Exercises������������������������������������������������������������������������������������� 73
Multiple Collection Function Exercises���������������������������������������������������������������������������������� 77

vi
Table of Contents

Partial Functions������������������������������������������������������������������������������������������������������������������������� 80
Coding Around Partial Functions������������������������������������������������������������������������������������������� 82
Using the “try” Idiom for Partial Functions���������������������������������������������������������������������������� 84
Consuming Values from try… Functions������������������������������������������������������������������������������� 86
Try… Function Exercises������������������������������������������������������������������������������������������������������������ 86
Functions for Other Kinds of Collections������������������������������������������������������������������������������������� 87
When the Collection Function Is Missing������������������������������������������������������������������������������������ 88
Common Mistakes���������������������������������������������������������������������������������������������������������������������� 89
Recommendations���������������������������������������������������������������������������������������������������������������������� 93
Summary������������������������������������������������������������������������������������������������������������������������������������ 94
Exercise Solutions����������������������������������������������������������������������������������������������������������������������� 94

Chapter 5: Immutability and Mutation������������������������������������������������������������������� 99


These Folks Are Crazy!���������������������������������������������������������������������������������������������������������������� 99
Classic Mutable Style������������������������������������������������������������������������������������������������������������������ 99
Immutability Basics������������������������������������������������������������������������������������������������������������������� 101
Common Mutable Patterns������������������������������������������������������������������������������������������������������� 103
Linear Search���������������������������������������������������������������������������������������������������������������������� 104
Guarded Linear Search�������������������������������������������������������������������������������������������������������� 105
Process All Items����������������������������������������������������������������������������������������������������������������� 107
Repeat Until������������������������������������������������������������������������������������������������������������������������� 110
Find Extreme Value�������������������������������������������������������������������������������������������������������������� 112
Summarize a Collection������������������������������������������������������������������������������������������������������� 115
Recommendations�������������������������������������������������������������������������������������������������������������������� 117
Summary���������������������������������������������������������������������������������������������������������������������������������� 118
Exercises����������������������������������������������������������������������������������������������������������������������������������� 118
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 119

Chapter 6: Pattern Matching�������������������������������������������������������������������������������� 123


Weaving Software with Patterns����������������������������������������������������������������������������������������������� 123
Pattern Matching Basics����������������������������������������������������������������������������������������������������������� 123
When Guards����������������������������������������������������������������������������������������������������������������������������� 126
vii
Table of Contents

Pattern Matching on Arrays and Lists��������������������������������������������������������������������������������������� 127


Pattern Matching on Tuples������������������������������������������������������������������������������������������������������ 129
Pattern Matching on Records��������������������������������������������������������������������������������������������������� 130
Pattern Matching on Discriminated Unions������������������������������������������������������������������������������ 133
Pattern Matching on DUs in Function Parameters�������������������������������������������������������������������� 135
Pattern Matching in Let Bindings���������������������������������������������������������������������������������������������� 138
Revisiting Single-Case Discriminated Unions��������������������������������������������������������������������������� 139
Pattern Matching in Loops and Lambdas��������������������������������������������������������������������������������� 141
Pattern Matching and Enums���������������������������������������������������������������������������������������������������� 142
Active Patterns�������������������������������������������������������������������������������������������������������������������������� 144
Single-Case Active Patterns������������������������������������������������������������������������������������������������ 144
Multicase Active Patterns���������������������������������������������������������������������������������������������������� 146
Partial Active Patterns��������������������������������������������������������������������������������������������������������� 147
Parameterized Active Patterns�������������������������������������������������������������������������������������������� 149
Pattern Matching with “&”�������������������������������������������������������������������������������������������������������� 150
Pattern Matching on Types�������������������������������������������������������������������������������������������������������� 151
Pattern Matching on Null���������������������������������������������������������������������������������������������������������� 153
Recommendations�������������������������������������������������������������������������������������������������������������������� 154
Summary���������������������������������������������������������������������������������������������������������������������������������� 156
Exercises����������������������������������������������������������������������������������������������������������������������������������� 157
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 160

Chapter 7: Record Types��������������������������������������������������������������������������������������� 165


Winning with Records��������������������������������������������������������������������������������������������������������������� 165
Record Type Basics������������������������������������������������������������������������������������������������������������������� 165
Record Types and Immutability������������������������������������������������������������������������������������������������� 167
Default Constructors, Setters, and Getters�������������������������������������������������������������������������������� 169
Records vs. Classes������������������������������������������������������������������������������������������������������������������ 169
Structural Equality by Default���������������������������������������������������������������������������������������������� 170
Records as Structs�������������������������������������������������������������������������������������������������������������� 173
Mapping from Instantiation Values to Members������������������������������������������������������������������ 175

viii
Table of Contents

Records Everywhere?��������������������������������������������������������������������������������������������������������������� 176


Pushing Records to the Limit���������������������������������������������������������������������������������������������������� 177
Generic Records������������������������������������������������������������������������������������������������������������������ 178
Recursive Records��������������������������������������������������������������������������������������������������������������� 179
Records with Methods��������������������������������������������������������������������������������������������������������� 180
Records with Methods – A Good Idea?�������������������������������������������������������������������������������� 183
Anonymous Records����������������������������������������������������������������������������������������������������������������� 184
Anonymous and Named Record Terminology���������������������������������������������������������������������� 186
Anonymous Records and Comparison��������������������������������������������������������������������������������� 186
“Copy and Update” on Anonymous Records������������������������������������������������������������������������ 189
Serialization and Deserialization of Anonymous Records��������������������������������������������������� 190
Anonymous Records in Type Hints�������������������������������������������������������������������������������������� 192
Struct Anonymous Records������������������������������������������������������������������������������������������������� 192
Anonymous Records and C#������������������������������������������������������������������������������������������������ 193
Pattern Matching on Anonymous Records�������������������������������������������������������������������������� 193
Adding Methods to Anonymous Records����������������������������������������������������������������������������� 194
Mutation and Anonymous Records�������������������������������������������������������������������������������������� 194
Record Layout��������������������������������������������������������������������������������������������������������������������������� 195
Recommendations�������������������������������������������������������������������������������������������������������������������� 196
Summary���������������������������������������������������������������������������������������������������������������������������������� 198
Exercises����������������������������������������������������������������������������������������������������������������������������������� 198
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 200

Chapter 8: Classes������������������������������������������������������������������������������������������������ 205


The Power of Classes���������������������������������������������������������������������������������������������������������������� 205
Additional Constructors������������������������������������������������������������������������������������������������������������� 215
Values As Members������������������������������������������������������������������������������������������������������������������� 217
Simple Mutable Properties�������������������������������������������������������������������������������������������������������� 219
Member Getters and Setters with Bodies��������������������������������������������������������������������������������� 220
Named Parameters and Object Initialization Syntax����������������������������������������������������������������� 222
Indexed Properties�������������������������������������������������������������������������������������������������������������������� 223

ix
Table of Contents

Interfaces���������������������������������������������������������������������������������������������������������������������������������� 226
Object Expressions�������������������������������������������������������������������������������������������������������������������� 232
Abstract Classes����������������������������������������������������������������������������������������������������������������������� 235
Abstract Members��������������������������������������������������������������������������������������������������������������� 235
Default Member Implementations��������������������������������������������������������������������������������������� 236
Class Equality and Comparison������������������������������������������������������������������������������������������������� 237
Implementing Equality��������������������������������������������������������������������������������������������������������� 237
Implementing Comparison�������������������������������������������������������������������������������������������������� 243
Recommendations�������������������������������������������������������������������������������������������������������������������� 246
Summary���������������������������������������������������������������������������������������������������������������������������������� 246
Exercises����������������������������������������������������������������������������������������������������������������������������������� 248
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 249

Chapter 9: Programming with Functions�������������������������������������������������������������� 253


Functions First�������������������������������������������������������������������������������������������������������������������������� 253
Functions as Values������������������������������������������������������������������������������������������������������������������ 253
Currying and Partial Application����������������������������������������������������������������������������������������������� 255
Mixing Tupled and Curried Styles���������������������������������������������������������������������������������������������� 257
Function Signatures Revisited�������������������������������������������������������������������������������������������������� 259
Type Hints for Functions����������������������������������������������������������������������������������������������������������� 260
Functions That Return Functions���������������������������������������������������������������������������������������������� 262
Function Composition��������������������������������������������������������������������������������������������������������������� 265
Recommendations�������������������������������������������������������������������������������������������������������������������� 268
Summary���������������������������������������������������������������������������������������������������������������������������������� 269
Exercises����������������������������������������������������������������������������������������������������������������������������������� 269
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 272

Chapter 10: Asynchronous and Parallel Programming����������������������������������������� 275


Ordering Pizza��������������������������������������������������������������������������������������������������������������������������� 275
A World Without Async�������������������������������������������������������������������������������������������������������������� 276
Running the Synchronous Downloader������������������������������������������������������������������������������������� 282
Converting Code to Asynchronous�������������������������������������������������������������������������������������������� 284
x
Table of Contents

Locking Shared Resources������������������������������������������������������������������������������������������������������� 290


Testing Asynchronous Downloads�������������������������������������������������������������������������������������������� 291
Batching������������������������������������������������������������������������������������������������������������������������������������ 292
Throttling����������������������������������������������������������������������������������������������������������������������������������� 297
C# Task vs. F# Async����������������������������������������������������������������������������������������������������������������� 299
F# Tasks������������������������������������������������������������������������������������������������������������������������������������ 301
Recommendations�������������������������������������������������������������������������������������������������������������������� 304
Summary���������������������������������������������������������������������������������������������������������������������������������� 305
Exercises����������������������������������������������������������������������������������������������������������������������������������� 306
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 307

Chapter 11: Railway Oriented Programming�������������������������������������������������������� 311


Going Off the Rails�������������������������������������������������������������������������������������������������������������������� 311
On the Factory Floor������������������������������������������������������������������������������������������������������������������ 312
Adapting Functions for Failure�������������������������������������������������������������������������������������������������� 316
Writing a Bypass Adapter���������������������������������������������������������������������������������������������������������� 317
Writing a Pass-Through Adapter����������������������������������������������������������������������������������������������� 318
Building the Production Line����������������������������������������������������������������������������������������������������� 319
Making It Official����������������������������������������������������������������������������������������������������������������������� 323
Love Your Errors������������������������������������������������������������������������������������������������������������������������ 324
Recommendations�������������������������������������������������������������������������������������������������������������������� 328
Summary���������������������������������������������������������������������������������������������������������������������������������� 329
Exercises����������������������������������������������������������������������������������������������������������������������������������� 330
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 333

Chapter 12: Performance�������������������������������������������������������������������������������������� 337


Design Is Compromise�������������������������������������������������������������������������������������������������������������� 337
Some Case Studies������������������������������������������������������������������������������������������������������������������� 338
BenchmarkDotNet��������������������������������������������������������������������������������������������������������������������� 338
Case Study: Inappropriate Collection Types������������������������������������������������������������������������������ 340
Avoiding Indexed Access to Lists���������������������������������������������������������������������������������������� 343

xi
Table of Contents

Using Arrays Instead of Lists����������������������������������������������������������������������������������������������� 345


Use Sequences Instead of Arrays���������������������������������������������������������������������������������������� 346
Avoiding Collection Functions��������������������������������������������������������������������������������������������� 347
Avoiding Loops Having Skips����������������������������������������������������������������������������������������������� 349
Inappropriate Collection Types – Summary������������������������������������������������������������������������� 350
Case Study: Short-Term Objects����������������������������������������������������������������������������������������������� 352
Sequences Instead of Arrays����������������������������������������������������������������������������������������������� 355
Avoiding Object Creation����������������������������������������������������������������������������������������������������� 356
Reducing Tuples������������������������������������������������������������������������������������������������������������������ 357
Using Struct Tuples�������������������������������������������������������������������������������������������������������������� 358
Operator Choice������������������������������������������������������������������������������������������������������������������� 360
Short-Term Objects – Summary������������������������������������������������������������������������������������������ 362
Case Study: Naive String Building��������������������������������������������������������������������������������������������� 364
StringBuilder to the Rescue������������������������������������������������������������������������������������������������� 366
Using String.Join����������������������������������������������������������������������������������������������������������������� 367
Using Array.Parallel.map������������������������������������������������������������������������������������������������������ 368
Using String Interpolation���������������������������������������������������������������������������������������������������� 370
Naive String Building – Summary��������������������������������������������������������������������������������������� 371
Other Common Performance Issues����������������������������������������������������������������������������������������� 372
Searching Large Collections������������������������������������������������������������������������������������������������ 372
Comparison Operators and DateTimes�������������������������������������������������������������������������������� 372
Concatenating Lists������������������������������������������������������������������������������������������������������������� 372
For-Loop with Unexpected List Creation������������������������������������������������������������������������������ 372
F# and Span Support���������������������������������������������������������������������������������������������������������������� 373
The Importance of Tests������������������������������������������������������������������������������������������������������������ 373
Recommendations�������������������������������������������������������������������������������������������������������������������� 375
Summary���������������������������������������������������������������������������������������������������������������������������������� 376
Exercises����������������������������������������������������������������������������������������������������������������������������������� 377
Exercise Solutions��������������������������������������������������������������������������������������������������������������������� 380

xii
Table of Contents

Chapter 13: Layout and Naming��������������������������������������������������������������������������� 383


Where Are My Braces?�������������������������������������������������������������������������������������������������������������� 383
It’s Okay Pluto, I’m Not a Planet Either�������������������������������������������������������������������������������������� 384
Some Infelicitous Code������������������������������������������������������������������������������������������������������������� 386
Convenience Functions������������������������������������������������������������������������������������������������������������� 390
Column Extraction Functions���������������������������������������������������������������������������������������������������� 391
The Observation Range Type����������������������������������������������������������������������������������������������������� 393
The Importance of Alignment���������������������������������������������������������������������������������������������������� 395
The Minor Planet Type��������������������������������������������������������������������������������������������������������������� 397
Recommendations�������������������������������������������������������������������������������������������������������������������� 404
Summary���������������������������������������������������������������������������������������������������������������������������������� 405
Exercise������������������������������������������������������������������������������������������������������������������������������������ 406
Exercise Solution���������������������������������������������������������������������������������������������������������������������� 407

Chapter 14: Summary������������������������������������������������������������������������������������������� 409


F# and the Sense of Style��������������������������������������������������������������������������������������������������������� 409
Designing Functions with Types������������������������������������������������������������������������������������������������ 409
Missing Data����������������������������������������������������������������������������������������������������������������������������� 410
Collection Functions������������������������������������������������������������������������������������������������������������������ 410
Immutability and Mutation�������������������������������������������������������������������������������������������������������� 411
Pattern Matching���������������������������������������������������������������������������������������������������������������������� 411
Record Types����������������������������������������������������������������������������������������������������������������������������� 411
Classes�������������������������������������������������������������������������������������������������������������������������������������� 412
Programming with Functions���������������������������������������������������������������������������������������������������� 412
Asynchronous and Parallel Programming��������������������������������������������������������������������������������� 413
Railway Oriented Programming������������������������������������������������������������������������������������������������ 414
Performance����������������������������������������������������������������������������������������������������������������������������� 414
Layout and Naming������������������������������������������������������������������������������������������������������������������� 415
Onward!������������������������������������������������������������������������������������������������������������������������������������ 416

Index��������������������������������������������������������������������������������������������������������������������� 417

xiii
About the Author
Kit Eason is a software developer and educator with more than 20 years of experience.
He has been programming in F# since 2011 and is employed at Perpetuum Ltd., working
on an extensive network of energy-harvesting vibration sensors fitted to railway rolling
stock and infrastructure. Kit is an avid F# user who is passionate about teaching others.
He has contributed to several publications, including the Apress book “Beginning F#.”
He often teaches on the topic of F#, and his popular videos appear on Udemy and
Pluralsight.

xv
About the Technical Reviewer
Stachu Korick stumbled upon F# in 2014 and instantly
fell in love with both the language and the surrounding
community. Most importantly, he met his wife Olya after
speaking on F# at a local .NET conference near Philadelphia.
As time allows, he works on an F# podcast WTF# (https://
wtfsharp.com). Beyond software, Stachu spends his time as
an amateur woodworker, playing with his cats, practicing
chemistry, or jotting down bits of lyrics to eventually
compose into music.

xvii
Other documents randomly have
different content
FACTUM

POUR Mademoiselle PETIT, Danseuse de l'Opéra, révoquée,


Complaignante au Public.

MESSIEURS,

C'EST avec autant de douleur que de honte que je me vois réduite à


emprunter la plume d'un ami, pour me défendre contre mes
persécuteurs, & contre mon Accusatrice. J'espere encore assez des
uns, & je méprise trop l'autre pour les nommer. Le Public les
connoît: il sera notre Juge. Je suis cette Danseuse qu'on a, dit-on,
surprise sous le théâtre de l'Opéra, telle que Vénus & Mars furent
exposés aux yeux de l'Olympe assemblé dans les Rets de Vulcain. Le
témoin prétendu de mon infamie ressemble assez par la noirceur de
son teint, & la difformité de sa taille, à ce Chef des Cyclopes. Son
ame est bien digne du corps qu'elle occupe; elle a tous les vices de
son état, & n'en a pas les vertus.
Il est d'usage parmi nous de s'accorder une indulgence réciproque
en matiere de galanterie. Cette discrétion politique est absolument
nécessaire à l'intérêt commun. Sans cela nous serions tour à tour les
dupes de nos vengeances, & les hommes cesseroient d'être les
nôtres. J'avouerai que je ne voulois entrer à l'Opéra que dans la vue
d'imiter mes Compagnes, & d'arriver comme elles au bonheur par la
route du plaisir. Je suis jeune, bien faite & d'une assez jolie figure:
j'ai les yeux petits, mais vifs, & ma mere, qui s'y connoît, dit qu'ils en
valent bien de plus grands.
Tous mes amis solliciterent donc pour moi une place dans les
Chœurs, & je l'obtins à force de crédit. Je comptai dès-lors ma
fortune assurée. Nous sommes sur le théâtre ce que les Fermiers-
Généraux sont dans les Finances. La plupart commencent avec rien,
nous commençons de même. Ils s'intéressent dans plus d'une
affaire, nous n'avons jamais pour une intrigue. Ils doivent l'alliance
des Grands à leurs richesses, nous la devons à nos appas. Ils
sacrifient leurs amis à l'intérêt, nous lui sacrifions nos amans. Un
trait de plume leur vaut cent mille livres, une faveur accordée nous
en vaut quelquefois davantage. Ils font des traités captieux, les
nôtres sont équivoques. Le goût du plaisir nous mene à la
prodigalité, le faste les rend dissipateurs. Deux choses nous
différencient; ils s'endurcissent pour thésauriser, nous nous
attendrissons pour nous enrichir: ceux qu'ils ruinent les maudissent,
ceux que nous ruinons nous adorent. Vous voyez, Messieurs, que je
connoissois toutes les prérogatives de ma place, & j'aurois bientôt
acquis le peu qui me manquoit pour la remplir dignement. J'ai peu
d'esprit, mais en faut-il beaucoup quand on a le reste? Et d'ailleurs le
théâtre n'en donne-t-il pas? Hélas! j'en aurois comme les autres sans
la malheureuse aventure que la calomnie m'impute pour m'en
enlever de brillantes. Je vais, Messieurs, vous exposer le fait qui a
servi de base aux impostures de mon Accusatrice.
J'arrivai sur les trois heures à l'Opéra avec ma Coëffeuse; le Tailleur
étoit dans la loge. M. ...., protecteur né de toutes les Filles qui
commencent, étoit venu assister à ma petite toilette, & me débitoit
mille jolies choses sur l'éclat de mon teint, la blancheur de ma peau
& la finesse de ma taille. J'écoutois avec plaisir ce qu'il me disoit
avec confiance; un usage de vingt ans donne bien de la facilité pour
le débit. M. de ..... qui passa vis-à-vis de ma loge, m'apperçut, & me
souhaita le bon jour; je lui répondis en Fille bien née: un homme de
qualité ne veut pas être en reste de politesse; il entra dans la loge,
& me dit des folies auxquelles je répliquai avec sagesse. Enfin il
poursuivit sa plaisanterie, la conversation s'anima, & nous nous
donnâmes en badinant quelques coups: j'avois eu le dernier, je
courus après lui dans le dessein de me venger: il me demanda
grace, & me baisa la main: je m'appaisai. La Jaquet qui passa dans
cet instant, feignit de prendre les préliminaires pour la chose même.
Elle alla sur le théâtre annoncer ses lubriques visions à Mademoiselle
Cartou qui refusa de la croire, & qui lui conseilla chrétiennement, la
chose supposée vraie, d'en supprimer le scandale qui ne pouvoit
manquer de rejaillir sur tout le Corps. Les méchans n'écoutent point
de conseils; elle raconta le fait à des esprits moins bons, & plus
crédules sur le compte du prochain. Quand je parus dans les
coulisses, on vint me regarder, on se parla bas, on rit sous cape. Je
m'apperçus que j'étois l'objet de tout ce manege: j'en demandai la
raison, & je l'appris avec toute l'indignation que donne le
témoignage de la conscience contre la calomnie. M. de T..., galant
homme, mais subordonné, fut informé de l'histoire par une femme
qu'il est obligé de croire, lors même qu'elle ment, & je fus sacrifiée à
sa haine, que j'ai encourue sans l'avoir jamais méritée.
Voilà le fait tel qu'il s'est passé; examinons maintenant quel ordre on
a observé dans l'arrêt de ma proscription, unus testis, testis nullus.
Un seul témoin ne fait point de témoignage. La Loi est formelle &
triomphante en ma faveur. Je n'ai contre moi qu'un témoin, encore
est-ce une Fille, & quelle Fille, Messieurs! Il me faudroit toute son
impudence pour détailler l'histoire de sa vie. Ce que je vous dois,
Messieurs, aussi bien qu'à mon sexe, ne me permet pas de
l'entreprendre. Il me suffit de vous dire que son amant lui-même
l'avoit quittée il y a environ un an. M. Pibrac sçait bien pourquoi:
mais ces Messieurs se taisent par devoir, & je me tais par
bienséance. Si ma Partie avoit pensé comme moi, je ne me verrois
pas aujourd'hui forcée à la noircir pour me justifier. Tel est,
Messieurs, ce témoin qui dépose contre moi; voyons si ceux qui
m'innocentent ne méritent pas au moins de balancer sa déposition.
Le Tailleur de la loge ne m'a pas quittée, & il nie le fait. Mais, me
dira-t-on, 1o. vous avez acheté son silence. Qu'on prouve la
subornation. L'on a menacé le pauvre homme de le chasser: il a
persisté dans la négative, & je ne suis assurément pas dans le cas
de le dédommager de son emploi s'il venoit à le perdre. 2o. Sept
autres témoins oculaires déposent contre vous.
Qu'on me les produise ces témoins, qu'ils se présentent devant moi
pour me confondre par une déposition unanime & circonstanciée.
Suffit-il donc d'annoncer des témoins pour condamner un Accusé? La
Loi n'exige-t-elle pas qu'ils soient confrontés avec lui, afin qu'il
puisse infirmer leur témoignage, s'il se trouve faux, ou qu'il soit forcé
à l'aveu du crime s'il est coupable?

3o. La Coëffeuse est d'une profession suspecte, & elle est à vos
gages.
R. Elle n'est point à mes gages, & quand cela seroit, en matiere
criminelle le témoignage des Domestiques est reçu dans les
Tribunaux. Sa profession à la vérité est suspecte, mais sa personne
ne l'est pas, & sa déposition est d'un tout autre poids que celle de
ma Partie, dont heureusement pour moi les histoires sont avérées.
M. de ....., décoré des honneurs militaires, & connu par sa probité,
est-il aussi un témoin suspect de vénalité? N'avoit-il pas des raisons,
non-seulement pour m'abandonner, mais pour être le plus cruel de
mes ennemis si j'avois été coupable? Il est cependant le premier & le
plus ardent de mes Défenseurs. Il a vu arriver M. de .....: il a
entendu ses propos & mes réponses: il a été témoin de mes actions,
rien de tout ce qui s'est passé entre nous ne lui a échappé. Un
témoignage de cette espece, est, je crois, victorieux, & doit rejetter
sur mon Accusatrice toute l'infamie dont elle a voulu me couvrir. Je
ne demande point à rentrer à l'Opéra: il ne faut pas même que la
femme de César soit soupçonnée: j'aurois trop à rougir de cette
affreuse intrigue. Mais, Messieurs, j'exige un acte de justice de votre
part que vous ne sçauriez me refuser. Si la calomnie est avérée,
sifflez mon ennemie: que vos avanies la forcent à chercher les
ténèbres, asyles du crime. Elle est en Chanteuse ce que je suis en
Danseuse; vous perdrez peu à ses talens, & vous aurez la
satisfaction d'être les vengeurs de l'innocence opprimée. Signée,
PETIT.
Cette Piece est de feu M. l'Abbé DE LA MARRE, Auteur de l'Opéra de
Zaïde.
ANECDOTES,
Reparties, Traits singuliers, &c.

IL étoit très-ordinaire au Barreau, jusqu'au milieu du dix-septieme


siecle, de dire avec emphase des choses triviales, & de surcharger
les causes d'une foule de citations étrangeres. C'est cette affectation
que Racine a si bien jouée dans sa Comédie des Plaideurs; l'Intimé
qui est dans cette Piece l'habile Avocat, commence ainsi son
plaidoyer;
Messieurs, tout ce qui peut effrayer un
coupable;
Tout ce que les mortels ont de plus redoutable,
&c.
C'est une Parodie de l'Exorde de Cicéron pro Quintio. Un Avocat en
plaidant pour un Pâtissier contre un Boulanger, s'étoit servi du même
Exorde, & c'est ce qui donna lieu à la plaisanterie de Racine. Le
plaidoyer de Petit-Jean est une critique des Orateurs qui s'égaroient
dans des dissertations étrangeres à leur sujet.
Ce défaut est beaucoup plus ancien que le Barreau françois. Martial
s'en plaint dans une jolie Epigramme. Lib. VI, Ep. 19.

Non de vi, neque cæde, nec veneno,


Sed lis est mihi de tribus capellis.
Vicini queror has abesse furto.
Hoc Judex sibi postulat probari.
Tu Cannas, Mithridaticumque bellum
Et perjuria Punici furoris,
Et Syllas, Mariosque, Mutiosque
Magnâ voce sonas, manuque totâ.
Jam dic, Postume, de tribus capellis.

On ne sera peut-être pas fâché de voir de quelle maniere M. de la


Monnoie a rendu cette Epigramme.

Pour trois moutons qu'on m'avoit pris


J'avois un Procès au Bailliage.
Gui, le phénix des beaux esprits,
Plaidoit ma cause & faisoit rage.
Quand il eut dit un mot du fait,
Pour exagérer le forfait,
Il cita la Fable & l'Histoire,
Les Aristotes, les Platons.
Gui, laissez-là tout ce grimoire
Et revenez à vos moutons.

Un Avocat, homme d'esprit, fit sentir le même ridicule à son


Adversaire, qui dans une affaire où il s'agissoit d'un mur mitoyen,
parloit de la guerre de Troye & du Scamandre; il l'interrompit, en
disant: la Cour observera que ma Partie ne s'appelle pas Scamandre,
mais Michault.

Le Premier Président du Parlement de Paris demanda un jour à Me


Montauban, Avocat, s'il seroit long: Oui, Monsieur, répondit-il; du
moins, reprit le Magistrat, vous êtes de bonne foi. Racine a encore
fait usage de ce trait dans les Plaideurs.
Un Avocat, qui défend une cause, se voit souvent dans la nécessité
d'employer toutes sortes de moyens, parce que chaque Juge a son
principe, bon ou mauvais, suivant lequel il se décide. Dumont,
célebre Avocat, persuadé de cette vérité, plaidoit un jour à la
Grand'Chambre, & mêloit à des moyens victorieux, d'autres moyens
foibles ou captieux. Après l'Audience le Premier Président lui en fit
des reproches: M. le Président, lui répondit-il, un tel moyen est pour
M. un tel; cet autre, pour M. un tel. Après quelques séances l'affaire
fut jugée, & Me Dumont gagna sa cause. Le Premier Président
l'appella, & lui dit: Me Dumont, vos paquets ont été rendus à leur
adresse.

Un Premier Président demandoit à Me Langlois, pourquoi il se


chargeoit souvent de mauvaises causes: Monsieur, lui répondit
l'Avocat, j'en ai tant perdu de bonnes que je ne sçais plus lesquelles
prendre.

Un Avocat célebre s'étoit chargé de défendre des Bateleurs &


Farceurs, qui avoient un procès; le Premier Président lui marqua de
la surprise de ce qu'il plaidoit pour de telles gens: Monsieur, répondit
l'Avocat, j'ai cru que puisque la Cour avoit bien voulu leur donner
audience, je pouvois plaider pour eux.

Un Magistrat de beaucoup de réputation qui, par timidité ou par


défaut de mémoire, n'avoit jamais pu venir à bout de prononcer de
suite un discours, interrompit un jour un Avocat qui plaidoit devant
lui; l'Avocat, piqué, lui dit malignement: vous m'interrompez,
Monsieur, quoique vous sçachiez bien la peine qu'il y a de parler en
public.
Un Avocat, dont le plaidoyer paroissoit trop étendu pour la cause
qu'il défendoit, avoit reçu ordre du Premier Président d'abréger; mais
celui-ci, sans rien retrancher, répondit d'un ton ferme, que tout ce
qu'il disoit étoit essentiel. Le Président espérant enfin le faire taire,
lui dit; la Cour vous ordonne de conclure: hé bien, repartit l'Avocat,
je conclus à ce que la Cour m'entende.

M. Fourcroy, Avocat célebre, plaidoit: les Juges prévenus que sa


cause étoit mauvaise, se leverent pour aller aux opinions; dans le
tems qu'ils opinoient, l'Avocat crioit de tems en tems, M. le
Président: à la fin ce Magistrat se tourna, & lui dit, d'un ton fort sec,
que voulez-vous, Avocat? je demande acte à la Cour, répondit
l'Avocat, du refus qu'elle fait de m'entendre, afin que je puisse me
justifier envers ma Partie, qui est à cent lieues d'ici. Cette demande
frappa les Juges: ils reprirent leurs places pour donner audience à
l'Avocat, qui, ramassant tout ce qu'il avoit de force & de feu, plaida
avec tant d'éloquence qu'il gagna la cause.

Dans la cause d'un Grand-Chantre, à qui quelques Chanoines, dont il


avoit troublé le sommeil pendant l'office, vouloient contester la
police du Chœur; l'Avocat qui plaidoit pour le Chantre, s'apperçut
que les Juges se livroient eux-mêmes au sommeil; il feignit alors
d'apostropher les Chanoines, ses Adversaires, & cria d'une voix
forte: quoi, Messieurs, vous dormirez, & il ne me sera pas permis de
vous rappeller à vos fonctions? L'apostrophe eut un double effet, elle
réveilla l'Auditoire, & l'Avocat gagna sa cause.

Un Avocat de Toulouse, nommé Adam, faisoit les harangues que


devoit prononcer un Président. Cet Avocat fut obligé de faire un
voyage à Paris: pendant son absence, le Président eut une harangue
à faire, qu'il composa le mieux qu'il put; comme il la prononçoit, un
Conseiller qui le vit embarrassé cita ces paroles de la Genese, Adam,
ubi es? Adam, où es-tu?

Un Avocat au Parlement de Grenoble, qui plaidoit contre les


Religieux de la grande Chartreuse, commença ainsi: Messieurs, je
parle contre les pauvres Religieux du desert S. Bruno, Marquis de
Mirebel, Comtes d'Entremont, Barons de Vaurex & Seigneurs de
beaucoup d'autres lieux.

M. B...., Avocat à ...., possédoit une petite terre, voisine d'une autre
qui appartenoit au Procureur Général du Parlement de B.... Pendant
le cours d'une vacance, l'Avocat profitant des droits du voisinage,
alla rendre une visite au Magistrat, qu'il trouva dans son cabinet;
après les premiers complimens il s'assit & continua la conversation.
Au bout de quelque tems il mit son chapeau sur sa tête & se permit
d'user de la liberté de la campagne; mais M. le Procureur Général
crut que c'étoit une licence, & voulant la lui faire sentir: les tems
sont bien changés, lui dit-il doctoralement; les Avocats autrefois ne
s'asseyoient ni ne se couvroient en présence d'un Procureur Général.
Vous m'étonnez beaucoup, Monsieur, reprit vivement M. B... vous
parlez, sans doute, d'un tems où les Avocats n'avoient ni cul ni tête.
Cette plaisanterie désarma la morgue campagnarde du Magistrat: en
effet, plusieurs Souverains auroient invité Me Charles Dumoulin à
s'asseoir devant eux, & ils n'auroient pas cru déroger à leur dignité.

Un Avocat du siecle dernier, chargé de défendre la cause d'un


homme sur le compte duquel on vouloit mettre un enfant, se jettoit
dans des digressions étrangeres à son sujet: le Juge ne cessoit de lui
dire, au fait, venez au fait, un mot du fait; l'Avocat impatienté de la
leçon, termina brusquement son plaidoyer: en disant; le fait est un
enfant fait, celui qu'on dit l'avoir fait, nie le fait: voilà le fait.
Pé Fournier étoit borgne: plaidant un jour, il mit ses lunettes pour
lire une piece, & dit, Messieurs, je ne produirai rien qui ne soit
nécessaire; l'Avocat adverse lui répliqua, commencez donc par
retrancher un des verres de vos lunettes. Cette plaisanterie
déconcerta Pé Fournier.

Un Avocat assez mal bâti & fort laid, plaidoit contre une Bourgeoise;
c'étoit une cause sommaire, & qu'il chargeoit de beaucoup de
moyens inutiles. La Bourgeoise perdant patience, interrompit
l'Avocat: Messieurs, dit-elle, voici le fait en peu de mots; je m'engage
de donner au Tapissier, qui est ma Partie, une somme pour une
Tapisserie de Flandre, à personnages bien dessinés, beaux comme
M. le Président, (c'étoit effectivement un bel homme) il veut m'en
livrer une où il y a des personnages croqués, mal bâtis, comme
l'Avocat de ma Partie: ne suis-je pas dispensée d'exécuter la
convention? Cette comparaison, qui étoit très-claire, déconcerta
l'Avocat adverse, & la Bourgeoise gagna sa cause.

Il est d'usage de donner un conseil aux criminels avant de les


condamner. Un Avocat devenu le conseil d'un filou, surpris a dérober
des bourses dans une Audience du Parlement, le tire à l'écart; il lui
demande s'il étoit vrai qu'il eût coupé la bourse à quelqu'un? Il est
vrai, Monsieur, dit le voleur; mais.... tais-toi, reprit l'Avocat, le
meilleur conseil que je puisse te donner est de t'en aller au plus vîte.
Le Voleur, trouvant l'avis fort bon, gagne l'escalier le plus proche &
disparoît. L'Avocat se présente au Barreau; les Juges lui demandent
s'il n'a rien à dire pour la défense du criminel: Messieurs, dit-il, ce
pauvre malheureux m'a avoué son crime; mais comme j'étois
nommé son conseil, j'ai cru devoir lui conseiller de prendre la fuite.
Ce fut un sujet de risée; mais il n'y avoit rien à dire à l'Avocat.
M. V...., Avocat, arrivant dans la grande Salle du Palais, vit un
nombre de personnes assemblées & un certain brouhaha: il
demanda le sujet de ce tumulte, & on lui répondit que c'étoit à
l'occasion d'un voleur qu'on venoit d'arrêter en flagrant délit: tant
mieux, dit M. V...., il faut faire un exemple & punir sévérement ce
coquin-là; il lui convient bien de venir au Palais voler sans robe.

Le Maréchal de ...... menoit des Dames à l'Opera, mais toutes les


loges avoient été retenues; comme il en vit une remplie par un
domestique, qui la gardoit pour un Abbé, il obligea ce domestique de
sortir, & fit entrer sa compagnie dans la loge. L'Abbé arriva peu de
tems après avec des Dames, & fut piqué, comme on le pense bien,
de cette violence. Force lui fut néanmoins de céder pour le moment;
mais le lendemain il fit assigner son rival devant le Tribunal des
Maréchaux de France; & plaidant lui-même sa cause, dit »qu'il étoit
bien malheureux d'être obligé de se plaindre de l'un d'entr'eux, qui
de sa vie n'avoit pris que sa loge,« & demanda justice: le Président
lui répondit, »vous venez de vous la faire«.

Dans le tems que l'habit de velours étoit regardé comme un


habillement de luxe, M. D...., Avocat, en avoit commandé un à son
Tailleur; celui-ci le fit & le lui apporta; mais M. D..... trouvant
quelques défauts à l'habit, voulut forcer le Tailleur à le reprendre &
le fit assigner au Châtelet: M. D.... plaida lui-même sa cause, & dit
qu'il avoit à la vérité commandé l'habit de velours, mais que le
Tailleur devoit le garder à ses frais, puisque l'habit ne lui alloit pas;
là-dessus le Lieutenant Civil prononça, & dit, nous donnons acte à M.
D.... que l'habit de velours ne lui va pas; mais comme il l'a
commandé, il est condamné à le payer.

Un Avocat disoit d'un de ses Confreres, qui passoit pour très-


ignorant, vous voyez un tel, il n'y a pas d'Avocat plus cher que lui, il
ne donneroit pas un bon conseil pour cent pistoles.

Un jeune Avocat, qui plaidoit une affaire criminelle, dit naïvement,


Messieurs, le jour de la querelle fut une belle nuit.

Topenot, Procureur aux Consuls, plaidoit d'une façon naïve & tout-à-
fait singuliere. Il défendoit un jour un Maquignon, que l'on vouloit
forcer de reprendre un cheval: Messieurs, disoit Topenot, quand
nous avons vendu notre cheval il étoit en très-bon état, il étoit gros
& gras; aujourd'hui comment veut-on que nous le reprennions, on
nous l'a ramené comme un Ecce homo, parce qu'on lui a fait faire
trop de chemin & qu'on l'a fait courir à ventre déboutonné. Après
tout, nous ne vous en imposons pas, il est là-bas dans la cour, il n'y
a qu'à le faire monter & comparoître en personne. Mais, lui dit-on,
gardez le cheval à l'écurie une quinzaine de jours, il sera bientôt
refait. Ah! Messieurs; dit Topenot, ce que l'on demande n'est pas
raisonnable, & ma Partie n'est pas en état de garder pendant quinze
jours à l'écurie un cheval qui resteroit là les bras croisés à ne rien
faire.

Deux Huissiers nouvellement reçus, & qui n'avoient encore guere fait
de procès-verbaux, furent chargés d'une contrainte contre un
Village, pour le recouvrement d'un reste de Taille; ils eurent affaire à
des gens qui prirent mal la chose, & ils furent battus de la maniere la
plus complette. Ils ne manquerent pas d'en dresser un grand procès-
verbal, & d'exagérer les excès commis contre des membres de la
Justice; lesquels assassins, disoient-ils, en nous outrageant &
excédant, prenoient Dieu depuis la tête jusqu'aux pieds, &
proféroient tous les blasphêmes imaginables contre ledit Dieu,
soutenant que nous étions des coquins, des fripons, des scélérats &
des voleurs, ce que nous affirmons véritable; en foi de quoi, &c. Ces
Huissiers furent admonestés pour leur ignorance.
L'Avocat d'une Veuve, qui avoit un procès de famille qui duroit
depuis quatre-vingts ans, dit un jour en plaidant devant M. le
Premier Président de Verdun: Messieurs, les Parties adverses qui
jouissent injustement du bien de nos pupilles, prétendent que la
longueur de leur oppression est pour eux un titre légitime, & que
nous ayant accoutumés à notre misere, ils sont en droit de nous la
faire toujours souffrir. Il y a près d'un siecle que nous avons intenté
action contr'eux; & vous n'en douterez point, quand je vous aurai
fait voir par des certificats incontestables que mon aïeul, mon pere &
moi, nous sommes morts à la poursuite de ce procès...... Avocat,
interrompit le Premier Président, Dieu veuille avoir votre ame, & fit
appeller une autre cause.

Une bonne Dame, choquée de ce que les Ecclésiastiques familiarisés


avec les cérémonies lugubres des enterremens, n'y paroissoient pas
fort tristes, & rient même quelquefois, s'ils croient en avoir sujet,
parce que ab assuetis non fit passio, déclara par son testament, que
si quelque Ecclésiastique rioit à son convoi, elle entendoit ne rien
payer de la somme qu'elle destinoit à leur rétribution, laquelle
appartiendroit à l'exclusion de ceux qui riroient, à ceux qui ne
riroient pas. Le frere de la Testatrice fit lecture au Clergé convoqué
de la volonté de sa sœur, après sa mort. Cette disposition, loin
d'inspirer le sérieux, ne donna que plus d'envie de rire, & il n'y eut
pas un Prêtre de ceux qui y assisterent, qui, en se regardant, pût se
conformer au vœu de la défunte. Sur ce fondement, le frere se crut
en droit de refuser les honoraires au Clergé assistant; l'affaire fut
portée à l'Audience, & l'Avocat de l'héritier eut beau faire valoir la
sagesse de la disposition testamentaire, celui du Clergé lui répondit
qu'il étoit impossible d'envisager le zele hypocrite d'un frere, héritier
d'une succession opulente, sans en rire, qu'ainsi il falloit mettre la
disposition au rang des dispositions non écrites. Le Clergé gagna sa
cause, & on n'eut point d'égard au testament.
La premiere représentation d'Adelaïde du Guesclin fut sifflée dès le
premier acte, & quelques années après à la reprise de cette Piece,
les endroits qui avoient été le plus sifflés furent ceux qui exciterent
le plus de battemens de mains; là-dessus M. de Voltaire dit, vous me
demanderez peut-être auquel des deux jugemens je me tiens, je
vous répondrai ce que dit un Avocat Vénitien aux sérénissimes
Sénateurs devant lesquels il plaidoit; Il mese passato, le vostre
Excellenze hanno judicato cosi, & questo mese nella medesima
causa hanno judicato tutto l'contrario & sempre ben. Vos
Excellences, le mois passé, jugerent de cette façon; & ce mois-ci,
dans la même cause, ils ont jugé tout le contraire, & toujours à
merveille.
NOTES:
[1] Regles pour former un Avocat, chap. 13.
[2] Racine, Edit. de 1736, pag. 254.
[3] Voyez le Dictionnaire de Richelet, au mot Fripon.
[4]Ce témoin n'est point parent ni allié, mais seulement fils de la
premiere femme du beau-frere de l'Appellante.
[5] Ce fait est constaté par le Certificat du Curé & des principaux
habitans de Vanvres, qui attestent même, que pendant six ans que
cet âne a appartenu à un autre habitant, qu'aucun ne s'en est jamais
plaint, ni entendu qu'il ait fait de malice dans le pays. Voyez le
Certificat à la fin du Mémoire.
[6] Il demeure contre les Gobelins.
[7]Il est resté deux mois chez Leclerc, & n'en est sorti qu'à la caution
juratoire de son maître, à qui on demande aujourd'hui 1200 livres de
rançon, & 60 livres pour deux mois de nourriture.
[8] Voyez le Certificat du sieur Nepveux à la fin du Mémoire.
[9] Il s'est depuis restraint à une somme de 1200 liv.
Suivant ce rapport, on voit que la femme Leclerc étoit pour lors
[10]
guérie, & qu'il n'y avoit plus que la cicatrice.
[11] Loix Civiles, tom. 2, l. 2, tit. 8, nomb. 10. Vide toute la section.
[12] §. 5 de la Loi II du tit. 2 du livre 9. Si Quad paup. fec. dic ss.
[13] Liv. I, §. 6, L. L. Si quadrup. paup. fec. dic.
Il lui échappa d'appeler le Sieur ... brutal, enragé, villain fils de
[14]
Marchand de vin.
[15] L'Abbé de Marigny.
[16] Tout le monde sçait que M. le Trésorier de la Sainte Chapelle
jouit des honneurs & de plusieurs des droits de l'Episcopat.
[17]Nota. Ce Chapelain n'avoit en rien excédé ses droits, puisque ce
sont les Chapelains qui font l'Office, donnent la bénédiction à l'Enfant
de Chœur pour commencer les Complies; les Chanoines s'abstenant
de tous ces détails.
Le Trésorier seulement peut procéder juridiquement à l'expulsion
[18]
des Chapelains & des Clercs. Il a aussi droit de visite chez les
Chanoines, lesquels lui sont subordonnés.
[19] Cette distinction & les exemples qui l'appuyent sont présentés
pour raisonner en Jurisconsulte, & sans qu'on puisse ni qu'on doive
en inférer rien de contraire au respect profond dû à l'autorité
spirituelle.
[20]La Bulle de la Croisade permet, en Espagne, de manger le
samedi, moyennant une petite redevance, les extrêmités des
animaux.
[21] Argou, liv. 4, ch. 18.
Lettres Patentes du 4 Décembre 1402, de Janvier 1518, de Mars
[22]
1559. Déclaration du 16 Avril 1641, registrée le 24 Avril 1641. Arrêts
des 19 Novembre 1548, 10 Décembre 1588, 22 Mai 1633, 10
Septembre 1668.
[23] Le Carnaval de Venise.
[24] Siecle de Louis XIV, tom. 2, p. 7, édit de 1753.
[25] Mémoire de la Demoiselle Mazarelli, pages 7, 8, 9, 10 & 11.

FIN.
*** END OF THE PROJECT GUTENBERG EBOOK CAUSES
AMUSANTES ET CONNUES ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you


derive from the use of Project Gutenberg™ works
calculated using the method you already use to calculate
your applicable taxes. The fee is owed to the owner of
the Project Gutenberg™ trademark, but he has agreed to
donate royalties under this paragraph to the Project
Gutenberg Literary Archive Foundation. Royalty payments
must be paid within 60 days following each date on
which you prepare (or are legally required to prepare)
your periodic tax returns. Royalty payments should be
clearly marked as such and sent to the Project Gutenberg
Literary Archive Foundation at the address specified in
Section 4, “Information about donations to the Project
Gutenberg Literary Archive Foundation.”

• You provide a full refund of any money paid by a user


who notifies you in writing (or by e-mail) within 30 days
of receipt that s/he does not agree to the terms of the
full Project Gutenberg™ License. You must require such a
user to return or destroy all copies of the works
possessed in a physical medium and discontinue all use
of and all access to other copies of Project Gutenberg™
works.

• You provide, in accordance with paragraph 1.F.3, a full


refund of any money paid for a work or a replacement
copy, if a defect in the electronic work is discovered and
reported to you within 90 days of receipt of the work.

• You comply with all other terms of this agreement for


free distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.
Please check the Project Gutenberg web pages for current
donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like