Typesafe MRef with a regular monad

Derek Elkins ddarius@hotpop.com
Wed, 11 Jun 2003 14:14:10 -0400


On Wed, 11 Jun 2003 09:19:46 +0200 (MET DST)
Koen Claessen <koen@cs.chalmers.se> wrote:

> Derek Elkins wrote:
> 
>  | The question (at least to me) is more, 'you can
>  | satisfy the RefMonad interface with STRefs or IORefs,
>  | but those use "imperative" features under the hood;
>  | can it be satisfied without them?'
> 
> As I showed in the message that spawned off this discussion,
> this is indeed possible to do (unless you think any monad by
> itself is an imperative thing). The only thing one needs to
> focus on is the typing and not the imperativeness.
> 
> /Koen.

Hence the very next sentence,
"Personally, I think Tim Sweeney is
focusing on the wrong aspect.  The problem here has nothing to do with
monads, it's purely a typing issue,"

and the last sentence,

"[...]STRefs/IORefs are only
type safe because they are in a monad, or perhaps you can look at it
another way and they aren't safe at all but monads simply make it
impossible to abuse them, in which case unsafeCoerce is likely the
minimal extension, again this just shows that this is purely a type
issue, unsafeCoerce has nothing to do with monads and I don't think most
would consider it an imperative feature (though a common feature in
imperative languages ;)."