on dev help sign in
start on constraints

* `:=>` type level constraints + ty pairing, intended to connote Haskell's `=>` * `ColumnConstraint` kind. A given column may have a DEFAULT value, no repeat values in different rows, or it might refer to the same value in another table's column.

commit15ea7767b0e20e4811781cf10754879f5a1157cb authorEitan Chatav <eitan.chatav@gmail.com> dateSun 5 Nov 2017, 13:20 (9 years ago) parent5bc3ad1
3 files changed+14
squeal-postgresql/squeal-postgresql.cabal+1 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+11 stack.yaml+2
squeal-postgresql/squeal-postgresql.cabal+1
@@ -49,6 +49,7 @@ library
4949 , time >= 1.8.0.2 && < 2
5050 , transformers >= 0.5.2.0 && < 1
5151 , transformers-base >= 0.4.4 && < 1
52+ , type-level-sets
5253 , uuid >= 1.3.13 && < 2
5354
5455test-suite squeal-postgresql-spec
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+11
@@ -68,12 +68,16 @@ module Squeal.PostgreSQL.Schema
6868 -- * Generics
6969 , SameField
7070 , SameFields
71+ -- * PostgreSQL Constraints
72+ , (:=>)
73+ , ColumnConstraint (..)
7174 ) where
7275
7376import Control.DeepSeq
7477import Data.ByteString
7578import Data.Monoid
7679import Data.String
80+import Data.Type.Set
7781import Generics.SOP (AllZip)
7882import GHC.Generics (Generic)
7983import GHC.Exts
@@ -322,3 +326,10 @@ type family SameFields
322326 ('Type.Newtype _module _datatype ('Type.Record _constructor fields))
323327 columns
324328 = AllZip SameField fields columns
329+
330+type (:=>) constraints ty = '(AsSet constraints,ty)
331+
332+data ColumnConstraint
333+ = Default
334+ | Unique
335+ | References Symbol Symbol
stack.yaml+2
@@ -1,3 +1,5 @@
11resolver: nightly-2017-08-25
22packages:
33- squeal-postgresql
4+extra-deps:
5+- type-level-sets-0.8.0.0