typelevel / scalaz-contrib

Interoperability libraries & additional data structures and instances for Scalaz
http://typelevel.org
MIT License
54 stars 16 forks source link

Add a semigroup instance for Interval defined as "intersection". #22

Closed LeifW closed 10 years ago

LeifW commented 10 years ago

I think of this like the product of a Ring, with an annihilating zero, but there's no "union" operator for Intervals in Joda-time. overlap is defined here: http://joda-time.sourceforge.net/apidocs/org/joda/time/Interval.html#overlap(org.joda.time.ReadableInterval) Says it returns null on no overlap, but that throws a NPE in the scalacheck properties. So instead I return an interval that starts and stops at dawn of epoch to serve as the "empty set".

larsrh commented 10 years ago

Makes sense. Thanks!