[Haskell-cafe] Why can `env` be assigned value two times ?

zaxis z_axis at 163.com
Sun Nov 15 02:05:05 EST 2009


defineVar :: Env -> (Id, Val) -> IOThrowsError Val
defineVar envRef (id, val) = do {
    env <- liftIO $ readIORef envRef;
    env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the current
scope
    valRef <- liftIO $ newIORef val;
    liftIO $ writeIORef envRef $ ((id, valRef):env);
    return val;
}

In haskell, the variable canot change its value , right? If so, why can the
`env` be assigned value twice?

Sincerely!

-----
fac n = foldr (*) 1 [1..n]
-- 
View this message in context: http://old.nabble.com/Why-can-%60env%60-be-assigned-value-two-times---tp26356073p26356073.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list