-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Intervals, and monoids thereof -- -- Please see the README at -- https://github.com/mixphix/interval-patterns @package interval-patterns @version 0.7.0.1 module Data.OneOrTwo -- | Either one of something, or two of it. -- -- Use oneOrTwo to deconstruct. data OneOrTwo x One :: !x -> OneOrTwo x Two :: !x -> !x -> OneOrTwo x -- | Apply a oneOrTwo argument function appropriately. oneOrTwo :: (x -> a) -> (x -> x -> a) -> OneOrTwo x -> a instance Data.Traversable.Traversable Data.OneOrTwo.OneOrTwo instance Data.Foldable.Foldable Data.OneOrTwo.OneOrTwo instance GHC.Base.Functor Data.OneOrTwo.OneOrTwo instance Data.Data.Data x => Data.Data.Data (Data.OneOrTwo.OneOrTwo x) instance GHC.Generics.Generic (Data.OneOrTwo.OneOrTwo x) instance GHC.Read.Read x => GHC.Read.Read (Data.OneOrTwo.OneOrTwo x) instance GHC.Show.Show x => GHC.Show.Show (Data.OneOrTwo.OneOrTwo x) instance GHC.Classes.Ord x => GHC.Classes.Ord (Data.OneOrTwo.OneOrTwo x) instance GHC.Classes.Eq x => GHC.Classes.Eq (Data.OneOrTwo.OneOrTwo x) -- | Intervals over types and their operations. module Data.Interval -- | The kinds of extremum an interval can have. data Extremum Minimum :: Extremum Infimum :: Extremum Supremum :: Extremum Maximum :: Extremum -- | The opposite of an Extremum is its complementary -- analogue: how the same point would be viewed from the complement of -- the interval to which it belongs. -- -- c.f. opposeBound. opposite :: Extremum -> Extremum -- | A Bound is an endpoint of an Interval. data Bound ext x [Min] :: !x -> Bound Minimum x [Inf] :: !x -> Bound Infimum x [Sup] :: !x -> Bound Supremum x [Max] :: !x -> Bound Maximum x -- | Extract the term from a Bound. unBound :: Bound ext x -> x -- | A type class for inverting Bounds. class (Opposite (Opposite ext) ~ ext) => Bounding ext where { type Opposite ext :: Extremum; } bound :: Bounding ext => x -> Bound ext x -- | c.f. opposite. opposeBound :: Bounding ext => Bound ext x -> Bound (Opposite ext) x -- | Bounds have special comparison rules for identical points. -- --
--   >>> compareBounds (Min (Levitate 5)) (Max (Levitate 5))
--   EQ
--   
--   >>> compareBounds (Inf (Levitate 5)) (Sup (Levitate 5))
--   GT
--   
--   >>> compareBounds (Max (Levitate 5)) (Sup (Levitate 5))
--   GT
--   
--   >>> compareBounds (Inf (Levitate 5)) (Min (Levitate 5))
--   GT
--   
--   >>> compareBounds (Max (Levitate 5)) (Inf (Levitate 5))
--   LT
--   
compareBounds :: Ord x => Bound ext1 x -> Bound ext2 x -> Ordering data SomeBound x SomeBound :: !Bound ext x -> SomeBound x unSomeBound :: Ord x => SomeBound x -> x oppose :: SomeBound x -> SomeBound x data Interval x [:<-->:] :: Ord x => !Bound Infimum (Levitated x) -> !Bound Supremum (Levitated x) -> Interval x [:<--|:] :: Ord x => !Bound Infimum (Levitated x) -> !Bound Maximum (Levitated x) -> Interval x [:|-->:] :: Ord x => !Bound Minimum (Levitated x) -> !Bound Supremum (Levitated x) -> Interval x [:|--|:] :: Ord x => !Bound Minimum (Levitated x) -> !Bound Maximum (Levitated x) -> Interval x infix 5 :<-->: infix 5 :<--|: infix 5 :|-->: infix 5 :|--|: -- | Since the Ord constraints on the constructors for -- Interval prevent it from being a Functor, this will have -- to suffice. imap :: (Ord x, Ord y) => (x -> y) -> Interval x -> Interval y -- | Same as imap but on the Levitated of the underlying -- type. imapLev :: (Ord x, Ord y) => (Levitated x -> Levitated y) -> Interval x -> Interval y -- | Since the Ord constraints on the constructors for -- Interval prevent it from being Traversable, this will -- have to suffice. itraverse :: (Ord x, Ord y, Applicative f) => (x -> f y) -> Interval x -> f (Interval y) -- | Same as itraverse but on the Levitated of the underlying -- type. itraverseLev :: (Ord x, Ord y, Applicative f) => (Levitated x -> f (Levitated y)) -> Interval x -> f (Interval y) -- | A bidirectional pattern synonym matching open intervals. pattern (:<->:) :: Ord x => Levitated x -> Levitated x -> Interval x infix 5 :<->: -- | A bidirectional pattern synonym matching open-closed intervals. pattern (:<-|:) :: Ord x => Levitated x -> Levitated x -> Interval x infix 5 :<-|: -- | A bidirectional pattern synonym matching closed-open intervals. pattern (:|->:) :: Ord x => Levitated x -> Levitated x -> Interval x infix 5 :|->: -- | A bidirectional pattern synonym matching closed intervals. pattern (:|-|:) :: Ord x => Levitated x -> Levitated x -> Interval x infix 5 :|-|: -- | A unidirectional pattern synonym ignoring the particular -- Bounds. pattern (:---:) :: forall x. Ord x => Levitated x -> Levitated x -> Interval x -- | A bidirectional pattern synonym matching finite open intervals. pattern (:<>:) :: forall x. Ord x => x -> x -> Interval x infix 5 :<>: -- | A bidirectional pattern synonym matching finite open-closed intervals. pattern (:<|:) :: forall x. Ord x => x -> x -> Interval x infix 5 :<|: -- | A bidirectional pattern synonym matching finite closed-open intervals. pattern (:|>:) :: forall x. Ord x => x -> x -> Interval x infix 5 :|>: -- | A bidirectional pattern synonym matching finite closed intervals. pattern (:||:) :: forall x. Ord x => x -> x -> Interval x infix 5 :||: -- | A unidirectional pattern synonym matching finite intervals, that -- ignores the particular Bounds. pattern (:--:) :: forall x. Ord x => x -> x -> Interval x -- | The whole interval. pattern Whole :: Ord x => Interval x -- | m +/- r creates the closed interval centred at -- m with radius r. -- -- For the open interval, simply write open (x +/- -- y). (+/-) :: (Ord x, Num x) => x -> x -> Interval x -- | Given limits and Extremums, try to make an interval. (...) :: Ord x => (Levitated x, Extremum) -> (Levitated x, Extremum) -> Interval x -- | Get the (lower, upper) bounds of an Interval. -- -- c.f. lower, upper. bounds :: Interval x -> (SomeBound (Levitated x), SomeBound (Levitated x)) -- | Get the lower bound of an interval. -- --
--   lower = fst . bounds
--   
lower :: Ord x => Interval x -> SomeBound (Levitated x) -- | Get the lower bound of an interval (with the bound expressed at the -- term level). lowerBound :: Ord x => Interval x -> (Levitated x, Extremum) -- | Get the upper bound of an interval. -- --
--   upper = snd . bounds
--   
upper :: Ord x => Interval x -> SomeBound (Levitated x) -- | Get the upper bound of an interval (with the bound expressed at the -- term level). upperBound :: Ord x => Interval x -> (Levitated x, Extremum) -- | Given SomeBounds, try to make an interval. interval :: Ord x => SomeBound (Levitated x) -> SomeBound (Levitated x) -> Interval x -- | Get the minimum of an interval, if it exists. imin :: Ord x => Interval x -> Maybe (Levitated x) -- | Get the infimum of an interval, weakening if necessary. iinf :: Ord x => Interval x -> Levitated x -- | Get the supremum of an interval, weakening if necessary. isup :: Ord x => Interval x -> Levitated x -- | Get the maximum of an interval if it exists. imax :: Ord x => Interval x -> Maybe (Levitated x) -- | Get the convex hull of two intervals. -- --
--   >>> hull (7 :|>: 8) (3 :|>: 4)
--   (3 :|>: 8)
--   
-- --
--   >>> hull (Bottom :<-|: Levitate 3) (4 :<>: 5)
--   (Bottom :<->: Levitate 5)
--   
hull :: Ord x => Interval x -> Interval x -> Interval x -- | Get the convex hull of a non-empty list of intervals. hulls :: Ord x => NonEmpty (Interval x) -> Interval x -- | Test whether a point is contained in the interval. within :: Ord x => x -> Interval x -> Bool -- | Create the closed-closed interval at a given point. point :: Ord x => x -> Interval x -- | Open both bounds of the given interval. open :: Ord x => Interval x -> Interval x -- | Close both bounds of the given interval. close :: Ord x => Interval x -> Interval x -- | Make the interval open-closed, leaving the endpoints unchanged. openclosed :: Ord x => Interval x -> Interval x -- | Make the interval closed-open, leaving the endpoints unchanged. closedopen :: Ord x => Interval x -> Interval x -- | Make the lower bound open, leaving the endpoints unchanged. openLower :: Ord x => Interval x -> Interval x -- | Make the lower bound closed, leaving the endpoints unchanged. closedLower :: Ord x => Interval x -> Interval x -- | Make the upper bound open, leaving the endpoints unchanged. openUpper :: Ord x => Interval x -> Interval x -- | Make the upper bound closed, leaving the endpoints unchanged. closedUpper :: Ord x => Interval x -> Interval x setLower :: Ord x => Levitated x -> Interval x -> Interval x setUpper :: Ord x => Levitated x -> Interval x -> Interval x -- | According to Allen, two intervals can be "adjacent" in 13 -- different ways, into at most 3 distinct intervals. In this package, -- this quality is called the Adjacency of the intervals. data Adjacency x Before :: !Interval x -> !Interval x -> Adjacency x Meets :: !Interval x -> !Interval x -> !Interval x -> Adjacency x Overlaps :: !Interval x -> !Interval x -> !Interval x -> Adjacency x Starts :: !Interval x -> !Interval x -> Adjacency x During :: !Interval x -> !Interval x -> !Interval x -> Adjacency x Finishes :: !Interval x -> !Interval x -> Adjacency x Identical :: !Interval x -> Adjacency x FinishedBy :: !Interval x -> !Interval x -> Adjacency x Contains :: !Interval x -> !Interval x -> !Interval x -> Adjacency x StartedBy :: !Interval x -> !Interval x -> Adjacency x OverlappedBy :: !Interval x -> !Interval x -> !Interval x -> Adjacency x MetBy :: !Interval x -> !Interval x -> !Interval x -> Adjacency x After :: !Interval x -> !Interval x -> Adjacency x -- | The result of having compared the same two intervals in reverse order. converseAdjacency :: Adjacency x -> Adjacency x -- | Calculate the Adjacency between two intervals, according to -- Allen. adjacency :: Ord x => Interval x -> Interval x -> Adjacency x -- | Calculate the intersection of two intervals, if it exists. -- --
--   >>> intersect (2 :<>: 4) (3 :||: 5)
--   Just (3 :|>: 4)
--   
--   >>> intersect (2 :<>: 4) (4 :||: 5)
--   Nothing
--   
--   >>> intersect (1 :<>: 4) (2 :||: 3)
--   Just (2 :||: 3)
--   
intersect :: forall x. Ord x => Interval x -> Interval x -> Maybe (Interval x) -- | Get the union of two intervals, as either OneOrTwo. -- --
--   >>> union (2 :||: 5) (5 :<>: 7)
--   One (Levitate 2 :|->: Levitate 7)
--   
--   >>> union (2 :||: 4) (5 :<>: 7)
--   Two (Levitate 2 :|-|: Levitate 4) (Levitate 5 :-: Levitate 7)
--   
union :: forall x. Ord x => Interval x -> Interval x -> OneOrTwo (Interval x) -- | O(n log n). Get the union of a list of intervals. -- -- This function uses sort. See also unionsAsc. unions :: forall x. Ord x => [Interval x] -> [Interval x] -- | O(n). Get the union of a sorted list of intervals. -- -- NOTE: The input condition is not checked. Use with care. unionsAsc :: forall x. Ord x => [Interval x] -> [Interval x] -- | Take the complement of the interval, as possibly OneOrTwo. -- --
--   >>> complement (3 :<>: 4)
--   Just (Two (Bottom :|-|: Levitate 3) (Levitate 4 :|-|: Top))
--   
-- -- Note that infinitely-open intervals will return the points at infinity -- toward which they are infinite in their result: -- --
--   >>> complement (Levitate 3 :-: Top)
--   Just (Two (Bottom :|-|: Levitate 3) (Top :|-|: Top))
--   
complement :: forall x. Ord x => Interval x -> Maybe (OneOrTwo (Interval x)) -- | Remove all points of the second interval from the first. -- --
--   >>> difference Whole (3 :<>: 4)
--   Just (Two (Bottom :|-|: Levitate 3) (Levitate 4 :|-|: Top))
--   
--   >>> difference (1 :<>: 4) (2 :||: 3)
--   Just (Two (1 :<>: 2) (3 :<>: 4))
--   
--   >>> difference (1 :|>: 4) (0 :||: 1)
--   Just (One (1 :<>: 4))
--   
--   >>> difference (1 :<>: 4) (0 :||: 1)
--   Just (One (1 :<>: 4))
--   
difference :: forall x. Ord x => Interval x -> Interval x -> Maybe (OneOrTwo (Interval x)) -- | Infix synonym for difference (\\) :: forall x. Ord x => Interval x -> Interval x -> Maybe (OneOrTwo (Interval x)) -- | The difference of the union and intersection of two intervals. -- --
--   >>> symmetricDifference Whole (3 :<>: 4)
--   Just (Two (Bottom :|-|: Levitate 3) (Levitate 4 :|-|: Top))
--   
--   >>> symmetricDifference (1 :<>: 4) (2 :||: 3)
--   Just (Two (1 :<>: 2) (3 :<>: 4))
--   
symmetricDifference :: forall x. Ord x => Interval x -> Interval x -> Maybe (OneOrTwo (Interval x)) -- | Get the measure of an interval. -- --
--   >>> measure (-1 :<>: 1)
--   Just 2
--   
--   >>> measure (Bottom :-: Levitate 1)
--   Nothing
--   
measure :: forall x. (Ord x, Num x) => Interval x -> Maybe x -- | Apply a function to the lower, then upper, endpoint of an interval. -- --
--   >>> measuring max (-1 :<>: 1)
--   Just 1
--   
--   >>> measuring min (-1 :<>: 1)
--   Just (-1)
--   
--   >>> measuring (*) (4 :<>: 6)
--   Just 24
--   
measuring :: forall y x. (Ord x, Num y) => (x -> x -> y) -> Interval x -> Maybe y -- | Get the distance between two intervals, or 0 if they adjacency. -- --
--   >>> hausdorff (3 :<>: 5) (6 :<>: 7)
--   Just 1
--   
--   >>> hausdorff (3 :<>: 5) Whole
--   Just 0
--   
hausdorff :: (Ord x, Num x) => Interval x -> Interval x -> Maybe x -- | Full containment. isSubsetOf :: Ord x => Interval x -> Interval x -> Bool -- | Either one of something, or two of it. -- -- Use oneOrTwo to deconstruct. data OneOrTwo x One :: !x -> OneOrTwo x Two :: !x -> !x -> OneOrTwo x instance Data.Data.Data Data.Interval.Extremum instance GHC.Generics.Generic Data.Interval.Extremum instance GHC.Read.Read Data.Interval.Extremum instance GHC.Show.Show Data.Interval.Extremum instance GHC.Enum.Bounded Data.Interval.Extremum instance GHC.Enum.Enum Data.Interval.Extremum instance GHC.Classes.Ord Data.Interval.Extremum instance GHC.Classes.Eq Data.Interval.Extremum instance (Data.Data.Data x, GHC.Classes.Ord x) => Data.Data.Data (Data.Interval.Adjacency x) instance GHC.Generics.Generic (Data.Interval.Adjacency x) instance (GHC.Classes.Ord x, GHC.Show.Show x) => GHC.Show.Show (Data.Interval.Adjacency x) instance GHC.Classes.Ord x => GHC.Classes.Ord (Data.Interval.Adjacency x) instance GHC.Classes.Ord x => GHC.Classes.Eq (Data.Interval.Adjacency x) instance GHC.Classes.Ord x => GHC.Classes.Eq (Data.Interval.Interval x) instance (GHC.Classes.Ord x, GHC.Show.Show x) => GHC.Show.Show (Data.Interval.Interval x) instance GHC.Classes.Ord x => GHC.Classes.Ord (Data.Interval.Interval x) instance (GHC.Classes.Ord x, Data.Data.Data x) => Data.Data.Data (Data.Interval.Interval x) instance (GHC.Classes.Ord x, GHC.Generics.Generic x) => GHC.Generics.Generic (Data.Interval.Interval x) instance GHC.Classes.Eq x => GHC.Classes.Eq (Data.Interval.SomeBound (Algebra.Lattice.Levitated.Levitated x)) instance GHC.Classes.Ord x => GHC.Classes.Ord (Data.Interval.SomeBound (Algebra.Lattice.Levitated.Levitated x)) instance Data.Interval.Bounding 'Data.Interval.Minimum instance Data.Interval.Bounding 'Data.Interval.Infimum instance Data.Interval.Bounding 'Data.Interval.Supremum instance Data.Interval.Bounding 'Data.Interval.Maximum instance GHC.Base.Functor (Data.Interval.Bound ext) instance Data.Foldable.Foldable (Data.Interval.Bound ext) instance Data.Traversable.Traversable (Data.Interval.Bound ext) instance GHC.Classes.Eq x => GHC.Classes.Eq (Data.Interval.Bound ext x) instance GHC.Classes.Ord x => GHC.Classes.Ord (Data.Interval.Bound ext (Algebra.Lattice.Levitated.Levitated x)) module Data.Interval.Borel -- | The Borel sets on a type are the sets generated by its -- intervals. It forms a Heyting algebra with union as join -- and intersection as meet, and a Ring with -- symmetricDifference as addition and intersection as -- multiplication (and complement as negation). In fact the -- algebra is Boolean as the operation x ==> y = -- complement x \/ y. -- -- It is a monoid that is convenient for agglomerating groups of -- intervals, such as for calculating the overall timespan of a group of -- events. However, it is agnostic of how many times each given point has -- been covered. To keep track of this data, use Layers. data Borel x -- | Consider the Borel set identified by a list of -- Intervals. borel :: Ord x => [Interval x] -> Borel x -- | Turn a Borel set into a Set of Intervals. intervalSet :: Ord x => Borel x -> Set (Interval x) -- | The empty Borel set. empty :: Ord x => Borel x -- | The Borel set consisting of a single Interval. singleton :: Ord x => Interval x -> Borel x -- | Is this Borel set empty? null :: Borel x -> Bool -- | Insert an Interval into a Borel set, agglomerating along -- the way. insert :: Ord x => Interval x -> Borel x -> Borel x -- | The maximal Borel set, that covers the entire range. whole :: Ord x => Borel x -- | Completely remove an Interval from a Borel set. -- Essentially the opposite of truncate. remove :: Ord x => Interval x -> Borel x -> Borel x -- | Flipped infix version of remove. (\-) :: Ord x => Borel x -> Interval x -> Borel x -- | Given an Interval i, truncate i will -- trim a Borel set so that its hull is contained in -- i. truncate :: Ord x => Interval x -> Borel x -> Borel x -- | Flipped infix version of truncate. (\=) :: Ord x => Borel x -> Interval x -> Borel x -- | Is this point within any connected component of the -- Borel set? member :: Ord x => x -> Borel x -> Bool -- | Is this point not within any connected component of the -- Borel set? notMember :: Ord x => x -> Borel x -> Bool -- | A synonym for (<>). union :: Ord x => Borel x -> Borel x -> Borel x -- | A synonym for fold. unions :: Ord x => [Borel x] -> Borel x -- | Remove all intervals of the second set from the first. difference :: Ord x => Borel x -> Borel x -> Borel x -- | Take the symmetric difference of two Borel sets. symmetricDifference :: Ord x => Borel x -> Borel x -> Borel x -- | Take the Borel set consisting of each point not in the given -- one. complement :: Ord x => Borel x -> Borel x -- | Take the intersection of two Borel sets. intersection :: Ord x => Borel x -> Borel x -> Borel x -- | Take the intersection of a list of Borel sets. intersections :: Ord x => [Borel x] -> Borel x -- | Take the smallest spanning Interval of a Borel set, -- provided that it is not the empty set. hull :: Ord x => Borel x -> Maybe (Interval x) isSubsetOf :: Ord x => Borel x -> Borel x -> Bool instance (Data.Data.Data x, GHC.Classes.Ord x) => Data.Data.Data (Data.Interval.Borel.Borel x) instance GHC.Generics.Generic (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, GHC.Show.Show x) => GHC.Show.Show (Data.Interval.Borel.Borel x) instance GHC.Classes.Ord x => GHC.Classes.Ord (Data.Interval.Borel.Borel x) instance GHC.Classes.Ord x => GHC.Classes.Eq (Data.Interval.Borel.Borel x) instance GHC.Classes.Ord x => GHC.Base.Semigroup (Data.Interval.Borel.Borel x) instance GHC.Classes.Ord x => GHC.Base.Monoid (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, Algebra.Lattice.Lattice x) => Algebra.Lattice.Lattice (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, Algebra.Lattice.Lattice x) => Algebra.Lattice.BoundedMeetSemiLattice (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, Algebra.Lattice.Lattice x) => Algebra.Lattice.BoundedJoinSemiLattice (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, Algebra.Lattice.Lattice x) => Algebra.Heyting.Heyting (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, Algebra.Lattice.Lattice x) => Data.Semiring.Semiring (Data.Interval.Borel.Borel x) instance (GHC.Classes.Ord x, Algebra.Lattice.Lattice x) => Data.Semiring.Ring (Data.Interval.Borel.Borel x) module Data.Interval.Layers data Layers x y -- | Draw the Layers of specified bases and thicknesses. fromList :: (Ord x, Ord y, Semigroup y) => [(Interval x, y)] -> Layers x y -- | Get all of the bases and thicknesses in the Layers. toList :: Ord x => Layers x y -> [(Interval x, y)] -- | A blank canvas. empty :: Layers x y -- | singleton ix y is the rectangle with base ix of -- thickness y. singleton :: Ord x => Interval x -> y -> Layers x y -- | insert ix y l draws over l a rectangle with base -- ix of thickness y. insert :: (Ord x, Ord y, Semigroup y) => Interval x -> y -> Layers x y -> Layers x y -- | Flipped synonym for insert. Mnemonic: "pile" this much onto the -- existing Layers over the given Interval. pile :: (Ord x, Ord y, Semigroup y) => y -> Interval x -> Layers x y -> Layers x y -- | Ignore the Layers and focus only on whether points are -- within any contained Interval or not. squash :: Ord x => Layers x y -> Borel x -- | Get the thickness of the Layers at a point. thickness :: (Ord x, Monoid y) => x -> Layers x y -> y -- | Where and how thick is the thickest Interval? thickest :: (Ord x, Ord y) => Layers x y -> Maybe (Interval x, y) -- | Take away a thickness over a given base from the Layers. dig :: (Ord x, Ord y, Group y) => y -> Interval x -> Layers x y -> Layers x y -- | Completely remove an Interval from the Layers. remove :: (Ord x, Ord y, Semigroup y) => Interval x -> Layers x y -> Layers x y -- | Fliped infix version of remove. (\-) :: (Ord x, Ord y, Semigroup y) => Layers x y -> Interval x -> Layers x y -- | Add the given thickness to every point. baseline :: (Ord x, Ord y, Semigroup y) => y -> Layers x y -> Layers x y -- | Excavate the second argument from the first. difference :: (Ord x, Ord y, Group y) => Layers x y -> Layers x y -> Layers x y -- | Restrict the range of the Layers to the given Interval. truncate :: (Ord x, Ord y, Semigroup y) => Interval x -> Layers x y -> Layers x y -- | Flipped infix version of truncate. (\=) :: (Ord x, Ord y, Semigroup y) => Layers x y -> Interval x -> Layers x y -- | Convert the Layers into a list of beginning-points and heights, -- that define a step function piecewise. toStepFunction :: (Ord x, Ord y, Monoid y) => Layers x y -> [(Levitated x, y)] -- | integrate diff hgt ix l calculates the area under the -- Interval ix using the measure diff of the -- interval multiplied by the height hgt of the layers over each -- sub-interval in the layers. integrate :: (Ord x, Ord y, Semigroup y, Num z) => (x -> x -> z) -> (y -> z) -> Interval x -> Layers x y -> Maybe z nestings :: (Ord x, Ord y, Semigroup y) => [(Interval x, y)] -> [(Interval x, y)] instance (Data.Data.Data x, Data.Data.Data y, GHC.Classes.Ord x) => Data.Data.Data (Data.Interval.Layers.Layers x y) instance GHC.Generics.Generic (Data.Interval.Layers.Layers x y) instance GHC.Base.Functor (Data.Interval.Layers.Layers x) instance (GHC.Classes.Ord x, GHC.Show.Show x, GHC.Show.Show y) => GHC.Show.Show (Data.Interval.Layers.Layers x y) instance (GHC.Classes.Ord x, GHC.Classes.Ord y) => GHC.Classes.Ord (Data.Interval.Layers.Layers x y) instance (GHC.Classes.Ord x, GHC.Classes.Eq y) => GHC.Classes.Eq (Data.Interval.Layers.Layers x y) instance (GHC.Classes.Ord x, GHC.Classes.Ord y, GHC.Base.Semigroup y) => GHC.Base.Semigroup (Data.Interval.Layers.Layers x y) instance (GHC.Classes.Ord x, GHC.Classes.Ord y, GHC.Base.Semigroup y) => GHC.Base.Monoid (Data.Interval.Layers.Layers x y) instance (GHC.Classes.Ord x, GHC.Classes.Ord y, Data.Group.Group y) => Data.Group.Group (Data.Interval.Layers.Layers x y) module Data.Timeframe -- |
--   type Timeframe = Interval UTCTime
--   
type Timeframe = Interval UTCTime localTimeframeAt :: TimeZone -> LocalTime -> LocalTime -> Timeframe localTimeframe :: MonadIO io => LocalTime -> LocalTime -> io Timeframe pureLocalTimeframe :: LocalTime -> LocalTime -> Timeframe duration :: Timeframe -> Maybe NominalDiffTime module Data.Calendar -- | An Event is a collection of Timeframes that keeps track -- of how deeply a particular interval has been overlapped. -- --
--   type Event n = Layers UTCTime (Sum n)
--   
type Event n = Layers UTCTime (Sum n) -- | Make a new Event from a Timeframe with default thickness -- 1. -- --
--   event = eventSize 1
--   
event :: Num n => Timeframe -> Event n -- | Make an Event with the given size from a Timeframe. eventSize :: Num n => n -> Timeframe -> Event n -- | Measure the carried load of an Event over a given -- Timeframe. In other words: how many copies of you would you -- need, in order to attend all of the simultaneous happenings over a -- given span (on average)? erlangs :: Real n => Timeframe -> Event n -> Maybe Rational -- | A Calendar is a map from a given event type to durations. newtype Calendar ev n Calendar :: Map ev (Event n) -> Calendar ev n [getCalendar] :: Calendar ev n -> Map ev (Event n) -- | Make a Calendar from an Event. singleton :: (Ord ev, Ord n, Num n) => ev -> Event n -> Calendar ev n -- | Make a Calendar from a Timeframe. calendar :: (Ord ev, Ord n, Num n) => ev -> Timeframe -> Calendar ev n -- | Insert an Event of the given sort into a Calendar. insert :: (Ord ev, Ord n, Num n) => ev -> Event n -> Calendar ev n -> Calendar ev n -- | Get the Event corresponding to a given key, or Nothing -- if the key is not present. (!?) :: (Ord ev, Ord n, Num n) => Calendar ev n -> ev -> Maybe (Event n) -- | Get the Event corresponding to a given key, or mempty if -- the key is not present. (!) :: (Ord ev, Ord n, Num n) => Calendar ev n -> ev -> Event n toList :: (Ord ev, Ord n, Num n) => Calendar ev n -> [(ev, [(Interval UTCTime, n)])] -- | What, and how many events are happening at the given UTCTime on -- this Calendar? happeningAt :: (Ord ev, Ord n, Num n) => UTCTime -> Calendar ev n -> [(ev, n)] -- | Consider every kind of event the same, and observe the overall -- Layers. coalesce :: (Ord ev, Ord n, Num n) => Calendar ev n -> Event n totalDuration :: forall ev n. (Ord ev, Real n) => ev -> Calendar ev n -> Maybe NominalDiffTime instance (GHC.Show.Show ev, GHC.Show.Show n) => GHC.Show.Show (Data.Calendar.Calendar ev n) instance (GHC.Classes.Ord ev, GHC.Classes.Ord n) => GHC.Classes.Ord (Data.Calendar.Calendar ev n) instance (GHC.Classes.Eq ev, GHC.Classes.Eq n) => GHC.Classes.Eq (Data.Calendar.Calendar ev n) instance (GHC.Classes.Ord ev, GHC.Classes.Ord n, GHC.Num.Num n) => GHC.Base.Semigroup (Data.Calendar.Calendar ev n) instance (GHC.Classes.Ord ev, GHC.Classes.Ord n, GHC.Num.Num n) => GHC.Base.Monoid (Data.Calendar.Calendar ev n)