1{-# language MonoLocalBinds #-}
3module Rel8.Table.Window
14import qualified Opaleye.Window as Opaleye
17import Rel8.Aggregate ( Aggregates )
18import qualified Rel8.Expr.Window as Expr
19import Rel8.Schema.HTable ( hfield, htabulateA )
20import Rel8.Table ( fromColumns, toColumns )
21import Rel8.Window ( Window( Window ) )
24-- | 'cumulative' allows the use of aggregation functions in 'Window'
25-- expressions. In particular, @'cumulative' 'Rel8.sum'@
26-- (when combined with 'Rel8.Window.orderPartitionBy') gives a running total,
27-- also known as a \"cumulative sum\", hence the name @cumulative@.
28cumulative :: Aggregates aggregates exprs => (a -> aggregates) -> Window a exprs
31 htabulateA $ \field ->
32 Expr.cumulative ((`hfield` field) . toColumns . f)
35-- | A version of 'cumulative' for use with nullary aggregators like
36-- 'Rel8.Expr.Aggregate.countStar'.
37cumulative_ :: Aggregates aggregates exprs => aggregates -> Window a exprs
38cumulative_ = cumulative . const
41-- | Return every column of the current row of a window query.
42currentRow :: Window a a
43currentRow = Window $ Opaleye.over (Opaleye.noWindowFunction id) mempty mempty
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list