# List

List is an aggregate.

[] ++ ys = ys (x:xs) ++ ys = x : (xs ++ ys)

instance Semigroup [a] where (<>) = (++)

instance Monoid [a] where mempty = [] mconcat xss = [x | xs <- xss, x <- xs]

foldr k z = go where go [] = z go (y:ys) = y `k` go ys

xs ++ ys = foldr (:) ys xs

## Mapping

The notion of mapping is abstracted out transformation. A function is a particular kind of mapping from one value to another.

The notion of a *Mappable* type is generalized as Functor

instance Functor [] where fmap = map

where

map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (x:xs) = f x : map f xs

Last modified
3 years ago
Last modified on Apr 4, 2018, 3:15:27 PM

**Note:**See TracWiki for help on using the wiki.