Read
map in the view
The view is a Haskell function, so a list in the model becomes a list of elements with map (or a list comprehension).
view :: [MisoString] -> View () () [MisoString] Action
view items =
H.ul_ []
[ H.li_ [ key_ item ] [ text item ]
| item <- items
]key_ gives each element a stable identity. When an item is removed from the middle of the list, miso moves the surrounding DOM nodes instead of rewriting their contents. It also keeps focus and input state attached to the right element. Use the item itself, or an id from the model.
Often you want an action per item. Constructors take arguments, so E.onClick (Remove item) dispatches Remove with that particular item.
data Action = Remove MisoString | Add
update :: Action -> Effect () () [MisoString] Action
update (Remove x) = this %= filter (/= x)
update Add = this %= ("new item" :)