Open tnielens opened 4 years ago
If I'm not misunderstanding something, works for me with 2.2.0
test("empty") {
import alleycats.Empty
// works fine
Empty[List[Int]]
Empty[Set[Int]]
Empty[Stream[Int]]
// doesn't work by default
println(">>>> "+ Empty[Option[Int]].empty) // >>>> None
//resolved implicit is alleycats.EmptyInstances1.monoidIsEmpty
}
indeed it does not work if T has no Monoid
Empty[Option[T]].empty
Indeed, I got confused while trying to minimize the example. I'll rewrite the example with a type for which a Monoid wouldn't make sense.
There is no default instance for
Empty[Option[T]]
if T has no Monoid. But there is one for collections. Would it make sense to add anEmpty[Option[T]]
instance that behaves like the collection default ones?EDIT: rewrite the example with a type that has no Monoid.