PDF Introducing ReScript: Functional Programming for Web Applications 1st Edition Danny Yang download
PDF Introducing ReScript: Functional Programming for Web Applications 1st Edition Danny Yang download
com
https://ebookmass.com/product/introducing-rescript-
functional-programming-for-web-applications-1st-edition-
danny-yang/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmass.com/product/introducing-functional-programming-
using-c-leveraging-a-new-perspective-for-oop-developers-vaskaran-
sarcar/
ebookmass.com
https://ebookmass.com/product/php-8-basics-for-programming-and-web-
development-1st-edition-gunnard-engebreth/
ebookmass.com
https://ebookmass.com/product/php-8-basics-for-programming-and-web-
development-gunnard-engebreth/
ebookmass.com
Coastal Reservoir: Technology and Applications 1st Edition
Shu-Qing Yang
https://ebookmass.com/product/coastal-reservoir-technology-and-
applications-1st-edition-shu-qing-yang/
ebookmass.com
https://ebookmass.com/product/mastering-functional-programming-with-
python-brett-neutreon/
ebookmass.com
https://ebookmass.com/product/functional-programming-in-r-4-second-
edition-thomas-mailund/
ebookmass.com
Danny Yang
Introducing ReScript: Functional Programming for Web Applications
Danny Yang
Mountain View, CA, USA
Introduction���������������������������������������������������������������������������������������xiii
iii
Table of Contents
Chapter 2: Functions��������������������������������������������������������������������������29
Defining and Using Functions�����������������������������������������������������������������������������29
Type Annotations�������������������������������������������������������������������������������������������31
Using Standard Library Functions and Opening Modules������������������������������32
Higher-Order Functions���������������������������������������������������������������������������������34
Piping������������������������������������������������������������������������������������������������������������35
Labeled and Optional Parameters�����������������������������������������������������������������38
Currying and Partial Application��������������������������������������������������������������������40
Polymorphic Functions����������������������������������������������������������������������������������42
Pure Functions����������������������������������������������������������������������������������������������������43
Ignoring Return Values����������������������������������������������������������������������������������44
Recursion������������������������������������������������������������������������������������������������������������46
Syntax������������������������������������������������������������������������������������������������������������46
How to Use Recursion�����������������������������������������������������������������������������������48
Final Thoughts�����������������������������������������������������������������������������������������������������52
iv
Table of Contents
v
Table of Contents
Printing Objects�������������������������������������������������������������������������������������������105
Objects and JSON����������������������������������������������������������������������������������������106
Objects vs. Records������������������������������������������������������������������������������������������108
Chapter 6: Collections����������������������������������������������������������������������141
Immutable Collections��������������������������������������������������������������������������������������142
Immutable Sets�������������������������������������������������������������������������������������������143
Immutable Maps������������������������������������������������������������������������������������������146
vi
Table of Contents
Chapter 7: Modules��������������������������������������������������������������������������173
Files as Modules�����������������������������������������������������������������������������������������������174
Defining Modules����������������������������������������������������������������������������������������������174
Using Modules��������������������������������������������������������������������������������������������������175
Opening Modules�����������������������������������������������������������������������������������������177
Destructuring a Module�������������������������������������������������������������������������������181
Module Examples����������������������������������������������������������������������������������������������182
Module Signatures��������������������������������������������������������������������������������������������188
Interface Files����������������������������������������������������������������������������������������������189
Defining Module Signatures������������������������������������������������������������������������189
Functors������������������������������������������������������������������������������������������������������194
Defining and Using Functors�����������������������������������������������������������������������195
Extending Modules��������������������������������������������������������������������������������������197
Functors in the Standard Library�����������������������������������������������������������������199
Final Thoughts���������������������������������������������������������������������������������������������������200
vii
Table of Contents
Index�������������������������������������������������������������������������������������������������255
viii
About the Author
Danny Yang is a professional software engineer at Meta working on
infrastructure for WhatsApp. He has previously worked on Facebook
Messenger, including the web interface which was written in ReScript.
His technical interests include functional programming, compilers, and
data visualization, which he writes about on his blog at www.yangdanny97
.github.io.
ix
About the Technical Reviewer
German Gonzalez-Morris is a software architect/engineer working
with C/C++, Java, and different application containers, in particular
with WebLogic Server. He has developed various applications using JEE,
Spring, and Python. His areas of expertise also include OOP, Java/JEE,
Python, design patterns, algorithms, Spring Core/MVC/security, and
microservices. German has worked with performance messaging, RESTful
API, and transactional systems. For more information about him, visit
www.linkedin.com/in/german-gonzalez-morris.
xi
Introduction
Why Learn ReScript?
JavaScript is vital to the modern web ecosystem. It’s used in the front end
to implement websites and other user interfaces, and used in the back end
to implement servers for websites and APIs.
Part of JavaScript’s ubiquity is due to its ease of use. JavaScript is
dynamic and flexible, making it easy for people to pick up. However, this
strength becomes a weakness when working on large web applications
with multiple developers – the only way to know that JavaScript code works
correctly is to actually run it, and it’s relatively easy to make mistakes when
programming in JavaScript.
What if there was a way to detect bugs in JavaScript before running
the code, or prevent many classes of bugs altogether? What if there was a
language that was concise and elegant that made it easy for programmers
to write complex web applications and hard for programmers to make
mistakes?
Enter ReScript.
ReScript is a language designed for writing web applications. It brings
a lot to the table: static typechecking, a strong type system, and powerful
language features that will change the way you program.
Here’s a glimpse of some of the features that make ReScript a great
language:
xiii
Introduction
There are a number of other languages and tools that offer static
typechecking for web applications, but ReScript has several key advantages
over its competitors. As an example, let’s look at the benefits ReScript has
compared with another popular JavaScript alternative, TypeScript:
xiv
Introduction
History of ReScript
The lineage of ReScript can ultimately be traced back to the ML family of
languages originating from the 1960s. In particular, ReScript is directly
based on OCaml, a general-purpose programming language that was
developed in the 1980s and used today for systems programming in
academia and industry.
In 2015, Jordan Walke, the creator of the React web framework,
developed a toolchain and alternative syntax for OCaml called Reason.
Reason was designed to bridge the gap between the web and OCaml
ecosystems – it could be compiled into both native machine code and
JavaScript, allowing web developers to take advantage of OCaml’s
features. Static typechecking and OCaml’s sound type system eliminated
many common bugs in JavaScript code, and OCaml’s immutability and
functional style was a great fit for React.
Reason was compiled to JavaScript using a compiler called
BuckleScript, which was developed at Bloomberg around the same time
Reason was being created at Facebook.
Around 2020, the BuckleScript project created a new language
based on Reason that could only be compiled to JavaScript using the
BuckleScript compiler, and so ReScript was born.
xv
Introduction
xvi
Discovering Diverse Content Through
Random Scribd Documents
The Project Gutenberg eBook of The works of
the Rev. John Wesley, Vol. 09 (of 32)
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.
Title: The works of the Rev. John Wesley, Vol. 09 (of 32)
Language: English
Transcriber’s Notes
The cover image was provided by the transcriber and is placed
in the public domain.
The text may show quotations within quotations, all set off by
similar quote marks. The inner quotations have been
changed to alternate quote marks for improved readability.
This book was written in a period when many words had not
become standardized in their spelling. Words may have
multiple spelling variations or inconsistent hyphenation in
the text. These have been left unchanged unless indicated
with a Transcriber’s Note.
WORKS
OF THE
Volume IX.
B R I S T O L:
Printed by WILLIAM PINE, in Wine-Street.
MDCCLXXII.
THE
CONTENTS
Of the Ninth Volume.
Chapter VIII. Of their care of the poor sick, their hospitality, and
patience.
The doctrine of Salvation, Faith, and Good Works; extracted from the
homilies of the church of England.
A Word to a Swearer.
A Word to a Drunkard.
A Word to a Smuggler.
A Word to a Protestant.
A Word to a Freeholder.
Advice to a Soldier.
The Manners of the
ANCIENT
C H R I S T I A N S.
Extracted from a French Author.
C H A P T E R I.
Of the life of Christ.
9. That his disciples might have the full benefit of his example,
he lived with them in common, as one family. They followed him
wherever he went; they eat and lodged with him; they had
opportunity of studying him continually. He spared no pains to
instruct them. What they understood not in his public discourses, he
explained to them in private; treating them as his friends, and telling
them all things, as they were able to bear them. He bore with the
utmost patience, their dulness, their ignorance, their vanity, and all
their faults, and laboured without ceasing to correct them.
*10. But he had other disciples beside the twelve: for all who
believed and were baptized were called his disciples. St. Paul
mentions above 500 of them, who together saw him after his
resurrection. So that the church even then consisted of two parts:
the people, simply called The disciples or The brethren, and those
whom Christ had set apart for ministring in public: such were first,
The apostles, and then the seventy, whom he chose, and sent two
and two before his face.
12. But in his sufferings chiefly hath “He left us an example, that
we should tread in his steps.” Being like us in all things, except sin,
he felt all the inconveniences of life; hunger, thirst and weariness
and pain: and the state he was in, the night before his passion in the
garden, plainly shews, that he was sensible like us, of grief and fear
and sadness. Add to these his sense of the hardness of men’s
hearts, and the contradiction of sinners. But he suffered all, and
particularly in his passion, with an invincible constancy. He who with
a word could have confounded his accusers and judges together,
opened not his mouth. He stood unmoved as a rock in the midst of
all insults, reproaches, outrages. On the very cross he possest his
soul in patience. Even there retaining composure of mind, he prays
for his murderers; he accepts the faith of the penitent thief; he
provides for his mother’s comfort; he finishes the accomplishment of
the prophecies; he commends his spirit to God.
C H A P T E R II.
Of the church at Jerusalem.
1. FTER the apostles had received the Holy Ghost, they were living
A images of Jesus Christ. And by them all the following servants
of Christ were to form their hearts and lives. So St. Paul to the
Corinthians, Be ye followers of me, as I am of Christ: and to the
♦Philippians, Brethren, be followers together of me, and mark them
which walk so, as ye have us for an example.
C H A P T E R III.
The state of the Heathens before their conversion.
1. HEY who are unacquainted with history, suppose, that the men
T who lived seventeen hundred years ago, were more artless,
more innocent and more teachable, than those that are now alive.
But the writings of those times which still remain, clearly prove the
contrary. The crimes, whereof they give us to full accounts, were
committed in the face of the sun. No one ran into a corner to
commit them, or endeavoured afterwards to conceal them. And the
providence of God seems to have preserved these accounts, on
purpose to shew, from what an abyss of corruption (described in
short by St. Paul in the beginning of his epistle to the Romans) Jesus
Christ delivered the world.
C H A P T E R IV.
Of their prayer and study of the scriptures.
1. HOSE who were baptized began to lead a new life, wholly
T spiritual and supernatural: a life of faith and prayer:
remembring the words of their Lord, that men ought always to pray
and not to faint; they endeavoured to pray without ceasing, and
used all sorts of means, that the application of their spirit to God,
might ♦be interrupted the least that was possible. But of all prayer,
they had the greatest esteem for public; as well knowing, the more
persons joined together, to beg of God any mercy, the more force
their prayers had to obtain it. And the service ended, they saluted
each other, the men the men, and the women the women, with the
kiss of peace.
C H A P T E R V.
Of their fasts, meals, modesty and seriousness.
1. HE fasts of the ancients were either yearly, as that of Lent, which
T they observed daily till six in the evening; or weekly, as those
of Wednesday and Friday, which they observed till three in the
afternoon. The yearly they kept in memory of their Lord, and in
obedience to that command, When the bridegroom shall be taken
away, then shall they fast in those days. And the weekly too were
observed throughout the whole church, in remembrance of his
passion: because on Wednesday the council against him was held,
and on Friday he was put to death. During the whole Lent, many eat
only bread and water: some added thereto nuts and almonds: and
others were obliged to use different food, according to their different
infirmities. But all abstained from wine and delicate meats, during
whatever time was set apart for fasting, and spent as large a
proportion of it as they could, in retirement, reading and prayer.
2. At all times the meals of Christians were plain and frugal. They
did not live to eat, but eat to live. They used only such food and
such a measure of it, as was necessary for health and strength. As
to the kinds of food, they eat whatever was set before them, except
blood and things strangled; from which they carefully abstained,
according to the decree of the apostles speaking by the Holy Ghost.
Some indeed there were in all ages, who eat only herbs with bread
and water: not out of any abhorrence of other food; but believing
this to be best for their own weakness. No Christians eat with
♦ heretics, or persons excommunicate: but they did sometimes with
infidels, that they might not break off all society with them.
7. Nor did the care of their posterity give them any inquietude.
The happiness they wished their children was no other, than that
they desired for themselves, even to finish their course with joy. If
they left them orphans, they knew the church would be their mother,
and supply all their wants. Thus they lived without care, without
fear, without desire of any of the things of the world. But not without
pleasure. What pleasure, (says Tertullian) is greater than contempt
of the world, “contempt of death, true liberty, purity of conscience;
contentedness with all things? You tread under foot the gods of the
Heathens; you heal diseases; you cast out devils; you are led by the
Holy Ghost; you live to God. These are the pleasures; these the
diversions of Christians.”
C H A P T E R VI.
Of their marriages, their union and public assemblies.
1.
W
ITH all this disengagement from the world, the greatest part of
the first Christians were married. They were sensible indeed
of the vast advantages, which St. Paul observes belong to a single
life. And many accordingly chose it, both men and women, for the
kingdom of heaven’s sake: but they knew, all men cannot receive
this saying: and therefore never ♦ condemned those who did not
receive it. Those who bred up orphans generally married them
young, and usually to their own children. For interest had nothing to
do with their choice, nor indeed any other consideration but the
glory of God. In this, as in all important affairs, they failed not to
consult the bishop; and when all was fixed, the marriage was
publicly and solemnly celebrated in the church, where it was
consecrated by the blessing of the pastor, and confirmed by the
oblation of the holy eucharist.
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.
ebookmass.com