on dev help sign in
Fix doctest
commit41b0c5ebe4c517a5e4cf8c597f7cda2a40bc3d04 authorChShersh <dmitrii@holmusk.com> dateMon 25 Mar 2019, 13:10 (8 years ago) parent9f5cfb1
4 files changed+18−18
README.md+5−5 squeal-postgresql/src/Squeal/PostgreSQL.hs+6−6 squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+6−6 squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+1−1
README.md+5−5
@@ -80,7 +80,7 @@ We'll need some imports.
8080
8181```Haskell
8282>>> import Control.Monad (void)
83−>>> import Control.Monad.Base (liftBase)
83+>>> import Control.Monad.IO.Class (liftIO)
8484>>> import Data.Int (Int32)
8585>>> import Data.Text (Text)
8686>>> import Squeal.PostgreSQL
@@ -128,7 +128,7 @@ yielding a `TableType`, or to pair a `ColumnConstraint` with a `NullityType`,
128128yielding a `ColumnType`. It is intended to connote Haskell's `=>` operator
129129
130130Next, we'll write `Definition`s to set up and tear down the schema. In
131−Squeal, a `Definition` like `createTable`, `alterTable` or `dropTable`
131+Squeal, a `Definition` like `createTable`, `alterTable` or `dropTable`
132132has two type parameters, corresponding to the schema
133133before being run and the schema after. We can compose definitions using `>>>`.
134134Here and in the rest of our commands we make use of overloaded
@@ -138,7 +138,7 @@ labels to refer to named tables and columns in our schema.
138138>>> :{
139139let
140140 setup :: Definition '[] Schema
141− setup =
141+ setup =
142142 createTable #users
143143 ( serial `as` #id :*
144144 (text & notNullable) `as` #name )
@@ -254,7 +254,7 @@ Let's also create some users to add to the database.
254254>>> :{
255255let
256256 users :: [User]
257− users =
257+ users =
258258 [ User "Alice" (Just "alice@gmail.com")
259259 , User "Bob" Nothing
260260 , User "Carole" (Just "carole@hotmail.com")
@@ -280,7 +280,7 @@ let
280280 traversePrepared_ insertEmail (zip (ids :: [Int32]) (userEmail <$> users))
281281 usersResult <- runQuery getUsers
282282 usersRows <- getRows usersResult
283− liftBase $ print (usersRows :: [User])
283+ liftIO $ print (usersRows :: [User])
284284in
285285 void . withConnection "host=localhost port=5432 dbname=exampledb" $
286286 define setup
squeal-postgresql/src/Squeal/PostgreSQL.hs+6−6
@@ -17,7 +17,7 @@ features.
1717We'll need some imports.
1818
1919>>> import Control.Monad (void)
20−>>> import Control.Monad.Base (liftBase)
20+>>> import Control.Monad.IO.Class (liftIO)
2121>>> import Data.Int (Int32)
2222>>> import Data.Text (Text)
2323>>> import Squeal.PostgreSQL
@@ -60,7 +60,7 @@ yielding a `TableType`, or to pair a `ColumnConstraint` with a `NullityType`,
6060yielding a `ColumnType`. It is intended to connote Haskell's @=>@ operator
6161
6262Next, we'll write `Definition`s to set up and tear down the schema. In
63−Squeal, a `Definition` like `createTable`, `alterTable` or `dropTable`
63+Squeal, a `Definition` like `createTable`, `alterTable` or `dropTable`
6464has two type parameters, corresponding to the schema
6565before being run and the schema after. We can compose definitions using `>>>`.
6666Here and in the rest of our commands we make use of overloaded
@@ -69,7 +69,7 @@ labels to refer to named tables and columns in our schema.
6969>>> :{
7070let
7171 setup :: Definition (Public '[]) Schemas
72− setup =
72+ setup =
7373 createTable #users
7474 ( serial `as` #id :*
7575 (text & notNullable) `as` #name )
@@ -119,7 +119,7 @@ We'll need a Haskell type for users. We give the type `Generics.SOP.Generic` and
119119`Generics.SOP.HasDatatypeInfo` instances so that we can decode the rows
120120we receive when we run @getUsers@. Notice that the record fields of the
121121@User@ type match the column names of @getUsers@.
122−
122+
123123>>> data User = User { userName :: Text, userEmail :: Maybe Text } deriving (Show, GHC.Generic)
124124>>> instance SOP.Generic User
125125>>> instance SOP.HasDatatypeInfo User
@@ -162,7 +162,7 @@ Let's create some users to add to the database.
162162>>> :{
163163let
164164 users :: [User]
165− users =
165+ users =
166166 [ User "Alice" (Just "alice@gmail.com")
167167 , User "Bob" Nothing
168168 , User "Carole" (Just "carole@hotmail.com")
@@ -184,7 +184,7 @@ let
184184 _ <- traversePrepared_ insertUser users
185185 usersResult <- runQuery getUsers
186186 usersRows <- getRows usersResult
187− liftBase $ print (usersRows :: [User])
187+ liftIO $ print (usersRows :: [User])
188188in
189189 void . withConnection "host=localhost port=5432 dbname=exampledb" $
190190 define setup
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+6−6
@@ -16,7 +16,7 @@ Let's see some examples. We'll need some imports
1616>>> import Data.Int (Int16)
1717>>> import Data.Text (Text)
1818>>> import Control.Monad (void)
19−>>> import Control.Monad.Base (liftBase)
19+>>> import Control.Monad.IO.Class (liftIO)
2020>>> import Squeal.PostgreSQL
2121
2222Define a Haskell datatype @Row@ that will serve as both the input and output of a simple
@@ -42,7 +42,7 @@ the input and output should be equal.
4242void . withConnection "host=localhost port=5432 dbname=exampledb" $ do
4343 result <- runQueryParams roundTrip input
4444 Just output <- firstRow result
45− liftBase . print $ input == output
45+ liftIO . print $ input == output
4646:}
4747True
4848
@@ -81,7 +81,7 @@ let
8181void . withConnection "host=localhost port=5432 dbname=exampledb" $ do
8282 result <- runQueryParams roundTrip input
8383 Just output <- firstRow result
84− liftBase . print $ input == output
84+ liftIO . print $ input == output
8585:}
8686True
8787
@@ -168,7 +168,7 @@ let
168168 session = do
169169 result <- runQueryParams roundTrip input
170170 Just output <- firstRow result
171− liftBase . print $ input == output
171+ liftIO . print $ input == output
172172in
173173 void . withConnection "host=localhost port=5432 dbname=exampledb" $
174174 define setup
@@ -723,7 +723,7 @@ of the number of cents, i.e. @$2,000.20@ would be expressed as
723723@Money { cents = 200020 }@.
724724
725725>>> import Control.Monad (void)
726−>>> import Control.Monad.Base (liftBase)
726+>>> import Control.Monad.IO.Class (liftIO)
727727>>> import Squeal.PostgreSQL
728728>>> :{
729729let
@@ -737,7 +737,7 @@ let
737737void . withConnection "host=localhost port=5432 dbname=exampledb" $ do
738738 result <- runQueryParams roundTrip input
739739 Just output <- firstRow result
740− liftBase . print $ input == output
740+ liftIO . print $ input == output
741741:}
742742True
743743-}
squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+1−1
@@ -73,7 +73,7 @@ let
7373 numMigrations = do
7474 result <- runQuery (select Star (from (table (#migrations ! #schema_migrations `as` #m))))
7575 num <- ntuples result
76− liftBase $ print num
76+ liftIO $ print num
7777:}
7878
7979>>> :{