Skip to content

Commit

Permalink
Rename option to represent its real effect.
Browse files Browse the repository at this point in the history
* src/Interpreter.hs (Strategy): Rename 'lazy' -> 'evalBodies'.
  • Loading branch information
sirius94 committed Nov 18, 2016
1 parent 7adf1c3 commit dae4ae1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import LambdaAST

data Strategy = Strategy {
prepareArgument :: Context -> String -> LambdaTerm -> (Context, LambdaTerm),
lazy :: Bool}
evalBodies :: Bool}

type Environment = Map.Map String LambdaTerm

Expand All @@ -36,9 +36,9 @@ varLookup context var = case Map.lookup var $ environment context of
emptyEnvironment = Map.empty

lambdaEval :: Context -> LambdaTerm -> (Context, LambdaTerm)
lambdaEval context@Context {evalStrategy = Strategy {lazy = lazy}}
lambdaEval context@Context {evalStrategy = Strategy {evalBodies = evalBodies}}
l@(Lambda parameter term) =
if lazy
if evalBodies
then
(context, l)
else
Expand All @@ -59,7 +59,7 @@ lambdaEval context (Definition name value) =
lambdaApply :: Context -> LambdaTerm -> LambdaTerm -> (Context, LambdaTerm)
lambdaApply context (Lambda parameter term) argument =
let (context', argument') =
prepareArgument (evalStrategy context) context parameter argument in
prepareArgument (evalStrategy context) context argument in
lambdaEval context' (replaceWithSubtree parameter argument' term)
lambdaApply context function argument =
let (context', function') = lambdaEval context function in
Expand All @@ -75,24 +75,24 @@ byValue =
evalStrategy = Strategy
{
prepareArgument = prepareArgument,
lazy = True
evalBodies = True
},
environment = emptyEnvironment
}
where
prepareArgument :: Context -> String -> LambdaTerm -> (Context, LambdaTerm)
prepareArgument context _ argument = lambdaEval context argument
prepareArgument :: Context -> LambdaTerm -> (Context, LambdaTerm)
prepareArgument context argument = lambdaEval context argument

byName =
Context
{
evalStrategy = Strategy
{
prepareArgument = prepareArgument,
lazy = True
evalBodies = True
},
environment = emptyEnvironment
}
where
prepareArgument :: Context -> String -> LambdaTerm -> (Context, LambdaTerm)
prepareArgument context _ argument = (context, argument)
prepareArgument :: Context -> LambdaTerm -> (Context, LambdaTerm)
prepareArgument context argument = (context, argument)

0 comments on commit dae4ae1

Please sign in to comment.