• Stars
    star
    367
  • Rank 116,257 (Top 3 %)
  • Language
    Scala
  • License
    Creative Commons ...
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Abstractions from Category theory with simple description & implementation, links to further resources.

Build Status Scala Steward badge

Scala typeclassopedia

classDiagram
   Functor~F~ <|-- Apply~F~
   Apply <|-- FlatMap~F~
   Functor <|-- Traverse~F~
   Foldable~F~ <|-- Traverse
   FlatMap~F~ <|-- Monad~F~
   Apply~F~ <|-- Applicative~F~
   Apply <|-- CoflatMap~F~
   CoflatMap <|-- Comonad~F~
   Applicative <|-- Selective~F~
   Selective <|-- Monad
   Applicative <|-- Alternative~F~
   MonoidK~F~ <|-- Alternative
   Applicative <|-- ApplicativeError~F~
   ApplicativeError <|-- MonadError~F~
   Monad <|-- MonadError
   Monad <|-- Bimonad~F~
   Comonad <|-- Bimonad

   class Functor {
     ) map(F[A], A => B): F[B]
   }
   class Foldable {
     ) foldLeft(F[A], B, Tuple2[B,A] => B): B
   }
   class Traverse {
     ) traverse(F[A], A => G[B]): G[F[B]]
   }
   class Apply {
     ) ap(F[A], F[A => B]): F[B]
     ) map2(Tuple2[A,B] => C, F[A], F[B]): F[C]
   }
   class Applicative {
     ) pure(A): F[A]
   }
   class Selective {
     ) select(F[Either[A,B]], F[A=>B]): F[B]
   }
   class FlatMap {
     ) flatmap(F[A], A => F[B]): F[B]
   }
   class Monad {
     ) flatten(F[F[A]]): F[A]
   }
   class ApplicativeError {
     ) raiseError(E): F[A]
   }
   class CoflatMap {
     ) extend(F[A], F[A] => B): F[B]
   }
   class Comonad {
     ) extract(W[A]): A
   }
   class MonoidK {
     ) empty(): F[A]
     ) combine(F[A], F[A]): F[A]
   }
   class Alternative {
     ) some(F[A]): F[NonEmptyList[A]]
     ) many(F[A]): F[List[A]]
   }
classDiagram
   Bifoldable~P[+_,+_]~ <|-- Bitraverse~P[+_,+_]~
   Bifunctor~P[+_,+_]~ <|-- Bitraverse
   Bifunctor <|-- Biapply~P[+_,+_]~
   Biapply <|-- Biapplicative~P[+_,+_]~
   Functor~F[+_]~ <|-- Bifunctor
   Functor <|-- Bifunctor
   Functor <|-- Profunctor~P[-_,+_]~
   Bifunctor <|-- Zivariant~Z[-_,+_,+_]~
   Profunctor <|-- Zivariant

  class Functor {
    ) map(F[A], A => B): F[B]
  }
  class Profunctor {
    ) dimap(AA => A, B => BB): P[A,B] => P[AA,BB]
  }
  class Bifunctor {
    ) bimap(A => AA, B => BB): P[A,B] => P[AA,BB]
  }
  class Bifoldable {
    ) bifoldLeft(F[A,B], C, (C,A) => C, (C,B) => C): C
  }
  class Bitraverse {
    ) bitraverse[G: Applicative](F[A,B], A=>G[C], B => G[D]): G[F[C,D]]
  }
  class Biapply {
    ) biApply(F[A,B], F[A=>AA,B=>BB]): F[AA,BB]
  }
  class Biapplicative {
    ) bipure(a: A, b: B): F[A,B]
  }
  class Zivariant {
    ) zimap(AA => A, B => BB, C => CC): P[A,B,C] => P[AA,BB,CC]
  }
classDiagram
   Ran~G[_], H[_], A~ <|-- Yoneda~H[_], A~
   Lan~G[_], H[_], A~ <|-- CoYoneda~H[_], A~
   Ran <|-- Codensity~G[_], A~
   Lan <|-- Density~G[_], A~

  class Ran {
    // Right Kan Extension
    ) run[B](A => G[B]): H[B]
  }
  class Yoneda {
    ) run[B](A => B): H[R]
  }
  class Codensity {
    ) run[B](A => G[B]): G[B]
  }
  class Lan {
    // Left Kan Extension
    fz: H[Z]
    run: G[Z] => A
  }
  class CoYoneda {
    fz: H[Z]
    run: Z => A
  }
  class Density {
    fz: G[Z]
    run: G[Z] => A
  }
  class Day~G[_], H[_], A~ {
    // Day convolution
    gb: G[Z]
    hb: H[X]
    ) run: (Z,X) => A
  }
classDiagram
   Functor~F[+_]~ <|-- Bifunctor~F[+_,+_]~
   Functor <|-- Bifunctor
   Functor <|-- Profunctor~F[-_,+_]~
   Contravariant~F[-_]~ <|-- Profunctor
   Semicategory~F[-_,+_]~ <|-- Category~F[-_,+_]~
   Category <|-- Arrow~F[-_,+_]~
   Bifunctor <|-- Zivariant~F[-_,+_,+_]~
   Profunctor <|-- Zivariant
   Profunctor <|-- Strong~F[-_,+_]~
   Strong -- Arrow
   Arrow <|-- ArrowApply~F[-_,+_]~
   Arrow <|-- CommutativeArrow~F[-_,+_]~
   Arrow <|-- ArrowLoop~F[-_,+_]~
   Profunctor <|-- Choice~F[-_,+_]~
   Arrow <|-- ArrowZero~F[-_,+_]~
   Arrow <|-- ArrowChoice~F[-_,+_]~
   Choice <|-- ArrowChoice

   class Functor {
     ) map(F[A], A => B): F[B]
   }
   class Contravariant {
     ) contramap(F[A], B => A): F[B]
   }
   class Semicategory {
     ) compose[A,B,C](F[B,C], F[A,B]): F[A,C]
   }
  class Category {
    ) id[A]: F[A,A]
  }
  class Profunctor {
    ) dimap(AA => A, B => BB): P[A,B] => P[AA,BB]
  }
  class Bifunctor {
    ) bimap(A => AA, B => BB): P[A,B] => P[AA,BB]
  }
  class Zivariant {
    ) zimap(AA => A, B => BB, C => CC): P[A,B,C] => P[AA,BB,CC]
  }
  class Strong {
    ) first(P[A,B]): P[(A,C), (B,C)]
  }
  class Choice {
    ) left(P[A,B]): P[Either[A, C], Either[B, C]]
  }
  class Arrow {
    ) arr(A => B): F[A, B]
  }
  class ArrowZero {
    ) zeroArr(): P[A,B]
  }
  class ArrowApply {
    ) app(P[P[B,C],B]): C
  }
  class ArrowApply {
    ) app(P[P[B,C],B]): C
  }
  class ArrowLoop {
    ) loop(P[(B,D), (C,D)]: P[B,C]
  }
Types Logic Category Theory Homotopy Theory
Void false initial object empty space
Unit true terminal object singleton
Sum (Coproduct) Eiter[A,B] A v B disjunction coproduct coproduct space
Product (A,B) A ∧ B conjunction product product space
A => B A => B implication exponential object singleton
A => Void negation exp. obj. into initial obj.

Resources covering topics about FP and category theory in great details:

Computational trinitarianism resources