Skip to content

Instantly share code, notes, and snippets.

Working from home

Anirudh Vyas AnirudhVyas

Working from home
View GitHub Profile
AnirudhVyas / TypeClasses.scala
Last active Mar 15, 2020
Some Basic typeclasses
View TypeClasses.scala
import scala.language.higherKinds
object TypeClasses {
// applies to type constructors (F[_])
trait Functor[F[_]] {
def map[A, B](xs: F[A])(f: A => B): F[B]
implicit object ListFunctor extends Functor[List] {
override def map[A, B](xs: List[A])(f: A => B): List[B] =
implicit object OptionFunctor extends Functor[Option] {