Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.SOP.Counting
Description
Type-level counting
Intended for unqualified import.
Synopsis
- data AtMost (xs ∷ [Type]) a where
- newtype Exactly (xs ∷ [Type]) a where
- Exactly {
- getExactly ∷ NP (K a ∷ Type → Type) xs
- pattern ExactlyNil ∷ () ⇒ xs ~ ('[] ∷ [Type]) ⇒ Exactly xs a
- pattern ExactlyCons ∷ ∀ xs' a x xs. () ⇒ ∀. xs' ~ (x ': xs) ⇒ a → Exactly xs a → Exactly xs' a
- Exactly {
- exactlyHead ∷ ∀ x (xs ∷ [Type]) a. Exactly (x ': xs) a → a
- exactlyOne ∷ a → Exactly '[x] a
- exactlyReplicate ∷ Word → a → (∀ (xs ∷ [Type]). Exactly xs a → r) → r
- exactlyTail ∷ ∀ x (xs ∷ [Type]) a. Exactly (x ': xs) a → Exactly xs a
- exactlyTwo ∷ a → a → Exactly '[x, y] a
- exactlyWeaken ∷ ∀ (xs ∷ [Type]) a. Exactly xs a → AtMost xs a
- exactlyWeakenNonEmpty ∷ ∀ x (xs ∷ [Type]) a. Exactly (x ': xs) a → NonEmpty (x ': xs) a
- exactlyZip ∷ ∀ (xs ∷ [Type]) a b. Exactly xs a → Exactly xs b → Exactly xs (a, b)
- exactlyZipFoldable ∷ ∀ t (xs ∷ [Type]) a b. Foldable t ⇒ Exactly xs a → t b → AtMost xs (a, b)
- atMostFromNonEmpty ∷ ∀ (xs ∷ [Type]) a. NonEmpty xs a → AtMost xs a
- atMostHead ∷ ∀ (xs ∷ [Type]) a. AtMost xs a → Maybe a
- atMostInit ∷ ∀ (xs ∷ [Type]) a. AtMost xs a → Maybe (AtMost xs a, a)
- atMostLast ∷ ∀ (xs ∷ [Type]) a. AtMost xs a → Maybe a
- atMostNonEmpty ∷ ∀ x (xs ∷ [Type]) a. AtMost (x ': xs) a → Maybe (NonEmpty (x ': xs) a)
- atMostOne ∷ ∀ a x (xs ∷ [Type]). a → AtMost (x ': xs) a
- atMostZipFoldable ∷ ∀ t (xs ∷ [Type]) a b. Foldable t ⇒ AtMost xs a → t b → AtMost xs (a, b)
Documentation
data AtMost (xs ∷ [Type]) a where Source #
At most one value for each type level index
Constructors
AtMostNil ∷ ∀ (xs ∷ [Type]) a. AtMost xs a | |
AtMostCons ∷ ∀ a (xs1 ∷ [Type]) x. !a → !(AtMost xs1 a) → AtMost (x ': xs1) a |
Instances
Functor (AtMost xs) Source # | |
Foldable (AtMost xs) Source # | |
Defined in Data.SOP.Counting Methods fold ∷ Monoid m ⇒ AtMost xs m → m # foldMap ∷ Monoid 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 # elem ∷ Eq a ⇒ a → AtMost xs a → Bool # maximum ∷ Ord a ⇒ AtMost xs a → a # minimum ∷ Ord a ⇒ AtMost xs a → a # | |
Traversable (AtMost xs) Source # | |
Show a ⇒ Show (AtMost xs a) Source # | |
Eq a ⇒ Eq (AtMost xs a) Source # | |
newtype Exactly (xs ∷ [Type]) a Source #
Bundled Patterns
pattern ExactlyNil ∷ () ⇒ xs ~ ('[] ∷ [Type]) ⇒ Exactly xs a | |
pattern ExactlyCons ∷ ∀ xs' a x xs. () ⇒ ∀. xs' ~ (x ': xs) ⇒ a → Exactly xs a → Exactly xs' a |
Instances
Functor (Exactly xs) Source # | |
Foldable (Exactly xs) Source # | |
Defined in Data.SOP.Counting Methods fold ∷ Monoid m ⇒ Exactly xs m → m # foldMap ∷ Monoid 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 # elem ∷ Eq a ⇒ a → Exactly xs a → Bool # maximum ∷ Ord a ⇒ Exactly xs a → a # minimum ∷ Ord a ⇒ Exactly xs a → a # | |
Traversable (Exactly xs) Source # | |
Show a ⇒ Show (Exactly xs a) Source # | |
Eq a ⇒ Eq (Exactly xs a) Source # | |
Working with Exactly
exactlyOne ∷ a → Exactly '[x] a Source #
Singleton
exactlyReplicate ∷ Word → a → (∀ (xs ∷ [Type]). Exactly xs a → r) → r Source #
Analogue of replicate
In CPS style because the xs
type parameter is not statically known.
exactlyTwo ∷ a → a → Exactly '[x, y] a Source #
From a pair
exactlyZip ∷ ∀ (xs ∷ [Type]) a b. Exactly xs a → Exactly xs b → Exactly xs (a, b) Source #
Analogue of zip
exactlyZipFoldable ∷ ∀ t (xs ∷ [Type]) a b. Foldable t ⇒ Exactly xs a → t b → AtMost xs (a, b) Source #
Analogue of zip
where the length of second argument is unknown