Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Last active August 29, 2020 08:00
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpolecat/7401433 to your computer and use it in GitHub Desktop.
Save tpolecat/7401433 to your computer and use it in GitHub Desktop.
set is not a functor mkay
scala> case class Bad(a: Int) { override def equals(a:Any) = true }
scala> val f = (n:Int) => Bad(n)
scala> val g = (b:Bad) => b.a
...
scala> Set(1,2,3).map(f andThen g)
res2: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
scala> Set(1,2,3).map(f).map(g)
res3: scala.collection.immutable.Set[Int] = Set(1)
@tpolecat
Copy link
Author

Functor says for all A.

@EncodePanda
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment