interval-algebra 0.8.2 → 0.8.3
raw patch · 5 files changed
+35/−53 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +9/−1
- interval-algebra.cabal +1/−1
- src/IntervalAlgebra.hs +17/−47
- src/IntervalAlgebra/IntervalUtilities.hs +5/−3
- test/IntervalAlgebraSpec.hs +3/−1
ChangeLog.md view
@@ -1,6 +1,14 @@ # Changelog for interval-algebra -## 0.8.2 +## 0.8.3++* Moves `begin` and `end` out of the `Intervallic` class.+* Avoids incomplete patterns warnings by:+ * deriving `Enum` instance of `IntervalRelation`+ * catching equals case with `otherwise` in `disjoinPairs`+ * catching disjoint case with `otherwise` in `clip`++## 0.8.2 * Removes `Show` constraint from `intervals` function in `PairIntervals`.
interval-algebra.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: interval-algebra-version: 0.8.2+version: 0.8.3 synopsis: An implementation of Allen's interval algebra for temporal logic description: Please see the README on GitHub at <https://github.com/novisci/interval-algebra> category: Algebra,Time
src/IntervalAlgebra.hs view
@@ -37,6 +37,8 @@ -- * Intervals Interval , Intervallic(..)+ , begin+ , end -- ** Create new intervals , parseInterval@@ -247,11 +249,10 @@ -- | Set the interval in an @i a@. setInterval :: i a -> Interval a -> i a - -- | Access the endpoints of an @i a@ .- begin, end :: i a -> a- begin = intervalBegin . getInterval- end = intervalEnd . getInterval-+-- | Access the endpoints of an @i a@ .+begin, end :: Intervallic i a => i a -> a+begin = intervalBegin . getInterval+end = intervalEnd . getInterval {- | The 'IntervalRelation' type and the associated predicate functions enumerate@@ -260,55 +261,24 @@ predicate function. -} data IntervalRelation =- Meets -- ^ `meets`- | MetBy -- ^ `metBy`- | Before -- ^ `before`- | After -- ^ `after`- | Overlaps -- ^ `overlaps` - | OverlappedBy -- ^ `overlappedBy`- | Starts -- ^ `starts`- | StartedBy -- ^ `startedBy`- | Finishes -- ^ `finishes`+ Before -- ^ `before`+ | Meets -- ^ `meets`+ | Overlaps -- ^ `overlaps` | FinishedBy -- ^ `finishedBy`- | During -- ^ `during` | Contains -- ^ `contains`+ | Starts -- ^ `starts` | Equals -- ^ `equals`- deriving (Eq, Show, Read)+ | StartedBy -- ^ `startedBy`+ | During -- ^ `during`+ | Finishes -- ^ `finishes`+ | OverlappedBy -- ^ `overlappedBy`+ | MetBy -- ^ `metBy`+ | After -- ^ `after`+ deriving (Eq, Show, Read, Enum) instance Bounded IntervalRelation where minBound = Before maxBound = After--instance Enum IntervalRelation where- fromEnum r = case r of- Before -> 0- Meets -> 1- Overlaps -> 2- FinishedBy -> 3- Contains -> 4- Starts -> 5- Equals -> 6- StartedBy -> 7- During -> 8- Finishes -> 9- OverlappedBy -> 10- MetBy -> 11- After -> 12-- toEnum i = case i of- 0 -> Before- 1 -> Meets- 2 -> Overlaps- 3 -> FinishedBy- 4 -> Contains- 5 -> Starts- 6 -> Equals- 7 -> StartedBy- 8 -> During- 9 -> Finishes- 10 -> OverlappedBy- 11 -> MetBy- 12 -> After instance Ord IntervalRelation where compare x y = compare (fromEnum x) (fromEnum y)
src/IntervalAlgebra/IntervalUtilities.hs view
@@ -83,6 +83,8 @@ import Safe ( headMay, lastMay, initSafe, tailSafe) import Witherable ( Filterable(filter) ) import IntervalAlgebra ( (<|>),+ begin, + end, after, before, beginerval,@@ -250,7 +252,7 @@ | overlappedBy x y = Just $ beginerval (diff (end y) (begin x)) (begin x) | jx x y = Just (getInterval x) | jy x y = Just (getInterval y)- | disjoint x y = Nothing+ | otherwise = Nothing {- disjoint x y case -} where jy = equals <|> startedBy <|> contains <|> finishedBy jx = starts <|> during <|> finishes @@ -387,7 +389,7 @@ makeFilter f p = Witherable.filter (f p) {- | -Filter 'Filterable' containers of one @'Intervallic'@ type based by comparing to +Filter 'Witherable.Filterable' containers of one @'Intervallic'@ type based by comparing to a (potentially different) 'Intervallic' type using the corresponding interval predicate function. -}@@ -501,7 +503,7 @@ | x `finishedBy` y = foldMeeting $ Meeting [ evp b1 b2 s1, ev i2 sc ] | x `contains` y = foldMeeting $ Meeting [ evp b1 b2 s1, evp b2 e2 sc, evp e2 e1 s1 ] | x `starts` y = foldMeeting $ Meeting [ ev i1 sc, evp e1 e2 s2 ]- | x `equals` y = Meeting [ ev i1 sc ]+ | otherwise = Meeting [ ev i1 sc ] {- x `equals` y case -} where x = min o e y = max o e i1 = getInterval x
test/IntervalAlgebraSpec.hs view
@@ -38,11 +38,13 @@ , compose , disjoint , (<|>)+ , begin+ , end , IntervalCombinable((.+.)) , IntervalSizeable(moment, diff) , ComparativePredicateOf1 , ComparativePredicateOf2- , Intervallic(begin, end)+ , Intervallic , Interval ) mkIntrvl :: Int -> Int -> Interval Int