-
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
Add print
+ erase
commands, and a challenge scenario showing off print
#2245
Conversation
Co-authored-by: Restyled.io <[email protected]>
Am not sure how to obtain the |
@kostmo maybe you need to refresh yourself with |
Again, I've abstained from peeking at the solution, but now I'm stuck on how to |
Ah, you're not supposed to |
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.
Nice challenge. Here's my solution.
toErase <- ensureItem paperName "erase" | ||
(paperName /= "paper") | ||
`holdsOrFail` ["That is already blank!"] | ||
("paper: " `T.isPrefixOf` paperName) |
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.
It seems fragile in some way to use an "in-band" indicator for erasability and printability, in that it must be inferred by the entity's name. Perhaps instead we want to define a "printable" property? Then we could have different printable entities like "papyrus", "clay", "whiteboard". Each of them can still be subject to the name transformation with the colon. A property called "printable" would be inherent to the "unmarked" entity, whereas the property called "erasable" would be dynamically set once the entity undergoes a "print".
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.
Oh, that's a nice idea. Let me play with that.
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.
@kostmo What do you think? I decided to just go with a single property printable
that determines whether something can be both printed and erased. Having a separate property erasable
didn't seem to make sense to me since it's not something that would make sense to set on base entities, and the only reason to erase
something is that you previously print
ed on it.
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 guess this does mean that you can still print
on something that has been previously print
ed on, like this:
> print "paper" "3"
it0 : Text = "paper: 3"
> print "paper: 3" "7"
it1 : Text = "paper: 3: 7"
That's a bit strange, perhaps, but I don't think it's really a problem.
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.
Added a few suggestions
@kostmo thanks! Also, I saw you asked why we had to redefine |
I would be in favor of having the |
This PR is a complement/follow-up to #2224 .
print : Text -> Cmd Text
command which consumes apaper
entity and produces an entity namedpaper: <text>
where<text>
is the given text to be printed on the papererase : Text -> Cmd Unit
command which takes a printed-on paper entity and erases it back to a plainpaper
print
Especially eager to hear feedback from anyone who wants to try solving the new scenario!