-- 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. Is a fork of the -- https://hackage.haskell.org/package/subG. @package monoid-insertleft @version 0.1.0.1 -- | 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. For lists as instances of InsertLeft -- and Monoid just use the basic library functions from GHC.List -- or Data.List modules where possible. Is a fork of -- https://hackage.haskell.org/package/subG-0.6.1.0. module Data.InsertLeft -- | Some extension to the Foldable and Monoid classes. class (Foldable t, Eq a, Eq t a) => InsertLeft (t :: Type -> Type) 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. 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. 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. 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. 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. 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. 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) -- | 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. Not recommended for performance reasons. For -- lists just use the combination (reverse . take n). 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. Uses strict variant -- of the foldl, so is strict and the data must be finite. Not -- recommended for performance reasons. For lists just use GHC.List.take -- n. 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. 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. Not recommended for performance reasons. For -- lists just use @ (reverse . drop n) combination. 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. Uses strict variant -- of the foldl, so is strict and the data must be finite. Not -- recommended for performance reasons. For lists just use the -- GHC.List.drop. 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. Uses strict variant -- of the foldl, so is strict and the data must be finite. Not -- recommended for performance reasons. For lists just use the -- GHC.List.splitAt. splitAtG :: (Integral b, InsertLeft t a, Monoid (t a)) => b -> t a -> (t a, t a) -- | If the structure is empty, just returns itself. Uses strict variant of -- the foldl, so is strict and the data must be finite. Not recommended -- for performance reasons. For lists just use Data.List.tail or -- something equivalent. safeTailG :: (InsertLeft t a, Monoid (t a)) => t a -> t a instance GHC.Classes.Eq a => Data.InsertLeft.InsertLeft [] 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. Is a fork of -- https://hackage.haskell.org/package/subG-0.6.1.0 module Data.InsertLeft.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