Concept

Shpadoinkle is a new way to program user interfaces with Haskell. The core idea here is to model user interfaces as functions with this type:

view :: Model -> Html m Model

Here, Model is a data type representing your application’s state. The view is a function that defines how to (visually) represent your application’s state. Changes to application state are dictated by the view.

Here is a simple example. It displays an integer. The integer can be incremented by clicking a button.

view :: Int -> Html m Int
view model = (1)
  div []
  [ text $ pack $ show model (2)
  , button
    [ onClick (+ 1) ] (3)
    [ text "Increment" ]
  ]
1 The function receives the current application state (which is just an Int).
2 Shows the current state to the user in a text DOM node.
3 When the user clicks the

That’s it. If you can understand what is going on in the above example, you understand Shpadoinkle. It’s that simple. There is no dispatch, no payloads, no event types, no giant update function, no networks of state managers, no templating, no special HTML syntax, no magic attributes, and no digest cycle.