Comments (6)
Certain things (like show
) are going to need an implementation somewhere. To me it seems to make sense to put the implementations on the data structure itself and then have the type class instance call through to it.
However, there's also the question of derived methods. At nescala @tpolecat, @non, some others (whose GitHub handles I don't know :( ), and I were discussing what options there might be to have derived methods available on data structures for free. It's always slightly annoyed me that in scalaz it's pretty ad hoc as to which derived type class methods are available on a given structure. I can't recall whether or not we came to a good solution. Maybe they remember?
from cats.
I also like defining the methods in the class because it gives a better documentation and no need of special import. however, what do we do for TC like Traverse
or Fold
which have a lot of derived methods?
from cats.
@julien-truffaut that's a good question. Hopefully some good suggestions will come out of this discussion!
from cats.
I agree with @ceedubs -- I think concrete types should provide all the concrete implementations there type classes need.
This can be a bit ugly but it has many benefits:
- Things for users are guaranteed to "just work" whenever possible.
- You can avoid repeatedly synthesizing type class instances.
- It makes the methods more discoverable via documentation / browsing.
Of these concerns I think (2) is the most important.
If we agree with this approach then it implies that at a minimum we should be adding ===
and =!=
methods to our concrete types where applicable, so that they can directly do type-safe equality checking.
from cats.
@julien-truffaut seems like there in consensus here, do you think we need to do more with this issue?
from cats.
sure I think we all agree
from cats.
Related Issues (20)
- `Apply` syntax is allocating HOT 2
- add `sizeIs` method like std-lib to `cats.Reducible` and/or NonEmpty collections HOT 1
- Maybe you are looking for `as`? :) HOT 2
- Fix documentation (or design) of Free Monad
- Type-classes for Prepend (Cons) and Append (Snoc) operations HOT 5
- Scala 3: No given instance of type cats.Applicative[[_] =>> Any] was found for parameter F of method apply in class PurePartiallyApplied
- Unusual EqLaws definition HOT 4
- Outdated Link in Docs - Seeking Guidance for Fix HOT 1
- algebra-core/src HOT 1
- Option size method implicitly selected from UnorderedFoldable HOT 2
- IndexedStateT has superfluous parts HOT 4
- .splitWhen
- Difference in the Applicative inferred for Seq[Seq[?]]#sequence between Scala 2 and 3
- Inconsistent behaviour when using Eval as Applicative
- `Tuple1SemigroupalOps` methods have different names from other `TupleNSemigroupalOps` classes HOT 3
- Instances for Currency HOT 7
- EitherT[Option, ?, ?]] can't be used as a bifunctor HOT 5
- trait EuclidianRing should not be a Ring HOT 4
- OutOfMemoryError when IO.uncancelable is used in recursive function HOT 1
- ambiguous implicit resolution of `Show.ContravariantShow[immutable.SortedMap[K, V]]` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cats.