Ryan Ingram wrote:
Here's a simple example:

runMud :: Mud a -> a
runMud = flip evalState emptyMud

main = do
    let v = runMud (mkVar "hello")
    let crash = runMud $ do
        v2 <- mkVar True  -- v2 :: Var Bool
        res <- readVar v -- v :: Var String
        return res
    print crash -- boom!

Both v2 and v are the same variable index (0), but different types.
Since there's nothing preventing the variable from escaping from the
first "runMud", we can import it into the second one where it fails.
The key is that both use the same "initial state", so you have lost
the uniqueness of variables.

Ah, yes, of course, thank you. :-) I was trying to break it from within the monad.

Martijn.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to