Programming Elm

Book description

Elm brings the safety and stability of functional programing to front-end development, making it one of the most popular new languages. Elm's functional nature and static typing means that run-time errors are nearly impossible, and it compiles to JavaScript for easy web deployment. This book helps you take advantage of this new language in your web site development. Learn how the Elm Architecture will help you create fast applications. Discover how to integrate Elm with JavaScript so you can update legacy applications. See how Elm tooling makes deployment quicker and easier.

Functional programming offers safer applications with decreased runtime errors, but functional solutions that are type safe and easy to use have been hard to find, until the Elm language. Elm has the benefits of functional languages while compiling to JavaScript. This book provides a complete tutorial for the Elm language, starting with a simple static application that introduces Elm syntax, modules, and the virtual DOM, to exploring how to create a UI using functions. See how Elm handles the issues of state in functional languages. You'll continue to build up larger applications involving HTTP requests for communication. Integrate your Elm applications with JavaScript so you can update legacy applications or take advantage of JavaScript resources.

Elm also provides built-in tooling to alleviate the tooling creep that's so common in JavaScript. This book covers Elm's deployment and testing tools that ease development confusion. Dive into advanced concepts including creating single-page applications, and creating performance improvements. Elm expert Jeremy Fairbank brings his years of web development experience to teaching how to use Elm for front-end development.

Your web UIs will be faster, safer, and easier to develop with Elm and this tutorial.

What You Need:

You will need the latest version of Elm, 0.19, along with a browser to run the examples in this book.

Publisher resources

View/Submit Errata

Table of contents

  1.  Preface
    1. Why Elm?
    2. Who Is This Book For?
    3. What’s In This Book?
    4. How to Read This Book
    5. Online Resources
    6. Acknowledgements
  2. 1. Get Started with Elm
    1. Get Started with Functions
    2. Use Static Types
    3. Build a Static App
    4. What You Learned
  3. 2. Create Stateful Elm Applications
    1. Apply the Elm Architecture
    2. Create the View
    3. Handle State Changes
    4. The Elm Architecture Life Cycle
    5. What You Learned
  4. 3. Refactor and Enhance Elm Applications
    1. Refactor with Good Practices
    2. Comment on Photos
    3. What You Learned
  5. 4. Communicate with Servers
    1. Safely Decode JSON
    2. Fetch from HTTP APIs
    3. What You Learned
  6. 5. Go Real-Time with WebSockets
    1. Load Multiple Photos
    2. Receive Photos from WebSockets
    3. What You Learned
  7. 6. Build Larger Applications
    1. Organize the View
    2. Simplify Messages
    3. Use Nested State
    4. Use Extensible Records
    5. Remove View Duplication
    6. Prevent Invalid States
    7. What You Learned
  8. 7. Develop, Debug, and Deploy with Powerful Tooling
    1. Debug Code with the Debug Module
    2. Rapidly Develop and Deploy Elm Applications
    3. What You Learned
  9. 8. Integrate with JavaScript
    1. Embed an Elm Application
    2. Upload Images with Ports
    3. Display Uploaded Images
    4. What You Learned
  10. 9. Test Elm Applications
    1. Test-Driven Development in Elm
    2. What to Expect When You’re Expecting
    3. Fuzz Your Tests
    4. Test an Application
    5. What You Learned
  11. 10. Build Single-Page Applications
    1. Build a Skeleton SPA
    2. Route to a Component Page
    3. Welcome Back Picshare
    4. Handle Dynamic Routes
    5. What You Learned
  12. 11. Write Fast Applications
    1. Benchmark Code
    2. Traverse Large Lists
    3. Get Lazy
    4. Build Lazy Applications
    5. What You Learned
  13. A1. Install Elm
    1. All Roads Lead to Node
    2. Install the Elm Compiler
    3. Install Development Tools
  14. A2. Run the Local Server
    1. Install and Run the Server
  15. A3. Elm Package Versions
    1. Install an Older Package Version
  16.  Bibliography

Product information

  • Title: Programming Elm
  • Author(s): Jeremy Fairbank
  • Release date: July 2019
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781680502855