event-data-theory-0.30.3: event data theory
Copyright(c) Target RWE 2023
LicenseBSD3
Maintainerbbrown@targetrwe.com ljackman@targetrwe.com dpritchard@targetrwe.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

EventDataTheory.Utilities

Description

 
Synopsis

Documentation

newtype Predicate a #

Constructors

Predicate 

Fields

Instances

Instances details
Contravariant Predicate

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 details

Defined in Data.Functor.Contravariant

Methods

contramap :: (a' -> a) -> Predicate a -> Predicate a' #

(>$) :: b -> Predicate b -> Predicate a #

Monoid (Predicate a)

mempty on predicates always returns True. Without newtypes this equals pure True.

mempty :: Predicate a
mempty = _ -> True
Instance details

Defined in Data.Functor.Contravariant

Semigroup (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 details

Defined 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 details

Defined in Dhall.Marshal.Decode

Methods

autoWith :: 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.

findOccurrenceOfEvent Source #

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.