subG 0.1.1.0 → 0.1.1.1
raw patch · 3 files changed
+22/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +3/−0
- Data/SubG.hs +17/−4
- subG.cabal +2/−2
CHANGELOG.md view
@@ -8,3 +8,6 @@ * First version revised A. Discontinued the support for the GHC-7.8.* series. +## 0.1.1.1 -- 2020-10-16++* First version revised B. Some documentation improvements.
Data/SubG.hs view
@@ -5,8 +5,8 @@ -- Stability : Experimental -- Maintainer : olexandr543@yahoo.com ----- Some extension to the 'F.Foldable' and 'Monoid' classes. Introduces a new class 'InsertLeft' -- the type of values that can be inserted from the left--- to the 'F.Foldable' structure that is simultaneously the 'Monoid' instance.+-- 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. {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} @@ -35,32 +35,45 @@ (%^) = (:) -- | 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.+-- 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 'Prelude.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) subG whspss xs = if F.null ts then mempty else w %^ subG whspss s'' where ts = dropWhile (`F.elem` whspss) xs (w, s'') = span (`F.notElem` whspss) ts +-- | 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, t a) dropWhile' p = F.foldr f v where f x (ys, xs) = (if p x then ys else x %@ xs, x %@ xs) v = (mempty,mempty) +-- | 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 dropWhile p = fst . dropWhile' p +-- | 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) span p = fst . span' p +-- | 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), t a) span' p = F.foldr f v where f x ((ys, zs), xs) = (if p x then (x %@ ys, zs) else (mempty,x %@ xs), x %@ xs) v = ((mempty, mempty), mempty) +-- | 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 takeWhile p = fst . takeWhile' p +-- | 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, t a) takeWhile' p = F.foldr f v where f x (ys,xs) = (if p x then x %@ ys else mempty, x %@ xs)
subG.cabal view
@@ -2,9 +2,9 @@ -- see http://haskell.org/cabal/users-guide/ name: subG-version: 0.1.1.0+version: 0.1.1.1 synopsis: Some extension to the Foldable and Monoid classes.-description: Some extension to the Foldable and Monoid classes. Introduces a new class InsertLeft -- the type of values that can be inserted from the left to the Foldable structure that is also a Monoid.+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. homepage: https://hackage.haskell.org/package/subG license: MIT license-file: LICENSE