Skip to content

Jacobbishopxy/herding-cats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Herding CATS

book source: Scala with CATS

web source: herding cats

cats exercises: Scala Cats exercises

my study note: CatsStudyNote

Content

  1. theory

  2. herding cats

  3. case studies

Note

Abstract implementations patterns

Functor: mapping

Applicative: zipping

Monad: sequencing

Traverse: iteration

Cats Typeclass cheat sheet

cheat sheet

  1. Defining Signatures
Typeclass Signature
Functor F[A] => (A => B) => F[B]
Contravariant F[A] => (B => A) => F[B]
Apply F[A] => F[A => B] => F[B]
FlatMap F[A] => (A => F[B]) => F[B]
CoFlatMap F[A] => (F[A] => B) => F[B]
Traverse F[A] => (A => G[B]) => G[F[B]]
Foldable F[A] => (B, (B, A) => B) => B
SemigroupK F[A] => F[A] => F[A]
Cartesian F[A] => F[B] => F[(A, B)]
  1. Derived Functions
Typeclass Function Signature
Functor map
fproduct
as
tupleLeft
tupleRight
void
F[A] => (A => B) => F[B]
F[A] => (A => B) => F[(A, B)]
F[A] => B => F[B]
F[A] => B => F[(B, A)]
F[A] => B => F[(A, B)]
F[A] => F[Unit]
Contravariant contramap F[A] => (B => A) => F[B]
Apply ap
map2
F[A] => F[A => B] => F[B]
F[A] => (F[B] => ((A, B) => C)) => F[C]
Applicative ap
unlessA
whenA
replicateA
F[A] => F[A => B] => F[B]
F[A] => Boolean => F[Unit]
F[A] => Boolean => F[Unit]
F[A] => Int => F[List[A]]
FlatMap flatMap
followedBy
forEffect
mproduct
flatten
F[A] => (A => F[B]) => F[B]
F[A] => F[B] => F[B]
F[A] => F[B] => F[A]
F[A] => (A => F[B]) => F[(A, B)]
F[F[A]] => F[A]
CoFlatMap coflatMap
coflatten
F[A] => (F[A] => B) => F[B]
F[A] => F[A[A]]
Traverse traverse
mapWithIndex
zipWithIndex
sequence
F[A] => (A => G[B]) => G[F[B]]
F[A] => ((A, Int) => B) => F[B]
F[A] => F[(A, Int)]
F[G[A]] => G[F[A]]
Foldable foldLeft
foldRight
foldMap
combineAll
find
exists
forall
toList
isEmpty
nonEmpty
size
F[A] => (B => ((B, A) => B)) => B
F[A] => (Eval[B] => ((A, Eval[B]) => Eval[B])) => Eval[B]
F[A] => (A => B) => B
F[A] => A
F[A] => (A => Boolean) => Option[A]
F[A] => (A => Boolean) => Boolean
F[A] => (A => Boolean) => Boolean
F[A] => List[A]
F[A] => Boolean
F[A] => Boolean
F[A] => Int
SemigroupK combine F[A] => F[A] => F[A]
Cartesian product F[A] => F[B] => F[(A, B)]

Monad type class hierarchy


Cartesian            Functor
(product)             (map)
    |___________________|
              |
            Apply
            (ap)
     _________|_________
    |                   |
Applicative          FlatMap
  (pure)            (flatMap)
    |___________________|
              |
            Monad

Cats type class view:

thanks to tpolecat's project

Cats type class

About

CATS studies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages