@@ -1,5 +1,6 @@
1{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
1{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
3+------------------------------------------------------------------------------
4-- Module: Database.PostgreSQL.Simple.Types
5-- Module: Database.PostgreSQL.Simple.Types
5-- Copyright: (c) 2011 MailRank, Inc.
6-- Copyright: (c) 2011 MailRank, Inc.
@@ -10,6 +11,8 @@
10-- Portability: portable
11-- Portability: portable
12-- Basic types.
13-- Basic types.
15+------------------------------------------------------------------------------
14module Database.PostgreSQL.Simple.Types
17module Database.PostgreSQL.Simple.Types
@@ -19,6 +22,7 @@ module Database.PostgreSQL.Simple.Types
19 , Binary(..)
22 , Binary(..)
20 , Query(..)
23 , Query(..)
24import Blaze.ByteString.Builder (toByteString)
28import Blaze.ByteString.Builder (toByteString)
@@ -106,3 +110,23 @@ newtype In a = In a
106-- | Wrap a mostly-binary string to be escaped in hexadecimal.
110-- | Wrap a mostly-binary string to be escaped in hexadecimal.
107newtype Binary a = Binary a
111newtype Binary a = Binary a
108 deriving (Eq, Ord, Read, Show, Typeable, Functor)
112 deriving (Eq, Ord, Read, Show, Typeable, Functor)
114+-- | A composite type to parse your custom data structures without
115+-- having to define dummy newtype wrappers every time.
118+-- > instance FromRow MyData where ...
120+-- > instance FromRow MyData2 where ...
123+-- then I can do the following for free:
126+-- res <- query' c "..."
127+-- forM res $ \\(MyData{..} :. MyData2{..}) -> do
130+data h :. t = h :. t deriving (Eq,Ord,Show,Read,Typeable)