relational-query-0.5.1.1: Typeful, Modular, Relational, algebraic query engine

Copyright2013 Kei Hibino
LicenseBSD3
Maintainerex8k.hibino@gmail.com
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Database.Relational.Query.ProjectableExtended

Contents

Description

This module defines operators on various polymorphic projections which needs extended GHC features.

Synopsis

Projection for nested Maybes

class ProjectableFlattenMaybe a b where Source

Interface to compose phantom Maybe nested type.

Methods

flatten :: ProjectableMaybe p => p a -> p b Source

Instances

ProjectableFlattenMaybe (Maybe a) b => ProjectableFlattenMaybe (Maybe (Maybe a)) b

Compose Maybe type in projection phantom type.

ProjectableFlattenMaybe (Maybe a) (Maybe a)

Not Maybe type is not processed.

flattenPiMaybe Source

Arguments

:: (ProjectableMaybe (Projection cont), ProjectableFlattenMaybe (Maybe b) c) 
=> Projection cont (Maybe a)

Source Projection. Maybe phantom type

-> Pi a b

Projection path

-> Projection cont c

Narrower Projection. Flatten Maybe phantom type

Get narrower projection with flatten leaf phantom Maybe types along with projection path.

Get narrower projections

(!) infixl 8 Source

Arguments

:: Projectable Projection p 
=> Projection c a

Source projection

-> Pi a b

Projection path

-> p c b

Narrower projected object

Get narrower projection along with projection path and project into result projection type.

(?!) infixl 8 Source

Arguments

:: Projectable Projection p 
=> Projection c (Maybe a)

Source Projection. Maybe type

-> Pi a b

Projection path

-> p c (Maybe b)

Narrower projected object. Maybe type result

Get narrower projection along with projection path and project into result projection type. Maybe phantom functor is map-ed.

(?!?) infixl 8 Source

Arguments

:: Projectable Projection p 
=> Projection c (Maybe a)

Source Projection. Maybe phantom type

-> Pi a (Maybe b)

Projection path. Maybe type leaf

-> p c (Maybe b)

Narrower projected object. Maybe phantom type result

Get narrower projection along with projection path and project into result projection type. Source record Maybe phantom functor and projection path leaf Maybe functor are join-ed.

(!??) infixl 8 Source

Arguments

:: (ProjectableFlattenMaybe (Maybe b) c, Projectable Projection p, ProjectableMaybe (p cont)) 
=> Projection cont (Maybe a)

Source Projection. Maybe phantom type

-> Pi a b

Projection path

-> p cont c

Narrower flatten and projected object.

Get narrower projection with flatten leaf phantom Maybe types along with projection path and project into result projection type.

(.!) infixl 8 Source

Arguments

:: Projection c (Maybe a)

Source projection type p. Maybe phantom type

-> Pi a b

Projection path

-> Expr c b

Narrower projected expression. Maybe phantom type is stripped off

Get narrower projected expression along with projectino path and strip Maybe phantom type off.

(.?) infixl 8 Source

Arguments

:: Projection c (Maybe a)

Source projection type p. Maybe phantom type

-> Pi a (Maybe b)

Projection path. Maybe type leaf

-> Expr c b

Narrower projected expression. Maybe phantom type is stripped off

Get narrower projected expression along with projectino path and strip Maybe phantom type off. Projection path leaf is Maybe case.

Aggregate functions

unsafeAggregateOp :: (AggregatedContext ac, SqlProjectable (p ac)) => Keyword -> Projection Flat a -> p ac b Source

Unsafely make aggregation uni-operator from SQL keyword.

count :: (Integral b, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac b Source

Aggregation function COUNT.

sum' :: (Num a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe a) Source

Aggregation function SUM.

sumMaybe :: (Num a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe a) Source

Aggregation function SUM.

avg :: (Num a, Fractional b, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe b) Source

Aggregation function AVG.

avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe b) Source

Aggregation function AVG.

max' :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe a) Source

Aggregation function MAX.

maxMaybe :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe a) Source

Aggregation function MAX.

min' :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe a) Source

Aggregation function MIN.

minMaybe :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe a) Source

Aggregation function MIN.

every :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe Bool) -> p ac (Maybe Bool) Source

Aggregation function EVERY.

any' :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe Bool) -> p ac (Maybe Bool) Source

Aggregation function ANY.

some' :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe Bool) -> p ac (Maybe Bool) Source

Aggregation function SOME.

Zipping projection type trick

class ProjectableApplicative p => ProjectableIdZip p where Source

Zipping except for identity element laws.

Methods

leftId :: p ((), a) -> p a Source

rightId :: p (a, ()) -> p a Source

Instances

ProjectableIdZip PlaceHolders

Zipping except for identity element laws against placeholder parameter type.

class ProjectableRunIdsZip a b where Source

Interface to run recursively identity element laws.

Methods

runIds :: ProjectableIdZip p => p a -> p b Source

Instances

ProjectableRunIdsZip a a

Base case definition to run recursively identity element laws.

ProjectableRunIdsZip a b => ProjectableRunIdsZip ((), a) b

Run left identity element law.

ProjectableRunIdsZip a b => ProjectableRunIdsZip (a, ()) b

Run right identity element law.