on dev help sign in
doctests
commite8283fdea3667eb8b938b7207b6287830640e900 authorEitan Chatav <eitan.chatav@gmail.com> dateMon 28 Aug 2017, 16:11 (9 years ago) parentd240b73
2 files changed+11−5
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+9−5 squeal-postgresql/test/DocTest.hs+2
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+9−5
@@ -117,8 +117,12 @@ backslashes within the value must be escaped with a backslash, i.e., ' and \.
117117
118118To specify the schema you wish to connect with, use type application.
119119
120−>>> :set -XTypeApplication
121−>>> conn <- connectdb @MySchema "host=localhost port=5432 dbname=exampledb"
120+>>> :set -XDataKinds
121+>>> :set -XTypeOperators
122+>>> type Schema = '["tab" ::: '["col" ::: 'Required ('Null 'PGint2)]]
123+>>> :set -XTypeApplications
124+>>> :set -XOverloadedStrings
125+>>> conn <- connectdb @Schema "host=localhost port=5432 dbname=exampledb"
122126
123127Note that, for now, squeal doesn't offer any protection from connecting
124128with the wrong schema!
@@ -193,7 +197,7 @@ pqThen pq2 pq1 = pq1 & pqBind (\ _ -> pq2)
193197
194198-- | Run a `Definition` with `LibPQ.exec`, we expect that libpq obeys the law
195199--
196−-- prop> pqThen (define statement2) statement1 = define (statement2 . statement1)
200+-- @pqThen (define statement2) statement1 = define (statement2 . statement1)@
197201define
198202 :: MonadBase IO io
199203 => Definition schema0 schema1
@@ -462,8 +466,8 @@ newtype RowNumber = RowNumber { unRowNumber :: LibPQ.Row }
462466newtype ColumnNumber (n :: Nat) (cs :: [k]) (c :: k) =
463467 UnsafeColumnNumber { getColumnNumber :: LibPQ.Column }
464468
465−-- | >>> getColumnNumber (columnNumber @5)
466−-- 5
469+-- | >>> getColumnNumber (columnNumber @5 @'[_,_,_,_,_,_])
470+-- Col 5
467471class KnownNat n => HasColumnNumber n columns column
468472 | n columns -> column where
469473 columnNumber :: ColumnNumber n columns column
squeal-postgresql/test/DocTest.hs+2
@@ -9,4 +9,6 @@ main = doctest
99 , "src/Squeal/PostgreSQL/Definition.hs"
1010 , "src/Squeal/PostgreSQL/Manipulation.hs"
1111 , "src/Squeal/PostgreSQL/Query.hs"
12+ , "src/Squeal/PostgreSQL/Expression.hs"
13+ , "src/Squeal/PostgreSQL/PQ.hs"
1214 ]