on dev help sign in
docs
commit4c0f2d6b8e30ed037487e348b086d76e718c27e5 authorEitan Chatav <eitan.chatav@gmail.com> dateTue 13 Mar 2018, 17:54 (9 years ago) parent92615d8
5 files changed+30−2
squeal-postgresql/src/Squeal/PostgreSQL.hs+2 squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+11−1 squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+2 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−1 squeal-postgresql/src/Squeal/PostgreSQL/Transaction.hs+10
squeal-postgresql/src/Squeal/PostgreSQL.hs+2
@@ -173,6 +173,7 @@ module Squeal.PostgreSQL
173173 , module Squeal.PostgreSQL.PQ
174174 , module Squeal.PostgreSQL.Query
175175 , module Squeal.PostgreSQL.Schema
176+ , module Squeal.PostgreSQL.Transaction
176177 ) where
177178
178179import Squeal.PostgreSQL.Binary
@@ -182,3 +183,4 @@ import Squeal.PostgreSQL.Manipulation
182183import Squeal.PostgreSQL.PQ
183184import Squeal.PostgreSQL.Query
184185import 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+
112{-# LANGUAGE
213 ScopedTypeVariables
314 , OverloadedStrings
@@ -34,7 +45,6 @@ import Data.Text (Text)
3445import Prelude hiding (id, (.))
3546
3647import Squeal.PostgreSQL
37−import Squeal.PostgreSQL.Transaction
3848
3949-- | A `Migration` is a schema-aligned sequence of `Step`s.
4050data Migration io schema0 schema1 where
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+2
@@ -171,6 +171,7 @@ execPQ
171171 -> m (K LibPQ.Connection schema1)
172172execPQ (PQ pq) conn = fmap (mapKK (\ _ -> unK conn)) $ pq conn
173173
174+-- | Safely embed a `PQ` computation in a larger schema.
174175pqEmbed
175176 :: Monad m
176177 => PQ schema0 schema1 m x
@@ -197,6 +198,7 @@ pqJoin
197198 -> PQ schema0 schema2 m y
198199pqJoin pq = pq & pqBind id
199200
201+-- | indexed analog of `=<<`
200202pqBind
201203 :: Monad m
202204 => (x -> PQ schema1 schema2 m y)
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−1
@@ -45,6 +45,7 @@ module Squeal.PostgreSQL.Schema
4545 , RelationsType
4646 , TableType
4747 , TablesType
48+ , NilTables
4849 , Grouping (..)
4950 -- * Constraints
5051 , (:=>)
@@ -135,7 +136,7 @@ data PGType
135136-- | The object identifier of a `PGType`.
136137--
137138-- >>> :set -XTypeApplications
138−-- >>> oid @'PGbool
139+-- >>> oid @'PGbool
139140-- 16
140141class HasOid (ty :: PGType) where oid :: Word32
141142instance HasOid 'PGbool where oid = 16
@@ -268,6 +269,8 @@ type TableType = ([(Symbol,TableConstraint)],ColumnsType)
268269-- :}
269270--
270271type TablesType = [(Symbol,TableType)]
272+-- | A monokinded `'[]` of `TablesType`.
273+type family NilTables :: TablesType where NilTables = '[]
271274
272275-- | `RelationType` is a row of `NullityType`
273276--
@@ -282,6 +285,7 @@ type TablesType = [(Symbol,TableType)]
282285-- >>> :kind Relation
283286-- Relation :: [(Symbol, NullityType)]
284287type RelationType = [(Symbol,NullityType)]
288+-- | A monokinded `'[]` of `RelationType`.
285289type family NilRelation :: RelationType where NilRelation = '[]
286290
287291-- | `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+
111{-# LANGUAGE
212 DataKinds
313 , EmptyCase