on dev help sign in
unscope my heart
commitdcb0870921e1cfe4c7d92d3c3499a85197903fba authorEitan Chatav <eitan.chatav@gmail.com> dateSun 6 Aug 2017, 13:50 (9 years ago) parentea4c7e5
2 files changed+7−8
squeel-postgresql/exe/Example.hs+5−7 squeel-postgresql/src/Squeel/PostgreSQL/PQ.hs+2−1
squeel-postgresql/exe/Example.hs+5−7
@@ -1,9 +1,7 @@
11{-# LANGUAGE
22 DataKinds
3− , MagicHash
43 , OverloadedLabels
54 , OverloadedStrings
6− , ScopedTypeVariables
75 , TypeApplications
86 , TypeOperators
97#-}
@@ -29,9 +27,9 @@ main = do
2927 connectionString <- pure
3028 "host=localhost port=5432 dbname=exampledb"
3129 Char8.putStrLn $ "connecting to " <> connectionString
32− connection0 :: Connection '[] <- connectdb connectionString
30+ connection0 <- connectdb connectionString
3331 Char8.putStrLn "setting up database"
34− connection1 :: Connection Tables <- flip execPQ connection0 $ pqExec $
32+ connection1 <- flip execPQ (connection0 :: Connection '[]) $ pqExec $
3533 createTable #students
3634 ( (text & notNull) `As` #name
3735 :* Nil )
@@ -41,7 +39,7 @@ main = do
4139 :* (int4 & notNull) `As` #col2
4240 :* Nil )
4341 Char8.putStrLn "querying"
44− connection2 :: Connection Tables <- flip execPQ connection1 $ do
42+ connection2 <- flip execPQ (connection1 :: Connection Tables) $ do
4543 for_ [I i :* I (i+1) :* Nil | i <- [1::Int32,3..9]] $ pqExecParams
4644 (insertInto #table1 (param1 `As` #col1 :* param2 `As` #col2 :* Nil))
4745 Just result <- pqExecNil . query $
@@ -61,9 +59,9 @@ main = do
6159 print (row0 :: NP I '[Int32,Int32])
6260 print (row1 :: NP I '[Int32,Int32])
6361 Char8.putStrLn "tearing down database"
64− connection3 :: Connection '[] <- flip execPQ connection2 $ pqExec $
62+ connection3 <- flip execPQ (connection2 :: Connection Tables) $ pqExec $
6563 dropTable #table1 >>> dropTable #students
66− finish connection3
64+ finish (connection3 :: Connection '[])
6765
6866type Columns =
6967 '[ "col1" ::: 'Required ('NotNull 'PGInt4)
squeel-postgresql/src/Squeel/PostgreSQL/PQ.hs+2−1
@@ -38,7 +38,8 @@ import Squeel.PostgreSQL.Binary
3838import Squeel.PostgreSQL.Statement
3939import Squeel.PostgreSQL.Schema
4040
41−newtype Connection db = Connection { unConnection :: LibPQ.Connection }
41+newtype Connection (db :: [(Symbol,[(Symbol,ColumnType)])]) =
42+ Connection { unConnection :: LibPQ.Connection }
4243
4344newtype PQ
4445 (db0 :: [(Symbol,[(Symbol,ColumnType)])])