Copyright | 2013 Kei Hibino |
---|---|

License | BSD3 |

Maintainer | ex8k.hibino@gmail.com |

Stability | experimental |

Portability | unknown |

Safe Haskell | None |

Language | Haskell2010 |

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

- class ProjectableFlattenMaybe a b where
- flatten :: ProjectableMaybe p => p a -> p b

- flattenPiMaybe :: (ProjectableMaybe (Projection cont), ProjectableFlattenMaybe (Maybe b) c) => Projection cont (Maybe a) -> Pi a b -> Projection cont c
- (!) :: Projectable Projection p => Projection c a -> Pi a b -> p c b
- (?!) :: Projectable Projection p => Projection c (Maybe a) -> Pi a b -> p c (Maybe b)
- (?!?) :: Projectable Projection p => Projection c (Maybe a) -> Pi a (Maybe b) -> p c (Maybe b)
- (!??) :: (ProjectableFlattenMaybe (Maybe b) c, Projectable Projection p, ProjectableMaybe (p cont)) => Projection cont (Maybe a) -> Pi a b -> p cont c
- (.!) :: Projection c (Maybe a) -> Pi a b -> Expr c b
- (.?) :: Projection c (Maybe a) -> Pi a (Maybe b) -> Expr c b
- unsafeAggregateOp :: (AggregatedContext ac, SqlProjectable (p ac)) => Keyword -> Projection Flat a -> p ac b
- count :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac Int64
- sum' :: (Num a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe a)
- sumMaybe :: (Num a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe a)
- avg :: (Num a, Fractional b, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe b)
- avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe b)
- max' :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe a)
- maxMaybe :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe a)
- min' :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac (Maybe a)
- minMaybe :: (Ord a, AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe a) -> p ac (Maybe a)
- every :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe Bool) -> p ac (Maybe Bool)
- any' :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe Bool) -> p ac (Maybe Bool)
- some' :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat (Maybe Bool) -> p ac (Maybe Bool)
- class ProjectableApplicative p => ProjectableIdZip p where
- class ProjectableRunIdsZip a b where
- runIds :: ProjectableIdZip p => p a -> p b

- flattenPh :: ProjectableRunIdsZip a b => PlaceHolders a -> PlaceHolders b

# Projection for nested `Maybe`

s

class ProjectableFlattenMaybe a b where Source

Interface to compose phantom `Maybe`

nested type.

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

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

ProjectableFlattenMaybe (Maybe a) (Maybe a) | Not |

:: (ProjectableMaybe (Projection cont), ProjectableFlattenMaybe (Maybe b) c) | |

=> Projection cont (Maybe a) | Source |

-> Pi a b | Projection path |

-> Projection cont c | Narrower |

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

# Get narrower projections

:: 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.

:: Projectable Projection p | |

=> Projection c (Maybe a) | Source |

-> Pi a b | Projection path |

-> p c (Maybe b) | Narrower projected object. |

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

phantom type is propagated.

:: Projectable Projection p | |

=> Projection c (Maybe a) | Source |

-> Pi a (Maybe b) | Projection path. |

-> p c (Maybe b) | Narrower projected object. |

:: (ProjectableFlattenMaybe (Maybe b) c, Projectable Projection p, ProjectableMaybe (p cont)) | |

=> Projection cont (Maybe a) | Source |

-> 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.

:: Projection c (Maybe a) | Source projection type |

-> Pi a b | Projection path |

-> Expr c b | Narrower projected expression. |

Get narrower projected expression along with projectino path
and strip `Maybe`

phantom type off.

# 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 :: (AggregatedContext ac, SqlProjectable (p ac)) => Projection Flat a -> p ac Int64 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.

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.

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

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. |

flattenPh :: ProjectableRunIdsZip a b => PlaceHolders a -> PlaceHolders b Source

Specialize `runIds`

for `PlaceHolders`

type.