Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- data NonEmpty a = a :| [a]
- break :: (a -> Bool) -> NonEmpty a -> ([a], [a])
- cons :: a -> NonEmpty a -> NonEmpty a
- cycle :: NonEmpty a -> NonEmpty a
- drop :: Int -> NonEmpty a -> [a]
- dropWhile :: (a -> Bool) -> NonEmpty a -> [a]
- filter :: (a -> Bool) -> NonEmpty a -> [a]
- group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a)
- groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
- groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a)
- groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
- head :: NonEmpty a -> a
- init :: NonEmpty a -> [a]
- intersperse :: a -> NonEmpty a -> NonEmpty a
- isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool
- iterate :: (a -> a) -> a -> NonEmpty a
- last :: NonEmpty a -> a
- map :: (a -> b) -> NonEmpty a -> NonEmpty b
- nonEmpty :: [a] -> Maybe (NonEmpty a)
- nub :: Eq a => NonEmpty a -> NonEmpty a
- nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a
- partition :: (a -> Bool) -> NonEmpty a -> ([a], [a])
- repeat :: a -> NonEmpty a
- reverse :: NonEmpty a -> NonEmpty a
- scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b
- scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
- scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b
- scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
- sort :: Ord a => NonEmpty a -> NonEmpty a
- sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a
- sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a
- span :: (a -> Bool) -> NonEmpty a -> ([a], [a])
- splitAt :: Int -> NonEmpty a -> ([a], [a])
- tail :: NonEmpty a -> [a]
- take :: Int -> NonEmpty a -> [a]
- takeWhile :: (a -> Bool) -> NonEmpty a -> [a]
- transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a)
- uncons :: NonEmpty a -> (a, Maybe (NonEmpty a))
- unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b
- xor :: NonEmpty Bool -> Bool
- zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)
- zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c
Documentation
Non-empty (and non-strict) list type.
Since: base-4.9.0.0
a :| [a] infixr 5 |
Instances
cycle :: NonEmpty a -> NonEmpty a #
returns the infinite repetition of cycle
xsxs
:
cycle (1 :| [2,3]) = 1 :| [2,3,1,2,3,...]
drop :: Int -> NonEmpty a -> [a] #
drops the first drop
n xsn
elements off the front of
the sequence xs
.
filter :: (a -> Bool) -> NonEmpty a -> [a] #
removes any elements from filter
p xsxs
that do not satisfy p
.
groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) #
groupAllWith1
is to groupWith1
as groupAllWith
is to groupWith
groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) #
groupWith1
is to group1
as groupWith
is to group
intersperse :: a -> NonEmpty a -> NonEmpty a #
'intersperse x xs' alternates elements of the list with copies of x
.
intersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3]
isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool #
The isPrefix
function returns True
if the first argument is
a prefix of the second.
iterate :: (a -> a) -> a -> NonEmpty a #
produces the infinite sequence
of repeated applications of iterate
f xf
to x
.
iterate f x = x :| [f x, f (f x), ..]
partition :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #
The partition
function takes a predicate p
and a stream
xs
, and returns a pair of lists. The first list corresponds to the
elements of xs
for which p
holds; the second corresponds to the
elements of xs
for which p
does not hold.
'partition' p xs = ('filter' p xs, 'filter' (not . p) xs)
span :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #
returns the longest prefix of span
p xsxs
that satisfies
p
, together with the remainder of the stream.
'span' p xs == ('takeWhile' p xs, 'dropWhile' p xs) xs == ys ++ zs where (ys, zs) = 'span' p xs
splitAt :: Int -> NonEmpty a -> ([a], [a]) #
returns a pair consisting of the prefix of splitAt
n xsxs
of length n
and the remaining stream immediately following this prefix.
'splitAt' n xs == ('take' n xs, 'drop' n xs) xs == ys ++ zs where (ys, zs) = 'splitAt' n xs
takeWhile :: (a -> Bool) -> NonEmpty a -> [a] #
returns the longest prefix of the stream
takeWhile
p xsxs
for which the predicate p
holds.
uncons :: NonEmpty a -> (a, Maybe (NonEmpty a)) #
uncons
produces the first element of the stream, and a stream of the
remaining elements, if any.