-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Some extension to the Foldable and Monoid classes.
--
-- Introduces a new class InsertLeft -- the class of types of values that
-- can be inserted from the left to the Foldable structure that is a data
-- that is also the Monoid instance. Also contains some functions to find
-- out both minimum and maximum elements of the finite Foldable
-- structures.
@package subG
@version 0.5.3.0
-- | Some extension to the Foldable and Monoid classes.
-- Introduces a new class InsertLeft -- the class of types of
-- values that can be inserted from the left to the Foldable
-- structure that is simultaneously the data that is also the
-- Monoid instance.
module Data.SubG
-- | Some extension to the Foldable and Monoid classes.
class (Foldable t, Eq a, Eq (t a)) => InsertLeft t a
(%@) :: InsertLeft t a => a -> t a -> t a
(%^) :: InsertLeft t a => t a -> t (t a) -> t (t a)
infixr 1 %@
infixr 1 %^
-- | Inspired by:
-- https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.OldList.html#words
-- and: Graham Hutton. A tutorial on the universality and expressiveness
-- of fold. J. Functional Programming 9 (4): 355–372, July 1999.
-- that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Is similar to the
-- words but operates on more general structures an allows more
-- control.
subG :: (InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a -> t a -> t (t a)
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Uses strict variant
-- of the foldl, so is strict and the data must be finite.
takeG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Takes the first
-- argument quantity from the right end of the structure preserving the
-- order.
takeFromEndG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Is analogous to the
-- taking the specified quantity from the structure and then reversing
-- the result. Uses strict variant of the foldl, so is not suitable for
-- large amounts of data.
reverseTakeG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Takes the specified
-- quantity from the right end of the structure and then reverses the
-- result.
reverseTakeFromEndG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Uses strict variant
-- of the foldl, so is strict and the data must be finite.
dropG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Drops the first
-- argument quantity from the right end of the structure and returns the
-- result preserving the order.
dropFromEndG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Is analogous to the
-- dropping the specified quantity from the structure and then reversing
-- the result. Uses strict variant of the foldl, so is strict and the
-- data must be finite.
reverseDropG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Drops the specified
-- quantity from the right end of the structure and then reverses the
-- result.
reverseDropFromEndG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf.
takeWhile :: (InsertLeft t a, Monoid (t a)) => (a -> Bool) -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf.
dropWhile :: (InsertLeft t a, Monoid (t a)) => (a -> Bool) -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf.
span :: (InsertLeft t a, Monoid (t a)) => (a -> Bool) -> t a -> (t a, t a)
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Uses strict variant
-- of the foldl, so is strict and the data must be finite.
splitAtG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> (t a, t a)
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Splits the
-- structure starting from the end and preserves the order.
splitAtEndG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> (t a, t a)
-- | Prepends and appends the given two first arguments to the third one.
preAppend :: (InsertLeft t a, Monoid (t (t a))) => t a -> t (t a) -> t (t a) -> t (t a)
-- | If a structure is empty, just returns Nothing.
safeHeadG :: Foldable t => t a -> Maybe a
-- | If the structure is empty, just returns itself. Uses strict variant of
-- the foldl, so is strict and the data must be finite.
safeTailG :: (InsertLeft t a, Monoid (t a)) => t a -> t a
-- | If the structure is empty, just returns itself.
safeInitG :: (InsertLeft t a, Monoid (t a)) => t a -> t a
-- | If the structure is empty, just returns Nothing.
safeLastG :: (InsertLeft t a, Monoid (t a)) => t a -> Maybe a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Acts similarly to
-- the map function from Prelude.
mapG :: (InsertLeft t b, Monoid (t b)) => (a -> b) -> t a -> t b
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Acts similarly to
-- filter function from Prelude.
filterG :: (InsertLeft t a, Monoid (t a)) => (a -> Bool) -> t a -> t a
-- | Inspired by: Graham Hutton. A tutorial on the universality and
-- expressiveness of fold. J. Functional Programming 9 (4):
-- 355–372, July 1999. that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Acts similarly to
-- partition function from Data.List. Practically is a rewritten
-- for more general variants function partition from
-- https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.OldList.html#partition
partitionG :: (InsertLeft t a, Monoid (t a)) => (a -> Bool) -> t a -> (t a, t a)
instance GHC.Classes.Eq a => Data.SubG.InsertLeft [] a
-- | Functions to find both minimum and maximum elements of the
-- Foldable structure of the Ordered elements. With the
-- preconditions that the structure at least have enough elements (this
-- is contrary to the functions from the module Data.MinMax not checked
-- internally).
module Data.MinMax3Plus.Preconditions
-- | Given a finite structure returns a tuple with two minimum elements and
-- three maximum elements. Uses just two passes through the structure, so
-- may be more efficient than some other approaches.
minMax23C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a), (a, a, a))
-- | A variant of the minMax23C where you can specify your own
-- comparison function.
minMax23ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a), (a, a, a))
-- | Given a finite structure returns a tuple with three minimum elements
-- and two maximum elements. Uses just two passes through the structure,
-- so may be more efficient than some other approaches.
minMax32C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a, a), (a, a))
-- | A variant of the minMax32C where you can specify your own
-- comparison function.
minMax32ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a, a), (a, a))
-- | Given a finite structure returns a tuple with three minimum elements
-- and three maximum elements. Uses just two passes through the
-- structure, so may be more efficient than some other approaches.
minMax33C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a, a), (a, a, a))
-- | A variant of the minMax33C where you can specify your own
-- comparison function.
minMax33ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a, a), (a, a, a))
-- | Functions to find both minimum and maximum elements of the
-- Foldable structure of the Ordered elements.
module Data.MinMax3Plus
-- | Given a finite structure returns a tuple with two minimum elements and
-- three maximum elements. Uses just three passes through the structure,
-- so may be more efficient than some other approaches.
minMax23 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a), (a, a, a))
-- | A variant of the minMax23 where you can specify your own
-- comparison function.
minMax23By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a), (a, a, a))
-- | Given a finite structure returns a tuple with three minimum elements
-- and two maximum elements. Uses just three passes through the
-- structure, so may be more efficient than some other approaches.
minMax32 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a, a), (a, a))
-- | A variant of the minMax32 where you can specify your own
-- comparison function.
minMax32By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a, a), (a, a))
-- | Given a finite structure returns a tuple with three minimum elements
-- and three maximum elements. Uses just three passes through the
-- structure, so may be more efficient than some other approaches.
minMax33 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a, a), (a, a, a))
-- | A variant of the minMax33 where you can specify your own
-- comparison function.
minMax33By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a, a), (a, a, a))
-- | Functions to find both minimum and maximum elements of the
-- Foldable structure of the Ordered elements. With the
-- preconditions that the structure at least have enough elements (this
-- is contrary to the functions from the module Data.MinMax not checked
-- internally).
module Data.MinMax.Preconditions
-- | Finds out the minimum and maximum values of the finite structure that
-- has not less than two elements.
minMax11C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> (a, a)
-- | A generalized variant of the minMax where you can specify
-- your own comparison function.
minMax11ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> (a, a)
-- | Given a finite structure returns a tuple with the two most minimum
-- elements (the first one is less than the second one) and the maximum
-- element. Uses just two passes through the structure, so may be more
-- efficient than some other approaches.
minMax21C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a), a)
-- | A variant of the minMax21C where you can specify your own
-- comparison function.
minMax21ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a), a)
-- | Given a finite structure returns a tuple with the minimum element and
-- two maximum elements (the first one is less than the second one). Uses
-- just two passes through the structure, so may be more efficient than
-- some other approaches.
minMax12C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> (a, (a, a))
-- | A variant of the minMax12C where you can specify your own
-- comparison function.
minMax12ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> (a, (a, a))
-- | Given a finite structure returns a tuple with two minimum elements and
-- two maximum elements. Uses just two passes through the structure, so
-- may be more efficient than some other approaches.
minMax22C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a), (a, a))
-- | A variant of the minMax22C where you can specify your own
-- comparison function.
minMax22ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a), (a, a))
-- | Functions to find both minimum and maximum elements of the
-- Foldable structure of the Ordered elements.
module Data.MinMax
-- | Returns a pair where the first element is the minimum element from the
-- two given ones and the second one is the maximum. If the arguments are
-- equal then the tuple contains equal elements.
minmaxP :: Ord a => a -> a -> (a, a)
-- | A variant of the minmaxP where you can specify your own
-- comparison function.
minmaxPBy :: Ord a => (a -> a -> Ordering) -> a -> a -> (a, a)
-- | A ternary predicate to check whether the third argument lies between
-- the first two unequal ones or whether they are all equal.
betweenNX :: Ord a => a -> a -> a -> Bool
-- | A variant of the betweenNX where you can specify your own
-- comparison function.
betweenNXBy :: Ord a => (a -> a -> Ordering) -> a -> a -> a -> Bool
-- | Finds out the minimum and maximum values of the finite structure that
-- has not less than two elements. Otherwise returns Nothing.
minMax11 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> Maybe (a, a)
-- | A generalized variant of the minMax11 where you can specify
-- your own comparison function.
minMax11By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> Maybe (a, a)
-- | Given a finite structure with at least 3 elements returns a tuple with
-- the two most minimum elements (the first one is less than the second
-- one) and the maximum element. If the structure has less elements,
-- returns Nothing. Uses just three passes through the structure,
-- so may be more efficient than some other approaches.
minMax21 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> Maybe ((a, a), a)
-- | A variant of the minMax21 where you can specify your own
-- comparison function.
minMax21By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> Maybe ((a, a), a)
-- | Given a finite structure with at least 3 elements returns a tuple with
-- the minimum element and two maximum elements (the first one is less
-- than the second one). If the structure has less elements, returns
-- Nothing. Uses just three passes through the structure, so may
-- be more efficient than some other approaches.
minMax12 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> Maybe (a, (a, a))
-- | A variant of the minMax12 where you can specify your own
-- comparison function.
minMax12By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> Maybe (a, (a, a))
-- | Given a finite structure with at least 4 elements returns a tuple with
-- two minimum elements and two maximum elements. If the structure has
-- less elements, returns Nothing. Uses just three passes through
-- the structure, so may be more efficient than some other approaches.
minMax22 :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> Maybe ((a, a), (a, a))
-- | A variant of the minMax22 where you can specify your own
-- comparison function.
minMax22By :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> Maybe ((a, a), (a, a))
-- | Generalization of the unfoldr for the data type that has
-- InsertLeft and Monoid instances. Inspired by:
-- https://www.works-hub.com/learn/number-anamorphisms-aka-unfolds-explained-50e1a
-- by Marty Stumpf.
module Data.SubG.Unfold
-- | Inspired by:
-- https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.OldList.html#words
-- and: Graham Hutton. A tutorial on the universality and expressiveness
-- of fold. J. Functional Programming 9 (4): 355–372, July 1999.
-- that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Also inspired by:
-- https://www.works-hub.com/learn/number-anamorphisms-aka-unfolds-explained-50e1a
-- by Marty Stumpf. Generalizes the unfoldr function not only for
-- lists, but for the data type that has InsertLeft and
-- Monoid instances.
unfoldG :: (InsertLeft t a, Monoid (t a)) => (b -> Maybe (a, b)) -> b -> t a
-- | Inspired by:
-- https://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.OldList.html#words
-- and: Graham Hutton. A tutorial on the universality and expressiveness
-- of fold. J. Functional Programming 9 (4): 355–372, July 1999.
-- that is available at the URL:
-- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf. Also inspired by:
-- https://www.works-hub.com/learn/number-anamorphisms-aka-unfolds-explained-50e1a
-- by Marty Stumpf. Generalizes the iterate function not only for
-- lists, but for the data type that has InsertLeft and
-- Monoid instances.
iterateG :: (InsertLeft t a, Monoid (t a)) => (a -> a) -> a -> t a