[Haskell-cafe] ANNOUNCE: pqueue-mtl, stateful-mtl
noteed at gmail.com
Mon Feb 16 09:03:50 EST 2009
2009/2/16 Josef Svenningsson <josef.svenningsson at gmail.com>:
> On Mon, Feb 16, 2009 at 2:30 AM, wren ng thornton <wren at freegeek.org> wrote:
>> Louis Wasserman wrote:
>>> I follow. The primary issue, I'm sort of wildly inferring, is that use of
>>> STT -- despite being pretty much a State monad on the inside -- allows
>>> access to things like mutable references?
>> That's exactly the problem. The essential reason for ST's existence are
>> STRefs which allow mutability.
> I'd like to point out one other thing that ST provides, which is often
> forgotten. It provides *polymorphic* references. That is, we can
> create new references of any type.
> So ST is a really magical beast. Not only does it provide mutation, it
> also provides mutable references. And these are two different
> features. Now, everyone agrees that mutation is not something that you
> can implement in a functional language, so ST cannot be implemented in
> Haskell for that reason. It has to be given as a primitive. But what
> about polymorphic references? Can they be implemented in Haskell? The
> Claessen conjecture (after Koen Claessen) is that they cannot be
> implemented in Haskell. See the following email for more details:
> One could try and separate mutation and polymorphic references and
> give them as two different primitives and implement ST on top of that.
> But I haven't seen anyone actually trying that (or needing it for that
Actually, I was interested in making a state holding polymorphic
references in the state monad, so that the state could be passed
around. I made an attempt, and if my memory serves me right, it worked
like this : It was based on Dynamics, with an IntMap indexed,
indirectly, by TypeRep, yielding, for each type, a new IntMap,
providing references for any value of that type.
In fact, I think the next stpe would be to have some TH to generate
specific state monads to hold references on specific types.
More information about the Haskell-Cafe