You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The important detail is that we factor the state into two components.
239
-
One represents where in the overall structure we are (inside the `head`, inside the `body`, or inside neither).
240
-
The other represents whether we have a `title` element or not.
241
-
We could certainly represent this with one state type variable, but I find the factored representation easier to work with.
240
+
The key point is that we factor the state into two components.
241
+
`StructureState` represents where in the overall structure we are (inside the `head`, inside the `body`, or inside neither).
242
+
`TitleState` represents the state when defining the elements inside the `head`, specifically whether we have a `title` element or not.
243
+
We could certainly represent this with one state type variable, but I find the factored representation both easier to work with and easier for other developers to understand.
244
+
We can implement more complex protcols, such as those that can be represented by context-free or even context-sensitive grammars, using the same technique.
242
245
243
246
Here's an example in use.
244
247
@@ -261,9 +264,109 @@ Html.empty.head
261
264
.h1("This Shouldn't Work")
262
265
```
263
266
264
-
(Note that the error messages are not great. We'll address this in Chapter [@sec:usability]).
267
+
These error messages are not great. We'll address this in Chapter [@sec:usability].
265
268
266
-
We can implement more complex protcols, such as those that can be represented by context-free or even context-sensitive grammars, using the same technique.
269
+
270
+
#### Exercise: HTML API Design {-}
271
+
272
+
I don't particularly like the HTML API we developed above,
273
+
as the flat method call structure doesn't match the nesting in the HTML structure we're creating.
0 commit comments