@@ -5,7 +5,6 @@
55-- Stability: experimental
66--
77-- Squeal is a deep embedding of PostgreSQL in Haskell. Let's see an example!
8−-- FIX DOCS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98--
109-- First, we need some language extensions because Squeal uses modern GHC
1110-- features.
@@ -45,13 +44,13 @@
4544--
4645-- > type Schema =
4746-- > '[ "users" :::
48−-- > '[ "id" ::: 'Optional ('NotNull 'PGint4)
49−-- > , "name" ::: 'Required ('NotNull 'PGtext)
47+-- > '[ "id" ::: 'Def :=> 'NotNull 'PGint4
48+-- > , "name" ::: 'NoDef :=> 'NotNull 'PGtext
5049-- > ]
5150-- > , "emails" :::
52−-- > '[ "id" ::: 'Optional ('NotNull 'PGint4)
53−-- > , "user_id" ::: 'Required ('NotNull 'PGint4)
54−-- > , "email" ::: 'Required ('Null 'PGtext)
51+-- > '[ "id" ::: 'Def :=> 'NotNull 'PGint4
52+-- > , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
53+-- > , "email" ::: 'NoDef :=> 'Null 'PGtext
5554-- > ]
5655-- > ]
5756--
@@ -64,18 +63,19 @@
6463--
6564-- > setup :: Definition '[] Schema
6665-- > setup =
67−-- > createTable #users
68−-- > ( serial `As` #id :*
69−-- > (text & notNull) `As` #name :* Nil )
70−-- > [ primaryKey (Column #id :* Nil) ]
71−-- > >>>
72−-- > createTable #emails
73−-- > ( serial `As` #id :*
74−-- > (int & notNull) `As` #user_id :*
75−-- > text `As` #email :* Nil )
76−-- > [ primaryKey (Column #id :* Nil)
77−-- > , foreignKey (Column #user_id :* Nil) #users (Column #id :* Nil)
78−-- > OnDeleteCascade OnUpdateCascade ]
66+-- > createTable #users
67+-- > ( serial `As` #id :*
68+-- > (text & notNull) `As` #name :*
69+-- > (vararray int2 & notNull) `As` #vec :* Nil )
70+-- > ( primaryKey (Column #id :* Nil) `As` #pk_users :* Nil )
71+-- > >>>
72+-- > createTable #emails
73+-- > ( serial `As` #id :*
74+-- > (int & notNull) `As` #user_id :*
75+-- > text `As` #email :* Nil )
76+-- > ( primaryKey (Column #id :* Nil) `As` #pk_emails :*
77+-- > foreignKey (Column #user_id :* Nil) #users (Column #id :* Nil)
78+-- > OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
7979--
8080-- Notice that @setup@ starts with an empty schema @'[]@ and produces @Schema@.
8181-- In our `createTable` commands we included `TableConstraint`s to define
@@ -97,14 +97,12 @@
9797-- of our inserts.
9898--
9999-- > insertUser :: Manipulation Schema
100−-- > '[ 'Required ('NotNull 'PGtext)]
101−-- > '[ "fromOnly" ::: 'Required ('NotNull 'PGint4) ]
100+-- > '[ 'NotNull 'PGtext] '[ "fromOnly" ::: 'NotNull 'PGint4 ]
102101-- > insertUser = insertInto #users
103102-- > ( Values (def `As` #id :* param @1 `As` #name :* Nil) [] )
104103-- > OnConflictDoNothing (Returning (#id `As` #fromOnly :* Nil))
105104-- >
106−-- > insertEmail :: Manipulation Schema
107−-- > '[ 'Required ('NotNull 'PGint4), 'Required ('Null 'PGtext)] '[]
105+-- > insertEmail :: Manipulation Schema '[ 'NotNull 'PGint4, 'Null 'PGtext] '[]
108106-- > insertEmail = insertInto #emails ( Values
109107-- > ( def `As` #id :*
110108-- > param @1 `As` #user_id :*
@@ -117,8 +115,7 @@
117115-- `Manipulation` with the same kind of type parameters.
118116--
119117-- > getUsers :: Query Schema '[]
120−-- > '[ "userName" ::: 'Required ('NotNull 'PGtext)
121−-- > , "userEmail" ::: 'Required ('Null 'PGtext) ]
118+-- > '["userName" ::: 'NotNull 'PGtext, "userEmail" ::: 'Null 'PGtext]
122119-- > getUsers = select
123120-- > (#u ! #name `As` #userName :* #e ! #email `As` #userEmail :* Nil)
124121-- > ( from (Table (#users `As` #u)