rel8-internal
Safe HaskellNone
LanguageHaskell2010

Rel8.Internal.Window

Synopsis

Documentation

newtype Window a b Source #

Window is an applicative functor that represents expressions that contain window functions. window can be used to evaluate these expressions over a particular query.

Constructors

Window (Windows a b) 

Instances

Instances details
ProductProfunctor Window Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

purePP :: b -> Window a b

(****) :: Window a (b -> c) -> Window a b -> Window a c

empty :: Window () ()

(***!) :: Window a b -> Window a' b' -> Window (a, a') (b, b')

Profunctor Window Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

dimap :: (a -> b) -> (c -> d) -> Window b c -> Window a d

lmap :: (a -> b) -> Window b c -> Window a c

rmap :: (b -> c) -> Window a b -> Window a c

(#.) :: forall a b c q. Coercible c b => q b c -> Window a b -> Window a c

(.#) :: forall a b c q. Coercible b a => Window b c -> q a b -> Window a c

Applicative (Window a) Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

pure :: a0 -> Window a a0 #

(<*>) :: Window a (a0 -> b) -> Window a a0 -> Window a b #

liftA2 :: (a0 -> b -> c) -> Window a a0 -> Window a b -> Window a c #

(*>) :: Window a a0 -> Window a b -> Window a b #

(<*) :: Window a a0 -> Window a b -> Window a a0 #

Functor (Window a) Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

fmap :: (a0 -> b) -> Window a a0 -> Window a b #

(<$) :: a0 -> Window a b -> Window a a0 #

Apply (Window a) Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

(<.>) :: Window a (a0 -> b) -> Window a a0 -> Window a b

(.>) :: Window a a0 -> Window a b -> Window a b

(<.) :: Window a a0 -> Window a b -> Window a a0

liftF2 :: (a0 -> b -> c) -> Window a a0 -> Window a b -> Window a c

data Partition a Source #

In PostgreSQL, window functions must specify the "window" or "partition" over which they operate. The syntax for this looks like: SUM(salary) OVER (PARTITION BY department). The Rel8 type Partition represents everything that comes after OVER.

Partition is a Monoid, so Windows created with partitionBy and orderWindowBy can be combined using <>.

Instances

Instances details
Contravariant Partition Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

contramap :: (a' -> a) -> Partition a -> Partition a' #

(>$) :: b -> Partition b -> Partition a #

Monoid (Partition a) Source # 
Instance details

Defined in Rel8.Internal.Window

Semigroup (Partition a) Source # 
Instance details

Defined in Rel8.Internal.Window

Methods

(<>) :: Partition a -> Partition a -> Partition a #

sconcat :: NonEmpty (Partition a) -> Partition a #

stimes :: Integral b => b -> Partition a -> Partition a #

over :: Window a b -> Partition a -> Window a b infixl 1 Source #

over adds a Partition to a Window expression.

  cumulative (sum . salary) over partitionBy department <> orderPartitionBy (salary >$< desc)

partitionBy :: EqTable b => (a -> b) -> Partition a Source #

Restricts a window function to operate only the group of rows that share the same value(s) for the given expression(s).

orderPartitionBy :: Order a -> Partition a Source #

Controls the order in which rows are processed by window functions. This does not need to match the ordering of the overall query.