FunctionalProgrammingSimplified icon indicating copy to clipboard operation
FunctionalProgrammingSimplified copied to clipboard

Missing interface object on Typeclass 101

Open wibisono opened this issue 6 years ago • 0 comments

In page 797, BehavesLikeHuman.speak(rover) won't compile since we only have instances definition, but have not yet defined interface object, the following is missing:

object BehavesLikeHuman {
  def speak[A](creature : A)(implicit humanLike : BehavesLikeHuman[A]) = humanLike.speak(creature)
}

Personally, I prefer to just call this interface Speaking instead of behaves like human. Example gist I find easier to read https://gist.github.com/wibisono/28d8808159e0c7103042d7c5c668edf7

wibisono avatar Mar 14 '18 21:03 wibisono