Created
September 8, 2021 17:18
-
-
Save programaker/d6e8086816d3f2207a07f5ca6d726976 to your computer and use it in GitHub Desktop.
Functions are Functors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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