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

Add more instances. #7

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

kindaro
Copy link

@kindaro kindaro commented Sep 10, 2020

Resolve #5.

@kindaro kindaro marked this pull request as ready for review September 12, 2020 20:52
@kindaro
Copy link
Author

kindaro commented Sep 12, 2020

Notes:

  • I took the liberty to adjust change log and package version.
  • The instances work for me, but please see if they are satisfactory to your expert eye.
  • Since the commit history is so fine-grained, I suppose it is best to squash and merge.

@robrix
Copy link
Owner

robrix commented Oct 31, 2020

(I don’t squash and merge; fine-grained history is fine by me.)

Copy link
Owner

@robrix robrix left a comment

Choose a reason for hiding this comment

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

Couple of notes; I’d ideally also like to see tests demonstrating that Eq & Eq1, Ord & Ord1, etc. agree.

version: 0.0.0.0
version: 0.1.0.0
Copy link
Owner

Choose a reason for hiding this comment

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

I don’t think this constitutes a major release; there’s no backwards-compat issue that I can see.

Copy link
Author

Choose a reason for hiding this comment

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

New instances being exported may conflict with orphan instances defined in user code.

Copy link
Owner

Choose a reason for hiding this comment

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

You could make the same claim for any added symbol—it could break a build if you’re importing it open in a module using a symbol of the same name from elsewhere.

Copy link
Author

Choose a reason for hiding this comment

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

Other sorts of names are safe to add assuming the consumers follow the advised practice of importing qualified or with explicit import lists. On the contrary, the import of classes is not possible to opt out.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, the official guide for PVP says that added non-orphan instances are not considered a breaking change. These instances here are non-orphan. So you are right.

@@ -50,6 +50,8 @@ library
build-depends:
, base >= 4.10 && < 5
, transformers ^>= 0.5.6.2
, generic-data ^>= 0.9
Copy link
Owner

Choose a reason for hiding this comment

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

I’d rather we define the instance ourselves than take on this dependency.

Copy link
Author

Choose a reason for hiding this comment

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

Alright!

EQ -> liftCompare f v v'
x -> x

instance NFData (f a) => NFData (Interval f a)
Copy link
Owner

Choose a reason for hiding this comment

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

NFData1 exists too, FWIW. Let’s define both.

Comment on lines +84 to +85
instance Show1 f => Show1 (Interval f) where
liftShowsPrec = gliftShowsPrec
Copy link
Owner

Choose a reason for hiding this comment

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

In addition to not wanting to take on the extra dependency, it strikes me as strange that we’d have different behaviour for Show1 and Show.

import Control.Monad.Trans.Class
import Data.Coerce (coerce)
import Data.Fixed (mod')
import Data.Function (on)
import Data.Functor.Classes (Show1, liftShowsPrec, Eq1, liftEq, Ord1, liftCompare)
Copy link
Owner

Choose a reason for hiding this comment

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

I don’t think we need to list the imports explicitly here, but if we’re going to, let’s sort this alphabetically. I think I have stylish-haskell config in this repo, if that helps.


## `0.1.0.0` — Sunday, 13 of September 2020.

* Add instances `Show1`, `Eq1`, `Ord1`.
Copy link
Owner

Choose a reason for hiding this comment

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

Should mention NFData.

@kindaro
Copy link
Author

kindaro commented Nov 13, 2020

Thank you for your thoughtful commentary. I shall get it fixed.

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.

Add instances Show1, Eq1, Ord1, NFData, Arbitrary, Series?
2 participants