User interface components are highly configurable, allowing a multitude of parameters of how they should be presented and behave to be specified when we create them and perhaps even dynamically change these attribute values, See section Creating and customising a component in the Haggis tutorial for example of why we need it.
To pass such customisation inexampleion to the components we create, the Style environment is passed to each function creating a component. Since some components also rely on knowing what Window they appear in, we group the Window and the Style into a DisplayContext or DC:
data DC
= DC
Window
Style
Each function that creates a user interface component then takes on the form:
createFoo :: a -> DC -> IO (FooHandle, DisplayHandle)
This combination of IO monad and environment turns out to be quite common, so we introduce the Component IO+DC monad:
type Component a = DC -> IO a createFoo :: a -> Component (FooHandle, DisplayHandle)
In fact the Component is an instance of the general EnvIO monad, but we digress, See section Component abstraction for the full story.