mono-traversable-0.6.2: Type classes for mapping, folding, and traversing monomorphic containers

Safe HaskellNone
LanguageHaskell2010

Data.MinLen

Contents

Synopsis

Type level naturals

data Zero Source

Constructors

Zero 

Instances

TypeNat Zero 
MonoPointed mono => MonoPointed (MinLen (Succ Zero) mono) 
MonoPointed mono => MonoPointed (MinLen Zero mono) 
type MaxNat x Zero = x 
type MaxNat Zero y = y 
type AddNat Zero y = y 

data Succ nat Source

Constructors

Succ nat 

Instances

TypeNat nat => TypeNat (Succ nat) 
MonoPointed mono => MonoPointed (MinLen (Succ Zero) mono) 
type AddNat (Succ x) y = AddNat x (Succ y) 
type MaxNat (Succ x) (Succ y) = Succ (MaxNat x y) 

class TypeNat nat where Source

Methods

toValueNat :: Num i => nat -> i Source

typeNat :: nat Source

Instances

TypeNat Zero 
TypeNat nat => TypeNat (Succ nat) 

type family AddNat x y Source

Instances

type AddNat Zero y = y 
type AddNat (Succ x) y = AddNat x (Succ y) 

type family MaxNat x y Source

Instances

type MaxNat x Zero = x 
type MaxNat Zero y = y 
type MaxNat (Succ x) (Succ y) = Succ (MaxNat x y) 

Minimum length newtype wrapper

data MinLen nat mono Source

Instances

Functor (MinLen nat) 
Eq mono => Eq (MinLen nat mono) 
(Data nat, Data mono) => Data (MinLen nat mono) 
Ord mono => Ord (MinLen nat mono) 
Read mono => Read (MinLen nat mono) 
Show mono => Show (MinLen nat mono) 
GrowingAppend mono => Semigroup (MinLen nat mono) 
MonoPointed mono => MonoPointed (MinLen (Succ Zero) mono) 
MonoPointed mono => MonoPointed (MinLen Zero mono) 
MonoTraversable mono => MonoTraversable (MinLen nat mono) 
MonoFoldableOrd mono => MonoFoldableOrd (MinLen nat mono) 
MonoFoldable mono => MonoFoldable (MinLen nat mono) 
MonoFunctor mono => MonoFunctor (MinLen nat mono) 
GrowingAppend mono => GrowingAppend (MinLen nat mono) 
SemiSequence seq => SemiSequence (MinLen nat seq) 
Typeable (* -> * -> *) MinLen 
type Element (MinLen nat mono) = Element mono 
type Index (MinLen nat seq) = Index seq 

unMinLen :: MinLen nat mono -> mono Source

toMinLenZero :: mono -> MinLen Zero mono Source

toMinLen :: (MonoFoldable mono, TypeNat nat) => mono -> Maybe (MinLen nat mono) Source

unsafeToMinLen :: mono -> MinLen nat mono Source

Although this function itself cannot cause a segfault, it breaks the safety guarantees of MinLen and can lead to a segfault when using otherwise safe functions.

mlcons :: IsSequence seq => Element seq -> MinLen nat seq -> MinLen (Succ nat) seq Source

mlappend :: IsSequence seq => MinLen x seq -> MinLen y seq -> MinLen (AddNat x y) seq Source

mlunion :: GrowingAppend mono => MinLen x mono -> MinLen y mono -> MinLen (MaxNat x y) mono Source

head :: MonoTraversable mono => MinLen (Succ nat) mono -> Element mono Source

last :: MonoTraversable mono => MinLen (Succ nat) mono -> Element mono Source

tailML :: IsSequence seq => MinLen (Succ nat) seq -> MinLen nat seq Source

initML :: IsSequence seq => MinLen (Succ nat) seq -> MinLen nat seq Source

ofoldMap1 :: (MonoFoldable mono, Semigroup m) => (Element mono -> m) -> MinLen (Succ nat) mono -> m Source

ofold1 :: (MonoFoldable mono, Semigroup (Element mono)) => MinLen (Succ nat) mono -> Element mono Source

ofoldr1 :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> MinLen (Succ nat) mono -> Element mono Source

ofoldl1' :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> MinLen (Succ nat) mono -> Element mono Source

A variant of 'ofoldl\'' that has no base case, and thus may only be applied to non-empty structures.

'foldl1\'' f = foldl1 f . otoList

maximum :: MonoFoldableOrd mono => MinLen (Succ nat) mono -> Element mono Source

like Data.List, but not partial on a MonoFoldable

minimum :: MonoFoldableOrd mono => MinLen (Succ nat) mono -> Element mono Source

like Data.List, but not partial on a MonoFoldable

maximumBy :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> MinLen (Succ nat) mono -> Element mono Source

like Data.List, but not partial on a MonoFoldable

minimumBy :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> MinLen (Succ nat) mono -> Element mono Source

like Data.List, but not partial on a MonoFoldable