The following code from this guide employs a union type to hold all possible widget types, then render a view:
type Widget
= ScatterPlot (List (Int, Int))
| LogData (List String)
| TimePlot (List (Time, Int))
view : Widget -> Element
view widget =
case widget of
ScatterPlot points ->
viewScatterPlot points
LogData logs ->
flow down (map viewLog logs)
TimePlot occurrences ->
viewTimePlot occurrences
My rather elementary question is:
With respect to the Widget
type, what is the underlying model here?
Given an action (e.g. user wants to see a scatter graph widget), what is the underlying structure that should be updated?