mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2025-01-06 04:16:21 +03:00
relational-record: apply replaced types.
This commit is contained in:
parent
c66cc46575
commit
17091a2d6c
@ -17,6 +17,7 @@ library
|
|||||||
Database.Relational.Documentation
|
Database.Relational.Documentation
|
||||||
|
|
||||||
build-depends: base <5
|
build-depends: base <5
|
||||||
|
, product-isomorphic >= 0.0.3
|
||||||
, persistable-record >= 0.5
|
, persistable-record >= 0.5
|
||||||
, relational-query >=0.9
|
, relational-query >=0.9
|
||||||
, relational-query-HDBC
|
, relational-query-HDBC
|
||||||
|
@ -53,12 +53,12 @@ module Database.Relational.Documentation (
|
|||||||
UpdateTarget, updateTarget,
|
UpdateTarget, updateTarget,
|
||||||
Restriction, restriction,
|
Restriction, restriction,
|
||||||
|
|
||||||
-- ** Projection
|
-- ** Record
|
||||||
-- $projection
|
-- $record
|
||||||
|
|
||||||
-- *** Projection Type
|
-- *** Record Type
|
||||||
-- $projectionType
|
-- $recordType
|
||||||
Projection,
|
Record,
|
||||||
|
|
||||||
Flat, Aggregated,
|
Flat, Aggregated,
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ module Database.Relational.Documentation (
|
|||||||
Pi, (!), (<.>),
|
Pi, (!), (<.>),
|
||||||
|
|
||||||
-- *** Projection Operators
|
-- *** Projection Operators
|
||||||
-- $projectionOperators
|
-- $recordOperators
|
||||||
ShowConstantTermsSQL,
|
ShowConstantTermsSQL,
|
||||||
|
|
||||||
value, values,
|
value, values,
|
||||||
@ -104,8 +104,8 @@ module Database.Relational.Documentation (
|
|||||||
-- $setOperators
|
-- $setOperators
|
||||||
union, except, intersect,
|
union, except, intersect,
|
||||||
|
|
||||||
-- ** Maybe Projections
|
-- ** Maybe Records
|
||||||
-- $maybeProjection
|
-- $maybeRecord
|
||||||
just, flattenMaybe,
|
just, flattenMaybe,
|
||||||
|
|
||||||
(?!), (?!?),
|
(?!), (?!?),
|
||||||
@ -129,8 +129,8 @@ module Database.Relational.Documentation (
|
|||||||
-- ** Record Mapping
|
-- ** Record Mapping
|
||||||
-- $recordMapping
|
-- $recordMapping
|
||||||
ProductConstructor,
|
ProductConstructor,
|
||||||
ProjectableFunctor (..),
|
ProductIsoFunctor (..),
|
||||||
ProjectableApplicative (..),
|
ProductIsoApplicative (..),
|
||||||
(><),
|
(><),
|
||||||
|
|
||||||
-- ** Database Statements
|
-- ** Database Statements
|
||||||
@ -197,6 +197,7 @@ module Database.Relational.Documentation (
|
|||||||
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Data.Functor.ProductIsomorphic
|
||||||
import Database.Relational
|
import Database.Relational
|
||||||
import Database.Record (RecordFromSql, FromSql, RecordToSql, ToSql)
|
import Database.Record (RecordFromSql, FromSql, RecordToSql, ToSql)
|
||||||
import Database.HDBC.Record
|
import Database.HDBC.Record
|
||||||
@ -210,7 +211,7 @@ User interface of Relational Record has main two part of modules.
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
{- $queryBuildingDSL
|
{- $queryBuildingDSL
|
||||||
Relational Query ("Database.Relational.Query") module
|
Relational Query ("Database.Relational") module
|
||||||
defines Typed DSL to build complex SQL query.
|
defines Typed DSL to build complex SQL query.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
@ -224,14 +225,14 @@ Some operators are defined to build query structures in monadic context.
|
|||||||
'query' and 'queryMaybe' operators grow query product of monadic context like join operation of SQL.
|
'query' and 'queryMaybe' operators grow query product of monadic context like join operation of SQL.
|
||||||
'on' operator appends a new condition into recent join product condition.
|
'on' operator appends a new condition into recent join product condition.
|
||||||
|
|
||||||
'groupBy' operator aggregates flat projection value, and can be used only in 'MonadAggregate' context.
|
'groupBy' operator aggregates flat record value, and can be used only in 'MonadAggregate' context.
|
||||||
|
|
||||||
'wheres' and 'having' operators appends a new condition into whole query condition.
|
'wheres' and 'having' operators appends a new condition into whole query condition.
|
||||||
'having' only accepts aggregated projection value, and can be used only in 'MonadRestrict' 'Aggregated' context.
|
'having' only accepts aggregated record value, and can be used only in 'MonadRestrict' 'Aggregated' context.
|
||||||
|
|
||||||
'distinct' operator and 'all'' operator specify SELECT DISTINCT or SELECT ALL, the last specified in monad is used.
|
'distinct' operator and 'all'' operator specify SELECT DISTINCT or SELECT ALL, the last specified in monad is used.
|
||||||
|
|
||||||
'<-#' operator assigns update target column and projection value to build update statement structure.
|
'<-#' operator assigns update target column and record value to build update statement structure.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $directJoin
|
{- $directJoin
|
||||||
@ -258,12 +259,12 @@ which can be used as update statement.
|
|||||||
which can be used as delete statement.
|
which can be used as delete statement.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $projection
|
{- $record
|
||||||
SQL expression can be projected to Haskell phantom type in this DSL.
|
SQL expression corresponds to Haskell record phantom type in this DSL.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $projectionType
|
{- $recordType
|
||||||
'Projection' /c/ /t/ is SQL value type projection to Haskell type with context type /c/ correspond Haskell type /t/.
|
'Record' /c/ /a/ is projected SQL value type corresponding to Haskell record type /a/ with context type /c/.
|
||||||
|
|
||||||
'Flat' is not aggregated query context type,
|
'Flat' is not aggregated query context type,
|
||||||
'Aggregated' is aggregated query context type,
|
'Aggregated' is aggregated query context type,
|
||||||
@ -273,24 +274,24 @@ Module "Database.Relational.Context" contains documentation of other context typ
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
{- $projectionPath
|
{- $projectionPath
|
||||||
'!' operator is projected value selector using projection path type 'Pi' /r0/ /r1/.
|
'!' operator is record value selector using projection path type 'Pi' /r0/ /r1/.
|
||||||
'Pi' /r0/ /r1/ is projection path type selecting column type /r1/ from record type /r0/.
|
'Pi' /r0/ /r1/ is projection path type selecting column type /r1/ from record type /r0/.
|
||||||
'<.>' operator makes composed projection path from two projection paths.
|
'<.>' operator makes composed projection path from two projection paths.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $projectionOperators
|
{- $recordOperators
|
||||||
Some operators are defined to calculate projected values.
|
Some operators are defined to calculate record values.
|
||||||
|
|
||||||
For example,
|
For example,
|
||||||
'value' operator projects from Haskell value into 'Projection' corresponding SQL row value,
|
'value' operator lifts from Haskell value into 'Record' corresponding SQL row value,
|
||||||
which projection is implicitly specified by 'ShowConstantTermsSQL' class.
|
which conversion is implicitly specified by 'ShowConstantTermsSQL' class.
|
||||||
Generic programming with default signature is available to define instances of 'ShowConstantTermsSQL'.
|
Generic programming with default signature is available to define instances of 'ShowConstantTermsSQL'.
|
||||||
|
|
||||||
'values' operator projects from Haskell list value into 'ListProjection', corresponding SQL set value,
|
'values' operator converts from Haskell list value into 'RecordList', corresponding SQL set value,
|
||||||
'.=.' operator is equal compare operation of projected value correspond to SQL =,
|
'.=.' operator is equal compare operation of record value correspond to SQL =,
|
||||||
'.+.' operator is plus operation of projected value correspond to SQL +, and so on.
|
'.+.' operator is plus operation of record value correspond to SQL +, and so on.
|
||||||
|
|
||||||
Module "Database.Relational.Projectable" contains documentation of other projection operators.
|
Module "Database.Relational.Projectable" contains documentation of other record operators.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $aggregateFunctions
|
{- $aggregateFunctions
|
||||||
@ -298,11 +299,11 @@ Typed aggregate function operators are defined.
|
|||||||
Aggregated value types is distinguished with Flat value types.
|
Aggregated value types is distinguished with Flat value types.
|
||||||
|
|
||||||
For example,
|
For example,
|
||||||
'sum'' operator is aggregate function of projected flat (not aggregated) value
|
'sum'' operator is aggregate function of flat (not aggregated) record value
|
||||||
correspond to SQL SUM(...),
|
correspond to SQL SUM(...),
|
||||||
'rank' operator is window function of projected value correspond to SQL RANK(), and so on.
|
'rank' operator is window function of record value correspond to SQL RANK(), and so on.
|
||||||
|
|
||||||
To convert window function result into normal projection, use the 'over' operator with built 'Window' monad.
|
To convert window function result into normal record, use the 'over' operator with built 'Window' monad.
|
||||||
|
|
||||||
Module "Database.Relational.Projectable" contains documentation of
|
Module "Database.Relational.Projectable" contains documentation of
|
||||||
other aggregate function operators and window function operators.
|
other aggregate function operators and window function operators.
|
||||||
@ -316,13 +317,13 @@ Several operators are defined to manipulate relation set.
|
|||||||
'intersect' operator makes intersection relation set of two relation set correspond to SQL INTERSECT.
|
'intersect' operator makes intersection relation set of two relation set correspond to SQL INTERSECT.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $maybeProjection
|
{- $maybeRecord
|
||||||
Some operators are provided to manage projections with 'Maybe' phantom type.
|
Some operators are provided to manage records with 'Maybe' phantom type.
|
||||||
|
|
||||||
'just' operator creates 'Maybe' typed projection,
|
'just' operator creates 'Maybe' typed record,
|
||||||
'flattenMaybe' operator joins nested 'Maybe' typed projection.
|
'flattenMaybe' operator joins nested 'Maybe' typed record.
|
||||||
|
|
||||||
'Maybe' type flavor of operators against projection path, projection and aggregation are also provided.
|
'Maybe' type flavor of operators against projection path, record and aggregation are also provided.
|
||||||
|
|
||||||
For example,
|
For example,
|
||||||
'?!' operator is maybe flavor of '!',
|
'?!' operator is maybe flavor of '!',
|
||||||
@ -333,13 +334,13 @@ For example,
|
|||||||
'negateMaybe' operator is maybe flavor of 'negate'',
|
'negateMaybe' operator is maybe flavor of 'negate'',
|
||||||
'sumMaybe' operator is maybe flavor of 'sum''.
|
'sumMaybe' operator is maybe flavor of 'sum''.
|
||||||
|
|
||||||
Module "Database.Relational.Projectable" and "Database.Relational.Query.ProjectableExtended"
|
Module "Database.Relational.Projectable" and "Database.Relational.ProjectableExtended"
|
||||||
contain documentation of other 'Maybe' flavor projection operators.
|
contain documentation of other 'Maybe' flavor operators.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $placeholders
|
{- $placeholders
|
||||||
'placeholders' operator takes
|
'placeholders' operator takes
|
||||||
a lambda-form which argument is 'Projection' typed placeholders and its scope is restricted by that lambda-form
|
a lambda-form which argument is 'Record' typed placeholders and its scope is restricted by that lambda-form
|
||||||
and then creates dummy value with 'Placeholders' typed which propagate placeholder type information into 'Relation' layer.
|
and then creates dummy value with 'Placeholders' typed which propagate placeholder type information into 'Relation' layer.
|
||||||
|
|
||||||
Placeholders' flavor of operators against query operation and set operation are also provided, to realize type safe placeholders.
|
Placeholders' flavor of operators against query operation and set operation are also provided, to realize type safe placeholders.
|
||||||
@ -347,15 +348,15 @@ Placeholders' flavor of operators against query operation and set operation are
|
|||||||
'query'', 'left'', 'relation'', 'updateTarget'', 'restriction'', and 'union''
|
'query'', 'left'', 'relation'', 'updateTarget'', 'restriction'', and 'union''
|
||||||
operator are placeholders' flavor 'query', 'left', 'relation', 'updateTarget', 'restriction' and 'union'.
|
operator are placeholders' flavor 'query', 'left', 'relation', 'updateTarget', 'restriction' and 'union'.
|
||||||
|
|
||||||
Module "Database.Relational.Relation" and "Database.Relational.Query.Effect"
|
Module "Database.Relational.Relation" and "Database.Relational.Effect"
|
||||||
contains documentation of other placeholders' flavor operators.
|
contains documentation of other placeholders' flavor operators.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{- $recordMapping
|
{- $recordMapping
|
||||||
Applicative style record mapping is supported, for 'Projection', 'Pi' and 'PlaceHolders'.
|
Applicative style record mapping is supported, for 'Record', 'Pi' and 'PlaceHolders'.
|
||||||
'|$|' operator can be used on 'ProjectableFunctor' context, and
|
'|$|' operator can be used on 'ProductIsoFunctor' context, and
|
||||||
'|*|' operator can be used on 'ProjectableApplicative' context with 'ProductConstructor',
|
'|*|' operator can be used on 'ProductIsoApplicative' context with 'ProductConstructor',
|
||||||
like /Foo |$| projection1 |*| projection2 |*| projection3/
|
like /Foo |$| record1 |*| record2 |*| record3/
|
||||||
, /Foo |$| placeholders1 |*| placeholders2 |*| placeholders3/, and so on.
|
, /Foo |$| placeholders1 |*| placeholders2 |*| placeholders3/, and so on.
|
||||||
|
|
||||||
'><' operator constructs pair result. /x >< y/ is the same as /(,) |$| x |*| y/.
|
'><' operator constructs pair result. /x >< y/ is the same as /(,) |$| x |*| y/.
|
||||||
|
Loading…
Reference in New Issue
Block a user