fmlist-0.4: FoldMap lists

Portabilityportable
Stabilityexperimental
Maintainersjoerd

Data.FMList

Contents

Description

FoldMap lists: lists represented by their foldMap function.

Synopsis

Documentation

newtype FMList a Source

FMList is a foldMap function wrapped up in a newtype. Examples:

 -- A right-infinite list
 c = 1 `cons` c
 -- A left-infinite list
 d = d `snoc` 2
 -- A middle-infinite list ??
 e = c `append` d
 *> head e
 1
 *> last e
 2

Constructors

FM 

Fields

unFM :: forall b. Monoid b => (a -> b) -> b
 

transform :: (forall b. Monoid b => (a -> b) -> c -> b) -> FMList c -> FMList aSource

Transform transforms a list by changing the map function that is passed to foldMap. It has the following property:

transform a . transform b = transform (b . a)

For example:

  •   m >>= g
  • = flatten (fmap g m)
  • = flatten . fmap g $ m
  • = transform foldMap . transform (. g) $ m
  • = transform ((. g) . foldMap) m
  • = transform (\f -> foldMap f . g) m

Construction

empty :: Alternative f => forall a. f a

The identity of <|>

cons :: a -> FMList a -> FMList aSource

snoc :: FMList a -> a -> FMList aSource

toList :: Foldable t => t a -> [a]

List of elements of a structure.

Basic functions

head :: FMList a -> aSource

last :: FMList a -> aSource

Folding

filter :: (a -> Bool) -> FMList a -> FMList aSource

take :: (Ord n, Num n) => n -> FMList a -> FMList aSource

drop :: (Ord n, Num n) => n -> FMList a -> FMList aSource

takeWhile :: (a -> Bool) -> FMList a -> FMList aSource

dropWhile :: (a -> Bool) -> FMList a -> FMList aSource

zip :: FMList a -> FMList b -> FMList (a, b)Source

zipWith :: (a -> b -> c) -> FMList a -> FMList b -> FMList cSource

Unfolding

iterate :: (a -> a) -> a -> FMList aSource

unfoldr :: (b -> Maybe (a, b)) -> b -> FMList aSource

unfoldl :: (b -> Maybe (b, a)) -> b -> FMList aSource