Skip to content

Commit

Permalink
Merge pull request #1565 from kailuowang/instance-table
Browse files Browse the repository at this point in the history
added instance table to docs, enhanced typeclass diagram
  • Loading branch information
ceedubs authored May 13, 2017
2 parents fc40a1c + 24fda91 commit 5340ee6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 49 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ lazy val docSettings = Seq(
"-diagrams"
),
git.remoteRepo := "[email protected]: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
76 changes: 28 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,34 @@ 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

![infographic](https://cdn.rawgit.com/tpolecat/cats-infographic/master/cats.svg)
From [cats-infographic by @tpolecat](https://github.com/tpolecat/cats-infographic).


## 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

0 comments on commit 5340ee6

Please sign in to comment.