Skip to content

Conversation

@andrewthad
Copy link
Collaborator

Still a work in progress

liftEq p a1 a2 = sizeofArray a1 == sizeofArray a2 && loop (sizeofArray a1 - 1)
where loop i | i < 0 = True
| otherwise = p (indexArray a1 i) (indexArray a2 i) && loop (i-1)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just merged my eagerness patch, so you should use indexArray## here. Also, if we're adding Eq1 we should surely also add Ord1.

@andrewthad
Copy link
Collaborator Author

@treeowl I probably won’t be able to get back to this PR tomorrow. If you want, go ahead and take over it. I am pretty confident that we are in agreement about the improvements that still need to be made to it.

@treeowl
Copy link
Collaborator

treeowl commented Mar 20, 2018 via email

@andrewthad
Copy link
Collaborator Author

It turns out that the IsList instance for ByteArray was wrong since foldrByteArray was wrong.

Copy link
Collaborator

@treeowl treeowl left a comment

Choose a reason for hiding this comment

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

What are these fromList copies for?

@andrewthad
Copy link
Collaborator Author

@treeowl For some reason, github won't show me which code your comment refers to, so I'll try to explain more generally what's going on. On GHC 7.4.2, there is no IsList typeclass, so the Data.Primitive.SmallArray module doesn't end up exporting anything that let's us build a SmallArray from a list. Consequently, I have to copy their definitions into the test suite.

@andrewthad
Copy link
Collaborator Author

@RyanGlScott This appears to be passing in travis now. There's a bogus failure for GHC 7.8, but everything else is good. Please review when you get a chance. In the process of adding the test suite, it was discovered that <*> was incorrect for both Array and SmallArray and that the IsList instance for ByteArray was incorrect. These have been fixed so that the test suite would pass.

Copy link
Member

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

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

Thanks. It looks like this does quite a bit more than change the test suite—do you mind adding entries to the changelog describing what all have changed here?

primitive.cabal Outdated
Build-Depends: base >= 4.5 && < 4.12
, ghc-prim >= 0.2 && < 0.6
, transformers >= 0.2 && < 0.6
, transformers >= 0.4 && < 0.6
Copy link
Member

Choose a reason for hiding this comment

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

Why are you bumping the upper version bounds for transformers? (Note that that is what is causing the GHC 7.8 build failure in Travis.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we can keep the bounds down, maybe we can just deprecate the last couple versions altogether. The correctness and safety bugs are really piling up.

test/main.hs Outdated
(?) = flip
{-# INLINE (?) #-}

smallArrayFromListN :: Int -> [a] -> SmallArray a
Copy link
Member

Choose a reason for hiding this comment

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

If this is literally copy-pasted from the main library, it might make sense to just export it from Data.Primitive.SmallArray proper.

go !ix (x : xs) = do
writeByteArray marr ix x
go (ix + 1) xs
go 0 ys
Copy link
Collaborator

Choose a reason for hiding this comment

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

While you're replacing the IsList instance, I think you should make it safe by checking against the given size on each iteration. I'm adding that check to the polymorphic arrays.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I’ll do that. It’s a pretty inexpensive check, and this function should never be used in performance-critical situations, and segfaults are terrible.

@treeowl
Copy link
Collaborator

treeowl commented Mar 21, 2018

Oh, I see... You want newer transformers because the lifted classes changed... Hrmm. I think it might be better just not to run those tests with sufficiently elderly GHC versions. Or something. Gross. Can we avoid Eq1, etc., in the test suite by using FlexibleContexts?

@treeowl
Copy link
Collaborator

treeowl commented Mar 21, 2018

@RyanGlScott Who is going to decide what happens with the last two releases? Having bug-ridden instances in non-deprecated releases seems rather bad.

@RyanGlScott
Copy link
Member

I don't have Hackage permissions for primitive, so there's nothing I can do about that.

@treeowl
Copy link
Collaborator

treeowl commented Mar 21, 2018

Ah, I guess @dolio will have to chime in at some point.

@andrewthad
Copy link
Collaborator Author

I'll need to think a little more about how to allow transformers-0.2 and transformers-0.3. I don't particularly want to change quickcheck-classes to use FlexibleContexts since that makes the type signatures less clear. I'll keep thinking about this and see if I can come up with a different solution.

@andrewthad
Copy link
Collaborator Author

So, what I think that I’m going to do is make quickcheck-classes able to build with even older versions of transformers. When built with these old versions of transformers (and a sufficiently old version of base) , it will not provide property tests for any of the higher kinded type classes. In primitive, I’ll just CPP our the functor, applicative, etc. tests when the dependencies are old. Does this sound like an acceptable approach? Practically speaking, I believe that the effect it will have will be that GHC 7.8.4 does not get tests for higher kinded type classes run (since that appears to be the only one where transformers < 0.4 is used).

@treeowl
Copy link
Collaborator

treeowl commented Mar 22, 2018 via email

@andrewthad
Copy link
Collaborator Author

Just pushed a commit (and a new version of quickcheck-classes) where all the Traversable laws are tested. Also, I'm testing foldl1 and foldr1 now. As you suspected, something was still wrong with foldl1 (it was doing a right-associated fold instead of left-associated), and I've fixed that.

@andrewthad
Copy link
Collaborator Author

Build is passing.

, Typeable
#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0)
, Eq1
, Ord1
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should derive Read1 here as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Your thoroughness knows no bounds.

@RyanGlScott
Copy link
Member

Excellent work, @andrewthad.

At this point, I really only have one additional comment, which is about dependencies. Due to the hacky nature of primitive's test suite, we cannot cache the builds of any library which depends on primitive. Thus, with the addition of quickcheck-instances, we have to build several additional libraries on every run of Travis, including semigroupoids and aeson, which are somewhat bulky.

Perhaps this is an acceptable cost—I'm not sure. But it is worth thinking about. What are your thoughts?

@andrewthad
Copy link
Collaborator Author

@RyanGlScott It looks like the deps on semigroupoids and aeson only come from quickcheck-classes. I can add a cabal flag for turning those off. Do you know how to get travis to pass a flag to a dependency? (I don't know how to use travis for cabal builds very well but I assume this is possible).

@RyanGlScott
Copy link
Member

@andrewthad, that might be a worthwhile pursuit.

As far as how to change Travis, I think it would be a matter of passing --flags='quickcheck-classes -aeson -semigroupoids' to each invocation of cabal new-* in the script. The cleanest way to do this would be to declare:

- CABALFLAGS="--flags='quickcheck-classes -aeson -semigroupoids'"

Somewhere around here and pass ${CABALFLAGS} to the right places.

.travis.yml Outdated

# build & run tests, build benchmarks
- cabal new-build -w ${HC} ${TEST} ${BENCH} -j2 all
- cabal new-build -w ${HC} ${CABALFLAGS} ${TEST} ${BENCH} -j2 all
Copy link
Member

Choose a reason for hiding this comment

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

You'll need to pass ${CABALFLAGS} to more than just here. You'll also need it on lines 121, 124, 128, and 137, which call new-build, new-test, and new-haddock. (Otherwise, when those commands are run, it will first calculate a new set of dependencies, since you passed a different set of flags!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, thanks. I had forgotten that new-test even existed, so I didn't think to search for that. Also, it's a little strange to me that this to the earlier new-build commands in the file (the ones that don't build suite) would have any affect at all since primitive doesn't actually depend on quickcheck-classes.

Copy link
Member

Choose a reason for hiding this comment

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

To be clear, it's not necessarily guaranteed that not passing ${CABALFLAGS} would make a difference. But in my experience, things tend to work best when you use a consistent set of build flags everywhere—you don't want to give the recompilation checker any excuse for believing that some dependency needs to be rebuilt.

.travis.yml Outdated
- HADDOCK=${HADDOCK-true}
- INSTALLED=${INSTALLED-true}
- GHCHEAD=${GHCHEAD-false}
- CABALFLAGS="--flags='quickcheck-classes -aeson -semigroupoids'"
Copy link
Member

Choose a reason for hiding this comment

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

I think I goofed—it turns out cabal-install doesn't like it when you surround this with double-quotes. I think it should work if you remove them.

@andrewthad
Copy link
Collaborator Author

I think I actually need to use constraint instead of flags. Trying this again.

@RyanGlScott
Copy link
Member

No, flags should be correct. But I realized another issue—the quotes around the arguments to flags aren't being preserved. This should actually do the trick:

CABALFLAGS="--flags=\"quickcheck-classes -aeson -semigroupoids\""

I actually tested this one, so it better work :)

@andrewthad
Copy link
Collaborator Author

No dice.

@RyanGlScott
Copy link
Member

Ugh. When I said "I actually tested this one", I meant I ran echo ${CABALFLAGS}, and it produced the output I expected. But evidently, this isn't what is actually passed to other commands... god I hate bash.

I'll experiment more with this locally.

@RyanGlScott
Copy link
Member

On second thought, we might be making this way more complicated than need be. I neglected to notice that you actually amended cabal.project with the right flags in the first place! In light of that, I think this CABALFLAGS hack is wholly unnecessary. Can you try removing it and seeing if that does the right thing?

Sorry for the agonizing delay, @andrewthad—this stuff is always trickier than one would hope.

@RyanGlScott
Copy link
Member

Oh, right. I forgot that haskell-ci generates its own cabal.project on the fly, which is why putting those flags in the local cabal.project won't show up. I know how to fix this, but this is something that can be done after merging.

In any case, this is building, and we should get this landed. Thanks for all the hard work, @andrewthad!

@RyanGlScott RyanGlScott merged commit 59e90f7 into haskell:master Mar 23, 2018
RyanGlScott added a commit that referenced this pull request Mar 23, 2018
@andrewthad
Copy link
Collaborator Author

Thanks!

@treeowl
Copy link
Collaborator

treeowl commented Mar 23, 2018

No, thank you. Testing is some of the least visible and most important maintenance work there is.

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.

3 participants