Skip to content

Instantly share code, notes, and snippets.

View AnirudhVyas's full-sized avatar
🏠
Working from home

Anirudh Vyas AnirudhVyas

🏠
Working from home
  • Goldilocks Fashion LLC
  • San Ramon,CA
View GitHub Profile
@AnirudhVyas
AnirudhVyas / TypeClasses.scala
Last active March 15, 2020 06:17
Some Basic typeclasses
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] = xs.map(f)
}
implicit object OptionFunctor extends Functor[Option] {