Description |
1 online resource (281 pages) |
Contents |
Intro -- Table of Contents -- About the Author -- About the Technical Reviewer -- Introduction -- Chapter 1: ReScript Basics -- Expressions, Values, and Side Effects -- Compile Time and Runtime -- Types, Typechecking, and Type Inference -- Primitive Types and Operators -- Integer and Float -- Boolean -- String -- Unit -- Printing and Debugging -- Bindings -- Mutation and Refs -- Blocks -- Block Scoping -- Conditionals -- Switches -- Loops -- Putting It All Together -- Final Thoughts -- Chapter 2: Functions -- Defining and Using Functions -- Type Annotations |
|
Using Standard Library Functions and Opening Modules -- Higher-Order Functions -- Piping -- Labeled and Optional Parameters -- Currying and Partial Application -- Polymorphic Functions -- Pure Functions -- Ignoring Return Values -- Recursion -- Syntax -- How to Use Recursion -- Final Thoughts -- Chapter 3: Composite Data Types -- Tuples -- Creating Tuples -- Accessing Tuples -- Pattern Matching with Tuples -- Variants -- Declaring and Constructing Variants -- Pattern Matching with Variants -- Exhaustiveness -- Complex Patterns -- Variants with Data -- Recursive Data Types -- Options |
|
Pattern Matching Options -- Exceptions and Error Handling -- Raising Exceptions -- Catching Exceptions -- Custom Exceptions -- Another Way to Handle Errors: Result -- Result in Action -- Defining Errors for Results -- Composing Results -- Final Thoughts -- Chapter 4: Records and Objects -- Records -- Declaring and Creating Records -- Nominal Typing -- Accessing Record Fields -- Updating Records -- Mutable Fields -- Optional Fields -- Destructuring Records -- Pattern Matching with Records -- Records and Variants -- Printing Records -- Records and JSON -- Serialization -- Deserialization -- Objects |
|
Declaring and Creating Objects -- Accessing Object Fields -- Structural Typing -- Mutating Objects -- Printing Objects -- Objects and JSON -- Serializing Objects -- Deserializing Objects -- Objects vs. Records -- Chapter 5: Lists and Arrays -- Arrays -- Array Standard Library -- Note on Accessing Arrays -- Higher-Order Functions for Arrays -- Map -- Filter -- Reduce -- Composing Higher-Order Functions -- Higher-Order Functions in Action -- Generalizing Higher-Order Functions -- Lists -- Building a List -- Immutability and Lists -- Pattern Matching with List -- Higher-Order Functions with Lists |
|
Drawbacks of Lists -- Use Cases for Immutable Collections -- Lists vs. Arrays -- Final Thoughts -- Chapter 6: Collections -- Immutable Collections -- Immutable Sets -- Creating a Set -- Updating a Set -- Common Set Operations -- Immutable Maps -- Creating a Map -- Updating a Map -- Accessing a Map -- Using Collections: Luggage Example Revisited -- Advanced Topic: Generic Collections -- Mutable Collections -- Mutable Stack -- Mutable Queue -- Mutable Set and Mutable Map -- Mutable Map Example -- Hash Set and Hash Map -- Creating a Hash Set/Hash Map -- Accessing Hash Maps -- Hash Map Example |
Note |
Advanced Topic: Generic Hash Set/Hash Map Keys |
Summary |
This book serves as a succinct guide on ReScript, a functional language for building web applications. Using examples of ReScript language features along with explanations of fundamental concepts in functional programming, this book will show web developers with a background in JavaScript how to effectively use ReScript to its full potential. In Introducing ReScript, you'll learn how to use features in ReScript that JavaScript lacks, such as type inference, null-safety, algebraic data types, pattern matching, and more. Along the way, you'll pick up functional programming concepts like immutability and higher-order functions. You'll also gain a sense of how ReScript works under the hood and how to leverage interoperability between ReScript and JavaScript. Whether you're a web developer interested in dabbling with functional programming or you just want to learn how to write safer and cleaner code for web applications, this book is a great way for you to get started with ReScript. What You Will Learn Use ReScript to write clean, safe, and elegant software Understand the features of ReScript that set it apart from JavaScript, such as type inference, null-safety, and algebraic data types Explore functional programming concepts like immutabhigher-orderr order functions, and pattern matching Use popular JavaScript libraries and frameworks in your ReScript code and integrate ReScript code into JavaScript codebases Who This Book Is For Web developers that want a strictly typed, safer alternative to JavaScript, as well as web developers interested in learning functional programming and leveraging the elegant and powerful functional features in ReScript. |
Note |
Includes index. |
Subject |
Web applications -- Programming.
|
|
Applications Web -- Programmation. |
Other Form: |
Print version: Yang, Danny Introducing Rescript Berkeley, CA : Apress L. P.,c2023 9781484288870 |
ISBN |
9781484288887 (electronic bk.) |
|
1484288882 (electronic bk.) |
Standard No. |
10.1007/978-1-4842-8888-7 doi |
|