Skip to content
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

Use NonEmpty and separate EmptyGrid constructor for Grid #1843

Closed
kostmo opened this issue May 12, 2024 · 0 comments · Fixed by #1933
Closed

Use NonEmpty and separate EmptyGrid constructor for Grid #1843

kostmo opened this issue May 12, 2024 · 0 comments · Fixed by #1933
Labels
Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality.

Comments

@kostmo
Copy link
Member

kostmo commented May 12, 2024

With a grid definition like newtype Grid = Grid [[a]], there is more than one way to represent an "empty grid":

  • Grid []
  • Grid [[]]
  • Grid [[], [], [], [], [], ...]

If instead we use NonEmpty for both rows and columns, then there can be exactly one "normalized" representation for an empty grid:

data Grid a = EmptyGrid | Grid (NonEmpty (NonEmpty a))
@kostmo kostmo added the Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. label May 12, 2024
@kostmo kostmo changed the title Grid should have NonEmpty rows Separate EmptyGrid constructor for Grid Jun 25, 2024
@kostmo kostmo changed the title Separate EmptyGrid constructor for Grid Use NonEmpty and separate EmptyGrid constructor for Grid Jun 25, 2024
@mergify mergify bot closed this as completed in #1933 Jul 1, 2024
mergify bot pushed a commit that referenced this issue Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant