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

Define Eq, Ord and NFData instances for Sample #63

Open
alexandervandenbroucke opened this issue Sep 17, 2021 · 2 comments
Open

Define Eq, Ord and NFData instances for Sample #63

alexandervandenbroucke opened this issue Sep 17, 2021 · 2 comments

Comments

@alexandervandenbroucke
Copy link

The Sample data type does not have instances for Eq, Ord and NFData.

The former two type classes are generally useful can can be automatically derived by GHC.

The latter type class is primarily useful when writing tests and benchmarks. The entire definition of the instance fits on two lines:

instance NFData Sample where
  rnf (Sample name labelSet value) = rnf name `seq` rnf labelSet `seq` rnf value
@ocharles
Copy link
Collaborator

This seems reasonable to me. Did you run into a situation where you needed these instances?

@alexandervandenbroucke
Copy link
Author

Yes, in particular when I was writing some test-cases:

  • The test framework requires NFData.
  • It is useful to sort the samples when comparing actual and expected output values.

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

No branches or pull requests

2 participants