on dev help sign in
doctest setup
commite883295bc859cc37999b0582f6f97bd66a44710a authorEitan Chatav <eitan@Eitans-MacBook-Pro.local> dateSat 6 Apr 2019, 13:41 (8 years ago) parent6f1f957
3 files changed+17−8
squeal-postgresql/src/Squeal/PostgreSQL/Alias.hs+4−2 squeal-postgresql/src/Squeal/PostgreSQL/PG.hs+10−6 squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+3
squeal-postgresql/src/Squeal/PostgreSQL/Alias.hs+4−2
@@ -51,6 +51,9 @@ import qualified GHC.Generics as GHC
5151
5252import Squeal.PostgreSQL.Render
5353
54+-- $setup
55+-- >>> import Squeal.PostgreSQL
56+
5457-- | The alias operator `:::` is like a promoted version of `As`,
5558-- a type level pair between an alias and some type.
5659type (:::) (alias :: Symbol) ty = '(alias,ty)
@@ -95,8 +98,7 @@ instance aliases ~ '[alias] => IsLabel alias (SOP.NP Alias aliases) where
9598instance KnownSymbol alias => RenderSQL (Alias alias) where
9699 renderSQL = doubleQuoted . fromString . symbolVal
97100
98−-- | >>> import Generics.SOP (SOP.NP(..))
99−-- >>> printSQL (#jimbob SOP.:* #kandi :: SOP.NP Alias '["jimbob", "kandi"])
101+-- >>> printSQL (#jimbob :* #kandi :: NP Alias '["jimbob", "kandi"])
100102-- "jimbob", "kandi"
101103instance SOP.All KnownSymbol aliases => RenderSQL (SOP.NP Alias aliases) where
102104 renderSQL
squeal-postgresql/src/Squeal/PostgreSQL/PG.hs+10−6
@@ -73,6 +73,10 @@ import Squeal.PostgreSQL.Alias
7373import Squeal.PostgreSQL.List
7474import Squeal.PostgreSQL.Schema
7575
76+-- $setup
77+-- >>> import Squeal.PostgreSQL
78+-- >>> import Data.Text (Text)
79+
7680{- | The `PG` type family embeds a subset of Haskell types
7781as Postgres types. As an open type family, `PG` is extensible.
7882
@@ -115,8 +119,8 @@ type instance PG Value = 'PGjson
115119Haskell enum type.
116120
117121>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
118−>>> instance Generic Schwarma
119−>>> instance HasDatatypeInfo Schwarma
122+>>> instance SOP.Generic Schwarma
123+>>> instance SOP.HasDatatypeInfo Schwarma
120124>>> :kind! LabelsPG Schwarma
121125LabelsPG Schwarma :: [Type.ConstructorName]
122126= '["Beef", "Lamb", "Chicken"]
@@ -132,8 +136,8 @@ type family LabelsPG (hask :: Type) :: [Type.ConstructorName] where
132136have the `Generic` and `HasDatatypeInfo` instances;
133137
134138>>> data Person = Person { name :: Text, age :: Int32 } deriving GHC.Generic
135−>>> instance Generic Person
136−>>> instance HasDatatypeInfo Person
139+>>> instance SOP.Generic Person
140+>>> instance SOP.HasDatatypeInfo Person
137141>>> :kind! RowPG Person
138142RowPG Person :: [(Symbol, NullityType)]
139143= '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]
@@ -180,8 +184,8 @@ type family ColumnsOf (record :: [(Symbol, Type)]) :: ColumnsType where
180184have the `Generic` and `HasDatatypeInfo` instances;
181185
182186>>> data Person = Person { name :: Text, age :: Int32 } deriving GHC.Generic
183−>>> instance Generic Person
184−>>> instance HasDatatypeInfo Person
187+>>> instance SOP.Generic Person
188+>>> instance SOP.HasDatatypeInfo Person
185189>>> :kind! Entity Person
186190Entity Person :: [(Symbol, (ColumnConstraint, NullityType))]
187191= '["name" ::: ('NoDef :=> 'NotNull 'PGtext),
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+3
@@ -103,6 +103,9 @@ import qualified Control.Monad.Trans.Writer.Strict as Strict
103103import qualified Control.Monad.Trans.RWS.Lazy as Lazy
104104import qualified Control.Monad.Trans.RWS.Strict as Strict
105105
106+-- $setup
107+-- >>> import Squeal.PostgreSQL
108+
106109{- | Makes a new connection to the database server.
107110
108111This function opens a new database connection using the parameters taken