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

added instance table to docs, enhanced typeclass diagram #1565

Merged
merged 9 commits into from
May 13, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ lazy val docSettings = Seq(
"-diagrams"
),
git.remoteRepo := "git@github.com:typelevel/cats.git",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md"
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md" | "*.svg",
includeFilter in Jekyll := (includeFilter in makeSite).value
)

lazy val docs = project
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 29 additions & 48 deletions docs/src/main/tut/typeclasses/typeclasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,54 +221,35 @@ val result = Monoid[Int].combine(sumLeft, sumRight)
Cats provides laws for type classes via the `kernel-laws` and `laws` modules which makes law checking
type class instances easy.

## Typeclass Hierarchy
![Typeclass hierarchy](http://g.gravizo.com/g?
digraph G {
size ="6,6";
edge [dir=back]
node [shape=box,style="rounded"]
Functor [group=g2]
Apply [group=g2]
Applicative [group=g2]
Monad [group=g2]
SemigroupK [group=g1]
MonoidK [group=g1]
Alternative [group=g1]
MonadFilter [group=g1]
MonadCombine [group=g1]
Invariant [group=g4]
Contravariant [group=g4]
CoflatMap [group=g5]
Comonad [group=g5]
Bimonad [group=g5]
MonadError [group=g6]
ApplicativeError [group=g6]
Functor -> Apply -> Applicative -> Monad -> MonadFilter -> MonadCombine
Applicative -> Alternative -> MonadCombine
MonoidK -> Alternative
Functor -> CoflatMap
Applicative -> ApplicativeError -> MonadError
Monad -> MonadError
subgraph cluster_s3{
Invariant -> Contravariant
graph[style=dotted,label="functor"]
}
Invariant -> Functor
subgraph cluster_s2{
SemigroupK -> MonoidK
graph[style=dotted]
}
subgraph cluster_s1{
CoflatMap -> Comonad -> Bimonad
graph[style=dotted]
}
Monad -> Bimonad
Apply -> FlatMap -> Monad
Foldable -> Traverse
Functor -> Traverse
Foldable -> Reducible
}
)
## Type classes in cats

Created by [@tpolecat](https://github.com/tpolecat/cats-infographic).

![infographic](./img/typeclass-infographic.svg)


## Incomplete type class instances in cats

Originally from [@alexknvl](https://gist.github.com/alexknvl/d63508ddb6a728015ace53cb70a1fd5d)


| Type | Functor | Apply | Applicative | Monad | MonoidK | ApplicativeError | MonadError | CoflatMap | Comonad |
| --------------- |:-------:|:-----------------:|:-----------:|:-----:|:-------:|:-----------------:|:----------:|:---------:|:-------:|
| Id[A] | ✔ | ✔ | ✔ | ✔ | ✗ | ✗ | ✗ | ✔ | ✔ |
| Eval[A] | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | ✔ | ✔ | ✔ |
| Option[A] | ✔ | ✔ | ✔ | ✔ | ✔ | ✗ | ✗ | ✔ | ✗ |
| Const[K, A] | ✔ | ✔ (`K:Monoid`) | ✔ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| Either[E, A] | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✗ | ✗ |
| List[A] | ✔ | ✔ | ✔ | ✔ | ✔ | ✗ | ✗ | ✔ | ✗ |
| NonEmptyList[A] | ✔ | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | ✔ | ✔ |
| Stream[A] | ✔ | ✔ | ✔ | ✔ | ✔ | ✗ | ✗ | ✔ | ✗ |
| Map[K, A] | ✔ | ✔ | ✗ | ✗ | ✔ | ✗ | ✗ | ✗ | ✗ |
| Validated[E, A] | ✔ | ✔ (`E: Semigroup`)| ✔ | ✗ | ✗ | ✔ (`E: Semigroup`)| ✗ | ✗ | ✗ |
| Reader[E, A] | ✔ | ✔ | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | ✗ |
| Writer[E, A] | ✔ | ✔ (`E:Monoid`) | ✔ | ✔ | ✗ | ✗ | ✗ | ✔ | ✗ |




## Further reading
* [Returning the "Current" Type in Scala][fbounds]
Expand Down