Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Programming Elixir ≥ 1.6
About the Pragmatic Bookshelf
Table of Contents
Foreword
A Vain Attempt at a Justification, Take Two
Acknowledgments
Chapter 1: Take the Red Pill
Programming Should Be About Transforming Data
Installing Elixir
Running Elixir
Suggestions for Reading the Book
Exercises
Think Different(ly)
Part 1: Conventional Programming
Assignment: I Do Not Think It Means What You Think It Means.
More Complex Matches
Your Turn
Ignoring a Value with _ (Underscore)
Variables Bind Once (per Match)
Your Turn
Another Way of Looking at the Equals Sign
You Already Have (Some) Immutable Data
Immutable Data Is Known Data
Performance Implications of Immutability
Coding with Immutable Data
Built-in Types
Value Types
System Types
Collection Types
Maps
Binaries
Dates and Times
Names, Source Files, Conventions, Operators, a nd So On
Variable Scope
End of the Basics
Functions and Pattern Matching
Your Turn
One Function, Multiple Bodies
Your Turn
Functions Can Return Functions
Your Turn
Passing Functions as Arguments
Your Turn
Functions Are the Core
Compiling a Module
The Function’s Body Is a Block
Your Turn
Function Calls and Pattern Matching
Your Turn
Guard Clauses
Default Parameters
Your Turn
Private Functions
The Amazing Pipe Operator: | >
Modules
Module Attributes
Module Names: Elixir, Erlang, and Atoms
Calling a Function in an Erlang Library
Finding Libraries
Your Turn
Heads and Tails
Using Head and Tail to Process a List
Using Head and Tail to Build a List
Creating a Map Function
Reducing a List to a Single Value
Your Turn
More Complex List Patterns
Your Turn
The List Module in Action
Get Friendly with Lists
How to Choose Between Maps, Structs, and Keyw ord Lists
Keyword Lists
Maps
Pattern Matching and Updating Maps
Updating a Map
Structs
Nested Dictionary Structures
Sets
With Great Power Comes Great Temptation
Chapter 9: An Aside—What Are Types?
Enum—Processing Collections
Your Turn
Streams—Lazy Enumerables
The Collectable Protocol
Comprehensions
Your Turn
Moving Past Divinity
String Literals
The Name “strings”
Single-Quoted Strings—Lists of Character Code s
Your Turn
Binaries
Double-Quoted Strings Are Binaries
Your Turn
Binaries and Pattern Matching
Your Turn
Familiar Yet Strange
if and unless
cond
case
Raising Exceptions
Designing with Exceptions
Doing More with Less
Your Turn
The Project: Fetch Issues from GitHub
Step 1: Use Mix to Create Our New Project
Transformation: Parse the Command Line
Write Some Basic Tests
Your Turn
Refactor: Big Function Alert
Transformation: Fetch from GitHub
Step 2: Use Libraries
Your Turn
Transformation: Convert Response
Transformation: Sort Data
Transformation: Take First n Items
Your Turn
Transformation: Format the Table
Step 3: Make a Command-Line Executable
Step 4: Add Some Logging
Step 5: Create Project Documentation
Coding by Transforming Data
Your Turn
Debugging with IEx
Testing
Code Dependencies
Server Monitoring
Source-Code Formatting
Inevitably, There’s More
Part 2: Concurrent Programming
Chapter 15: Working with Multiple Processes
A Simple Process
Process Overhead
Your Turn
When Processes Die
Your Turn
Parallel Map—The “Hello, World” of Erlang
Your Turn
A Fibonacci Server
Your Turn
Agents—A Teaser
Thinking in Processes
Chapter 16: Nodes—The Key to Distributing Services
Naming Nodes
Your Turn
Naming Your Processes
Your Turn
Input, Output, PIDs, and Nodes
Your Turn
Nodes Are the Basis of Distribution
Chapter 17: OTP: Servers
Some OTP Definitions
An OTP Server
Your Turn
Your Turn
GenServer Callbacks
Naming a Process
Tidying Up the Interface
Making Our Server into a Component
Your Turn
Chapter 18: OTP: Supervisors
Supervisors and Workers
Your Turn
Your Turn
Worker Restart Options
Supervisors Are the Heart of Reliability
Chapter 19: A More Complex Example
Introduction to Duper
The Duper Application
But Does It Work?
Planning Your Elixir Application
Next Up
Chapter 20: OTP: Applications
This Is Not Your Father’s Application
The Application Specification File
Turning Our Sequence Program into an OTP Appl ication
Supervision Is the Basis of Reliability
Your Turn
Releasing Your Code
Distillery—The Elixir Release Manager
OTP Is Big—Unbelievably Big
Your Turn
Chapter 21: Tasks and Agents
Tasks
Agents
A Bigger Example
Agents and Tasks, or GenServer?
Part 3: More Advanced Elixir
Chapter 22: Macros and Code Evaluation
Implementing an if Statement
Macros Inject Code
Using the Representation as Code
Your Turn
Using Bindings to Inject Values
Macros Are Hygienic
Other Ways to Run Code Fragments
Macros and Operators
Digging Deeper
Digging Ridiculously Deep
Your Turn
Chapter 23: Linking Modules: Behavio(u)rs and use
Behaviours
use and __using__
Putting It Together—Tracing Method Calls
Use use
Your Turn
Chapter 24: Protocols—Polymorphic Functions
Defining a Protocol
Implementing a Protocol
The Available Types
Your Turn
Protocols and Structs
Built-in Protocols
Protocols Are Polymorphism
Your Turn
Chapter 25: More Cool Stuff
Writing Your Own Sigils
Your Turn
Multi-app Umbrella Projects
But Wait! There’s More!
Appendix 1: Exceptions: raise and try, catch and throw
Raising an Exception
catch, exit, and throw
Defining Your Own Exceptions
Now Ignore This Appendix
Appendix 2: Type Specifications and Type Checking
When Specifications Are Used
Specifying a Type
Defining New Types
Specs for Functions and Callbacks
Using Dialyzer
Bibliography
You May Be Interested In…
← Prev
Back
Next →
← Prev
Back
Next →