Skip to content

Conversation

@anttih
Copy link

@anttih anttih commented Aug 20, 2023

Add foreign definitions for almost all missing modules.

Noteworthy things:

  • No overflow checks are done for Int (fixnums). This means that any operation on an Int might overflow. For example degree bot will overflow and was removed from the test suite. I think this is a better compromise than trying to somehow prevent any overflow, which would be very difficult to do anyway.
  • unit is the symbol unit.
  • AlmostEff was replaced with "normal" Effect by including the definition in the test suite. This change we probably should upstream, but it wasn't clear to me how. Also note that since the Effect is in Utils.Effect some of the inlining will not trigger. Not sure if this is good or bad. It's now defined as Effect, and inlining works.
  • The backend-optimizer is very aggressive especially for any code in the prelude so a lot of the test suite is inlined. This means that many of the foreign definitions are not exercised.
  • I added a few tests for the array instances that are missing from the test suite.
  • I refactored a few existing do loops to slightly simpler tail-recursive variants.
  • The biggest thing that is missing/incomplete is the Show module whose implementations are probably not fully compatible. Update: now just using format. Not sure how much we should worry about the Show instances for the primitives.
  • The test suite does pass but there is no easy way to run it currently. I will soon post a PR for the purs-backend-chez cli tool so that people can try this out. Now it can be run, and passes.
  • degree bot overflows because (fxabs (most-negative-fixnum)) overflows. Maybe we can figure out a different implementation for intDegree? Meanwhile the test is commented out.

Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@f-f
Copy link

f-f commented Sep 17, 2023

@anttih is this one good to review?

@anttih anttih marked this pull request as draft September 17, 2023 11:27
@anttih
Copy link
Author

anttih commented Sep 17, 2023

@f-f not yet. There's too much code that has no test coverage. I'm trying to at least run the test suite locally with no inlining.

@anttih anttih marked this pull request as ready for review September 20, 2023 13:17
@anttih
Copy link
Author

anttih commented Sep 20, 2023

This is ready for review. It's quite difficult to tell if we have full test coverage. I did add some tests for arrays.

main :: Effect Unit
main = do
testNumberShow show
-- testNumberShow show
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented?

Copy link
Author

@anttih anttih Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this for another PR. Partly because I didn't know how to implement it yet. Should I somehow properly leave a TODO or make an issue? I wanted comment it out so I could run the test suite.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense

assert "degree returns absolute integers" $ degree 4 == 4
assert "degree returns absolute integers" $ degree bot >= 0
assert "degree does not return out-of-bounds integers" $ degree bot <= top
-- assert "degree returns absolute integers" $ degree bot >= 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I explain in the PR description. Basically degree bot can overflow, just like any operation on Int. We might be able to solve this one with another implementation of degree, but it's not clear to me how that would help since any operation can overflow anyway.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Let's leave a comment and a TODO about this so the future implementors will find a thread to follow

@anttih anttih merged commit 452938d into purescm:v6.0.1-scm Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants