Skip to content

Instantly share code, notes, and snippets.

@programaker
Created September 8, 2021 17:18
Show Gist options
  • Save programaker/d6e8086816d3f2207a07f5ca6d726976 to your computer and use it in GitHub Desktop.
Save programaker/d6e8086816d3f2207a07f5ca6d726976 to your computer and use it in GitHub Desktop.
Functions are Functors
import cats.syntax.functor._
// Some types
trait A
trait B
trait C
// Some functions
val f: A => B = ???
val g: B => C = ???
// Function composition
val h1: A => C = g compose f // or...
val h2: A => C = f andThen g
// Functions are Functors where `map` is function composition!
val h3: A => C = f map g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment