on dev help sign in
docs
4c0f2d6Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL.hs+2
@@ -173,6 +173,7 @@ module Squeal.PostgreSQL
173 , module Squeal.PostgreSQL.PQ
173 , module Squeal.PostgreSQL.PQ
174 , module Squeal.PostgreSQL.Query
174 , module Squeal.PostgreSQL.Query
175 , module Squeal.PostgreSQL.Schema
175 , module Squeal.PostgreSQL.Schema
176+ , module Squeal.PostgreSQL.Transaction
176 ) where
177 ) where
177
178
178import Squeal.PostgreSQL.Binary
179import Squeal.PostgreSQL.Binary
@@ -182,3 +183,4 @@ import Squeal.PostgreSQL.Manipulation
182import Squeal.PostgreSQL.PQ
183import Squeal.PostgreSQL.PQ
183import Squeal.PostgreSQL.Query
184import Squeal.PostgreSQL.Query
184import Squeal.PostgreSQL.Schema
185import Squeal.PostgreSQL.Schema
186+import Squeal.PostgreSQL.Transaction
squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+11−1
@@ -1,3 +1,14 @@
1+{-|
2+Module: Squeal.PostgreSQL.Migration
3+Description: Squeal migrations
4+Copyright: (c) Eitan Chatav, 2017
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+`Squeal.PostgreSQL.Migration` defines a `Migration` type to safely
9+change the schema of your database over time.
10+-}
11+
1{-# LANGUAGE
12{-# LANGUAGE
2 ScopedTypeVariables
13 ScopedTypeVariables
3 , OverloadedStrings
14 , OverloadedStrings
@@ -34,7 +45,6 @@ import Data.Text (Text)
34import Prelude hiding (id, (.))
45import Prelude hiding (id, (.))
35
46
36import Squeal.PostgreSQL
47import Squeal.PostgreSQL
37−import Squeal.PostgreSQL.Transaction
38
48
39-- | A `Migration` is a schema-aligned sequence of `Step`s.
49-- | A `Migration` is a schema-aligned sequence of `Step`s.
40data Migration io schema0 schema1 where
50data Migration io schema0 schema1 where
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+2
@@ -171,6 +171,7 @@ execPQ
171 -> m (K LibPQ.Connection schema1)
171 -> m (K LibPQ.Connection schema1)
172execPQ (PQ pq) conn = fmap (mapKK (\ _ -> unK conn)) $ pq conn
172execPQ (PQ pq) conn = fmap (mapKK (\ _ -> unK conn)) $ pq conn
173
173
174+-- | Safely embed a `PQ` computation in a larger schema.
174pqEmbed
175pqEmbed
175 :: Monad m
176 :: Monad m
176 => PQ schema0 schema1 m x
177 => PQ schema0 schema1 m x
@@ -197,6 +198,7 @@ pqJoin
197 -> PQ schema0 schema2 m y
198 -> PQ schema0 schema2 m y
198pqJoin pq = pq & pqBind id
199pqJoin pq = pq & pqBind id
199
200
201+-- | indexed analog of `=<<`
200pqBind
202pqBind
201 :: Monad m
203 :: Monad m
202 => (x -> PQ schema1 schema2 m y)
204 => (x -> PQ schema1 schema2 m y)
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−1
@@ -45,6 +45,7 @@ module Squeal.PostgreSQL.Schema
45 , RelationsType
45 , RelationsType
46 , TableType
46 , TableType
47 , TablesType
47 , TablesType
48+ , NilTables
48 , Grouping (..)
49 , Grouping (..)
49 -- * Constraints
50 -- * Constraints
50 , (:=>)
51 , (:=>)
@@ -135,7 +136,7 @@ data PGType
135-- | The object identifier of a `PGType`.
136-- | The object identifier of a `PGType`.
136--
137--
137-- >>> :set -XTypeApplications
138-- >>> :set -XTypeApplications
138−-- >>> oid @'PGbool
139+-- >>> oid @'PGbool
139-- 16
140-- 16
140class HasOid (ty :: PGType) where oid :: Word32
141class HasOid (ty :: PGType) where oid :: Word32
141instance HasOid 'PGbool where oid = 16
142instance HasOid 'PGbool where oid = 16
@@ -268,6 +269,8 @@ type TableType = ([(Symbol,TableConstraint)],ColumnsType)
268-- :}
269-- :}
269--
270--
270type TablesType = [(Symbol,TableType)]
271type TablesType = [(Symbol,TableType)]
272+-- | A monokinded `'[]` of `TablesType`.
273+type family NilTables :: TablesType where NilTables = '[]
271
274
272-- | `RelationType` is a row of `NullityType`
275-- | `RelationType` is a row of `NullityType`
273--
276--
@@ -282,6 +285,7 @@ type TablesType = [(Symbol,TableType)]
282-- >>> :kind Relation
285-- >>> :kind Relation
283-- Relation :: [(Symbol, NullityType)]
286-- Relation :: [(Symbol, NullityType)]
284type RelationType = [(Symbol,NullityType)]
287type RelationType = [(Symbol,NullityType)]
288+-- | A monokinded `'[]` of `RelationType`.
285type family NilRelation :: RelationType where NilRelation = '[]
289type family NilRelation :: RelationType where NilRelation = '[]
286
290
287-- | `RelationsType` is a row of `RelationType`s, thought of as a product.
291-- | `RelationsType` is a row of `RelationType`s, thought of as a product.
squeal-postgresql/src/Squeal/PostgreSQL/Transaction.hs+10
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Transaction
3+Description: Squeal transaction control language
4+Copyright: (c) Eitan Chatav, 2017
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+Squeal transaction control language.
9+-}
10+
1{-# LANGUAGE
11{-# LANGUAGE
2 DataKinds
12 DataKinds
3 , EmptyCase
13 , EmptyCase