@@ -11,7 +11,8 @@ Maintainer : The Idris Community.
1111
1212module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC,
1313 normaliseAll, normaliseBlocking, toValue, quoteTerm,
14− rt_simplify, simplify, specialise, unfold, convEq, convEq',
14+ rt_simplify, simplify, inlineSmall,
15+ specialise, unfold, convEq, convEq',
1516 Def(..), CaseInfo(..), CaseDefs(..),
1617 Accessibility(..), Injectivity, Totality(..), PReason(..), MetaInformation(..),
1718 Context, initContext, ctxtAlist, next_tvar,
@@ -19,7 +20,7 @@ module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC,
1920 addDatatype, addCasedef, simplifyCasedef, addOperator,
2021 lookupNames, lookupTyName, lookupTyNameExact, lookupTy, lookupTyExact,
2122 lookupP, lookupP_all, lookupDef, lookupNameDef, lookupDefExact, lookupDefAcc, lookupDefAccExact, lookupVal,
22− mapDefCtxt,
23+ mapDefCtxt, tcReducible,
2324 lookupTotal, lookupTotalExact, lookupInjectiveExact,
2425 lookupNameTotal, lookupMetaInformation, lookupTyEnv, isTCDict,
2526 isCanonical, isDConName, canBeDConName, isTConName, isConName, isFnName,
@@ -148,16 +149,9 @@ simplify ctxt env t
148149
149150-- | Like simplify, but we only reduce functions that are marked as okay to
150151-- inline, and don't reduce lets
151−inline :: Context -> Env -> TT Name -> TT Name
152−inline ctxt env t
153− = evalState (do val <- eval False ctxt [(sUN "lazy", 0),
154− (sUN "force", 0),
155− (sUN "Force", 0),
156− (sUN "assert_smaller", 0),
157− (sUN "assert_total", 0),
158− (sUN "par", 0),
159− (sUN "prim__syntactic_eq", 0),
160− (sUN "fork", 0)]
152+inlineSmall :: Context -> Env -> TT Name -> TT Name
153+inlineSmall ctxt env t
154+ = evalState (do val <- eval False ctxt []
161155 (map finalEntry env) (finalise t)
162156 [Simplify False]
163157 quote 0 val) initEval
@@ -284,13 +278,13 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
284278 || runtime || unfold
285279 || sUN "assert_total" `elem` stk)
286280 if red then
287− do let val = lookupDefAcc n (spec || unfold || atRepl || runtime) ctxt
281+ do let val = lookupDefAccExact n (spec || unfold || atRepl || runtime) ctxt
288282 case val of
289− [(Function _ tm, Public)] ->
283+ Just (Function _ tm, Public) ->
290284 ev ntimes (n:stk) True env tm
291− [(TyDecl nt ty, _)] -> do vty <- ev ntimes stk True env ty
292− return $ VP nt n vty
293− [(CaseOp ci _ _ _ _ cd, acc)]
285+ Just (TyDecl nt ty, _) -> do vty <- ev ntimes stk True env ty
286+ return $ VP nt n vty
287+ Just (CaseOp ci _ _ _ _ cd, acc)
294288 | (acc == Public || acc == Hidden) &&
295289-- || sUN "assert_total" `elem` stk) &&
296290 null (fst (cases_compiletime cd)) -> -- unoptimised version
@@ -353,7 +347,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
353347 evApply ntimes' stk top env [l',t',arg'] d'
354348 -- Treat "assert_total" specially, as long as it's defined!
355349 ev ntimes stk top env (App _ (App _ (P _ n@(UN at) _) _) arg)
356− | [(CaseOp _ _ _ _ _ _, _)] <- lookupDefAcc n (spec || atRepl || runtime) ctxt,
350+ | Just (CaseOp _ _ _ _ _ _, _) <- lookupDefAccExact n (spec || atRepl || runtime) ctxt,
357351 at == txt "assert_total" && not (simpl || unfold)
358352 = ev ntimes (n : stk) top env arg
359353 ev ntimes stk top env (App _ f a)
@@ -381,9 +375,9 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
381375 = apply ntimes stk top env f args
382376
383377 reapply ntimes stk top env f@(VP Ref n ty) args
384− = let val = lookupDefAcc n (spec || atRepl || runtime) ctxt in
378+ = let val = lookupDefAccExact n (spec || atRepl || runtime) ctxt in
385379 case val of
386− [(CaseOp ci _ _ _ _ cd, acc)] ->
380+ Just (CaseOp ci _ _ _ _ cd, acc) ->
387381 let (ns, tree) = getCases cd in
388382 do c <- evCase ntimes n (n:stk) top env ns args tree
389383 case c of
@@ -407,9 +401,9 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
407401 || unfold || runtime
408402 || sUN "assert_total" `elem` stk)
409403 if red then
410− do let val = lookupDefAcc n (spec || unfold || atRepl || runtime) ctxt
404+ do let val = lookupDefAccExact n (spec || unfold || atRepl || runtime) ctxt
411405 case val of
412− [(CaseOp ci _ _ _ _ cd, acc)]
406+ Just (CaseOp ci _ _ _ _ cd, acc)
413407 | acc == Public || acc == Hidden ->
414408 -- unoptimised version
415409 let (ns, tree) = getCases cd in
@@ -420,7 +414,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
420414 case c of
421415 (Nothing, _) -> return $ unload env (VP Ref n ty) args
422416 (Just v, rest) -> evApply ntimes stk top env rest v
423− [(Operator _ i op, _)] ->
417+ Just (Operator _ i op, _) ->
424418 if (i <= length args)
425419 then case op (take i args) of
426420 Nothing -> return $ unload env (VP Ref n ty) args