@@ -13,6 +13,7 @@ Instances are governed by the `Generic` and `HasDatatype` typeclasses.
13>>> import Control.Monad.Base
13>>> import Control.Monad.Base
15>>> import Squeal.PostgreSQL
15>>> import Squeal.PostgreSQL
16+>>> import qualified Squeal.PostgreSQL as SQL
17>>> data Schwarma = Beef | Lamb | Chicken deriving (Show, GHC.Generic)
18>>> data Schwarma = Beef | Lamb | Chicken deriving (Show, GHC.Generic)
18>>> instance Generic Schwarma
19>>> instance Generic Schwarma
@@ -28,6 +29,7 @@ void . withConnection "host=localhost port=5432 dbname=exampledb" $ do
32+>>> :set -XTypeFamilies -XTypeInType -XUndecidableInstances
32type family Schema :: SchemaType where
34type family Schema :: SchemaType where
@@ -50,7 +52,7 @@ let
50 insertRow_ #tab (Set (param @1) `As` #col :* Nil)
52 insertRow_ #tab (Set (param @1) `As` #col :* Nil)
51 :: Manipulation Schema '[ 'NotNull (EnumWith Schwarma)] '[]
53 :: Manipulation Schema '[ 'NotNull (EnumWith Schwarma)] '[]
53− select (#col `As` #fromOnly :* Nil) (from (table #tab))
55+ select (#col `As` #fromOnly :* Nil) (SQL.from (table #tab))
54 :: Query Schema '[] '["fromOnly" ::: 'NotNull (EnumWith Schwarma)]
56 :: Query Schema '[] '["fromOnly" ::: 'NotNull (EnumWith Schwarma)]
55 session = do
57 session = do
56 manipulateParams manip (Only Chicken)
58 manipulateParams manip (Only Chicken)