event-data-theory-0.30.3: event data theory

EventDataTheory.Utilities

Description

Synopsis

# Documentation

newtype Predicate a #

Constructors

 Predicate FieldsgetPredicate :: a -> Bool

#### Instances

Instances details
 A Predicate is a Contravariant Functor, because contramap can apply its function argument to the input of the predicate.Without newtypes contramap f equals precomposing with f (= (. f)).contramap :: (a' -> a) -> (Predicate a -> Predicate a') contramap f (Predicate g) = Predicate (g . f)  Instance detailsDefined in Data.Functor.Contravariant Methodscontramap :: (a' -> a) -> Predicate a -> Predicate a' #(>\$) :: b -> Predicate b -> Predicate a # mempty on predicates always returns True. Without newtypes this equals pure True.mempty :: Predicate a mempty = _ -> True  Instance detailsDefined in Data.Functor.Contravariant Methodsmappend :: Predicate a -> Predicate a -> Predicate a #mconcat :: [Predicate a] -> Predicate a # (<>) on predicates uses logical conjunction (&&) on the results. Without newtypes this equals liftA2 (&&).(<>) :: Predicate a -> Predicate a -> Predicate a Predicate pred <> Predicate pred' = Predicate a -> pred a && pred' a  Instance detailsDefined in Data.Functor.Contravariant Methods(<>) :: Predicate a -> Predicate a -> Predicate a #sconcat :: NonEmpty (Predicate a) -> Predicate a #stimes :: Integral b => b -> Predicate a -> Predicate a # ToDhall x => FromDhall (Predicate x) Instance detailsDefined in Dhall.Marshal.Decode MethodsautoWith :: InputNormalizer -> Decoder (Predicate x)

containsTag :: Ord t => [t] -> Predicate (Event t m a) Source #

Creates a predicate to check that an Event contains any of a given list of tags.

Arguments

 :: Filterable f => (f (Event t m a) -> Maybe (Event t m a)) function used to select a single event after the container is filtered -> Predicate (Event t m a) predicate by which to filter -> f (Event t m a) a container of events -> Maybe (Event t m a)

Filter a container of Events to a single Maybe Event, based on a provided function, with the provided tag set.

For example, see firstOccurrenceOfTag and lastOccurrenceOfTag.

firstOccurrenceOfTag :: (Witherable f, Ord t) => [t] -> f (Event t m a) -> Maybe (Event t m a) Source #

Finds the *first* occurrence of an Event with at least one of the tags if one exists. Assumes the input events are appropriately sorted.

lastOccurrenceOfTag :: (Witherable f, Ord t) => [t] -> f (Event t m a) -> Maybe (Event t m a) Source #

Finds the *last* occurrence of an Event with at least one of the tags if one exists. Assumes the input events list are appropriately sorted.

splitByTags :: (Filterable f, Ord t) => [t] -> [t] -> f (Event t m a) -> (f (Event t m a), f (Event t m a)) Source #

Split a container of Events into a pair of Events. The first element contains events have any of the tags in the first argument, similarly for the second element.

Note that one or both of the resulting containers may be empty.

filterEvents :: Filterable f => Predicate (Event t m a) -> f (Event t m a) -> f (Event t m a) Source #

Filter a container of events by a predicate.

tallyEvents :: Witherable f => Predicate (Event t m a) -> f (Event t m a) -> Int Source #

Tally the number of events in a container satisfying the given predicate.