packages feed

time-patterns 0.1.0.2 → 0.1.1.0

raw patch · 3 files changed

+19/−5 lines, 3 files

Files

src/Data/Time/Patterns.hs view
@@ -22,10 +22,18 @@ -- >   let april6 = (take 1 $ skip 5 day) `inEach` april -- >   let today = (YearMonthDay 2013 12 01)^.from gregorian -- >   print $ P.take 10 $ instancesFrom today april6--- >+-- +-- @DatePattern@s can be combined using @union@, @intersect@ with their +-- obvious meanings and @inEach@ which repeats one pattern inside another one.+-- For example, +--+-- > ((take 1 day) 'inEach' august) `intersect` sunday+--+-- will give the 1st of August in years when it falls on a Sunday. ---------------------------------------------------------------------------- module Data.Time.Patterns(     -- * Date Patterns+    DatePattern,     day,     mondayWeek,     sundayWeek,@@ -77,6 +85,9 @@ import qualified Data.Time.Patterns.Internal as I import Prelude hiding (cycle, elem, filter, take) import qualified Prelude as P++-- | A DatePattern describes a sequence of intervals of type Data.Thyme.Day.+type DatePattern = IntervalSequence Day  -- | An event that occurs every month. month :: DatePattern
src/Data/Time/Patterns/Internal.hs view
@@ -11,7 +11,7 @@ module Data.Time.Patterns.Internal where  import Numeric.Interval-import Data.Thyme.Calendar (Day)+import Data.Monoid (Monoid(..)) import Data.Thyme.Clock (UTCTime) import Prelude hiding (cycle, elem, filter, take) @@ -20,9 +20,11 @@ -- nextOccurrence yield a sequence of occurrences. newtype IntervalSequence t = IntervalSequence { nextInterval :: t -> Maybe (Interval t, IntervalSequence t)} -type DatePattern = IntervalSequence Day type TimePattern = IntervalSequence UTCTime -- TimePattern should cycle throu +instance (Ord t) => Monoid (IntervalSequence t) where+    mappend = union+    mempty  = never  -- | A sequence with no occurrences never :: IntervalSequence t
time-patterns.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                time-patterns-version:             0.1.0.2+version:             0.1.1.0 synopsis:            Patterns of re-occurring events     license:             BSD3 license-file:        LICENSE@@ -23,7 +23,8 @@   > >> let today = (YearMonthDay 2013 12 01)^.from gregorian   > >> P.take 2 $ instancesFrom today sundays   > [2013-12-08, 2013-12-22]-+  .+  See @Data.Time.Patterns@ for more examples. source-repository head   type: git   location: git@bitbucket.org:jfmueller/time-patterns.git