Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- data Aggr a b
- aggrConst :: forall a t. (Typeable a, Typeable t) => Closure a -> Aggr t a
- aggrCount :: Typeable a => Aggr a Integer
- aggrSum :: StaticSerialise a => Closure (Dict (Num a)) -> Aggr a a
- aggrMean :: Aggr Double Double
- aggrMax :: StaticSerialise a => Closure (Dict (Ord a)) -> Aggr a (Maybe a)
- aggrMin :: StaticSerialise a => Closure (Dict (Ord a)) -> Aggr a (Maybe a)
- aggrCollect :: StaticSerialise a => Aggr a [a]
- aggrDistinct :: forall a. (StaticSerialise a, StaticHashable a) => Aggr a (HashSet a)
- aggrTopK :: (StaticSerialise a, Typeable k) => Closure (Dict (Ord k)) -> Int -> Closure (a -> k) -> Aggr a [a]
- aggrBottomK :: (StaticSerialise a, Typeable k) => Closure (Dict (Ord k)) -> Int -> Closure (a -> k) -> Aggr a [a]
- aggrFiltered :: Closure (a -> Bool) -> Aggr a b -> Aggr a b
- aggrFromMonoid :: StaticSerialise a => Closure (Dict (Monoid a)) -> Aggr a a
- aggrFromReduce :: StaticSerialise a => Closure (a -> a -> a) -> Aggr a (Maybe a)
- aggrFromFold :: (StaticSerialise t, Typeable a, Typeable b) => Closure (Fold a t) -> Closure (Fold t b) -> Aggr a b

# Documentation

Represent an aggregation which takes many `a`

s and returns a single `b`

.

Use `dAggr`

and `dGroupedAggr`

functions to use them on `Dataset`

s.

You can use the `StaticApply`

and `StaticProfunctor`

instances to compose
`Aggr`

s together. Example:

dAvg :: Aggr Double Double dAvg = aggrConst (static (/)) `staticApply` aggrSum (static Dict) `staticApply` staticMap (static realToFrac) aggrCount

Alternatively, you can use aggrFrom* functions to create `Aggr`

s.

## Instances

StaticProfunctor Aggr # | |

Defined in Control.Distributed.Dataset.Internal.Aggr staticDimap :: (Typeable a, Typeable b, Typeable c, Typeable d) => Closure (a -> b) -> Closure (c -> d) -> Aggr b c -> Aggr a d # staticLmap :: (Typeable a, Typeable b, Typeable c) => Closure (a -> b) -> Aggr b c -> Aggr a c # staticRmap :: (Typeable a, Typeable c, Typeable d) => Closure (c -> d) -> Aggr a c -> Aggr a d # | |

Typeable m => StaticApply (Aggr m) # | |

Defined in Control.Distributed.Dataset.Internal.Aggr | |

Typeable m => StaticFunctor (Aggr m) # | |

aggrConst :: forall a t. (Typeable a, Typeable t) => Closure a -> Aggr t a #

An aggregation which ignores the input data and always yields the given value.

aggrMax :: StaticSerialise a => Closure (Dict (Ord a)) -> Aggr a (Maybe a) #

Return the maximum of the inputs.

Returns `Nothing`

on empty `Dataset`

s.

aggrMin :: StaticSerialise a => Closure (Dict (Ord a)) -> Aggr a (Maybe a) #

Return the minimum of the inputs.

Returns `Nothing`

on empty `Dataset`

s.

aggrCollect :: StaticSerialise a => Aggr a [a] #

Collects the inputs as a list.

Warning: Ordering of the resulting list is non-deterministic.

aggrDistinct :: forall a. (StaticSerialise a, StaticHashable a) => Aggr a (HashSet a) #

Collects the inputs to a `HashSet`

.

:: (StaticSerialise a, Typeable k) | |

=> Closure (Dict (Ord k)) | |

-> Int | Number of rows to return |

-> Closure (a -> k) | Sorting key |

-> Aggr a [a] |

Returns the `n`

greatest elements according to a key function. Similar to:
`take n . sortOn (Down . f)`

Warning: Ordering of the repeated elements is non-deterministic.

:: (StaticSerialise a, Typeable k) | |

=> Closure (Dict (Ord k)) | |

-> Int | Number of rows to return |

-> Closure (a -> k) | Sorting key |

-> Aggr a [a] |

Returns the `n`

least elements according to a key function. Similar to:
`take n . sortOn (Down . f)`

Warning: Ordering of the repeated elements is non-deterministic.

aggrFiltered :: Closure (a -> Bool) -> Aggr a b -> Aggr a b #

Returns a new Aggr which only aggregates rows matching the predicate, discarding others.

# Creating Aggr's

aggrFromMonoid :: StaticSerialise a => Closure (Dict (Monoid a)) -> Aggr a a #

Create an aggregation given a `Monoid`

instance.

aggrFromReduce :: StaticSerialise a => Closure (a -> a -> a) -> Aggr a (Maybe a) #

Create an aggregation given a reduce function.

Returns `Nothing`

on empty `Dataset`

s.