Skip to content

Instantly share code, notes, and snippets.

@jayzz55
Last active December 19, 2018 22:04
Show Gist options
  • Save jayzz55/ba60150a0722fe9d257c3c5c581cb775 to your computer and use it in GitHub Desktop.
Save jayzz55/ba60150a0722fe9d257c3c5c581cb775 to your computer and use it in GitHub Desktop.
scala contramap example
F[A] Ordering[Int]
B => A listing => listing.id
F[B] Ordering[Listing]
val intOrderer: Ordering[Int]
val listingOrderer: Ordering[Listing] = intOrderer.contraMap(listing => listing.id)
See: http://igstan.ro/posts/2013-10-31-contravariant-functors-an-intuition.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment