(hello

‘world)

Unique types and STM?

I had an idea at work.

A given programming language is mostly useful only for masturbation if it cannot support things such as file handles, sockets, pipes, graphics, etc… but these wreck hell on purely functional languages. Monads conceptually work by passing a data structure representing the world between the functions which must alter it, it is happenstance that it is never the same twice. Unique types are a sort of middle ground, a type of data which can only be used once afterwards from which an alternate is derived. Both monads and unique types are syntactically noisier than allowing direct mutation, although Kernel’s clean support for multiple value returns would greatly simplify the handling of uniques. Scheme and Ocaml “solve” it by presuming to be “mostly” functional languages and allow mutation of variables (via refs in Ocaml, set! in Scheme). This is the simplest method but breaks referential transparency a whole lot.

So here’s the question. Why don’t we make those things unique types, and automagically handle their updating in the background managed by something along the lines of STM or the such as is already done for mutable data (ala Clojure)?

Someone steal this idea and implement it or point me to something which already does something similar, or point out some flaws, or whatever. I think it’s a neat idea and would like to know if it’s redundant or for some reason unworkable.

August 24, 2009 - Posted by | Programming

No comments yet.

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

%d bloggers like this: