<div dir="ltr"><div><span style="font-size:13px">Thank you very much.  I have actually started to have a look at opaleye independently after the reddit discussion and I would like to experiment with it.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">I assume that I somehow have to declare my own </span>queryRunnerColumn for the array.  I am afraid that I did not understand the example so I was not able to generalise it.</div><span style="font-size:13px"><div><span style="font-size:13px"><br></span></div>Date: Fri, 26 Dec 2014 11:02:12 +0000</span><br style="font-size:13px"><span style="font-size:13px">From: Tom Ellis <</span><a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk" style="font-size:13px">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a><span style="font-size:13px">></span><br style="font-size:13px"><span style="font-size:13px">To: </span><a href="mailto:haskell-cafe@haskell.org" style="font-size:13px">haskell-cafe@haskell.org</a><br style="font-size:13px"><span style="font-size:13px">Subject: Re: [Haskell-cafe] Handling Postgresql array types</span><br style="font-size:13px"><span style="font-size:13px">Message-ID: <20141226110212.GJ31575@weber></span><br style="font-size:13px"><span style="font-size:13px">Content-Type: text/plain; charset=us-ascii</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">On Fri, Dec 26, 2014 at 10:52:46AM +0000, Tom Ellis wrote:</span><br style="font-size:13px"><span style="font-size:13px">> On Fri, Dec 26, 2014 at 02:36:07PM +1100, Riaan wrote:</span><br style="font-size:13px"><span style="font-size:13px">> > So went back to HDBC.  But now my queries are starting to get fairly long</span><br style="font-size:13px"><span style="font-size:13px">> > and I have been looking at libraries like Persistent with Esqualeto,</span><br style="font-size:13px"><span style="font-size:13px">> > HaskellDB and Groundhog to make my queries a little more composable and</span><br style="font-size:13px"><span style="font-size:13px">> > type safe.</span><br style="font-size:13px"><span style="font-size:13px">></span><br style="font-size:13px"><span style="font-size:13px">> Don't forget to look at Opaleye too :)  It doesn't really have much support</span><br style="font-size:13px"><span style="font-size:13px">> for arrays at the moment, but if you let me know what you want to do I'm</span><br style="font-size:13px"><span style="font-size:13px">> happy to help you.</span><br style="font-size:13px"><span style="font-size:13px">></span><br style="font-size:13px"><span style="font-size:13px">> > So to my question.  Does anyone have experience with one of these libraries</span><br style="font-size:13px"><span style="font-size:13px">> > in dealing with postgresql arrays</span><br style="font-size:13px"><span style="font-size:13px">></span><br style="font-size:13px"><span style="font-size:13px">> postgresql-simple has</span><br style="font-size:13px"><span style="font-size:13px">></span><br style="font-size:13px"><span style="font-size:13px">>     instance (FromField a, Typeable a) => FromField (PGArray a)</span><br style="font-size:13px"><span style="font-size:13px">></span><br style="font-size:13px"><span style="font-size:13px">> Does that not do exactly what you want?</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">import Database.PostgreSQL.Simple (query_, ConnectInfo(..), connect, Only)</span><br style="font-size:13px"><span style="font-size:13px">import Database.PostgreSQL.Simple.</span><span style="font-size:13px">Types (PGArray)</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">import Data.String (fromString)</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">connectInfo :: ConnectInfo</span><br style="font-size:13px"><span style="font-size:13px">connectInfo =  ConnectInfo { connectHost = "localhost"</span><br style="font-size:13px"><span style="font-size:13px">                           , connectPort = 25433</span><br style="font-size:13px"><span style="font-size:13px">                           , connectUser = "tom"</span><br style="font-size:13px"><span style="font-size:13px">                           , connectPassword = "tom"</span><br style="font-size:13px"><span style="font-size:13px">                           , connectDatabase = "opaleye_test" }</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">arrayQuery :: String</span><br style="font-size:13px"><span style="font-size:13px">arrayQuery = "select '{{1,2}, {3,4}}' :: integer[][]"</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">main :: IO ()</span><br style="font-size:13px"><span style="font-size:13px">main = do</span><br style="font-size:13px"><span style="font-size:13px">  conn <- connect connectInfo</span><br style="font-size:13px"><span style="font-size:13px">  results <- query_ conn (fromString arrayQuery) :: IO [Only (PGArray (PGArray Int))]</span><br style="font-size:13px"><span style="font-size:13px">  print results</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">-- Output</span><br style="font-size:13px"><span style="font-size:13px">--</span><br style="font-size:13px"><span style="font-size:13px">-- ghci> main</span><br style="font-size:13px"><span style="font-size:13px">-- [Only {fromOnly = PGArray {fromPGArray = [PGArray {fromPGArray = [1,2]},PGArray {fromPGArray = [3,4]}]}}]</span></div>