git.iko.soy/typeable/postgresql-simple
on master help sign in
Move to HVR's Only package for a common 1-tuple
commit9033bcbe30347a3a9c57624a26d51ea873f74ed2 authorLeon P Smith <leon@melding-monads.com> dateThu 22 Jun 2017, 23:49 (9 years ago) parentc2e00bf
2 files changed+2−17
postgresql-simple.cabal+1 src/Database/PostgreSQL/Simple/Types.hs+1−17
postgresql-simple.cabal+1
@@ -65,6 +65,7 @@ Library
6565 case-insensitive,
6666 containers,
6767 hashable,
68+ Only,
6869 postgresql-libpq >= 0.9 && < 0.10,
6970 template-haskell,
7071 text >= 0.11.1,
src/Database/PostgreSQL/Simple/Types.hs+1−17
@@ -40,6 +40,7 @@ import Data.ByteString.Builder ( stringUtf8 )
4040import qualified Data.ByteString as B
4141import Data.Text (Text)
4242import qualified Data.Text as T
43+import Data.Tuple.Only (Only(..))
4344import Database.PostgreSQL.LibPQ (Oid(..))
4445import Database.PostgreSQL.Simple.Compat (toByteString)
4546
@@ -93,23 +94,6 @@ instance Monoid Query where
9394 {-# INLINE mappend #-}
9495 mconcat xs = Query (B.concat (map fromQuery xs))
9596
96−-- | A single-value \"collection\".
97−--
98−-- This is useful if you need to supply a single parameter to a SQL
99−-- query, or extract a single column from a SQL result.
100−--
101−-- Parameter example:
102−--
103−-- @query c \"select x from scores where x > ?\" ('Only' (42::Int))@
104−--
105−-- Result example:
106−--
107−-- @xs <- query_ c \"select id from users\"
108−--forM_ xs $ \\('Only' id) -> {- ... -}@
109−newtype Only a = Only {
110− fromOnly :: a
111− } deriving (Eq, Ord, Read, Show, Typeable, Functor)
112−
11397-- | Wrap a list of values for use in an @IN@ clause. Replaces a
11498-- single \"@?@\" character with a parenthesized list of rendered
11599-- values.