subG 0.6.0.0 → 0.6.1.0
raw patch · 3 files changed
+29/−14 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- Data/SubG.hs +22/−13
- subG.cabal +1/−1
CHANGELOG.md view
@@ -61,3 +61,9 @@ * Sixth version. Switched to NoImplicitPrelude extension. Updated dependencies boundaries. Some metadata improvements. +## 0.6.1.0 -- 2023-01-25++* Sixth version revised A. Done additional testing according to the advice for foldl package. +For performance reasons some functions were moved to the not recommended ones' section.+Some documentation improvements.+
Data/SubG.hs view
@@ -6,34 +6,37 @@ -- Maintainer : oleksandr.zhabenko@yahoo.com -- -- Some extension to the 'F.Foldable' and 'Monoid' classes. Introduces a new class 'InsertLeft' -- the class of types of values that can be inserted from the left--- to the 'F.Foldable' structure that is simultaneously the data that is also the 'Monoid' instance.+-- to the 'F.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. {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, NoImplicitPrelude #-} module Data.SubG ( InsertLeft(..) , subG- , takeG , takeFromEndG- , reverseTakeG , reverseTakeFromEndG- , dropG , dropFromEndG- , reverseDropG , reverseDropFromEndG , takeWhile , dropWhile , span- , splitAtG , splitAtEndG , preAppend , safeHeadG- , safeTailG , safeInitG , safeLastG , mapG , filterG , partitionG+ -- * Not recommended for performance reasons, provided if there is no other acceptable possibilities (as fallback placeholders)+ , reverseTakeG+ , takeG+ , reverseDropG+ , dropG+ , splitAtG+ , safeTailG ) where import GHC.Base@@ -129,7 +132,8 @@ -- | 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 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 reverseTakeG n = (\(xs,_,_) -> xs) . F.foldl' f v where v = (mempty,0,n)@@ -139,7 +143,8 @@ -- | 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.+-- 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 takeG n = (\(xs,_,_) -> xs) . F.foldl' f v where v = (mempty,0,n)@@ -150,7 +155,8 @@ -- | 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.+-- 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 reverseDropG n = (\(xs,_,_) -> xs) . F.foldl' f v where v = (mempty,0,n)@@ -180,7 +186,8 @@ -- | 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.+-- 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 dropG n = (\(xs,_,_) -> xs) . F.foldl' f v where v = (mempty,0,n)@@ -190,7 +197,8 @@ -- | 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.+-- 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) splitAtG n = (\(x,y,_,_) -> (x,y)) . F.foldl' f v where v = (mempty,mempty,0,n)@@ -212,7 +220,8 @@ safeHeadG = F.find (const True) -- | If the structure is empty, just returns itself. Uses strict variant of the foldl, so is--- strict and the data must be finite.+-- 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 safeTailG = dropG 1
subG.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: subG-version: 0.6.0.0+version: 0.6.1.0 synopsis: Some extension to the Foldable and Monoid classes. description: 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. homepage: https://hackage.haskell.org/package/subG