Skip to content

Commit 9033bcb

Browse files
committed
Move to HVR's Only package for a common 1-tuple
1 parent c2e00bf commit 9033bcb

2 files changed

Lines changed: 2 additions & 17 deletions

File tree

postgresql-simple.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import Data.ByteString.Builder ( stringUtf8 )
4040
import qualified Data.ByteString as B
4141
import Data.Text (Text)
4242
import qualified Data.Text as T
43+
import Data.Tuple.Only (Only(..))
4344
import Database.PostgreSQL.LibPQ (Oid(..))
4445
import 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.

0 commit comments

Comments
 (0)