Created
February 3, 2021 03:34
-
-
Save dhinojosa/06637d1023746a8906c9183e51dddc6c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
trait Functor[F[_]]: | |
def fmap[A, B](fa:F[A])(f: A => B):F[B] | |
trait Applicative[F[_]] extends Functor[F]: | |
def pure[A](a:A):F[A] | |
object Lists: | |
given Functor[List] with | |
def fmap[A,B](fa:List[A])(f:A=>B):List[B] = fa.map(f) | |
given (using fn:Functor[List]):Applicative[List] with | |
def fmap[A,B](fa:List[A])(f:A=>B):List[B] = fn.fmap(fa)(f) | |
def pure[A](a:A) = List(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This appears to work, but looks wierd: