π³
π³
π³
π³
Walking though the Elm woods
Searchβ¦
π³
π³
π³
π³
Walking though the Elm woods
Introduction
Structure of the book
Frequently asked questions
How can different types share data?
How to break Dependency Cycles?
How to structure an Elm project?
How to turn a Msg into a Cmd Msg?
How to update nested Records?
What are comparable types?
Why are Booleans bad?
π
Future topics
Recipes
Writing a Single Page Application
Making impossible states Impossible
Non empty lists using Zippers
Restrict records using Opaque Types
Write safer functions using Phantom Types
Designing Elm package APIs
π
Future topics
Frameworks and packages
elm/parser
mdgriffith/elm-ui
π
Future topics
Powered By
GitBook
Making impossible states Impossible
A good coding practice in Elm is to define the Model such that impossible states can not occur.
Instead of writing
1
type alias ServerRequest =
2
{ Response (Maybe String)
3
, Failed (Maybe Error)
4
}
5
-- There can not be a Response and an Error at the same time.
Copied!
one can use
1
type ServerRequest =
2
Waiting
3
Response String
4
Failed Error
Copied!
In this section we will look at common ways how to avoid impossible states.
Further reading
π₯
Video:
Making impossible states impossible
by Richard Feldman
β
Example:
Tic Tac Toe
β
β
Example:
Subset of {a,b}
β
β
Example:
Up to 2 choices of a set
β
Previous
Reusable views
Next
Non empty lists using Zippers
Last modified
2yr ago
Copy link
Contents
Further reading