-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove superfluous trobotContext lens #1731
Conversation
@@ -1061,7 +1061,7 @@ execConst runChildProg c vs s k = do | |||
-- Construct the new robot and add it to the world. | |||
parentCtx <- use robotContext | |||
newRobot <- | |||
zoomRobots . addTRobot (In cmd e s [FExec]) . (trobotContext .~ parentCtx) $ | |||
zoomRobots . fmap (robotContext .~ parentCtx) . addTRobot (In cmd e s [FExec]) $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason this doesn't work is that it only modifies the robotContext
of the Robot
value returned by addTRobot
, but it does not modify the original Robot
value which addTRobot
actually adds to the robot map (of which it then returns a copy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just have addTRobot
take a Maybe RobotContext
as an extra argument? I don't know if that's actually a good idea, just random brainstorming...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, wonderful. I like how this uncovers the fact that the only time we really needed the returned Robot
was when we were actually setting the context, so now in the common case we can have addTRobot
return ()
and get rid of a bunch of calls to void
.
Motivation
Want to remove dependence of
TRobot
on theRobotContext
record. However, a lenstrobotContext
had been added in #817 to fix #394.Test