Cabal-1.22.5.0: A framework for packaging Haskell software

Safe Haskell | None
Language | Haskell98

Distribution.Utils.NubList

Synopsis

- data NubList a
- toNubList :: Ord a => [a] -> NubList a
- fromNubList :: NubList a -> [a]
- overNubList :: Ord a => ([a] -> [a]) -> NubList a -> NubList a
- data NubListR a
- toNubListR :: Ord a => [a] -> NubListR a
- fromNubListR :: NubListR a -> [a]
- overNubListR :: Ord a => ([a] -> [a]) -> NubListR a -> NubListR a

# Documentation

data NubList a

NubList : A de-duplicated list that maintains the original order.

Instances

Eq a => Eq (NubList a) |
(Ord a, Read a) => Read (NubList a) |
Show a => Show (NubList a) |

Ord a => Monoid (NubList a)

Monoid operations on NubLists. For a valid Monoid instance we need to satistfy the required monoid laws; identity, associativity and closure.

Identity : by inspection: mempty `mappend` NubList xs == NubList xs `mappend` mempty

Associativity : by inspection: (NubList xs `mappend` NubList ys) `mappend` NubList zs == NubList xs `mappend` (NubList ys `mappend` NubList zs)

Closure : appending two lists of type a and removing duplicates obviously does not change the type.

(Ord a, Binary a) => Binary (NubList a) | Binary instance for 'NubList a' is the same as for '[a]'. For `put`, we just pull off constructor and put the list. For `get`, we get the list and make a `NubList` out of it using `toNubList`.

toNubList :: Ord a => [a] -> NubList a

Smart constructor for the NubList type.

fromNubList :: NubList a -> [a]

overNubList :: Ord a => ([a] -> [a]) -> NubList a -> NubList a

Lift a function over lists to a function over NubLists.

data NubListR a

NubListR : A right-biased version of `NubList`. That is `toNubListR ["-XNoFoo", "-XFoo", "-XNoFoo"]` will result in `["-XFoo", "-XNoFoo"]`, unlike the normal `NubList`, which is left-biased. Built on top of `ordNubRight` and `listUnionRight`.

Instances

Eq a => Eq (NubListR a) |
(Ord a, Read a) => Read (NubListR a) |
Show a => Show (NubListR a) |
Ord a => Monoid (NubListR a) |

toNubListR :: Ord a => [a] -> NubListR a

Smart constructor for the NubListR type.

fromNubListR :: NubListR a -> [a]

overNubListR :: Ord a => ([a] -> [a]) -> NubListR a -> NubListR a

Lift a function over lists to a function over NubListRs.