Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Anirudh Vyas AnirudhVyas

🏠
Working from home
View GitHub Profile
@AnirudhVyas
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] = xs.map(f)
}
implicit object OptionFunctor extends Functor[Option] {
You can’t perform that action at this time.