on dev help sign in
doctest setup
e883295Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Alias.hs+4−2
@@ -51,6 +51,9 @@ import qualified GHC.Generics as GHC
51
51
52import Squeal.PostgreSQL.Render
52import Squeal.PostgreSQL.Render
53
53
54+-- $setup
55+-- >>> import Squeal.PostgreSQL
56+
54-- | The alias operator `:::` is like a promoted version of `As`,
57-- | The alias operator `:::` is like a promoted version of `As`,
55-- a type level pair between an alias and some type.
58-- a type level pair between an alias and some type.
56type (:::) (alias :: Symbol) ty = '(alias,ty)
59type (:::) (alias :: Symbol) ty = '(alias,ty)
@@ -95,8 +98,7 @@ instance aliases ~ '[alias] => IsLabel alias (SOP.NP Alias aliases) where
95instance KnownSymbol alias => RenderSQL (Alias alias) where
98instance KnownSymbol alias => RenderSQL (Alias alias) where
96 renderSQL = doubleQuoted . fromString . symbolVal
99 renderSQL = doubleQuoted . fromString . symbolVal
97
100
98−-- | >>> import Generics.SOP (SOP.NP(..))
99−-- >>> printSQL (#jimbob SOP.:* #kandi :: SOP.NP Alias '["jimbob", "kandi"])
101+-- >>> printSQL (#jimbob :* #kandi :: NP Alias '["jimbob", "kandi"])
100-- "jimbob", "kandi"
102-- "jimbob", "kandi"
101instance SOP.All KnownSymbol aliases => RenderSQL (SOP.NP Alias aliases) where
103instance SOP.All KnownSymbol aliases => RenderSQL (SOP.NP Alias aliases) where
102 renderSQL
104 renderSQL
squeal-postgresql/src/Squeal/PostgreSQL/PG.hs+10−6
@@ -73,6 +73,10 @@ import Squeal.PostgreSQL.Alias
73import Squeal.PostgreSQL.List
73import Squeal.PostgreSQL.List
74import Squeal.PostgreSQL.Schema
74import Squeal.PostgreSQL.Schema
75
75
76+-- $setup
77+-- >>> import Squeal.PostgreSQL
78+-- >>> import Data.Text (Text)
79+
76{- | The `PG` type family embeds a subset of Haskell types
80{- | The `PG` type family embeds a subset of Haskell types
77as Postgres types. As an open type family, `PG` is extensible.
81as Postgres types. As an open type family, `PG` is extensible.
78
82
@@ -115,8 +119,8 @@ type instance PG Value = 'PGjson
115Haskell enum type.
119Haskell enum type.
116
120
117>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
121>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
118−>>> instance Generic Schwarma
122+>>> instance SOP.Generic Schwarma
119−>>> instance HasDatatypeInfo Schwarma
123+>>> instance SOP.HasDatatypeInfo Schwarma
120>>> :kind! LabelsPG Schwarma
124>>> :kind! LabelsPG Schwarma
121LabelsPG Schwarma :: [Type.ConstructorName]
125LabelsPG Schwarma :: [Type.ConstructorName]
122= '["Beef", "Lamb", "Chicken"]
126= '["Beef", "Lamb", "Chicken"]
@@ -132,8 +136,8 @@ type family LabelsPG (hask :: Type) :: [Type.ConstructorName] where
132have the `Generic` and `HasDatatypeInfo` instances;
136have the `Generic` and `HasDatatypeInfo` instances;
133
137
134>>> data Person = Person { name :: Text, age :: Int32 } deriving GHC.Generic
138>>> data Person = Person { name :: Text, age :: Int32 } deriving GHC.Generic
135−>>> instance Generic Person
139+>>> instance SOP.Generic Person
136−>>> instance HasDatatypeInfo Person
140+>>> instance SOP.HasDatatypeInfo Person
137>>> :kind! RowPG Person
141>>> :kind! RowPG Person
138RowPG Person :: [(Symbol, NullityType)]
142RowPG Person :: [(Symbol, NullityType)]
139= '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]
143= '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]
@@ -180,8 +184,8 @@ type family ColumnsOf (record :: [(Symbol, Type)]) :: ColumnsType where
180have the `Generic` and `HasDatatypeInfo` instances;
184have the `Generic` and `HasDatatypeInfo` instances;
181
185
182>>> data Person = Person { name :: Text, age :: Int32 } deriving GHC.Generic
186>>> data Person = Person { name :: Text, age :: Int32 } deriving GHC.Generic
183−>>> instance Generic Person
187+>>> instance SOP.Generic Person
184−>>> instance HasDatatypeInfo Person
188+>>> instance SOP.HasDatatypeInfo Person
185>>> :kind! Entity Person
189>>> :kind! Entity Person
186Entity Person :: [(Symbol, (ColumnConstraint, NullityType))]
190Entity Person :: [(Symbol, (ColumnConstraint, NullityType))]
187= '["name" ::: ('NoDef :=> 'NotNull 'PGtext),
191= '["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
103import qualified Control.Monad.Trans.RWS.Lazy as Lazy
103import qualified Control.Monad.Trans.RWS.Lazy as Lazy
104import qualified Control.Monad.Trans.RWS.Strict as Strict
104import qualified Control.Monad.Trans.RWS.Strict as Strict
105
105
106+-- $setup
107+-- >>> import Squeal.PostgreSQL
108+
106{- | Makes a new connection to the database server.
109{- | Makes a new connection to the database server.
107
110
108This function opens a new database connection using the parameters taken
111This function opens a new database connection using the parameters taken