On Fri, Feb 27, 2009 at 11:10 PM, Ryan Ingram <ryani.spam@gmail.com> wrote:
It's obvious that anything that accesses the STT constructor will potentially not be typesafe; the question I have is that whether you can construct something that isn't typesafe just via the use of runSTT & lift.
To my surprise, it turns out that you can. data Foo m a b = V a | K (Foo m a b -> m b) test = do v <- lift $ callCC $ \k -> return (K k) case v of K k -> do r1 <- newSTTRef 'a' lift $ k (V r1) -- * V r1 -> do r2 <- newSTTRef (65 :: Int) return (r1,r2) The call to k in the marked line undoes the heap changes since the call to callCC, and we end up with r1 and r2 both pointing to the same cell. -- Dave Menendez <dave@zednenem.com> <http://www.eyrie.org/~zednenem/>