-
Notifications
You must be signed in to change notification settings - Fork 53
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
web api to parse, render, and run code #1142
Conversation
f6fc462
to
cec96d2
Compare
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.
Ready for another look, @byorgey.
src/Swarm/Web.hs
Outdated
drawTree . fmap prettyString . para Node $ stx | ||
Left x -> x | ||
codeRunHandler contents = do | ||
liftIO $ writeBChan chan $ Web $ RunWebCode contents |
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.
Potentially we could do some syntactical validation "client-side" before sending the raw text over the channel. We could even use the GameState
from the IORef
to parse the code "in context" with processTerm'
. However, we would probably want to re-parse it "game-side", because (1) we want to add the raw command text to the REPL history, and (2) possible race condition (as mentioned above w.r.t. replWorking
).
But I think that both of these client-side validations could wait until a later PR.
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.
Sorry it took me so long to look at this!
@kostmo are there any other PRs that you'd like feedback on at the moment? I think I'm now caught up but I could very easily have missed some. |
Closes #625.
Demo
Running code
Start a creative game:
In another terminal window:
Observe that the robot has moved, and that the command sent via
curl
has been added to the REPL history.Parsing and rendering code
Start swarm:
Run curl:
See output: