covenant
Copyright(C) MLabs 2025
LicenseApache 2.0
Maintainerkoz@mlabs.city, sean@mlabs.city
Safe HaskellNone
LanguageHaskell2010

Covenant.Index

Description

Positional indexes, starting from 0, and cardinality indicators.

Since: 1.0.0

Synopsis

Documentation

data Index (ofWhat :: Symbol) Source #

A positional index, starting from zero. The label allows distinguishing different flavours of indices.

Since: 1.0.0

Instances

Instances details
Arbitrary (Index ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

arbitrary :: Gen (Index ofWhat) #

shrink :: Index ofWhat -> [Index ofWhat] #

Monoid (Index ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

mempty :: Index ofWhat #

mappend :: Index ofWhat -> Index ofWhat -> Index ofWhat #

mconcat :: [Index ofWhat] -> Index ofWhat #

Semigroup (Index ofWhat) Source #

Enables some manner of arithmetic with Indexess. In this case, <> is analogous to +, while stimes b is analogous to scalar multiplication by b. Note that Indexes cannot be scaled by negative numbers.

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

(<>) :: Index ofWhat -> Index ofWhat -> Index ofWhat #

sconcat :: NonEmpty (Index ofWhat) -> Index ofWhat #

stimes :: Integral b => b -> Index ofWhat -> Index ofWhat #

Show (Index ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

showsPrec :: Int -> Index ofWhat -> ShowS #

show :: Index ofWhat -> String #

showList :: [Index ofWhat] -> ShowS #

Eq (Index ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

(==) :: Index ofWhat -> Index ofWhat -> Bool #

(/=) :: Index ofWhat -> Index ofWhat -> Bool #

Ord (Index ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

compare :: Index ofWhat -> Index ofWhat -> Ordering #

(<) :: Index ofWhat -> Index ofWhat -> Bool #

(<=) :: Index ofWhat -> Index ofWhat -> Bool #

(>) :: Index ofWhat -> Index ofWhat -> Bool #

(>=) :: Index ofWhat -> Index ofWhat -> Bool #

max :: Index ofWhat -> Index ofWhat -> Index ofWhat #

min :: Index ofWhat -> Index ofWhat -> Index ofWhat #

data Count (ofWhat :: Symbol) Source #

An indicator of the cardinality of something. Meant to be paired with Index to specify which unique something you mean.

Since: 1.0.0

Instances

Instances details
Show (Count ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

showsPrec :: Int -> Count ofWhat -> ShowS #

show :: Count ofWhat -> String #

showList :: [Count ofWhat] -> ShowS #

Eq (Count ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

(==) :: Count ofWhat -> Count ofWhat -> Bool #

(/=) :: Count ofWhat -> Count ofWhat -> Bool #

Ord (Count ofWhat) Source #

Since: 1.0.0

Instance details

Defined in Covenant.Index

Methods

compare :: Count ofWhat -> Count ofWhat -> Ordering #

(<) :: Count ofWhat -> Count ofWhat -> Bool #

(<=) :: Count ofWhat -> Count ofWhat -> Bool #

(>) :: Count ofWhat -> Count ofWhat -> Bool #

(>=) :: Count ofWhat -> Count ofWhat -> Bool #

max :: Count ofWhat -> Count ofWhat -> Count ofWhat #

min :: Count ofWhat -> Count ofWhat -> Count ofWhat #

intIndex :: forall (ofWhat :: Symbol). Prism' Int (Index ofWhat) Source #

Helper to construct, and convert, Indexes and Ints. This is needed because unfortunately, the standard Haskell practice is to use Int for indexes.

To use this, do one of the following:

  • Construct with preview: for example, preview intIndex 1.
  • Destruct with review.

Since: 1.0.0

intCount :: forall (ofWhat :: Symbol). Prism' Int (Count ofWhat) Source #

Helper to construct, and convert, Counts and Ints. This is needed because unfortunately, sizes of things are usually Ints in Haskell.

To use this, do one of the following:

  • Construct with preview: for example, preview intCount 1.
  • Destruct with review.

Since: 1.0.0

ix0 :: forall (ofWhat :: Symbol). Index ofWhat Source #

Helper for the first index.

Since: 1.0.0

count0 :: forall (ofWhat :: Symbol). Count ofWhat Source #

Helper for a count of zero items.

Since: 1.0.0

ix1 :: forall (ofWhat :: Symbol). Index ofWhat Source #

Helper for the second index.

Since: 1.0.0

count1 :: forall (ofWhat :: Symbol). Count ofWhat Source #

Helper for a count of one item.

Since: 1.0.0

ix2 :: forall (ofWhat :: Symbol). Index ofWhat Source #

Helper for the third index.

Since: 1.0.0

count2 :: forall (ofWhat :: Symbol). Count ofWhat Source #

Helper for a count of two items.

Since: 1.0.0

ix3 :: forall (ofWhat :: Symbol). Index ofWhat Source #

Helper for the fourth index.

Since: 1.0.0

count3 :: forall (ofWhat :: Symbol). Count ofWhat Source #

Helper for a count of three items.

Since: 1.0.0