11module Test.Main where
22
3+ import Prelude
34import Control.Monad.Eff.Console as C
45import Control.Monad.Aff (Aff , apathize , attempt , runAff )
5- import Control.Monad.Aff.Console (log , print )
6+ import Control.Monad.Aff.Console (log , logShow )
67import Control.Monad.Eff (Eff )
78import Control.Monad.Eff.Class (liftEff )
89import Control.Monad.Eff.Console (CONSOLE )
@@ -15,11 +16,10 @@ import Data.Maybe (Maybe)
1516import Database.Postgres (DB , Query (Query), queryOne_ , execute_ , withConnection , query , withClient , end , query_ , connect , queryValue_ , disconnect , mkConnectionString )
1617import Database.Postgres.SqlValue (toSql )
1718import Database.Postgres.Transaction (withTransaction )
18- import Prelude (class Show , Unit , return , ($), bind , show , (<>), void , flip , (>>>), const )
1919
2020main :: forall eff . Eff ( console :: CONSOLE , db :: DB | eff ) Unit
21- main = runAff C .print (const $ C .log " All ok" ) $ do
22- print $ " connecting to " <> mkConnectionString connectionInfo <> " ..."
21+ main = runAff C .logShow (const $ C .log " All ok" ) $ do
22+ logShow $ " connecting to " <> mkConnectionString connectionInfo <> " ..."
2323 exampleUsingWithConnection
2424 exampleLowLevel
2525
@@ -51,7 +51,7 @@ exampleUsingWithConnection = withConnection connectionInfo $ \c -> do
5151 execute_ (Query " insert into artist values ('Led Zeppelin', 1968)" ) c
5252 execute_ (Query " insert into artist values ('Deep Purple', 1968)" ) c
5353 year <- queryValue_ (Query " insert into artist values ('Fairport Convention', 1967) returning year" :: Query Number ) c
54- print (show year)
54+ logShow (show year)
5555 artists <- query_ (Query " select * from artist" :: Query Artist ) c
5656 printRows artists
5757
@@ -83,7 +83,7 @@ exampleTransaction = withConnection connectionInfo $ \c -> do
8383 execute_ (Query " delete from artist" ) c
8484 apathize $ tryInsert c
8585 one <- queryOne_ (Query " select * from artist" :: Query Artist ) c
86- void $ print one
86+ void $ logShow one
8787 where
8888 tryInsert = withTransaction $ \c -> do
8989 execute_ (Query " insert into artist values ('Not there', 1999)" ) c
@@ -100,4 +100,4 @@ instance artistIsForeign :: IsForeign Artist where
100100 read obj = do
101101 n <- readProp " name" obj
102102 y <- readProp " year" obj
103- return $ Artist { name: n, year: y }
103+ pure $ Artist { name: n, year: y }
0 commit comments