Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Add cats-kernel dependency. #152

Merged
merged 6 commits into from
May 18, 2016
Merged

Add cats-kernel dependency. #152

merged 6 commits into from
May 18, 2016

Conversation

non
Copy link
Contributor

@non non commented Apr 30, 2016

This commit switches the algebra-core package over to just
aliasing the cats-kernel type classes and companion objects.
It also uses cats.kernel.std instances instead of the
corresponding algebra.std instances.

It also updates the scala.js version to be compatible with
cats.kernel, and removes some unnecessary imports.

This commit switches the algebra-core package over to just
aliasing the cats-kernel type classes and companion objects.
It also uses cats.kernel.std instances instead of the
corresponding algebra.std instances.

It also updates the scala.js version to be compatible with
cats.kernel, and removes some unnecessary imports.
@non
Copy link
Contributor Author

non commented Apr 30, 2016

This is currently using a local snapshot. I plan to publish cats 0.6.0-M1 and update this PR to that dependency before asking for a merge. But I wanted to put this out there so folks could take a look at it.

@@ -107,9 +108,9 @@ trait LawTestsBase extends FunSuite with Discipline {
laws[RingLaws, Set[String]].check(_.semiring)

laws[OrderLaws, Map[Char, Int]].check(_.eqv)
laws[RingLaws, Map[Char, Int]].check(_.rng)
Copy link
Contributor

Choose a reason for hiding this comment

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

did these break because of the change to the Eq?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the RNG instance for Map because of the changes to Eq[Map[K, V]].

@johnynek
Copy link
Contributor

looks good to me.

One comment: I guess we should never add an instance here to any type not defined here if it is only for typeclasses in cats (e.g. Semigroup, Monoid, Group, etc...)

So, for the #148 discussion, we might consider adding the TotalMap, TotalVector type to cats kernel? Or just since we added it here, it is safe to add the instances too, of course.

@rklaehn
Copy link
Collaborator

rklaehn commented May 1, 2016

@johnynek

I would be against having any sort of data structure in cats-kernel, even if it is just a trivial wrapper around scala.collection.immutable data structures. It should be very small and just contain completely uncontroversial typeclasses.

Regarding the implementation, I think TotalX shouldn't have much except an apply method and an O(1) way to get the underlying non-total map/vector.

@non
Copy link
Contributor Author

non commented May 2, 2016

As far as "vector" wrappers go -- yeah, I think that is a good starting principle.

I think having algebra define simple "vector" wrappers makes sense. I think @rklaehn is right that we should have (unsafe) accessors, but we should also provide a minimal interface to use the type as a vector. The reason I think accessing the underlying structure is (potentially) unsafe is that we want to treat things like Map(1 -> 0.0) and Map.empty[Double] as equivalent, but the laws for Eq mandates that they behave identically.

@rklaehn
Copy link
Collaborator

rklaehn commented May 2, 2016

@non, the way I solve it in https://github.com/rklaehn/abc is that in TotalArrayMap, I never store mappings to the default value. It's my fetish with canonical representations. Without that property, you wouldn't be able to use structural comparison to compare TotalArrayMap instances, which would suck.

scala> ArrayMap(1 -> 1).withDefault(1)
res1: com.rklaehn.abc.TotalArrayMap[Int,Int] = TotalArrayMap((), 1)

scala> ArraySeq(1,0,1,0).withDefault(0)
res2: com.rklaehn.abc.TotalArraySeq[Int] = ArraySeq(1,0,1).withDefault(0)

A consequence is that sometimes, x.withDefault(y).withoutDefault =!= x, which might be unexpected.

@non
Copy link
Contributor Author

non commented May 2, 2016

@rklaehn Right, that is definitely the correct way to do it.

Instead of the previous SNAPSHOT dependency, this commit moves
us to depending on a stable milestone.
@non
Copy link
Contributor Author

non commented May 17, 2016

Assuming Travis is happy, I think we should merge this. It depends on a stable Cats milestone (0.6.0-M2) and will allow us to make this transition now anticipating Cats 0.6.0.

non and others added 2 commits May 17, 2016 10:49
The goal is to make our tests faster. For example,
it would be nice if we could eliminate Travis timeouts.
We should re-enable once we figure out how to speed
up the JS law tests.
@@ -1,2 +1,38 @@
package object algebra {

Copy link
Contributor

Choose a reason for hiding this comment

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

would it be too much of a pain to sort the types alphabetically.

@johnynek
Copy link
Contributor

some minor comments, but pretty much ready to merge.

@non
Copy link
Contributor Author

non commented May 17, 2016

I'll go ahead and handle the obvious issues @johnynek pointed out.

@TomasMikula
Copy link
Collaborator

👍

1 similar comment
@johnynek
Copy link
Contributor

👍

@non non merged commit e4654c5 into master May 18, 2016
@milessabin
Copy link
Member

🎉

@johnynek johnynek deleted the topic/cats-kernel-dep branch May 24, 2016 17:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants