@@ -228,11 +228,11 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
228228 ev ntimes stk top env (P nt n ty)
229229 = liftM (VP nt n) (ev ntimes stk top env ty)
230230 ev ntimes stk top env (V i)
231− | i < length env && i >= 0 = return $ env !! i
231+ | i < length env && i >= 0 = return $ snd (env !! i)
232232 | otherwise = return $ VV i
233233 ev ntimes stk top env (Bind n (Let t v) sc)
234234 = do v' <- ev ntimes stk top env v --(finalise v)
235− sc' <- ev ntimes stk top (v' : env) sc
235+ sc' <- ev ntimes stk top ((n, v') : env) sc
236236 wknV (-1) sc'
237237-- | otherwise
238238-- = do t' <- ev ntimes stk top env t
@@ -247,12 +247,13 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
247247 ev ntimes stk top env (Bind n (NLet t v) sc)
248248 = do t' <- ev ntimes stk top env (finalise t)
249249 v' <- ev ntimes stk top env (finalise v)
250− sc' <- ev ntimes stk top (v' : env) sc
250+ sc' <- ev ntimes stk top ((n, v') : env) sc
251251 return $ VBind True n (Let t' v') (\x -> return sc')
252252 ev ntimes stk top env (Bind n b sc)
253253 = do b' <- vbind env b
254+ let n' = uniqueName n (map fst env)
254255 return $ VBind True -- (vinstances 0 sc < 2)
255− n b' (\x -> ev ntimes stk False (x:env) sc)
256+ n' b' (\x -> ev ntimes stk False ((n, x):env) sc)
256257 where vbind env t
257258-- | simpl
258259-- = fmapMB (\tm -> ev ((MN 0 "STOP", 0) : ntimes)
@@ -345,7 +346,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
345346-- _ -> return $ unload env f args
346347-- specApply stk env f args = return $ unload env f args
347348
348− unload :: [Value] -> Value -> [Value] -> Value
349+ unload :: [(Name, Value)] -> Value -> [Value] -> Value
349350 unload env f [] = f
350351 unload env f (a:as) = unload env (VApp f a) as
351352
@@ -360,12 +361,12 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
360361 | otherwise = return (Nothing, args)
361362
362363 evTree :: [(Name, Int)] -> [Name] -> Bool ->
363− [Value] -> [(Name, Value)] -> SC -> Eval (Maybe Value)
364+ [(Name, Value)] -> [(Name, Value)] -> SC -> Eval (Maybe Value)
364365 evTree ntimes stk top env amap (UnmatchedCase str) = return Nothing
365366 evTree ntimes stk top env amap (STerm tm)
366367 = do let etm = pToVs (map fst amap) tm
367368 etm' <- ev ntimes stk (not (conHeaded tm))
368− (map snd amap ++ env) etm
369+ (amap ++ env) etm
369370 return $ Just etm'
370371 evTree ntimes stk top env amap (ProjCase t alts)
371372 = do t' <- ev ntimes stk top env t
@@ -394,7 +395,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
394395 chooseAlt env f' (getValArgs f')
395396 alts amap
396397
397− chooseAlt :: [Value] -> Value -> (Value, [Value]) -> [CaseAlt] ->
398+ chooseAlt :: [(Name, Value)] -> Value -> (Value, [Value]) -> [CaseAlt] ->
398399 [(Name, Value)] ->
399400 Eval (Maybe ([(Name, Value)], SC))
400401 chooseAlt env _ (VP (DCon i a) _ _, args) alts amap