subG-0.6.1.0: Some extension to the Foldable and Monoid classes.
Copyright(c) OleksandrZhabenko 2021-2023
LicenseMIT
Maintaineroleksandr.zhabenko@yahoo.com
StabilityExperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.SubG.Unfold

Description

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.

Synopsis

Documentation

unfoldG :: (InsertLeft t a, Monoid (t a)) => (b -> Maybe (a, b)) -> b -> t a Source #

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.

iterateG :: (InsertLeft t a, Monoid (t a)) => (a -> a) -> a -> t a Source #

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.