[Haskell-cafe] Why can `env` be assigned value two times ?
zaxis
z_axis at 163.com
Mon Nov 16 02:06:25 EST 2009
thanks for all your answers !
zaxis wrote:
>
> 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---tp26356073p26367496.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list