packages feed

subG 0.5.3.0 → 0.6.1.0

raw patch · 9 files changed

Files

CHANGELOG.md view
@@ -55,3 +55,15 @@ ## 0.5.3.0 -- 2022-03-24  * Fifth version revised C. Updated the dependency boundaries to support the latest GHC and Cabal versions.++## 0.6.0.0 -- 2023-01-24++* 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/MinMax.hs view
@@ -1,15 +1,17 @@ -- | -- Module      :  Data.MinMax--- Copyright   :  (c) OleksandrZhabenko 2020+-- Copyright   :  (c) OleksandrZhabenko 2020-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- Maintainer  :  oleksandr.zhabenko@yahoo.com -- -- Functions to find both minimum and maximum elements of the 'F.Foldable' structure of the 'Ord'ered elements. +{-# LANGUAGE NoImplicitPrelude #-}+ module Data.MinMax where -import Prelude hiding (takeWhile,dropWhile,span)+import GHC.Base import Data.SubG import qualified Data.Foldable as F import qualified Data.List as L (sortBy)
Data/MinMax/Preconditions.hs view
@@ -1,16 +1,18 @@ -- | -- Module      :  Data.MinMax.Preconditions--- Copyright   :  (c) OleksandrZhabenko 2020+-- Copyright   :  (c) OleksandrZhabenko 2020-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- Maintainer  :  oleksandr.zhabenko@yahoo.com -- -- Functions to find both minimum and maximum elements of the 'F.Foldable' structure of the 'Ord'ered 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). +{-# LANGUAGE NoImplicitPrelude #-}+ module Data.MinMax.Preconditions where -import Prelude hiding (takeWhile,dropWhile,span)+import GHC.Base import Data.SubG import qualified Data.Foldable as F import qualified Data.List as L (sortBy)
Data/MinMax3Plus.hs view
@@ -1,15 +1,17 @@ -- | -- Module      :  Data.MinMax3Plus--- Copyright   :  (c) OleksandrZhabenko 2020+-- Copyright   :  (c) OleksandrZhabenko 2020-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- Maintainer  :  oleksandr.zhabenko@yahoo.com -- -- Functions to find both minimum and maximum elements of the 'F.Foldable' structure of the 'Ord'ered elements. +{-# LANGUAGE NoImplicitPrelude #-}+ module Data.MinMax3Plus where -import Prelude hiding (takeWhile,dropWhile,span)+import GHC.Base import Data.SubG import qualified Data.Foldable as F import qualified Data.List as L (sortBy)
Data/MinMax3Plus/Preconditions.hs view
@@ -1,16 +1,18 @@ -- | -- Module      :  Data.MinMax3Plus.Preconditions--- Copyright   :  (c) OleksandrZhabenko 2020+-- Copyright   :  (c) OleksandrZhabenko 2020-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- Maintainer  :  oleksandr.zhabenko@yahoo.com -- -- Functions to find both minimum and maximum elements of the 'F.Foldable' structure of the 'Ord'ered 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). +{-# LANGUAGE NoImplicitPrelude #-}+ module Data.MinMax3Plus.Preconditions where -import Prelude hiding (takeWhile,dropWhile,span)+import GHC.Base import Data.SubG import qualified Data.Foldable as F import qualified Data.List as L (sortBy)
Data/SubG.hs view
@@ -1,42 +1,48 @@ -- | -- Module      :  Data.SubG--- Copyright   :  (c) OleksandrZhabenko 2020+-- Copyright   :  (c) OleksandrZhabenko 2020-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- 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 #-}+{-# 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 Prelude hiding (dropWhile, span, takeWhile)+import GHC.Base+import GHC.Num+import GHC.Real+import Data.Tuple import qualified Data.Foldable as F import Data.Monoid @@ -126,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)@@ -136,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)@@ -147,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)@@ -177,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)@@ -187,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)@@ -205,11 +216,12 @@         | otherwise = (zs,x %@ ts,k + 1,n)  -- | If a structure is empty, just returns 'Nothing'.-safeHeadG :: (Foldable t) => t a -> Maybe a+safeHeadG :: (F.Foldable t) => t a -> Maybe a 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 
Data/SubG/Unfold.hs view
@@ -1,18 +1,21 @@ -- | -- Module      :  Data.SubG.Unfold--- Copyright   :  (c) OleksandrZhabenko 2021+-- Copyright   :  (c) OleksandrZhabenko 2021-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- Maintainer  :  oleksandr.zhabenko@yahoo.com -- -- Generalization of the 'Data.List.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. +{-# LANGUAGE NoImplicitPrelude #-}+ module Data.SubG.Unfold (   unfoldG   , iterateG ) where +import GHC.Base import Data.SubG import Data.Monoid 
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020-2021 OleksandrZhabenko+Copyright (c) 2020-2023 Oleksandr Zhabenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
subG.cabal view
@@ -2,14 +2,14 @@ -- see http://haskell.org/cabal/users-guide/  name:                subG-version:             0.5.3.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.+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 license:             MIT license-file:        LICENSE author:              OleksandrZhabenko-maintainer:          olexandr543@yahoo.com+maintainer:          oleksandr.zhabenko@yahoo.com copyright:           Oleksandr Zhabenko category:            Data, Development build-type:          Simple@@ -19,7 +19,7 @@ library   exposed-modules:     Data.SubG, Data.SubG.Unfold, Data.MinMax, Data.MinMax3Plus, Data.MinMax.Preconditions, Data.MinMax3Plus.Preconditions   -- other-modules:-  other-extensions:    MultiParamTypeClasses, FlexibleInstances-  build-depends:       base >=4.8 && <5+  other-extensions:    MultiParamTypeClasses, FlexibleInstances, NoImplicitPrelude+  build-depends:       base >=4.13 && <5   -- hs-source-dirs:   default-language:    Haskell2010