Yampa
Yampa copied to clipboard
use newtype in SF declaration
I believe newtype may be used here instead of data.
@ivanperez-keera Are we good to merge?
Can you try to compile haskanoid with this change and see if it works?
I would like to make sure that the difference in how laziness works in data
and newtype
does not affect applications.
(For an explanation of what I mean, see: https://stackoverflow.com/a/13567709/660339)
Thanks for the explanation, The game compiles with haskanoid, and thanks for the unexpected entertainment!
Thanks for checking! :)
Would you be able to send an email to Yampa's mailing list, asking if anyone can think of a case that might not work?
Some of the original creators of Yampa are there, and they may be able to explain why this choice was made that way, and whether it would have any inadvertent consequences.
Just sent the email. Edit: Never mind, I have to subscribe first.
Great!
Actually, I have to subscribe first and the mail bounced back. Waiting for moderator approval.
Now it is sent. Does 2 days sound like a reasonable amount of time to wait for responses?
Thanks for sending it :)
Yeah, let's give them a few days to reply. I've emailed Henrik Nilsson, who may have some insight as one of the creators of Yampa and the person who worked on optimising it using GADTs.
We have a good range of tests and games now, so, if nobody shows evidence against this in a few days, we'll run your variant with those to make sure that it works as expected and then merge.
Two comments from Henrik Nilsson:
-
He believes performance won't be affected much, because the newtype is out of the way as soon as the SF is applied.
-
He sees no reason to add it and no reason not to add it. But he insists that we test this kind of change very, very thoroughly before modifying the code definitions.
Looks like this change would be a small change, but a positive nontheless. Is there a list of projects I can try this change with in case I or anyone in the future feels inclined?
That's a good question.
There's a number of things we could check:
- The regression test suite in Yampa's repo (there's a test in the cabal file for this).
- Games like haskanoid (which you already tried), space invaders, pang-a-lambda, and generally any game listed here: https://github.com/ivanperez-keera/Yampa#other-examples (the more, the better).
I've been trying to make sure that we consider the projects that are using Yampa before introducing anything that could break things (even if it's an improvement to the API). It's requires some effort, but I think people will appreciate it and be more likely to use Yampa if they know they are in good hands :)
(In particular, it looks like frag could be a comprehensive example.)
Once we build the benchmarks we can revisit this idea. Closing for now.