Elm is also a strong, statically typed language, preventing incorrectly typed programs from compiling and runtime exceptions from occurring. In addition to the typical data types like strings and lists, Elm offers union types that provide a powerful mechanism for representing custom types and the values they can take on. With no null data type, Elm also avoids null-reference errors by supplying built-in union types such as maybe and result that guarantee code handles null-like situations.
Jeremy then examines Elm’s architecture, which espouses a unidirectional Model-View-Update pattern. Elm applications provide a view function for displaying their state and an update function for creating new state and represent possible changes to their state via messages, which are typically implemented with union types. While this architecture sounds similar to Redux, it offers greater safety through static typing and pure functions. To better explain how Elm applications work, Jeremy walks you through creating a model, view function, and update function in a simple Elm application. He also discusses how to manage side effects such as HTTP requests in a pure manner via commands.
You’ll leave ready to start incorporating Elm into your frontend development.
©2017, O'Reilly Media, Inc. • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • email@example.com