-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell 98 semigroups -- -- Haskell 98 semigroups @package semigroups @version 0.5.0 -- | A NonEmpty list forms a monad as per list, but always contains at -- least one element. module Data.List.NonEmpty data NonEmpty a (:|) :: a -> [a] -> NonEmpty a -- | map a function over a NonEmpty stream map :: (a -> b) -> NonEmpty a -> NonEmpty b intersperse :: a -> NonEmpty a -> NonEmpty a -- | scanl is similar to foldl, but returns a stream of -- successive reduced values from the left: -- --
-- scanl f z [x1, x2, ...] == z :| [z `f` x1, (z `f` x1) `f` x2, ...] ---- -- Note that -- --
-- last (scanl f z xs) == foldl f z xs. --scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b -- | scanr is the right-to-left dual of scanl. Note that -- --
-- head (scanr f z xs) == foldr f z xs. --scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b -- | scanl1 is a variant of scanl that has no starting value -- argument: -- --
-- scanl1 f [x1, x2, ...] == x1 :| [x1 `f` x2, x1 `f` (x2 `f` x3), ...] --scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a -- | scanr1 is a variant of scanr that has no starting value -- argument. scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a -- | Extract the first element of the stream head :: NonEmpty a -> a -- | Extract the possibly empty tail of the stream tail :: NonEmpty a -> [a] -- | Extract the last element of the stream last :: NonEmpty a -> a -- | Extract everything except the last element of the stream init :: NonEmpty a -> [a] -- | cons onto a stream (<|) :: a -> NonEmpty a -> NonEmpty a cons :: a -> NonEmpty a -> NonEmpty a uncons :: NonEmpty a -> (a, Maybe (NonEmpty a)) -- | Sort a stream sort :: Ord a => NonEmpty a -> NonEmpty a -- | reverse a finite NonEmpty reverse :: NonEmpty a -> NonEmpty a -- | The inits function takes a stream xs and returns all -- the finite prefixes of xs. inits :: Foldable f => f a -> NonEmpty [a] -- | The tails function takes a stream xs and returns all -- the suffixes of xs. tails :: Foldable f => f a -> NonEmpty [a] -- | iterate f x produces the infinite sequence of repeated -- applications of f to x. -- --
-- iterate f x = [x, f x, f (f x), ..] --iterate :: (a -> a) -> a -> NonEmpty a -- | repeat x returns a constant stream, where all elements -- are equal to x. repeat :: a -> NonEmpty a -- | cycle xs returns the infinite repetition of -- xs: -- --
-- cycle [1,2,3] = 1 :| [2,3,1,2,3,...] --cycle :: NonEmpty a -> NonEmpty a unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b -- | insert an item into a NonEmpty insert :: Foldable f => Ord a => a -> f a -> NonEmpty a -- | take n xs returns the first n elements of -- xs. -- -- Beware: passing a negative integer as the first argument will -- cause an error. take :: Int -> NonEmpty a -> [a] -- | drop n xs drops the first n elements off the -- front of the sequence xs. -- -- Beware: passing a negative integer as the first argument will -- cause an error. drop :: Int -> NonEmpty a -> [a] -- | splitAt n xs returns a pair consisting of the prefix -- of xs of length n and the remaining stream -- immediately following this prefix. -- -- Beware: passing a negative integer as the first argument will -- cause an error. splitAt :: Int -> NonEmpty a -> ([a], [a]) -- | takeWhile p xs returns the longest prefix of the -- stream xs for which the predicate p holds. takeWhile :: (a -> Bool) -> NonEmpty a -> [a] -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs. dropWhile :: (a -> Bool) -> NonEmpty a -> [a] -- | span p xs returns the longest prefix of -- xs that satisfies p, together with the remainder of -- the stream. span :: (a -> Bool) -> NonEmpty a -> ([a], [a]) -- | The break p function is equivalent to span -- not . p. break :: (a -> Bool) -> NonEmpty a -> ([a], [a]) -- | filter p xs, removes any elements from -- xs that do not satisfy p. filter :: (a -> Bool) -> NonEmpty a -> [a] -- | The partition function takes a predicate p and a -- stream xs, and returns a pair of streams. The first stream -- corresponds to the elements of xs for which p holds; -- the second stream corresponds to the elements of xs for which -- p does not hold. partition :: (a -> Bool) -> NonEmpty a -> ([a], [a]) -- | The group function takes a stream and returns a stream of lists -- such that flattening the resulting stream is equal to the argument. -- Moreover, each sublist in the resulting stream contains only equal -- elements. For example, -- --
-- group $ cycle "Mississippi" = "M" : "i" : "ss" : "i" : "ss" : "i" : "pp" : "i" : "M" : "i" : ... --group :: (Foldable f, Eq a) => f a -> [NonEmpty a] groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) -- | The isPrefix function returns True if the first -- argument is a prefix of the second. isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool -- | xs !! n returns the element of the stream xs at -- index n. Note that the head of the stream has index 0. -- -- Beware: passing a negative integer as the first argument will -- cause an error. (!!) :: NonEmpty a -> Int -> a -- | The zip function takes two streams and returns a list of -- corresponding pairs. zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) -- | The zipWith function generalizes zip. Rather than -- tupling the functions, the elements are combined using the function -- passed as the first argument to zipWith. zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c -- | The unzip function is the inverse of the zip function. unzip :: Functor f => f (a, b) -> (f a, f b) -- | The words function breaks a stream of characters into a stream -- of words, which were delimited by white space. words :: NonEmpty Char -> NonEmpty String -- | The unwords function is an inverse operation to words. -- It joins words with separating spaces. unwords :: NonEmpty String -> NonEmpty Char -- | The lines function breaks a stream of characters into a list of -- strings at newline characters. The resulting strings do not contain -- newlines. lines :: NonEmpty Char -> NonEmpty String -- | The unlines function is an inverse operation to lines. -- It joins lines, after appending a terminating newline to each. unlines :: NonEmpty String -> NonEmpty Char -- | Converts an non-empty list to a stream. fromList :: [a] -> NonEmpty a -- | Convert a stream to a list efficiently toList :: NonEmpty a -> [a] nonEmpty :: [a] -> Maybe (NonEmpty a) instance Typeable1 NonEmpty instance Eq a => Eq (NonEmpty a) instance Ord a => Ord (NonEmpty a) instance Show a => Show (NonEmpty a) instance Read a => Read (NonEmpty a) instance Data a => Data (NonEmpty a) instance Foldable NonEmpty instance Traversable NonEmpty instance Monad NonEmpty instance Applicative NonEmpty instance Functor NonEmpty module Data.Semigroup class Semigroup a (<>) :: Semigroup a => a -> a -> a sconcat :: Semigroup a => NonEmpty a -> a newtype Min a Min :: a -> Min a getMin :: Min a -> a newtype Max a Max :: a -> Max a getMax :: Max a -> a -- | Use Option (First a) -- to get the behavior of -- Data.Monoid.First newtype First a First :: a -> First a getFirst :: First a -> a -- | Use Option (Last a) -- to get the behavior of -- Data.Monoid.Last newtype Last a Last :: a -> Last a getLast :: Last a -> a newtype WrappedMonoid m WrapMonoid :: m -> WrappedMonoid m unwrapMonoid :: WrappedMonoid m -> m -- | The dual of a monoid, obtained by swapping the arguments of -- mappend. newtype Dual a :: * -> * Dual :: a -> Dual a getDual :: Dual a -> a -- | The monoid of endomorphisms under composition. newtype Endo a :: * -> * Endo :: (a -> a) -> Endo a appEndo :: Endo a -> a -> a -- | Boolean monoid under conjunction. newtype All :: * All :: Bool -> All getAll :: All -> Bool -- | Boolean monoid under disjunction. newtype Any :: * Any :: Bool -> Any getAny :: Any -> Bool -- | Monoid under addition. newtype Sum a :: * -> * Sum :: a -> Sum a getSum :: Sum a -> a -- | Monoid under multiplication. newtype Product a :: * -> * Product :: a -> Product a getProduct :: Product a -> a -- | Option is effectively Maybe with a better instance of -- Monoid, built off of an underlying Semigroup instead of -- an underlying Monoid. Ideally, this type would not exist at all -- and we would just fix the Monoid intance of Maybe newtype Option a Option :: Maybe a -> Option a getOption :: Option a -> Maybe a option :: b -> (a -> b) -> Option a -> b -- | This lets you use a difference list of a Semigroup as a Monoid. diff :: Semigroup m => m -> Endo m instance Typeable1 Min instance Typeable1 Max instance Typeable1 First instance Typeable1 Last instance Typeable1 WrappedMonoid instance Typeable1 Option instance Eq a => Eq (Min a) instance Ord a => Ord (Min a) instance Bounded a => Bounded (Min a) instance Show a => Show (Min a) instance Read a => Read (Min a) instance Data a => Data (Min a) instance Eq a => Eq (Max a) instance Ord a => Ord (Max a) instance Bounded a => Bounded (Max a) instance Show a => Show (Max a) instance Read a => Read (Max a) instance Data a => Data (Max a) instance Eq a => Eq (First a) instance Ord a => Ord (First a) instance Bounded a => Bounded (First a) instance Show a => Show (First a) instance Read a => Read (First a) instance Data a => Data (First a) instance Eq a => Eq (Last a) instance Ord a => Ord (Last a) instance Bounded a => Bounded (Last a) instance Show a => Show (Last a) instance Read a => Read (Last a) instance Data a => Data (Last a) instance Eq m => Eq (WrappedMonoid m) instance Ord m => Ord (WrappedMonoid m) instance Bounded m => Bounded (WrappedMonoid m) instance Show m => Show (WrappedMonoid m) instance Read m => Read (WrappedMonoid m) instance Data m => Data (WrappedMonoid m) instance Eq a => Eq (Option a) instance Ord a => Ord (Option a) instance Show a => Show (Option a) instance Read a => Read (Option a) instance Data a => Data (Option a) instance Ord k => Semigroup (Map k v) instance Semigroup (IntMap v) instance Ord a => Semigroup (Set a) instance Semigroup IntSet instance Semigroup (Seq a) instance Semigroup a => Monoid (Option a) instance Semigroup a => Semigroup (Option a) instance Traversable Option instance Foldable Option instance MonadFix Option instance MonadPlus Option instance Alternative Option instance Monad Option instance Applicative Option instance Functor Option instance Monoid m => Monoid (WrappedMonoid m) instance Monoid m => Semigroup (WrappedMonoid m) instance Semigroup (Last a) instance Semigroup (First a) instance (Ord a, Bounded a) => Monoid (Max a) instance Ord a => Semigroup (Max a) instance (Ord a, Bounded a) => Monoid (Min a) instance Ord a => Semigroup (Min a) instance Semigroup (NonEmpty a) instance Semigroup (Last a) instance Semigroup (First a) instance Num a => Semigroup (Product a) instance Num a => Semigroup (Sum a) instance Semigroup Any instance Semigroup All instance Semigroup (Endo a) instance Semigroup a => Semigroup (Dual a) instance (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) instance (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) instance (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) instance (Semigroup a, Semigroup b) => Semigroup (a, b) instance Semigroup (Either a b) instance Semigroup a => Semigroup (Maybe a) instance Semigroup [a] instance Semigroup b => Semigroup (a -> b)