Copyright | 2013-2017 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.
- class SqlProjectable p where
- unsafeProjectSql' :: SqlProjectable p => StringSQL -> p t
- unsafeProjectSql :: SqlProjectable p => String -> p t
- value :: (ShowConstantTermsSQL t, OperatorProjectable p) => t -> p t
- valueTrue :: (OperatorProjectable p, ProjectableMaybe p) => p (Maybe Bool)
- valueFalse :: (OperatorProjectable p, ProjectableMaybe p) => p (Maybe Bool)
- values :: (ShowConstantTermsSQL t, OperatorProjectable p) => [t] -> ListProjection p t
- nothing :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a) => Projection c (Maybe a)
- unsafeValueNull :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a) => Projection c (Maybe a)
- data PlaceHolders p
- unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)
- unsafePlaceHolders :: PlaceHolders p
- pwPlaceholder :: SqlProjectable p => PersistableRecordWidth a -> (p a -> b) -> (PlaceHolders a, b)
- placeholder' :: (PersistableWidth t, SqlProjectable p) => (p t -> a) -> (PlaceHolders t, a)
- placeholder :: (PersistableWidth t, SqlProjectable p, Monad m) => (p t -> m a) -> m (PlaceHolders t, a)
- unitPlaceHolder :: PlaceHolders ()
- unitPH :: PlaceHolders ()
- class ProjectableShowSql p where
- unsafeShowSql :: ProjectableShowSql p => p a -> String
- (.=.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool)
- (.<.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool)
- (.<=.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool)
- (.>.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool)
- (.>=.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool)
- (.<>.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool)
- and' :: (OperatorProjectable p, ProjectableShowSql p) => p (Maybe Bool) -> p (Maybe Bool) -> p (Maybe Bool)
- or' :: (OperatorProjectable p, ProjectableShowSql p) => p (Maybe Bool) -> p (Maybe Bool) -> p (Maybe Bool)
- in' :: (OperatorProjectable p, ProjectableShowSql p) => p t -> ListProjection p t -> p (Maybe Bool)
- (.||.) :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p a -> p a -> p a
- (?||?) :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a)
- like :: (OperatorProjectable p, ProjectableShowSql p, IsString a, ShowConstantTermsSQL a) => p a -> a -> p (Maybe Bool)
- likeMaybe :: (OperatorProjectable p, ProjectableShowSql p, IsString a, ShowConstantTermsSQL a) => p (Maybe a) -> a -> p (Maybe Bool)
- like' :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p a -> p a -> p (Maybe Bool)
- likeMaybe' :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p (Maybe a) -> p (Maybe a) -> p (Maybe Bool)
- (.+.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a
- (.-.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a
- (.*.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a
- (./.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a
- (?+?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a)
- (?-?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a)
- (?*?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a)
- (?/?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a)
- isNothing :: (OperatorProjectable (Projection c), ProjectableShowSql (Projection c), HasColumnConstraint NotNull r) => Projection c (Maybe r) -> Projection c (Maybe Bool)
- isJust :: (OperatorProjectable (Projection c), ProjectableShowSql (Projection c), HasColumnConstraint NotNull r) => Projection c (Maybe r) -> Projection c (Maybe Bool)
- fromMaybe :: (OperatorProjectable (Projection c), ProjectableShowSql (Projection c), HasColumnConstraint NotNull r) => Projection c r -> Projection c (Maybe r) -> Projection c r
- not' :: (OperatorProjectable p, ProjectableShowSql p) => p (Maybe Bool) -> p (Maybe Bool)
- exists :: (OperatorProjectable p, ProjectableShowSql p) => ListProjection (Projection Exists) r -> p (Maybe Bool)
- negate' :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a
- fromIntegral' :: (SqlProjectable p, ProjectableShowSql p, Integral a, Num b) => p a -> p b
- showNum :: (SqlProjectable p, ProjectableShowSql p, Num a, IsString b) => p a -> p b
- negateMaybe :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a)
- fromIntegralMaybe :: (SqlProjectable p, ProjectableShowSql p, Integral a, Num b) => p (Maybe a) -> p (Maybe b)
- showNumMaybe :: (SqlProjectable p, ProjectableShowSql p, Num a, IsString b) => p (Maybe a) -> p (Maybe b)
- casesOrElse :: OperatorProjectable (Projection c) => [(Projection c (Maybe Bool), Projection c a)] -> Projection c a -> Projection c a
- casesOrElse' :: OperatorProjectable (Projection c) => (Projection c a, [(Projection c a, Projection c b)]) -> Projection c b -> Projection c b
- caseSearch :: OperatorProjectable (Projection c) => [(Projection c (Maybe Bool), Projection c a)] -> Projection c a -> Projection c a
- caseSearchMaybe :: (OperatorProjectable (Projection c), PersistableWidth a) => [(Projection c (Maybe Bool), Projection c (Maybe a))] -> Projection c (Maybe a)
- case' :: OperatorProjectable (Projection c) => Projection c a -> [(Projection c a, Projection c b)] -> Projection c b -> Projection c b
- caseMaybe :: (OperatorProjectable (Projection c), PersistableWidth b) => Projection c a -> [(Projection c a, Projection c (Maybe b))] -> Projection c (Maybe b)
- type SqlBinOp = Keyword -> Keyword -> Keyword
- unsafeBinOp :: (SqlProjectable p, ProjectableShowSql p) => SqlBinOp -> p a -> p b -> p c
- unsafeUniOp :: (ProjectableShowSql p0, SqlProjectable p1) => (Keyword -> Keyword) -> p0 a -> p1 b
- rank :: Integral a => Projection OverWindow a
- denseRank :: Integral a => Projection OverWindow a
- rowNumber :: Integral a => Projection OverWindow a
- percentRank :: Projection OverWindow Double
- cumeDist :: Projection OverWindow Double
- projectZip :: ProjectableApplicative p => p a -> p b -> p (a, b)
- (><) :: ProjectableApplicative p => p a -> p b -> p (a, b)
- class ProjectableApplicative p => ProjectableIdZip p where
- class ProjectableMaybe p where
Projectable from SQL strings
class SqlProjectable p where Source #
Interface to project SQL terms unsafely.
unsafeProjectSqlTerms :: [StringSQL] -> p t Source #
Unsafely project from SQL expression terms.
SqlProjectable (Projection OverWindow) Source # | Unsafely make |
SqlProjectable (Projection Aggregated) Source # | Unsafely make |
SqlProjectable (Projection Flat) Source # | Unsafely make |
unsafeProjectSql' :: SqlProjectable p => StringSQL -> p t Source #
Unsafely Project single SQL term.
unsafeProjectSql :: SqlProjectable p => String -> p t Source #
Unsafely Project single SQL string. String interface of unsafeProjectSql'
.
Projections of values
value :: (ShowConstantTermsSQL t, OperatorProjectable p) => t -> p t Source #
Generate polymorphic projection of SQL constant values from Haskell value.
valueTrue :: (OperatorProjectable p, ProjectableMaybe p) => p (Maybe Bool) Source #
Polymorphic proejction of SQL true value.
valueFalse :: (OperatorProjectable p, ProjectableMaybe p) => p (Maybe Bool) Source #
Polymorphic proejction of SQL false value.
values :: (ShowConstantTermsSQL t, OperatorProjectable p) => [t] -> ListProjection p t Source #
Polymorphic proejction of SQL set value from Haskell list.
nothing :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a) => Projection c (Maybe a) Source #
Polymorphic projection of SQL null value. Semantics of comparing is unsafe.
unsafeValueNull :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a) => Projection c (Maybe a) Source #
Deprecated: Use nothing
instead of this.
Deprecated. Polymorphic projection of SQL null value.
Placeholders
data PlaceHolders p Source #
Placeholder parameter type which has real parameter type arguemnt p
.
ProjectableApplicative PlaceHolders Source # | Compose record type |
ProjectableFunctor PlaceHolders Source # | Compose seed of record type |
ProjectableIdZip PlaceHolders Source # | Zipping except for identity element laws against placeholder parameter type. |
ProjectableMaybe PlaceHolders Source # | Control phantom |
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a) Source #
Unsafely add placeholder parameter to queries.
unsafePlaceHolders :: PlaceHolders p Source #
Unsafely get placeholder parameter
pwPlaceholder :: SqlProjectable p => PersistableRecordWidth a -> (p a -> b) -> (PlaceHolders a, b) Source #
Provide scoped placeholder from width and return its parameter object.
placeholder' :: (PersistableWidth t, SqlProjectable p) => (p t -> a) -> (PlaceHolders t, a) Source #
Provide scoped placeholder and return its parameter object.
placeholder :: (PersistableWidth t, SqlProjectable p, Monad m) => (p t -> m a) -> m (PlaceHolders t, a) Source #
Provide scoped placeholder and return its parameter object. Monadic version.
unitPlaceHolder :: PlaceHolders () Source #
No placeholder semantics
unitPH :: PlaceHolders () Source #
No placeholder semantics. Same as unitPlaceHolder
Projectable into SQL strings
class ProjectableShowSql p where Source #
Interface to get SQL term from projections.
unsafeShowSql' :: p a -> StringSQL Source #
Unsafely generate SQL expression term from projection object.
ProjectableShowSql (Projection c) Source # | Unsafely get SQL term from |
:: ProjectableShowSql p | |
=> p a | Source projection object |
-> String | Result SQL expression string. |
Unsafely generate SQL expression string from projection object.
String interface of unsafeShowSql'
.
Operators
(.=.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool) infix 4 Source #
Compare operator corresponding SQL = .
(.<.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool) infix 4 Source #
Compare operator corresponding SQL < .
(.<=.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool) infix 4 Source #
Compare operator corresponding SQL <= .
(.>.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool) infix 4 Source #
Compare operator corresponding SQL > .
(.>=.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool) infix 4 Source #
Compare operator corresponding SQL >= .
(.<>.) :: (OperatorProjectable p, ProjectableShowSql p) => p ft -> p ft -> p (Maybe Bool) infix 4 Source #
Compare operator corresponding SQL <> .
and' :: (OperatorProjectable p, ProjectableShowSql p) => p (Maybe Bool) -> p (Maybe Bool) -> p (Maybe Bool) infixr 3 Source #
Logical operator corresponding SQL AND .
or' :: (OperatorProjectable p, ProjectableShowSql p) => p (Maybe Bool) -> p (Maybe Bool) -> p (Maybe Bool) infixr 2 Source #
Logical operator corresponding SQL OR .
in' :: (OperatorProjectable p, ProjectableShowSql p) => p t -> ListProjection p t -> p (Maybe Bool) infix 4 Source #
Binary operator corresponding SQL IN .
(.||.) :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p a -> p a -> p a infixl 5 Source #
Concatinate operator corresponding SQL || .
(?||?) :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a) infixl 5 Source #
Concatinate operator corresponding SQL || . Maybe type version.
like :: (OperatorProjectable p, ProjectableShowSql p, IsString a, ShowConstantTermsSQL a) => p a -> a -> p (Maybe Bool) infix 4 Source #
String-compare operator corresponding SQL LIKE .
likeMaybe :: (OperatorProjectable p, ProjectableShowSql p, IsString a, ShowConstantTermsSQL a) => p (Maybe a) -> a -> p (Maybe Bool) infix 4 Source #
String-compare operator corresponding SQL LIKE . Maybe type version.
like' :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p a -> p a -> p (Maybe Bool) infix 4 Source #
String-compare operator corresponding SQL LIKE .
likeMaybe' :: (OperatorProjectable p, ProjectableShowSql p, IsString a) => p (Maybe a) -> p (Maybe a) -> p (Maybe Bool) infix 4 Source #
String-compare operator corresponding SQL LIKE .
(.+.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a infixl 6 Source #
Number operator corresponding SQL + .
(.-.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a infixl 6 Source #
Number operator corresponding SQL - .
(.*.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a infixl 7 Source #
Number operator corresponding SQL * .
(./.) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a -> p a infixl 7 Source #
Number operator corresponding SQL /// .
(?+?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a) infixl 6 Source #
Number operator corresponding SQL + .
(?-?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a) infixl 6 Source #
Number operator corresponding SQL - .
(?*?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a) infixl 7 Source #
Number operator corresponding SQL * .
(?/?) :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) -> p (Maybe a) infixl 7 Source #
Number operator corresponding SQL /// .
isNothing :: (OperatorProjectable (Projection c), ProjectableShowSql (Projection c), HasColumnConstraint NotNull r) => Projection c (Maybe r) -> Projection c (Maybe Bool) Source #
Operator corresponding SQL IS NULL , and extended against record types.
isJust :: (OperatorProjectable (Projection c), ProjectableShowSql (Projection c), HasColumnConstraint NotNull r) => Projection c (Maybe r) -> Projection c (Maybe Bool) Source #
Operator corresponding SQL NOT (... IS NULL) , and extended against record type.
fromMaybe :: (OperatorProjectable (Projection c), ProjectableShowSql (Projection c), HasColumnConstraint NotNull r) => Projection c r -> Projection c (Maybe r) -> Projection c r Source #
Operator from maybe type using record extended isNull
.
not' :: (OperatorProjectable p, ProjectableShowSql p) => p (Maybe Bool) -> p (Maybe Bool) Source #
Logical operator corresponding SQL NOT .
exists :: (OperatorProjectable p, ProjectableShowSql p) => ListProjection (Projection Exists) r -> p (Maybe Bool) Source #
Logical operator corresponding SQL EXISTS .
negate' :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p a -> p a Source #
Number negate uni-operator corresponding SQL -.
fromIntegral' :: (SqlProjectable p, ProjectableShowSql p, Integral a, Num b) => p a -> p b Source #
Number fromIntegral uni-operator.
showNum :: (SqlProjectable p, ProjectableShowSql p, Num a, IsString b) => p a -> p b Source #
Unsafely show number into string-like type in projections.
negateMaybe :: (OperatorProjectable p, ProjectableShowSql p, Num a) => p (Maybe a) -> p (Maybe a) Source #
Number negate uni-operator corresponding SQL -.
fromIntegralMaybe :: (SqlProjectable p, ProjectableShowSql p, Integral a, Num b) => p (Maybe a) -> p (Maybe b) Source #
Number fromIntegral uni-operator.
showNumMaybe :: (SqlProjectable p, ProjectableShowSql p, Num a, IsString b) => p (Maybe a) -> p (Maybe b) Source #
Unsafely show number into string-like type in projections.
:: OperatorProjectable (Projection c) | |
=> [(Projection c (Maybe Bool), Projection c a)] | Each when clauses |
-> Projection c a | Else result projection |
-> Projection c a | Result projection |
Same as caseSearch
, but you can write like list casesOrElse
clause.
:: OperatorProjectable (Projection c) | |
=> (Projection c a, [(Projection c a, Projection c b)]) | Projection value to match and each when clauses list |
-> Projection c b | Else result projection |
-> Projection c b | Result projection |
Uncurry version of case'
, and you can write like ... casesOrElse'
clause.
:: OperatorProjectable (Projection c) | |
=> [(Projection c (Maybe Bool), Projection c a)] | Each when clauses |
-> Projection c a | Else result projection |
-> Projection c a | Result projection |
Search case operator correnponding SQL search CASE. Like, CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END
:: (OperatorProjectable (Projection c), PersistableWidth a) | |
=> [(Projection c (Maybe Bool), Projection c (Maybe a))] | Each when clauses |
-> Projection c (Maybe a) | Result projection |
Null default version of caseSearch
.
:: OperatorProjectable (Projection c) | |
=> Projection c a | Projection value to match |
-> [(Projection c a, Projection c b)] | Each when clauses |
-> Projection c b | Else result projection |
-> Projection c b | Result projection |
Simple case operator correnponding SQL simple CASE. Like, CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END
:: (OperatorProjectable (Projection c), PersistableWidth b) | |
=> Projection c a | Projection value to match |
-> [(Projection c a, Projection c (Maybe b))] | Each when clauses |
-> Projection c (Maybe b) | Result projection |
Null default version of case'
.
unsafeBinOp :: (SqlProjectable p, ProjectableShowSql p) => SqlBinOp -> p a -> p b -> p c Source #
Unsafely make projection binary operator from string binary operator.
unsafeUniOp :: (ProjectableShowSql p0, SqlProjectable p1) => (Keyword -> Keyword) -> p0 a -> p1 b Source #
Unsafely make projection unary operator from SQL keyword.
Terms for Window function types
rank :: Integral a => Projection OverWindow a Source #
RANK() term.
denseRank :: Integral a => Projection OverWindow a Source #
DENSE_RANK() term.
rowNumber :: Integral a => Projection OverWindow a Source #
ROW_NUMBER() term.
percentRank :: Projection OverWindow Double Source #
PERCENT_RANK() term.
cumeDist :: Projection OverWindow Double Source #
CUME_DIST() term.
Zipping projections
projectZip :: ProjectableApplicative p => p a -> p b -> p (a, b) Source #
Zipping projections.
(><) :: ProjectableApplicative p => p a -> p b -> p (a, b) infixl 1 Source #
Binary operator the same as projectZip
.
class ProjectableApplicative p => ProjectableIdZip p where Source #
Zipping except for identity element laws.
ProjectableIdZip PlaceHolders Source # | Zipping except for identity element laws against placeholder parameter type. |
Maybe
type projecitoins
class ProjectableMaybe p where Source #
Interface to control Maybe
of phantom type in projections.
just :: p a -> p (Maybe a) Source #
Cast projection phantom type into Maybe
.
flattenMaybe :: p (Maybe (Maybe a)) -> p (Maybe a) Source #
Compose nested Maybe
phantom type on projection.
ProjectableMaybe PlaceHolders Source # | Control phantom |
ProjectableMaybe (Projection c) Source # | Control phantom |