**diff options**

author | OleksandrZhabenko <> | 2020-10-16 16:49:00 (GMT) |
---|---|---|

committer | hdiff <hdiff@hdiff.luite.com> | 2020-10-16 16:49:00 (GMT) |

commit | 74553d1f69911c9d1971a6949a07942959baba62 (patch) | |

tree | 262d8233bded83d12b9063654b574c9076ff05be | |

parent | adfa68116371922a6ccd59743aed2b8b34a4a252 (diff) |

version 0.1.1.10.1.1.1

-rw-r--r-- | CHANGELOG.md | 3 | ||||

-rw-r--r-- | Data/SubG.hs | 21 | ||||

-rw-r--r-- | subG.cabal | 4 |

3 files changed, 22 insertions, 6 deletions

diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c8d18..c8e05a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Data/SubG.hs b/Data/SubG.hs index d8a2a48..89f58d5 100644 --- a/Data/SubG.hs +++ b/Data/SubG.hs @@ -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 @@ instance (Eq a) => InsertLeft [] a where (%^) = (:) -- | 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 +-- 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) +-- 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 +-- 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) @@ -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 |