1
내가 http://hseeberger.wordpress.com/2010/11/25/introduction-to-category-theory-in-scala/ 찾고 있어요 내가 어떻게 작동하는지 이해할 수없는 코드의 비트있다 : 특히스칼라 변수 범위는
object Functor {
def fmap[A, B, F[_]](as: F[A])(f: A => B)(implicit functor: Functor[F]): F[B] =
functor.fmap(as)(f)
implicit object ListFunctor extends Functor[List] {
def fmap[A, B](f: A => B): List[A] => List[B] =
as => as map f
}
}
, 어떻게 ListFunctor.fmap
이 as
에 액세스하는 것은 as
의 정의는 경우 Functor.fmap
의 범위에서 (내가 말할 수있는 한) ListFunctor.fmap
에 액세스 할 수 없습니까? (트위스트 관련)
정의되어 위의 코드에 이전 반복 있습니다 :
trait Functor[F[_]] extends GenericFunctor[Function, Function, F] {
final def fmap[A, B](as: F[A])(f: A => B): F[B] =
fmap(f)(as)
}
object ListFunctor extends Functor[List] {
def fmap[A, B](f: A => B): List[A] => List[B] = as => as map f
}
그러나 다시는 as
는 ListFunctor
에 마술 액세스 할 것으로 보인다. 나는이 중 하나를 이해한다면 다른 것을 이해할 것입니다.
아, 쏘지, 네 말이 맞아. 감사! – JasonMond