Safe Haskell  SafeInferred 

Language  Haskell2010 
Typelevel counting
Intended for unqualified import.
Synopsis
 data AtMost xs a where
 AtMostNil ∷ AtMost xs a
 AtMostCons ∷ !a → !(AtMost xs a) → AtMost (x ': xs) a
 newtype Exactly xs a where
 Exactly {
 getExactly ∷ NP (K a) xs
 pattern ExactlyNil ∷ () ⇒ xs ~ '[] ⇒ Exactly xs a
 pattern ExactlyCons ∷ () ⇒ xs' ~ (x ': xs) ⇒ a → Exactly xs a → Exactly xs' a
 Exactly {
 exactlyHead ∷ Exactly (x ': xs) a → a
 exactlyOne ∷ a → Exactly '[x] a
 exactlyReplicate ∷ ∀ a r. Word → a → (∀ xs. Exactly xs a → r) → r
 exactlyTail ∷ Exactly (x ': xs) a → Exactly xs a
 exactlyTwo ∷ a → a → Exactly '[x, y] a
 exactlyWeaken ∷ Exactly xs a → AtMost xs a
 exactlyWeakenNonEmpty ∷ Exactly (x ': xs) a → NonEmpty (x ': xs) a
 exactlyZip ∷ Exactly xs a → Exactly xs b → Exactly xs (a, b)
 exactlyZipFoldable ∷ Foldable t ⇒ Exactly xs a → t b → AtMost xs (a, b)
 atMostFromNonEmpty ∷ NonEmpty xs a → AtMost xs a
 atMostHead ∷ AtMost xs a → Maybe a
 atMostInit ∷ AtMost xs a → Maybe (AtMost xs a, a)
 atMostLast ∷ AtMost xs a → Maybe a
 atMostNonEmpty ∷ AtMost (x ': xs) a → Maybe (NonEmpty (x ': xs) a)
 atMostOne ∷ a → AtMost (x ': xs) a
 atMostZipFoldable ∷ Foldable t ⇒ AtMost xs a → t b → AtMost xs (a, b)
Documentation
data AtMost xs a where Source #
At most one value for each type level index
AtMostNil ∷ AtMost xs a  
AtMostCons ∷ !a → !(AtMost xs a) → AtMost (x ': xs) a 
Instances
Foldable (AtMost xs) Source #  
Defined in Data.SOP.Counting 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 #  
Functor (AtMost xs) Source #  
Show a ⇒ Show (AtMost xs a) Source #  
Eq a ⇒ Eq (AtMost xs a) Source #  
Exactly  

pattern ExactlyNil ∷ () ⇒ xs ~ '[] ⇒ Exactly xs a  
pattern ExactlyCons ∷ () ⇒ xs' ~ (x ': xs) ⇒ a → Exactly xs a → Exactly xs' a 
Instances
Foldable (Exactly xs) Source #  
Defined in Data.SOP.Counting 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 #  
Functor (Exactly xs) Source #  
Show a ⇒ Show (Exactly xs a) Source #  
Eq a ⇒ Eq (Exactly xs a) Source #  
Working with Exactly
exactlyHead ∷ Exactly (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.
exactlyTwo ∷ a → a → Exactly '[x, y] a Source #
From a pair
exactlyWeaken ∷ Exactly xs a → AtMost xs a Source #
exactlyWeakenNonEmpty ∷ Exactly (x ': xs) a → NonEmpty (x ': xs) a Source #
exactlyZipFoldable ∷ Foldable 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
atMostFromNonEmpty ∷ NonEmpty xs a → AtMost xs a Source #