100% found this document useful (2 votes)
14 views

Introducing Elixir Getting Started in Functional Programming 2nd Edition Edition Simon St. Laurent instant download

Introducing Elixir is a guide to the Elixir programming language, which combines the functional capabilities of Erlang with a more user-friendly syntax. The book is aimed at developers familiar with other programming languages who are interested in exploring Elixir's features, including its concurrency and metaprogramming capabilities. This second edition covers Elixir version 1.0.0 and provides updated content as the language evolves.

Uploaded by

ancureshab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
14 views

Introducing Elixir Getting Started in Functional Programming 2nd Edition Edition Simon St. Laurent instant download

Introducing Elixir is a guide to the Elixir programming language, which combines the functional capabilities of Erlang with a more user-friendly syntax. The book is aimed at developers familiar with other programming languages who are interested in exploring Elixir's features, including its concurrency and metaprogramming capabilities. This second edition covers Elixir version 1.0.0 and provides updated content as the language evolves.

Uploaded by

ancureshab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Introducing Elixir Getting Started in Functional

Programming 2nd Edition Edition Simon St.


Laurent pdf download

https://ebookfinal.com/download/introducing-elixir-getting-
started-in-functional-programming-2nd-edition-edition-simon-st-
laurent/

Explore and download more ebooks or textbooks


at ebookfinal.com
We have selected some products that you may be interested in
Click the link to download now or visit ebookfinal.com
for more options!.

Introducing Elixir Getting Started in Functional


Programming 1st Edition Simon St. Laurent

https://ebookfinal.com/download/introducing-elixir-getting-started-in-
functional-programming-1st-edition-simon-st-laurent/

From Ruby to Elixir Unleash the Full Potential of


Functional Programming 1st Edition Stephen Bussey

https://ebookfinal.com/download/from-ruby-to-elixir-unleash-the-full-
potential-of-functional-programming-1st-edition-stephen-bussey/

Getting Started in Hedge Funds 2nd ed Edition Daniel A.


Strachman

https://ebookfinal.com/download/getting-started-in-hedge-funds-2nd-ed-
edition-daniel-a-strachman/

Getting Started with C Audio Programming for Game


Development 1st Edition David Gouveia

https://ebookfinal.com/download/getting-started-with-c-audio-
programming-for-game-development-1st-edition-david-gouveia/
Getting Started With Advanced C Upgrade Your Programming
Skills 1st Edition Vaskaran Sarcar

https://ebookfinal.com/download/getting-started-with-advanced-c-
upgrade-your-programming-skills-1st-edition-vaskaran-sarcar/

Make Getting Started with Processing 2nd Edition Edition


Fry

https://ebookfinal.com/download/make-getting-started-with-
processing-2nd-edition-edition-fry/

Getting Started in Options Michael C. Thomsett

https://ebookfinal.com/download/getting-started-in-options-michael-c-
thomsett/

Getting Started in Investment Analysis Warren Brussee

https://ebookfinal.com/download/getting-started-in-investment-
analysis-warren-brussee/

Getting Started in Options 7th Edition Michael C. Thomsett

https://ebookfinal.com/download/getting-started-in-options-7th-
edition-michael-c-thomsett/
Introducing Elixir Getting Started in Functional
Programming 2nd Edition Edition Simon St. Laurent
Digital Instant Download
Author(s): Simon St. Laurent, J. David Eisenberg
ISBN(s): 9781491956748, 1491956747
Edition: 2nd Edition
File Details: PDF, 11.18 MB
Year: 2016
Language: english
Introducing Elixir

Simon St. Laurent and J. David Eisenberg

Boston
Introducing Elixir
by Simon St. Laurent and J. David Eisenberg
Copyright © 2016 Simon St. Laurent and J. Eisenberg. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles ( http://safaribooksonline.com ). For more information, contact our corporate/
institutional sales department: 800-998-9938 or corporate@oreilly.com .

Editors: Brian MacDonald and Susan Conant Indexer: FILL IN INDEXER


Production Editor: FILL IN PRODUCTION EDI‐ Interior Designer: David Futato
TOR Cover Designer: Karen Montgomery
Copyeditor: FILL IN COPYEDITOR Illustrator: Rebecca Demarest
Proofreader: FILL IN PROOFREADER

January -4712: Second Edition

Revision History for the Second Edition


2016-10-11: First Early Release

See http://oreilly.com/catalog/errata.csp?isbn=9781491956748 for release details.

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Introducing Elixir, the cover image,
and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author(s) have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author(s) disclaim all responsibil‐
ity for errors or omissions, including without limitation responsibility for damages resulting from the use
of or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.

978-1-491-95674-8
[FILL IN]
Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

1. Getting Comfortable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Installation 1
Installing Erlang 1
Installing Elixir 2
Firing It Up 2
First Steps 3
Moving Through Text and History 4
Moving Through Files 4
Doing Something 5
Calling Functions 6
Numbers in Elixir 7
Working with Variables in the Shell 9

2. Functions and Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


Fun with fn 11
And the & 13
Defining Modules 13
From Module to Free-Floating Function 17
Splitting Code Across Modules 17
Combining Functions with the Pipe Operator 19
Importing Functions 20
Default Values for Arguments 21
Documenting Code 22
Documenting Functions 23
Documenting Modules 24

iii
3. Atoms, Tuples, and Pattern Matching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Atoms 27
Pattern Matching with Atoms 27
Atomic Booleans 29
Guards 30
Underscoring That You Don’t Care 33
Adding Structure: Tuples 35
Pattern Matching with Tuples 36
Processing Tuples 37

4. Logic and Recursion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39


Logic Inside of Functions 39
Evaluating Cases 39
Adjusting to Conditions 42
If, or else 43
Variable Assignment in case and if Constructs 45
The Gentlest Side Effect: IO.puts 46
Simple Recursion 47
Counting Down 47
Counting Up 49
Recursing with Return Values 50

5. Communicating with Humans. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55


Strings 55
Multiline Strings 58
Unicode 58
Character Lists 58
String Sigils 59
Asking Users for Information 60
Gathering Characters 60
Reading Lines of Text 62

6. Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
List Basics 65
Splitting Lists into Heads and Tails 67
Processing List Content 68
Creating Lists with Heads and Tails 70
Mixing Lists and Tuples 72
Building a List of Lists 72

7. Name-Value Pairs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Keyword Lists 77

iv | Table of Contents
Lists of Tuples with Multiple Keys 79
Hash Dictionaries 80
From Lists to Maps 81
Creating Maps 81
Updating Maps 82
Reading Maps 82
From Maps to Structs 82
Setting Up Structs 83
Creating and Reading Structs 83
Pattern Matching Against Structs 84
Using Structs in Functions 84
Adding Behavior to Structs 87
Adding to Existing Protocols 88

8. Higher-Order Functions and List Comprehensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91


Simple Higher-Order Functions 91
Creating New Lists with Higher-Order Functions 93
Reporting on a List 94
Running List Values Through a Function 94
Filtering List Values 95
Beyond List Comprehensions 96
Testing Lists 96
Splitting Lists 97
Folding Lists 97

9. Playing with Processes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101


The Shell Is a Process 101
Spawning Processes from Modules 103
Lightweight Processes 106
Registering a Process 107
When Processes Break 108
Processes Talking Amongst Themselves 109
Watching Your Processes 111
Watching Messages Among Processes 113
Breaking Things and Linking Processes 115

10. Exceptions, Errors, and Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123


Flavors of Errors 123
Rescuing Code from Runtime Errors as They Happen 124
Logging Progress and Failure 126
Tracing Messages 127
Watching Function Calls 129

Table of Contents | v
11. Static Analysis, Typespecs, and Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Static Analysis 131
Typespecs 133
Writing Unit Tests 136
Setting up Tests 139
e. Embedding Tests in Documentation

12. Storing Structured Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143


Records: Structured Data Before structs 143
Setting Up Records 144
Creating and Reading Records 145
Using Records in Functions 146
Storing Data in Erlang Term Storage 148
Creating and Populating a Table 150
Simple Queries 155
Overwriting Values 156
ETS Tables and Processes 156
Next Steps 158
Storing Records in Mnesia 159
Starting up Mnesia 159
Creating Tables 160
Reading Data 164

13. Getting Started with OTP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167


Creating Services with gen_server 168
A Simple Supervisor 173
Packaging an Application with Mix 177

14. Using Macros to Extend Elixir. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181


Functions versus Macros 181
A Simple Macro 182
Creating New Logic 184
Creating Functions Programatically 185
When (Not) to Use Macros 187
Sharing the Gospel of Elixir 187

15. Using Phoenix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189


Skeleton installation 189
Structuring a Basic Phoenix Application 192
Presenting a Page 192
Routing 193
A Simple Controller 195

vi | Table of Contents
A Simple View 196
Calculating 198

A. An Elixir Parts Catalog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

B. Generating Documentation with ExDoc. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

Table of Contents | vii


Preface

Elixir offers developers the functional power and concurrent resilience of Erlang,
with friendlier syntax, libraries, and metaprogramming. Elixir compiles to Erlang
byte code, and you can mix and match it with Erlang and Erlang tools. Despite a
shared foundation, however, Elixir feels very different, perhaps more similar to Ruby
than to Erlang’s ancestor Prolog.
Introducing Elixir will give you a gentle guide to this powerful language.

This release of Introducing Elixir covers version 1.0.0. We will


update it as the language evolves. If you find mistakes or things that
have broken, please let us know through the errata system.

Who This Book Is For


This book is mostly for people who’ve been programming in other languages but
want to look around. Maybe you’re being very practical, and a distributed model,
with its resulting scale and resilience advantages, appeals to you. Maybe you want to
see what this “functional programming” stuff is all about. Or maybe you’re just going
for a hike, taking your mind to a new place.
I suspect that functional programming is more approachable as a first language,
before you’ve learned to program in other paradigms. However, getting started in
Elixir—sometimes even just installing it—requires a fair amount of computing skill.
If you’re a complete newcomer to programming, welcome, but there will be a few
challenges along the way.

Who This Book Is Not For


This book is not for people in a hurry to get things done.

ix
If you already know Elixir, you don’t likely need this book unless you’re looking for a
slow brush-up.
If you already know Erlang, this book will give you an opportunity to see how things
are different, but odds are good that you understand the key structures.
If you’re already familiar with functional languages, you may find the pacing of this
gentle introduction hopelessly slow. Definitely feel welcome to jump to another book
or online documentation that moves faster if you get bored.

What This Book Will Do For You


You’ll learn to write simple Elixir programs. You’ll understand why Elixir makes it
easier to build resilient programs that can scale up and down with ease. You’ll be able
to read other Elixir resources that assume a fair amount of experience and make sense
of them.
In more theoretical terms, you’ll get to know functional programming. You’ll learn
how to design programs around message passing and recursion, creating process-
oriented programs focused more on data flow.
Most importantly, the gates to concurrent application development will be open.
Though this introduction only gets you started using the incredible powers of OTP,
that foundation can take you amazing places. Once you’ve mastered the syntax and
learned about Elixir’s expectations for structuring programs, your next steps should
be creating reliable and scalable applications - with much less effort than you would
have needed in other approaches!

How This Book Works


This book tries to tell a story with Elixir. You’ll probably get the most out of it if you
read it in order at least the first time, though you’re always welcome to come back to
find whatever bits and pieces you need.
You’ll start by getting Elixir installed and running, and looking around its shell, IEx.
You’ll spend a lot of time in that shell, so get cozy. Next, you’ll start loading code into
the shell to make it easier to write programs, and you’ll learn how to call that code
and mix it up.
You’ll take a close look at numbers because they’re an easy place to get familiar with
Elixir’s basic structures. Then you’ll learn about atoms, pattern matching, and guards
—the likely foundations of your program structure. After that you’ll learn about
strings, lists, and the recursion at the heart of much Elixir processing. Once you’ve
gone a few thousand recursions down and back, it’ll be time to look at processes, a

x | Preface
key part of Elixir that relies on the message-passing model to support concurrency
and resilience.
Once you have the foundation set, you can take a closer look at debugging and data
storage, and then get a quick look at a toolset that is likely at the heart of your long-
term development with Elixir: Erlang’s Open Telecom Platform (OTP), which is
about much much more than telephones.
Finally, you’ll learn about Elixir’s macro tools, features that give Elixir tremendous
flexibility by letting you extend the language.
Some people want to learn programming languages through a dictionary, smashing
together a list of operators, control structures, and datatypes. Those lists are here, but
they’re in Appendix A, not the main flow of the book.
The main point you should get from this book is that you can program in Elixir. If
you don’t get that, let me know!

Other Resources
This book may not be the best way for you to learn Elixir. It all depends on what you
want to learn and why. If you’re looking for a faster-flying introduction to the lan‐
guage, Dave Thomas’ Programming Elixir (Pragmatic Publishers) jumps in faster and
emphasizes Elixir’s uniqueness more frequently.
If you like the pace of this book and want to try out your new knowledge, you might
like Études for Elixir (O’Reilly Media). That book provides descriptions of short pro‐
grams that you can write in Elixir, and they may ask you stretch a bit beyond the
examples you find here. It is also designed so that its chapters are in parallel with this
book’s chapters.
The other books in the field all cover Erlang, not Elixir. Hopefully there will be more
Elixir-specific work soon. Elixir in Action (Manning) is getting underway. The main
Elixir website includes a lot of tutorials, documentation, and links to other resources.
If your primary interest in learning Elixir is to break out of a programming rut, you
should explore Bruce Tate’s wild tour of Seven Languages in Seven Weeks (Pragmatic
Publishers), which explores Ruby, Io, Prolog, Scala, Erlang, Clojure, and Haskell.
Erlang gets only (an excellent) 37 pages, but that might be what you want.
Erlang books can also help you understand what makes Elixir work so well.
For a simple introduction to Erlang that largely parallels this book, Introducing Erlang
will get you started with Erlang and functional programming.
For an online experience (now also in print from No Starch Books) with more snark
and funnier illustrations, you should explore Fred Hebert’s Learn You Some Erlang for
Great Good!.

Preface | xi
The two classic general books on Erlang are the similarly-titled Programming Erlang
(Pragmatic Publishers) by Erlang creator Joe Armstrong, and Erlang Programming
(O’Reilly) by Francesco Cesarini and Simon Thompson. They cover a lot of similar
and overlapping terrain, and both may be good places to start if this book moves too
slowly or you need more reference material. Erlang Programming goes further into
what you can do with Erlang, whereas Programming Erlang provides a lot of detail on
setting up an Erlang programming environment.
On the more advanced side, Erlang and OTP in Action (Manning) by Martin Logan,
Eric Merritt, and Richard Carlsson, opens with a high-speed 72-page introduction to
Erlang and then spends most of its time applying the Open Telecom Platform,
Erlang’s framework for building upgradeable and maintainable concurrent applica‐
tions.
Designing for Scalability with Erlang/OTP (O’Reilly), by Francesco Cesarini and Steve
Vinoski, explores how OTP and Erlang make things that seem hugely difficult in
other environments a normal day’s work in Erlang.
If you want to focus on connecting Erlang to the Web, you should definitely also
explore Building Erlang Web Applications (O’Reilly) by Zachary Kessin.
You’ll also want to visit the main Erlang website for updates, downloads, documenta‐
tion, and more.

Elixir Will Change You


Before you go deeper, you should know that working in Elixir may irrevocably
change the way you look at programs. Its combination of functional code, process
orientation, and distributed development may seem alien at first. However, once it
sinks in, Elixir can transform the way you solve problems (perhaps even beyond the
way Erlang does), and potentially make it difficult to return to other languages, envi‐
ronments, and programming cultures.

Conventions Used in This Book


The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program ele‐
ments such as variable or function names, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.

xii | Preface
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter‐
mined by context.

This icon signifies a tip, suggestion, or general note.

This icon indicates a warning or caution.

Using Code Examples


The examples in this book are meant to teach basic concepts in small bites, making it
easy to see what changed from one example to another. While you may certainly bor‐
row code and reuse it as you see fit, you won’t be able to take the code of this book
and build a stupendous application instantly (unless perhaps you have an unusual
fondness for calculating the speeds of falling objects). You should, however, be able to
figure out the steps you need to take to build a great application.
You can download the code from GitHub. (Eventually it will also be available from
the Examples link on the book’s catalog page.)
This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you are reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example
code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: "Introducing Elixir, by Simon St.Lau‐
rent and J. David Eisenberg (O’Reilly). Copyright 2014 Simon St.Laurent and J. David
Eisenberg, 978-1-449-36999-6.”
If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at permissions@oreilly.com.

Preface | xiii
Help This Book Grow
While I hope that you will enjoy reading this book and learn from it, I also hope that
you can contribute to helping other readers learn Elixir here. You can help your fel‐
low readers in a number of ways:

• If you find specific technical problems, bad explanations, or things that can be
improved, please report them through the errata system.
• If you like (or don’t like) the book, please leave reviews. The most visible places to
do so are on Amazon.com (or its international sites) and at the O’Reilly page for
the book. Detailed explanations of what worked and what didn’t work for you
(and the broader target audience of programmers new to Erlang) are helpful to
other readers and to me.
• If you find you have much more you want to say about Elixir, please consider
sharing it, whether on the Web, in a book of your own, in training classes, or in
whatever form you find easiest.

We’ll update the book for errata and try to address issues raised in reviews. Even once
the book is “complete,” I may still add some extra pieces to it. If you purchased it as
an ebook, you’ll receive these updates for free at least up to the point where it’s time
for a whole new edition. I don’t expect that new edition declaration to come quickly,
however, unless the Elixir world changes substantially.
Hopefully this book will engage you enough to make you consider sharing.

Please Use It For Good


We’ll let you determine what “good” means, but think about it. Please try to use Elix‐
ir’s power for projects that make the world a better place, or at least not a worse place.

Safari® Books Online


Safari Books Online is an on-demand digital library that deliv‐
ers expert content in both book and video form from the
world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research,
problem solving, learning, and certification training.
Safari Books Online offers a range of plans and pricing for enterprise, government,
education, and individuals.

xiv | Preface
Members have access to thousands of books, training videos, and prepublication
manuscripts in one fully searchable database from publishers like O’Reilly Media,
Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que,
Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kauf‐
mann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders,
McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more
information about Safari Books Online, please visit us online.

How to Contact Us
Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.


1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://bit.ly/introducing_elixir.
To comment or ask technical questions about this book, send email to bookques‐
tions@oreilly.com.
For more information about our books, courses, conferences, and news, see our web‐
site at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments
The Elixir community is amazing, open to questions and suggestions from a wide
range of perspectives. We’ve been lucky to be able to ask questions and get them
answered, and have enjoyed a rare community that treats “difficult to explain” as a
problem worth fixing in code.
José Valim’s leadership and explanations have helped us throughout the project. Our
competitor Dave Thomas confirmed that yes, Elixir is here and the world is waiting
for it. From the Erlang side, Francesco Cesarini encouraged us to purse this new lan‐
guage sibling. Reviewers Bibek Pandey, Alexei Sholik, David Lorenzetti, Bengt Kle‐

Preface | xv
berg, Mistral Contrastin, Augie De Blieck Jr, Arie van Wingerden, Elias Carrillo, and
Nicholas helped us find the errors of our ways.
Our editor Meghan Blanchette kept us on track, and Melanie Yarbrough saw the book
through an intricate production process as we waited for Elixir to finalize.
Also, J. David Eisenberg’s commitment to the project saved Simon St.Laurent repeat‐
edly!
Thanks also to Simon, who made David’s first experience as a co-author a pleasant
one.

xvi | Preface
CHAPTER 1
Getting Comfortable

The easiest place to start learning Elixir is in Interactive Elixir, iex. This command-
line interface is a cozy place to get started and a good place to start figuring out what
works and what doesn’t work in Elixir. Its features will spare you headaches later, so
settle in!

Installation
Because Elixir runs on top of Erlang, you’ll need to install Erlang on your system first,
and then install Elixir.

Installing Erlang
If you’re on Windows, installing Erlang is easy. Download the Windows binary file,
run the installer, and you’re set. If you are a brave beginner tackling your first pro‐
gramming language, this is easily your best bet.
On Linux or Mac OS X, you may be able to download the source file and compile it.
For me, on Mac OS X, I just had to unzip and untar it, and then, from the directory
created by the untarring, run ./configure, make, and sudo make install. However,
that simple sequence works only if you have the right files previously installed, and
can give you mysterious errors if they weren’t. In particular, Apple’s shift to the LLVM
compiler in newer versions of XCode instead of GCC makes it less likely that GCC
will be on newer Mac OS X systems, and Erlang needs GCC.
(You can also ignore the error about FOP, which Erlang uses to generate PDF docu‐
mentation you can download elsewhere. Also, on newer Macs, you’ll get an error at
the end that wxWidgets doesn’t work on 64-bit Mac OS X. For now, ignore this.)

1
If the compilation approach doesn’t work or isn’t for you, Erlang Solutions offers a
number of installs. Also, many different package managers (Debian, Ubuntu, Mac‐
Ports, homebrew, and so on) include Erlang. It may not be the very latest version, but
having Erlang running is much better than not having Erlang running. They do tend
to make it run on the latest version of various operating systems, so if you have instal‐
lation problems, look closely at their requirements.

Erlang is increasingly part of the default installation on many sys‐


tems, including Ubuntu, largely thanks to the spread of CouchDB.

Installing Elixir
Once you have Erlang installed, you should be able to download a precompiled ver‐
sion of Elixir or the GitHub source. Some package managers are starting to support
Elixir, including homebrew. This version of this book should work with Elixir 1.0.0.
Then you need to set your path so that it can find elixir/bin.
Elixir’s instructions for setup are organized into a tutorial.

Firing It Up
Go to the command line (or shell, or terminal) and type mix new first_app. This
will invoke Elixir’s Mix tool, which “provides tasks for creating, compiling, and test‐
ing Elixir projects, managing its dependencies, and more.” In this case, the command
you typed creates a new, empty project in a directory named first_app:
$ mix new first_app
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/first_app.ex
* creating test
* creating test/test_helper.exs
* creating test/first_app_test.exs

Your Mix project was created successfully.


You can use "mix" to compile it, test it, and more:

cd first_app
mix test

2 | Chapter 1: Getting Comfortable


Discovering Diverse Content Through
Random Scribd Documents
219 Folio MS., f. 79.

220 Folio MS., f. 78. The correctness of this narrative of what


passed at the negociations was afterwards impugned by Charles,
and it was burnt in London by the hands of the hangman.

221 Privy Council Record.

222 Folio, MS., f. 79.

223 Burnet, p. 144.

224 Hardwicke, vol. 1., p. 141; who adds this note: “As Burnet,
in his Memoirs of Hamilton, has already mentioned, though in an
inaccurate way, this extraordinary warrant, it is thought not
improper to publish it exactly from the original.”—Burnet’s
statement thus referred to is to the following effect (p. 148:)
—“But, before they came to Berwick, the King ordered the
Marquis, by a warrant in writing, yet extant under His Majesties
hand, to try what way he could gain upon them, and discover the
bottom of their intentions, how the estate of Bishops should be
supplied in Parliament, and how far they intended to lessen the
King’s Authority. The King also allowed him to use what means he
pleased, and speak to them what he thought fit; not onely
authorizing, but requiring him to it, and warranting him, if he
were ever questioned or accused for it by any. Bearing date at
Berwick the 17th of July 1639.”

225 Burnet, p. 149.

226 Burnet, p. 154. “Penned” by Hamilton, and “interlined” by


Canterbury.—Burnet, p. 153.

227 Burnet, p. 155.

228 Burnet, p. 156.

229 Privy Council Record.

230 Burnet, p. 158.

231 Folio MS., from f. 169 to f. 211.

232 It may be proper to explain that Mr David Dick, whoso


name is so often introduced as taking a part in the proceedings of
these Assemblies, is the same person as Mr David Dickson,
minister of Irvine. This abbreviation of his name appears
throughout all the MS. reports we have seen, although, in the list
of members, 1638, and other documents, it is given at full length.
This abbreviation, we presume, has arisen from some colloquial
and conventional usage at the time; but it is right to note the
circumstance, in order to prevent mistakes.

233 The “Large Declaration,” in which Henderson was vilified


and depreciated.

234 It is impossible to peruse this interesting debate without


remarking how assiduously the Commissioner, and those to whom
he was opposed in the argument, kept in the back ground the
main objection to the Assembly exercising judicial functions—
namely, that it had no legal power to do so. The Assembly 1638
had not obtained the civil sanction to give any of its proceedings,
or those emanating from its instructions, any legal authority—and
the declarations of the Assembly 1639, confessedly by the
Assembly itself, required the sanction of Parliament ere the
Presbyterian Constitution could be in full and legitimate operation.
It was, therefore, evidently premature and unwarrantable, to
assume, at the very moment that so much anxiety was expressed
for that sanction, that it already possessed that judicial character
which it could not possibly derive, as an Establishment, from any
other source than the supreme legislature of the country. It must
be remembered that, by law, Episcopacy was still the established
form of national religion; and nothing more preposterous can be
conceived than the project of punishing any man merely for
adhering to it.

235 Improbation—a form of process in the law of Scotland,


under which the testimony of a witness was challenged.

236 Although these several Declarations are to be found in the


Acts (Records, pp. 207 and 208), yet, as the terms of them
formed the subject of future debates, we have inserted them
here, as we find them detailed in the report of proceedings in the
Folio MS.

237 Vide Report, p. 251.

238 Amidst the multiplicity of documents, and of authorities to


which we are obliged to resort for them, we see, on looking into
Rushworth, that two have been omitted, which we take the
earliest opportunity of supplying. These are, a Note by Lord
Lowdon, at a conference with the King, on 11th June 1639, and
his Majesty’s answer thereto, on the 13th. These are important,
as shewing the primary basis of the negociation. They are in the
following terms:—
“Memorandum.—That our desires are only the enjoying of our
Religion and Liberties, according to the ecclesiastical and civil laws
of his Majestys Kingdom,
“To clear, by sufficient grounds, that the particulars are such,
we shall not insist to crave any point which is not so warranted.
And we humbly offer all civil and temporal obedience to your
Majesty which can be required or expected of Loyal Subjects.—
(Signed) Lowdon.”—(Rushworth, vol. iii., p. 941.)
At the next Meeting in the King’s Camp, on the 13th, (where
Henderson and Johnston were present,) the following answer, by
the King, to Lowdon’s Memorandum, was produced:—
“That, whereas his Majesty, the 11th of June, received a short
paper of the general grounds and limits of their humble desires,
his Majesty is graceously pleased to make this answer. That, if
their desires be only the enjoying of their religion and liberties,
according to the ecclesiastical and civil laws of his Majestys
Kingdom of Scotland, his Majesty doth not only agree to the
same, but shall always protect them to the uttermost of his
power; and if they shall not insist upon any thing but that is so
warranted, his Majesty will most willingly and readily condescend
thereunto, so that in the meantime they pay unto him that civil
and temporal obedience which can be justly required and
expected of Loial Subjects.—At his Majestys Camp, the 13th of
June 1639.”—(Ibid., p. 942.)
We may also note that Rushworth gives all the dates more
precisely than we find elsewhere. The Earl of Dunfermline went to
the King’s from the Scotch Camp, on the 6th, with the petition
from the Covenanters, (No. 49 of Documents, p. 225;) and Sir E.
Verney returned with him, bearing the King’s answer, (No. 50, p.
226;) the “Reasons and Grounds,” &c., were produced on the
13th. The Scots deputies returned on Saturday the 15th, and
again on Monday the 17th; and the treaty was signed on the
18th. On the 22d, the King left the Camp for Berwick; and, on the
24th, his army was dismissed and dissolved.—Rushworth, p. 943-
946.
239 Vide Report, p. 268.

240 Vol. ii, p. 501.

241 Rushworth, vol. iii, p. 955.

242 Acts of Parliament, vol. iv., p. 285, 286. (Mr Thomson’s


edition.)

243 Rush vol. iii. p. 992, 1016, et sequen. Vide also Franklyn, p.
796, et sequen; Clarendon, and others.

244 Vide Burnet’s Memoirs, p. 169, et sequen.

245 Vide Documents.

246 Minutes of Parliament, in Acts, vol. v., p. 256.

247 Rushworth, vol. iii., p. 983.

248 Burnet, p. 163.

249 Rushworth, vol. iii., p. 984.

250 Rushworth, vol. iii., p. 1037.

251 Rushworth, vol. iii., p. 1210.

252 Burnet, p. 170.

253 Rushworth, vol. iii., p. 1212.

254 Ibid., 1213.

255 Baillie’s Letters, vol. i., p. 195.—A great number of Baillie’s


Letters, relative to the troubles in Scotland, were addressed to Mr
Spang, a Scotch Presbyterian minister at Campvere in Holland;
and from these and other materials, that learned person
afterwards compiled a work in Latin for the information of
foreigners which is thus titled:—“Rerum nuper in Regno Scotiæ
gestarum Historia, seu verius Commentarius, causas, occasiones,
progressus horum mottuum, breviter et perspicue proponens,
simul cum synopsi concordiæ, quantum hactenus inita est.—
Excerptus ex scriptis intriusque partis scitu dignissimis, quorum
primaria in Latinum sermonem nunc primum fideliter translata
inseruntur, &c.—Per Irinævm Philalethen, Eleutherium.—Dantisci,
Anno Domini 1641.” There is a copy of this work in the
Theological Library, Edinburgh.
By an Act of Assembly 1641, the Scotch church at Campvere
was brought into connection with the Church of Scotland, and the
Kirk Session thereof authorized to send its minister and a ruling-
elder to the General Assembly. This connection continued long
after, till that branch of the Scottish Church was swept away in
the French revolutionary war, since which it has not been
renewed, although that church has been revived.

256 It appears fitting to embody in this collection a brief


statement of the discrepancies betwixt the English and the
obnovious Scotch Service Books, and to point out the
resemblances which the latter had to the Popish missals. For this
exposition we are indebted to a kind and learned friend, who is
fully master of the subject.

257 Rushworth says it was on Thursday the 20th—Balfour,


Friday the 21st.

258 Vide Documents.

259 Rushworth, vol. iii., p. 1221.

260 Ibid, p. 1236.

261 Rushworth, vol. iii., p. 1238.

262 Vide Documents, p. 299.

263 Rushworth, vol. iii., p. 1257.

264 Ibid, p. 1276, 1277-1282.

265 Vide Documents, p. 302.

266 Rushworth, Baillie, passim.

267 Vide Documents, p. 303.

268 Rushworth, vol. iii., p. 1221.

269 Ibid, p. 1223.


270 Burnet, p. 174.

271 Burnet, p. 176.

272 Burnet, p. 177.

273 Burnet, p. 178.

274 Rushworth, vol. iii., p. 1295.

275 Rushworth, vol. iii., p. 1306.

276 Burnet, p. 182.

277 Baillie, p. 298.

278 Vide Documents.

279 Vide Balfour, vol. iii., pp. 4-9.

280 Vide p. 235. Minutes of Parliament. Acts, vol. v., p. 360.

281 Son of the Archbishop, and President of the Session.

282 Baillie, vol. i., p. 324.

283 Vol. iii., p. 40.

284 Vide Acts, vol. v., p. 370, 371, &c.

285 Balfour, vol. iii., p. 65.

286 The following lists of officers of state, &c., (from Balfour’s


Annals, vol. iii., p. 148,) when compared with the rolls of the
Assemblies in 1638 and 1639 shew, that the former of these,
(and, indeed, the latter, too,) were quite as much political as
ecclesiastical conventions. The lay leaders of the Tables, and in
the Assemblies, were just the identical persons who had mounted
on the ecclesiastical ladder to political power and place:—
“The 3 estaits of parl: hes delett out of the roll of counsellors
giuen in by hes Maiesty, thesse follouing—viz., George, Marques
of Huntley; Villiam, Earle of Airth and Menteth; Alexander, Earle of
Linlithgow; James, Earle of Home; Patrick, Earle of Tullibardyne;
Alexander, Earle of Galloway; Villiam, Earle of Dumfreis; Robert,
Earle of Carnwathe. And in ther places the 3 estaits did put in
Johne, Earle of Sutherland; Villiam, Earle of Louthean; Alex: Earle
of Dalhousie; Johne, Lord Zester; Johne, Lord St. Claire; Johne,
Lord Balmerinache; Robert, Lord Burlie.
“Acte anent the nominatione and electione of the counsellours
votted and past, according to this subsequent roll:—James, Duck
of Lennox and Richmond; James, Marq: of Hamilton; Archbald,
Earle of Argyle; Villiam, Earle of Marishall; Johne, Earle of
Sutherland; Johne, Earle of Mar; Alex: Earle of Eglintone; Johne,
Earle of Cassiles; Villiam, Earle of Glencairne; James, Earle of
Murray; Johne, Earle of Perth; Charles, Earle of Dumfermling;
Johne, Earle of Vigtone; Johne, Earle of Kingorne; George, Earle
of Seaforte; Johne, Earle of Lauderdaill; George, Earle of
Kinnoule; Villiam, Earle of Louthean; Dauid, Earle of Southescke;
John, Earle of Wymees; Alex: Earle of Dalhousie; James, Earle of
Finlater; Alexander, Earle of Leuin; Archbald, Lo: Angus; Johne,
Lo: Lindesay; Johne, Lo: Zester; Johne, Lo: St. Claire; Alex: Lo:
Elphingstone; Johne, Lo: Balmerinoche; Robert, Lo: Burlie; James,
Lo: Amont; Alexandʳ, Lo: Balcarras; Sʳ Robert Gordon, Vice
Chamberlaine; Sʳ Patrick Hepburne of Vaughtone; Sʳ Villiam
Douglas of Cauers; Sʳ Ja: Dundas of the same; Thomas Myrtone
of Camwo; Sʳ Dauid Grhame of Fintrey; Sʳ John Erskyne of Dune;
Sʳ Robert Grhame of Morphie; Sʳ Robert Innes of the same;
Prouest of Edinbrughe for the tyme.
“Acte anent the nominatione and electione of thesse officers of
estait retained in ther places, votted and past accordinng to this
ensewing roll, they all beinng includit within the roll of counsellers
also, viz:—
“1. Jo: Lord London, Chancelour;
“2. Commissioners for the office of Thesaurer, 3 of them to be a
coram, votted, viz.:—Chancelour, Argyle, Glencairne, Lindesay,
Thʳˢ depute.
“3. Earle of Roxbrughe, Lo: Priuey Seall;
“4. Earle Lanricke, Secretarey;
“5. Mr Alex: Gibsone of Durie, Clerke Register;
“6. Sʳ Tho: Hope of Craighall, Aduocat;
“7. Sʳ Jo: Hamilton of Orbeston, Justice Clerke;
“8. Sʳ Ja: Carmichell of the same, Thʳˢ depute;
“9. Sʳ Ja: Galloway, Master of Requysts.
“Supernumerarey counsellours, so called in his Maiesties rolls,
wotted and approuen by the housse, wer:—Thomas Houard, Earle
of Arundaill; Philipe Herbert, Earle of Pembrock and
Montgomerey; Villiam Cicill, Earle of Sarisburrey; Henrey Riche,
Earle of Holland; Lord Villoughbie; Eduard, Lord Houard; Sʳ
Henrey Vaine, Secretarey for England; Sʳ Johne Cooke, knight.
“Acte ament the nominatione and electione of the ordinar and
extraordinar Lordes of the Session, conforme to this roll, votted
and approuen by the housse:—Sʳ George Erskyne of Innerteill; Sʳ
Alex: Gibsone of Durie, elder; Sʳ Androw Fletcher of Innerpepher;
Sʳ James Lermonth of Balcomey; Sʳ George Halibrunton of
Fodrens; Sʳ James Mackgill of Cranston-Ridell; Sʳ Johne Hope of
Cragehall; Sʳ Johne Hamilton of Orbestone; Sʳ John Scott of
Scottstaruett; Sir James Carmichell of the same; Sʳ Alex: Falconer
of Halcartone. Thesse foure follouing, by the estaits wer putt from
ther places in Sessione, for crymes lybelled aganist them:—Sʳ
Rob: Spotswood, President; Sʳ Jo: Hay, Clerke Register; Sʳ Vill:
Elphingstone, Justice Generall; Sʳ Patrick Nisbett of Eastbancke.
And in the place of thir forsaid foure, the estaitts put in John
Lesley of Neutone; Sʳ Thomas Hope of Kers; Mr Adam Hepburne
of Humbie; Mr Archbald Ihonstone, Clerke of the Generall
Assembley.
Extraordinarey Lordes of the Sessione, wotted and approuen by
the housse this day, wer:—E. Argyle, L. Angus, L. Lindesay, L.
Balmerinoche.”

287 Hume’s History, vol. vii., pp. 5-14.

288 Oct. 22, 1641. Rush. vol. iv., p. 399.

289 Acts, vol v., p. 519.

290 50 George III., c. 89, 15th June, 1810.

291 Burnet, p. 188. Rushworth, vol. iv., pp. 498, 501.

292 Rushworth, vol. iv., p. 501. Neal, vol ii., p. 519.

293 Whitelocke’s Mem., p. 57; Baillie, vol. i., p. 337; Clarendon,


Guthrie, &c.

294 Rushworth, vol. iv., pp. 373-5.


295 Baillie, vol. 1, p. 337.

296 The several proceedings which we have thus characterised


freely but honestly, are recorded in the Acts of the General
Assembly 1642, to which we have alluded.

297 History of Scotland, vol. i., p. 245.

298 Vide the Account of Westminster Assembly, in excerpts


from Baillie’s Letters among Documents.

299 Vide p. 362.

300 Vide Documents, p. 362.

301 Acts of Parl., vol. vi., pp. 107-9.

302 Acts of Parl., vol. vi., pp. 106-7.

303 Baillie’s Letters, vol. i, p. 373.

304 Baillie’s Letters, vol. i., p. 392.

305 Vide Baillie’s Letters.

306 Cheesly, afterwards Sir John Cheesly, was Mr Henderson’s


servant.

307 Burnet, p. 196.

308 Ibid, p. 197.

309 Burnet, p. 198.

310 Burnet, p. 200.

311 Burnet, p. 203.

312 Lanerick.

313 Burnet, p. 205.

314 Burnet, p. 206.

315 Burnet, p. 210.


316 Burnet, p. 213.

317 Burnet, p. 215.

318 Burnet, p. 219.

319 Burnet, p. 221.

320 Burnet, p. 218.

321 Burnet, p. 225.

322 Burnet, p. 230, and Register of Secret Council.

323 Ibid, p. 230.

324 Ibid, p. 231.

325 Burnet, p. 226.

326 Burnet, p. 231.

327 Vide Rushworth, vol. iv., part ii., p. 499; and Clarendon, vol.
ii., part i., p. 383.

328 Vide Letter among Acts.

329 As copies of Mr Thomson’s edition of the Acts are


deposited in the office of every Sheriff-Clerk, and are accessible to
all who think fit to consult them, it is not thought necessary to
give more than the title and page in which several Acts, referring
to the Church, may be found.

330 Acts of Parliament, vol. v., p. 61.

331 Ibid., p. 66, and Act of Ratification, ibid., p. 129.

332 Vide Acts, vol. v., p. 190.

333 Minstrelsy of the Scottish Border, vol. ii., p. 170. Clarendon


State Papers, vol. ii., p. 189. Spalding, vol. ii., pp. 273; 26, 27, 28;
83, 85.

334 Vide Neal’s Hist. of Puritans, vol. iii., p. 131. Baillie, vol. ii.,
p. 85
335 Rushworth, vol. i., p. 268, 271.

336 In order to save the necessity of frequent references to the


authorities on which this brief historical sketch is given, it may be
deemed sufficient to state that the facts are given chiefly from
Rushworth, (Part iv., vol. i.,) in which all the documents relative to
the period are to be found in the most authentic form. Whitelock’s
Memorials, Baillie’s Letters, Guthrie’s Memoirs, Crawford’s Lives,
and Clarendon, may also be consulted by those who desire to
obtain minute and exact information with respect to the
transactions of those times. We think it right to state, that
throughout we have taken the documentary evidence afforded by
Rushworth as our safest guide, both as to the chronology and the
character of events. The works of Mr Hume and Mr Laing, in
relation to those times, may be regarded rather as able historical
disquisitions than histories; for the almost entire want of dates
renders their narratives extremely perplexed and unsatisfactory.

337 Vide Acts, p. 450.

338 Rushworth, part iv., vol. i., p. 305.

339 Ibid., p. 306.

340 Ibid., p. 309, et seq.

341 Rushworth, part iv., vol. i. 319, 320.

342 Vide Documents.

343 Vide Documents.

344 Rushworth, part iv., vol. i., p. 329.

345 Ibid.

346 Rushworth, part iv., vol. i., p. 373.

347 Acts of Estates, vol. vi., p. 239.

348 Vide Documents.

349 Rushworth, part iv., vol. i., p. 392.

350 Rushworth, part iv., vol. i., p. 393.


351 Acts of Estates, vol. vi., p. 240; and Rushworth, part iv., pp.
395-6.

352 Rushworth, part iv., vol. i., p. 398.

353 Laing, vol. i., p. 345, on the authority of Burnet.

354 A high controversy has recently been carried on by Mr


Lister, (author of a Life of Lord Clarendon,) and certain writers in
the Edinburgh and Quarterly Reviews, relative to the
circumstances which preceded the surrender of King Charles I., by
the Scottish Commissioners, into the hands of his Parliamentary
antagonists. We have no intention of entering on the minutiæ of
this discussion, which relates mainly to Clarendon’s historical
character, and to the communications that took place through the
instrumentality of Montrevil, and the documents therewith
connected. There is only one point to which we shall advert, as
bearing on the statements we have given in the text, namely, as
regards the footing upon which the King went to the Scottish
camp. Referring to the last article inculpating the King in this
matter, (Edinburgh Review, No. cxxxix., p. 104,) we find a
document, said to be Montrevil’s, quoted p. 109, dated in April,
1646, stating the conditions that had been agreed to by the Scots
Commissioners, on which they were to receive him; and, among
other things, it appears, “with regard to the Presbyterian
government, they desire his Majesty to agree with them—as soon
as he can.” On this, a comment is made, by which this expression
is converted into one of quite a different meaning—viz., that the
Commissioners “told him [the King] plainly (as appears by this
letter) through Montrevil, that, if he came to their army, he must
be prepared to give his assent to their Presbyterian Government
[in England] as speedily as he could.” It is quite obvious, from a
single glance, that the terms of the document and this
interpretation of it, are very different. In the former, it is only a
desire that he should agree to their proposals “as soon as he
can,” i. e., when, and if he could, make up his mind to do so; but,
in the comment, this is converted into a peremptory and pointed
requisition that he should do so, absolutely and speedily. This is
scarcely a fair construction. Take the reviewer’s further statement,
(p. 111,) “It is plain from this correspondence, that the Scots
made no promises to the King which they did not fulfil. They
engaged to assist him in his escape from Oxford—to protect his
person, which was placed in danger by the votes of the two
Houses, in case he was forced within their quarters—to treat him
with honour and respect, and not impose force on his conscience
—to admit into their camp three of his servants, &c. All this they
performed, and more they refused to promise, unless the King
gave his consent to the establishment of the Presbyterian Church
in England.” The concluding assertion assuredly is not borne out
by the document founded on; and, taking the reviewer’s own
statement in these particulars, it humbly appears to us to be
inconsistent with itself, and with the propositions that they fulfilled
the compact, and that none of the actors of that period were
responsible for the events which followed, (p. 125.) If they were
bound to protect his person from danger, which they knew to be
impending, as here assumed—if they were to treat him with
honour and respect, and not to impose force on his conscience,
surely it was a breach of such pledges, when they afterwards, not
only insisted absolutely on his violating his conscientious, his
inflexible, and oft-repeated declaration of aversion to Presbytery
as the establishment in England, but delivered him over
personally to his implacable enemies, without the slightest
security either for his safety or his honour. Even on the reviewer’s
own shewing, they violated their pledges; and, independently of
the taint which the whole proceedings of the Scottish
Commissioners received from the pecuniary part of the
transaction, the reviewer only aggravates the turpitude of the
whole affair by admitting that, in their negotiations with the King,
as to this matter, they acted clandestinely and in bad faith
towards the English Parliament. This new champion of the
Scottish Commissioners, like all his predecessors in the same
track, has signally failed in his attempts to vindicate them from
the imputations of double dealing, dissimulation, bad faith, and
sordid treachery, which has been but too conclusively laid to their
charge.

355 Rushworth, part iv., vol. i., p. 448. Thurloe, vol. i., p. 89,
92. Salmanet, p. 253-4.

356
The fire in the cavern of Etna concealed,
Still mantles unseen in its secret recess,
At length in a volume terrific revealed,
No torrent can quench it, no bounds can repress.
Byron.

357 Rushworth, part iv., vol. i., p. 485.

358 Not that they are to be heer Printed, but because they
being to bee Printed severally, this act is to be prefixed to them.

359 Rushworth, part iv., vol. i., p. 320.

360 Rushworth, part iv., vol. i., p. 327.

361 Rushworth, part iv., vol. i., p. 328.

362 Rushworth, part iv., vol. i., p. 390.

363 Vide p. 468.

364 Rushworth, part iv., vol. ii., p. 871 and 880.

365 Rushworth, part iv., vol. ii., p. 768 to 771. Acts of Estates.

366 Rushworth, part iv., vol. ii., p. 810.

367 Rushworth, part iv., vol. ii., p. 818.

368 Ibid. p. 842.

369 Ibid. p. 843.

370 Ibid. p. 859.

371 Ibid. p. 864.

372 Ibid. p. 869.

373 Burnet, p. 323-334. Vide also Rushworth, part iv., vol. ii., p.
946-950 et passim.

374 Acts of Parliament, vol. vi., p. 290.

375 Acts of Parliament, vol. vi., p. 292.

376 Ibid. p. 305.

377 Acts of Parliament, vol. vi., p. 319-322.


378 Hist. of Church, vol. iii., p. 153.

379 Baillie’s Letters, vol. ii., p. 286. See Documents.

380 Acts of Parliament, vol. vi., p. 331.

381 Acts of Parliament, vol. vi., p. 332.

382 Burnet, p. 341, et seq.

383 Turner’s Memoirs, p. 53.

384 Turner’s Memoirs, p. 56.

385 Burnet, p. 355.

386 Burnet, p. 348, et seq. Rushworth, part iv., vol. ii., p. 1193-
1242. Turner, p.63.

387 The party appellation of “Whigamores,” or, briefly, “Whigs,”


had its origin at this period; and the insurrection referred to was
called the “Whigamores’ Raid” or incursion, that term being the
common one for the predatory expeditions of the Borderers. This
nickname being still preserved in the vocabulary of party,
although there is truly none now existing that can be in any
degree assimilated to the original sect, it seems proper to explain
how the distinction originated. Mr Laing, in his history, (vol. i., p.
381, 2d ed. 1804,) informs us that “the expedition was termed
the Whigamores’ inroad, from a word employed by these western
peasants in driving horses; and the name transferred, in the
succeeding reign, to the opponents of the court, in still preserved
and cherished by the Whigs as the genuine descendants of the
covenanting Scots.” And, in a foot-note, he adds—“According to
others, from whig or whey, the customary food of those
peasants.”
Sir Walter Scott, in his “Tales of a Grandfather,” (Prose Works,
vol. xxiv.,) says:—“This insurrection was called the Whigamores’
Raid, from the word whig-whig—that is, get on, get on, which is
used by the western peasants in driving their horses—a name
destined to become the distinction of a powerful party in British
history.”
In Daniel Defoe’s “Memoirs of the Church of Scotland,” (printed
1717,) p. 173, speaking of the Covenanters, he says:—“This is the
first time that the name of a Whigg was used in the world—I
mean as applied to a man or to a party of men; and these were
the original primitive Whiggs—the name for many years being
given to no other people. The word is said to be taken from a
mixed drink the poor men drank in their wanderings, composed of
water and sour milk.”
And Bishop Burnet, who lived nearer to the time in which the
nickname was invented, gives the following explanation of it in
the “History of his own Times,” (p. 26, imperial ed. 1837):—“The
southwest counties of Scotland have seldom corn enough to serve
them round the year, and the northern parts producing more than
they need, those in the west came in the summer to buy at Leith
the stores that came from the north; and from a word Whiggam,
used in driving their horses, all that drove were called
Whiggamors; and, shorter, the Whiggs. Now, in that year, after
the news came down of Duke Hamilton’s defeat, the Ministers
animated their people to rise and march to Edinburgh; and they
came up marching on the head of their parishes with an unheard-
of fury, praying and preaching all the way as they came. The
Marquis of Argyle and his party came and headed them, they
being about 6,000. This was called the Whiggamors’ inroad; and,
ever after that, all that opposed the court came, in contempt, to
be called Whiggs; and from Scotland the word was brought into
England, where it is now one of our unhappy terms of distinction.”
The following description of the Whigs, in some of their risings
after the restoration of Charles II., is taken from a MS. copy of a
doggrel poem, (by Cleland, it is thought,) which the editor
presented some years ago to the Library of the Antiquarian
Society of Edinburgh—
“It was in Januar or December,
When I did see the outlaw Whigs
Lye scattered up and down the riggs
Some had hoggers, some straw boots,
Some uncovered leggs and coots;
Some had halbards, some had durks,
Some had crooked swords, like Turks;
Some had slings, and some had flails,
Knit with eel and oxen tails;
Some had speares, some had pikes,
Some had spades which delvit dykes;
Some had guns with roustie ratches,
Some had firie peats for matches;
Some had bows, but wanted arrows,
Some had pistols without marrows;
Some the coulter of a plough,
Some syths had, men and horse to hough;
And some with a Lochaber axe
Resolved to give Dalziell his paiks;
Some had cross-bows, some were slingers,
Some had only knives and whingers;
But most of all, (believe who lists,)
Had nought to fight with but their fists:
They had no colours to display;
They wanted order and array;
Their officers and motion-teachers
Were verie few beside their preachers:
Without horse, or artilzierie pieces,
They thought to imitate the Sweeses,
When from Novarr they sallyed out,
Tremoville and brave Trivulce to rout.
For martial musique everie day
They used oft to sing and pray,
Which chears them more, when danger comes,
Than others’ trumpets and their drums.
With such provision as they had,
They were so stout, or else so madd,
As to petition once again;
And, if the issue proved vain,
They were resolved, with one accord,
To fight the battells of the Lord.”
388 Vide Documents.

389 Rushworth, part iv., vol. ii., p. 1282-1289.

390 Rushworth, part iv., vol. ii., p. 1295.

391 Rushworth, part iv., vol. ii., p. 1311.

392 Vide Documents.

393 Rushworth, part iv., vol. ii., p. 1338.

394 Ibid. p. 1338-1343.

395 Rushworth, part iv., vol. ii., p. 1350-1351.

396 Ibid. p. 1352.

397 Ibid. p. 1353.

398 Ibid. p. 1354.

399 Rushworth, part iv., vol. ii., p. 1358-61.

400 Ibid. p. 1361.

401 Ibid. p. 1362.

402 Rushworth, part iv., vol. ii., p. 1376-80.

403 Ibid. p. 1382-83.

404 Rushworth, part iv., vol. ii., p. 1392.

405 Acts, vol. vi., p. 337.

406 Ibid. p. 339.

407 Ibid. p. 341.

408 Ibid. p. 349-50.

409 Ibid. p. 352-6.

410 Acts, vol. vi., p. 359-60.

411 Vide Documents.


412 Rushworth, part iv., vol. ii., p. 1426, et seq.

413 Acts, vol. vi., p. 362.

414 Ibid. p. 363.

415 Ibid. p. 364.

416 Ibid. p. 411.

417 Acts, vol. vi., p 451, et seq

418 The annuity-tax to the six ministers in Edinburgh was first


imposed by an Act on the 19th of June, 1649.

419 Burnet, p. 575.

420 Originals in the Register Office, Edinburgh.

421 Rushworth, part iv., vol. ii., p. 1330.

422 Rushworth, part iv., vol. ii., p. 1395, et seq.

423 Acts of Estates, vol. vi., p. 411.

424 Scott’s Extracts from an Hospital Register of Perth, MS., in


the Advocates’ Library, pp. 385-6.

425 Balfour’s Annales and Lamont’s Diary. Vide ante, p. 587-8.

426 Lamont’s Diary, p. 12. Vide ante, p. 589.

427 Balfour’s Annales, vol. iii., pp. 410-413.

428 Acts of Estates, vol. vi., p. 481.

429 Ibid, p. 491.

430 Ibid, pp. 504, 505, 506.

431 Acts of Estates, vol. vi. p. 513.

432 Vide Guthrie’s Waters of Sihor, postea, p. 619.

433 There was a General Assembly held at Edinburgh, on 10th


July, this year, for which see Lamont’s Diary, postea.—Ed.
434 The volume containing these is not known to be in
existence.

435 Vide ante, p. 599.

436 Vide ante, p. 613.

437 Vide ante, p. 604.

438 “The Waters of Sihor, or the Lands Defectione; founded on


yᵉ late Publick Resolutiones of the Comissione of the General
Assembly, and of the Parliment at Perth, 1651, concerning the
Imploying and Intrusting of the Malignant party in the Army and
in the Judicatories, discovered and demonstrated,” 341 pages MS.
in Advocate’s Library.—Wodrow MS., vol. xvii.—Rob. iii., 2.15. Such
is the title of a work by James Guthrie, one of the leading
Protestors, who made a great figure in the transactions of these
times, and who was executed after the restoration of Charles II.
We are not aware that this work has ever been printed, and think
it right to give some specimens of the principles and practices of
the Protestors, as exhibited in the writings of one of their most
conspicuous leaders.

439 Vide ante, p. 501.

440 Vide ante, p. 600.

441 Vide ante, p. 599-600.

442 Vide ante, p. 599.

443 Journal, p. 160, et seq.

444 Vide ante, p. 599.

445 For the Heads of the Declaration, see p. 599, ante.

446 Wodrow’s 8vo MSS, vol. v., in the Advocate’s Library.

447 Most of these Documents are to be found in Wodrow’s


MSS., vol. xvii., in the Advocates’ Library.

448 Wodrow’s 4to MSS., vol. xvii., in the Advocates’ Library.

449 Vide ante, p. 636.


450 The General Assembly was sitting in St Andrew’s at this
time, and in consequence of the success of Lambert, on the 20th,
adjourned to Dundee, and, finally, was broken up. Vide Gordon’s
account of it, ante p. 626-631.

451 Most of these Documents are to be found in Wodrow’s


MSS., vol. xvii., in the Advocates’ Library.

452 Vide ante, p. 649.


Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like