Scaling Views with Master View Types

Hi,

You talk about the idea of ‘Reusable Views’ which is something that chimes with me. I also like the idea of using types to guide the implementation of a program at a larger scale. We use types all the time for small stuff, like making sure we put the right kind of thing into a list, but it can be very powerful to use types in a more zoomed out fashion to give shape to a whole application.

The principal way in which functional programming allows for code re-use is through higher-order functions. In your article you have explored a different approach, which is to use a custom type to describe a set of permitted options (TextBanner, ViewerBanner, ArticleBanner, …) and to restrict construction of the view using that type so that the various pieces of the view can only be plugged together in the right way.

I have previously explored the other option, which is to make use of higher-order functions; to allow customizable behaviour to be plugged into some defined piece of view logic in order to make it work in different settings. This is a more open-ended way of re-using code.

Perhaps you will find this interesting, when considering the use of ‘large types’ in overall program structure.