intervalidus

package intervalidus

Intervalidus is a Scala library with zero dependencies for representing data as valid only in discrete or continuous intervals of arbitrary dimensions (tests cover up to four-dimensional data). It answers the question "In what intervals are your data valid?"

This top-level package includes Intervalidus's main traits, classes, and other members:

  • Type classes for common discrete and continuous domain values.
  • Foundational case classes, type classes, and enums for multidimensional domains, intervals, diff actions, and valid data.
  • Base traits for dimensional data, including versioned and multivalued data.

Attributes

Members list

Packages

Intervalidus's main traits and classes for defining immutable dimensional data, including versioned and multivalued data:

Intervalidus's main traits and classes for defining immutable dimensional data, including versioned and multivalued data:

  • Base trait for all immutable dimensional data.
  • Classes defining immutable data in multidimensional intervals.

Attributes

Intervalidus's main traits and classes for defining mutable dimensional data, including versioned and multivalued data:

Intervalidus's main traits and classes for defining mutable dimensional data, including versioned and multivalued data:

  • Base trait for all mutable dimensional data.
  • Classes defining mutable data in multidimensional intervals.

Attributes

Type members

Classlikes

trait ContinuousValue[T] extends DomainValueLike[T]

Type class for a continuous value.

Type class for a continuous value.

Unlike discrete values, there is no requirement for having predecessors and successors defined. Although every digitized data structure is discrete, it is often easier to work with some data types when they are treated as continuous. For example, integer values and local dates are good candidates for being discrete where double-precision float values and local date-times are better treated as continuous.

Type parameters

T

a value that has continuous value behavior (e.g., Double)

Attributes

Companion
object
Supertypes
trait DomainValueLike[T]
trait Ordering[T]
trait PartialOrdering[T]
trait Equiv[T]
trait Serializable
trait Comparator[T]
class Object
trait Matchable
class Any
Show all
Known subtypes

Default continuous value type classes for common data types.

Default continuous value type classes for common data types.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
enum DiffAction[+V, +D <: NonEmptyTuple](using x$1: DomainLike[D])

Create/update/delete actions (like CQRS mutation commands). Used when extrapolating or applying event source-style information.

Create/update/delete actions (like CQRS mutation commands). Used when extrapolating or applying event source-style information.

Type parameters

D

for Create and Update, the type of domain used in the interval assigned to each valid value, and for Delete, the type of domain used as the key.

V

the type of the value managed as data (not used in Delete).

Attributes

Note

intervalidus does not have event-sourced data structures, and the history of mutations is not maintained.

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Create[VV, DD]
class Update[VV, DD]
class Delete[DD]
object DiffAction

Attributes

Companion
enum
Supertypes
class Object
trait Matchable
class Any
Self type
DiffAction.type

Common definitions used in all dimensional data.

Common definitions used in all dimensional data.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait DimensionalBase[V, D <: NonEmptyTuple](using domainLike: DomainLike[D])(using x$2: Experimental) extends PartialFunction[D, V]

Base for all dimensional data, both mutable and immutable, of arbitrary dimensions.

Base for all dimensional data, both mutable and immutable, of arbitrary dimensions.

Type parameters

D

the domain type -- DomainLike non-empty tuples.

V

the value type for valid data.

Attributes

Companion
object
Supertypes
trait PartialFunction[D, V]
trait D => V
class Object
trait Matchable
class Any
Known subtypes
trait ImmutableBase[V, D, Self]
class Data[V, D]
class DataMulti[V, D]
trait MutableBase[V, D]
class Data[V, D]
class DataMulti[V, D]
trait DimensionalMultiBase[V, D]
Show all

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Data
object Data
object DataMulti
object DataMulti

Constructs data in multidimensional intervals.

Constructs data in multidimensional intervals.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Data
object Data
class DimensionalDataBuilder[V, D <: NonEmptyTuple, Self <: DimensionalBase[V, D]](build: (List[ValidData[V, D]]) => Self)(implicit evidence$1: DomainLike[D], x$2: Experimental) extends ReusableBuilder[ValidData[V, D], Self]

Attributes

Supertypes
trait ReusableBuilder[ValidData[V, D], Self]
trait Builder[ValidData[V, D], Self]
trait Growable[ValidData[V, D]]
trait Clearable
class Object
trait Matchable
class Any
Show all
class DimensionalDataMultiBuilder[V, D <: NonEmptyTuple, Self <: DimensionalMultiBase[V, D]](build: (List[ValidData[V, D]]) => Self)(implicit evidence$1: DomainLike[D], x$2: Experimental) extends ReusableBuilder[ValidData[V, D], Self]

Attributes

Supertypes
trait ReusableBuilder[ValidData[V, D], Self]
trait Builder[ValidData[V, D], Self]
trait Growable[ValidData[V, D]]
trait Clearable
class Object
trait Matchable
class Any
Show all
class DimensionalDataVersionedBuilder[V, D <: NonEmptyTuple, Self <: DimensionalVersionedBase[V, D]](build: (List[ValidData[V, D]]) => Self)(implicit evidence$1: DomainLike[D]) extends ReusableBuilder[ValidData[V, D], Self]

Attributes

Supertypes
trait ReusableBuilder[ValidData[V, D], Self]
trait Builder[ValidData[V, D], Self]
trait Growable[ValidData[V, D]]
trait Clearable
class Object
trait Matchable
class Any
Show all

Common definitions used in all dimensional multivalued data.

Common definitions used in all dimensional multivalued data.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait DimensionalMultiBase[V, D <: NonEmptyTuple](implicit evidence$1: DomainLike[D], x$1: Experimental) extends DimensionalBase[Set[V], D]

Data that may have multiple values (managed as sets of values) in different intervals.

Data that may have multiple values (managed as sets of values) in different intervals.

Type parameters

D

the domain type -- DomainLike non-empty tuples.

V

the value type for valid data.

Attributes

Companion
object
Supertypes
trait DimensionalBase[Set[V], D]
trait PartialFunction[D, Set[V]]
trait D => Set[V]
class Object
trait Matchable
class Any
Show all
Known subtypes
class DataMulti[V, D]
class DataMulti[V, D]

Constructs multivalued data in multidimensional intervals.

Constructs multivalued data in multidimensional intervals.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object DataMulti
object DataMulti

Common definitions used in all versioned dimensional data (with a hidden version dimension).

Common definitions used in all versioned dimensional data (with a hidden version dimension).

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait DimensionalVersionedBase[V, D <: NonEmptyTuple](initialData: Iterable[ValidData[V, Versioned[D]]], initialVersion: VersionDomainValue, withCurrentVersion: Option[VersionDomain])(implicit evidence$1: DomainLike[D], x$4: Experimental, x$5: DomainLike[Versioned[D]]) extends PartialFunction[Versioned[D], V]

Base for all versioned dimensional data, both mutable and immutable, in any dimension.

Base for all versioned dimensional data, both mutable and immutable, in any dimension.

Interface is similar to DimensionalBase, but it operates on an underlying mutable.Data using an extra integer-valued head dimension to version data. One use case would be versioned data that are valid in two dimensions of time, so the underlying data actually vary in terms of version and two dimensions of time (three dimensions). Most methods require some generic version selection criteria rather than specific integer intervals, therefore this does not extend DimensionalBase.

The "current" version is managed as state (a var). Versioning also separates notions of approved vs. unapproved data (unapproved data are pushed up to start at version maxValue).

When getting data, by default, we return "current" version data (a.k.a., approved). When updating data, by default, we don't rewrite history, so mutations start with the "current" version too.

Type parameters

D

the domain type for intervals in the public interface -- DomainLike non-empty tuples.

V

the value type for valid data.

Attributes

Note

Updates starting with "current" also update unapproved changes (since intervalFrom goes to the Top).

Companion
object
Supertypes
trait PartialFunction[Versioned[D], V]
trait (Versioned[D]) => V
class Object
trait Matchable
class Any
Known subtypes
class DataVersioned[V, D]
class DataVersioned[V, D]

Constructs data in multidimensional intervals that are also versioned (hidden extra dimension).

Constructs data in multidimensional intervals that are also versioned (hidden extra dimension).

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait DiscreteValue[T] extends DomainValueLike[T]

Type class for a discrete value.

Type class for a discrete value.

Unlike continuous values, discrete values also have predecessors and successors, which are properly defined on x: maxValue < x < minValue. Having predecessors and successors defined this way avoids issues where the natural successor functions of the underlying types behave unexpectedly/inconsistently on the boundaries, e.g., how Int.MaxValue + 1 and Int.MinValue - 1 silently wrap around to each other, vs. how both LocalDate.MAX.plusDays(1) and LocalDate.MIN.minusDays(1) throw a DateTimeException.

Type parameters

T

a value that has discrete value behavior (e.g., Int)

Attributes

Companion
object
Supertypes
trait DomainValueLike[T]
trait Ordering[T]
trait PartialOrdering[T]
trait Equiv[T]
trait Serializable
trait Comparator[T]
class Object
trait Matchable
class Any
Show all
Known subtypes
object DiscreteValue

Default discrete value type classes for common data types.

Default discrete value type classes for common data types.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
object Domain

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Domain.type
enum Domain1D[+T]

A domain is based on an underlying domain value type, and is used to define the boundaries of interval. It describes specific data points in the domain value range as well as the special "Bottom" and "Top" cases which conceptually lie below and above this finite range of data points (logically below and above minValue and maxValue respectively). Domains can be based on domain values that are discrete or continuous. When continuous, a boundary point can either be open or closed, where discrete points must always be closed. This also gives a way to completely describe adjacency.

A domain is based on an underlying domain value type, and is used to define the boundaries of interval. It describes specific data points in the domain value range as well as the special "Bottom" and "Top" cases which conceptually lie below and above this finite range of data points (logically below and above minValue and maxValue respectively). Domains can be based on domain values that are discrete or continuous. When continuous, a boundary point can either be open or closed, where discrete points must always be closed. This also gives a way to completely describe adjacency.

When domain values are discrete, the left and right adjacent domains of a point are the respective predecessors and successors of the domain value. This also gives us a way to accommodate having a predecessor or successor on a boundary, i.e., maxValue.rightAdjacent == Top and minValue.leftAdjacent == Bottom.

When domain values are continuous, the left and right adjacent domains are always the same: open if the point is closed and closed if the point is open.

In both discrete and continuous domains, Top and Bottom are considered self-adjacent.

Type parameters

T

expected to be a domain value (i.e., DomainValueLike[T] should be given).

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Point[P]
class OpenPoint[P]
object Domain1D

Companion for the one-dimensional domain used in defining and operating on intervals.

Companion for the one-dimensional domain used in defining and operating on intervals.

Attributes

Companion
enum
Supertypes
class Object
trait Matchable
class Any
Self type
Domain1D.type
trait DomainLike[D <: NonEmptyTuple]

Type class with operations on a domain with multiple discrete and/or continuous dimensions.

Type class with operations on a domain with multiple discrete and/or continuous dimensions.

An n-dimensional domain is represented by a tuple of Domain1D[Ti] values (where i varies from 1 to n), and each Ti is a (potentially different) domain value type that is DomainValueLike.

An n-dimensional domain is used in defining the boundaries of an n-dimensional interval. Generally, you will not need to use these methods directly -- they are here primarily to support methods on Interval and ValidData.

Type parameters

D

Domain type, a tuple of one-dimensional domains (where each can have a different domain value type).

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object DomainLike

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
DomainLike.type
trait DomainLikeTupleOps[D <: NonEmptyTuple]

Type class for operating on domains and related structures of arbitrary dimension.

Type class for operating on domains and related structures of arbitrary dimension.

An n-dimensional domain is represented by a tuple of Domain1D[Ti] values (where i varies from 1 to n), and each Ti is a (potentially different) domain value type that is DomainValueLike.

This makes extensive use of Scala 3's generic programming techniques on tuples (for more information, see https://www.scala-lang.org/2021/02/26/tuples-bring-generic-programming-to-scala-3.html). These operations are meant to support DomainLike type classes and should not need to be called directly.

Type parameters

D

Tuple of domain one-dimensional domains of various domain value types

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Use recursive decomposition of tuples to provide domain-like capabilities to tuples.

Use recursive decomposition of tuples to provide domain-like capabilities to tuples.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait DomainValueLike[T] extends Ordering[T]

A domain value is at least

A domain value is at least

  1. finite, with a max and min value (think Double with its MaxValue and MinValue methods)
  2. totally ordered (this type class extends the Ordering type class, requiring a compare method).
  3. mappable to a similarly ordered double value (potentially with collisions)

Type parameters

T

a value that has continuous or discrete value behavior (e.g., Double)

Attributes

Supertypes
trait Ordering[T]
trait PartialOrdering[T]
trait Equiv[T]
trait Serializable
trait Comparator[T]
class Object
trait Matchable
class Any
Show all
Known subtypes
object EnumMacro

Gets the values field from an enum (i.e., from the companion of the sealed trait) to retrieve all enums values.

Gets the values field from an enum (i.e., from the companion of the sealed trait) to retrieve all enums values.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
EnumMacro.type
object Experimental

Constructs experimental feature configurations.

Constructs experimental feature configurations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Interval[D <: NonEmptyTuple](start: D, end: D)(using domainLike: DomainLike[D])

An interval in multiple dimensions over a contiguous set of domain values in D. See https://en.wikipedia.org/wiki/Interval_(mathematics) for more information.

An interval in multiple dimensions over a contiguous set of domain values in D. See https://en.wikipedia.org/wiki/Interval_(mathematics) for more information.

Type parameters

D

the domain type -- DomainLike non-empty tuples.

Value parameters

end

the "supremum", i.e., the right (and/or above and/or front, depending on dimensions and context) boundary of the interval -- must be greater than or equal to the start in all dimensions

start

the "infimum", i.e., the left (and/or below and/or back, depending on dimensions and context) boundary of the interval

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Interval

Companion for the multidimensional interval used in defining and operating on valid data.

Companion for the multidimensional interval used in defining and operating on valid data.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Interval.type
case class Interval1D[T](start: Domain1D[T], end: Domain1D[T])(using domainValue: DomainValueLike[T])

A one-dimensional interval over a contiguous set of domain values in T. See https://en.wikipedia.org/wiki/Interval_(mathematics) for more information.

A one-dimensional interval over a contiguous set of domain values in T. See https://en.wikipedia.org/wiki/Interval_(mathematics) for more information.

Type parameters

T

a domain value type for this interval's domain (e.g., Int, LocalDate) -- boundaries of the interval are defined in terms of Domain1D[T] given the type class DomainValueLike[T].

Value parameters

end

the "supremum", i.e., the right boundary of the interval -- must be greater than or equal to the start

start

the "infimum", i.e., the left boundary of the interval

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Interval1D

Companion for the one-dimensional interval used in defining and operating on valid data.

Companion for the one-dimensional interval used in defining and operating on valid data.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Interval1D.type
case class ValidData[V, D <: NonEmptyTuple](value: V, interval: Interval[D])(using domainLike: DomainLike[D]) extends PartialFunction[D, V]

A value that is valid in an interval of arbitrary dimensions. Conceptually, this defines a partial function where all domain elements that are part of the interval map to the value.

A value that is valid in an interval of arbitrary dimensions. Conceptually, this defines a partial function where all domain elements that are part of the interval map to the value.

Type parameters

D

the domain type -- DomainLike non-empty tuples.

V

the type of the value managed as data (the codomain).

Value parameters

interval

the interval in which the value is valid.

value

value that is valid in this interval.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait PartialFunction[D, V]
trait D => V
class Object
trait Matchable
class Any
Show all
object ValidData

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
ValidData.type

Types

opaque type Experimental

Enables/disables experimental features.

Enables/disables experimental features.

Attributes