sop-extras-0.2.1.0: Type-level and data utilities that build upon SOP.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.SOP.Counting

Description

Type-level counting

Intended for unqualified import.

Synopsis

Documentation

data AtMost xs a where Source #

At most one value for each type level index

Constructors

AtMostNilAtMost xs a 
AtMostCons ∷ !a → !(AtMost xs a) → AtMost (x ': xs) a 

Instances

Instances details
Foldable (AtMost xs) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

foldMonoid m ⇒ AtMost xs m → m #

foldMapMonoid m ⇒ (a → m) → AtMost xs a → m #

foldMap'Monoid m ⇒ (a → m) → AtMost xs a → m #

foldr ∷ (a → b → b) → b → AtMost xs a → b #

foldr' ∷ (a → b → b) → b → AtMost xs a → b #

foldl ∷ (b → a → b) → b → AtMost xs a → b #

foldl' ∷ (b → a → b) → b → AtMost xs a → b #

foldr1 ∷ (a → a → a) → AtMost xs a → a #

foldl1 ∷ (a → a → a) → AtMost xs a → a #

toListAtMost xs a → [a] #

nullAtMost xs a → Bool #

lengthAtMost xs a → Int #

elemEq a ⇒ a → AtMost xs a → Bool #

maximumOrd a ⇒ AtMost xs a → a #

minimumOrd a ⇒ AtMost xs a → a #

sumNum a ⇒ AtMost xs a → a #

productNum a ⇒ AtMost xs a → a #

Traversable (AtMost xs) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

traverseApplicative f ⇒ (a → f b) → AtMost xs a → f (AtMost xs b) #

sequenceAApplicative f ⇒ AtMost xs (f a) → f (AtMost xs a) #

mapMMonad m ⇒ (a → m b) → AtMost xs a → m (AtMost xs b) #

sequenceMonad m ⇒ AtMost xs (m a) → m (AtMost xs a) #

Functor (AtMost xs) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

fmap ∷ (a → b) → AtMost xs a → AtMost xs b #

(<$) ∷ a → AtMost xs b → AtMost xs a #

Show a ⇒ Show (AtMost xs a) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

showsPrecIntAtMost xs a → ShowS #

showAtMost xs a → String #

showList ∷ [AtMost xs a] → ShowS #

Eq a ⇒ Eq (AtMost xs a) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

(==)AtMost xs a → AtMost xs a → Bool #

(/=)AtMost xs a → AtMost xs a → Bool #

newtype Exactly xs a Source #

Constructors

Exactly 

Fields

Bundled Patterns

pattern ExactlyNil ∷ () ⇒ xs ~ '[] ⇒ Exactly xs a 
pattern ExactlyCons ∷ () ⇒ xs' ~ (x ': xs) ⇒ a → Exactly xs a → Exactly xs' a 

Instances

Instances details
Foldable (Exactly xs) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

foldMonoid m ⇒ Exactly xs m → m #

foldMapMonoid m ⇒ (a → m) → Exactly xs a → m #

foldMap'Monoid m ⇒ (a → m) → Exactly xs a → m #

foldr ∷ (a → b → b) → b → Exactly xs a → b #

foldr' ∷ (a → b → b) → b → Exactly xs a → b #

foldl ∷ (b → a → b) → b → Exactly xs a → b #

foldl' ∷ (b → a → b) → b → Exactly xs a → b #

foldr1 ∷ (a → a → a) → Exactly xs a → a #

foldl1 ∷ (a → a → a) → Exactly xs a → a #

toListExactly xs a → [a] #

nullExactly xs a → Bool #

lengthExactly xs a → Int #

elemEq a ⇒ a → Exactly xs a → Bool #

maximumOrd a ⇒ Exactly xs a → a #

minimumOrd a ⇒ Exactly xs a → a #

sumNum a ⇒ Exactly xs a → a #

productNum a ⇒ Exactly xs a → a #

Traversable (Exactly xs) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

traverseApplicative f ⇒ (a → f b) → Exactly xs a → f (Exactly xs b) #

sequenceAApplicative f ⇒ Exactly xs (f a) → f (Exactly xs a) #

mapMMonad m ⇒ (a → m b) → Exactly xs a → m (Exactly xs b) #

sequenceMonad m ⇒ Exactly xs (m a) → m (Exactly xs a) #

Functor (Exactly xs) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

fmap ∷ (a → b) → Exactly xs a → Exactly xs b #

(<$) ∷ a → Exactly xs b → Exactly xs a #

Show a ⇒ Show (Exactly xs a) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

showsPrecIntExactly xs a → ShowS #

showExactly xs a → String #

showList ∷ [Exactly xs a] → ShowS #

Eq a ⇒ Eq (Exactly xs a) Source # 
Instance details

Defined in Data.SOP.Counting

Methods

(==)Exactly xs a → Exactly xs a → Bool #

(/=)Exactly xs a → Exactly xs a → Bool #

Working with Exactly

exactlyHeadExactly (x ': xs) a → a Source #

Analogue of head

exactlyOne ∷ a → Exactly '[x] a Source #

Singleton

exactlyReplicate ∷ ∀ a r. Word → a → (∀ xs. Exactly xs a → r) → r Source #

Analogue of replicate

In CPS style because the xs type parameter is not statically known.

exactlyTailExactly (x ': xs) a → Exactly xs a Source #

Analogue of tail

exactlyTwo ∷ a → a → Exactly '[x, y] a Source #

From a pair

exactlyWeakenExactly xs a → AtMost xs a Source #

exactlyWeakenNonEmptyExactly (x ': xs) a → NonEmpty (x ': xs) a Source #

exactlyZipExactly xs a → Exactly xs b → Exactly xs (a, b) Source #

Analogue of zip

exactlyZipFoldableFoldable t ⇒ Exactly xs a → t b → AtMost xs (a, b) Source #

Analogue of zip where the length of second argument is unknown

Working with AtMost

atMostHeadAtMost xs a → Maybe a Source #

Analogue of head

atMostInitAtMost xs a → Maybe (AtMost xs a, a) Source #

Analogue of init

For simplicity we don't shrink the type-level index.

atMostLastAtMost xs a → Maybe a Source #

Analogue of last

atMostNonEmptyAtMost (x ': xs) a → Maybe (NonEmpty (x ': xs) a) Source #

atMostOne ∷ a → AtMost (x ': xs) a Source #

Singleton

atMostZipFoldableFoldable t ⇒ AtMost xs a → t b → AtMost xs (a, b) Source #