Yampa icon indicating copy to clipboard operation
Yampa copied to clipboard

use newtype in SF declaration

Open concavegit opened this issue 6 years ago • 14 comments

I believe newtype may be used here instead of data.

concavegit avatar Jan 11 '18 23:01 concavegit

@ivanperez-keera Are we good to merge?

concavegit avatar Jun 09 '18 04:06 concavegit

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.

ivanperez-keera avatar Jun 09 '18 04:06 ivanperez-keera

(For an explanation of what I mean, see: https://stackoverflow.com/a/13567709/660339)

ivanperez-keera avatar Jun 09 '18 04:06 ivanperez-keera

Thanks for the explanation, The game compiles with haskanoid, and thanks for the unexpected entertainment!

concavegit avatar Jun 09 '18 15:06 concavegit

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.

ivanperez-keera avatar Jun 10 '18 06:06 ivanperez-keera

Just sent the email. Edit: Never mind, I have to subscribe first.

concavegit avatar Jun 10 '18 15:06 concavegit

Great!

ivanperez-keera avatar Jun 10 '18 15:06 ivanperez-keera

Actually, I have to subscribe first and the mail bounced back. Waiting for moderator approval.

concavegit avatar Jun 10 '18 15:06 concavegit

Now it is sent. Does 2 days sound like a reasonable amount of time to wait for responses?

concavegit avatar Jun 10 '18 21:06 concavegit

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.

ivanperez-keera avatar Jun 10 '18 21:06 ivanperez-keera

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.

ivanperez-keera avatar Jun 11 '18 22:06 ivanperez-keera

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?

concavegit avatar Jun 11 '18 23:06 concavegit

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 :)

ivanperez-keera avatar Jun 12 '18 00:06 ivanperez-keera

(In particular, it looks like frag could be a comprehensive example.)

ivanperez-keera avatar Jun 12 '18 00:06 ivanperez-keera

Once we build the benchmarks we can revisit this idea. Closing for now.

ivanperez-keera avatar Apr 23 '23 22:04 ivanperez-keera