Objects as Dependently Typed Functions

One issue I have with objects is that I cannot compose them like functions (i.e. `f . g . h`). The reason for this is the method-set associated with each object – it requires a lot of wiring to compose two objects, and it is awkward to express or apply that wiring in a higher-order manner.

An alternative model for objects is as a dependently-typed function (or a dependently typed procedure). The basic constraint for such an object model is that every method essentially have a distinguishable input type. This isn’t terribly difficult to achieve, since we can use a `newtype` mechanism to wrap equivalent types for different roles, and thus method names would often become newtype identifiers.

Wiring between objects of different types or kinds may still difficult, but now can itself be expressed as a simple object/function that can be composed like every other object/function.

Advertisements
This entry was posted in Language Design and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s