-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | List-like structures with static restrictions on the number of elements -- -- We provide the data type NonEmpty that allows to store a -- list-like structure with at least or exactly n elements, -- where n is fixed in the type in a kind of Peano encoding and -- is usually small. The datatype is intended to increase safety by -- making functions total that are partial on plain lists. E.g. on a -- non-empty list, head and tail are always defined. -- -- There are more such data types like Optional and -- Empty. Together with NonEmpty you can define a list -- type for every finite set of admissible list lengths. -- -- The datatype can be combined with Lists, Sequences and Sets (from the -- containers package). -- -- The package needs only Haskell 98. -- -- Similar packages: -- --
-- fmap f xs -- = zipWith (\x _ -> f x) xs xs -- = zipWith (\_ x -> f x) xs xs --class Functor f => Zip f zipWith :: Zip f => (a -> b -> c) -> f a -> f b -> f c zipWith3 :: (Zip f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d zipWith4 :: (Zip f) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e zip :: (Zip f) => f a -> f b -> f (a, b) zip3 :: (Zip f) => f a -> f b -> f c -> f (a, b, c) zip4 :: (Zip f) => f a -> f b -> f c -> f d -> f (a, b, c, d) class Repeat f -- | Create a container with as many copies as possible of a given value. -- That is, for a container with fixed size n, the call -- repeat x will generate a container with n copies of -- x. repeat :: Repeat f => a -> f a class Repeat f => Iterate f iterate :: Iterate f => (a -> a) -> a -> f a -- | We need to distinguish between Sort and SortBy, since -- there is an instance Sort Set but there cannot be an -- instance SortBy Set. class Sort f sort :: (Sort f, Ord a) => f a -> f a -- | Default implementation for sort based on sortBy. sortDefault :: (Ord a, SortBy f) => f a -> f a class Sort f => SortBy f sortBy :: SortBy f => (a -> a -> Ordering) -> f a -> f a class Reverse f reverse :: Reverse f => f a -> f a class Show f showsPrec :: (Show f, Show a) => Int -> f a -> ShowS class Arbitrary f arbitrary :: (Arbitrary f, Arbitrary a) => Gen (f a) shrink :: (Arbitrary f, Arbitrary a) => f a -> [f a] class NFData f rnf :: (NFData f, NFData a) => f a -> () instance Data.NonEmpty.Class.Empty [] instance Data.NonEmpty.Class.Empty GHC.Base.Maybe instance Data.NonEmpty.Class.Empty Data.Set.Base.Set instance Data.NonEmpty.Class.Empty (Data.Map.Base.Map k) instance Data.NonEmpty.Class.Empty Data.Sequence.Seq instance Data.NonEmpty.Class.Cons [] instance Data.NonEmpty.Class.Cons Data.Sequence.Seq instance Data.NonEmpty.Class.Snoc [] instance Data.NonEmpty.Class.Snoc Data.Sequence.Seq instance Data.NonEmpty.Class.ViewL [] instance Data.NonEmpty.Class.ViewL GHC.Base.Maybe instance Data.NonEmpty.Class.ViewL Data.Set.Base.Set instance Data.NonEmpty.Class.ViewL Data.Sequence.Seq instance Data.NonEmpty.Class.ViewR [] instance Data.NonEmpty.Class.ViewR GHC.Base.Maybe instance Data.NonEmpty.Class.ViewR Data.Set.Base.Set instance Data.NonEmpty.Class.ViewR Data.Sequence.Seq instance Data.NonEmpty.Class.View [] instance Data.NonEmpty.Class.View GHC.Base.Maybe instance Data.NonEmpty.Class.View Data.Set.Base.Set instance Data.NonEmpty.Class.View Data.Sequence.Seq instance Data.NonEmpty.Class.Singleton [] instance Data.NonEmpty.Class.Singleton GHC.Base.Maybe instance Data.NonEmpty.Class.Singleton Data.Set.Base.Set instance Data.NonEmpty.Class.Singleton Data.Sequence.Seq instance Data.NonEmpty.Class.Append [] instance Data.NonEmpty.Class.Append Data.Sequence.Seq instance Data.NonEmpty.Class.Zip [] instance Data.NonEmpty.Class.Zip GHC.Base.Maybe instance Data.NonEmpty.Class.Zip Data.Sequence.Seq instance Data.NonEmpty.Class.Repeat [] instance Data.NonEmpty.Class.Repeat GHC.Base.Maybe instance Data.NonEmpty.Class.Iterate [] instance Data.NonEmpty.Class.Iterate GHC.Base.Maybe instance Data.NonEmpty.Class.Sort [] instance Data.NonEmpty.Class.Sort GHC.Base.Maybe instance Data.NonEmpty.Class.Sort Data.Sequence.Seq instance Data.NonEmpty.Class.Sort Data.Set.Base.Set instance Data.NonEmpty.Class.SortBy [] instance Data.NonEmpty.Class.SortBy GHC.Base.Maybe instance Data.NonEmpty.Class.SortBy Data.Sequence.Seq instance Data.NonEmpty.Class.Reverse [] instance Data.NonEmpty.Class.Reverse GHC.Base.Maybe instance Data.NonEmpty.Class.Reverse Data.Sequence.Seq instance Data.NonEmpty.Class.Show [] instance Data.NonEmpty.Class.Show Data.Set.Base.Set instance Data.NonEmpty.Class.Arbitrary [] instance Data.NonEmpty.Class.NFData GHC.Base.Maybe instance Data.NonEmpty.Class.NFData [] instance Data.NonEmpty.Class.NFData Data.Set.Base.Set instance Control.DeepSeq.NFData k => Data.NonEmpty.Class.NFData (Data.Map.Base.Map k) module Data.Empty data T a Cons :: T a instance GHC.Classes.Ord (Data.Empty.T a) instance GHC.Classes.Eq (Data.Empty.T a) instance GHC.Show.Show (Data.Empty.T a) instance Data.NonEmpty.Class.Show Data.Empty.T instance GHC.Base.Functor Data.Empty.T instance Data.Foldable.Foldable Data.Empty.T instance Data.Traversable.Traversable Data.Empty.T instance Data.NonEmpty.Class.ViewL Data.Empty.T instance Data.NonEmpty.Class.ViewR Data.Empty.T instance Data.NonEmpty.Class.View Data.Empty.T instance Test.QuickCheck.Arbitrary.Arbitrary (Data.Empty.T a) instance Data.NonEmpty.Class.Empty Data.Empty.T instance Data.NonEmpty.Class.Zip Data.Empty.T instance Data.NonEmpty.Class.Reverse Data.Empty.T instance Data.NonEmpty.Class.Sort Data.Empty.T instance Data.NonEmpty.Class.SortBy Data.Empty.T instance Data.NonEmpty.Class.Repeat Data.Empty.T instance Data.NonEmpty.Class.Iterate Data.Empty.T instance Data.NonEmpty.Class.NFData Data.Empty.T instance Control.DeepSeq.NFData (Data.Empty.T a) -- | Generalized version of utility-ht:Data.List.Match. module Data.NonEmpty.Match -- | Make a list as long as another one take :: (Zip f) => f b -> f a -> f a -- | the same as ($>) replicate :: (Functor f) => f a -> b -> f b module Data.Append data T f g a Cons :: f a -> g a -> T f g a [fst] :: T f g a -> f a [snd] :: T f g a -> g a instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (Data.Append.T f g) instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (Data.Append.T f g) instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (Data.Append.T f g) instance (Data.NonEmpty.Class.NFData f, Data.NonEmpty.Class.NFData g) => Data.NonEmpty.Class.NFData (Data.Append.T f g) instance (Data.NonEmpty.Class.NFData f, Data.NonEmpty.Class.NFData g, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Data.Append.T f g a) module Data.Zip -- | Wrap a container such that its Applicative instance is based on zip. newtype T f a Cons :: f a -> T f a [decons] :: T f a -> f a -- | Always returns a rectangular list by clipping all dimensions to the -- shortest slice. Be aware that transpose [] == repeat []. transposeClip :: (Traversable f, Zip g, Repeat g) => f (g a) -> g (f a) instance GHC.Base.Functor f => GHC.Base.Functor (Data.Zip.T f) instance (Data.NonEmpty.Class.Zip f, Data.NonEmpty.Class.Repeat f) => GHC.Base.Applicative (Data.Zip.T f) instance (Data.NonEmpty.Class.NFData f, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Data.Zip.T f a) instance Data.NonEmpty.Class.NFData f => Data.NonEmpty.Class.NFData (Data.Zip.T f) module Data.NonEmpty -- | The type T can be used for many kinds of list-like structures -- with restrictions on the size. -- --
-- foldl1Map f g = foldl1 f . fmap g ---- -- but foldl1Map does not need a Functor instance. foldl1Map :: (Foldable f) => (b -> b -> b) -> (a -> b) -> T f a -> b -- | Fold a non-empty list in a balanced way. Balanced means that -- each element has approximately the same depth in the operator tree. -- Approximately the same depth means that the difference between -- maximum and minimum depth is at most 1. The accumulation operation -- must be associative and commutative in order to get the same result as -- foldl1 or foldr1. foldBalanced :: (a -> a -> a) -> T [] a -> a foldBalancedStrict :: (a -> a -> a) -> T [] a -> a -- | maximum is a total function maximum :: (Ord a, Foldable f) => T f a -> a -- | maximumBy is a total function maximumBy :: (Foldable f) => (a -> a -> Ordering) -> T f a -> a -- | maximumKey is a total function maximumKey :: (Ord b, Foldable f) => (a -> b) -> T f a -> a -- | minimum is a total function minimum :: (Ord a, Foldable f) => T f a -> a -- | minimumBy is a total function minimumBy :: (Foldable f) => (a -> a -> Ordering) -> T f a -> a -- | minimumKey is a total function minimumKey :: (Ord b, Foldable f) => (a -> b) -> T f a -> a -- | sum does not need a zero for initialization sum :: (Num a, Foldable f) => T f a -> a -- | product does not need a one for initialization product :: (Num a, Foldable f) => T f a -> a append :: (Append f, Traversable f) => T f a -> T f a -> T (T f) a infixr 5 `append` appendLeft :: (Append f, Traversable f) => f a -> T f a -> T f a infixr 5 `appendLeft` appendRight :: (Append f) => T f a -> f a -> T f a infixr 5 `appendRight` -- | generic variants: cycle or better Semigroup.cycle cycle :: (Cons f, Append f) => T f a -> T f a zipWith :: (Zip f) => (a -> b -> c) -> T f a -> T f b -> T f c mapAdjacent :: (Traversable f) => (a -> a -> b) -> T f a -> f b class Insert f -- | Insert an element into an ordered list while preserving the order. insert :: (Insert f, Ord a) => a -> f a -> T f a -- | Default implementation for insert based on insertBy. insertDefault :: (Ord a, InsertBy f, SortBy f) => a -> f a -> T f a class Insert f => InsertBy f insertBy :: InsertBy f => (a -> a -> Ordering) -> a -> f a -> T f a scanl :: Traversable f => (b -> a -> b) -> b -> f a -> T f b scanr :: Traversable f => (a -> b -> b) -> b -> f a -> T f b tails :: (Traversable f, Cons g, Empty g) => f a -> T f (g a) -- | Only advised for structures with efficient appending of single -- elements like Sequence. Alternatively you may consider -- initsRev. inits :: (Traversable f, Snoc g, Empty g) => f a -> T f (g a) initsRev :: (Traversable f, Cons g, Empty g, Reverse g) => f a -> T f (g a) removeEach :: (Traversable f) => T f a -> T f (a, f a) -- | Functions that cope both with plain and non-empty structures. -- -- If there are two versions of a function, where one works on -- fixed-length lists, then place the fixed-length list variant in -- NonEmpty and the other one here. module Data.NonEmpty.Mixed groupBy :: (Foldable f) => (a -> a -> Bool) -> f a -> [T [] a] groupPairs :: (Foldable f, Eq a) => f (a, b) -> [(a, T [] b)] groupKey :: (Foldable f, Eq a) => (b -> a) -> f b -> [(a, T [] b)] groupEithers :: (Foldable f) => f (Either a b) -> [Either (T [] a) (T [] b)] segmentAfter :: (Foldable f) => (a -> Bool) -> f a -> ([T [] a], [a]) segmentBefore :: (Foldable f) => (a -> Bool) -> f a -> ([a], [T [] a]) filterToInfixes :: (Foldable f) => (a -> Bool) -> f a -> [T [] a] mapAdjacent :: (Cons f, Zip f) => (a -> a -> b) -> T f a -> f b take :: (View g, Repeat f, Traversable f) => g a -> Maybe (f a) splitAt :: (View g, Repeat f, Traversable f) => g a -> (Maybe (f a), g a) sliceVertical :: (View g, Repeat f, Traversable f) => g a -> ([f a], g a) -- | This implementation is more efficient for Sequence than viewR. viewR :: (ViewR f, Empty f, Cons f) => T f a -> (f a, a) init :: (ViewR f, Empty f, Cons f) => T f a -> f a last :: (ViewR f) => T f a -> a tails :: (ViewL f, Empty f) => f a -> T [] (f a) inits :: (ViewL f, Cons f, Empty f) => f a -> T [] (f a) appendLeft :: (Cons f) => [a] -> f a -> f a iterate :: (Repeat f, Traversable f) => (a -> a) -> a -> f a class Choose f -- | Select tuples of list elements: choose "abc" == -- ['a'!:'b'!:empty,'a'!:'c'!:empty,'b'!:'c'!:empty] choose :: Choose f => [a] -> [f a] instance Data.NonEmpty.Mixed.Choose Data.Empty.T instance Data.NonEmpty.Mixed.Choose f => Data.NonEmpty.Mixed.Choose (Data.NonEmptyPrivate.T f) instance Data.NonEmpty.Mixed.Choose [] module Data.NonEmpty.Set data T a -- | We cannot have a reasonable instance Insert Set, since the -- instance Insert (NonEmpty Set) would preserve duplicate -- leading elements, whereas Set does not. -- -- However, the instance Insert NonEmpty is not the problem. A -- general type like -- --
-- insertSet :: (Insert f, Ord a) => a -> f a -> NonEmpty f a ---- -- cannot work, since it can be instantiated to -- --
-- insertSet :: (Ord a) => a -> NonEmpty Set a -> NonEmpty (NonEmpty Set) a ---- -- and this is obviously wrong: insertSet x (singleton x) has -- only one element, not two. insert :: Ord a => a -> Set a -> T a singleton :: a -> T a member :: (Ord a) => a -> T a -> Bool size :: T a -> Int fromList :: (Ord a) => T [] a -> T a toAscList :: T a -> T [] a fetch :: (Ord a) => Set a -> Maybe (T a) flatten :: (Ord a) => T a -> Set a union :: (Ord a) => T a -> T a -> T a unionLeft :: (Ord a) => Set a -> T a -> T a unionRight :: (Ord a) => T a -> Set a -> T a findMin :: T a -> a findMax :: T a -> a deleteMin :: T a -> Set a deleteMax :: (Ord a) => T a -> Set a deleteFindMin :: T a -> (a, Set a) deleteFindMax :: (Ord a) => T a -> (a, Set a) minView :: T a -> (a, Set a) maxView :: (Ord a) => T a -> (a, Set a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.NonEmpty.Set.T a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.NonEmpty.Set.T a) instance GHC.Show.Show a => GHC.Show.Show (Data.NonEmpty.Set.T a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.NonEmpty.Set.T a) instance Data.NonEmpty.Class.NFData Data.NonEmpty.Set.T module Data.NonEmpty.Map data T k a insert :: Ord k => k -> a -> Map k a -> T k a singleton :: k -> a -> T k a member :: (Ord k) => k -> T k a -> Bool size :: T k a -> Int elems :: T k a -> T [] a keys :: T k a -> T [] k keysSet :: (Ord k) => T k a -> T k lookup :: (Ord k) => k -> T k a -> Maybe a minViewWithKey :: T k a -> ((k, a), Map k a) maxViewWithKey :: (Ord k) => T k a -> ((k, a), Map k a) fromList :: (Ord k) => T [] (k, a) -> T k a toAscList :: T k a -> T [] (k, a) fetch :: (Ord k) => Map k a -> Maybe (T k a) flatten :: (Ord k) => T k a -> Map k a union :: (Ord k) => T k a -> T k a -> T k a unionLeft :: (Ord k) => Map k a -> T k a -> T k a unionRight :: (Ord k) => T k a -> Map k a -> T k a map :: (Ord k) => (a -> b) -> T k a -> T k b mapWithKey :: (Ord k) => (k -> a -> b) -> T k a -> T k b instance (GHC.Classes.Ord k, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.NonEmpty.Map.T k a) instance (GHC.Classes.Eq k, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.NonEmpty.Map.T k a) instance (GHC.Show.Show k, GHC.Show.Show a) => GHC.Show.Show (Data.NonEmpty.Map.T k a) instance GHC.Classes.Ord k => GHC.Base.Functor (Data.NonEmpty.Map.T k) instance GHC.Classes.Ord k => Data.Foldable.Foldable (Data.NonEmpty.Map.T k) instance GHC.Classes.Ord k => Data.Traversable.Traversable (Data.NonEmpty.Map.T k) instance (Control.DeepSeq.NFData k, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Data.NonEmpty.Map.T k a) instance Control.DeepSeq.NFData k => Data.NonEmpty.Class.NFData (Data.NonEmpty.Map.T k) module Data.Optional data T f a Nil :: T f a Cons :: a -> (f a) -> T f a (?:) :: a -> f a -> T f a infixr 5 ?: fromEmpty :: T a -> T f a fromNonEmpty :: T f a -> T f a instance (GHC.Classes.Ord a, GHC.Classes.Ord (f a)) => GHC.Classes.Ord (Data.Optional.T f a) instance (GHC.Classes.Eq a, GHC.Classes.Eq (f a)) => GHC.Classes.Eq (Data.Optional.T f a) instance (Data.NonEmpty.Class.NFData f, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Data.Optional.T f a) instance Data.NonEmpty.Class.NFData f => Data.NonEmpty.Class.NFData (Data.Optional.T f) instance (Data.NonEmpty.Class.Show f, GHC.Show.Show a) => GHC.Show.Show (Data.Optional.T f a) instance Data.NonEmpty.Class.Show f => Data.NonEmpty.Class.Show (Data.Optional.T f) instance GHC.Base.Functor f => GHC.Base.Functor (Data.Optional.T f) instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Data.Optional.T f) instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Data.Optional.T f) instance (Data.NonEmpty.Class.Arbitrary f, Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Data.Optional.T f a) instance Data.NonEmpty.Class.Empty (Data.Optional.T f) instance (Data.NonEmpty.Class.Cons f, Data.NonEmpty.Class.Empty f) => Data.NonEmpty.Class.Cons (Data.Optional.T f) instance Data.NonEmpty.Class.Repeat f => Data.NonEmpty.Class.Repeat (Data.Optional.T f) instance Data.NonEmpty.Class.Iterate f => Data.NonEmpty.Class.Iterate (Data.Optional.T f) instance Data.NonEmpty.Class.Zip f => Data.NonEmpty.Class.Zip (Data.Optional.T f) instance (Data.Traversable.Traversable f, Data.NonEmpty.Class.Reverse f) => Data.NonEmpty.Class.Reverse (Data.Optional.T f) instance (Data.NonEmptyPrivate.Insert f, Data.NonEmpty.Class.Sort f) => Data.NonEmpty.Class.Sort (Data.Optional.T f) instance (Data.NonEmptyPrivate.InsertBy f, Data.NonEmpty.Class.SortBy f) => Data.NonEmpty.Class.SortBy (Data.Optional.T f) instance Data.NonEmptyPrivate.Insert f => Data.NonEmptyPrivate.Insert (Data.Optional.T f) instance Data.NonEmptyPrivate.InsertBy f => Data.NonEmptyPrivate.InsertBy (Data.Optional.T f)