@@ -1,5 +1,6 @@
11{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, GeneralizedNewtypeDeriving #-}
22
3+------------------------------------------------------------------------------
34-- |
45-- Module: Database.PostgreSQL.Simple.Types
56-- Copyright: (c) 2011 MailRank, Inc.
@@ -10,6 +11,8 @@
1011-- Portability: portable
1112--
1213-- Basic types.
14+--
15+------------------------------------------------------------------------------
1316
1417module Database.PostgreSQL.Simple.Types
1518 (
@@ -19,6 +22,7 @@ module Database.PostgreSQL.Simple.Types
1922 , Binary(..)
2023 , Query(..)
2124 , Oid(..)
25+ , (:.)(..)
2226 ) where
2327
2428import Blaze.ByteString.Builder (toByteString)
@@ -106,3 +110,23 @@ newtype In a = In a
106110-- | Wrap a mostly-binary string to be escaped in hexadecimal.
107111newtype Binary a = Binary a
108112 deriving (Eq, Ord, Read, Show, Typeable, Functor)
113+
114+-- | A composite type to parse your custom data structures without
115+-- having to define dummy newtype wrappers every time.
116+--
117+--
118+-- > instance FromRow MyData where ...
119+--
120+-- > instance FromRow MyData2 where ...
121+--
122+--
123+-- then I can do the following for free:
124+--
125+-- @
126+-- res <- query' c "..."
127+-- forM res $ \\(MyData{..} :. MyData2{..}) -> do
128+-- ....
129+-- @
130+data h :. t = h :. t deriving (Eq,Ord,Show,Read,Typeable)
131+
132+infixr 3 :.